mutation.go 463 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/batchmsg"
  11. "wechat-api/ent/contact"
  12. "wechat-api/ent/custom_types"
  13. "wechat-api/ent/label"
  14. "wechat-api/ent/labelrelationship"
  15. "wechat-api/ent/message"
  16. "wechat-api/ent/messagerecords"
  17. "wechat-api/ent/msg"
  18. "wechat-api/ent/predicate"
  19. "wechat-api/ent/server"
  20. "wechat-api/ent/sopnode"
  21. "wechat-api/ent/sopstage"
  22. "wechat-api/ent/soptask"
  23. "wechat-api/ent/wx"
  24. "entgo.io/ent"
  25. "entgo.io/ent/dialect/sql"
  26. )
  27. const (
  28. // Operation types.
  29. OpCreate = ent.OpCreate
  30. OpDelete = ent.OpDelete
  31. OpDeleteOne = ent.OpDeleteOne
  32. OpUpdate = ent.OpUpdate
  33. OpUpdateOne = ent.OpUpdateOne
  34. // Node types.
  35. TypeAgent = "Agent"
  36. TypeBatchMsg = "BatchMsg"
  37. TypeContact = "Contact"
  38. TypeLabel = "Label"
  39. TypeLabelRelationship = "LabelRelationship"
  40. TypeMessage = "Message"
  41. TypeMessageRecords = "MessageRecords"
  42. TypeMsg = "Msg"
  43. TypeServer = "Server"
  44. TypeSopNode = "SopNode"
  45. TypeSopStage = "SopStage"
  46. TypeSopTask = "SopTask"
  47. TypeWx = "Wx"
  48. )
  49. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  50. type AgentMutation struct {
  51. config
  52. op Op
  53. typ string
  54. id *uint64
  55. created_at *time.Time
  56. updated_at *time.Time
  57. deleted_at *time.Time
  58. name *string
  59. role *string
  60. status *int
  61. addstatus *int
  62. background *string
  63. examples *string
  64. organization_id *uint64
  65. addorganization_id *int64
  66. clearedFields map[string]struct{}
  67. wx_agent map[uint64]struct{}
  68. removedwx_agent map[uint64]struct{}
  69. clearedwx_agent bool
  70. done bool
  71. oldValue func(context.Context) (*Agent, error)
  72. predicates []predicate.Agent
  73. }
  74. var _ ent.Mutation = (*AgentMutation)(nil)
  75. // agentOption allows management of the mutation configuration using functional options.
  76. type agentOption func(*AgentMutation)
  77. // newAgentMutation creates new mutation for the Agent entity.
  78. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  79. m := &AgentMutation{
  80. config: c,
  81. op: op,
  82. typ: TypeAgent,
  83. clearedFields: make(map[string]struct{}),
  84. }
  85. for _, opt := range opts {
  86. opt(m)
  87. }
  88. return m
  89. }
  90. // withAgentID sets the ID field of the mutation.
  91. func withAgentID(id uint64) agentOption {
  92. return func(m *AgentMutation) {
  93. var (
  94. err error
  95. once sync.Once
  96. value *Agent
  97. )
  98. m.oldValue = func(ctx context.Context) (*Agent, error) {
  99. once.Do(func() {
  100. if m.done {
  101. err = errors.New("querying old values post mutation is not allowed")
  102. } else {
  103. value, err = m.Client().Agent.Get(ctx, id)
  104. }
  105. })
  106. return value, err
  107. }
  108. m.id = &id
  109. }
  110. }
  111. // withAgent sets the old Agent of the mutation.
  112. func withAgent(node *Agent) agentOption {
  113. return func(m *AgentMutation) {
  114. m.oldValue = func(context.Context) (*Agent, error) {
  115. return node, nil
  116. }
  117. m.id = &node.ID
  118. }
  119. }
  120. // Client returns a new `ent.Client` from the mutation. If the mutation was
  121. // executed in a transaction (ent.Tx), a transactional client is returned.
  122. func (m AgentMutation) Client() *Client {
  123. client := &Client{config: m.config}
  124. client.init()
  125. return client
  126. }
  127. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  128. // it returns an error otherwise.
  129. func (m AgentMutation) Tx() (*Tx, error) {
  130. if _, ok := m.driver.(*txDriver); !ok {
  131. return nil, errors.New("ent: mutation is not running in a transaction")
  132. }
  133. tx := &Tx{config: m.config}
  134. tx.init()
  135. return tx, nil
  136. }
  137. // SetID sets the value of the id field. Note that this
  138. // operation is only accepted on creation of Agent entities.
  139. func (m *AgentMutation) SetID(id uint64) {
  140. m.id = &id
  141. }
  142. // ID returns the ID value in the mutation. Note that the ID is only available
  143. // if it was provided to the builder or after it was returned from the database.
  144. func (m *AgentMutation) ID() (id uint64, exists bool) {
  145. if m.id == nil {
  146. return
  147. }
  148. return *m.id, true
  149. }
  150. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  151. // That means, if the mutation is applied within a transaction with an isolation level such
  152. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  153. // or updated by the mutation.
  154. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  155. switch {
  156. case m.op.Is(OpUpdateOne | OpDeleteOne):
  157. id, exists := m.ID()
  158. if exists {
  159. return []uint64{id}, nil
  160. }
  161. fallthrough
  162. case m.op.Is(OpUpdate | OpDelete):
  163. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  164. default:
  165. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  166. }
  167. }
  168. // SetCreatedAt sets the "created_at" field.
  169. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  170. m.created_at = &t
  171. }
  172. // CreatedAt returns the value of the "created_at" field in the mutation.
  173. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  174. v := m.created_at
  175. if v == nil {
  176. return
  177. }
  178. return *v, true
  179. }
  180. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  181. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  183. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  184. if !m.op.Is(OpUpdateOne) {
  185. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  186. }
  187. if m.id == nil || m.oldValue == nil {
  188. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  189. }
  190. oldValue, err := m.oldValue(ctx)
  191. if err != nil {
  192. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  193. }
  194. return oldValue.CreatedAt, nil
  195. }
  196. // ResetCreatedAt resets all changes to the "created_at" field.
  197. func (m *AgentMutation) ResetCreatedAt() {
  198. m.created_at = nil
  199. }
  200. // SetUpdatedAt sets the "updated_at" field.
  201. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  202. m.updated_at = &t
  203. }
  204. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  205. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  206. v := m.updated_at
  207. if v == nil {
  208. return
  209. }
  210. return *v, true
  211. }
  212. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  213. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  215. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  216. if !m.op.Is(OpUpdateOne) {
  217. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  218. }
  219. if m.id == nil || m.oldValue == nil {
  220. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  221. }
  222. oldValue, err := m.oldValue(ctx)
  223. if err != nil {
  224. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  225. }
  226. return oldValue.UpdatedAt, nil
  227. }
  228. // ResetUpdatedAt resets all changes to the "updated_at" field.
  229. func (m *AgentMutation) ResetUpdatedAt() {
  230. m.updated_at = nil
  231. }
  232. // SetDeletedAt sets the "deleted_at" field.
  233. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  234. m.deleted_at = &t
  235. }
  236. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  237. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  238. v := m.deleted_at
  239. if v == nil {
  240. return
  241. }
  242. return *v, true
  243. }
  244. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  245. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  247. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  248. if !m.op.Is(OpUpdateOne) {
  249. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  250. }
  251. if m.id == nil || m.oldValue == nil {
  252. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  253. }
  254. oldValue, err := m.oldValue(ctx)
  255. if err != nil {
  256. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  257. }
  258. return oldValue.DeletedAt, nil
  259. }
  260. // ClearDeletedAt clears the value of the "deleted_at" field.
  261. func (m *AgentMutation) ClearDeletedAt() {
  262. m.deleted_at = nil
  263. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  264. }
  265. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  266. func (m *AgentMutation) DeletedAtCleared() bool {
  267. _, ok := m.clearedFields[agent.FieldDeletedAt]
  268. return ok
  269. }
  270. // ResetDeletedAt resets all changes to the "deleted_at" field.
  271. func (m *AgentMutation) ResetDeletedAt() {
  272. m.deleted_at = nil
  273. delete(m.clearedFields, agent.FieldDeletedAt)
  274. }
  275. // SetName sets the "name" field.
  276. func (m *AgentMutation) SetName(s string) {
  277. m.name = &s
  278. }
  279. // Name returns the value of the "name" field in the mutation.
  280. func (m *AgentMutation) Name() (r string, exists bool) {
  281. v := m.name
  282. if v == nil {
  283. return
  284. }
  285. return *v, true
  286. }
  287. // OldName returns the old "name" field's value of the Agent entity.
  288. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  290. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  291. if !m.op.Is(OpUpdateOne) {
  292. return v, errors.New("OldName is only allowed on UpdateOne operations")
  293. }
  294. if m.id == nil || m.oldValue == nil {
  295. return v, errors.New("OldName requires an ID field in the mutation")
  296. }
  297. oldValue, err := m.oldValue(ctx)
  298. if err != nil {
  299. return v, fmt.Errorf("querying old value for OldName: %w", err)
  300. }
  301. return oldValue.Name, nil
  302. }
  303. // ResetName resets all changes to the "name" field.
  304. func (m *AgentMutation) ResetName() {
  305. m.name = nil
  306. }
  307. // SetRole sets the "role" field.
  308. func (m *AgentMutation) SetRole(s string) {
  309. m.role = &s
  310. }
  311. // Role returns the value of the "role" field in the mutation.
  312. func (m *AgentMutation) Role() (r string, exists bool) {
  313. v := m.role
  314. if v == nil {
  315. return
  316. }
  317. return *v, true
  318. }
  319. // OldRole returns the old "role" field's value of the Agent entity.
  320. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  322. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  323. if !m.op.Is(OpUpdateOne) {
  324. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  325. }
  326. if m.id == nil || m.oldValue == nil {
  327. return v, errors.New("OldRole requires an ID field in the mutation")
  328. }
  329. oldValue, err := m.oldValue(ctx)
  330. if err != nil {
  331. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  332. }
  333. return oldValue.Role, nil
  334. }
  335. // ResetRole resets all changes to the "role" field.
  336. func (m *AgentMutation) ResetRole() {
  337. m.role = nil
  338. }
  339. // SetStatus sets the "status" field.
  340. func (m *AgentMutation) SetStatus(i int) {
  341. m.status = &i
  342. m.addstatus = nil
  343. }
  344. // Status returns the value of the "status" field in the mutation.
  345. func (m *AgentMutation) Status() (r int, exists bool) {
  346. v := m.status
  347. if v == nil {
  348. return
  349. }
  350. return *v, true
  351. }
  352. // OldStatus returns the old "status" field's value of the Agent entity.
  353. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  355. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  356. if !m.op.Is(OpUpdateOne) {
  357. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  358. }
  359. if m.id == nil || m.oldValue == nil {
  360. return v, errors.New("OldStatus requires an ID field in the mutation")
  361. }
  362. oldValue, err := m.oldValue(ctx)
  363. if err != nil {
  364. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  365. }
  366. return oldValue.Status, nil
  367. }
  368. // AddStatus adds i to the "status" field.
  369. func (m *AgentMutation) AddStatus(i int) {
  370. if m.addstatus != nil {
  371. *m.addstatus += i
  372. } else {
  373. m.addstatus = &i
  374. }
  375. }
  376. // AddedStatus returns the value that was added to the "status" field in this mutation.
  377. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  378. v := m.addstatus
  379. if v == nil {
  380. return
  381. }
  382. return *v, true
  383. }
  384. // ClearStatus clears the value of the "status" field.
  385. func (m *AgentMutation) ClearStatus() {
  386. m.status = nil
  387. m.addstatus = nil
  388. m.clearedFields[agent.FieldStatus] = struct{}{}
  389. }
  390. // StatusCleared returns if the "status" field was cleared in this mutation.
  391. func (m *AgentMutation) StatusCleared() bool {
  392. _, ok := m.clearedFields[agent.FieldStatus]
  393. return ok
  394. }
  395. // ResetStatus resets all changes to the "status" field.
  396. func (m *AgentMutation) ResetStatus() {
  397. m.status = nil
  398. m.addstatus = nil
  399. delete(m.clearedFields, agent.FieldStatus)
  400. }
  401. // SetBackground sets the "background" field.
  402. func (m *AgentMutation) SetBackground(s string) {
  403. m.background = &s
  404. }
  405. // Background returns the value of the "background" field in the mutation.
  406. func (m *AgentMutation) Background() (r string, exists bool) {
  407. v := m.background
  408. if v == nil {
  409. return
  410. }
  411. return *v, true
  412. }
  413. // OldBackground returns the old "background" field's value of the Agent entity.
  414. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  416. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  417. if !m.op.Is(OpUpdateOne) {
  418. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  419. }
  420. if m.id == nil || m.oldValue == nil {
  421. return v, errors.New("OldBackground requires an ID field in the mutation")
  422. }
  423. oldValue, err := m.oldValue(ctx)
  424. if err != nil {
  425. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  426. }
  427. return oldValue.Background, nil
  428. }
  429. // ClearBackground clears the value of the "background" field.
  430. func (m *AgentMutation) ClearBackground() {
  431. m.background = nil
  432. m.clearedFields[agent.FieldBackground] = struct{}{}
  433. }
  434. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  435. func (m *AgentMutation) BackgroundCleared() bool {
  436. _, ok := m.clearedFields[agent.FieldBackground]
  437. return ok
  438. }
  439. // ResetBackground resets all changes to the "background" field.
  440. func (m *AgentMutation) ResetBackground() {
  441. m.background = nil
  442. delete(m.clearedFields, agent.FieldBackground)
  443. }
  444. // SetExamples sets the "examples" field.
  445. func (m *AgentMutation) SetExamples(s string) {
  446. m.examples = &s
  447. }
  448. // Examples returns the value of the "examples" field in the mutation.
  449. func (m *AgentMutation) Examples() (r string, exists bool) {
  450. v := m.examples
  451. if v == nil {
  452. return
  453. }
  454. return *v, true
  455. }
  456. // OldExamples returns the old "examples" field's value of the Agent entity.
  457. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  458. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  459. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  460. if !m.op.Is(OpUpdateOne) {
  461. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  462. }
  463. if m.id == nil || m.oldValue == nil {
  464. return v, errors.New("OldExamples requires an ID field in the mutation")
  465. }
  466. oldValue, err := m.oldValue(ctx)
  467. if err != nil {
  468. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  469. }
  470. return oldValue.Examples, nil
  471. }
  472. // ClearExamples clears the value of the "examples" field.
  473. func (m *AgentMutation) ClearExamples() {
  474. m.examples = nil
  475. m.clearedFields[agent.FieldExamples] = struct{}{}
  476. }
  477. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  478. func (m *AgentMutation) ExamplesCleared() bool {
  479. _, ok := m.clearedFields[agent.FieldExamples]
  480. return ok
  481. }
  482. // ResetExamples resets all changes to the "examples" field.
  483. func (m *AgentMutation) ResetExamples() {
  484. m.examples = nil
  485. delete(m.clearedFields, agent.FieldExamples)
  486. }
  487. // SetOrganizationID sets the "organization_id" field.
  488. func (m *AgentMutation) SetOrganizationID(u uint64) {
  489. m.organization_id = &u
  490. m.addorganization_id = nil
  491. }
  492. // OrganizationID returns the value of the "organization_id" field in the mutation.
  493. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  494. v := m.organization_id
  495. if v == nil {
  496. return
  497. }
  498. return *v, true
  499. }
  500. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  501. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  503. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  504. if !m.op.Is(OpUpdateOne) {
  505. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  506. }
  507. if m.id == nil || m.oldValue == nil {
  508. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  509. }
  510. oldValue, err := m.oldValue(ctx)
  511. if err != nil {
  512. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  513. }
  514. return oldValue.OrganizationID, nil
  515. }
  516. // AddOrganizationID adds u to the "organization_id" field.
  517. func (m *AgentMutation) AddOrganizationID(u int64) {
  518. if m.addorganization_id != nil {
  519. *m.addorganization_id += u
  520. } else {
  521. m.addorganization_id = &u
  522. }
  523. }
  524. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  525. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  526. v := m.addorganization_id
  527. if v == nil {
  528. return
  529. }
  530. return *v, true
  531. }
  532. // ResetOrganizationID resets all changes to the "organization_id" field.
  533. func (m *AgentMutation) ResetOrganizationID() {
  534. m.organization_id = nil
  535. m.addorganization_id = nil
  536. }
  537. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  538. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  539. if m.wx_agent == nil {
  540. m.wx_agent = make(map[uint64]struct{})
  541. }
  542. for i := range ids {
  543. m.wx_agent[ids[i]] = struct{}{}
  544. }
  545. }
  546. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  547. func (m *AgentMutation) ClearWxAgent() {
  548. m.clearedwx_agent = true
  549. }
  550. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  551. func (m *AgentMutation) WxAgentCleared() bool {
  552. return m.clearedwx_agent
  553. }
  554. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  555. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  556. if m.removedwx_agent == nil {
  557. m.removedwx_agent = make(map[uint64]struct{})
  558. }
  559. for i := range ids {
  560. delete(m.wx_agent, ids[i])
  561. m.removedwx_agent[ids[i]] = struct{}{}
  562. }
  563. }
  564. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  565. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  566. for id := range m.removedwx_agent {
  567. ids = append(ids, id)
  568. }
  569. return
  570. }
  571. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  572. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  573. for id := range m.wx_agent {
  574. ids = append(ids, id)
  575. }
  576. return
  577. }
  578. // ResetWxAgent resets all changes to the "wx_agent" edge.
  579. func (m *AgentMutation) ResetWxAgent() {
  580. m.wx_agent = nil
  581. m.clearedwx_agent = false
  582. m.removedwx_agent = nil
  583. }
  584. // Where appends a list predicates to the AgentMutation builder.
  585. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  586. m.predicates = append(m.predicates, ps...)
  587. }
  588. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  589. // users can use type-assertion to append predicates that do not depend on any generated package.
  590. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  591. p := make([]predicate.Agent, len(ps))
  592. for i := range ps {
  593. p[i] = ps[i]
  594. }
  595. m.Where(p...)
  596. }
  597. // Op returns the operation name.
  598. func (m *AgentMutation) Op() Op {
  599. return m.op
  600. }
  601. // SetOp allows setting the mutation operation.
  602. func (m *AgentMutation) SetOp(op Op) {
  603. m.op = op
  604. }
  605. // Type returns the node type of this mutation (Agent).
  606. func (m *AgentMutation) Type() string {
  607. return m.typ
  608. }
  609. // Fields returns all fields that were changed during this mutation. Note that in
  610. // order to get all numeric fields that were incremented/decremented, call
  611. // AddedFields().
  612. func (m *AgentMutation) Fields() []string {
  613. fields := make([]string, 0, 9)
  614. if m.created_at != nil {
  615. fields = append(fields, agent.FieldCreatedAt)
  616. }
  617. if m.updated_at != nil {
  618. fields = append(fields, agent.FieldUpdatedAt)
  619. }
  620. if m.deleted_at != nil {
  621. fields = append(fields, agent.FieldDeletedAt)
  622. }
  623. if m.name != nil {
  624. fields = append(fields, agent.FieldName)
  625. }
  626. if m.role != nil {
  627. fields = append(fields, agent.FieldRole)
  628. }
  629. if m.status != nil {
  630. fields = append(fields, agent.FieldStatus)
  631. }
  632. if m.background != nil {
  633. fields = append(fields, agent.FieldBackground)
  634. }
  635. if m.examples != nil {
  636. fields = append(fields, agent.FieldExamples)
  637. }
  638. if m.organization_id != nil {
  639. fields = append(fields, agent.FieldOrganizationID)
  640. }
  641. return fields
  642. }
  643. // Field returns the value of a field with the given name. The second boolean
  644. // return value indicates that this field was not set, or was not defined in the
  645. // schema.
  646. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  647. switch name {
  648. case agent.FieldCreatedAt:
  649. return m.CreatedAt()
  650. case agent.FieldUpdatedAt:
  651. return m.UpdatedAt()
  652. case agent.FieldDeletedAt:
  653. return m.DeletedAt()
  654. case agent.FieldName:
  655. return m.Name()
  656. case agent.FieldRole:
  657. return m.Role()
  658. case agent.FieldStatus:
  659. return m.Status()
  660. case agent.FieldBackground:
  661. return m.Background()
  662. case agent.FieldExamples:
  663. return m.Examples()
  664. case agent.FieldOrganizationID:
  665. return m.OrganizationID()
  666. }
  667. return nil, false
  668. }
  669. // OldField returns the old value of the field from the database. An error is
  670. // returned if the mutation operation is not UpdateOne, or the query to the
  671. // database failed.
  672. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  673. switch name {
  674. case agent.FieldCreatedAt:
  675. return m.OldCreatedAt(ctx)
  676. case agent.FieldUpdatedAt:
  677. return m.OldUpdatedAt(ctx)
  678. case agent.FieldDeletedAt:
  679. return m.OldDeletedAt(ctx)
  680. case agent.FieldName:
  681. return m.OldName(ctx)
  682. case agent.FieldRole:
  683. return m.OldRole(ctx)
  684. case agent.FieldStatus:
  685. return m.OldStatus(ctx)
  686. case agent.FieldBackground:
  687. return m.OldBackground(ctx)
  688. case agent.FieldExamples:
  689. return m.OldExamples(ctx)
  690. case agent.FieldOrganizationID:
  691. return m.OldOrganizationID(ctx)
  692. }
  693. return nil, fmt.Errorf("unknown Agent field %s", name)
  694. }
  695. // SetField sets the value of a field with the given name. It returns an error if
  696. // the field is not defined in the schema, or if the type mismatched the field
  697. // type.
  698. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  699. switch name {
  700. case agent.FieldCreatedAt:
  701. v, ok := value.(time.Time)
  702. if !ok {
  703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  704. }
  705. m.SetCreatedAt(v)
  706. return nil
  707. case agent.FieldUpdatedAt:
  708. v, ok := value.(time.Time)
  709. if !ok {
  710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  711. }
  712. m.SetUpdatedAt(v)
  713. return nil
  714. case agent.FieldDeletedAt:
  715. v, ok := value.(time.Time)
  716. if !ok {
  717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  718. }
  719. m.SetDeletedAt(v)
  720. return nil
  721. case agent.FieldName:
  722. v, ok := value.(string)
  723. if !ok {
  724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  725. }
  726. m.SetName(v)
  727. return nil
  728. case agent.FieldRole:
  729. v, ok := value.(string)
  730. if !ok {
  731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  732. }
  733. m.SetRole(v)
  734. return nil
  735. case agent.FieldStatus:
  736. v, ok := value.(int)
  737. if !ok {
  738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  739. }
  740. m.SetStatus(v)
  741. return nil
  742. case agent.FieldBackground:
  743. v, ok := value.(string)
  744. if !ok {
  745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  746. }
  747. m.SetBackground(v)
  748. return nil
  749. case agent.FieldExamples:
  750. v, ok := value.(string)
  751. if !ok {
  752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  753. }
  754. m.SetExamples(v)
  755. return nil
  756. case agent.FieldOrganizationID:
  757. v, ok := value.(uint64)
  758. if !ok {
  759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  760. }
  761. m.SetOrganizationID(v)
  762. return nil
  763. }
  764. return fmt.Errorf("unknown Agent field %s", name)
  765. }
  766. // AddedFields returns all numeric fields that were incremented/decremented during
  767. // this mutation.
  768. func (m *AgentMutation) AddedFields() []string {
  769. var fields []string
  770. if m.addstatus != nil {
  771. fields = append(fields, agent.FieldStatus)
  772. }
  773. if m.addorganization_id != nil {
  774. fields = append(fields, agent.FieldOrganizationID)
  775. }
  776. return fields
  777. }
  778. // AddedField returns the numeric value that was incremented/decremented on a field
  779. // with the given name. The second boolean return value indicates that this field
  780. // was not set, or was not defined in the schema.
  781. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  782. switch name {
  783. case agent.FieldStatus:
  784. return m.AddedStatus()
  785. case agent.FieldOrganizationID:
  786. return m.AddedOrganizationID()
  787. }
  788. return nil, false
  789. }
  790. // AddField adds the value to the field with the given name. It returns an error if
  791. // the field is not defined in the schema, or if the type mismatched the field
  792. // type.
  793. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  794. switch name {
  795. case agent.FieldStatus:
  796. v, ok := value.(int)
  797. if !ok {
  798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  799. }
  800. m.AddStatus(v)
  801. return nil
  802. case agent.FieldOrganizationID:
  803. v, ok := value.(int64)
  804. if !ok {
  805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  806. }
  807. m.AddOrganizationID(v)
  808. return nil
  809. }
  810. return fmt.Errorf("unknown Agent numeric field %s", name)
  811. }
  812. // ClearedFields returns all nullable fields that were cleared during this
  813. // mutation.
  814. func (m *AgentMutation) ClearedFields() []string {
  815. var fields []string
  816. if m.FieldCleared(agent.FieldDeletedAt) {
  817. fields = append(fields, agent.FieldDeletedAt)
  818. }
  819. if m.FieldCleared(agent.FieldStatus) {
  820. fields = append(fields, agent.FieldStatus)
  821. }
  822. if m.FieldCleared(agent.FieldBackground) {
  823. fields = append(fields, agent.FieldBackground)
  824. }
  825. if m.FieldCleared(agent.FieldExamples) {
  826. fields = append(fields, agent.FieldExamples)
  827. }
  828. return fields
  829. }
  830. // FieldCleared returns a boolean indicating if a field with the given name was
  831. // cleared in this mutation.
  832. func (m *AgentMutation) FieldCleared(name string) bool {
  833. _, ok := m.clearedFields[name]
  834. return ok
  835. }
  836. // ClearField clears the value of the field with the given name. It returns an
  837. // error if the field is not defined in the schema.
  838. func (m *AgentMutation) ClearField(name string) error {
  839. switch name {
  840. case agent.FieldDeletedAt:
  841. m.ClearDeletedAt()
  842. return nil
  843. case agent.FieldStatus:
  844. m.ClearStatus()
  845. return nil
  846. case agent.FieldBackground:
  847. m.ClearBackground()
  848. return nil
  849. case agent.FieldExamples:
  850. m.ClearExamples()
  851. return nil
  852. }
  853. return fmt.Errorf("unknown Agent nullable field %s", name)
  854. }
  855. // ResetField resets all changes in the mutation for the field with the given name.
  856. // It returns an error if the field is not defined in the schema.
  857. func (m *AgentMutation) ResetField(name string) error {
  858. switch name {
  859. case agent.FieldCreatedAt:
  860. m.ResetCreatedAt()
  861. return nil
  862. case agent.FieldUpdatedAt:
  863. m.ResetUpdatedAt()
  864. return nil
  865. case agent.FieldDeletedAt:
  866. m.ResetDeletedAt()
  867. return nil
  868. case agent.FieldName:
  869. m.ResetName()
  870. return nil
  871. case agent.FieldRole:
  872. m.ResetRole()
  873. return nil
  874. case agent.FieldStatus:
  875. m.ResetStatus()
  876. return nil
  877. case agent.FieldBackground:
  878. m.ResetBackground()
  879. return nil
  880. case agent.FieldExamples:
  881. m.ResetExamples()
  882. return nil
  883. case agent.FieldOrganizationID:
  884. m.ResetOrganizationID()
  885. return nil
  886. }
  887. return fmt.Errorf("unknown Agent field %s", name)
  888. }
  889. // AddedEdges returns all edge names that were set/added in this mutation.
  890. func (m *AgentMutation) AddedEdges() []string {
  891. edges := make([]string, 0, 1)
  892. if m.wx_agent != nil {
  893. edges = append(edges, agent.EdgeWxAgent)
  894. }
  895. return edges
  896. }
  897. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  898. // name in this mutation.
  899. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  900. switch name {
  901. case agent.EdgeWxAgent:
  902. ids := make([]ent.Value, 0, len(m.wx_agent))
  903. for id := range m.wx_agent {
  904. ids = append(ids, id)
  905. }
  906. return ids
  907. }
  908. return nil
  909. }
  910. // RemovedEdges returns all edge names that were removed in this mutation.
  911. func (m *AgentMutation) RemovedEdges() []string {
  912. edges := make([]string, 0, 1)
  913. if m.removedwx_agent != nil {
  914. edges = append(edges, agent.EdgeWxAgent)
  915. }
  916. return edges
  917. }
  918. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  919. // the given name in this mutation.
  920. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  921. switch name {
  922. case agent.EdgeWxAgent:
  923. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  924. for id := range m.removedwx_agent {
  925. ids = append(ids, id)
  926. }
  927. return ids
  928. }
  929. return nil
  930. }
  931. // ClearedEdges returns all edge names that were cleared in this mutation.
  932. func (m *AgentMutation) ClearedEdges() []string {
  933. edges := make([]string, 0, 1)
  934. if m.clearedwx_agent {
  935. edges = append(edges, agent.EdgeWxAgent)
  936. }
  937. return edges
  938. }
  939. // EdgeCleared returns a boolean which indicates if the edge with the given name
  940. // was cleared in this mutation.
  941. func (m *AgentMutation) EdgeCleared(name string) bool {
  942. switch name {
  943. case agent.EdgeWxAgent:
  944. return m.clearedwx_agent
  945. }
  946. return false
  947. }
  948. // ClearEdge clears the value of the edge with the given name. It returns an error
  949. // if that edge is not defined in the schema.
  950. func (m *AgentMutation) ClearEdge(name string) error {
  951. switch name {
  952. }
  953. return fmt.Errorf("unknown Agent unique edge %s", name)
  954. }
  955. // ResetEdge resets all changes to the edge with the given name in this mutation.
  956. // It returns an error if the edge is not defined in the schema.
  957. func (m *AgentMutation) ResetEdge(name string) error {
  958. switch name {
  959. case agent.EdgeWxAgent:
  960. m.ResetWxAgent()
  961. return nil
  962. }
  963. return fmt.Errorf("unknown Agent edge %s", name)
  964. }
  965. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  966. type BatchMsgMutation struct {
  967. config
  968. op Op
  969. typ string
  970. id *uint64
  971. created_at *time.Time
  972. updated_at *time.Time
  973. deleted_at *time.Time
  974. status *uint8
  975. addstatus *int8
  976. batch_no *string
  977. task_name *string
  978. fromwxid *string
  979. msg *string
  980. tag *string
  981. total *int32
  982. addtotal *int32
  983. success *int32
  984. addsuccess *int32
  985. fail *int32
  986. addfail *int32
  987. start_time *time.Time
  988. stop_time *time.Time
  989. send_time *time.Time
  990. _type *int32
  991. add_type *int32
  992. clearedFields map[string]struct{}
  993. done bool
  994. oldValue func(context.Context) (*BatchMsg, error)
  995. predicates []predicate.BatchMsg
  996. }
  997. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  998. // batchmsgOption allows management of the mutation configuration using functional options.
  999. type batchmsgOption func(*BatchMsgMutation)
  1000. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  1001. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  1002. m := &BatchMsgMutation{
  1003. config: c,
  1004. op: op,
  1005. typ: TypeBatchMsg,
  1006. clearedFields: make(map[string]struct{}),
  1007. }
  1008. for _, opt := range opts {
  1009. opt(m)
  1010. }
  1011. return m
  1012. }
  1013. // withBatchMsgID sets the ID field of the mutation.
  1014. func withBatchMsgID(id uint64) batchmsgOption {
  1015. return func(m *BatchMsgMutation) {
  1016. var (
  1017. err error
  1018. once sync.Once
  1019. value *BatchMsg
  1020. )
  1021. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  1022. once.Do(func() {
  1023. if m.done {
  1024. err = errors.New("querying old values post mutation is not allowed")
  1025. } else {
  1026. value, err = m.Client().BatchMsg.Get(ctx, id)
  1027. }
  1028. })
  1029. return value, err
  1030. }
  1031. m.id = &id
  1032. }
  1033. }
  1034. // withBatchMsg sets the old BatchMsg of the mutation.
  1035. func withBatchMsg(node *BatchMsg) batchmsgOption {
  1036. return func(m *BatchMsgMutation) {
  1037. m.oldValue = func(context.Context) (*BatchMsg, error) {
  1038. return node, nil
  1039. }
  1040. m.id = &node.ID
  1041. }
  1042. }
  1043. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1044. // executed in a transaction (ent.Tx), a transactional client is returned.
  1045. func (m BatchMsgMutation) Client() *Client {
  1046. client := &Client{config: m.config}
  1047. client.init()
  1048. return client
  1049. }
  1050. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1051. // it returns an error otherwise.
  1052. func (m BatchMsgMutation) Tx() (*Tx, error) {
  1053. if _, ok := m.driver.(*txDriver); !ok {
  1054. return nil, errors.New("ent: mutation is not running in a transaction")
  1055. }
  1056. tx := &Tx{config: m.config}
  1057. tx.init()
  1058. return tx, nil
  1059. }
  1060. // SetID sets the value of the id field. Note that this
  1061. // operation is only accepted on creation of BatchMsg entities.
  1062. func (m *BatchMsgMutation) SetID(id uint64) {
  1063. m.id = &id
  1064. }
  1065. // ID returns the ID value in the mutation. Note that the ID is only available
  1066. // if it was provided to the builder or after it was returned from the database.
  1067. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  1068. if m.id == nil {
  1069. return
  1070. }
  1071. return *m.id, true
  1072. }
  1073. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1074. // That means, if the mutation is applied within a transaction with an isolation level such
  1075. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1076. // or updated by the mutation.
  1077. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  1078. switch {
  1079. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1080. id, exists := m.ID()
  1081. if exists {
  1082. return []uint64{id}, nil
  1083. }
  1084. fallthrough
  1085. case m.op.Is(OpUpdate | OpDelete):
  1086. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  1087. default:
  1088. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1089. }
  1090. }
  1091. // SetCreatedAt sets the "created_at" field.
  1092. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  1093. m.created_at = &t
  1094. }
  1095. // CreatedAt returns the value of the "created_at" field in the mutation.
  1096. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  1097. v := m.created_at
  1098. if v == nil {
  1099. return
  1100. }
  1101. return *v, true
  1102. }
  1103. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  1104. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1106. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  1107. if !m.op.Is(OpUpdateOne) {
  1108. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  1109. }
  1110. if m.id == nil || m.oldValue == nil {
  1111. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  1112. }
  1113. oldValue, err := m.oldValue(ctx)
  1114. if err != nil {
  1115. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  1116. }
  1117. return oldValue.CreatedAt, nil
  1118. }
  1119. // ResetCreatedAt resets all changes to the "created_at" field.
  1120. func (m *BatchMsgMutation) ResetCreatedAt() {
  1121. m.created_at = nil
  1122. }
  1123. // SetUpdatedAt sets the "updated_at" field.
  1124. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  1125. m.updated_at = &t
  1126. }
  1127. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  1128. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  1129. v := m.updated_at
  1130. if v == nil {
  1131. return
  1132. }
  1133. return *v, true
  1134. }
  1135. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  1136. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1138. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  1139. if !m.op.Is(OpUpdateOne) {
  1140. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  1141. }
  1142. if m.id == nil || m.oldValue == nil {
  1143. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  1144. }
  1145. oldValue, err := m.oldValue(ctx)
  1146. if err != nil {
  1147. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  1148. }
  1149. return oldValue.UpdatedAt, nil
  1150. }
  1151. // ResetUpdatedAt resets all changes to the "updated_at" field.
  1152. func (m *BatchMsgMutation) ResetUpdatedAt() {
  1153. m.updated_at = nil
  1154. }
  1155. // SetDeletedAt sets the "deleted_at" field.
  1156. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  1157. m.deleted_at = &t
  1158. }
  1159. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  1160. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  1161. v := m.deleted_at
  1162. if v == nil {
  1163. return
  1164. }
  1165. return *v, true
  1166. }
  1167. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  1168. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1170. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  1171. if !m.op.Is(OpUpdateOne) {
  1172. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  1173. }
  1174. if m.id == nil || m.oldValue == nil {
  1175. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  1176. }
  1177. oldValue, err := m.oldValue(ctx)
  1178. if err != nil {
  1179. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  1180. }
  1181. return oldValue.DeletedAt, nil
  1182. }
  1183. // ClearDeletedAt clears the value of the "deleted_at" field.
  1184. func (m *BatchMsgMutation) ClearDeletedAt() {
  1185. m.deleted_at = nil
  1186. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  1187. }
  1188. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  1189. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  1190. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  1191. return ok
  1192. }
  1193. // ResetDeletedAt resets all changes to the "deleted_at" field.
  1194. func (m *BatchMsgMutation) ResetDeletedAt() {
  1195. m.deleted_at = nil
  1196. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  1197. }
  1198. // SetStatus sets the "status" field.
  1199. func (m *BatchMsgMutation) SetStatus(u uint8) {
  1200. m.status = &u
  1201. m.addstatus = nil
  1202. }
  1203. // Status returns the value of the "status" field in the mutation.
  1204. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  1205. v := m.status
  1206. if v == nil {
  1207. return
  1208. }
  1209. return *v, true
  1210. }
  1211. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  1212. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1214. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  1215. if !m.op.Is(OpUpdateOne) {
  1216. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  1217. }
  1218. if m.id == nil || m.oldValue == nil {
  1219. return v, errors.New("OldStatus requires an ID field in the mutation")
  1220. }
  1221. oldValue, err := m.oldValue(ctx)
  1222. if err != nil {
  1223. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  1224. }
  1225. return oldValue.Status, nil
  1226. }
  1227. // AddStatus adds u to the "status" field.
  1228. func (m *BatchMsgMutation) AddStatus(u int8) {
  1229. if m.addstatus != nil {
  1230. *m.addstatus += u
  1231. } else {
  1232. m.addstatus = &u
  1233. }
  1234. }
  1235. // AddedStatus returns the value that was added to the "status" field in this mutation.
  1236. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  1237. v := m.addstatus
  1238. if v == nil {
  1239. return
  1240. }
  1241. return *v, true
  1242. }
  1243. // ClearStatus clears the value of the "status" field.
  1244. func (m *BatchMsgMutation) ClearStatus() {
  1245. m.status = nil
  1246. m.addstatus = nil
  1247. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  1248. }
  1249. // StatusCleared returns if the "status" field was cleared in this mutation.
  1250. func (m *BatchMsgMutation) StatusCleared() bool {
  1251. _, ok := m.clearedFields[batchmsg.FieldStatus]
  1252. return ok
  1253. }
  1254. // ResetStatus resets all changes to the "status" field.
  1255. func (m *BatchMsgMutation) ResetStatus() {
  1256. m.status = nil
  1257. m.addstatus = nil
  1258. delete(m.clearedFields, batchmsg.FieldStatus)
  1259. }
  1260. // SetBatchNo sets the "batch_no" field.
  1261. func (m *BatchMsgMutation) SetBatchNo(s string) {
  1262. m.batch_no = &s
  1263. }
  1264. // BatchNo returns the value of the "batch_no" field in the mutation.
  1265. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  1266. v := m.batch_no
  1267. if v == nil {
  1268. return
  1269. }
  1270. return *v, true
  1271. }
  1272. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  1273. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1275. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  1276. if !m.op.Is(OpUpdateOne) {
  1277. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  1278. }
  1279. if m.id == nil || m.oldValue == nil {
  1280. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  1281. }
  1282. oldValue, err := m.oldValue(ctx)
  1283. if err != nil {
  1284. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  1285. }
  1286. return oldValue.BatchNo, nil
  1287. }
  1288. // ClearBatchNo clears the value of the "batch_no" field.
  1289. func (m *BatchMsgMutation) ClearBatchNo() {
  1290. m.batch_no = nil
  1291. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  1292. }
  1293. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  1294. func (m *BatchMsgMutation) BatchNoCleared() bool {
  1295. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  1296. return ok
  1297. }
  1298. // ResetBatchNo resets all changes to the "batch_no" field.
  1299. func (m *BatchMsgMutation) ResetBatchNo() {
  1300. m.batch_no = nil
  1301. delete(m.clearedFields, batchmsg.FieldBatchNo)
  1302. }
  1303. // SetTaskName sets the "task_name" field.
  1304. func (m *BatchMsgMutation) SetTaskName(s string) {
  1305. m.task_name = &s
  1306. }
  1307. // TaskName returns the value of the "task_name" field in the mutation.
  1308. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  1309. v := m.task_name
  1310. if v == nil {
  1311. return
  1312. }
  1313. return *v, true
  1314. }
  1315. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  1316. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1318. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  1319. if !m.op.Is(OpUpdateOne) {
  1320. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  1321. }
  1322. if m.id == nil || m.oldValue == nil {
  1323. return v, errors.New("OldTaskName requires an ID field in the mutation")
  1324. }
  1325. oldValue, err := m.oldValue(ctx)
  1326. if err != nil {
  1327. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  1328. }
  1329. return oldValue.TaskName, nil
  1330. }
  1331. // ClearTaskName clears the value of the "task_name" field.
  1332. func (m *BatchMsgMutation) ClearTaskName() {
  1333. m.task_name = nil
  1334. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  1335. }
  1336. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  1337. func (m *BatchMsgMutation) TaskNameCleared() bool {
  1338. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  1339. return ok
  1340. }
  1341. // ResetTaskName resets all changes to the "task_name" field.
  1342. func (m *BatchMsgMutation) ResetTaskName() {
  1343. m.task_name = nil
  1344. delete(m.clearedFields, batchmsg.FieldTaskName)
  1345. }
  1346. // SetFromwxid sets the "fromwxid" field.
  1347. func (m *BatchMsgMutation) SetFromwxid(s string) {
  1348. m.fromwxid = &s
  1349. }
  1350. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  1351. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  1352. v := m.fromwxid
  1353. if v == nil {
  1354. return
  1355. }
  1356. return *v, true
  1357. }
  1358. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  1359. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1361. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  1362. if !m.op.Is(OpUpdateOne) {
  1363. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  1364. }
  1365. if m.id == nil || m.oldValue == nil {
  1366. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  1367. }
  1368. oldValue, err := m.oldValue(ctx)
  1369. if err != nil {
  1370. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  1371. }
  1372. return oldValue.Fromwxid, nil
  1373. }
  1374. // ClearFromwxid clears the value of the "fromwxid" field.
  1375. func (m *BatchMsgMutation) ClearFromwxid() {
  1376. m.fromwxid = nil
  1377. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  1378. }
  1379. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  1380. func (m *BatchMsgMutation) FromwxidCleared() bool {
  1381. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  1382. return ok
  1383. }
  1384. // ResetFromwxid resets all changes to the "fromwxid" field.
  1385. func (m *BatchMsgMutation) ResetFromwxid() {
  1386. m.fromwxid = nil
  1387. delete(m.clearedFields, batchmsg.FieldFromwxid)
  1388. }
  1389. // SetMsg sets the "msg" field.
  1390. func (m *BatchMsgMutation) SetMsg(s string) {
  1391. m.msg = &s
  1392. }
  1393. // Msg returns the value of the "msg" field in the mutation.
  1394. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  1395. v := m.msg
  1396. if v == nil {
  1397. return
  1398. }
  1399. return *v, true
  1400. }
  1401. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  1402. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1404. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  1405. if !m.op.Is(OpUpdateOne) {
  1406. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  1407. }
  1408. if m.id == nil || m.oldValue == nil {
  1409. return v, errors.New("OldMsg requires an ID field in the mutation")
  1410. }
  1411. oldValue, err := m.oldValue(ctx)
  1412. if err != nil {
  1413. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  1414. }
  1415. return oldValue.Msg, nil
  1416. }
  1417. // ClearMsg clears the value of the "msg" field.
  1418. func (m *BatchMsgMutation) ClearMsg() {
  1419. m.msg = nil
  1420. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  1421. }
  1422. // MsgCleared returns if the "msg" field was cleared in this mutation.
  1423. func (m *BatchMsgMutation) MsgCleared() bool {
  1424. _, ok := m.clearedFields[batchmsg.FieldMsg]
  1425. return ok
  1426. }
  1427. // ResetMsg resets all changes to the "msg" field.
  1428. func (m *BatchMsgMutation) ResetMsg() {
  1429. m.msg = nil
  1430. delete(m.clearedFields, batchmsg.FieldMsg)
  1431. }
  1432. // SetTag sets the "tag" field.
  1433. func (m *BatchMsgMutation) SetTag(s string) {
  1434. m.tag = &s
  1435. }
  1436. // Tag returns the value of the "tag" field in the mutation.
  1437. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  1438. v := m.tag
  1439. if v == nil {
  1440. return
  1441. }
  1442. return *v, true
  1443. }
  1444. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  1445. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1447. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  1448. if !m.op.Is(OpUpdateOne) {
  1449. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  1450. }
  1451. if m.id == nil || m.oldValue == nil {
  1452. return v, errors.New("OldTag requires an ID field in the mutation")
  1453. }
  1454. oldValue, err := m.oldValue(ctx)
  1455. if err != nil {
  1456. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  1457. }
  1458. return oldValue.Tag, nil
  1459. }
  1460. // ClearTag clears the value of the "tag" field.
  1461. func (m *BatchMsgMutation) ClearTag() {
  1462. m.tag = nil
  1463. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  1464. }
  1465. // TagCleared returns if the "tag" field was cleared in this mutation.
  1466. func (m *BatchMsgMutation) TagCleared() bool {
  1467. _, ok := m.clearedFields[batchmsg.FieldTag]
  1468. return ok
  1469. }
  1470. // ResetTag resets all changes to the "tag" field.
  1471. func (m *BatchMsgMutation) ResetTag() {
  1472. m.tag = nil
  1473. delete(m.clearedFields, batchmsg.FieldTag)
  1474. }
  1475. // SetTotal sets the "total" field.
  1476. func (m *BatchMsgMutation) SetTotal(i int32) {
  1477. m.total = &i
  1478. m.addtotal = nil
  1479. }
  1480. // Total returns the value of the "total" field in the mutation.
  1481. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  1482. v := m.total
  1483. if v == nil {
  1484. return
  1485. }
  1486. return *v, true
  1487. }
  1488. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  1489. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1491. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  1492. if !m.op.Is(OpUpdateOne) {
  1493. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  1494. }
  1495. if m.id == nil || m.oldValue == nil {
  1496. return v, errors.New("OldTotal requires an ID field in the mutation")
  1497. }
  1498. oldValue, err := m.oldValue(ctx)
  1499. if err != nil {
  1500. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  1501. }
  1502. return oldValue.Total, nil
  1503. }
  1504. // AddTotal adds i to the "total" field.
  1505. func (m *BatchMsgMutation) AddTotal(i int32) {
  1506. if m.addtotal != nil {
  1507. *m.addtotal += i
  1508. } else {
  1509. m.addtotal = &i
  1510. }
  1511. }
  1512. // AddedTotal returns the value that was added to the "total" field in this mutation.
  1513. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  1514. v := m.addtotal
  1515. if v == nil {
  1516. return
  1517. }
  1518. return *v, true
  1519. }
  1520. // ClearTotal clears the value of the "total" field.
  1521. func (m *BatchMsgMutation) ClearTotal() {
  1522. m.total = nil
  1523. m.addtotal = nil
  1524. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  1525. }
  1526. // TotalCleared returns if the "total" field was cleared in this mutation.
  1527. func (m *BatchMsgMutation) TotalCleared() bool {
  1528. _, ok := m.clearedFields[batchmsg.FieldTotal]
  1529. return ok
  1530. }
  1531. // ResetTotal resets all changes to the "total" field.
  1532. func (m *BatchMsgMutation) ResetTotal() {
  1533. m.total = nil
  1534. m.addtotal = nil
  1535. delete(m.clearedFields, batchmsg.FieldTotal)
  1536. }
  1537. // SetSuccess sets the "success" field.
  1538. func (m *BatchMsgMutation) SetSuccess(i int32) {
  1539. m.success = &i
  1540. m.addsuccess = nil
  1541. }
  1542. // Success returns the value of the "success" field in the mutation.
  1543. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  1544. v := m.success
  1545. if v == nil {
  1546. return
  1547. }
  1548. return *v, true
  1549. }
  1550. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  1551. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1553. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  1554. if !m.op.Is(OpUpdateOne) {
  1555. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  1556. }
  1557. if m.id == nil || m.oldValue == nil {
  1558. return v, errors.New("OldSuccess requires an ID field in the mutation")
  1559. }
  1560. oldValue, err := m.oldValue(ctx)
  1561. if err != nil {
  1562. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  1563. }
  1564. return oldValue.Success, nil
  1565. }
  1566. // AddSuccess adds i to the "success" field.
  1567. func (m *BatchMsgMutation) AddSuccess(i int32) {
  1568. if m.addsuccess != nil {
  1569. *m.addsuccess += i
  1570. } else {
  1571. m.addsuccess = &i
  1572. }
  1573. }
  1574. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  1575. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  1576. v := m.addsuccess
  1577. if v == nil {
  1578. return
  1579. }
  1580. return *v, true
  1581. }
  1582. // ClearSuccess clears the value of the "success" field.
  1583. func (m *BatchMsgMutation) ClearSuccess() {
  1584. m.success = nil
  1585. m.addsuccess = nil
  1586. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  1587. }
  1588. // SuccessCleared returns if the "success" field was cleared in this mutation.
  1589. func (m *BatchMsgMutation) SuccessCleared() bool {
  1590. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  1591. return ok
  1592. }
  1593. // ResetSuccess resets all changes to the "success" field.
  1594. func (m *BatchMsgMutation) ResetSuccess() {
  1595. m.success = nil
  1596. m.addsuccess = nil
  1597. delete(m.clearedFields, batchmsg.FieldSuccess)
  1598. }
  1599. // SetFail sets the "fail" field.
  1600. func (m *BatchMsgMutation) SetFail(i int32) {
  1601. m.fail = &i
  1602. m.addfail = nil
  1603. }
  1604. // Fail returns the value of the "fail" field in the mutation.
  1605. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  1606. v := m.fail
  1607. if v == nil {
  1608. return
  1609. }
  1610. return *v, true
  1611. }
  1612. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  1613. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1615. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  1616. if !m.op.Is(OpUpdateOne) {
  1617. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  1618. }
  1619. if m.id == nil || m.oldValue == nil {
  1620. return v, errors.New("OldFail requires an ID field in the mutation")
  1621. }
  1622. oldValue, err := m.oldValue(ctx)
  1623. if err != nil {
  1624. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  1625. }
  1626. return oldValue.Fail, nil
  1627. }
  1628. // AddFail adds i to the "fail" field.
  1629. func (m *BatchMsgMutation) AddFail(i int32) {
  1630. if m.addfail != nil {
  1631. *m.addfail += i
  1632. } else {
  1633. m.addfail = &i
  1634. }
  1635. }
  1636. // AddedFail returns the value that was added to the "fail" field in this mutation.
  1637. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  1638. v := m.addfail
  1639. if v == nil {
  1640. return
  1641. }
  1642. return *v, true
  1643. }
  1644. // ClearFail clears the value of the "fail" field.
  1645. func (m *BatchMsgMutation) ClearFail() {
  1646. m.fail = nil
  1647. m.addfail = nil
  1648. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  1649. }
  1650. // FailCleared returns if the "fail" field was cleared in this mutation.
  1651. func (m *BatchMsgMutation) FailCleared() bool {
  1652. _, ok := m.clearedFields[batchmsg.FieldFail]
  1653. return ok
  1654. }
  1655. // ResetFail resets all changes to the "fail" field.
  1656. func (m *BatchMsgMutation) ResetFail() {
  1657. m.fail = nil
  1658. m.addfail = nil
  1659. delete(m.clearedFields, batchmsg.FieldFail)
  1660. }
  1661. // SetStartTime sets the "start_time" field.
  1662. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  1663. m.start_time = &t
  1664. }
  1665. // StartTime returns the value of the "start_time" field in the mutation.
  1666. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  1667. v := m.start_time
  1668. if v == nil {
  1669. return
  1670. }
  1671. return *v, true
  1672. }
  1673. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  1674. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1676. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  1677. if !m.op.Is(OpUpdateOne) {
  1678. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  1679. }
  1680. if m.id == nil || m.oldValue == nil {
  1681. return v, errors.New("OldStartTime requires an ID field in the mutation")
  1682. }
  1683. oldValue, err := m.oldValue(ctx)
  1684. if err != nil {
  1685. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  1686. }
  1687. return oldValue.StartTime, nil
  1688. }
  1689. // ClearStartTime clears the value of the "start_time" field.
  1690. func (m *BatchMsgMutation) ClearStartTime() {
  1691. m.start_time = nil
  1692. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  1693. }
  1694. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  1695. func (m *BatchMsgMutation) StartTimeCleared() bool {
  1696. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  1697. return ok
  1698. }
  1699. // ResetStartTime resets all changes to the "start_time" field.
  1700. func (m *BatchMsgMutation) ResetStartTime() {
  1701. m.start_time = nil
  1702. delete(m.clearedFields, batchmsg.FieldStartTime)
  1703. }
  1704. // SetStopTime sets the "stop_time" field.
  1705. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  1706. m.stop_time = &t
  1707. }
  1708. // StopTime returns the value of the "stop_time" field in the mutation.
  1709. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  1710. v := m.stop_time
  1711. if v == nil {
  1712. return
  1713. }
  1714. return *v, true
  1715. }
  1716. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  1717. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1719. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  1720. if !m.op.Is(OpUpdateOne) {
  1721. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  1722. }
  1723. if m.id == nil || m.oldValue == nil {
  1724. return v, errors.New("OldStopTime requires an ID field in the mutation")
  1725. }
  1726. oldValue, err := m.oldValue(ctx)
  1727. if err != nil {
  1728. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  1729. }
  1730. return oldValue.StopTime, nil
  1731. }
  1732. // ClearStopTime clears the value of the "stop_time" field.
  1733. func (m *BatchMsgMutation) ClearStopTime() {
  1734. m.stop_time = nil
  1735. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  1736. }
  1737. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  1738. func (m *BatchMsgMutation) StopTimeCleared() bool {
  1739. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  1740. return ok
  1741. }
  1742. // ResetStopTime resets all changes to the "stop_time" field.
  1743. func (m *BatchMsgMutation) ResetStopTime() {
  1744. m.stop_time = nil
  1745. delete(m.clearedFields, batchmsg.FieldStopTime)
  1746. }
  1747. // SetSendTime sets the "send_time" field.
  1748. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  1749. m.send_time = &t
  1750. }
  1751. // SendTime returns the value of the "send_time" field in the mutation.
  1752. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  1753. v := m.send_time
  1754. if v == nil {
  1755. return
  1756. }
  1757. return *v, true
  1758. }
  1759. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  1760. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1762. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  1763. if !m.op.Is(OpUpdateOne) {
  1764. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  1765. }
  1766. if m.id == nil || m.oldValue == nil {
  1767. return v, errors.New("OldSendTime requires an ID field in the mutation")
  1768. }
  1769. oldValue, err := m.oldValue(ctx)
  1770. if err != nil {
  1771. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  1772. }
  1773. return oldValue.SendTime, nil
  1774. }
  1775. // ClearSendTime clears the value of the "send_time" field.
  1776. func (m *BatchMsgMutation) ClearSendTime() {
  1777. m.send_time = nil
  1778. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  1779. }
  1780. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  1781. func (m *BatchMsgMutation) SendTimeCleared() bool {
  1782. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  1783. return ok
  1784. }
  1785. // ResetSendTime resets all changes to the "send_time" field.
  1786. func (m *BatchMsgMutation) ResetSendTime() {
  1787. m.send_time = nil
  1788. delete(m.clearedFields, batchmsg.FieldSendTime)
  1789. }
  1790. // SetType sets the "type" field.
  1791. func (m *BatchMsgMutation) SetType(i int32) {
  1792. m._type = &i
  1793. m.add_type = nil
  1794. }
  1795. // GetType returns the value of the "type" field in the mutation.
  1796. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  1797. v := m._type
  1798. if v == nil {
  1799. return
  1800. }
  1801. return *v, true
  1802. }
  1803. // OldType returns the old "type" field's value of the BatchMsg entity.
  1804. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1806. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  1807. if !m.op.Is(OpUpdateOne) {
  1808. return v, errors.New("OldType is only allowed on UpdateOne operations")
  1809. }
  1810. if m.id == nil || m.oldValue == nil {
  1811. return v, errors.New("OldType requires an ID field in the mutation")
  1812. }
  1813. oldValue, err := m.oldValue(ctx)
  1814. if err != nil {
  1815. return v, fmt.Errorf("querying old value for OldType: %w", err)
  1816. }
  1817. return oldValue.Type, nil
  1818. }
  1819. // AddType adds i to the "type" field.
  1820. func (m *BatchMsgMutation) AddType(i int32) {
  1821. if m.add_type != nil {
  1822. *m.add_type += i
  1823. } else {
  1824. m.add_type = &i
  1825. }
  1826. }
  1827. // AddedType returns the value that was added to the "type" field in this mutation.
  1828. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  1829. v := m.add_type
  1830. if v == nil {
  1831. return
  1832. }
  1833. return *v, true
  1834. }
  1835. // ClearType clears the value of the "type" field.
  1836. func (m *BatchMsgMutation) ClearType() {
  1837. m._type = nil
  1838. m.add_type = nil
  1839. m.clearedFields[batchmsg.FieldType] = struct{}{}
  1840. }
  1841. // TypeCleared returns if the "type" field was cleared in this mutation.
  1842. func (m *BatchMsgMutation) TypeCleared() bool {
  1843. _, ok := m.clearedFields[batchmsg.FieldType]
  1844. return ok
  1845. }
  1846. // ResetType resets all changes to the "type" field.
  1847. func (m *BatchMsgMutation) ResetType() {
  1848. m._type = nil
  1849. m.add_type = nil
  1850. delete(m.clearedFields, batchmsg.FieldType)
  1851. }
  1852. // Where appends a list predicates to the BatchMsgMutation builder.
  1853. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  1854. m.predicates = append(m.predicates, ps...)
  1855. }
  1856. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  1857. // users can use type-assertion to append predicates that do not depend on any generated package.
  1858. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  1859. p := make([]predicate.BatchMsg, len(ps))
  1860. for i := range ps {
  1861. p[i] = ps[i]
  1862. }
  1863. m.Where(p...)
  1864. }
  1865. // Op returns the operation name.
  1866. func (m *BatchMsgMutation) Op() Op {
  1867. return m.op
  1868. }
  1869. // SetOp allows setting the mutation operation.
  1870. func (m *BatchMsgMutation) SetOp(op Op) {
  1871. m.op = op
  1872. }
  1873. // Type returns the node type of this mutation (BatchMsg).
  1874. func (m *BatchMsgMutation) Type() string {
  1875. return m.typ
  1876. }
  1877. // Fields returns all fields that were changed during this mutation. Note that in
  1878. // order to get all numeric fields that were incremented/decremented, call
  1879. // AddedFields().
  1880. func (m *BatchMsgMutation) Fields() []string {
  1881. fields := make([]string, 0, 16)
  1882. if m.created_at != nil {
  1883. fields = append(fields, batchmsg.FieldCreatedAt)
  1884. }
  1885. if m.updated_at != nil {
  1886. fields = append(fields, batchmsg.FieldUpdatedAt)
  1887. }
  1888. if m.deleted_at != nil {
  1889. fields = append(fields, batchmsg.FieldDeletedAt)
  1890. }
  1891. if m.status != nil {
  1892. fields = append(fields, batchmsg.FieldStatus)
  1893. }
  1894. if m.batch_no != nil {
  1895. fields = append(fields, batchmsg.FieldBatchNo)
  1896. }
  1897. if m.task_name != nil {
  1898. fields = append(fields, batchmsg.FieldTaskName)
  1899. }
  1900. if m.fromwxid != nil {
  1901. fields = append(fields, batchmsg.FieldFromwxid)
  1902. }
  1903. if m.msg != nil {
  1904. fields = append(fields, batchmsg.FieldMsg)
  1905. }
  1906. if m.tag != nil {
  1907. fields = append(fields, batchmsg.FieldTag)
  1908. }
  1909. if m.total != nil {
  1910. fields = append(fields, batchmsg.FieldTotal)
  1911. }
  1912. if m.success != nil {
  1913. fields = append(fields, batchmsg.FieldSuccess)
  1914. }
  1915. if m.fail != nil {
  1916. fields = append(fields, batchmsg.FieldFail)
  1917. }
  1918. if m.start_time != nil {
  1919. fields = append(fields, batchmsg.FieldStartTime)
  1920. }
  1921. if m.stop_time != nil {
  1922. fields = append(fields, batchmsg.FieldStopTime)
  1923. }
  1924. if m.send_time != nil {
  1925. fields = append(fields, batchmsg.FieldSendTime)
  1926. }
  1927. if m._type != nil {
  1928. fields = append(fields, batchmsg.FieldType)
  1929. }
  1930. return fields
  1931. }
  1932. // Field returns the value of a field with the given name. The second boolean
  1933. // return value indicates that this field was not set, or was not defined in the
  1934. // schema.
  1935. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  1936. switch name {
  1937. case batchmsg.FieldCreatedAt:
  1938. return m.CreatedAt()
  1939. case batchmsg.FieldUpdatedAt:
  1940. return m.UpdatedAt()
  1941. case batchmsg.FieldDeletedAt:
  1942. return m.DeletedAt()
  1943. case batchmsg.FieldStatus:
  1944. return m.Status()
  1945. case batchmsg.FieldBatchNo:
  1946. return m.BatchNo()
  1947. case batchmsg.FieldTaskName:
  1948. return m.TaskName()
  1949. case batchmsg.FieldFromwxid:
  1950. return m.Fromwxid()
  1951. case batchmsg.FieldMsg:
  1952. return m.Msg()
  1953. case batchmsg.FieldTag:
  1954. return m.Tag()
  1955. case batchmsg.FieldTotal:
  1956. return m.Total()
  1957. case batchmsg.FieldSuccess:
  1958. return m.Success()
  1959. case batchmsg.FieldFail:
  1960. return m.Fail()
  1961. case batchmsg.FieldStartTime:
  1962. return m.StartTime()
  1963. case batchmsg.FieldStopTime:
  1964. return m.StopTime()
  1965. case batchmsg.FieldSendTime:
  1966. return m.SendTime()
  1967. case batchmsg.FieldType:
  1968. return m.GetType()
  1969. }
  1970. return nil, false
  1971. }
  1972. // OldField returns the old value of the field from the database. An error is
  1973. // returned if the mutation operation is not UpdateOne, or the query to the
  1974. // database failed.
  1975. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1976. switch name {
  1977. case batchmsg.FieldCreatedAt:
  1978. return m.OldCreatedAt(ctx)
  1979. case batchmsg.FieldUpdatedAt:
  1980. return m.OldUpdatedAt(ctx)
  1981. case batchmsg.FieldDeletedAt:
  1982. return m.OldDeletedAt(ctx)
  1983. case batchmsg.FieldStatus:
  1984. return m.OldStatus(ctx)
  1985. case batchmsg.FieldBatchNo:
  1986. return m.OldBatchNo(ctx)
  1987. case batchmsg.FieldTaskName:
  1988. return m.OldTaskName(ctx)
  1989. case batchmsg.FieldFromwxid:
  1990. return m.OldFromwxid(ctx)
  1991. case batchmsg.FieldMsg:
  1992. return m.OldMsg(ctx)
  1993. case batchmsg.FieldTag:
  1994. return m.OldTag(ctx)
  1995. case batchmsg.FieldTotal:
  1996. return m.OldTotal(ctx)
  1997. case batchmsg.FieldSuccess:
  1998. return m.OldSuccess(ctx)
  1999. case batchmsg.FieldFail:
  2000. return m.OldFail(ctx)
  2001. case batchmsg.FieldStartTime:
  2002. return m.OldStartTime(ctx)
  2003. case batchmsg.FieldStopTime:
  2004. return m.OldStopTime(ctx)
  2005. case batchmsg.FieldSendTime:
  2006. return m.OldSendTime(ctx)
  2007. case batchmsg.FieldType:
  2008. return m.OldType(ctx)
  2009. }
  2010. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  2011. }
  2012. // SetField sets the value of a field with the given name. It returns an error if
  2013. // the field is not defined in the schema, or if the type mismatched the field
  2014. // type.
  2015. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  2016. switch name {
  2017. case batchmsg.FieldCreatedAt:
  2018. v, ok := value.(time.Time)
  2019. if !ok {
  2020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2021. }
  2022. m.SetCreatedAt(v)
  2023. return nil
  2024. case batchmsg.FieldUpdatedAt:
  2025. v, ok := value.(time.Time)
  2026. if !ok {
  2027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2028. }
  2029. m.SetUpdatedAt(v)
  2030. return nil
  2031. case batchmsg.FieldDeletedAt:
  2032. v, ok := value.(time.Time)
  2033. if !ok {
  2034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2035. }
  2036. m.SetDeletedAt(v)
  2037. return nil
  2038. case batchmsg.FieldStatus:
  2039. v, ok := value.(uint8)
  2040. if !ok {
  2041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2042. }
  2043. m.SetStatus(v)
  2044. return nil
  2045. case batchmsg.FieldBatchNo:
  2046. v, ok := value.(string)
  2047. if !ok {
  2048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2049. }
  2050. m.SetBatchNo(v)
  2051. return nil
  2052. case batchmsg.FieldTaskName:
  2053. v, ok := value.(string)
  2054. if !ok {
  2055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2056. }
  2057. m.SetTaskName(v)
  2058. return nil
  2059. case batchmsg.FieldFromwxid:
  2060. v, ok := value.(string)
  2061. if !ok {
  2062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2063. }
  2064. m.SetFromwxid(v)
  2065. return nil
  2066. case batchmsg.FieldMsg:
  2067. v, ok := value.(string)
  2068. if !ok {
  2069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2070. }
  2071. m.SetMsg(v)
  2072. return nil
  2073. case batchmsg.FieldTag:
  2074. v, ok := value.(string)
  2075. if !ok {
  2076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2077. }
  2078. m.SetTag(v)
  2079. return nil
  2080. case batchmsg.FieldTotal:
  2081. v, ok := value.(int32)
  2082. if !ok {
  2083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2084. }
  2085. m.SetTotal(v)
  2086. return nil
  2087. case batchmsg.FieldSuccess:
  2088. v, ok := value.(int32)
  2089. if !ok {
  2090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2091. }
  2092. m.SetSuccess(v)
  2093. return nil
  2094. case batchmsg.FieldFail:
  2095. v, ok := value.(int32)
  2096. if !ok {
  2097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2098. }
  2099. m.SetFail(v)
  2100. return nil
  2101. case batchmsg.FieldStartTime:
  2102. v, ok := value.(time.Time)
  2103. if !ok {
  2104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2105. }
  2106. m.SetStartTime(v)
  2107. return nil
  2108. case batchmsg.FieldStopTime:
  2109. v, ok := value.(time.Time)
  2110. if !ok {
  2111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2112. }
  2113. m.SetStopTime(v)
  2114. return nil
  2115. case batchmsg.FieldSendTime:
  2116. v, ok := value.(time.Time)
  2117. if !ok {
  2118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2119. }
  2120. m.SetSendTime(v)
  2121. return nil
  2122. case batchmsg.FieldType:
  2123. v, ok := value.(int32)
  2124. if !ok {
  2125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2126. }
  2127. m.SetType(v)
  2128. return nil
  2129. }
  2130. return fmt.Errorf("unknown BatchMsg field %s", name)
  2131. }
  2132. // AddedFields returns all numeric fields that were incremented/decremented during
  2133. // this mutation.
  2134. func (m *BatchMsgMutation) AddedFields() []string {
  2135. var fields []string
  2136. if m.addstatus != nil {
  2137. fields = append(fields, batchmsg.FieldStatus)
  2138. }
  2139. if m.addtotal != nil {
  2140. fields = append(fields, batchmsg.FieldTotal)
  2141. }
  2142. if m.addsuccess != nil {
  2143. fields = append(fields, batchmsg.FieldSuccess)
  2144. }
  2145. if m.addfail != nil {
  2146. fields = append(fields, batchmsg.FieldFail)
  2147. }
  2148. if m.add_type != nil {
  2149. fields = append(fields, batchmsg.FieldType)
  2150. }
  2151. return fields
  2152. }
  2153. // AddedField returns the numeric value that was incremented/decremented on a field
  2154. // with the given name. The second boolean return value indicates that this field
  2155. // was not set, or was not defined in the schema.
  2156. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  2157. switch name {
  2158. case batchmsg.FieldStatus:
  2159. return m.AddedStatus()
  2160. case batchmsg.FieldTotal:
  2161. return m.AddedTotal()
  2162. case batchmsg.FieldSuccess:
  2163. return m.AddedSuccess()
  2164. case batchmsg.FieldFail:
  2165. return m.AddedFail()
  2166. case batchmsg.FieldType:
  2167. return m.AddedType()
  2168. }
  2169. return nil, false
  2170. }
  2171. // AddField adds the value to the field with the given name. It returns an error if
  2172. // the field is not defined in the schema, or if the type mismatched the field
  2173. // type.
  2174. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  2175. switch name {
  2176. case batchmsg.FieldStatus:
  2177. v, ok := value.(int8)
  2178. if !ok {
  2179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2180. }
  2181. m.AddStatus(v)
  2182. return nil
  2183. case batchmsg.FieldTotal:
  2184. v, ok := value.(int32)
  2185. if !ok {
  2186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2187. }
  2188. m.AddTotal(v)
  2189. return nil
  2190. case batchmsg.FieldSuccess:
  2191. v, ok := value.(int32)
  2192. if !ok {
  2193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2194. }
  2195. m.AddSuccess(v)
  2196. return nil
  2197. case batchmsg.FieldFail:
  2198. v, ok := value.(int32)
  2199. if !ok {
  2200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2201. }
  2202. m.AddFail(v)
  2203. return nil
  2204. case batchmsg.FieldType:
  2205. v, ok := value.(int32)
  2206. if !ok {
  2207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2208. }
  2209. m.AddType(v)
  2210. return nil
  2211. }
  2212. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  2213. }
  2214. // ClearedFields returns all nullable fields that were cleared during this
  2215. // mutation.
  2216. func (m *BatchMsgMutation) ClearedFields() []string {
  2217. var fields []string
  2218. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  2219. fields = append(fields, batchmsg.FieldDeletedAt)
  2220. }
  2221. if m.FieldCleared(batchmsg.FieldStatus) {
  2222. fields = append(fields, batchmsg.FieldStatus)
  2223. }
  2224. if m.FieldCleared(batchmsg.FieldBatchNo) {
  2225. fields = append(fields, batchmsg.FieldBatchNo)
  2226. }
  2227. if m.FieldCleared(batchmsg.FieldTaskName) {
  2228. fields = append(fields, batchmsg.FieldTaskName)
  2229. }
  2230. if m.FieldCleared(batchmsg.FieldFromwxid) {
  2231. fields = append(fields, batchmsg.FieldFromwxid)
  2232. }
  2233. if m.FieldCleared(batchmsg.FieldMsg) {
  2234. fields = append(fields, batchmsg.FieldMsg)
  2235. }
  2236. if m.FieldCleared(batchmsg.FieldTag) {
  2237. fields = append(fields, batchmsg.FieldTag)
  2238. }
  2239. if m.FieldCleared(batchmsg.FieldTotal) {
  2240. fields = append(fields, batchmsg.FieldTotal)
  2241. }
  2242. if m.FieldCleared(batchmsg.FieldSuccess) {
  2243. fields = append(fields, batchmsg.FieldSuccess)
  2244. }
  2245. if m.FieldCleared(batchmsg.FieldFail) {
  2246. fields = append(fields, batchmsg.FieldFail)
  2247. }
  2248. if m.FieldCleared(batchmsg.FieldStartTime) {
  2249. fields = append(fields, batchmsg.FieldStartTime)
  2250. }
  2251. if m.FieldCleared(batchmsg.FieldStopTime) {
  2252. fields = append(fields, batchmsg.FieldStopTime)
  2253. }
  2254. if m.FieldCleared(batchmsg.FieldSendTime) {
  2255. fields = append(fields, batchmsg.FieldSendTime)
  2256. }
  2257. if m.FieldCleared(batchmsg.FieldType) {
  2258. fields = append(fields, batchmsg.FieldType)
  2259. }
  2260. return fields
  2261. }
  2262. // FieldCleared returns a boolean indicating if a field with the given name was
  2263. // cleared in this mutation.
  2264. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  2265. _, ok := m.clearedFields[name]
  2266. return ok
  2267. }
  2268. // ClearField clears the value of the field with the given name. It returns an
  2269. // error if the field is not defined in the schema.
  2270. func (m *BatchMsgMutation) ClearField(name string) error {
  2271. switch name {
  2272. case batchmsg.FieldDeletedAt:
  2273. m.ClearDeletedAt()
  2274. return nil
  2275. case batchmsg.FieldStatus:
  2276. m.ClearStatus()
  2277. return nil
  2278. case batchmsg.FieldBatchNo:
  2279. m.ClearBatchNo()
  2280. return nil
  2281. case batchmsg.FieldTaskName:
  2282. m.ClearTaskName()
  2283. return nil
  2284. case batchmsg.FieldFromwxid:
  2285. m.ClearFromwxid()
  2286. return nil
  2287. case batchmsg.FieldMsg:
  2288. m.ClearMsg()
  2289. return nil
  2290. case batchmsg.FieldTag:
  2291. m.ClearTag()
  2292. return nil
  2293. case batchmsg.FieldTotal:
  2294. m.ClearTotal()
  2295. return nil
  2296. case batchmsg.FieldSuccess:
  2297. m.ClearSuccess()
  2298. return nil
  2299. case batchmsg.FieldFail:
  2300. m.ClearFail()
  2301. return nil
  2302. case batchmsg.FieldStartTime:
  2303. m.ClearStartTime()
  2304. return nil
  2305. case batchmsg.FieldStopTime:
  2306. m.ClearStopTime()
  2307. return nil
  2308. case batchmsg.FieldSendTime:
  2309. m.ClearSendTime()
  2310. return nil
  2311. case batchmsg.FieldType:
  2312. m.ClearType()
  2313. return nil
  2314. }
  2315. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  2316. }
  2317. // ResetField resets all changes in the mutation for the field with the given name.
  2318. // It returns an error if the field is not defined in the schema.
  2319. func (m *BatchMsgMutation) ResetField(name string) error {
  2320. switch name {
  2321. case batchmsg.FieldCreatedAt:
  2322. m.ResetCreatedAt()
  2323. return nil
  2324. case batchmsg.FieldUpdatedAt:
  2325. m.ResetUpdatedAt()
  2326. return nil
  2327. case batchmsg.FieldDeletedAt:
  2328. m.ResetDeletedAt()
  2329. return nil
  2330. case batchmsg.FieldStatus:
  2331. m.ResetStatus()
  2332. return nil
  2333. case batchmsg.FieldBatchNo:
  2334. m.ResetBatchNo()
  2335. return nil
  2336. case batchmsg.FieldTaskName:
  2337. m.ResetTaskName()
  2338. return nil
  2339. case batchmsg.FieldFromwxid:
  2340. m.ResetFromwxid()
  2341. return nil
  2342. case batchmsg.FieldMsg:
  2343. m.ResetMsg()
  2344. return nil
  2345. case batchmsg.FieldTag:
  2346. m.ResetTag()
  2347. return nil
  2348. case batchmsg.FieldTotal:
  2349. m.ResetTotal()
  2350. return nil
  2351. case batchmsg.FieldSuccess:
  2352. m.ResetSuccess()
  2353. return nil
  2354. case batchmsg.FieldFail:
  2355. m.ResetFail()
  2356. return nil
  2357. case batchmsg.FieldStartTime:
  2358. m.ResetStartTime()
  2359. return nil
  2360. case batchmsg.FieldStopTime:
  2361. m.ResetStopTime()
  2362. return nil
  2363. case batchmsg.FieldSendTime:
  2364. m.ResetSendTime()
  2365. return nil
  2366. case batchmsg.FieldType:
  2367. m.ResetType()
  2368. return nil
  2369. }
  2370. return fmt.Errorf("unknown BatchMsg field %s", name)
  2371. }
  2372. // AddedEdges returns all edge names that were set/added in this mutation.
  2373. func (m *BatchMsgMutation) AddedEdges() []string {
  2374. edges := make([]string, 0, 0)
  2375. return edges
  2376. }
  2377. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2378. // name in this mutation.
  2379. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  2380. return nil
  2381. }
  2382. // RemovedEdges returns all edge names that were removed in this mutation.
  2383. func (m *BatchMsgMutation) RemovedEdges() []string {
  2384. edges := make([]string, 0, 0)
  2385. return edges
  2386. }
  2387. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2388. // the given name in this mutation.
  2389. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  2390. return nil
  2391. }
  2392. // ClearedEdges returns all edge names that were cleared in this mutation.
  2393. func (m *BatchMsgMutation) ClearedEdges() []string {
  2394. edges := make([]string, 0, 0)
  2395. return edges
  2396. }
  2397. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2398. // was cleared in this mutation.
  2399. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  2400. return false
  2401. }
  2402. // ClearEdge clears the value of the edge with the given name. It returns an error
  2403. // if that edge is not defined in the schema.
  2404. func (m *BatchMsgMutation) ClearEdge(name string) error {
  2405. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  2406. }
  2407. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2408. // It returns an error if the edge is not defined in the schema.
  2409. func (m *BatchMsgMutation) ResetEdge(name string) error {
  2410. return fmt.Errorf("unknown BatchMsg edge %s", name)
  2411. }
  2412. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  2413. type ContactMutation struct {
  2414. config
  2415. op Op
  2416. typ string
  2417. id *uint64
  2418. created_at *time.Time
  2419. updated_at *time.Time
  2420. status *uint8
  2421. addstatus *int8
  2422. deleted_at *time.Time
  2423. wx_wxid *string
  2424. _type *int
  2425. add_type *int
  2426. wxid *string
  2427. account *string
  2428. nickname *string
  2429. markname *string
  2430. headimg *string
  2431. sex *int
  2432. addsex *int
  2433. starrole *string
  2434. dontseeit *int
  2435. adddontseeit *int
  2436. dontseeme *int
  2437. adddontseeme *int
  2438. lag *string
  2439. gid *string
  2440. gname *string
  2441. v3 *string
  2442. organization_id *uint64
  2443. addorganization_id *int64
  2444. clearedFields map[string]struct{}
  2445. contact_relationships map[uint64]struct{}
  2446. removedcontact_relationships map[uint64]struct{}
  2447. clearedcontact_relationships bool
  2448. contact_messages map[uint64]struct{}
  2449. removedcontact_messages map[uint64]struct{}
  2450. clearedcontact_messages bool
  2451. done bool
  2452. oldValue func(context.Context) (*Contact, error)
  2453. predicates []predicate.Contact
  2454. }
  2455. var _ ent.Mutation = (*ContactMutation)(nil)
  2456. // contactOption allows management of the mutation configuration using functional options.
  2457. type contactOption func(*ContactMutation)
  2458. // newContactMutation creates new mutation for the Contact entity.
  2459. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  2460. m := &ContactMutation{
  2461. config: c,
  2462. op: op,
  2463. typ: TypeContact,
  2464. clearedFields: make(map[string]struct{}),
  2465. }
  2466. for _, opt := range opts {
  2467. opt(m)
  2468. }
  2469. return m
  2470. }
  2471. // withContactID sets the ID field of the mutation.
  2472. func withContactID(id uint64) contactOption {
  2473. return func(m *ContactMutation) {
  2474. var (
  2475. err error
  2476. once sync.Once
  2477. value *Contact
  2478. )
  2479. m.oldValue = func(ctx context.Context) (*Contact, error) {
  2480. once.Do(func() {
  2481. if m.done {
  2482. err = errors.New("querying old values post mutation is not allowed")
  2483. } else {
  2484. value, err = m.Client().Contact.Get(ctx, id)
  2485. }
  2486. })
  2487. return value, err
  2488. }
  2489. m.id = &id
  2490. }
  2491. }
  2492. // withContact sets the old Contact of the mutation.
  2493. func withContact(node *Contact) contactOption {
  2494. return func(m *ContactMutation) {
  2495. m.oldValue = func(context.Context) (*Contact, error) {
  2496. return node, nil
  2497. }
  2498. m.id = &node.ID
  2499. }
  2500. }
  2501. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2502. // executed in a transaction (ent.Tx), a transactional client is returned.
  2503. func (m ContactMutation) Client() *Client {
  2504. client := &Client{config: m.config}
  2505. client.init()
  2506. return client
  2507. }
  2508. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2509. // it returns an error otherwise.
  2510. func (m ContactMutation) Tx() (*Tx, error) {
  2511. if _, ok := m.driver.(*txDriver); !ok {
  2512. return nil, errors.New("ent: mutation is not running in a transaction")
  2513. }
  2514. tx := &Tx{config: m.config}
  2515. tx.init()
  2516. return tx, nil
  2517. }
  2518. // SetID sets the value of the id field. Note that this
  2519. // operation is only accepted on creation of Contact entities.
  2520. func (m *ContactMutation) SetID(id uint64) {
  2521. m.id = &id
  2522. }
  2523. // ID returns the ID value in the mutation. Note that the ID is only available
  2524. // if it was provided to the builder or after it was returned from the database.
  2525. func (m *ContactMutation) ID() (id uint64, exists bool) {
  2526. if m.id == nil {
  2527. return
  2528. }
  2529. return *m.id, true
  2530. }
  2531. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2532. // That means, if the mutation is applied within a transaction with an isolation level such
  2533. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2534. // or updated by the mutation.
  2535. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  2536. switch {
  2537. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2538. id, exists := m.ID()
  2539. if exists {
  2540. return []uint64{id}, nil
  2541. }
  2542. fallthrough
  2543. case m.op.Is(OpUpdate | OpDelete):
  2544. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  2545. default:
  2546. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2547. }
  2548. }
  2549. // SetCreatedAt sets the "created_at" field.
  2550. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  2551. m.created_at = &t
  2552. }
  2553. // CreatedAt returns the value of the "created_at" field in the mutation.
  2554. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  2555. v := m.created_at
  2556. if v == nil {
  2557. return
  2558. }
  2559. return *v, true
  2560. }
  2561. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  2562. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2564. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2565. if !m.op.Is(OpUpdateOne) {
  2566. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2567. }
  2568. if m.id == nil || m.oldValue == nil {
  2569. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2570. }
  2571. oldValue, err := m.oldValue(ctx)
  2572. if err != nil {
  2573. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2574. }
  2575. return oldValue.CreatedAt, nil
  2576. }
  2577. // ResetCreatedAt resets all changes to the "created_at" field.
  2578. func (m *ContactMutation) ResetCreatedAt() {
  2579. m.created_at = nil
  2580. }
  2581. // SetUpdatedAt sets the "updated_at" field.
  2582. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  2583. m.updated_at = &t
  2584. }
  2585. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2586. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  2587. v := m.updated_at
  2588. if v == nil {
  2589. return
  2590. }
  2591. return *v, true
  2592. }
  2593. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  2594. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2595. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2596. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2597. if !m.op.Is(OpUpdateOne) {
  2598. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2599. }
  2600. if m.id == nil || m.oldValue == nil {
  2601. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2602. }
  2603. oldValue, err := m.oldValue(ctx)
  2604. if err != nil {
  2605. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2606. }
  2607. return oldValue.UpdatedAt, nil
  2608. }
  2609. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2610. func (m *ContactMutation) ResetUpdatedAt() {
  2611. m.updated_at = nil
  2612. }
  2613. // SetStatus sets the "status" field.
  2614. func (m *ContactMutation) SetStatus(u uint8) {
  2615. m.status = &u
  2616. m.addstatus = nil
  2617. }
  2618. // Status returns the value of the "status" field in the mutation.
  2619. func (m *ContactMutation) Status() (r uint8, exists bool) {
  2620. v := m.status
  2621. if v == nil {
  2622. return
  2623. }
  2624. return *v, true
  2625. }
  2626. // OldStatus returns the old "status" field's value of the Contact entity.
  2627. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2629. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  2630. if !m.op.Is(OpUpdateOne) {
  2631. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  2632. }
  2633. if m.id == nil || m.oldValue == nil {
  2634. return v, errors.New("OldStatus requires an ID field in the mutation")
  2635. }
  2636. oldValue, err := m.oldValue(ctx)
  2637. if err != nil {
  2638. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  2639. }
  2640. return oldValue.Status, nil
  2641. }
  2642. // AddStatus adds u to the "status" field.
  2643. func (m *ContactMutation) AddStatus(u int8) {
  2644. if m.addstatus != nil {
  2645. *m.addstatus += u
  2646. } else {
  2647. m.addstatus = &u
  2648. }
  2649. }
  2650. // AddedStatus returns the value that was added to the "status" field in this mutation.
  2651. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  2652. v := m.addstatus
  2653. if v == nil {
  2654. return
  2655. }
  2656. return *v, true
  2657. }
  2658. // ClearStatus clears the value of the "status" field.
  2659. func (m *ContactMutation) ClearStatus() {
  2660. m.status = nil
  2661. m.addstatus = nil
  2662. m.clearedFields[contact.FieldStatus] = struct{}{}
  2663. }
  2664. // StatusCleared returns if the "status" field was cleared in this mutation.
  2665. func (m *ContactMutation) StatusCleared() bool {
  2666. _, ok := m.clearedFields[contact.FieldStatus]
  2667. return ok
  2668. }
  2669. // ResetStatus resets all changes to the "status" field.
  2670. func (m *ContactMutation) ResetStatus() {
  2671. m.status = nil
  2672. m.addstatus = nil
  2673. delete(m.clearedFields, contact.FieldStatus)
  2674. }
  2675. // SetDeletedAt sets the "deleted_at" field.
  2676. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  2677. m.deleted_at = &t
  2678. }
  2679. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2680. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  2681. v := m.deleted_at
  2682. if v == nil {
  2683. return
  2684. }
  2685. return *v, true
  2686. }
  2687. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  2688. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2690. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2691. if !m.op.Is(OpUpdateOne) {
  2692. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2693. }
  2694. if m.id == nil || m.oldValue == nil {
  2695. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2696. }
  2697. oldValue, err := m.oldValue(ctx)
  2698. if err != nil {
  2699. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2700. }
  2701. return oldValue.DeletedAt, nil
  2702. }
  2703. // ClearDeletedAt clears the value of the "deleted_at" field.
  2704. func (m *ContactMutation) ClearDeletedAt() {
  2705. m.deleted_at = nil
  2706. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  2707. }
  2708. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2709. func (m *ContactMutation) DeletedAtCleared() bool {
  2710. _, ok := m.clearedFields[contact.FieldDeletedAt]
  2711. return ok
  2712. }
  2713. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2714. func (m *ContactMutation) ResetDeletedAt() {
  2715. m.deleted_at = nil
  2716. delete(m.clearedFields, contact.FieldDeletedAt)
  2717. }
  2718. // SetWxWxid sets the "wx_wxid" field.
  2719. func (m *ContactMutation) SetWxWxid(s string) {
  2720. m.wx_wxid = &s
  2721. }
  2722. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  2723. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  2724. v := m.wx_wxid
  2725. if v == nil {
  2726. return
  2727. }
  2728. return *v, true
  2729. }
  2730. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  2731. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2733. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  2734. if !m.op.Is(OpUpdateOne) {
  2735. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  2736. }
  2737. if m.id == nil || m.oldValue == nil {
  2738. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  2739. }
  2740. oldValue, err := m.oldValue(ctx)
  2741. if err != nil {
  2742. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  2743. }
  2744. return oldValue.WxWxid, nil
  2745. }
  2746. // ClearWxWxid clears the value of the "wx_wxid" field.
  2747. func (m *ContactMutation) ClearWxWxid() {
  2748. m.wx_wxid = nil
  2749. m.clearedFields[contact.FieldWxWxid] = struct{}{}
  2750. }
  2751. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  2752. func (m *ContactMutation) WxWxidCleared() bool {
  2753. _, ok := m.clearedFields[contact.FieldWxWxid]
  2754. return ok
  2755. }
  2756. // ResetWxWxid resets all changes to the "wx_wxid" field.
  2757. func (m *ContactMutation) ResetWxWxid() {
  2758. m.wx_wxid = nil
  2759. delete(m.clearedFields, contact.FieldWxWxid)
  2760. }
  2761. // SetType sets the "type" field.
  2762. func (m *ContactMutation) SetType(i int) {
  2763. m._type = &i
  2764. m.add_type = nil
  2765. }
  2766. // GetType returns the value of the "type" field in the mutation.
  2767. func (m *ContactMutation) GetType() (r int, exists bool) {
  2768. v := m._type
  2769. if v == nil {
  2770. return
  2771. }
  2772. return *v, true
  2773. }
  2774. // OldType returns the old "type" field's value of the Contact entity.
  2775. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2777. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  2778. if !m.op.Is(OpUpdateOne) {
  2779. return v, errors.New("OldType is only allowed on UpdateOne operations")
  2780. }
  2781. if m.id == nil || m.oldValue == nil {
  2782. return v, errors.New("OldType requires an ID field in the mutation")
  2783. }
  2784. oldValue, err := m.oldValue(ctx)
  2785. if err != nil {
  2786. return v, fmt.Errorf("querying old value for OldType: %w", err)
  2787. }
  2788. return oldValue.Type, nil
  2789. }
  2790. // AddType adds i to the "type" field.
  2791. func (m *ContactMutation) AddType(i int) {
  2792. if m.add_type != nil {
  2793. *m.add_type += i
  2794. } else {
  2795. m.add_type = &i
  2796. }
  2797. }
  2798. // AddedType returns the value that was added to the "type" field in this mutation.
  2799. func (m *ContactMutation) AddedType() (r int, exists bool) {
  2800. v := m.add_type
  2801. if v == nil {
  2802. return
  2803. }
  2804. return *v, true
  2805. }
  2806. // ClearType clears the value of the "type" field.
  2807. func (m *ContactMutation) ClearType() {
  2808. m._type = nil
  2809. m.add_type = nil
  2810. m.clearedFields[contact.FieldType] = struct{}{}
  2811. }
  2812. // TypeCleared returns if the "type" field was cleared in this mutation.
  2813. func (m *ContactMutation) TypeCleared() bool {
  2814. _, ok := m.clearedFields[contact.FieldType]
  2815. return ok
  2816. }
  2817. // ResetType resets all changes to the "type" field.
  2818. func (m *ContactMutation) ResetType() {
  2819. m._type = nil
  2820. m.add_type = nil
  2821. delete(m.clearedFields, contact.FieldType)
  2822. }
  2823. // SetWxid sets the "wxid" field.
  2824. func (m *ContactMutation) SetWxid(s string) {
  2825. m.wxid = &s
  2826. }
  2827. // Wxid returns the value of the "wxid" field in the mutation.
  2828. func (m *ContactMutation) Wxid() (r string, exists bool) {
  2829. v := m.wxid
  2830. if v == nil {
  2831. return
  2832. }
  2833. return *v, true
  2834. }
  2835. // OldWxid returns the old "wxid" field's value of the Contact entity.
  2836. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2838. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  2839. if !m.op.Is(OpUpdateOne) {
  2840. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  2841. }
  2842. if m.id == nil || m.oldValue == nil {
  2843. return v, errors.New("OldWxid requires an ID field in the mutation")
  2844. }
  2845. oldValue, err := m.oldValue(ctx)
  2846. if err != nil {
  2847. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  2848. }
  2849. return oldValue.Wxid, nil
  2850. }
  2851. // ResetWxid resets all changes to the "wxid" field.
  2852. func (m *ContactMutation) ResetWxid() {
  2853. m.wxid = nil
  2854. }
  2855. // SetAccount sets the "account" field.
  2856. func (m *ContactMutation) SetAccount(s string) {
  2857. m.account = &s
  2858. }
  2859. // Account returns the value of the "account" field in the mutation.
  2860. func (m *ContactMutation) Account() (r string, exists bool) {
  2861. v := m.account
  2862. if v == nil {
  2863. return
  2864. }
  2865. return *v, true
  2866. }
  2867. // OldAccount returns the old "account" field's value of the Contact entity.
  2868. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2870. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  2871. if !m.op.Is(OpUpdateOne) {
  2872. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  2873. }
  2874. if m.id == nil || m.oldValue == nil {
  2875. return v, errors.New("OldAccount requires an ID field in the mutation")
  2876. }
  2877. oldValue, err := m.oldValue(ctx)
  2878. if err != nil {
  2879. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  2880. }
  2881. return oldValue.Account, nil
  2882. }
  2883. // ResetAccount resets all changes to the "account" field.
  2884. func (m *ContactMutation) ResetAccount() {
  2885. m.account = nil
  2886. }
  2887. // SetNickname sets the "nickname" field.
  2888. func (m *ContactMutation) SetNickname(s string) {
  2889. m.nickname = &s
  2890. }
  2891. // Nickname returns the value of the "nickname" field in the mutation.
  2892. func (m *ContactMutation) Nickname() (r string, exists bool) {
  2893. v := m.nickname
  2894. if v == nil {
  2895. return
  2896. }
  2897. return *v, true
  2898. }
  2899. // OldNickname returns the old "nickname" field's value of the Contact entity.
  2900. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2902. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  2903. if !m.op.Is(OpUpdateOne) {
  2904. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  2905. }
  2906. if m.id == nil || m.oldValue == nil {
  2907. return v, errors.New("OldNickname requires an ID field in the mutation")
  2908. }
  2909. oldValue, err := m.oldValue(ctx)
  2910. if err != nil {
  2911. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  2912. }
  2913. return oldValue.Nickname, nil
  2914. }
  2915. // ResetNickname resets all changes to the "nickname" field.
  2916. func (m *ContactMutation) ResetNickname() {
  2917. m.nickname = nil
  2918. }
  2919. // SetMarkname sets the "markname" field.
  2920. func (m *ContactMutation) SetMarkname(s string) {
  2921. m.markname = &s
  2922. }
  2923. // Markname returns the value of the "markname" field in the mutation.
  2924. func (m *ContactMutation) Markname() (r string, exists bool) {
  2925. v := m.markname
  2926. if v == nil {
  2927. return
  2928. }
  2929. return *v, true
  2930. }
  2931. // OldMarkname returns the old "markname" field's value of the Contact entity.
  2932. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2934. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  2935. if !m.op.Is(OpUpdateOne) {
  2936. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  2937. }
  2938. if m.id == nil || m.oldValue == nil {
  2939. return v, errors.New("OldMarkname requires an ID field in the mutation")
  2940. }
  2941. oldValue, err := m.oldValue(ctx)
  2942. if err != nil {
  2943. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  2944. }
  2945. return oldValue.Markname, nil
  2946. }
  2947. // ResetMarkname resets all changes to the "markname" field.
  2948. func (m *ContactMutation) ResetMarkname() {
  2949. m.markname = nil
  2950. }
  2951. // SetHeadimg sets the "headimg" field.
  2952. func (m *ContactMutation) SetHeadimg(s string) {
  2953. m.headimg = &s
  2954. }
  2955. // Headimg returns the value of the "headimg" field in the mutation.
  2956. func (m *ContactMutation) Headimg() (r string, exists bool) {
  2957. v := m.headimg
  2958. if v == nil {
  2959. return
  2960. }
  2961. return *v, true
  2962. }
  2963. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  2964. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2965. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2966. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  2967. if !m.op.Is(OpUpdateOne) {
  2968. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  2969. }
  2970. if m.id == nil || m.oldValue == nil {
  2971. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  2972. }
  2973. oldValue, err := m.oldValue(ctx)
  2974. if err != nil {
  2975. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  2976. }
  2977. return oldValue.Headimg, nil
  2978. }
  2979. // ResetHeadimg resets all changes to the "headimg" field.
  2980. func (m *ContactMutation) ResetHeadimg() {
  2981. m.headimg = nil
  2982. }
  2983. // SetSex sets the "sex" field.
  2984. func (m *ContactMutation) SetSex(i int) {
  2985. m.sex = &i
  2986. m.addsex = nil
  2987. }
  2988. // Sex returns the value of the "sex" field in the mutation.
  2989. func (m *ContactMutation) Sex() (r int, exists bool) {
  2990. v := m.sex
  2991. if v == nil {
  2992. return
  2993. }
  2994. return *v, true
  2995. }
  2996. // OldSex returns the old "sex" field's value of the Contact entity.
  2997. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2999. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  3000. if !m.op.Is(OpUpdateOne) {
  3001. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  3002. }
  3003. if m.id == nil || m.oldValue == nil {
  3004. return v, errors.New("OldSex requires an ID field in the mutation")
  3005. }
  3006. oldValue, err := m.oldValue(ctx)
  3007. if err != nil {
  3008. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  3009. }
  3010. return oldValue.Sex, nil
  3011. }
  3012. // AddSex adds i to the "sex" field.
  3013. func (m *ContactMutation) AddSex(i int) {
  3014. if m.addsex != nil {
  3015. *m.addsex += i
  3016. } else {
  3017. m.addsex = &i
  3018. }
  3019. }
  3020. // AddedSex returns the value that was added to the "sex" field in this mutation.
  3021. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  3022. v := m.addsex
  3023. if v == nil {
  3024. return
  3025. }
  3026. return *v, true
  3027. }
  3028. // ResetSex resets all changes to the "sex" field.
  3029. func (m *ContactMutation) ResetSex() {
  3030. m.sex = nil
  3031. m.addsex = nil
  3032. }
  3033. // SetStarrole sets the "starrole" field.
  3034. func (m *ContactMutation) SetStarrole(s string) {
  3035. m.starrole = &s
  3036. }
  3037. // Starrole returns the value of the "starrole" field in the mutation.
  3038. func (m *ContactMutation) Starrole() (r string, exists bool) {
  3039. v := m.starrole
  3040. if v == nil {
  3041. return
  3042. }
  3043. return *v, true
  3044. }
  3045. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  3046. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3048. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  3049. if !m.op.Is(OpUpdateOne) {
  3050. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  3051. }
  3052. if m.id == nil || m.oldValue == nil {
  3053. return v, errors.New("OldStarrole requires an ID field in the mutation")
  3054. }
  3055. oldValue, err := m.oldValue(ctx)
  3056. if err != nil {
  3057. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  3058. }
  3059. return oldValue.Starrole, nil
  3060. }
  3061. // ResetStarrole resets all changes to the "starrole" field.
  3062. func (m *ContactMutation) ResetStarrole() {
  3063. m.starrole = nil
  3064. }
  3065. // SetDontseeit sets the "dontseeit" field.
  3066. func (m *ContactMutation) SetDontseeit(i int) {
  3067. m.dontseeit = &i
  3068. m.adddontseeit = nil
  3069. }
  3070. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  3071. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  3072. v := m.dontseeit
  3073. if v == nil {
  3074. return
  3075. }
  3076. return *v, true
  3077. }
  3078. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  3079. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3081. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  3082. if !m.op.Is(OpUpdateOne) {
  3083. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  3084. }
  3085. if m.id == nil || m.oldValue == nil {
  3086. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  3087. }
  3088. oldValue, err := m.oldValue(ctx)
  3089. if err != nil {
  3090. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  3091. }
  3092. return oldValue.Dontseeit, nil
  3093. }
  3094. // AddDontseeit adds i to the "dontseeit" field.
  3095. func (m *ContactMutation) AddDontseeit(i int) {
  3096. if m.adddontseeit != nil {
  3097. *m.adddontseeit += i
  3098. } else {
  3099. m.adddontseeit = &i
  3100. }
  3101. }
  3102. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  3103. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  3104. v := m.adddontseeit
  3105. if v == nil {
  3106. return
  3107. }
  3108. return *v, true
  3109. }
  3110. // ResetDontseeit resets all changes to the "dontseeit" field.
  3111. func (m *ContactMutation) ResetDontseeit() {
  3112. m.dontseeit = nil
  3113. m.adddontseeit = nil
  3114. }
  3115. // SetDontseeme sets the "dontseeme" field.
  3116. func (m *ContactMutation) SetDontseeme(i int) {
  3117. m.dontseeme = &i
  3118. m.adddontseeme = nil
  3119. }
  3120. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  3121. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  3122. v := m.dontseeme
  3123. if v == nil {
  3124. return
  3125. }
  3126. return *v, true
  3127. }
  3128. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  3129. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3130. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3131. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  3132. if !m.op.Is(OpUpdateOne) {
  3133. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  3134. }
  3135. if m.id == nil || m.oldValue == nil {
  3136. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  3137. }
  3138. oldValue, err := m.oldValue(ctx)
  3139. if err != nil {
  3140. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  3141. }
  3142. return oldValue.Dontseeme, nil
  3143. }
  3144. // AddDontseeme adds i to the "dontseeme" field.
  3145. func (m *ContactMutation) AddDontseeme(i int) {
  3146. if m.adddontseeme != nil {
  3147. *m.adddontseeme += i
  3148. } else {
  3149. m.adddontseeme = &i
  3150. }
  3151. }
  3152. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  3153. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  3154. v := m.adddontseeme
  3155. if v == nil {
  3156. return
  3157. }
  3158. return *v, true
  3159. }
  3160. // ResetDontseeme resets all changes to the "dontseeme" field.
  3161. func (m *ContactMutation) ResetDontseeme() {
  3162. m.dontseeme = nil
  3163. m.adddontseeme = nil
  3164. }
  3165. // SetLag sets the "lag" field.
  3166. func (m *ContactMutation) SetLag(s string) {
  3167. m.lag = &s
  3168. }
  3169. // Lag returns the value of the "lag" field in the mutation.
  3170. func (m *ContactMutation) Lag() (r string, exists bool) {
  3171. v := m.lag
  3172. if v == nil {
  3173. return
  3174. }
  3175. return *v, true
  3176. }
  3177. // OldLag returns the old "lag" field's value of the Contact entity.
  3178. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3180. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  3181. if !m.op.Is(OpUpdateOne) {
  3182. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  3183. }
  3184. if m.id == nil || m.oldValue == nil {
  3185. return v, errors.New("OldLag requires an ID field in the mutation")
  3186. }
  3187. oldValue, err := m.oldValue(ctx)
  3188. if err != nil {
  3189. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  3190. }
  3191. return oldValue.Lag, nil
  3192. }
  3193. // ResetLag resets all changes to the "lag" field.
  3194. func (m *ContactMutation) ResetLag() {
  3195. m.lag = nil
  3196. }
  3197. // SetGid sets the "gid" field.
  3198. func (m *ContactMutation) SetGid(s string) {
  3199. m.gid = &s
  3200. }
  3201. // Gid returns the value of the "gid" field in the mutation.
  3202. func (m *ContactMutation) Gid() (r string, exists bool) {
  3203. v := m.gid
  3204. if v == nil {
  3205. return
  3206. }
  3207. return *v, true
  3208. }
  3209. // OldGid returns the old "gid" field's value of the Contact entity.
  3210. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3211. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3212. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  3213. if !m.op.Is(OpUpdateOne) {
  3214. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  3215. }
  3216. if m.id == nil || m.oldValue == nil {
  3217. return v, errors.New("OldGid requires an ID field in the mutation")
  3218. }
  3219. oldValue, err := m.oldValue(ctx)
  3220. if err != nil {
  3221. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  3222. }
  3223. return oldValue.Gid, nil
  3224. }
  3225. // ResetGid resets all changes to the "gid" field.
  3226. func (m *ContactMutation) ResetGid() {
  3227. m.gid = nil
  3228. }
  3229. // SetGname sets the "gname" field.
  3230. func (m *ContactMutation) SetGname(s string) {
  3231. m.gname = &s
  3232. }
  3233. // Gname returns the value of the "gname" field in the mutation.
  3234. func (m *ContactMutation) Gname() (r string, exists bool) {
  3235. v := m.gname
  3236. if v == nil {
  3237. return
  3238. }
  3239. return *v, true
  3240. }
  3241. // OldGname returns the old "gname" field's value of the Contact entity.
  3242. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3243. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3244. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  3245. if !m.op.Is(OpUpdateOne) {
  3246. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  3247. }
  3248. if m.id == nil || m.oldValue == nil {
  3249. return v, errors.New("OldGname requires an ID field in the mutation")
  3250. }
  3251. oldValue, err := m.oldValue(ctx)
  3252. if err != nil {
  3253. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  3254. }
  3255. return oldValue.Gname, nil
  3256. }
  3257. // ResetGname resets all changes to the "gname" field.
  3258. func (m *ContactMutation) ResetGname() {
  3259. m.gname = nil
  3260. }
  3261. // SetV3 sets the "v3" field.
  3262. func (m *ContactMutation) SetV3(s string) {
  3263. m.v3 = &s
  3264. }
  3265. // V3 returns the value of the "v3" field in the mutation.
  3266. func (m *ContactMutation) V3() (r string, exists bool) {
  3267. v := m.v3
  3268. if v == nil {
  3269. return
  3270. }
  3271. return *v, true
  3272. }
  3273. // OldV3 returns the old "v3" field's value of the Contact entity.
  3274. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3276. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  3277. if !m.op.Is(OpUpdateOne) {
  3278. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  3279. }
  3280. if m.id == nil || m.oldValue == nil {
  3281. return v, errors.New("OldV3 requires an ID field in the mutation")
  3282. }
  3283. oldValue, err := m.oldValue(ctx)
  3284. if err != nil {
  3285. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  3286. }
  3287. return oldValue.V3, nil
  3288. }
  3289. // ResetV3 resets all changes to the "v3" field.
  3290. func (m *ContactMutation) ResetV3() {
  3291. m.v3 = nil
  3292. }
  3293. // SetOrganizationID sets the "organization_id" field.
  3294. func (m *ContactMutation) SetOrganizationID(u uint64) {
  3295. m.organization_id = &u
  3296. m.addorganization_id = nil
  3297. }
  3298. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3299. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  3300. v := m.organization_id
  3301. if v == nil {
  3302. return
  3303. }
  3304. return *v, true
  3305. }
  3306. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  3307. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3309. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3310. if !m.op.Is(OpUpdateOne) {
  3311. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3312. }
  3313. if m.id == nil || m.oldValue == nil {
  3314. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3315. }
  3316. oldValue, err := m.oldValue(ctx)
  3317. if err != nil {
  3318. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3319. }
  3320. return oldValue.OrganizationID, nil
  3321. }
  3322. // AddOrganizationID adds u to the "organization_id" field.
  3323. func (m *ContactMutation) AddOrganizationID(u int64) {
  3324. if m.addorganization_id != nil {
  3325. *m.addorganization_id += u
  3326. } else {
  3327. m.addorganization_id = &u
  3328. }
  3329. }
  3330. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3331. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  3332. v := m.addorganization_id
  3333. if v == nil {
  3334. return
  3335. }
  3336. return *v, true
  3337. }
  3338. // ClearOrganizationID clears the value of the "organization_id" field.
  3339. func (m *ContactMutation) ClearOrganizationID() {
  3340. m.organization_id = nil
  3341. m.addorganization_id = nil
  3342. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  3343. }
  3344. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3345. func (m *ContactMutation) OrganizationIDCleared() bool {
  3346. _, ok := m.clearedFields[contact.FieldOrganizationID]
  3347. return ok
  3348. }
  3349. // ResetOrganizationID resets all changes to the "organization_id" field.
  3350. func (m *ContactMutation) ResetOrganizationID() {
  3351. m.organization_id = nil
  3352. m.addorganization_id = nil
  3353. delete(m.clearedFields, contact.FieldOrganizationID)
  3354. }
  3355. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  3356. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  3357. if m.contact_relationships == nil {
  3358. m.contact_relationships = make(map[uint64]struct{})
  3359. }
  3360. for i := range ids {
  3361. m.contact_relationships[ids[i]] = struct{}{}
  3362. }
  3363. }
  3364. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  3365. func (m *ContactMutation) ClearContactRelationships() {
  3366. m.clearedcontact_relationships = true
  3367. }
  3368. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  3369. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  3370. return m.clearedcontact_relationships
  3371. }
  3372. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  3373. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  3374. if m.removedcontact_relationships == nil {
  3375. m.removedcontact_relationships = make(map[uint64]struct{})
  3376. }
  3377. for i := range ids {
  3378. delete(m.contact_relationships, ids[i])
  3379. m.removedcontact_relationships[ids[i]] = struct{}{}
  3380. }
  3381. }
  3382. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  3383. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  3384. for id := range m.removedcontact_relationships {
  3385. ids = append(ids, id)
  3386. }
  3387. return
  3388. }
  3389. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  3390. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  3391. for id := range m.contact_relationships {
  3392. ids = append(ids, id)
  3393. }
  3394. return
  3395. }
  3396. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  3397. func (m *ContactMutation) ResetContactRelationships() {
  3398. m.contact_relationships = nil
  3399. m.clearedcontact_relationships = false
  3400. m.removedcontact_relationships = nil
  3401. }
  3402. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  3403. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  3404. if m.contact_messages == nil {
  3405. m.contact_messages = make(map[uint64]struct{})
  3406. }
  3407. for i := range ids {
  3408. m.contact_messages[ids[i]] = struct{}{}
  3409. }
  3410. }
  3411. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  3412. func (m *ContactMutation) ClearContactMessages() {
  3413. m.clearedcontact_messages = true
  3414. }
  3415. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  3416. func (m *ContactMutation) ContactMessagesCleared() bool {
  3417. return m.clearedcontact_messages
  3418. }
  3419. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  3420. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  3421. if m.removedcontact_messages == nil {
  3422. m.removedcontact_messages = make(map[uint64]struct{})
  3423. }
  3424. for i := range ids {
  3425. delete(m.contact_messages, ids[i])
  3426. m.removedcontact_messages[ids[i]] = struct{}{}
  3427. }
  3428. }
  3429. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  3430. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  3431. for id := range m.removedcontact_messages {
  3432. ids = append(ids, id)
  3433. }
  3434. return
  3435. }
  3436. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  3437. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  3438. for id := range m.contact_messages {
  3439. ids = append(ids, id)
  3440. }
  3441. return
  3442. }
  3443. // ResetContactMessages resets all changes to the "contact_messages" edge.
  3444. func (m *ContactMutation) ResetContactMessages() {
  3445. m.contact_messages = nil
  3446. m.clearedcontact_messages = false
  3447. m.removedcontact_messages = nil
  3448. }
  3449. // Where appends a list predicates to the ContactMutation builder.
  3450. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  3451. m.predicates = append(m.predicates, ps...)
  3452. }
  3453. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  3454. // users can use type-assertion to append predicates that do not depend on any generated package.
  3455. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  3456. p := make([]predicate.Contact, len(ps))
  3457. for i := range ps {
  3458. p[i] = ps[i]
  3459. }
  3460. m.Where(p...)
  3461. }
  3462. // Op returns the operation name.
  3463. func (m *ContactMutation) Op() Op {
  3464. return m.op
  3465. }
  3466. // SetOp allows setting the mutation operation.
  3467. func (m *ContactMutation) SetOp(op Op) {
  3468. m.op = op
  3469. }
  3470. // Type returns the node type of this mutation (Contact).
  3471. func (m *ContactMutation) Type() string {
  3472. return m.typ
  3473. }
  3474. // Fields returns all fields that were changed during this mutation. Note that in
  3475. // order to get all numeric fields that were incremented/decremented, call
  3476. // AddedFields().
  3477. func (m *ContactMutation) Fields() []string {
  3478. fields := make([]string, 0, 20)
  3479. if m.created_at != nil {
  3480. fields = append(fields, contact.FieldCreatedAt)
  3481. }
  3482. if m.updated_at != nil {
  3483. fields = append(fields, contact.FieldUpdatedAt)
  3484. }
  3485. if m.status != nil {
  3486. fields = append(fields, contact.FieldStatus)
  3487. }
  3488. if m.deleted_at != nil {
  3489. fields = append(fields, contact.FieldDeletedAt)
  3490. }
  3491. if m.wx_wxid != nil {
  3492. fields = append(fields, contact.FieldWxWxid)
  3493. }
  3494. if m._type != nil {
  3495. fields = append(fields, contact.FieldType)
  3496. }
  3497. if m.wxid != nil {
  3498. fields = append(fields, contact.FieldWxid)
  3499. }
  3500. if m.account != nil {
  3501. fields = append(fields, contact.FieldAccount)
  3502. }
  3503. if m.nickname != nil {
  3504. fields = append(fields, contact.FieldNickname)
  3505. }
  3506. if m.markname != nil {
  3507. fields = append(fields, contact.FieldMarkname)
  3508. }
  3509. if m.headimg != nil {
  3510. fields = append(fields, contact.FieldHeadimg)
  3511. }
  3512. if m.sex != nil {
  3513. fields = append(fields, contact.FieldSex)
  3514. }
  3515. if m.starrole != nil {
  3516. fields = append(fields, contact.FieldStarrole)
  3517. }
  3518. if m.dontseeit != nil {
  3519. fields = append(fields, contact.FieldDontseeit)
  3520. }
  3521. if m.dontseeme != nil {
  3522. fields = append(fields, contact.FieldDontseeme)
  3523. }
  3524. if m.lag != nil {
  3525. fields = append(fields, contact.FieldLag)
  3526. }
  3527. if m.gid != nil {
  3528. fields = append(fields, contact.FieldGid)
  3529. }
  3530. if m.gname != nil {
  3531. fields = append(fields, contact.FieldGname)
  3532. }
  3533. if m.v3 != nil {
  3534. fields = append(fields, contact.FieldV3)
  3535. }
  3536. if m.organization_id != nil {
  3537. fields = append(fields, contact.FieldOrganizationID)
  3538. }
  3539. return fields
  3540. }
  3541. // Field returns the value of a field with the given name. The second boolean
  3542. // return value indicates that this field was not set, or was not defined in the
  3543. // schema.
  3544. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  3545. switch name {
  3546. case contact.FieldCreatedAt:
  3547. return m.CreatedAt()
  3548. case contact.FieldUpdatedAt:
  3549. return m.UpdatedAt()
  3550. case contact.FieldStatus:
  3551. return m.Status()
  3552. case contact.FieldDeletedAt:
  3553. return m.DeletedAt()
  3554. case contact.FieldWxWxid:
  3555. return m.WxWxid()
  3556. case contact.FieldType:
  3557. return m.GetType()
  3558. case contact.FieldWxid:
  3559. return m.Wxid()
  3560. case contact.FieldAccount:
  3561. return m.Account()
  3562. case contact.FieldNickname:
  3563. return m.Nickname()
  3564. case contact.FieldMarkname:
  3565. return m.Markname()
  3566. case contact.FieldHeadimg:
  3567. return m.Headimg()
  3568. case contact.FieldSex:
  3569. return m.Sex()
  3570. case contact.FieldStarrole:
  3571. return m.Starrole()
  3572. case contact.FieldDontseeit:
  3573. return m.Dontseeit()
  3574. case contact.FieldDontseeme:
  3575. return m.Dontseeme()
  3576. case contact.FieldLag:
  3577. return m.Lag()
  3578. case contact.FieldGid:
  3579. return m.Gid()
  3580. case contact.FieldGname:
  3581. return m.Gname()
  3582. case contact.FieldV3:
  3583. return m.V3()
  3584. case contact.FieldOrganizationID:
  3585. return m.OrganizationID()
  3586. }
  3587. return nil, false
  3588. }
  3589. // OldField returns the old value of the field from the database. An error is
  3590. // returned if the mutation operation is not UpdateOne, or the query to the
  3591. // database failed.
  3592. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3593. switch name {
  3594. case contact.FieldCreatedAt:
  3595. return m.OldCreatedAt(ctx)
  3596. case contact.FieldUpdatedAt:
  3597. return m.OldUpdatedAt(ctx)
  3598. case contact.FieldStatus:
  3599. return m.OldStatus(ctx)
  3600. case contact.FieldDeletedAt:
  3601. return m.OldDeletedAt(ctx)
  3602. case contact.FieldWxWxid:
  3603. return m.OldWxWxid(ctx)
  3604. case contact.FieldType:
  3605. return m.OldType(ctx)
  3606. case contact.FieldWxid:
  3607. return m.OldWxid(ctx)
  3608. case contact.FieldAccount:
  3609. return m.OldAccount(ctx)
  3610. case contact.FieldNickname:
  3611. return m.OldNickname(ctx)
  3612. case contact.FieldMarkname:
  3613. return m.OldMarkname(ctx)
  3614. case contact.FieldHeadimg:
  3615. return m.OldHeadimg(ctx)
  3616. case contact.FieldSex:
  3617. return m.OldSex(ctx)
  3618. case contact.FieldStarrole:
  3619. return m.OldStarrole(ctx)
  3620. case contact.FieldDontseeit:
  3621. return m.OldDontseeit(ctx)
  3622. case contact.FieldDontseeme:
  3623. return m.OldDontseeme(ctx)
  3624. case contact.FieldLag:
  3625. return m.OldLag(ctx)
  3626. case contact.FieldGid:
  3627. return m.OldGid(ctx)
  3628. case contact.FieldGname:
  3629. return m.OldGname(ctx)
  3630. case contact.FieldV3:
  3631. return m.OldV3(ctx)
  3632. case contact.FieldOrganizationID:
  3633. return m.OldOrganizationID(ctx)
  3634. }
  3635. return nil, fmt.Errorf("unknown Contact field %s", name)
  3636. }
  3637. // SetField sets the value of a field with the given name. It returns an error if
  3638. // the field is not defined in the schema, or if the type mismatched the field
  3639. // type.
  3640. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  3641. switch name {
  3642. case contact.FieldCreatedAt:
  3643. v, ok := value.(time.Time)
  3644. if !ok {
  3645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3646. }
  3647. m.SetCreatedAt(v)
  3648. return nil
  3649. case contact.FieldUpdatedAt:
  3650. v, ok := value.(time.Time)
  3651. if !ok {
  3652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3653. }
  3654. m.SetUpdatedAt(v)
  3655. return nil
  3656. case contact.FieldStatus:
  3657. v, ok := value.(uint8)
  3658. if !ok {
  3659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3660. }
  3661. m.SetStatus(v)
  3662. return nil
  3663. case contact.FieldDeletedAt:
  3664. v, ok := value.(time.Time)
  3665. if !ok {
  3666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3667. }
  3668. m.SetDeletedAt(v)
  3669. return nil
  3670. case contact.FieldWxWxid:
  3671. v, ok := value.(string)
  3672. if !ok {
  3673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3674. }
  3675. m.SetWxWxid(v)
  3676. return nil
  3677. case contact.FieldType:
  3678. v, ok := value.(int)
  3679. if !ok {
  3680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3681. }
  3682. m.SetType(v)
  3683. return nil
  3684. case contact.FieldWxid:
  3685. v, ok := value.(string)
  3686. if !ok {
  3687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3688. }
  3689. m.SetWxid(v)
  3690. return nil
  3691. case contact.FieldAccount:
  3692. v, ok := value.(string)
  3693. if !ok {
  3694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3695. }
  3696. m.SetAccount(v)
  3697. return nil
  3698. case contact.FieldNickname:
  3699. v, ok := value.(string)
  3700. if !ok {
  3701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3702. }
  3703. m.SetNickname(v)
  3704. return nil
  3705. case contact.FieldMarkname:
  3706. v, ok := value.(string)
  3707. if !ok {
  3708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3709. }
  3710. m.SetMarkname(v)
  3711. return nil
  3712. case contact.FieldHeadimg:
  3713. v, ok := value.(string)
  3714. if !ok {
  3715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3716. }
  3717. m.SetHeadimg(v)
  3718. return nil
  3719. case contact.FieldSex:
  3720. v, ok := value.(int)
  3721. if !ok {
  3722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3723. }
  3724. m.SetSex(v)
  3725. return nil
  3726. case contact.FieldStarrole:
  3727. v, ok := value.(string)
  3728. if !ok {
  3729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3730. }
  3731. m.SetStarrole(v)
  3732. return nil
  3733. case contact.FieldDontseeit:
  3734. v, ok := value.(int)
  3735. if !ok {
  3736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3737. }
  3738. m.SetDontseeit(v)
  3739. return nil
  3740. case contact.FieldDontseeme:
  3741. v, ok := value.(int)
  3742. if !ok {
  3743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3744. }
  3745. m.SetDontseeme(v)
  3746. return nil
  3747. case contact.FieldLag:
  3748. v, ok := value.(string)
  3749. if !ok {
  3750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3751. }
  3752. m.SetLag(v)
  3753. return nil
  3754. case contact.FieldGid:
  3755. v, ok := value.(string)
  3756. if !ok {
  3757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3758. }
  3759. m.SetGid(v)
  3760. return nil
  3761. case contact.FieldGname:
  3762. v, ok := value.(string)
  3763. if !ok {
  3764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3765. }
  3766. m.SetGname(v)
  3767. return nil
  3768. case contact.FieldV3:
  3769. v, ok := value.(string)
  3770. if !ok {
  3771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3772. }
  3773. m.SetV3(v)
  3774. return nil
  3775. case contact.FieldOrganizationID:
  3776. v, ok := value.(uint64)
  3777. if !ok {
  3778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3779. }
  3780. m.SetOrganizationID(v)
  3781. return nil
  3782. }
  3783. return fmt.Errorf("unknown Contact field %s", name)
  3784. }
  3785. // AddedFields returns all numeric fields that were incremented/decremented during
  3786. // this mutation.
  3787. func (m *ContactMutation) AddedFields() []string {
  3788. var fields []string
  3789. if m.addstatus != nil {
  3790. fields = append(fields, contact.FieldStatus)
  3791. }
  3792. if m.add_type != nil {
  3793. fields = append(fields, contact.FieldType)
  3794. }
  3795. if m.addsex != nil {
  3796. fields = append(fields, contact.FieldSex)
  3797. }
  3798. if m.adddontseeit != nil {
  3799. fields = append(fields, contact.FieldDontseeit)
  3800. }
  3801. if m.adddontseeme != nil {
  3802. fields = append(fields, contact.FieldDontseeme)
  3803. }
  3804. if m.addorganization_id != nil {
  3805. fields = append(fields, contact.FieldOrganizationID)
  3806. }
  3807. return fields
  3808. }
  3809. // AddedField returns the numeric value that was incremented/decremented on a field
  3810. // with the given name. The second boolean return value indicates that this field
  3811. // was not set, or was not defined in the schema.
  3812. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  3813. switch name {
  3814. case contact.FieldStatus:
  3815. return m.AddedStatus()
  3816. case contact.FieldType:
  3817. return m.AddedType()
  3818. case contact.FieldSex:
  3819. return m.AddedSex()
  3820. case contact.FieldDontseeit:
  3821. return m.AddedDontseeit()
  3822. case contact.FieldDontseeme:
  3823. return m.AddedDontseeme()
  3824. case contact.FieldOrganizationID:
  3825. return m.AddedOrganizationID()
  3826. }
  3827. return nil, false
  3828. }
  3829. // AddField adds the value to the field with the given name. It returns an error if
  3830. // the field is not defined in the schema, or if the type mismatched the field
  3831. // type.
  3832. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  3833. switch name {
  3834. case contact.FieldStatus:
  3835. v, ok := value.(int8)
  3836. if !ok {
  3837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3838. }
  3839. m.AddStatus(v)
  3840. return nil
  3841. case contact.FieldType:
  3842. v, ok := value.(int)
  3843. if !ok {
  3844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3845. }
  3846. m.AddType(v)
  3847. return nil
  3848. case contact.FieldSex:
  3849. v, ok := value.(int)
  3850. if !ok {
  3851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3852. }
  3853. m.AddSex(v)
  3854. return nil
  3855. case contact.FieldDontseeit:
  3856. v, ok := value.(int)
  3857. if !ok {
  3858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3859. }
  3860. m.AddDontseeit(v)
  3861. return nil
  3862. case contact.FieldDontseeme:
  3863. v, ok := value.(int)
  3864. if !ok {
  3865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3866. }
  3867. m.AddDontseeme(v)
  3868. return nil
  3869. case contact.FieldOrganizationID:
  3870. v, ok := value.(int64)
  3871. if !ok {
  3872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3873. }
  3874. m.AddOrganizationID(v)
  3875. return nil
  3876. }
  3877. return fmt.Errorf("unknown Contact numeric field %s", name)
  3878. }
  3879. // ClearedFields returns all nullable fields that were cleared during this
  3880. // mutation.
  3881. func (m *ContactMutation) ClearedFields() []string {
  3882. var fields []string
  3883. if m.FieldCleared(contact.FieldStatus) {
  3884. fields = append(fields, contact.FieldStatus)
  3885. }
  3886. if m.FieldCleared(contact.FieldDeletedAt) {
  3887. fields = append(fields, contact.FieldDeletedAt)
  3888. }
  3889. if m.FieldCleared(contact.FieldWxWxid) {
  3890. fields = append(fields, contact.FieldWxWxid)
  3891. }
  3892. if m.FieldCleared(contact.FieldType) {
  3893. fields = append(fields, contact.FieldType)
  3894. }
  3895. if m.FieldCleared(contact.FieldOrganizationID) {
  3896. fields = append(fields, contact.FieldOrganizationID)
  3897. }
  3898. return fields
  3899. }
  3900. // FieldCleared returns a boolean indicating if a field with the given name was
  3901. // cleared in this mutation.
  3902. func (m *ContactMutation) FieldCleared(name string) bool {
  3903. _, ok := m.clearedFields[name]
  3904. return ok
  3905. }
  3906. // ClearField clears the value of the field with the given name. It returns an
  3907. // error if the field is not defined in the schema.
  3908. func (m *ContactMutation) ClearField(name string) error {
  3909. switch name {
  3910. case contact.FieldStatus:
  3911. m.ClearStatus()
  3912. return nil
  3913. case contact.FieldDeletedAt:
  3914. m.ClearDeletedAt()
  3915. return nil
  3916. case contact.FieldWxWxid:
  3917. m.ClearWxWxid()
  3918. return nil
  3919. case contact.FieldType:
  3920. m.ClearType()
  3921. return nil
  3922. case contact.FieldOrganizationID:
  3923. m.ClearOrganizationID()
  3924. return nil
  3925. }
  3926. return fmt.Errorf("unknown Contact nullable field %s", name)
  3927. }
  3928. // ResetField resets all changes in the mutation for the field with the given name.
  3929. // It returns an error if the field is not defined in the schema.
  3930. func (m *ContactMutation) ResetField(name string) error {
  3931. switch name {
  3932. case contact.FieldCreatedAt:
  3933. m.ResetCreatedAt()
  3934. return nil
  3935. case contact.FieldUpdatedAt:
  3936. m.ResetUpdatedAt()
  3937. return nil
  3938. case contact.FieldStatus:
  3939. m.ResetStatus()
  3940. return nil
  3941. case contact.FieldDeletedAt:
  3942. m.ResetDeletedAt()
  3943. return nil
  3944. case contact.FieldWxWxid:
  3945. m.ResetWxWxid()
  3946. return nil
  3947. case contact.FieldType:
  3948. m.ResetType()
  3949. return nil
  3950. case contact.FieldWxid:
  3951. m.ResetWxid()
  3952. return nil
  3953. case contact.FieldAccount:
  3954. m.ResetAccount()
  3955. return nil
  3956. case contact.FieldNickname:
  3957. m.ResetNickname()
  3958. return nil
  3959. case contact.FieldMarkname:
  3960. m.ResetMarkname()
  3961. return nil
  3962. case contact.FieldHeadimg:
  3963. m.ResetHeadimg()
  3964. return nil
  3965. case contact.FieldSex:
  3966. m.ResetSex()
  3967. return nil
  3968. case contact.FieldStarrole:
  3969. m.ResetStarrole()
  3970. return nil
  3971. case contact.FieldDontseeit:
  3972. m.ResetDontseeit()
  3973. return nil
  3974. case contact.FieldDontseeme:
  3975. m.ResetDontseeme()
  3976. return nil
  3977. case contact.FieldLag:
  3978. m.ResetLag()
  3979. return nil
  3980. case contact.FieldGid:
  3981. m.ResetGid()
  3982. return nil
  3983. case contact.FieldGname:
  3984. m.ResetGname()
  3985. return nil
  3986. case contact.FieldV3:
  3987. m.ResetV3()
  3988. return nil
  3989. case contact.FieldOrganizationID:
  3990. m.ResetOrganizationID()
  3991. return nil
  3992. }
  3993. return fmt.Errorf("unknown Contact field %s", name)
  3994. }
  3995. // AddedEdges returns all edge names that were set/added in this mutation.
  3996. func (m *ContactMutation) AddedEdges() []string {
  3997. edges := make([]string, 0, 2)
  3998. if m.contact_relationships != nil {
  3999. edges = append(edges, contact.EdgeContactRelationships)
  4000. }
  4001. if m.contact_messages != nil {
  4002. edges = append(edges, contact.EdgeContactMessages)
  4003. }
  4004. return edges
  4005. }
  4006. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4007. // name in this mutation.
  4008. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  4009. switch name {
  4010. case contact.EdgeContactRelationships:
  4011. ids := make([]ent.Value, 0, len(m.contact_relationships))
  4012. for id := range m.contact_relationships {
  4013. ids = append(ids, id)
  4014. }
  4015. return ids
  4016. case contact.EdgeContactMessages:
  4017. ids := make([]ent.Value, 0, len(m.contact_messages))
  4018. for id := range m.contact_messages {
  4019. ids = append(ids, id)
  4020. }
  4021. return ids
  4022. }
  4023. return nil
  4024. }
  4025. // RemovedEdges returns all edge names that were removed in this mutation.
  4026. func (m *ContactMutation) RemovedEdges() []string {
  4027. edges := make([]string, 0, 2)
  4028. if m.removedcontact_relationships != nil {
  4029. edges = append(edges, contact.EdgeContactRelationships)
  4030. }
  4031. if m.removedcontact_messages != nil {
  4032. edges = append(edges, contact.EdgeContactMessages)
  4033. }
  4034. return edges
  4035. }
  4036. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4037. // the given name in this mutation.
  4038. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  4039. switch name {
  4040. case contact.EdgeContactRelationships:
  4041. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  4042. for id := range m.removedcontact_relationships {
  4043. ids = append(ids, id)
  4044. }
  4045. return ids
  4046. case contact.EdgeContactMessages:
  4047. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  4048. for id := range m.removedcontact_messages {
  4049. ids = append(ids, id)
  4050. }
  4051. return ids
  4052. }
  4053. return nil
  4054. }
  4055. // ClearedEdges returns all edge names that were cleared in this mutation.
  4056. func (m *ContactMutation) ClearedEdges() []string {
  4057. edges := make([]string, 0, 2)
  4058. if m.clearedcontact_relationships {
  4059. edges = append(edges, contact.EdgeContactRelationships)
  4060. }
  4061. if m.clearedcontact_messages {
  4062. edges = append(edges, contact.EdgeContactMessages)
  4063. }
  4064. return edges
  4065. }
  4066. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4067. // was cleared in this mutation.
  4068. func (m *ContactMutation) EdgeCleared(name string) bool {
  4069. switch name {
  4070. case contact.EdgeContactRelationships:
  4071. return m.clearedcontact_relationships
  4072. case contact.EdgeContactMessages:
  4073. return m.clearedcontact_messages
  4074. }
  4075. return false
  4076. }
  4077. // ClearEdge clears the value of the edge with the given name. It returns an error
  4078. // if that edge is not defined in the schema.
  4079. func (m *ContactMutation) ClearEdge(name string) error {
  4080. switch name {
  4081. }
  4082. return fmt.Errorf("unknown Contact unique edge %s", name)
  4083. }
  4084. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4085. // It returns an error if the edge is not defined in the schema.
  4086. func (m *ContactMutation) ResetEdge(name string) error {
  4087. switch name {
  4088. case contact.EdgeContactRelationships:
  4089. m.ResetContactRelationships()
  4090. return nil
  4091. case contact.EdgeContactMessages:
  4092. m.ResetContactMessages()
  4093. return nil
  4094. }
  4095. return fmt.Errorf("unknown Contact edge %s", name)
  4096. }
  4097. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  4098. type LabelMutation struct {
  4099. config
  4100. op Op
  4101. typ string
  4102. id *uint64
  4103. created_at *time.Time
  4104. updated_at *time.Time
  4105. status *uint8
  4106. addstatus *int8
  4107. _type *int
  4108. add_type *int
  4109. name *string
  4110. from *int
  4111. addfrom *int
  4112. mode *int
  4113. addmode *int
  4114. conditions *string
  4115. organization_id *uint64
  4116. addorganization_id *int64
  4117. clearedFields map[string]struct{}
  4118. label_relationships map[uint64]struct{}
  4119. removedlabel_relationships map[uint64]struct{}
  4120. clearedlabel_relationships bool
  4121. done bool
  4122. oldValue func(context.Context) (*Label, error)
  4123. predicates []predicate.Label
  4124. }
  4125. var _ ent.Mutation = (*LabelMutation)(nil)
  4126. // labelOption allows management of the mutation configuration using functional options.
  4127. type labelOption func(*LabelMutation)
  4128. // newLabelMutation creates new mutation for the Label entity.
  4129. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  4130. m := &LabelMutation{
  4131. config: c,
  4132. op: op,
  4133. typ: TypeLabel,
  4134. clearedFields: make(map[string]struct{}),
  4135. }
  4136. for _, opt := range opts {
  4137. opt(m)
  4138. }
  4139. return m
  4140. }
  4141. // withLabelID sets the ID field of the mutation.
  4142. func withLabelID(id uint64) labelOption {
  4143. return func(m *LabelMutation) {
  4144. var (
  4145. err error
  4146. once sync.Once
  4147. value *Label
  4148. )
  4149. m.oldValue = func(ctx context.Context) (*Label, error) {
  4150. once.Do(func() {
  4151. if m.done {
  4152. err = errors.New("querying old values post mutation is not allowed")
  4153. } else {
  4154. value, err = m.Client().Label.Get(ctx, id)
  4155. }
  4156. })
  4157. return value, err
  4158. }
  4159. m.id = &id
  4160. }
  4161. }
  4162. // withLabel sets the old Label of the mutation.
  4163. func withLabel(node *Label) labelOption {
  4164. return func(m *LabelMutation) {
  4165. m.oldValue = func(context.Context) (*Label, error) {
  4166. return node, nil
  4167. }
  4168. m.id = &node.ID
  4169. }
  4170. }
  4171. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4172. // executed in a transaction (ent.Tx), a transactional client is returned.
  4173. func (m LabelMutation) Client() *Client {
  4174. client := &Client{config: m.config}
  4175. client.init()
  4176. return client
  4177. }
  4178. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4179. // it returns an error otherwise.
  4180. func (m LabelMutation) Tx() (*Tx, error) {
  4181. if _, ok := m.driver.(*txDriver); !ok {
  4182. return nil, errors.New("ent: mutation is not running in a transaction")
  4183. }
  4184. tx := &Tx{config: m.config}
  4185. tx.init()
  4186. return tx, nil
  4187. }
  4188. // SetID sets the value of the id field. Note that this
  4189. // operation is only accepted on creation of Label entities.
  4190. func (m *LabelMutation) SetID(id uint64) {
  4191. m.id = &id
  4192. }
  4193. // ID returns the ID value in the mutation. Note that the ID is only available
  4194. // if it was provided to the builder or after it was returned from the database.
  4195. func (m *LabelMutation) ID() (id uint64, exists bool) {
  4196. if m.id == nil {
  4197. return
  4198. }
  4199. return *m.id, true
  4200. }
  4201. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4202. // That means, if the mutation is applied within a transaction with an isolation level such
  4203. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4204. // or updated by the mutation.
  4205. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  4206. switch {
  4207. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4208. id, exists := m.ID()
  4209. if exists {
  4210. return []uint64{id}, nil
  4211. }
  4212. fallthrough
  4213. case m.op.Is(OpUpdate | OpDelete):
  4214. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  4215. default:
  4216. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4217. }
  4218. }
  4219. // SetCreatedAt sets the "created_at" field.
  4220. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  4221. m.created_at = &t
  4222. }
  4223. // CreatedAt returns the value of the "created_at" field in the mutation.
  4224. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  4225. v := m.created_at
  4226. if v == nil {
  4227. return
  4228. }
  4229. return *v, true
  4230. }
  4231. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  4232. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4234. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4235. if !m.op.Is(OpUpdateOne) {
  4236. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4237. }
  4238. if m.id == nil || m.oldValue == nil {
  4239. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4240. }
  4241. oldValue, err := m.oldValue(ctx)
  4242. if err != nil {
  4243. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4244. }
  4245. return oldValue.CreatedAt, nil
  4246. }
  4247. // ResetCreatedAt resets all changes to the "created_at" field.
  4248. func (m *LabelMutation) ResetCreatedAt() {
  4249. m.created_at = nil
  4250. }
  4251. // SetUpdatedAt sets the "updated_at" field.
  4252. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  4253. m.updated_at = &t
  4254. }
  4255. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4256. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  4257. v := m.updated_at
  4258. if v == nil {
  4259. return
  4260. }
  4261. return *v, true
  4262. }
  4263. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  4264. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4266. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4267. if !m.op.Is(OpUpdateOne) {
  4268. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4269. }
  4270. if m.id == nil || m.oldValue == nil {
  4271. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4272. }
  4273. oldValue, err := m.oldValue(ctx)
  4274. if err != nil {
  4275. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4276. }
  4277. return oldValue.UpdatedAt, nil
  4278. }
  4279. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4280. func (m *LabelMutation) ResetUpdatedAt() {
  4281. m.updated_at = nil
  4282. }
  4283. // SetStatus sets the "status" field.
  4284. func (m *LabelMutation) SetStatus(u uint8) {
  4285. m.status = &u
  4286. m.addstatus = nil
  4287. }
  4288. // Status returns the value of the "status" field in the mutation.
  4289. func (m *LabelMutation) Status() (r uint8, exists bool) {
  4290. v := m.status
  4291. if v == nil {
  4292. return
  4293. }
  4294. return *v, true
  4295. }
  4296. // OldStatus returns the old "status" field's value of the Label entity.
  4297. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4299. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4300. if !m.op.Is(OpUpdateOne) {
  4301. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4302. }
  4303. if m.id == nil || m.oldValue == nil {
  4304. return v, errors.New("OldStatus requires an ID field in the mutation")
  4305. }
  4306. oldValue, err := m.oldValue(ctx)
  4307. if err != nil {
  4308. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4309. }
  4310. return oldValue.Status, nil
  4311. }
  4312. // AddStatus adds u to the "status" field.
  4313. func (m *LabelMutation) AddStatus(u int8) {
  4314. if m.addstatus != nil {
  4315. *m.addstatus += u
  4316. } else {
  4317. m.addstatus = &u
  4318. }
  4319. }
  4320. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4321. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  4322. v := m.addstatus
  4323. if v == nil {
  4324. return
  4325. }
  4326. return *v, true
  4327. }
  4328. // ClearStatus clears the value of the "status" field.
  4329. func (m *LabelMutation) ClearStatus() {
  4330. m.status = nil
  4331. m.addstatus = nil
  4332. m.clearedFields[label.FieldStatus] = struct{}{}
  4333. }
  4334. // StatusCleared returns if the "status" field was cleared in this mutation.
  4335. func (m *LabelMutation) StatusCleared() bool {
  4336. _, ok := m.clearedFields[label.FieldStatus]
  4337. return ok
  4338. }
  4339. // ResetStatus resets all changes to the "status" field.
  4340. func (m *LabelMutation) ResetStatus() {
  4341. m.status = nil
  4342. m.addstatus = nil
  4343. delete(m.clearedFields, label.FieldStatus)
  4344. }
  4345. // SetType sets the "type" field.
  4346. func (m *LabelMutation) SetType(i int) {
  4347. m._type = &i
  4348. m.add_type = nil
  4349. }
  4350. // GetType returns the value of the "type" field in the mutation.
  4351. func (m *LabelMutation) GetType() (r int, exists bool) {
  4352. v := m._type
  4353. if v == nil {
  4354. return
  4355. }
  4356. return *v, true
  4357. }
  4358. // OldType returns the old "type" field's value of the Label entity.
  4359. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4361. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  4362. if !m.op.Is(OpUpdateOne) {
  4363. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4364. }
  4365. if m.id == nil || m.oldValue == nil {
  4366. return v, errors.New("OldType requires an ID field in the mutation")
  4367. }
  4368. oldValue, err := m.oldValue(ctx)
  4369. if err != nil {
  4370. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4371. }
  4372. return oldValue.Type, nil
  4373. }
  4374. // AddType adds i to the "type" field.
  4375. func (m *LabelMutation) AddType(i int) {
  4376. if m.add_type != nil {
  4377. *m.add_type += i
  4378. } else {
  4379. m.add_type = &i
  4380. }
  4381. }
  4382. // AddedType returns the value that was added to the "type" field in this mutation.
  4383. func (m *LabelMutation) AddedType() (r int, exists bool) {
  4384. v := m.add_type
  4385. if v == nil {
  4386. return
  4387. }
  4388. return *v, true
  4389. }
  4390. // ResetType resets all changes to the "type" field.
  4391. func (m *LabelMutation) ResetType() {
  4392. m._type = nil
  4393. m.add_type = nil
  4394. }
  4395. // SetName sets the "name" field.
  4396. func (m *LabelMutation) SetName(s string) {
  4397. m.name = &s
  4398. }
  4399. // Name returns the value of the "name" field in the mutation.
  4400. func (m *LabelMutation) Name() (r string, exists bool) {
  4401. v := m.name
  4402. if v == nil {
  4403. return
  4404. }
  4405. return *v, true
  4406. }
  4407. // OldName returns the old "name" field's value of the Label entity.
  4408. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4410. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  4411. if !m.op.Is(OpUpdateOne) {
  4412. return v, errors.New("OldName is only allowed on UpdateOne operations")
  4413. }
  4414. if m.id == nil || m.oldValue == nil {
  4415. return v, errors.New("OldName requires an ID field in the mutation")
  4416. }
  4417. oldValue, err := m.oldValue(ctx)
  4418. if err != nil {
  4419. return v, fmt.Errorf("querying old value for OldName: %w", err)
  4420. }
  4421. return oldValue.Name, nil
  4422. }
  4423. // ResetName resets all changes to the "name" field.
  4424. func (m *LabelMutation) ResetName() {
  4425. m.name = nil
  4426. }
  4427. // SetFrom sets the "from" field.
  4428. func (m *LabelMutation) SetFrom(i int) {
  4429. m.from = &i
  4430. m.addfrom = nil
  4431. }
  4432. // From returns the value of the "from" field in the mutation.
  4433. func (m *LabelMutation) From() (r int, exists bool) {
  4434. v := m.from
  4435. if v == nil {
  4436. return
  4437. }
  4438. return *v, true
  4439. }
  4440. // OldFrom returns the old "from" field's value of the Label entity.
  4441. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4443. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  4444. if !m.op.Is(OpUpdateOne) {
  4445. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  4446. }
  4447. if m.id == nil || m.oldValue == nil {
  4448. return v, errors.New("OldFrom requires an ID field in the mutation")
  4449. }
  4450. oldValue, err := m.oldValue(ctx)
  4451. if err != nil {
  4452. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  4453. }
  4454. return oldValue.From, nil
  4455. }
  4456. // AddFrom adds i to the "from" field.
  4457. func (m *LabelMutation) AddFrom(i int) {
  4458. if m.addfrom != nil {
  4459. *m.addfrom += i
  4460. } else {
  4461. m.addfrom = &i
  4462. }
  4463. }
  4464. // AddedFrom returns the value that was added to the "from" field in this mutation.
  4465. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  4466. v := m.addfrom
  4467. if v == nil {
  4468. return
  4469. }
  4470. return *v, true
  4471. }
  4472. // ResetFrom resets all changes to the "from" field.
  4473. func (m *LabelMutation) ResetFrom() {
  4474. m.from = nil
  4475. m.addfrom = nil
  4476. }
  4477. // SetMode sets the "mode" field.
  4478. func (m *LabelMutation) SetMode(i int) {
  4479. m.mode = &i
  4480. m.addmode = nil
  4481. }
  4482. // Mode returns the value of the "mode" field in the mutation.
  4483. func (m *LabelMutation) Mode() (r int, exists bool) {
  4484. v := m.mode
  4485. if v == nil {
  4486. return
  4487. }
  4488. return *v, true
  4489. }
  4490. // OldMode returns the old "mode" field's value of the Label entity.
  4491. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4493. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  4494. if !m.op.Is(OpUpdateOne) {
  4495. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  4496. }
  4497. if m.id == nil || m.oldValue == nil {
  4498. return v, errors.New("OldMode requires an ID field in the mutation")
  4499. }
  4500. oldValue, err := m.oldValue(ctx)
  4501. if err != nil {
  4502. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  4503. }
  4504. return oldValue.Mode, nil
  4505. }
  4506. // AddMode adds i to the "mode" field.
  4507. func (m *LabelMutation) AddMode(i int) {
  4508. if m.addmode != nil {
  4509. *m.addmode += i
  4510. } else {
  4511. m.addmode = &i
  4512. }
  4513. }
  4514. // AddedMode returns the value that was added to the "mode" field in this mutation.
  4515. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  4516. v := m.addmode
  4517. if v == nil {
  4518. return
  4519. }
  4520. return *v, true
  4521. }
  4522. // ResetMode resets all changes to the "mode" field.
  4523. func (m *LabelMutation) ResetMode() {
  4524. m.mode = nil
  4525. m.addmode = nil
  4526. }
  4527. // SetConditions sets the "conditions" field.
  4528. func (m *LabelMutation) SetConditions(s string) {
  4529. m.conditions = &s
  4530. }
  4531. // Conditions returns the value of the "conditions" field in the mutation.
  4532. func (m *LabelMutation) Conditions() (r string, exists bool) {
  4533. v := m.conditions
  4534. if v == nil {
  4535. return
  4536. }
  4537. return *v, true
  4538. }
  4539. // OldConditions returns the old "conditions" field's value of the Label entity.
  4540. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4542. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  4543. if !m.op.Is(OpUpdateOne) {
  4544. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  4545. }
  4546. if m.id == nil || m.oldValue == nil {
  4547. return v, errors.New("OldConditions requires an ID field in the mutation")
  4548. }
  4549. oldValue, err := m.oldValue(ctx)
  4550. if err != nil {
  4551. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  4552. }
  4553. return oldValue.Conditions, nil
  4554. }
  4555. // ClearConditions clears the value of the "conditions" field.
  4556. func (m *LabelMutation) ClearConditions() {
  4557. m.conditions = nil
  4558. m.clearedFields[label.FieldConditions] = struct{}{}
  4559. }
  4560. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  4561. func (m *LabelMutation) ConditionsCleared() bool {
  4562. _, ok := m.clearedFields[label.FieldConditions]
  4563. return ok
  4564. }
  4565. // ResetConditions resets all changes to the "conditions" field.
  4566. func (m *LabelMutation) ResetConditions() {
  4567. m.conditions = nil
  4568. delete(m.clearedFields, label.FieldConditions)
  4569. }
  4570. // SetOrganizationID sets the "organization_id" field.
  4571. func (m *LabelMutation) SetOrganizationID(u uint64) {
  4572. m.organization_id = &u
  4573. m.addorganization_id = nil
  4574. }
  4575. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4576. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  4577. v := m.organization_id
  4578. if v == nil {
  4579. return
  4580. }
  4581. return *v, true
  4582. }
  4583. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  4584. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4586. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4587. if !m.op.Is(OpUpdateOne) {
  4588. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4589. }
  4590. if m.id == nil || m.oldValue == nil {
  4591. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4592. }
  4593. oldValue, err := m.oldValue(ctx)
  4594. if err != nil {
  4595. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4596. }
  4597. return oldValue.OrganizationID, nil
  4598. }
  4599. // AddOrganizationID adds u to the "organization_id" field.
  4600. func (m *LabelMutation) AddOrganizationID(u int64) {
  4601. if m.addorganization_id != nil {
  4602. *m.addorganization_id += u
  4603. } else {
  4604. m.addorganization_id = &u
  4605. }
  4606. }
  4607. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4608. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  4609. v := m.addorganization_id
  4610. if v == nil {
  4611. return
  4612. }
  4613. return *v, true
  4614. }
  4615. // ClearOrganizationID clears the value of the "organization_id" field.
  4616. func (m *LabelMutation) ClearOrganizationID() {
  4617. m.organization_id = nil
  4618. m.addorganization_id = nil
  4619. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  4620. }
  4621. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  4622. func (m *LabelMutation) OrganizationIDCleared() bool {
  4623. _, ok := m.clearedFields[label.FieldOrganizationID]
  4624. return ok
  4625. }
  4626. // ResetOrganizationID resets all changes to the "organization_id" field.
  4627. func (m *LabelMutation) ResetOrganizationID() {
  4628. m.organization_id = nil
  4629. m.addorganization_id = nil
  4630. delete(m.clearedFields, label.FieldOrganizationID)
  4631. }
  4632. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  4633. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  4634. if m.label_relationships == nil {
  4635. m.label_relationships = make(map[uint64]struct{})
  4636. }
  4637. for i := range ids {
  4638. m.label_relationships[ids[i]] = struct{}{}
  4639. }
  4640. }
  4641. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  4642. func (m *LabelMutation) ClearLabelRelationships() {
  4643. m.clearedlabel_relationships = true
  4644. }
  4645. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  4646. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  4647. return m.clearedlabel_relationships
  4648. }
  4649. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  4650. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  4651. if m.removedlabel_relationships == nil {
  4652. m.removedlabel_relationships = make(map[uint64]struct{})
  4653. }
  4654. for i := range ids {
  4655. delete(m.label_relationships, ids[i])
  4656. m.removedlabel_relationships[ids[i]] = struct{}{}
  4657. }
  4658. }
  4659. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  4660. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  4661. for id := range m.removedlabel_relationships {
  4662. ids = append(ids, id)
  4663. }
  4664. return
  4665. }
  4666. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  4667. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  4668. for id := range m.label_relationships {
  4669. ids = append(ids, id)
  4670. }
  4671. return
  4672. }
  4673. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  4674. func (m *LabelMutation) ResetLabelRelationships() {
  4675. m.label_relationships = nil
  4676. m.clearedlabel_relationships = false
  4677. m.removedlabel_relationships = nil
  4678. }
  4679. // Where appends a list predicates to the LabelMutation builder.
  4680. func (m *LabelMutation) Where(ps ...predicate.Label) {
  4681. m.predicates = append(m.predicates, ps...)
  4682. }
  4683. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  4684. // users can use type-assertion to append predicates that do not depend on any generated package.
  4685. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  4686. p := make([]predicate.Label, len(ps))
  4687. for i := range ps {
  4688. p[i] = ps[i]
  4689. }
  4690. m.Where(p...)
  4691. }
  4692. // Op returns the operation name.
  4693. func (m *LabelMutation) Op() Op {
  4694. return m.op
  4695. }
  4696. // SetOp allows setting the mutation operation.
  4697. func (m *LabelMutation) SetOp(op Op) {
  4698. m.op = op
  4699. }
  4700. // Type returns the node type of this mutation (Label).
  4701. func (m *LabelMutation) Type() string {
  4702. return m.typ
  4703. }
  4704. // Fields returns all fields that were changed during this mutation. Note that in
  4705. // order to get all numeric fields that were incremented/decremented, call
  4706. // AddedFields().
  4707. func (m *LabelMutation) Fields() []string {
  4708. fields := make([]string, 0, 9)
  4709. if m.created_at != nil {
  4710. fields = append(fields, label.FieldCreatedAt)
  4711. }
  4712. if m.updated_at != nil {
  4713. fields = append(fields, label.FieldUpdatedAt)
  4714. }
  4715. if m.status != nil {
  4716. fields = append(fields, label.FieldStatus)
  4717. }
  4718. if m._type != nil {
  4719. fields = append(fields, label.FieldType)
  4720. }
  4721. if m.name != nil {
  4722. fields = append(fields, label.FieldName)
  4723. }
  4724. if m.from != nil {
  4725. fields = append(fields, label.FieldFrom)
  4726. }
  4727. if m.mode != nil {
  4728. fields = append(fields, label.FieldMode)
  4729. }
  4730. if m.conditions != nil {
  4731. fields = append(fields, label.FieldConditions)
  4732. }
  4733. if m.organization_id != nil {
  4734. fields = append(fields, label.FieldOrganizationID)
  4735. }
  4736. return fields
  4737. }
  4738. // Field returns the value of a field with the given name. The second boolean
  4739. // return value indicates that this field was not set, or was not defined in the
  4740. // schema.
  4741. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  4742. switch name {
  4743. case label.FieldCreatedAt:
  4744. return m.CreatedAt()
  4745. case label.FieldUpdatedAt:
  4746. return m.UpdatedAt()
  4747. case label.FieldStatus:
  4748. return m.Status()
  4749. case label.FieldType:
  4750. return m.GetType()
  4751. case label.FieldName:
  4752. return m.Name()
  4753. case label.FieldFrom:
  4754. return m.From()
  4755. case label.FieldMode:
  4756. return m.Mode()
  4757. case label.FieldConditions:
  4758. return m.Conditions()
  4759. case label.FieldOrganizationID:
  4760. return m.OrganizationID()
  4761. }
  4762. return nil, false
  4763. }
  4764. // OldField returns the old value of the field from the database. An error is
  4765. // returned if the mutation operation is not UpdateOne, or the query to the
  4766. // database failed.
  4767. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4768. switch name {
  4769. case label.FieldCreatedAt:
  4770. return m.OldCreatedAt(ctx)
  4771. case label.FieldUpdatedAt:
  4772. return m.OldUpdatedAt(ctx)
  4773. case label.FieldStatus:
  4774. return m.OldStatus(ctx)
  4775. case label.FieldType:
  4776. return m.OldType(ctx)
  4777. case label.FieldName:
  4778. return m.OldName(ctx)
  4779. case label.FieldFrom:
  4780. return m.OldFrom(ctx)
  4781. case label.FieldMode:
  4782. return m.OldMode(ctx)
  4783. case label.FieldConditions:
  4784. return m.OldConditions(ctx)
  4785. case label.FieldOrganizationID:
  4786. return m.OldOrganizationID(ctx)
  4787. }
  4788. return nil, fmt.Errorf("unknown Label field %s", name)
  4789. }
  4790. // SetField sets the value of a field with the given name. It returns an error if
  4791. // the field is not defined in the schema, or if the type mismatched the field
  4792. // type.
  4793. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  4794. switch name {
  4795. case label.FieldCreatedAt:
  4796. v, ok := value.(time.Time)
  4797. if !ok {
  4798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4799. }
  4800. m.SetCreatedAt(v)
  4801. return nil
  4802. case label.FieldUpdatedAt:
  4803. v, ok := value.(time.Time)
  4804. if !ok {
  4805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4806. }
  4807. m.SetUpdatedAt(v)
  4808. return nil
  4809. case label.FieldStatus:
  4810. v, ok := value.(uint8)
  4811. if !ok {
  4812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4813. }
  4814. m.SetStatus(v)
  4815. return nil
  4816. case label.FieldType:
  4817. v, ok := value.(int)
  4818. if !ok {
  4819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4820. }
  4821. m.SetType(v)
  4822. return nil
  4823. case label.FieldName:
  4824. v, ok := value.(string)
  4825. if !ok {
  4826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4827. }
  4828. m.SetName(v)
  4829. return nil
  4830. case label.FieldFrom:
  4831. v, ok := value.(int)
  4832. if !ok {
  4833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4834. }
  4835. m.SetFrom(v)
  4836. return nil
  4837. case label.FieldMode:
  4838. v, ok := value.(int)
  4839. if !ok {
  4840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4841. }
  4842. m.SetMode(v)
  4843. return nil
  4844. case label.FieldConditions:
  4845. v, ok := value.(string)
  4846. if !ok {
  4847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4848. }
  4849. m.SetConditions(v)
  4850. return nil
  4851. case label.FieldOrganizationID:
  4852. v, ok := value.(uint64)
  4853. if !ok {
  4854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4855. }
  4856. m.SetOrganizationID(v)
  4857. return nil
  4858. }
  4859. return fmt.Errorf("unknown Label field %s", name)
  4860. }
  4861. // AddedFields returns all numeric fields that were incremented/decremented during
  4862. // this mutation.
  4863. func (m *LabelMutation) AddedFields() []string {
  4864. var fields []string
  4865. if m.addstatus != nil {
  4866. fields = append(fields, label.FieldStatus)
  4867. }
  4868. if m.add_type != nil {
  4869. fields = append(fields, label.FieldType)
  4870. }
  4871. if m.addfrom != nil {
  4872. fields = append(fields, label.FieldFrom)
  4873. }
  4874. if m.addmode != nil {
  4875. fields = append(fields, label.FieldMode)
  4876. }
  4877. if m.addorganization_id != nil {
  4878. fields = append(fields, label.FieldOrganizationID)
  4879. }
  4880. return fields
  4881. }
  4882. // AddedField returns the numeric value that was incremented/decremented on a field
  4883. // with the given name. The second boolean return value indicates that this field
  4884. // was not set, or was not defined in the schema.
  4885. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  4886. switch name {
  4887. case label.FieldStatus:
  4888. return m.AddedStatus()
  4889. case label.FieldType:
  4890. return m.AddedType()
  4891. case label.FieldFrom:
  4892. return m.AddedFrom()
  4893. case label.FieldMode:
  4894. return m.AddedMode()
  4895. case label.FieldOrganizationID:
  4896. return m.AddedOrganizationID()
  4897. }
  4898. return nil, false
  4899. }
  4900. // AddField adds the value to the field with the given name. It returns an error if
  4901. // the field is not defined in the schema, or if the type mismatched the field
  4902. // type.
  4903. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  4904. switch name {
  4905. case label.FieldStatus:
  4906. v, ok := value.(int8)
  4907. if !ok {
  4908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4909. }
  4910. m.AddStatus(v)
  4911. return nil
  4912. case label.FieldType:
  4913. v, ok := value.(int)
  4914. if !ok {
  4915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4916. }
  4917. m.AddType(v)
  4918. return nil
  4919. case label.FieldFrom:
  4920. v, ok := value.(int)
  4921. if !ok {
  4922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4923. }
  4924. m.AddFrom(v)
  4925. return nil
  4926. case label.FieldMode:
  4927. v, ok := value.(int)
  4928. if !ok {
  4929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4930. }
  4931. m.AddMode(v)
  4932. return nil
  4933. case label.FieldOrganizationID:
  4934. v, ok := value.(int64)
  4935. if !ok {
  4936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4937. }
  4938. m.AddOrganizationID(v)
  4939. return nil
  4940. }
  4941. return fmt.Errorf("unknown Label numeric field %s", name)
  4942. }
  4943. // ClearedFields returns all nullable fields that were cleared during this
  4944. // mutation.
  4945. func (m *LabelMutation) ClearedFields() []string {
  4946. var fields []string
  4947. if m.FieldCleared(label.FieldStatus) {
  4948. fields = append(fields, label.FieldStatus)
  4949. }
  4950. if m.FieldCleared(label.FieldConditions) {
  4951. fields = append(fields, label.FieldConditions)
  4952. }
  4953. if m.FieldCleared(label.FieldOrganizationID) {
  4954. fields = append(fields, label.FieldOrganizationID)
  4955. }
  4956. return fields
  4957. }
  4958. // FieldCleared returns a boolean indicating if a field with the given name was
  4959. // cleared in this mutation.
  4960. func (m *LabelMutation) FieldCleared(name string) bool {
  4961. _, ok := m.clearedFields[name]
  4962. return ok
  4963. }
  4964. // ClearField clears the value of the field with the given name. It returns an
  4965. // error if the field is not defined in the schema.
  4966. func (m *LabelMutation) ClearField(name string) error {
  4967. switch name {
  4968. case label.FieldStatus:
  4969. m.ClearStatus()
  4970. return nil
  4971. case label.FieldConditions:
  4972. m.ClearConditions()
  4973. return nil
  4974. case label.FieldOrganizationID:
  4975. m.ClearOrganizationID()
  4976. return nil
  4977. }
  4978. return fmt.Errorf("unknown Label nullable field %s", name)
  4979. }
  4980. // ResetField resets all changes in the mutation for the field with the given name.
  4981. // It returns an error if the field is not defined in the schema.
  4982. func (m *LabelMutation) ResetField(name string) error {
  4983. switch name {
  4984. case label.FieldCreatedAt:
  4985. m.ResetCreatedAt()
  4986. return nil
  4987. case label.FieldUpdatedAt:
  4988. m.ResetUpdatedAt()
  4989. return nil
  4990. case label.FieldStatus:
  4991. m.ResetStatus()
  4992. return nil
  4993. case label.FieldType:
  4994. m.ResetType()
  4995. return nil
  4996. case label.FieldName:
  4997. m.ResetName()
  4998. return nil
  4999. case label.FieldFrom:
  5000. m.ResetFrom()
  5001. return nil
  5002. case label.FieldMode:
  5003. m.ResetMode()
  5004. return nil
  5005. case label.FieldConditions:
  5006. m.ResetConditions()
  5007. return nil
  5008. case label.FieldOrganizationID:
  5009. m.ResetOrganizationID()
  5010. return nil
  5011. }
  5012. return fmt.Errorf("unknown Label field %s", name)
  5013. }
  5014. // AddedEdges returns all edge names that were set/added in this mutation.
  5015. func (m *LabelMutation) AddedEdges() []string {
  5016. edges := make([]string, 0, 1)
  5017. if m.label_relationships != nil {
  5018. edges = append(edges, label.EdgeLabelRelationships)
  5019. }
  5020. return edges
  5021. }
  5022. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5023. // name in this mutation.
  5024. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  5025. switch name {
  5026. case label.EdgeLabelRelationships:
  5027. ids := make([]ent.Value, 0, len(m.label_relationships))
  5028. for id := range m.label_relationships {
  5029. ids = append(ids, id)
  5030. }
  5031. return ids
  5032. }
  5033. return nil
  5034. }
  5035. // RemovedEdges returns all edge names that were removed in this mutation.
  5036. func (m *LabelMutation) RemovedEdges() []string {
  5037. edges := make([]string, 0, 1)
  5038. if m.removedlabel_relationships != nil {
  5039. edges = append(edges, label.EdgeLabelRelationships)
  5040. }
  5041. return edges
  5042. }
  5043. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5044. // the given name in this mutation.
  5045. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  5046. switch name {
  5047. case label.EdgeLabelRelationships:
  5048. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  5049. for id := range m.removedlabel_relationships {
  5050. ids = append(ids, id)
  5051. }
  5052. return ids
  5053. }
  5054. return nil
  5055. }
  5056. // ClearedEdges returns all edge names that were cleared in this mutation.
  5057. func (m *LabelMutation) ClearedEdges() []string {
  5058. edges := make([]string, 0, 1)
  5059. if m.clearedlabel_relationships {
  5060. edges = append(edges, label.EdgeLabelRelationships)
  5061. }
  5062. return edges
  5063. }
  5064. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5065. // was cleared in this mutation.
  5066. func (m *LabelMutation) EdgeCleared(name string) bool {
  5067. switch name {
  5068. case label.EdgeLabelRelationships:
  5069. return m.clearedlabel_relationships
  5070. }
  5071. return false
  5072. }
  5073. // ClearEdge clears the value of the edge with the given name. It returns an error
  5074. // if that edge is not defined in the schema.
  5075. func (m *LabelMutation) ClearEdge(name string) error {
  5076. switch name {
  5077. }
  5078. return fmt.Errorf("unknown Label unique edge %s", name)
  5079. }
  5080. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5081. // It returns an error if the edge is not defined in the schema.
  5082. func (m *LabelMutation) ResetEdge(name string) error {
  5083. switch name {
  5084. case label.EdgeLabelRelationships:
  5085. m.ResetLabelRelationships()
  5086. return nil
  5087. }
  5088. return fmt.Errorf("unknown Label edge %s", name)
  5089. }
  5090. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  5091. type LabelRelationshipMutation struct {
  5092. config
  5093. op Op
  5094. typ string
  5095. id *uint64
  5096. created_at *time.Time
  5097. updated_at *time.Time
  5098. status *uint8
  5099. addstatus *int8
  5100. deleted_at *time.Time
  5101. organization_id *uint64
  5102. addorganization_id *int64
  5103. clearedFields map[string]struct{}
  5104. contacts *uint64
  5105. clearedcontacts bool
  5106. labels *uint64
  5107. clearedlabels bool
  5108. done bool
  5109. oldValue func(context.Context) (*LabelRelationship, error)
  5110. predicates []predicate.LabelRelationship
  5111. }
  5112. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  5113. // labelrelationshipOption allows management of the mutation configuration using functional options.
  5114. type labelrelationshipOption func(*LabelRelationshipMutation)
  5115. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  5116. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  5117. m := &LabelRelationshipMutation{
  5118. config: c,
  5119. op: op,
  5120. typ: TypeLabelRelationship,
  5121. clearedFields: make(map[string]struct{}),
  5122. }
  5123. for _, opt := range opts {
  5124. opt(m)
  5125. }
  5126. return m
  5127. }
  5128. // withLabelRelationshipID sets the ID field of the mutation.
  5129. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  5130. return func(m *LabelRelationshipMutation) {
  5131. var (
  5132. err error
  5133. once sync.Once
  5134. value *LabelRelationship
  5135. )
  5136. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  5137. once.Do(func() {
  5138. if m.done {
  5139. err = errors.New("querying old values post mutation is not allowed")
  5140. } else {
  5141. value, err = m.Client().LabelRelationship.Get(ctx, id)
  5142. }
  5143. })
  5144. return value, err
  5145. }
  5146. m.id = &id
  5147. }
  5148. }
  5149. // withLabelRelationship sets the old LabelRelationship of the mutation.
  5150. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  5151. return func(m *LabelRelationshipMutation) {
  5152. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  5153. return node, nil
  5154. }
  5155. m.id = &node.ID
  5156. }
  5157. }
  5158. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5159. // executed in a transaction (ent.Tx), a transactional client is returned.
  5160. func (m LabelRelationshipMutation) Client() *Client {
  5161. client := &Client{config: m.config}
  5162. client.init()
  5163. return client
  5164. }
  5165. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5166. // it returns an error otherwise.
  5167. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  5168. if _, ok := m.driver.(*txDriver); !ok {
  5169. return nil, errors.New("ent: mutation is not running in a transaction")
  5170. }
  5171. tx := &Tx{config: m.config}
  5172. tx.init()
  5173. return tx, nil
  5174. }
  5175. // SetID sets the value of the id field. Note that this
  5176. // operation is only accepted on creation of LabelRelationship entities.
  5177. func (m *LabelRelationshipMutation) SetID(id uint64) {
  5178. m.id = &id
  5179. }
  5180. // ID returns the ID value in the mutation. Note that the ID is only available
  5181. // if it was provided to the builder or after it was returned from the database.
  5182. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  5183. if m.id == nil {
  5184. return
  5185. }
  5186. return *m.id, true
  5187. }
  5188. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5189. // That means, if the mutation is applied within a transaction with an isolation level such
  5190. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5191. // or updated by the mutation.
  5192. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  5193. switch {
  5194. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5195. id, exists := m.ID()
  5196. if exists {
  5197. return []uint64{id}, nil
  5198. }
  5199. fallthrough
  5200. case m.op.Is(OpUpdate | OpDelete):
  5201. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  5202. default:
  5203. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5204. }
  5205. }
  5206. // SetCreatedAt sets the "created_at" field.
  5207. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  5208. m.created_at = &t
  5209. }
  5210. // CreatedAt returns the value of the "created_at" field in the mutation.
  5211. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  5212. v := m.created_at
  5213. if v == nil {
  5214. return
  5215. }
  5216. return *v, true
  5217. }
  5218. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  5219. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5221. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5222. if !m.op.Is(OpUpdateOne) {
  5223. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5224. }
  5225. if m.id == nil || m.oldValue == nil {
  5226. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5227. }
  5228. oldValue, err := m.oldValue(ctx)
  5229. if err != nil {
  5230. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5231. }
  5232. return oldValue.CreatedAt, nil
  5233. }
  5234. // ResetCreatedAt resets all changes to the "created_at" field.
  5235. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  5236. m.created_at = nil
  5237. }
  5238. // SetUpdatedAt sets the "updated_at" field.
  5239. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  5240. m.updated_at = &t
  5241. }
  5242. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5243. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  5244. v := m.updated_at
  5245. if v == nil {
  5246. return
  5247. }
  5248. return *v, true
  5249. }
  5250. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  5251. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5253. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5254. if !m.op.Is(OpUpdateOne) {
  5255. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5256. }
  5257. if m.id == nil || m.oldValue == nil {
  5258. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5259. }
  5260. oldValue, err := m.oldValue(ctx)
  5261. if err != nil {
  5262. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5263. }
  5264. return oldValue.UpdatedAt, nil
  5265. }
  5266. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5267. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  5268. m.updated_at = nil
  5269. }
  5270. // SetStatus sets the "status" field.
  5271. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  5272. m.status = &u
  5273. m.addstatus = nil
  5274. }
  5275. // Status returns the value of the "status" field in the mutation.
  5276. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  5277. v := m.status
  5278. if v == nil {
  5279. return
  5280. }
  5281. return *v, true
  5282. }
  5283. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  5284. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5286. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5287. if !m.op.Is(OpUpdateOne) {
  5288. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5289. }
  5290. if m.id == nil || m.oldValue == nil {
  5291. return v, errors.New("OldStatus requires an ID field in the mutation")
  5292. }
  5293. oldValue, err := m.oldValue(ctx)
  5294. if err != nil {
  5295. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5296. }
  5297. return oldValue.Status, nil
  5298. }
  5299. // AddStatus adds u to the "status" field.
  5300. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  5301. if m.addstatus != nil {
  5302. *m.addstatus += u
  5303. } else {
  5304. m.addstatus = &u
  5305. }
  5306. }
  5307. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5308. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  5309. v := m.addstatus
  5310. if v == nil {
  5311. return
  5312. }
  5313. return *v, true
  5314. }
  5315. // ClearStatus clears the value of the "status" field.
  5316. func (m *LabelRelationshipMutation) ClearStatus() {
  5317. m.status = nil
  5318. m.addstatus = nil
  5319. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  5320. }
  5321. // StatusCleared returns if the "status" field was cleared in this mutation.
  5322. func (m *LabelRelationshipMutation) StatusCleared() bool {
  5323. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  5324. return ok
  5325. }
  5326. // ResetStatus resets all changes to the "status" field.
  5327. func (m *LabelRelationshipMutation) ResetStatus() {
  5328. m.status = nil
  5329. m.addstatus = nil
  5330. delete(m.clearedFields, labelrelationship.FieldStatus)
  5331. }
  5332. // SetDeletedAt sets the "deleted_at" field.
  5333. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  5334. m.deleted_at = &t
  5335. }
  5336. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5337. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  5338. v := m.deleted_at
  5339. if v == nil {
  5340. return
  5341. }
  5342. return *v, true
  5343. }
  5344. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  5345. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5346. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5347. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5348. if !m.op.Is(OpUpdateOne) {
  5349. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5350. }
  5351. if m.id == nil || m.oldValue == nil {
  5352. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5353. }
  5354. oldValue, err := m.oldValue(ctx)
  5355. if err != nil {
  5356. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5357. }
  5358. return oldValue.DeletedAt, nil
  5359. }
  5360. // ClearDeletedAt clears the value of the "deleted_at" field.
  5361. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  5362. m.deleted_at = nil
  5363. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  5364. }
  5365. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5366. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  5367. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  5368. return ok
  5369. }
  5370. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5371. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  5372. m.deleted_at = nil
  5373. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  5374. }
  5375. // SetLabelID sets the "label_id" field.
  5376. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  5377. m.labels = &u
  5378. }
  5379. // LabelID returns the value of the "label_id" field in the mutation.
  5380. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  5381. v := m.labels
  5382. if v == nil {
  5383. return
  5384. }
  5385. return *v, true
  5386. }
  5387. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  5388. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5390. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  5391. if !m.op.Is(OpUpdateOne) {
  5392. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  5393. }
  5394. if m.id == nil || m.oldValue == nil {
  5395. return v, errors.New("OldLabelID requires an ID field in the mutation")
  5396. }
  5397. oldValue, err := m.oldValue(ctx)
  5398. if err != nil {
  5399. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  5400. }
  5401. return oldValue.LabelID, nil
  5402. }
  5403. // ResetLabelID resets all changes to the "label_id" field.
  5404. func (m *LabelRelationshipMutation) ResetLabelID() {
  5405. m.labels = nil
  5406. }
  5407. // SetContactID sets the "contact_id" field.
  5408. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  5409. m.contacts = &u
  5410. }
  5411. // ContactID returns the value of the "contact_id" field in the mutation.
  5412. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  5413. v := m.contacts
  5414. if v == nil {
  5415. return
  5416. }
  5417. return *v, true
  5418. }
  5419. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  5420. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5422. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  5423. if !m.op.Is(OpUpdateOne) {
  5424. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  5425. }
  5426. if m.id == nil || m.oldValue == nil {
  5427. return v, errors.New("OldContactID requires an ID field in the mutation")
  5428. }
  5429. oldValue, err := m.oldValue(ctx)
  5430. if err != nil {
  5431. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  5432. }
  5433. return oldValue.ContactID, nil
  5434. }
  5435. // ResetContactID resets all changes to the "contact_id" field.
  5436. func (m *LabelRelationshipMutation) ResetContactID() {
  5437. m.contacts = nil
  5438. }
  5439. // SetOrganizationID sets the "organization_id" field.
  5440. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  5441. m.organization_id = &u
  5442. m.addorganization_id = nil
  5443. }
  5444. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5445. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  5446. v := m.organization_id
  5447. if v == nil {
  5448. return
  5449. }
  5450. return *v, true
  5451. }
  5452. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  5453. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5455. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5456. if !m.op.Is(OpUpdateOne) {
  5457. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5458. }
  5459. if m.id == nil || m.oldValue == nil {
  5460. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5461. }
  5462. oldValue, err := m.oldValue(ctx)
  5463. if err != nil {
  5464. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5465. }
  5466. return oldValue.OrganizationID, nil
  5467. }
  5468. // AddOrganizationID adds u to the "organization_id" field.
  5469. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  5470. if m.addorganization_id != nil {
  5471. *m.addorganization_id += u
  5472. } else {
  5473. m.addorganization_id = &u
  5474. }
  5475. }
  5476. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5477. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  5478. v := m.addorganization_id
  5479. if v == nil {
  5480. return
  5481. }
  5482. return *v, true
  5483. }
  5484. // ClearOrganizationID clears the value of the "organization_id" field.
  5485. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  5486. m.organization_id = nil
  5487. m.addorganization_id = nil
  5488. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  5489. }
  5490. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  5491. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  5492. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  5493. return ok
  5494. }
  5495. // ResetOrganizationID resets all changes to the "organization_id" field.
  5496. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  5497. m.organization_id = nil
  5498. m.addorganization_id = nil
  5499. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  5500. }
  5501. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  5502. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  5503. m.contacts = &id
  5504. }
  5505. // ClearContacts clears the "contacts" edge to the Contact entity.
  5506. func (m *LabelRelationshipMutation) ClearContacts() {
  5507. m.clearedcontacts = true
  5508. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  5509. }
  5510. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  5511. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  5512. return m.clearedcontacts
  5513. }
  5514. // ContactsID returns the "contacts" edge ID in the mutation.
  5515. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  5516. if m.contacts != nil {
  5517. return *m.contacts, true
  5518. }
  5519. return
  5520. }
  5521. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  5522. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  5523. // ContactsID instead. It exists only for internal usage by the builders.
  5524. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  5525. if id := m.contacts; id != nil {
  5526. ids = append(ids, *id)
  5527. }
  5528. return
  5529. }
  5530. // ResetContacts resets all changes to the "contacts" edge.
  5531. func (m *LabelRelationshipMutation) ResetContacts() {
  5532. m.contacts = nil
  5533. m.clearedcontacts = false
  5534. }
  5535. // SetLabelsID sets the "labels" edge to the Label entity by id.
  5536. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  5537. m.labels = &id
  5538. }
  5539. // ClearLabels clears the "labels" edge to the Label entity.
  5540. func (m *LabelRelationshipMutation) ClearLabels() {
  5541. m.clearedlabels = true
  5542. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  5543. }
  5544. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  5545. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  5546. return m.clearedlabels
  5547. }
  5548. // LabelsID returns the "labels" edge ID in the mutation.
  5549. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  5550. if m.labels != nil {
  5551. return *m.labels, true
  5552. }
  5553. return
  5554. }
  5555. // LabelsIDs returns the "labels" edge IDs in the mutation.
  5556. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  5557. // LabelsID instead. It exists only for internal usage by the builders.
  5558. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  5559. if id := m.labels; id != nil {
  5560. ids = append(ids, *id)
  5561. }
  5562. return
  5563. }
  5564. // ResetLabels resets all changes to the "labels" edge.
  5565. func (m *LabelRelationshipMutation) ResetLabels() {
  5566. m.labels = nil
  5567. m.clearedlabels = false
  5568. }
  5569. // Where appends a list predicates to the LabelRelationshipMutation builder.
  5570. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  5571. m.predicates = append(m.predicates, ps...)
  5572. }
  5573. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  5574. // users can use type-assertion to append predicates that do not depend on any generated package.
  5575. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  5576. p := make([]predicate.LabelRelationship, len(ps))
  5577. for i := range ps {
  5578. p[i] = ps[i]
  5579. }
  5580. m.Where(p...)
  5581. }
  5582. // Op returns the operation name.
  5583. func (m *LabelRelationshipMutation) Op() Op {
  5584. return m.op
  5585. }
  5586. // SetOp allows setting the mutation operation.
  5587. func (m *LabelRelationshipMutation) SetOp(op Op) {
  5588. m.op = op
  5589. }
  5590. // Type returns the node type of this mutation (LabelRelationship).
  5591. func (m *LabelRelationshipMutation) Type() string {
  5592. return m.typ
  5593. }
  5594. // Fields returns all fields that were changed during this mutation. Note that in
  5595. // order to get all numeric fields that were incremented/decremented, call
  5596. // AddedFields().
  5597. func (m *LabelRelationshipMutation) Fields() []string {
  5598. fields := make([]string, 0, 7)
  5599. if m.created_at != nil {
  5600. fields = append(fields, labelrelationship.FieldCreatedAt)
  5601. }
  5602. if m.updated_at != nil {
  5603. fields = append(fields, labelrelationship.FieldUpdatedAt)
  5604. }
  5605. if m.status != nil {
  5606. fields = append(fields, labelrelationship.FieldStatus)
  5607. }
  5608. if m.deleted_at != nil {
  5609. fields = append(fields, labelrelationship.FieldDeletedAt)
  5610. }
  5611. if m.labels != nil {
  5612. fields = append(fields, labelrelationship.FieldLabelID)
  5613. }
  5614. if m.contacts != nil {
  5615. fields = append(fields, labelrelationship.FieldContactID)
  5616. }
  5617. if m.organization_id != nil {
  5618. fields = append(fields, labelrelationship.FieldOrganizationID)
  5619. }
  5620. return fields
  5621. }
  5622. // Field returns the value of a field with the given name. The second boolean
  5623. // return value indicates that this field was not set, or was not defined in the
  5624. // schema.
  5625. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  5626. switch name {
  5627. case labelrelationship.FieldCreatedAt:
  5628. return m.CreatedAt()
  5629. case labelrelationship.FieldUpdatedAt:
  5630. return m.UpdatedAt()
  5631. case labelrelationship.FieldStatus:
  5632. return m.Status()
  5633. case labelrelationship.FieldDeletedAt:
  5634. return m.DeletedAt()
  5635. case labelrelationship.FieldLabelID:
  5636. return m.LabelID()
  5637. case labelrelationship.FieldContactID:
  5638. return m.ContactID()
  5639. case labelrelationship.FieldOrganizationID:
  5640. return m.OrganizationID()
  5641. }
  5642. return nil, false
  5643. }
  5644. // OldField returns the old value of the field from the database. An error is
  5645. // returned if the mutation operation is not UpdateOne, or the query to the
  5646. // database failed.
  5647. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5648. switch name {
  5649. case labelrelationship.FieldCreatedAt:
  5650. return m.OldCreatedAt(ctx)
  5651. case labelrelationship.FieldUpdatedAt:
  5652. return m.OldUpdatedAt(ctx)
  5653. case labelrelationship.FieldStatus:
  5654. return m.OldStatus(ctx)
  5655. case labelrelationship.FieldDeletedAt:
  5656. return m.OldDeletedAt(ctx)
  5657. case labelrelationship.FieldLabelID:
  5658. return m.OldLabelID(ctx)
  5659. case labelrelationship.FieldContactID:
  5660. return m.OldContactID(ctx)
  5661. case labelrelationship.FieldOrganizationID:
  5662. return m.OldOrganizationID(ctx)
  5663. }
  5664. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  5665. }
  5666. // SetField sets the value of a field with the given name. It returns an error if
  5667. // the field is not defined in the schema, or if the type mismatched the field
  5668. // type.
  5669. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  5670. switch name {
  5671. case labelrelationship.FieldCreatedAt:
  5672. v, ok := value.(time.Time)
  5673. if !ok {
  5674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5675. }
  5676. m.SetCreatedAt(v)
  5677. return nil
  5678. case labelrelationship.FieldUpdatedAt:
  5679. v, ok := value.(time.Time)
  5680. if !ok {
  5681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5682. }
  5683. m.SetUpdatedAt(v)
  5684. return nil
  5685. case labelrelationship.FieldStatus:
  5686. v, ok := value.(uint8)
  5687. if !ok {
  5688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5689. }
  5690. m.SetStatus(v)
  5691. return nil
  5692. case labelrelationship.FieldDeletedAt:
  5693. v, ok := value.(time.Time)
  5694. if !ok {
  5695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5696. }
  5697. m.SetDeletedAt(v)
  5698. return nil
  5699. case labelrelationship.FieldLabelID:
  5700. v, ok := value.(uint64)
  5701. if !ok {
  5702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5703. }
  5704. m.SetLabelID(v)
  5705. return nil
  5706. case labelrelationship.FieldContactID:
  5707. v, ok := value.(uint64)
  5708. if !ok {
  5709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5710. }
  5711. m.SetContactID(v)
  5712. return nil
  5713. case labelrelationship.FieldOrganizationID:
  5714. v, ok := value.(uint64)
  5715. if !ok {
  5716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5717. }
  5718. m.SetOrganizationID(v)
  5719. return nil
  5720. }
  5721. return fmt.Errorf("unknown LabelRelationship field %s", name)
  5722. }
  5723. // AddedFields returns all numeric fields that were incremented/decremented during
  5724. // this mutation.
  5725. func (m *LabelRelationshipMutation) AddedFields() []string {
  5726. var fields []string
  5727. if m.addstatus != nil {
  5728. fields = append(fields, labelrelationship.FieldStatus)
  5729. }
  5730. if m.addorganization_id != nil {
  5731. fields = append(fields, labelrelationship.FieldOrganizationID)
  5732. }
  5733. return fields
  5734. }
  5735. // AddedField returns the numeric value that was incremented/decremented on a field
  5736. // with the given name. The second boolean return value indicates that this field
  5737. // was not set, or was not defined in the schema.
  5738. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  5739. switch name {
  5740. case labelrelationship.FieldStatus:
  5741. return m.AddedStatus()
  5742. case labelrelationship.FieldOrganizationID:
  5743. return m.AddedOrganizationID()
  5744. }
  5745. return nil, false
  5746. }
  5747. // AddField adds the value to the field with the given name. It returns an error if
  5748. // the field is not defined in the schema, or if the type mismatched the field
  5749. // type.
  5750. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  5751. switch name {
  5752. case labelrelationship.FieldStatus:
  5753. v, ok := value.(int8)
  5754. if !ok {
  5755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5756. }
  5757. m.AddStatus(v)
  5758. return nil
  5759. case labelrelationship.FieldOrganizationID:
  5760. v, ok := value.(int64)
  5761. if !ok {
  5762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5763. }
  5764. m.AddOrganizationID(v)
  5765. return nil
  5766. }
  5767. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  5768. }
  5769. // ClearedFields returns all nullable fields that were cleared during this
  5770. // mutation.
  5771. func (m *LabelRelationshipMutation) ClearedFields() []string {
  5772. var fields []string
  5773. if m.FieldCleared(labelrelationship.FieldStatus) {
  5774. fields = append(fields, labelrelationship.FieldStatus)
  5775. }
  5776. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  5777. fields = append(fields, labelrelationship.FieldDeletedAt)
  5778. }
  5779. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  5780. fields = append(fields, labelrelationship.FieldOrganizationID)
  5781. }
  5782. return fields
  5783. }
  5784. // FieldCleared returns a boolean indicating if a field with the given name was
  5785. // cleared in this mutation.
  5786. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  5787. _, ok := m.clearedFields[name]
  5788. return ok
  5789. }
  5790. // ClearField clears the value of the field with the given name. It returns an
  5791. // error if the field is not defined in the schema.
  5792. func (m *LabelRelationshipMutation) ClearField(name string) error {
  5793. switch name {
  5794. case labelrelationship.FieldStatus:
  5795. m.ClearStatus()
  5796. return nil
  5797. case labelrelationship.FieldDeletedAt:
  5798. m.ClearDeletedAt()
  5799. return nil
  5800. case labelrelationship.FieldOrganizationID:
  5801. m.ClearOrganizationID()
  5802. return nil
  5803. }
  5804. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  5805. }
  5806. // ResetField resets all changes in the mutation for the field with the given name.
  5807. // It returns an error if the field is not defined in the schema.
  5808. func (m *LabelRelationshipMutation) ResetField(name string) error {
  5809. switch name {
  5810. case labelrelationship.FieldCreatedAt:
  5811. m.ResetCreatedAt()
  5812. return nil
  5813. case labelrelationship.FieldUpdatedAt:
  5814. m.ResetUpdatedAt()
  5815. return nil
  5816. case labelrelationship.FieldStatus:
  5817. m.ResetStatus()
  5818. return nil
  5819. case labelrelationship.FieldDeletedAt:
  5820. m.ResetDeletedAt()
  5821. return nil
  5822. case labelrelationship.FieldLabelID:
  5823. m.ResetLabelID()
  5824. return nil
  5825. case labelrelationship.FieldContactID:
  5826. m.ResetContactID()
  5827. return nil
  5828. case labelrelationship.FieldOrganizationID:
  5829. m.ResetOrganizationID()
  5830. return nil
  5831. }
  5832. return fmt.Errorf("unknown LabelRelationship field %s", name)
  5833. }
  5834. // AddedEdges returns all edge names that were set/added in this mutation.
  5835. func (m *LabelRelationshipMutation) AddedEdges() []string {
  5836. edges := make([]string, 0, 2)
  5837. if m.contacts != nil {
  5838. edges = append(edges, labelrelationship.EdgeContacts)
  5839. }
  5840. if m.labels != nil {
  5841. edges = append(edges, labelrelationship.EdgeLabels)
  5842. }
  5843. return edges
  5844. }
  5845. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5846. // name in this mutation.
  5847. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  5848. switch name {
  5849. case labelrelationship.EdgeContacts:
  5850. if id := m.contacts; id != nil {
  5851. return []ent.Value{*id}
  5852. }
  5853. case labelrelationship.EdgeLabels:
  5854. if id := m.labels; id != nil {
  5855. return []ent.Value{*id}
  5856. }
  5857. }
  5858. return nil
  5859. }
  5860. // RemovedEdges returns all edge names that were removed in this mutation.
  5861. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  5862. edges := make([]string, 0, 2)
  5863. return edges
  5864. }
  5865. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5866. // the given name in this mutation.
  5867. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  5868. return nil
  5869. }
  5870. // ClearedEdges returns all edge names that were cleared in this mutation.
  5871. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  5872. edges := make([]string, 0, 2)
  5873. if m.clearedcontacts {
  5874. edges = append(edges, labelrelationship.EdgeContacts)
  5875. }
  5876. if m.clearedlabels {
  5877. edges = append(edges, labelrelationship.EdgeLabels)
  5878. }
  5879. return edges
  5880. }
  5881. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5882. // was cleared in this mutation.
  5883. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  5884. switch name {
  5885. case labelrelationship.EdgeContacts:
  5886. return m.clearedcontacts
  5887. case labelrelationship.EdgeLabels:
  5888. return m.clearedlabels
  5889. }
  5890. return false
  5891. }
  5892. // ClearEdge clears the value of the edge with the given name. It returns an error
  5893. // if that edge is not defined in the schema.
  5894. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  5895. switch name {
  5896. case labelrelationship.EdgeContacts:
  5897. m.ClearContacts()
  5898. return nil
  5899. case labelrelationship.EdgeLabels:
  5900. m.ClearLabels()
  5901. return nil
  5902. }
  5903. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  5904. }
  5905. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5906. // It returns an error if the edge is not defined in the schema.
  5907. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  5908. switch name {
  5909. case labelrelationship.EdgeContacts:
  5910. m.ResetContacts()
  5911. return nil
  5912. case labelrelationship.EdgeLabels:
  5913. m.ResetLabels()
  5914. return nil
  5915. }
  5916. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  5917. }
  5918. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  5919. type MessageMutation struct {
  5920. config
  5921. op Op
  5922. typ string
  5923. id *int
  5924. wx_wxid *string
  5925. wxid *string
  5926. content *string
  5927. clearedFields map[string]struct{}
  5928. done bool
  5929. oldValue func(context.Context) (*Message, error)
  5930. predicates []predicate.Message
  5931. }
  5932. var _ ent.Mutation = (*MessageMutation)(nil)
  5933. // messageOption allows management of the mutation configuration using functional options.
  5934. type messageOption func(*MessageMutation)
  5935. // newMessageMutation creates new mutation for the Message entity.
  5936. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  5937. m := &MessageMutation{
  5938. config: c,
  5939. op: op,
  5940. typ: TypeMessage,
  5941. clearedFields: make(map[string]struct{}),
  5942. }
  5943. for _, opt := range opts {
  5944. opt(m)
  5945. }
  5946. return m
  5947. }
  5948. // withMessageID sets the ID field of the mutation.
  5949. func withMessageID(id int) messageOption {
  5950. return func(m *MessageMutation) {
  5951. var (
  5952. err error
  5953. once sync.Once
  5954. value *Message
  5955. )
  5956. m.oldValue = func(ctx context.Context) (*Message, error) {
  5957. once.Do(func() {
  5958. if m.done {
  5959. err = errors.New("querying old values post mutation is not allowed")
  5960. } else {
  5961. value, err = m.Client().Message.Get(ctx, id)
  5962. }
  5963. })
  5964. return value, err
  5965. }
  5966. m.id = &id
  5967. }
  5968. }
  5969. // withMessage sets the old Message of the mutation.
  5970. func withMessage(node *Message) messageOption {
  5971. return func(m *MessageMutation) {
  5972. m.oldValue = func(context.Context) (*Message, error) {
  5973. return node, nil
  5974. }
  5975. m.id = &node.ID
  5976. }
  5977. }
  5978. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5979. // executed in a transaction (ent.Tx), a transactional client is returned.
  5980. func (m MessageMutation) Client() *Client {
  5981. client := &Client{config: m.config}
  5982. client.init()
  5983. return client
  5984. }
  5985. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5986. // it returns an error otherwise.
  5987. func (m MessageMutation) Tx() (*Tx, error) {
  5988. if _, ok := m.driver.(*txDriver); !ok {
  5989. return nil, errors.New("ent: mutation is not running in a transaction")
  5990. }
  5991. tx := &Tx{config: m.config}
  5992. tx.init()
  5993. return tx, nil
  5994. }
  5995. // ID returns the ID value in the mutation. Note that the ID is only available
  5996. // if it was provided to the builder or after it was returned from the database.
  5997. func (m *MessageMutation) ID() (id int, exists bool) {
  5998. if m.id == nil {
  5999. return
  6000. }
  6001. return *m.id, true
  6002. }
  6003. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6004. // That means, if the mutation is applied within a transaction with an isolation level such
  6005. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6006. // or updated by the mutation.
  6007. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  6008. switch {
  6009. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6010. id, exists := m.ID()
  6011. if exists {
  6012. return []int{id}, nil
  6013. }
  6014. fallthrough
  6015. case m.op.Is(OpUpdate | OpDelete):
  6016. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  6017. default:
  6018. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6019. }
  6020. }
  6021. // SetWxWxid sets the "wx_wxid" field.
  6022. func (m *MessageMutation) SetWxWxid(s string) {
  6023. m.wx_wxid = &s
  6024. }
  6025. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  6026. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  6027. v := m.wx_wxid
  6028. if v == nil {
  6029. return
  6030. }
  6031. return *v, true
  6032. }
  6033. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  6034. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  6035. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6036. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  6037. if !m.op.Is(OpUpdateOne) {
  6038. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  6039. }
  6040. if m.id == nil || m.oldValue == nil {
  6041. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  6042. }
  6043. oldValue, err := m.oldValue(ctx)
  6044. if err != nil {
  6045. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  6046. }
  6047. return oldValue.WxWxid, nil
  6048. }
  6049. // ClearWxWxid clears the value of the "wx_wxid" field.
  6050. func (m *MessageMutation) ClearWxWxid() {
  6051. m.wx_wxid = nil
  6052. m.clearedFields[message.FieldWxWxid] = struct{}{}
  6053. }
  6054. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  6055. func (m *MessageMutation) WxWxidCleared() bool {
  6056. _, ok := m.clearedFields[message.FieldWxWxid]
  6057. return ok
  6058. }
  6059. // ResetWxWxid resets all changes to the "wx_wxid" field.
  6060. func (m *MessageMutation) ResetWxWxid() {
  6061. m.wx_wxid = nil
  6062. delete(m.clearedFields, message.FieldWxWxid)
  6063. }
  6064. // SetWxid sets the "wxid" field.
  6065. func (m *MessageMutation) SetWxid(s string) {
  6066. m.wxid = &s
  6067. }
  6068. // Wxid returns the value of the "wxid" field in the mutation.
  6069. func (m *MessageMutation) Wxid() (r string, exists bool) {
  6070. v := m.wxid
  6071. if v == nil {
  6072. return
  6073. }
  6074. return *v, true
  6075. }
  6076. // OldWxid returns the old "wxid" field's value of the Message entity.
  6077. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  6078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6079. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  6080. if !m.op.Is(OpUpdateOne) {
  6081. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  6082. }
  6083. if m.id == nil || m.oldValue == nil {
  6084. return v, errors.New("OldWxid requires an ID field in the mutation")
  6085. }
  6086. oldValue, err := m.oldValue(ctx)
  6087. if err != nil {
  6088. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  6089. }
  6090. return oldValue.Wxid, nil
  6091. }
  6092. // ResetWxid resets all changes to the "wxid" field.
  6093. func (m *MessageMutation) ResetWxid() {
  6094. m.wxid = nil
  6095. }
  6096. // SetContent sets the "content" field.
  6097. func (m *MessageMutation) SetContent(s string) {
  6098. m.content = &s
  6099. }
  6100. // Content returns the value of the "content" field in the mutation.
  6101. func (m *MessageMutation) Content() (r string, exists bool) {
  6102. v := m.content
  6103. if v == nil {
  6104. return
  6105. }
  6106. return *v, true
  6107. }
  6108. // OldContent returns the old "content" field's value of the Message entity.
  6109. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  6110. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6111. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  6112. if !m.op.Is(OpUpdateOne) {
  6113. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6114. }
  6115. if m.id == nil || m.oldValue == nil {
  6116. return v, errors.New("OldContent requires an ID field in the mutation")
  6117. }
  6118. oldValue, err := m.oldValue(ctx)
  6119. if err != nil {
  6120. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  6121. }
  6122. return oldValue.Content, nil
  6123. }
  6124. // ResetContent resets all changes to the "content" field.
  6125. func (m *MessageMutation) ResetContent() {
  6126. m.content = nil
  6127. }
  6128. // Where appends a list predicates to the MessageMutation builder.
  6129. func (m *MessageMutation) Where(ps ...predicate.Message) {
  6130. m.predicates = append(m.predicates, ps...)
  6131. }
  6132. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  6133. // users can use type-assertion to append predicates that do not depend on any generated package.
  6134. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  6135. p := make([]predicate.Message, len(ps))
  6136. for i := range ps {
  6137. p[i] = ps[i]
  6138. }
  6139. m.Where(p...)
  6140. }
  6141. // Op returns the operation name.
  6142. func (m *MessageMutation) Op() Op {
  6143. return m.op
  6144. }
  6145. // SetOp allows setting the mutation operation.
  6146. func (m *MessageMutation) SetOp(op Op) {
  6147. m.op = op
  6148. }
  6149. // Type returns the node type of this mutation (Message).
  6150. func (m *MessageMutation) Type() string {
  6151. return m.typ
  6152. }
  6153. // Fields returns all fields that were changed during this mutation. Note that in
  6154. // order to get all numeric fields that were incremented/decremented, call
  6155. // AddedFields().
  6156. func (m *MessageMutation) Fields() []string {
  6157. fields := make([]string, 0, 3)
  6158. if m.wx_wxid != nil {
  6159. fields = append(fields, message.FieldWxWxid)
  6160. }
  6161. if m.wxid != nil {
  6162. fields = append(fields, message.FieldWxid)
  6163. }
  6164. if m.content != nil {
  6165. fields = append(fields, message.FieldContent)
  6166. }
  6167. return fields
  6168. }
  6169. // Field returns the value of a field with the given name. The second boolean
  6170. // return value indicates that this field was not set, or was not defined in the
  6171. // schema.
  6172. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  6173. switch name {
  6174. case message.FieldWxWxid:
  6175. return m.WxWxid()
  6176. case message.FieldWxid:
  6177. return m.Wxid()
  6178. case message.FieldContent:
  6179. return m.Content()
  6180. }
  6181. return nil, false
  6182. }
  6183. // OldField returns the old value of the field from the database. An error is
  6184. // returned if the mutation operation is not UpdateOne, or the query to the
  6185. // database failed.
  6186. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6187. switch name {
  6188. case message.FieldWxWxid:
  6189. return m.OldWxWxid(ctx)
  6190. case message.FieldWxid:
  6191. return m.OldWxid(ctx)
  6192. case message.FieldContent:
  6193. return m.OldContent(ctx)
  6194. }
  6195. return nil, fmt.Errorf("unknown Message field %s", name)
  6196. }
  6197. // SetField sets the value of a field with the given name. It returns an error if
  6198. // the field is not defined in the schema, or if the type mismatched the field
  6199. // type.
  6200. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  6201. switch name {
  6202. case message.FieldWxWxid:
  6203. v, ok := value.(string)
  6204. if !ok {
  6205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6206. }
  6207. m.SetWxWxid(v)
  6208. return nil
  6209. case message.FieldWxid:
  6210. v, ok := value.(string)
  6211. if !ok {
  6212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6213. }
  6214. m.SetWxid(v)
  6215. return nil
  6216. case message.FieldContent:
  6217. v, ok := value.(string)
  6218. if !ok {
  6219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6220. }
  6221. m.SetContent(v)
  6222. return nil
  6223. }
  6224. return fmt.Errorf("unknown Message field %s", name)
  6225. }
  6226. // AddedFields returns all numeric fields that were incremented/decremented during
  6227. // this mutation.
  6228. func (m *MessageMutation) AddedFields() []string {
  6229. return nil
  6230. }
  6231. // AddedField returns the numeric value that was incremented/decremented on a field
  6232. // with the given name. The second boolean return value indicates that this field
  6233. // was not set, or was not defined in the schema.
  6234. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  6235. return nil, false
  6236. }
  6237. // AddField adds the value to the field with the given name. It returns an error if
  6238. // the field is not defined in the schema, or if the type mismatched the field
  6239. // type.
  6240. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  6241. switch name {
  6242. }
  6243. return fmt.Errorf("unknown Message numeric field %s", name)
  6244. }
  6245. // ClearedFields returns all nullable fields that were cleared during this
  6246. // mutation.
  6247. func (m *MessageMutation) ClearedFields() []string {
  6248. var fields []string
  6249. if m.FieldCleared(message.FieldWxWxid) {
  6250. fields = append(fields, message.FieldWxWxid)
  6251. }
  6252. return fields
  6253. }
  6254. // FieldCleared returns a boolean indicating if a field with the given name was
  6255. // cleared in this mutation.
  6256. func (m *MessageMutation) FieldCleared(name string) bool {
  6257. _, ok := m.clearedFields[name]
  6258. return ok
  6259. }
  6260. // ClearField clears the value of the field with the given name. It returns an
  6261. // error if the field is not defined in the schema.
  6262. func (m *MessageMutation) ClearField(name string) error {
  6263. switch name {
  6264. case message.FieldWxWxid:
  6265. m.ClearWxWxid()
  6266. return nil
  6267. }
  6268. return fmt.Errorf("unknown Message nullable field %s", name)
  6269. }
  6270. // ResetField resets all changes in the mutation for the field with the given name.
  6271. // It returns an error if the field is not defined in the schema.
  6272. func (m *MessageMutation) ResetField(name string) error {
  6273. switch name {
  6274. case message.FieldWxWxid:
  6275. m.ResetWxWxid()
  6276. return nil
  6277. case message.FieldWxid:
  6278. m.ResetWxid()
  6279. return nil
  6280. case message.FieldContent:
  6281. m.ResetContent()
  6282. return nil
  6283. }
  6284. return fmt.Errorf("unknown Message field %s", name)
  6285. }
  6286. // AddedEdges returns all edge names that were set/added in this mutation.
  6287. func (m *MessageMutation) AddedEdges() []string {
  6288. edges := make([]string, 0, 0)
  6289. return edges
  6290. }
  6291. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6292. // name in this mutation.
  6293. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  6294. return nil
  6295. }
  6296. // RemovedEdges returns all edge names that were removed in this mutation.
  6297. func (m *MessageMutation) RemovedEdges() []string {
  6298. edges := make([]string, 0, 0)
  6299. return edges
  6300. }
  6301. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6302. // the given name in this mutation.
  6303. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  6304. return nil
  6305. }
  6306. // ClearedEdges returns all edge names that were cleared in this mutation.
  6307. func (m *MessageMutation) ClearedEdges() []string {
  6308. edges := make([]string, 0, 0)
  6309. return edges
  6310. }
  6311. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6312. // was cleared in this mutation.
  6313. func (m *MessageMutation) EdgeCleared(name string) bool {
  6314. return false
  6315. }
  6316. // ClearEdge clears the value of the edge with the given name. It returns an error
  6317. // if that edge is not defined in the schema.
  6318. func (m *MessageMutation) ClearEdge(name string) error {
  6319. return fmt.Errorf("unknown Message unique edge %s", name)
  6320. }
  6321. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6322. // It returns an error if the edge is not defined in the schema.
  6323. func (m *MessageMutation) ResetEdge(name string) error {
  6324. return fmt.Errorf("unknown Message edge %s", name)
  6325. }
  6326. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  6327. type MessageRecordsMutation struct {
  6328. config
  6329. op Op
  6330. typ string
  6331. id *uint64
  6332. created_at *time.Time
  6333. updated_at *time.Time
  6334. status *uint8
  6335. addstatus *int8
  6336. deleted_at *time.Time
  6337. bot_wxid *string
  6338. contact_type *int
  6339. addcontact_type *int
  6340. contact_wxid *string
  6341. content_type *int
  6342. addcontent_type *int
  6343. content *string
  6344. meta *custom_types.Meta
  6345. error_detail *string
  6346. send_time *time.Time
  6347. source_type *int
  6348. addsource_type *int
  6349. organization_id *uint64
  6350. addorganization_id *int64
  6351. clearedFields map[string]struct{}
  6352. sop_stage *uint64
  6353. clearedsop_stage bool
  6354. sop_node *uint64
  6355. clearedsop_node bool
  6356. message_contact *uint64
  6357. clearedmessage_contact bool
  6358. done bool
  6359. oldValue func(context.Context) (*MessageRecords, error)
  6360. predicates []predicate.MessageRecords
  6361. }
  6362. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  6363. // messagerecordsOption allows management of the mutation configuration using functional options.
  6364. type messagerecordsOption func(*MessageRecordsMutation)
  6365. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  6366. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  6367. m := &MessageRecordsMutation{
  6368. config: c,
  6369. op: op,
  6370. typ: TypeMessageRecords,
  6371. clearedFields: make(map[string]struct{}),
  6372. }
  6373. for _, opt := range opts {
  6374. opt(m)
  6375. }
  6376. return m
  6377. }
  6378. // withMessageRecordsID sets the ID field of the mutation.
  6379. func withMessageRecordsID(id uint64) messagerecordsOption {
  6380. return func(m *MessageRecordsMutation) {
  6381. var (
  6382. err error
  6383. once sync.Once
  6384. value *MessageRecords
  6385. )
  6386. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  6387. once.Do(func() {
  6388. if m.done {
  6389. err = errors.New("querying old values post mutation is not allowed")
  6390. } else {
  6391. value, err = m.Client().MessageRecords.Get(ctx, id)
  6392. }
  6393. })
  6394. return value, err
  6395. }
  6396. m.id = &id
  6397. }
  6398. }
  6399. // withMessageRecords sets the old MessageRecords of the mutation.
  6400. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  6401. return func(m *MessageRecordsMutation) {
  6402. m.oldValue = func(context.Context) (*MessageRecords, error) {
  6403. return node, nil
  6404. }
  6405. m.id = &node.ID
  6406. }
  6407. }
  6408. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6409. // executed in a transaction (ent.Tx), a transactional client is returned.
  6410. func (m MessageRecordsMutation) Client() *Client {
  6411. client := &Client{config: m.config}
  6412. client.init()
  6413. return client
  6414. }
  6415. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6416. // it returns an error otherwise.
  6417. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  6418. if _, ok := m.driver.(*txDriver); !ok {
  6419. return nil, errors.New("ent: mutation is not running in a transaction")
  6420. }
  6421. tx := &Tx{config: m.config}
  6422. tx.init()
  6423. return tx, nil
  6424. }
  6425. // SetID sets the value of the id field. Note that this
  6426. // operation is only accepted on creation of MessageRecords entities.
  6427. func (m *MessageRecordsMutation) SetID(id uint64) {
  6428. m.id = &id
  6429. }
  6430. // ID returns the ID value in the mutation. Note that the ID is only available
  6431. // if it was provided to the builder or after it was returned from the database.
  6432. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  6433. if m.id == nil {
  6434. return
  6435. }
  6436. return *m.id, true
  6437. }
  6438. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6439. // That means, if the mutation is applied within a transaction with an isolation level such
  6440. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6441. // or updated by the mutation.
  6442. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  6443. switch {
  6444. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6445. id, exists := m.ID()
  6446. if exists {
  6447. return []uint64{id}, nil
  6448. }
  6449. fallthrough
  6450. case m.op.Is(OpUpdate | OpDelete):
  6451. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  6452. default:
  6453. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6454. }
  6455. }
  6456. // SetCreatedAt sets the "created_at" field.
  6457. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  6458. m.created_at = &t
  6459. }
  6460. // CreatedAt returns the value of the "created_at" field in the mutation.
  6461. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  6462. v := m.created_at
  6463. if v == nil {
  6464. return
  6465. }
  6466. return *v, true
  6467. }
  6468. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  6469. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6470. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6471. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6472. if !m.op.Is(OpUpdateOne) {
  6473. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6474. }
  6475. if m.id == nil || m.oldValue == nil {
  6476. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6477. }
  6478. oldValue, err := m.oldValue(ctx)
  6479. if err != nil {
  6480. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6481. }
  6482. return oldValue.CreatedAt, nil
  6483. }
  6484. // ResetCreatedAt resets all changes to the "created_at" field.
  6485. func (m *MessageRecordsMutation) ResetCreatedAt() {
  6486. m.created_at = nil
  6487. }
  6488. // SetUpdatedAt sets the "updated_at" field.
  6489. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  6490. m.updated_at = &t
  6491. }
  6492. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6493. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  6494. v := m.updated_at
  6495. if v == nil {
  6496. return
  6497. }
  6498. return *v, true
  6499. }
  6500. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  6501. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6503. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6504. if !m.op.Is(OpUpdateOne) {
  6505. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6506. }
  6507. if m.id == nil || m.oldValue == nil {
  6508. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6509. }
  6510. oldValue, err := m.oldValue(ctx)
  6511. if err != nil {
  6512. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6513. }
  6514. return oldValue.UpdatedAt, nil
  6515. }
  6516. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6517. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  6518. m.updated_at = nil
  6519. }
  6520. // SetStatus sets the "status" field.
  6521. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  6522. m.status = &u
  6523. m.addstatus = nil
  6524. }
  6525. // Status returns the value of the "status" field in the mutation.
  6526. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  6527. v := m.status
  6528. if v == nil {
  6529. return
  6530. }
  6531. return *v, true
  6532. }
  6533. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  6534. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6536. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  6537. if !m.op.Is(OpUpdateOne) {
  6538. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  6539. }
  6540. if m.id == nil || m.oldValue == nil {
  6541. return v, errors.New("OldStatus requires an ID field in the mutation")
  6542. }
  6543. oldValue, err := m.oldValue(ctx)
  6544. if err != nil {
  6545. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  6546. }
  6547. return oldValue.Status, nil
  6548. }
  6549. // AddStatus adds u to the "status" field.
  6550. func (m *MessageRecordsMutation) AddStatus(u int8) {
  6551. if m.addstatus != nil {
  6552. *m.addstatus += u
  6553. } else {
  6554. m.addstatus = &u
  6555. }
  6556. }
  6557. // AddedStatus returns the value that was added to the "status" field in this mutation.
  6558. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  6559. v := m.addstatus
  6560. if v == nil {
  6561. return
  6562. }
  6563. return *v, true
  6564. }
  6565. // ClearStatus clears the value of the "status" field.
  6566. func (m *MessageRecordsMutation) ClearStatus() {
  6567. m.status = nil
  6568. m.addstatus = nil
  6569. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  6570. }
  6571. // StatusCleared returns if the "status" field was cleared in this mutation.
  6572. func (m *MessageRecordsMutation) StatusCleared() bool {
  6573. _, ok := m.clearedFields[messagerecords.FieldStatus]
  6574. return ok
  6575. }
  6576. // ResetStatus resets all changes to the "status" field.
  6577. func (m *MessageRecordsMutation) ResetStatus() {
  6578. m.status = nil
  6579. m.addstatus = nil
  6580. delete(m.clearedFields, messagerecords.FieldStatus)
  6581. }
  6582. // SetDeletedAt sets the "deleted_at" field.
  6583. func (m *MessageRecordsMutation) SetDeletedAt(t time.Time) {
  6584. m.deleted_at = &t
  6585. }
  6586. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6587. func (m *MessageRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  6588. v := m.deleted_at
  6589. if v == nil {
  6590. return
  6591. }
  6592. return *v, true
  6593. }
  6594. // OldDeletedAt returns the old "deleted_at" field's value of the MessageRecords entity.
  6595. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6597. func (m *MessageRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6598. if !m.op.Is(OpUpdateOne) {
  6599. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6600. }
  6601. if m.id == nil || m.oldValue == nil {
  6602. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6603. }
  6604. oldValue, err := m.oldValue(ctx)
  6605. if err != nil {
  6606. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6607. }
  6608. return oldValue.DeletedAt, nil
  6609. }
  6610. // ClearDeletedAt clears the value of the "deleted_at" field.
  6611. func (m *MessageRecordsMutation) ClearDeletedAt() {
  6612. m.deleted_at = nil
  6613. m.clearedFields[messagerecords.FieldDeletedAt] = struct{}{}
  6614. }
  6615. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6616. func (m *MessageRecordsMutation) DeletedAtCleared() bool {
  6617. _, ok := m.clearedFields[messagerecords.FieldDeletedAt]
  6618. return ok
  6619. }
  6620. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6621. func (m *MessageRecordsMutation) ResetDeletedAt() {
  6622. m.deleted_at = nil
  6623. delete(m.clearedFields, messagerecords.FieldDeletedAt)
  6624. }
  6625. // SetBotWxid sets the "bot_wxid" field.
  6626. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  6627. m.bot_wxid = &s
  6628. }
  6629. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  6630. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  6631. v := m.bot_wxid
  6632. if v == nil {
  6633. return
  6634. }
  6635. return *v, true
  6636. }
  6637. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  6638. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6639. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6640. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  6641. if !m.op.Is(OpUpdateOne) {
  6642. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  6643. }
  6644. if m.id == nil || m.oldValue == nil {
  6645. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  6646. }
  6647. oldValue, err := m.oldValue(ctx)
  6648. if err != nil {
  6649. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  6650. }
  6651. return oldValue.BotWxid, nil
  6652. }
  6653. // ResetBotWxid resets all changes to the "bot_wxid" field.
  6654. func (m *MessageRecordsMutation) ResetBotWxid() {
  6655. m.bot_wxid = nil
  6656. }
  6657. // SetContactID sets the "contact_id" field.
  6658. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  6659. m.message_contact = &u
  6660. }
  6661. // ContactID returns the value of the "contact_id" field in the mutation.
  6662. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  6663. v := m.message_contact
  6664. if v == nil {
  6665. return
  6666. }
  6667. return *v, true
  6668. }
  6669. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  6670. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6672. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  6673. if !m.op.Is(OpUpdateOne) {
  6674. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  6675. }
  6676. if m.id == nil || m.oldValue == nil {
  6677. return v, errors.New("OldContactID requires an ID field in the mutation")
  6678. }
  6679. oldValue, err := m.oldValue(ctx)
  6680. if err != nil {
  6681. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  6682. }
  6683. return oldValue.ContactID, nil
  6684. }
  6685. // ClearContactID clears the value of the "contact_id" field.
  6686. func (m *MessageRecordsMutation) ClearContactID() {
  6687. m.message_contact = nil
  6688. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  6689. }
  6690. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  6691. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  6692. _, ok := m.clearedFields[messagerecords.FieldContactID]
  6693. return ok
  6694. }
  6695. // ResetContactID resets all changes to the "contact_id" field.
  6696. func (m *MessageRecordsMutation) ResetContactID() {
  6697. m.message_contact = nil
  6698. delete(m.clearedFields, messagerecords.FieldContactID)
  6699. }
  6700. // SetContactType sets the "contact_type" field.
  6701. func (m *MessageRecordsMutation) SetContactType(i int) {
  6702. m.contact_type = &i
  6703. m.addcontact_type = nil
  6704. }
  6705. // ContactType returns the value of the "contact_type" field in the mutation.
  6706. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  6707. v := m.contact_type
  6708. if v == nil {
  6709. return
  6710. }
  6711. return *v, true
  6712. }
  6713. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  6714. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6715. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6716. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  6717. if !m.op.Is(OpUpdateOne) {
  6718. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  6719. }
  6720. if m.id == nil || m.oldValue == nil {
  6721. return v, errors.New("OldContactType requires an ID field in the mutation")
  6722. }
  6723. oldValue, err := m.oldValue(ctx)
  6724. if err != nil {
  6725. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  6726. }
  6727. return oldValue.ContactType, nil
  6728. }
  6729. // AddContactType adds i to the "contact_type" field.
  6730. func (m *MessageRecordsMutation) AddContactType(i int) {
  6731. if m.addcontact_type != nil {
  6732. *m.addcontact_type += i
  6733. } else {
  6734. m.addcontact_type = &i
  6735. }
  6736. }
  6737. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  6738. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  6739. v := m.addcontact_type
  6740. if v == nil {
  6741. return
  6742. }
  6743. return *v, true
  6744. }
  6745. // ResetContactType resets all changes to the "contact_type" field.
  6746. func (m *MessageRecordsMutation) ResetContactType() {
  6747. m.contact_type = nil
  6748. m.addcontact_type = nil
  6749. }
  6750. // SetContactWxid sets the "contact_wxid" field.
  6751. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  6752. m.contact_wxid = &s
  6753. }
  6754. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  6755. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  6756. v := m.contact_wxid
  6757. if v == nil {
  6758. return
  6759. }
  6760. return *v, true
  6761. }
  6762. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  6763. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6765. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  6766. if !m.op.Is(OpUpdateOne) {
  6767. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  6768. }
  6769. if m.id == nil || m.oldValue == nil {
  6770. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  6771. }
  6772. oldValue, err := m.oldValue(ctx)
  6773. if err != nil {
  6774. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  6775. }
  6776. return oldValue.ContactWxid, nil
  6777. }
  6778. // ResetContactWxid resets all changes to the "contact_wxid" field.
  6779. func (m *MessageRecordsMutation) ResetContactWxid() {
  6780. m.contact_wxid = nil
  6781. }
  6782. // SetContentType sets the "content_type" field.
  6783. func (m *MessageRecordsMutation) SetContentType(i int) {
  6784. m.content_type = &i
  6785. m.addcontent_type = nil
  6786. }
  6787. // ContentType returns the value of the "content_type" field in the mutation.
  6788. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  6789. v := m.content_type
  6790. if v == nil {
  6791. return
  6792. }
  6793. return *v, true
  6794. }
  6795. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  6796. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6798. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  6799. if !m.op.Is(OpUpdateOne) {
  6800. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  6801. }
  6802. if m.id == nil || m.oldValue == nil {
  6803. return v, errors.New("OldContentType requires an ID field in the mutation")
  6804. }
  6805. oldValue, err := m.oldValue(ctx)
  6806. if err != nil {
  6807. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  6808. }
  6809. return oldValue.ContentType, nil
  6810. }
  6811. // AddContentType adds i to the "content_type" field.
  6812. func (m *MessageRecordsMutation) AddContentType(i int) {
  6813. if m.addcontent_type != nil {
  6814. *m.addcontent_type += i
  6815. } else {
  6816. m.addcontent_type = &i
  6817. }
  6818. }
  6819. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  6820. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  6821. v := m.addcontent_type
  6822. if v == nil {
  6823. return
  6824. }
  6825. return *v, true
  6826. }
  6827. // ResetContentType resets all changes to the "content_type" field.
  6828. func (m *MessageRecordsMutation) ResetContentType() {
  6829. m.content_type = nil
  6830. m.addcontent_type = nil
  6831. }
  6832. // SetContent sets the "content" field.
  6833. func (m *MessageRecordsMutation) SetContent(s string) {
  6834. m.content = &s
  6835. }
  6836. // Content returns the value of the "content" field in the mutation.
  6837. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  6838. v := m.content
  6839. if v == nil {
  6840. return
  6841. }
  6842. return *v, true
  6843. }
  6844. // OldContent returns the old "content" field's value of the MessageRecords entity.
  6845. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6847. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  6848. if !m.op.Is(OpUpdateOne) {
  6849. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6850. }
  6851. if m.id == nil || m.oldValue == nil {
  6852. return v, errors.New("OldContent requires an ID field in the mutation")
  6853. }
  6854. oldValue, err := m.oldValue(ctx)
  6855. if err != nil {
  6856. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  6857. }
  6858. return oldValue.Content, nil
  6859. }
  6860. // ResetContent resets all changes to the "content" field.
  6861. func (m *MessageRecordsMutation) ResetContent() {
  6862. m.content = nil
  6863. }
  6864. // SetMeta sets the "meta" field.
  6865. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  6866. m.meta = &ct
  6867. }
  6868. // Meta returns the value of the "meta" field in the mutation.
  6869. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  6870. v := m.meta
  6871. if v == nil {
  6872. return
  6873. }
  6874. return *v, true
  6875. }
  6876. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  6877. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6879. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  6880. if !m.op.Is(OpUpdateOne) {
  6881. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  6882. }
  6883. if m.id == nil || m.oldValue == nil {
  6884. return v, errors.New("OldMeta requires an ID field in the mutation")
  6885. }
  6886. oldValue, err := m.oldValue(ctx)
  6887. if err != nil {
  6888. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  6889. }
  6890. return oldValue.Meta, nil
  6891. }
  6892. // ClearMeta clears the value of the "meta" field.
  6893. func (m *MessageRecordsMutation) ClearMeta() {
  6894. m.meta = nil
  6895. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  6896. }
  6897. // MetaCleared returns if the "meta" field was cleared in this mutation.
  6898. func (m *MessageRecordsMutation) MetaCleared() bool {
  6899. _, ok := m.clearedFields[messagerecords.FieldMeta]
  6900. return ok
  6901. }
  6902. // ResetMeta resets all changes to the "meta" field.
  6903. func (m *MessageRecordsMutation) ResetMeta() {
  6904. m.meta = nil
  6905. delete(m.clearedFields, messagerecords.FieldMeta)
  6906. }
  6907. // SetErrorDetail sets the "error_detail" field.
  6908. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  6909. m.error_detail = &s
  6910. }
  6911. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  6912. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  6913. v := m.error_detail
  6914. if v == nil {
  6915. return
  6916. }
  6917. return *v, true
  6918. }
  6919. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  6920. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6922. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  6923. if !m.op.Is(OpUpdateOne) {
  6924. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  6925. }
  6926. if m.id == nil || m.oldValue == nil {
  6927. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  6928. }
  6929. oldValue, err := m.oldValue(ctx)
  6930. if err != nil {
  6931. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  6932. }
  6933. return oldValue.ErrorDetail, nil
  6934. }
  6935. // ResetErrorDetail resets all changes to the "error_detail" field.
  6936. func (m *MessageRecordsMutation) ResetErrorDetail() {
  6937. m.error_detail = nil
  6938. }
  6939. // SetSendTime sets the "send_time" field.
  6940. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  6941. m.send_time = &t
  6942. }
  6943. // SendTime returns the value of the "send_time" field in the mutation.
  6944. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  6945. v := m.send_time
  6946. if v == nil {
  6947. return
  6948. }
  6949. return *v, true
  6950. }
  6951. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  6952. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6954. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  6955. if !m.op.Is(OpUpdateOne) {
  6956. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  6957. }
  6958. if m.id == nil || m.oldValue == nil {
  6959. return v, errors.New("OldSendTime requires an ID field in the mutation")
  6960. }
  6961. oldValue, err := m.oldValue(ctx)
  6962. if err != nil {
  6963. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  6964. }
  6965. return oldValue.SendTime, nil
  6966. }
  6967. // ClearSendTime clears the value of the "send_time" field.
  6968. func (m *MessageRecordsMutation) ClearSendTime() {
  6969. m.send_time = nil
  6970. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  6971. }
  6972. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  6973. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  6974. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  6975. return ok
  6976. }
  6977. // ResetSendTime resets all changes to the "send_time" field.
  6978. func (m *MessageRecordsMutation) ResetSendTime() {
  6979. m.send_time = nil
  6980. delete(m.clearedFields, messagerecords.FieldSendTime)
  6981. }
  6982. // SetSourceType sets the "source_type" field.
  6983. func (m *MessageRecordsMutation) SetSourceType(i int) {
  6984. m.source_type = &i
  6985. m.addsource_type = nil
  6986. }
  6987. // SourceType returns the value of the "source_type" field in the mutation.
  6988. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  6989. v := m.source_type
  6990. if v == nil {
  6991. return
  6992. }
  6993. return *v, true
  6994. }
  6995. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  6996. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6997. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6998. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  6999. if !m.op.Is(OpUpdateOne) {
  7000. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  7001. }
  7002. if m.id == nil || m.oldValue == nil {
  7003. return v, errors.New("OldSourceType requires an ID field in the mutation")
  7004. }
  7005. oldValue, err := m.oldValue(ctx)
  7006. if err != nil {
  7007. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  7008. }
  7009. return oldValue.SourceType, nil
  7010. }
  7011. // AddSourceType adds i to the "source_type" field.
  7012. func (m *MessageRecordsMutation) AddSourceType(i int) {
  7013. if m.addsource_type != nil {
  7014. *m.addsource_type += i
  7015. } else {
  7016. m.addsource_type = &i
  7017. }
  7018. }
  7019. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  7020. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  7021. v := m.addsource_type
  7022. if v == nil {
  7023. return
  7024. }
  7025. return *v, true
  7026. }
  7027. // ResetSourceType resets all changes to the "source_type" field.
  7028. func (m *MessageRecordsMutation) ResetSourceType() {
  7029. m.source_type = nil
  7030. m.addsource_type = nil
  7031. }
  7032. // SetSourceID sets the "source_id" field.
  7033. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  7034. m.sop_stage = &u
  7035. }
  7036. // SourceID returns the value of the "source_id" field in the mutation.
  7037. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  7038. v := m.sop_stage
  7039. if v == nil {
  7040. return
  7041. }
  7042. return *v, true
  7043. }
  7044. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  7045. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  7046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7047. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  7048. if !m.op.Is(OpUpdateOne) {
  7049. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  7050. }
  7051. if m.id == nil || m.oldValue == nil {
  7052. return v, errors.New("OldSourceID requires an ID field in the mutation")
  7053. }
  7054. oldValue, err := m.oldValue(ctx)
  7055. if err != nil {
  7056. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  7057. }
  7058. return oldValue.SourceID, nil
  7059. }
  7060. // ClearSourceID clears the value of the "source_id" field.
  7061. func (m *MessageRecordsMutation) ClearSourceID() {
  7062. m.sop_stage = nil
  7063. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  7064. }
  7065. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  7066. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  7067. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  7068. return ok
  7069. }
  7070. // ResetSourceID resets all changes to the "source_id" field.
  7071. func (m *MessageRecordsMutation) ResetSourceID() {
  7072. m.sop_stage = nil
  7073. delete(m.clearedFields, messagerecords.FieldSourceID)
  7074. }
  7075. // SetSubSourceID sets the "sub_source_id" field.
  7076. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  7077. m.sop_node = &u
  7078. }
  7079. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  7080. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  7081. v := m.sop_node
  7082. if v == nil {
  7083. return
  7084. }
  7085. return *v, true
  7086. }
  7087. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  7088. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  7089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7090. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  7091. if !m.op.Is(OpUpdateOne) {
  7092. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  7093. }
  7094. if m.id == nil || m.oldValue == nil {
  7095. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  7096. }
  7097. oldValue, err := m.oldValue(ctx)
  7098. if err != nil {
  7099. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  7100. }
  7101. return oldValue.SubSourceID, nil
  7102. }
  7103. // ClearSubSourceID clears the value of the "sub_source_id" field.
  7104. func (m *MessageRecordsMutation) ClearSubSourceID() {
  7105. m.sop_node = nil
  7106. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  7107. }
  7108. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  7109. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  7110. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  7111. return ok
  7112. }
  7113. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  7114. func (m *MessageRecordsMutation) ResetSubSourceID() {
  7115. m.sop_node = nil
  7116. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  7117. }
  7118. // SetOrganizationID sets the "organization_id" field.
  7119. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  7120. m.organization_id = &u
  7121. m.addorganization_id = nil
  7122. }
  7123. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7124. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  7125. v := m.organization_id
  7126. if v == nil {
  7127. return
  7128. }
  7129. return *v, true
  7130. }
  7131. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  7132. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  7133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7134. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7135. if !m.op.Is(OpUpdateOne) {
  7136. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7137. }
  7138. if m.id == nil || m.oldValue == nil {
  7139. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7140. }
  7141. oldValue, err := m.oldValue(ctx)
  7142. if err != nil {
  7143. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7144. }
  7145. return oldValue.OrganizationID, nil
  7146. }
  7147. // AddOrganizationID adds u to the "organization_id" field.
  7148. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  7149. if m.addorganization_id != nil {
  7150. *m.addorganization_id += u
  7151. } else {
  7152. m.addorganization_id = &u
  7153. }
  7154. }
  7155. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7156. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  7157. v := m.addorganization_id
  7158. if v == nil {
  7159. return
  7160. }
  7161. return *v, true
  7162. }
  7163. // ClearOrganizationID clears the value of the "organization_id" field.
  7164. func (m *MessageRecordsMutation) ClearOrganizationID() {
  7165. m.organization_id = nil
  7166. m.addorganization_id = nil
  7167. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  7168. }
  7169. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  7170. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  7171. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  7172. return ok
  7173. }
  7174. // ResetOrganizationID resets all changes to the "organization_id" field.
  7175. func (m *MessageRecordsMutation) ResetOrganizationID() {
  7176. m.organization_id = nil
  7177. m.addorganization_id = nil
  7178. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  7179. }
  7180. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  7181. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  7182. m.sop_stage = &id
  7183. }
  7184. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  7185. func (m *MessageRecordsMutation) ClearSopStage() {
  7186. m.clearedsop_stage = true
  7187. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  7188. }
  7189. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  7190. func (m *MessageRecordsMutation) SopStageCleared() bool {
  7191. return m.SourceIDCleared() || m.clearedsop_stage
  7192. }
  7193. // SopStageID returns the "sop_stage" edge ID in the mutation.
  7194. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  7195. if m.sop_stage != nil {
  7196. return *m.sop_stage, true
  7197. }
  7198. return
  7199. }
  7200. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  7201. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  7202. // SopStageID instead. It exists only for internal usage by the builders.
  7203. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  7204. if id := m.sop_stage; id != nil {
  7205. ids = append(ids, *id)
  7206. }
  7207. return
  7208. }
  7209. // ResetSopStage resets all changes to the "sop_stage" edge.
  7210. func (m *MessageRecordsMutation) ResetSopStage() {
  7211. m.sop_stage = nil
  7212. m.clearedsop_stage = false
  7213. }
  7214. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  7215. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  7216. m.sop_node = &id
  7217. }
  7218. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  7219. func (m *MessageRecordsMutation) ClearSopNode() {
  7220. m.clearedsop_node = true
  7221. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  7222. }
  7223. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  7224. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  7225. return m.SubSourceIDCleared() || m.clearedsop_node
  7226. }
  7227. // SopNodeID returns the "sop_node" edge ID in the mutation.
  7228. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  7229. if m.sop_node != nil {
  7230. return *m.sop_node, true
  7231. }
  7232. return
  7233. }
  7234. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  7235. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  7236. // SopNodeID instead. It exists only for internal usage by the builders.
  7237. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  7238. if id := m.sop_node; id != nil {
  7239. ids = append(ids, *id)
  7240. }
  7241. return
  7242. }
  7243. // ResetSopNode resets all changes to the "sop_node" edge.
  7244. func (m *MessageRecordsMutation) ResetSopNode() {
  7245. m.sop_node = nil
  7246. m.clearedsop_node = false
  7247. }
  7248. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  7249. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  7250. m.message_contact = &id
  7251. }
  7252. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  7253. func (m *MessageRecordsMutation) ClearMessageContact() {
  7254. m.clearedmessage_contact = true
  7255. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  7256. }
  7257. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  7258. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  7259. return m.ContactIDCleared() || m.clearedmessage_contact
  7260. }
  7261. // MessageContactID returns the "message_contact" edge ID in the mutation.
  7262. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  7263. if m.message_contact != nil {
  7264. return *m.message_contact, true
  7265. }
  7266. return
  7267. }
  7268. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  7269. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  7270. // MessageContactID instead. It exists only for internal usage by the builders.
  7271. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  7272. if id := m.message_contact; id != nil {
  7273. ids = append(ids, *id)
  7274. }
  7275. return
  7276. }
  7277. // ResetMessageContact resets all changes to the "message_contact" edge.
  7278. func (m *MessageRecordsMutation) ResetMessageContact() {
  7279. m.message_contact = nil
  7280. m.clearedmessage_contact = false
  7281. }
  7282. // Where appends a list predicates to the MessageRecordsMutation builder.
  7283. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  7284. m.predicates = append(m.predicates, ps...)
  7285. }
  7286. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  7287. // users can use type-assertion to append predicates that do not depend on any generated package.
  7288. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  7289. p := make([]predicate.MessageRecords, len(ps))
  7290. for i := range ps {
  7291. p[i] = ps[i]
  7292. }
  7293. m.Where(p...)
  7294. }
  7295. // Op returns the operation name.
  7296. func (m *MessageRecordsMutation) Op() Op {
  7297. return m.op
  7298. }
  7299. // SetOp allows setting the mutation operation.
  7300. func (m *MessageRecordsMutation) SetOp(op Op) {
  7301. m.op = op
  7302. }
  7303. // Type returns the node type of this mutation (MessageRecords).
  7304. func (m *MessageRecordsMutation) Type() string {
  7305. return m.typ
  7306. }
  7307. // Fields returns all fields that were changed during this mutation. Note that in
  7308. // order to get all numeric fields that were incremented/decremented, call
  7309. // AddedFields().
  7310. func (m *MessageRecordsMutation) Fields() []string {
  7311. fields := make([]string, 0, 17)
  7312. if m.created_at != nil {
  7313. fields = append(fields, messagerecords.FieldCreatedAt)
  7314. }
  7315. if m.updated_at != nil {
  7316. fields = append(fields, messagerecords.FieldUpdatedAt)
  7317. }
  7318. if m.status != nil {
  7319. fields = append(fields, messagerecords.FieldStatus)
  7320. }
  7321. if m.deleted_at != nil {
  7322. fields = append(fields, messagerecords.FieldDeletedAt)
  7323. }
  7324. if m.bot_wxid != nil {
  7325. fields = append(fields, messagerecords.FieldBotWxid)
  7326. }
  7327. if m.message_contact != nil {
  7328. fields = append(fields, messagerecords.FieldContactID)
  7329. }
  7330. if m.contact_type != nil {
  7331. fields = append(fields, messagerecords.FieldContactType)
  7332. }
  7333. if m.contact_wxid != nil {
  7334. fields = append(fields, messagerecords.FieldContactWxid)
  7335. }
  7336. if m.content_type != nil {
  7337. fields = append(fields, messagerecords.FieldContentType)
  7338. }
  7339. if m.content != nil {
  7340. fields = append(fields, messagerecords.FieldContent)
  7341. }
  7342. if m.meta != nil {
  7343. fields = append(fields, messagerecords.FieldMeta)
  7344. }
  7345. if m.error_detail != nil {
  7346. fields = append(fields, messagerecords.FieldErrorDetail)
  7347. }
  7348. if m.send_time != nil {
  7349. fields = append(fields, messagerecords.FieldSendTime)
  7350. }
  7351. if m.source_type != nil {
  7352. fields = append(fields, messagerecords.FieldSourceType)
  7353. }
  7354. if m.sop_stage != nil {
  7355. fields = append(fields, messagerecords.FieldSourceID)
  7356. }
  7357. if m.sop_node != nil {
  7358. fields = append(fields, messagerecords.FieldSubSourceID)
  7359. }
  7360. if m.organization_id != nil {
  7361. fields = append(fields, messagerecords.FieldOrganizationID)
  7362. }
  7363. return fields
  7364. }
  7365. // Field returns the value of a field with the given name. The second boolean
  7366. // return value indicates that this field was not set, or was not defined in the
  7367. // schema.
  7368. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  7369. switch name {
  7370. case messagerecords.FieldCreatedAt:
  7371. return m.CreatedAt()
  7372. case messagerecords.FieldUpdatedAt:
  7373. return m.UpdatedAt()
  7374. case messagerecords.FieldStatus:
  7375. return m.Status()
  7376. case messagerecords.FieldDeletedAt:
  7377. return m.DeletedAt()
  7378. case messagerecords.FieldBotWxid:
  7379. return m.BotWxid()
  7380. case messagerecords.FieldContactID:
  7381. return m.ContactID()
  7382. case messagerecords.FieldContactType:
  7383. return m.ContactType()
  7384. case messagerecords.FieldContactWxid:
  7385. return m.ContactWxid()
  7386. case messagerecords.FieldContentType:
  7387. return m.ContentType()
  7388. case messagerecords.FieldContent:
  7389. return m.Content()
  7390. case messagerecords.FieldMeta:
  7391. return m.Meta()
  7392. case messagerecords.FieldErrorDetail:
  7393. return m.ErrorDetail()
  7394. case messagerecords.FieldSendTime:
  7395. return m.SendTime()
  7396. case messagerecords.FieldSourceType:
  7397. return m.SourceType()
  7398. case messagerecords.FieldSourceID:
  7399. return m.SourceID()
  7400. case messagerecords.FieldSubSourceID:
  7401. return m.SubSourceID()
  7402. case messagerecords.FieldOrganizationID:
  7403. return m.OrganizationID()
  7404. }
  7405. return nil, false
  7406. }
  7407. // OldField returns the old value of the field from the database. An error is
  7408. // returned if the mutation operation is not UpdateOne, or the query to the
  7409. // database failed.
  7410. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7411. switch name {
  7412. case messagerecords.FieldCreatedAt:
  7413. return m.OldCreatedAt(ctx)
  7414. case messagerecords.FieldUpdatedAt:
  7415. return m.OldUpdatedAt(ctx)
  7416. case messagerecords.FieldStatus:
  7417. return m.OldStatus(ctx)
  7418. case messagerecords.FieldDeletedAt:
  7419. return m.OldDeletedAt(ctx)
  7420. case messagerecords.FieldBotWxid:
  7421. return m.OldBotWxid(ctx)
  7422. case messagerecords.FieldContactID:
  7423. return m.OldContactID(ctx)
  7424. case messagerecords.FieldContactType:
  7425. return m.OldContactType(ctx)
  7426. case messagerecords.FieldContactWxid:
  7427. return m.OldContactWxid(ctx)
  7428. case messagerecords.FieldContentType:
  7429. return m.OldContentType(ctx)
  7430. case messagerecords.FieldContent:
  7431. return m.OldContent(ctx)
  7432. case messagerecords.FieldMeta:
  7433. return m.OldMeta(ctx)
  7434. case messagerecords.FieldErrorDetail:
  7435. return m.OldErrorDetail(ctx)
  7436. case messagerecords.FieldSendTime:
  7437. return m.OldSendTime(ctx)
  7438. case messagerecords.FieldSourceType:
  7439. return m.OldSourceType(ctx)
  7440. case messagerecords.FieldSourceID:
  7441. return m.OldSourceID(ctx)
  7442. case messagerecords.FieldSubSourceID:
  7443. return m.OldSubSourceID(ctx)
  7444. case messagerecords.FieldOrganizationID:
  7445. return m.OldOrganizationID(ctx)
  7446. }
  7447. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  7448. }
  7449. // SetField sets the value of a field with the given name. It returns an error if
  7450. // the field is not defined in the schema, or if the type mismatched the field
  7451. // type.
  7452. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  7453. switch name {
  7454. case messagerecords.FieldCreatedAt:
  7455. v, ok := value.(time.Time)
  7456. if !ok {
  7457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7458. }
  7459. m.SetCreatedAt(v)
  7460. return nil
  7461. case messagerecords.FieldUpdatedAt:
  7462. v, ok := value.(time.Time)
  7463. if !ok {
  7464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7465. }
  7466. m.SetUpdatedAt(v)
  7467. return nil
  7468. case messagerecords.FieldStatus:
  7469. v, ok := value.(uint8)
  7470. if !ok {
  7471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7472. }
  7473. m.SetStatus(v)
  7474. return nil
  7475. case messagerecords.FieldDeletedAt:
  7476. v, ok := value.(time.Time)
  7477. if !ok {
  7478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7479. }
  7480. m.SetDeletedAt(v)
  7481. return nil
  7482. case messagerecords.FieldBotWxid:
  7483. v, ok := value.(string)
  7484. if !ok {
  7485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7486. }
  7487. m.SetBotWxid(v)
  7488. return nil
  7489. case messagerecords.FieldContactID:
  7490. v, ok := value.(uint64)
  7491. if !ok {
  7492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7493. }
  7494. m.SetContactID(v)
  7495. return nil
  7496. case messagerecords.FieldContactType:
  7497. v, ok := value.(int)
  7498. if !ok {
  7499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7500. }
  7501. m.SetContactType(v)
  7502. return nil
  7503. case messagerecords.FieldContactWxid:
  7504. v, ok := value.(string)
  7505. if !ok {
  7506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7507. }
  7508. m.SetContactWxid(v)
  7509. return nil
  7510. case messagerecords.FieldContentType:
  7511. v, ok := value.(int)
  7512. if !ok {
  7513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7514. }
  7515. m.SetContentType(v)
  7516. return nil
  7517. case messagerecords.FieldContent:
  7518. v, ok := value.(string)
  7519. if !ok {
  7520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7521. }
  7522. m.SetContent(v)
  7523. return nil
  7524. case messagerecords.FieldMeta:
  7525. v, ok := value.(custom_types.Meta)
  7526. if !ok {
  7527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7528. }
  7529. m.SetMeta(v)
  7530. return nil
  7531. case messagerecords.FieldErrorDetail:
  7532. v, ok := value.(string)
  7533. if !ok {
  7534. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7535. }
  7536. m.SetErrorDetail(v)
  7537. return nil
  7538. case messagerecords.FieldSendTime:
  7539. v, ok := value.(time.Time)
  7540. if !ok {
  7541. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7542. }
  7543. m.SetSendTime(v)
  7544. return nil
  7545. case messagerecords.FieldSourceType:
  7546. v, ok := value.(int)
  7547. if !ok {
  7548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7549. }
  7550. m.SetSourceType(v)
  7551. return nil
  7552. case messagerecords.FieldSourceID:
  7553. v, ok := value.(uint64)
  7554. if !ok {
  7555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7556. }
  7557. m.SetSourceID(v)
  7558. return nil
  7559. case messagerecords.FieldSubSourceID:
  7560. v, ok := value.(uint64)
  7561. if !ok {
  7562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7563. }
  7564. m.SetSubSourceID(v)
  7565. return nil
  7566. case messagerecords.FieldOrganizationID:
  7567. v, ok := value.(uint64)
  7568. if !ok {
  7569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7570. }
  7571. m.SetOrganizationID(v)
  7572. return nil
  7573. }
  7574. return fmt.Errorf("unknown MessageRecords field %s", name)
  7575. }
  7576. // AddedFields returns all numeric fields that were incremented/decremented during
  7577. // this mutation.
  7578. func (m *MessageRecordsMutation) AddedFields() []string {
  7579. var fields []string
  7580. if m.addstatus != nil {
  7581. fields = append(fields, messagerecords.FieldStatus)
  7582. }
  7583. if m.addcontact_type != nil {
  7584. fields = append(fields, messagerecords.FieldContactType)
  7585. }
  7586. if m.addcontent_type != nil {
  7587. fields = append(fields, messagerecords.FieldContentType)
  7588. }
  7589. if m.addsource_type != nil {
  7590. fields = append(fields, messagerecords.FieldSourceType)
  7591. }
  7592. if m.addorganization_id != nil {
  7593. fields = append(fields, messagerecords.FieldOrganizationID)
  7594. }
  7595. return fields
  7596. }
  7597. // AddedField returns the numeric value that was incremented/decremented on a field
  7598. // with the given name. The second boolean return value indicates that this field
  7599. // was not set, or was not defined in the schema.
  7600. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  7601. switch name {
  7602. case messagerecords.FieldStatus:
  7603. return m.AddedStatus()
  7604. case messagerecords.FieldContactType:
  7605. return m.AddedContactType()
  7606. case messagerecords.FieldContentType:
  7607. return m.AddedContentType()
  7608. case messagerecords.FieldSourceType:
  7609. return m.AddedSourceType()
  7610. case messagerecords.FieldOrganizationID:
  7611. return m.AddedOrganizationID()
  7612. }
  7613. return nil, false
  7614. }
  7615. // AddField adds the value to the field with the given name. It returns an error if
  7616. // the field is not defined in the schema, or if the type mismatched the field
  7617. // type.
  7618. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  7619. switch name {
  7620. case messagerecords.FieldStatus:
  7621. v, ok := value.(int8)
  7622. if !ok {
  7623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7624. }
  7625. m.AddStatus(v)
  7626. return nil
  7627. case messagerecords.FieldContactType:
  7628. v, ok := value.(int)
  7629. if !ok {
  7630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7631. }
  7632. m.AddContactType(v)
  7633. return nil
  7634. case messagerecords.FieldContentType:
  7635. v, ok := value.(int)
  7636. if !ok {
  7637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7638. }
  7639. m.AddContentType(v)
  7640. return nil
  7641. case messagerecords.FieldSourceType:
  7642. v, ok := value.(int)
  7643. if !ok {
  7644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7645. }
  7646. m.AddSourceType(v)
  7647. return nil
  7648. case messagerecords.FieldOrganizationID:
  7649. v, ok := value.(int64)
  7650. if !ok {
  7651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7652. }
  7653. m.AddOrganizationID(v)
  7654. return nil
  7655. }
  7656. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  7657. }
  7658. // ClearedFields returns all nullable fields that were cleared during this
  7659. // mutation.
  7660. func (m *MessageRecordsMutation) ClearedFields() []string {
  7661. var fields []string
  7662. if m.FieldCleared(messagerecords.FieldStatus) {
  7663. fields = append(fields, messagerecords.FieldStatus)
  7664. }
  7665. if m.FieldCleared(messagerecords.FieldDeletedAt) {
  7666. fields = append(fields, messagerecords.FieldDeletedAt)
  7667. }
  7668. if m.FieldCleared(messagerecords.FieldContactID) {
  7669. fields = append(fields, messagerecords.FieldContactID)
  7670. }
  7671. if m.FieldCleared(messagerecords.FieldMeta) {
  7672. fields = append(fields, messagerecords.FieldMeta)
  7673. }
  7674. if m.FieldCleared(messagerecords.FieldSendTime) {
  7675. fields = append(fields, messagerecords.FieldSendTime)
  7676. }
  7677. if m.FieldCleared(messagerecords.FieldSourceID) {
  7678. fields = append(fields, messagerecords.FieldSourceID)
  7679. }
  7680. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  7681. fields = append(fields, messagerecords.FieldSubSourceID)
  7682. }
  7683. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  7684. fields = append(fields, messagerecords.FieldOrganizationID)
  7685. }
  7686. return fields
  7687. }
  7688. // FieldCleared returns a boolean indicating if a field with the given name was
  7689. // cleared in this mutation.
  7690. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  7691. _, ok := m.clearedFields[name]
  7692. return ok
  7693. }
  7694. // ClearField clears the value of the field with the given name. It returns an
  7695. // error if the field is not defined in the schema.
  7696. func (m *MessageRecordsMutation) ClearField(name string) error {
  7697. switch name {
  7698. case messagerecords.FieldStatus:
  7699. m.ClearStatus()
  7700. return nil
  7701. case messagerecords.FieldDeletedAt:
  7702. m.ClearDeletedAt()
  7703. return nil
  7704. case messagerecords.FieldContactID:
  7705. m.ClearContactID()
  7706. return nil
  7707. case messagerecords.FieldMeta:
  7708. m.ClearMeta()
  7709. return nil
  7710. case messagerecords.FieldSendTime:
  7711. m.ClearSendTime()
  7712. return nil
  7713. case messagerecords.FieldSourceID:
  7714. m.ClearSourceID()
  7715. return nil
  7716. case messagerecords.FieldSubSourceID:
  7717. m.ClearSubSourceID()
  7718. return nil
  7719. case messagerecords.FieldOrganizationID:
  7720. m.ClearOrganizationID()
  7721. return nil
  7722. }
  7723. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  7724. }
  7725. // ResetField resets all changes in the mutation for the field with the given name.
  7726. // It returns an error if the field is not defined in the schema.
  7727. func (m *MessageRecordsMutation) ResetField(name string) error {
  7728. switch name {
  7729. case messagerecords.FieldCreatedAt:
  7730. m.ResetCreatedAt()
  7731. return nil
  7732. case messagerecords.FieldUpdatedAt:
  7733. m.ResetUpdatedAt()
  7734. return nil
  7735. case messagerecords.FieldStatus:
  7736. m.ResetStatus()
  7737. return nil
  7738. case messagerecords.FieldDeletedAt:
  7739. m.ResetDeletedAt()
  7740. return nil
  7741. case messagerecords.FieldBotWxid:
  7742. m.ResetBotWxid()
  7743. return nil
  7744. case messagerecords.FieldContactID:
  7745. m.ResetContactID()
  7746. return nil
  7747. case messagerecords.FieldContactType:
  7748. m.ResetContactType()
  7749. return nil
  7750. case messagerecords.FieldContactWxid:
  7751. m.ResetContactWxid()
  7752. return nil
  7753. case messagerecords.FieldContentType:
  7754. m.ResetContentType()
  7755. return nil
  7756. case messagerecords.FieldContent:
  7757. m.ResetContent()
  7758. return nil
  7759. case messagerecords.FieldMeta:
  7760. m.ResetMeta()
  7761. return nil
  7762. case messagerecords.FieldErrorDetail:
  7763. m.ResetErrorDetail()
  7764. return nil
  7765. case messagerecords.FieldSendTime:
  7766. m.ResetSendTime()
  7767. return nil
  7768. case messagerecords.FieldSourceType:
  7769. m.ResetSourceType()
  7770. return nil
  7771. case messagerecords.FieldSourceID:
  7772. m.ResetSourceID()
  7773. return nil
  7774. case messagerecords.FieldSubSourceID:
  7775. m.ResetSubSourceID()
  7776. return nil
  7777. case messagerecords.FieldOrganizationID:
  7778. m.ResetOrganizationID()
  7779. return nil
  7780. }
  7781. return fmt.Errorf("unknown MessageRecords field %s", name)
  7782. }
  7783. // AddedEdges returns all edge names that were set/added in this mutation.
  7784. func (m *MessageRecordsMutation) AddedEdges() []string {
  7785. edges := make([]string, 0, 3)
  7786. if m.sop_stage != nil {
  7787. edges = append(edges, messagerecords.EdgeSopStage)
  7788. }
  7789. if m.sop_node != nil {
  7790. edges = append(edges, messagerecords.EdgeSopNode)
  7791. }
  7792. if m.message_contact != nil {
  7793. edges = append(edges, messagerecords.EdgeMessageContact)
  7794. }
  7795. return edges
  7796. }
  7797. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7798. // name in this mutation.
  7799. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  7800. switch name {
  7801. case messagerecords.EdgeSopStage:
  7802. if id := m.sop_stage; id != nil {
  7803. return []ent.Value{*id}
  7804. }
  7805. case messagerecords.EdgeSopNode:
  7806. if id := m.sop_node; id != nil {
  7807. return []ent.Value{*id}
  7808. }
  7809. case messagerecords.EdgeMessageContact:
  7810. if id := m.message_contact; id != nil {
  7811. return []ent.Value{*id}
  7812. }
  7813. }
  7814. return nil
  7815. }
  7816. // RemovedEdges returns all edge names that were removed in this mutation.
  7817. func (m *MessageRecordsMutation) RemovedEdges() []string {
  7818. edges := make([]string, 0, 3)
  7819. return edges
  7820. }
  7821. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7822. // the given name in this mutation.
  7823. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  7824. return nil
  7825. }
  7826. // ClearedEdges returns all edge names that were cleared in this mutation.
  7827. func (m *MessageRecordsMutation) ClearedEdges() []string {
  7828. edges := make([]string, 0, 3)
  7829. if m.clearedsop_stage {
  7830. edges = append(edges, messagerecords.EdgeSopStage)
  7831. }
  7832. if m.clearedsop_node {
  7833. edges = append(edges, messagerecords.EdgeSopNode)
  7834. }
  7835. if m.clearedmessage_contact {
  7836. edges = append(edges, messagerecords.EdgeMessageContact)
  7837. }
  7838. return edges
  7839. }
  7840. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7841. // was cleared in this mutation.
  7842. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  7843. switch name {
  7844. case messagerecords.EdgeSopStage:
  7845. return m.clearedsop_stage
  7846. case messagerecords.EdgeSopNode:
  7847. return m.clearedsop_node
  7848. case messagerecords.EdgeMessageContact:
  7849. return m.clearedmessage_contact
  7850. }
  7851. return false
  7852. }
  7853. // ClearEdge clears the value of the edge with the given name. It returns an error
  7854. // if that edge is not defined in the schema.
  7855. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  7856. switch name {
  7857. case messagerecords.EdgeSopStage:
  7858. m.ClearSopStage()
  7859. return nil
  7860. case messagerecords.EdgeSopNode:
  7861. m.ClearSopNode()
  7862. return nil
  7863. case messagerecords.EdgeMessageContact:
  7864. m.ClearMessageContact()
  7865. return nil
  7866. }
  7867. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  7868. }
  7869. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7870. // It returns an error if the edge is not defined in the schema.
  7871. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  7872. switch name {
  7873. case messagerecords.EdgeSopStage:
  7874. m.ResetSopStage()
  7875. return nil
  7876. case messagerecords.EdgeSopNode:
  7877. m.ResetSopNode()
  7878. return nil
  7879. case messagerecords.EdgeMessageContact:
  7880. m.ResetMessageContact()
  7881. return nil
  7882. }
  7883. return fmt.Errorf("unknown MessageRecords edge %s", name)
  7884. }
  7885. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  7886. type MsgMutation struct {
  7887. config
  7888. op Op
  7889. typ string
  7890. id *uint64
  7891. created_at *time.Time
  7892. updated_at *time.Time
  7893. deleted_at *time.Time
  7894. status *uint8
  7895. addstatus *int8
  7896. fromwxid *string
  7897. toid *string
  7898. msgtype *int32
  7899. addmsgtype *int32
  7900. msg *string
  7901. batch_no *string
  7902. clearedFields map[string]struct{}
  7903. done bool
  7904. oldValue func(context.Context) (*Msg, error)
  7905. predicates []predicate.Msg
  7906. }
  7907. var _ ent.Mutation = (*MsgMutation)(nil)
  7908. // msgOption allows management of the mutation configuration using functional options.
  7909. type msgOption func(*MsgMutation)
  7910. // newMsgMutation creates new mutation for the Msg entity.
  7911. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  7912. m := &MsgMutation{
  7913. config: c,
  7914. op: op,
  7915. typ: TypeMsg,
  7916. clearedFields: make(map[string]struct{}),
  7917. }
  7918. for _, opt := range opts {
  7919. opt(m)
  7920. }
  7921. return m
  7922. }
  7923. // withMsgID sets the ID field of the mutation.
  7924. func withMsgID(id uint64) msgOption {
  7925. return func(m *MsgMutation) {
  7926. var (
  7927. err error
  7928. once sync.Once
  7929. value *Msg
  7930. )
  7931. m.oldValue = func(ctx context.Context) (*Msg, error) {
  7932. once.Do(func() {
  7933. if m.done {
  7934. err = errors.New("querying old values post mutation is not allowed")
  7935. } else {
  7936. value, err = m.Client().Msg.Get(ctx, id)
  7937. }
  7938. })
  7939. return value, err
  7940. }
  7941. m.id = &id
  7942. }
  7943. }
  7944. // withMsg sets the old Msg of the mutation.
  7945. func withMsg(node *Msg) msgOption {
  7946. return func(m *MsgMutation) {
  7947. m.oldValue = func(context.Context) (*Msg, error) {
  7948. return node, nil
  7949. }
  7950. m.id = &node.ID
  7951. }
  7952. }
  7953. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7954. // executed in a transaction (ent.Tx), a transactional client is returned.
  7955. func (m MsgMutation) Client() *Client {
  7956. client := &Client{config: m.config}
  7957. client.init()
  7958. return client
  7959. }
  7960. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7961. // it returns an error otherwise.
  7962. func (m MsgMutation) Tx() (*Tx, error) {
  7963. if _, ok := m.driver.(*txDriver); !ok {
  7964. return nil, errors.New("ent: mutation is not running in a transaction")
  7965. }
  7966. tx := &Tx{config: m.config}
  7967. tx.init()
  7968. return tx, nil
  7969. }
  7970. // SetID sets the value of the id field. Note that this
  7971. // operation is only accepted on creation of Msg entities.
  7972. func (m *MsgMutation) SetID(id uint64) {
  7973. m.id = &id
  7974. }
  7975. // ID returns the ID value in the mutation. Note that the ID is only available
  7976. // if it was provided to the builder or after it was returned from the database.
  7977. func (m *MsgMutation) ID() (id uint64, exists bool) {
  7978. if m.id == nil {
  7979. return
  7980. }
  7981. return *m.id, true
  7982. }
  7983. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7984. // That means, if the mutation is applied within a transaction with an isolation level such
  7985. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7986. // or updated by the mutation.
  7987. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  7988. switch {
  7989. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7990. id, exists := m.ID()
  7991. if exists {
  7992. return []uint64{id}, nil
  7993. }
  7994. fallthrough
  7995. case m.op.Is(OpUpdate | OpDelete):
  7996. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  7997. default:
  7998. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7999. }
  8000. }
  8001. // SetCreatedAt sets the "created_at" field.
  8002. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  8003. m.created_at = &t
  8004. }
  8005. // CreatedAt returns the value of the "created_at" field in the mutation.
  8006. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  8007. v := m.created_at
  8008. if v == nil {
  8009. return
  8010. }
  8011. return *v, true
  8012. }
  8013. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  8014. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  8015. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8016. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8017. if !m.op.Is(OpUpdateOne) {
  8018. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8019. }
  8020. if m.id == nil || m.oldValue == nil {
  8021. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8022. }
  8023. oldValue, err := m.oldValue(ctx)
  8024. if err != nil {
  8025. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8026. }
  8027. return oldValue.CreatedAt, nil
  8028. }
  8029. // ResetCreatedAt resets all changes to the "created_at" field.
  8030. func (m *MsgMutation) ResetCreatedAt() {
  8031. m.created_at = nil
  8032. }
  8033. // SetUpdatedAt sets the "updated_at" field.
  8034. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  8035. m.updated_at = &t
  8036. }
  8037. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8038. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  8039. v := m.updated_at
  8040. if v == nil {
  8041. return
  8042. }
  8043. return *v, true
  8044. }
  8045. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  8046. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  8047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8048. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8049. if !m.op.Is(OpUpdateOne) {
  8050. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8051. }
  8052. if m.id == nil || m.oldValue == nil {
  8053. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8054. }
  8055. oldValue, err := m.oldValue(ctx)
  8056. if err != nil {
  8057. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8058. }
  8059. return oldValue.UpdatedAt, nil
  8060. }
  8061. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8062. func (m *MsgMutation) ResetUpdatedAt() {
  8063. m.updated_at = nil
  8064. }
  8065. // SetDeletedAt sets the "deleted_at" field.
  8066. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  8067. m.deleted_at = &t
  8068. }
  8069. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8070. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  8071. v := m.deleted_at
  8072. if v == nil {
  8073. return
  8074. }
  8075. return *v, true
  8076. }
  8077. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  8078. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  8079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8080. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8081. if !m.op.Is(OpUpdateOne) {
  8082. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8083. }
  8084. if m.id == nil || m.oldValue == nil {
  8085. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8086. }
  8087. oldValue, err := m.oldValue(ctx)
  8088. if err != nil {
  8089. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8090. }
  8091. return oldValue.DeletedAt, nil
  8092. }
  8093. // ClearDeletedAt clears the value of the "deleted_at" field.
  8094. func (m *MsgMutation) ClearDeletedAt() {
  8095. m.deleted_at = nil
  8096. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  8097. }
  8098. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8099. func (m *MsgMutation) DeletedAtCleared() bool {
  8100. _, ok := m.clearedFields[msg.FieldDeletedAt]
  8101. return ok
  8102. }
  8103. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8104. func (m *MsgMutation) ResetDeletedAt() {
  8105. m.deleted_at = nil
  8106. delete(m.clearedFields, msg.FieldDeletedAt)
  8107. }
  8108. // SetStatus sets the "status" field.
  8109. func (m *MsgMutation) SetStatus(u uint8) {
  8110. m.status = &u
  8111. m.addstatus = nil
  8112. }
  8113. // Status returns the value of the "status" field in the mutation.
  8114. func (m *MsgMutation) Status() (r uint8, exists bool) {
  8115. v := m.status
  8116. if v == nil {
  8117. return
  8118. }
  8119. return *v, true
  8120. }
  8121. // OldStatus returns the old "status" field's value of the Msg entity.
  8122. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  8123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8124. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  8125. if !m.op.Is(OpUpdateOne) {
  8126. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  8127. }
  8128. if m.id == nil || m.oldValue == nil {
  8129. return v, errors.New("OldStatus requires an ID field in the mutation")
  8130. }
  8131. oldValue, err := m.oldValue(ctx)
  8132. if err != nil {
  8133. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  8134. }
  8135. return oldValue.Status, nil
  8136. }
  8137. // AddStatus adds u to the "status" field.
  8138. func (m *MsgMutation) AddStatus(u int8) {
  8139. if m.addstatus != nil {
  8140. *m.addstatus += u
  8141. } else {
  8142. m.addstatus = &u
  8143. }
  8144. }
  8145. // AddedStatus returns the value that was added to the "status" field in this mutation.
  8146. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  8147. v := m.addstatus
  8148. if v == nil {
  8149. return
  8150. }
  8151. return *v, true
  8152. }
  8153. // ClearStatus clears the value of the "status" field.
  8154. func (m *MsgMutation) ClearStatus() {
  8155. m.status = nil
  8156. m.addstatus = nil
  8157. m.clearedFields[msg.FieldStatus] = struct{}{}
  8158. }
  8159. // StatusCleared returns if the "status" field was cleared in this mutation.
  8160. func (m *MsgMutation) StatusCleared() bool {
  8161. _, ok := m.clearedFields[msg.FieldStatus]
  8162. return ok
  8163. }
  8164. // ResetStatus resets all changes to the "status" field.
  8165. func (m *MsgMutation) ResetStatus() {
  8166. m.status = nil
  8167. m.addstatus = nil
  8168. delete(m.clearedFields, msg.FieldStatus)
  8169. }
  8170. // SetFromwxid sets the "fromwxid" field.
  8171. func (m *MsgMutation) SetFromwxid(s string) {
  8172. m.fromwxid = &s
  8173. }
  8174. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  8175. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  8176. v := m.fromwxid
  8177. if v == nil {
  8178. return
  8179. }
  8180. return *v, true
  8181. }
  8182. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  8183. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  8184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8185. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  8186. if !m.op.Is(OpUpdateOne) {
  8187. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  8188. }
  8189. if m.id == nil || m.oldValue == nil {
  8190. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  8191. }
  8192. oldValue, err := m.oldValue(ctx)
  8193. if err != nil {
  8194. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  8195. }
  8196. return oldValue.Fromwxid, nil
  8197. }
  8198. // ClearFromwxid clears the value of the "fromwxid" field.
  8199. func (m *MsgMutation) ClearFromwxid() {
  8200. m.fromwxid = nil
  8201. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  8202. }
  8203. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  8204. func (m *MsgMutation) FromwxidCleared() bool {
  8205. _, ok := m.clearedFields[msg.FieldFromwxid]
  8206. return ok
  8207. }
  8208. // ResetFromwxid resets all changes to the "fromwxid" field.
  8209. func (m *MsgMutation) ResetFromwxid() {
  8210. m.fromwxid = nil
  8211. delete(m.clearedFields, msg.FieldFromwxid)
  8212. }
  8213. // SetToid sets the "toid" field.
  8214. func (m *MsgMutation) SetToid(s string) {
  8215. m.toid = &s
  8216. }
  8217. // Toid returns the value of the "toid" field in the mutation.
  8218. func (m *MsgMutation) Toid() (r string, exists bool) {
  8219. v := m.toid
  8220. if v == nil {
  8221. return
  8222. }
  8223. return *v, true
  8224. }
  8225. // OldToid returns the old "toid" field's value of the Msg entity.
  8226. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  8227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8228. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  8229. if !m.op.Is(OpUpdateOne) {
  8230. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  8231. }
  8232. if m.id == nil || m.oldValue == nil {
  8233. return v, errors.New("OldToid requires an ID field in the mutation")
  8234. }
  8235. oldValue, err := m.oldValue(ctx)
  8236. if err != nil {
  8237. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  8238. }
  8239. return oldValue.Toid, nil
  8240. }
  8241. // ClearToid clears the value of the "toid" field.
  8242. func (m *MsgMutation) ClearToid() {
  8243. m.toid = nil
  8244. m.clearedFields[msg.FieldToid] = struct{}{}
  8245. }
  8246. // ToidCleared returns if the "toid" field was cleared in this mutation.
  8247. func (m *MsgMutation) ToidCleared() bool {
  8248. _, ok := m.clearedFields[msg.FieldToid]
  8249. return ok
  8250. }
  8251. // ResetToid resets all changes to the "toid" field.
  8252. func (m *MsgMutation) ResetToid() {
  8253. m.toid = nil
  8254. delete(m.clearedFields, msg.FieldToid)
  8255. }
  8256. // SetMsgtype sets the "msgtype" field.
  8257. func (m *MsgMutation) SetMsgtype(i int32) {
  8258. m.msgtype = &i
  8259. m.addmsgtype = nil
  8260. }
  8261. // Msgtype returns the value of the "msgtype" field in the mutation.
  8262. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  8263. v := m.msgtype
  8264. if v == nil {
  8265. return
  8266. }
  8267. return *v, true
  8268. }
  8269. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  8270. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  8271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8272. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  8273. if !m.op.Is(OpUpdateOne) {
  8274. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  8275. }
  8276. if m.id == nil || m.oldValue == nil {
  8277. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  8278. }
  8279. oldValue, err := m.oldValue(ctx)
  8280. if err != nil {
  8281. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  8282. }
  8283. return oldValue.Msgtype, nil
  8284. }
  8285. // AddMsgtype adds i to the "msgtype" field.
  8286. func (m *MsgMutation) AddMsgtype(i int32) {
  8287. if m.addmsgtype != nil {
  8288. *m.addmsgtype += i
  8289. } else {
  8290. m.addmsgtype = &i
  8291. }
  8292. }
  8293. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  8294. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  8295. v := m.addmsgtype
  8296. if v == nil {
  8297. return
  8298. }
  8299. return *v, true
  8300. }
  8301. // ClearMsgtype clears the value of the "msgtype" field.
  8302. func (m *MsgMutation) ClearMsgtype() {
  8303. m.msgtype = nil
  8304. m.addmsgtype = nil
  8305. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  8306. }
  8307. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  8308. func (m *MsgMutation) MsgtypeCleared() bool {
  8309. _, ok := m.clearedFields[msg.FieldMsgtype]
  8310. return ok
  8311. }
  8312. // ResetMsgtype resets all changes to the "msgtype" field.
  8313. func (m *MsgMutation) ResetMsgtype() {
  8314. m.msgtype = nil
  8315. m.addmsgtype = nil
  8316. delete(m.clearedFields, msg.FieldMsgtype)
  8317. }
  8318. // SetMsg sets the "msg" field.
  8319. func (m *MsgMutation) SetMsg(s string) {
  8320. m.msg = &s
  8321. }
  8322. // Msg returns the value of the "msg" field in the mutation.
  8323. func (m *MsgMutation) Msg() (r string, exists bool) {
  8324. v := m.msg
  8325. if v == nil {
  8326. return
  8327. }
  8328. return *v, true
  8329. }
  8330. // OldMsg returns the old "msg" field's value of the Msg entity.
  8331. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  8332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8333. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  8334. if !m.op.Is(OpUpdateOne) {
  8335. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  8336. }
  8337. if m.id == nil || m.oldValue == nil {
  8338. return v, errors.New("OldMsg requires an ID field in the mutation")
  8339. }
  8340. oldValue, err := m.oldValue(ctx)
  8341. if err != nil {
  8342. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  8343. }
  8344. return oldValue.Msg, nil
  8345. }
  8346. // ClearMsg clears the value of the "msg" field.
  8347. func (m *MsgMutation) ClearMsg() {
  8348. m.msg = nil
  8349. m.clearedFields[msg.FieldMsg] = struct{}{}
  8350. }
  8351. // MsgCleared returns if the "msg" field was cleared in this mutation.
  8352. func (m *MsgMutation) MsgCleared() bool {
  8353. _, ok := m.clearedFields[msg.FieldMsg]
  8354. return ok
  8355. }
  8356. // ResetMsg resets all changes to the "msg" field.
  8357. func (m *MsgMutation) ResetMsg() {
  8358. m.msg = nil
  8359. delete(m.clearedFields, msg.FieldMsg)
  8360. }
  8361. // SetBatchNo sets the "batch_no" field.
  8362. func (m *MsgMutation) SetBatchNo(s string) {
  8363. m.batch_no = &s
  8364. }
  8365. // BatchNo returns the value of the "batch_no" field in the mutation.
  8366. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  8367. v := m.batch_no
  8368. if v == nil {
  8369. return
  8370. }
  8371. return *v, true
  8372. }
  8373. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  8374. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  8375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8376. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  8377. if !m.op.Is(OpUpdateOne) {
  8378. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  8379. }
  8380. if m.id == nil || m.oldValue == nil {
  8381. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  8382. }
  8383. oldValue, err := m.oldValue(ctx)
  8384. if err != nil {
  8385. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  8386. }
  8387. return oldValue.BatchNo, nil
  8388. }
  8389. // ClearBatchNo clears the value of the "batch_no" field.
  8390. func (m *MsgMutation) ClearBatchNo() {
  8391. m.batch_no = nil
  8392. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  8393. }
  8394. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  8395. func (m *MsgMutation) BatchNoCleared() bool {
  8396. _, ok := m.clearedFields[msg.FieldBatchNo]
  8397. return ok
  8398. }
  8399. // ResetBatchNo resets all changes to the "batch_no" field.
  8400. func (m *MsgMutation) ResetBatchNo() {
  8401. m.batch_no = nil
  8402. delete(m.clearedFields, msg.FieldBatchNo)
  8403. }
  8404. // Where appends a list predicates to the MsgMutation builder.
  8405. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  8406. m.predicates = append(m.predicates, ps...)
  8407. }
  8408. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  8409. // users can use type-assertion to append predicates that do not depend on any generated package.
  8410. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  8411. p := make([]predicate.Msg, len(ps))
  8412. for i := range ps {
  8413. p[i] = ps[i]
  8414. }
  8415. m.Where(p...)
  8416. }
  8417. // Op returns the operation name.
  8418. func (m *MsgMutation) Op() Op {
  8419. return m.op
  8420. }
  8421. // SetOp allows setting the mutation operation.
  8422. func (m *MsgMutation) SetOp(op Op) {
  8423. m.op = op
  8424. }
  8425. // Type returns the node type of this mutation (Msg).
  8426. func (m *MsgMutation) Type() string {
  8427. return m.typ
  8428. }
  8429. // Fields returns all fields that were changed during this mutation. Note that in
  8430. // order to get all numeric fields that were incremented/decremented, call
  8431. // AddedFields().
  8432. func (m *MsgMutation) Fields() []string {
  8433. fields := make([]string, 0, 9)
  8434. if m.created_at != nil {
  8435. fields = append(fields, msg.FieldCreatedAt)
  8436. }
  8437. if m.updated_at != nil {
  8438. fields = append(fields, msg.FieldUpdatedAt)
  8439. }
  8440. if m.deleted_at != nil {
  8441. fields = append(fields, msg.FieldDeletedAt)
  8442. }
  8443. if m.status != nil {
  8444. fields = append(fields, msg.FieldStatus)
  8445. }
  8446. if m.fromwxid != nil {
  8447. fields = append(fields, msg.FieldFromwxid)
  8448. }
  8449. if m.toid != nil {
  8450. fields = append(fields, msg.FieldToid)
  8451. }
  8452. if m.msgtype != nil {
  8453. fields = append(fields, msg.FieldMsgtype)
  8454. }
  8455. if m.msg != nil {
  8456. fields = append(fields, msg.FieldMsg)
  8457. }
  8458. if m.batch_no != nil {
  8459. fields = append(fields, msg.FieldBatchNo)
  8460. }
  8461. return fields
  8462. }
  8463. // Field returns the value of a field with the given name. The second boolean
  8464. // return value indicates that this field was not set, or was not defined in the
  8465. // schema.
  8466. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  8467. switch name {
  8468. case msg.FieldCreatedAt:
  8469. return m.CreatedAt()
  8470. case msg.FieldUpdatedAt:
  8471. return m.UpdatedAt()
  8472. case msg.FieldDeletedAt:
  8473. return m.DeletedAt()
  8474. case msg.FieldStatus:
  8475. return m.Status()
  8476. case msg.FieldFromwxid:
  8477. return m.Fromwxid()
  8478. case msg.FieldToid:
  8479. return m.Toid()
  8480. case msg.FieldMsgtype:
  8481. return m.Msgtype()
  8482. case msg.FieldMsg:
  8483. return m.Msg()
  8484. case msg.FieldBatchNo:
  8485. return m.BatchNo()
  8486. }
  8487. return nil, false
  8488. }
  8489. // OldField returns the old value of the field from the database. An error is
  8490. // returned if the mutation operation is not UpdateOne, or the query to the
  8491. // database failed.
  8492. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8493. switch name {
  8494. case msg.FieldCreatedAt:
  8495. return m.OldCreatedAt(ctx)
  8496. case msg.FieldUpdatedAt:
  8497. return m.OldUpdatedAt(ctx)
  8498. case msg.FieldDeletedAt:
  8499. return m.OldDeletedAt(ctx)
  8500. case msg.FieldStatus:
  8501. return m.OldStatus(ctx)
  8502. case msg.FieldFromwxid:
  8503. return m.OldFromwxid(ctx)
  8504. case msg.FieldToid:
  8505. return m.OldToid(ctx)
  8506. case msg.FieldMsgtype:
  8507. return m.OldMsgtype(ctx)
  8508. case msg.FieldMsg:
  8509. return m.OldMsg(ctx)
  8510. case msg.FieldBatchNo:
  8511. return m.OldBatchNo(ctx)
  8512. }
  8513. return nil, fmt.Errorf("unknown Msg field %s", name)
  8514. }
  8515. // SetField sets the value of a field with the given name. It returns an error if
  8516. // the field is not defined in the schema, or if the type mismatched the field
  8517. // type.
  8518. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  8519. switch name {
  8520. case msg.FieldCreatedAt:
  8521. v, ok := value.(time.Time)
  8522. if !ok {
  8523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8524. }
  8525. m.SetCreatedAt(v)
  8526. return nil
  8527. case msg.FieldUpdatedAt:
  8528. v, ok := value.(time.Time)
  8529. if !ok {
  8530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8531. }
  8532. m.SetUpdatedAt(v)
  8533. return nil
  8534. case msg.FieldDeletedAt:
  8535. v, ok := value.(time.Time)
  8536. if !ok {
  8537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8538. }
  8539. m.SetDeletedAt(v)
  8540. return nil
  8541. case msg.FieldStatus:
  8542. v, ok := value.(uint8)
  8543. if !ok {
  8544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8545. }
  8546. m.SetStatus(v)
  8547. return nil
  8548. case msg.FieldFromwxid:
  8549. v, ok := value.(string)
  8550. if !ok {
  8551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8552. }
  8553. m.SetFromwxid(v)
  8554. return nil
  8555. case msg.FieldToid:
  8556. v, ok := value.(string)
  8557. if !ok {
  8558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8559. }
  8560. m.SetToid(v)
  8561. return nil
  8562. case msg.FieldMsgtype:
  8563. v, ok := value.(int32)
  8564. if !ok {
  8565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8566. }
  8567. m.SetMsgtype(v)
  8568. return nil
  8569. case msg.FieldMsg:
  8570. v, ok := value.(string)
  8571. if !ok {
  8572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8573. }
  8574. m.SetMsg(v)
  8575. return nil
  8576. case msg.FieldBatchNo:
  8577. v, ok := value.(string)
  8578. if !ok {
  8579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8580. }
  8581. m.SetBatchNo(v)
  8582. return nil
  8583. }
  8584. return fmt.Errorf("unknown Msg field %s", name)
  8585. }
  8586. // AddedFields returns all numeric fields that were incremented/decremented during
  8587. // this mutation.
  8588. func (m *MsgMutation) AddedFields() []string {
  8589. var fields []string
  8590. if m.addstatus != nil {
  8591. fields = append(fields, msg.FieldStatus)
  8592. }
  8593. if m.addmsgtype != nil {
  8594. fields = append(fields, msg.FieldMsgtype)
  8595. }
  8596. return fields
  8597. }
  8598. // AddedField returns the numeric value that was incremented/decremented on a field
  8599. // with the given name. The second boolean return value indicates that this field
  8600. // was not set, or was not defined in the schema.
  8601. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  8602. switch name {
  8603. case msg.FieldStatus:
  8604. return m.AddedStatus()
  8605. case msg.FieldMsgtype:
  8606. return m.AddedMsgtype()
  8607. }
  8608. return nil, false
  8609. }
  8610. // AddField adds the value to the field with the given name. It returns an error if
  8611. // the field is not defined in the schema, or if the type mismatched the field
  8612. // type.
  8613. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  8614. switch name {
  8615. case msg.FieldStatus:
  8616. v, ok := value.(int8)
  8617. if !ok {
  8618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8619. }
  8620. m.AddStatus(v)
  8621. return nil
  8622. case msg.FieldMsgtype:
  8623. v, ok := value.(int32)
  8624. if !ok {
  8625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8626. }
  8627. m.AddMsgtype(v)
  8628. return nil
  8629. }
  8630. return fmt.Errorf("unknown Msg numeric field %s", name)
  8631. }
  8632. // ClearedFields returns all nullable fields that were cleared during this
  8633. // mutation.
  8634. func (m *MsgMutation) ClearedFields() []string {
  8635. var fields []string
  8636. if m.FieldCleared(msg.FieldDeletedAt) {
  8637. fields = append(fields, msg.FieldDeletedAt)
  8638. }
  8639. if m.FieldCleared(msg.FieldStatus) {
  8640. fields = append(fields, msg.FieldStatus)
  8641. }
  8642. if m.FieldCleared(msg.FieldFromwxid) {
  8643. fields = append(fields, msg.FieldFromwxid)
  8644. }
  8645. if m.FieldCleared(msg.FieldToid) {
  8646. fields = append(fields, msg.FieldToid)
  8647. }
  8648. if m.FieldCleared(msg.FieldMsgtype) {
  8649. fields = append(fields, msg.FieldMsgtype)
  8650. }
  8651. if m.FieldCleared(msg.FieldMsg) {
  8652. fields = append(fields, msg.FieldMsg)
  8653. }
  8654. if m.FieldCleared(msg.FieldBatchNo) {
  8655. fields = append(fields, msg.FieldBatchNo)
  8656. }
  8657. return fields
  8658. }
  8659. // FieldCleared returns a boolean indicating if a field with the given name was
  8660. // cleared in this mutation.
  8661. func (m *MsgMutation) FieldCleared(name string) bool {
  8662. _, ok := m.clearedFields[name]
  8663. return ok
  8664. }
  8665. // ClearField clears the value of the field with the given name. It returns an
  8666. // error if the field is not defined in the schema.
  8667. func (m *MsgMutation) ClearField(name string) error {
  8668. switch name {
  8669. case msg.FieldDeletedAt:
  8670. m.ClearDeletedAt()
  8671. return nil
  8672. case msg.FieldStatus:
  8673. m.ClearStatus()
  8674. return nil
  8675. case msg.FieldFromwxid:
  8676. m.ClearFromwxid()
  8677. return nil
  8678. case msg.FieldToid:
  8679. m.ClearToid()
  8680. return nil
  8681. case msg.FieldMsgtype:
  8682. m.ClearMsgtype()
  8683. return nil
  8684. case msg.FieldMsg:
  8685. m.ClearMsg()
  8686. return nil
  8687. case msg.FieldBatchNo:
  8688. m.ClearBatchNo()
  8689. return nil
  8690. }
  8691. return fmt.Errorf("unknown Msg nullable field %s", name)
  8692. }
  8693. // ResetField resets all changes in the mutation for the field with the given name.
  8694. // It returns an error if the field is not defined in the schema.
  8695. func (m *MsgMutation) ResetField(name string) error {
  8696. switch name {
  8697. case msg.FieldCreatedAt:
  8698. m.ResetCreatedAt()
  8699. return nil
  8700. case msg.FieldUpdatedAt:
  8701. m.ResetUpdatedAt()
  8702. return nil
  8703. case msg.FieldDeletedAt:
  8704. m.ResetDeletedAt()
  8705. return nil
  8706. case msg.FieldStatus:
  8707. m.ResetStatus()
  8708. return nil
  8709. case msg.FieldFromwxid:
  8710. m.ResetFromwxid()
  8711. return nil
  8712. case msg.FieldToid:
  8713. m.ResetToid()
  8714. return nil
  8715. case msg.FieldMsgtype:
  8716. m.ResetMsgtype()
  8717. return nil
  8718. case msg.FieldMsg:
  8719. m.ResetMsg()
  8720. return nil
  8721. case msg.FieldBatchNo:
  8722. m.ResetBatchNo()
  8723. return nil
  8724. }
  8725. return fmt.Errorf("unknown Msg field %s", name)
  8726. }
  8727. // AddedEdges returns all edge names that were set/added in this mutation.
  8728. func (m *MsgMutation) AddedEdges() []string {
  8729. edges := make([]string, 0, 0)
  8730. return edges
  8731. }
  8732. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8733. // name in this mutation.
  8734. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  8735. return nil
  8736. }
  8737. // RemovedEdges returns all edge names that were removed in this mutation.
  8738. func (m *MsgMutation) RemovedEdges() []string {
  8739. edges := make([]string, 0, 0)
  8740. return edges
  8741. }
  8742. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8743. // the given name in this mutation.
  8744. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  8745. return nil
  8746. }
  8747. // ClearedEdges returns all edge names that were cleared in this mutation.
  8748. func (m *MsgMutation) ClearedEdges() []string {
  8749. edges := make([]string, 0, 0)
  8750. return edges
  8751. }
  8752. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8753. // was cleared in this mutation.
  8754. func (m *MsgMutation) EdgeCleared(name string) bool {
  8755. return false
  8756. }
  8757. // ClearEdge clears the value of the edge with the given name. It returns an error
  8758. // if that edge is not defined in the schema.
  8759. func (m *MsgMutation) ClearEdge(name string) error {
  8760. return fmt.Errorf("unknown Msg unique edge %s", name)
  8761. }
  8762. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8763. // It returns an error if the edge is not defined in the schema.
  8764. func (m *MsgMutation) ResetEdge(name string) error {
  8765. return fmt.Errorf("unknown Msg edge %s", name)
  8766. }
  8767. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  8768. type ServerMutation struct {
  8769. config
  8770. op Op
  8771. typ string
  8772. id *uint64
  8773. created_at *time.Time
  8774. updated_at *time.Time
  8775. status *uint8
  8776. addstatus *int8
  8777. deleted_at *time.Time
  8778. name *string
  8779. public_ip *string
  8780. private_ip *string
  8781. admin_port *string
  8782. clearedFields map[string]struct{}
  8783. wxs map[uint64]struct{}
  8784. removedwxs map[uint64]struct{}
  8785. clearedwxs bool
  8786. done bool
  8787. oldValue func(context.Context) (*Server, error)
  8788. predicates []predicate.Server
  8789. }
  8790. var _ ent.Mutation = (*ServerMutation)(nil)
  8791. // serverOption allows management of the mutation configuration using functional options.
  8792. type serverOption func(*ServerMutation)
  8793. // newServerMutation creates new mutation for the Server entity.
  8794. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  8795. m := &ServerMutation{
  8796. config: c,
  8797. op: op,
  8798. typ: TypeServer,
  8799. clearedFields: make(map[string]struct{}),
  8800. }
  8801. for _, opt := range opts {
  8802. opt(m)
  8803. }
  8804. return m
  8805. }
  8806. // withServerID sets the ID field of the mutation.
  8807. func withServerID(id uint64) serverOption {
  8808. return func(m *ServerMutation) {
  8809. var (
  8810. err error
  8811. once sync.Once
  8812. value *Server
  8813. )
  8814. m.oldValue = func(ctx context.Context) (*Server, error) {
  8815. once.Do(func() {
  8816. if m.done {
  8817. err = errors.New("querying old values post mutation is not allowed")
  8818. } else {
  8819. value, err = m.Client().Server.Get(ctx, id)
  8820. }
  8821. })
  8822. return value, err
  8823. }
  8824. m.id = &id
  8825. }
  8826. }
  8827. // withServer sets the old Server of the mutation.
  8828. func withServer(node *Server) serverOption {
  8829. return func(m *ServerMutation) {
  8830. m.oldValue = func(context.Context) (*Server, error) {
  8831. return node, nil
  8832. }
  8833. m.id = &node.ID
  8834. }
  8835. }
  8836. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8837. // executed in a transaction (ent.Tx), a transactional client is returned.
  8838. func (m ServerMutation) Client() *Client {
  8839. client := &Client{config: m.config}
  8840. client.init()
  8841. return client
  8842. }
  8843. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8844. // it returns an error otherwise.
  8845. func (m ServerMutation) Tx() (*Tx, error) {
  8846. if _, ok := m.driver.(*txDriver); !ok {
  8847. return nil, errors.New("ent: mutation is not running in a transaction")
  8848. }
  8849. tx := &Tx{config: m.config}
  8850. tx.init()
  8851. return tx, nil
  8852. }
  8853. // SetID sets the value of the id field. Note that this
  8854. // operation is only accepted on creation of Server entities.
  8855. func (m *ServerMutation) SetID(id uint64) {
  8856. m.id = &id
  8857. }
  8858. // ID returns the ID value in the mutation. Note that the ID is only available
  8859. // if it was provided to the builder or after it was returned from the database.
  8860. func (m *ServerMutation) ID() (id uint64, exists bool) {
  8861. if m.id == nil {
  8862. return
  8863. }
  8864. return *m.id, true
  8865. }
  8866. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8867. // That means, if the mutation is applied within a transaction with an isolation level such
  8868. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8869. // or updated by the mutation.
  8870. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  8871. switch {
  8872. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8873. id, exists := m.ID()
  8874. if exists {
  8875. return []uint64{id}, nil
  8876. }
  8877. fallthrough
  8878. case m.op.Is(OpUpdate | OpDelete):
  8879. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  8880. default:
  8881. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8882. }
  8883. }
  8884. // SetCreatedAt sets the "created_at" field.
  8885. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  8886. m.created_at = &t
  8887. }
  8888. // CreatedAt returns the value of the "created_at" field in the mutation.
  8889. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  8890. v := m.created_at
  8891. if v == nil {
  8892. return
  8893. }
  8894. return *v, true
  8895. }
  8896. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  8897. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8898. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8899. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8900. if !m.op.Is(OpUpdateOne) {
  8901. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8902. }
  8903. if m.id == nil || m.oldValue == nil {
  8904. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8905. }
  8906. oldValue, err := m.oldValue(ctx)
  8907. if err != nil {
  8908. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8909. }
  8910. return oldValue.CreatedAt, nil
  8911. }
  8912. // ResetCreatedAt resets all changes to the "created_at" field.
  8913. func (m *ServerMutation) ResetCreatedAt() {
  8914. m.created_at = nil
  8915. }
  8916. // SetUpdatedAt sets the "updated_at" field.
  8917. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  8918. m.updated_at = &t
  8919. }
  8920. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8921. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  8922. v := m.updated_at
  8923. if v == nil {
  8924. return
  8925. }
  8926. return *v, true
  8927. }
  8928. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  8929. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8931. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8932. if !m.op.Is(OpUpdateOne) {
  8933. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8934. }
  8935. if m.id == nil || m.oldValue == nil {
  8936. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8937. }
  8938. oldValue, err := m.oldValue(ctx)
  8939. if err != nil {
  8940. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8941. }
  8942. return oldValue.UpdatedAt, nil
  8943. }
  8944. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8945. func (m *ServerMutation) ResetUpdatedAt() {
  8946. m.updated_at = nil
  8947. }
  8948. // SetStatus sets the "status" field.
  8949. func (m *ServerMutation) SetStatus(u uint8) {
  8950. m.status = &u
  8951. m.addstatus = nil
  8952. }
  8953. // Status returns the value of the "status" field in the mutation.
  8954. func (m *ServerMutation) Status() (r uint8, exists bool) {
  8955. v := m.status
  8956. if v == nil {
  8957. return
  8958. }
  8959. return *v, true
  8960. }
  8961. // OldStatus returns the old "status" field's value of the Server entity.
  8962. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8964. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  8965. if !m.op.Is(OpUpdateOne) {
  8966. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  8967. }
  8968. if m.id == nil || m.oldValue == nil {
  8969. return v, errors.New("OldStatus requires an ID field in the mutation")
  8970. }
  8971. oldValue, err := m.oldValue(ctx)
  8972. if err != nil {
  8973. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  8974. }
  8975. return oldValue.Status, nil
  8976. }
  8977. // AddStatus adds u to the "status" field.
  8978. func (m *ServerMutation) AddStatus(u int8) {
  8979. if m.addstatus != nil {
  8980. *m.addstatus += u
  8981. } else {
  8982. m.addstatus = &u
  8983. }
  8984. }
  8985. // AddedStatus returns the value that was added to the "status" field in this mutation.
  8986. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  8987. v := m.addstatus
  8988. if v == nil {
  8989. return
  8990. }
  8991. return *v, true
  8992. }
  8993. // ClearStatus clears the value of the "status" field.
  8994. func (m *ServerMutation) ClearStatus() {
  8995. m.status = nil
  8996. m.addstatus = nil
  8997. m.clearedFields[server.FieldStatus] = struct{}{}
  8998. }
  8999. // StatusCleared returns if the "status" field was cleared in this mutation.
  9000. func (m *ServerMutation) StatusCleared() bool {
  9001. _, ok := m.clearedFields[server.FieldStatus]
  9002. return ok
  9003. }
  9004. // ResetStatus resets all changes to the "status" field.
  9005. func (m *ServerMutation) ResetStatus() {
  9006. m.status = nil
  9007. m.addstatus = nil
  9008. delete(m.clearedFields, server.FieldStatus)
  9009. }
  9010. // SetDeletedAt sets the "deleted_at" field.
  9011. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  9012. m.deleted_at = &t
  9013. }
  9014. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9015. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  9016. v := m.deleted_at
  9017. if v == nil {
  9018. return
  9019. }
  9020. return *v, true
  9021. }
  9022. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  9023. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  9024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9025. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9026. if !m.op.Is(OpUpdateOne) {
  9027. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9028. }
  9029. if m.id == nil || m.oldValue == nil {
  9030. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9031. }
  9032. oldValue, err := m.oldValue(ctx)
  9033. if err != nil {
  9034. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9035. }
  9036. return oldValue.DeletedAt, nil
  9037. }
  9038. // ClearDeletedAt clears the value of the "deleted_at" field.
  9039. func (m *ServerMutation) ClearDeletedAt() {
  9040. m.deleted_at = nil
  9041. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  9042. }
  9043. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9044. func (m *ServerMutation) DeletedAtCleared() bool {
  9045. _, ok := m.clearedFields[server.FieldDeletedAt]
  9046. return ok
  9047. }
  9048. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9049. func (m *ServerMutation) ResetDeletedAt() {
  9050. m.deleted_at = nil
  9051. delete(m.clearedFields, server.FieldDeletedAt)
  9052. }
  9053. // SetName sets the "name" field.
  9054. func (m *ServerMutation) SetName(s string) {
  9055. m.name = &s
  9056. }
  9057. // Name returns the value of the "name" field in the mutation.
  9058. func (m *ServerMutation) Name() (r string, exists bool) {
  9059. v := m.name
  9060. if v == nil {
  9061. return
  9062. }
  9063. return *v, true
  9064. }
  9065. // OldName returns the old "name" field's value of the Server entity.
  9066. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  9067. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9068. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  9069. if !m.op.Is(OpUpdateOne) {
  9070. return v, errors.New("OldName is only allowed on UpdateOne operations")
  9071. }
  9072. if m.id == nil || m.oldValue == nil {
  9073. return v, errors.New("OldName requires an ID field in the mutation")
  9074. }
  9075. oldValue, err := m.oldValue(ctx)
  9076. if err != nil {
  9077. return v, fmt.Errorf("querying old value for OldName: %w", err)
  9078. }
  9079. return oldValue.Name, nil
  9080. }
  9081. // ResetName resets all changes to the "name" field.
  9082. func (m *ServerMutation) ResetName() {
  9083. m.name = nil
  9084. }
  9085. // SetPublicIP sets the "public_ip" field.
  9086. func (m *ServerMutation) SetPublicIP(s string) {
  9087. m.public_ip = &s
  9088. }
  9089. // PublicIP returns the value of the "public_ip" field in the mutation.
  9090. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  9091. v := m.public_ip
  9092. if v == nil {
  9093. return
  9094. }
  9095. return *v, true
  9096. }
  9097. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  9098. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  9099. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9100. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  9101. if !m.op.Is(OpUpdateOne) {
  9102. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  9103. }
  9104. if m.id == nil || m.oldValue == nil {
  9105. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  9106. }
  9107. oldValue, err := m.oldValue(ctx)
  9108. if err != nil {
  9109. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  9110. }
  9111. return oldValue.PublicIP, nil
  9112. }
  9113. // ResetPublicIP resets all changes to the "public_ip" field.
  9114. func (m *ServerMutation) ResetPublicIP() {
  9115. m.public_ip = nil
  9116. }
  9117. // SetPrivateIP sets the "private_ip" field.
  9118. func (m *ServerMutation) SetPrivateIP(s string) {
  9119. m.private_ip = &s
  9120. }
  9121. // PrivateIP returns the value of the "private_ip" field in the mutation.
  9122. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  9123. v := m.private_ip
  9124. if v == nil {
  9125. return
  9126. }
  9127. return *v, true
  9128. }
  9129. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  9130. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  9131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9132. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  9133. if !m.op.Is(OpUpdateOne) {
  9134. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  9135. }
  9136. if m.id == nil || m.oldValue == nil {
  9137. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  9138. }
  9139. oldValue, err := m.oldValue(ctx)
  9140. if err != nil {
  9141. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  9142. }
  9143. return oldValue.PrivateIP, nil
  9144. }
  9145. // ResetPrivateIP resets all changes to the "private_ip" field.
  9146. func (m *ServerMutation) ResetPrivateIP() {
  9147. m.private_ip = nil
  9148. }
  9149. // SetAdminPort sets the "admin_port" field.
  9150. func (m *ServerMutation) SetAdminPort(s string) {
  9151. m.admin_port = &s
  9152. }
  9153. // AdminPort returns the value of the "admin_port" field in the mutation.
  9154. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  9155. v := m.admin_port
  9156. if v == nil {
  9157. return
  9158. }
  9159. return *v, true
  9160. }
  9161. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  9162. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  9163. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9164. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  9165. if !m.op.Is(OpUpdateOne) {
  9166. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  9167. }
  9168. if m.id == nil || m.oldValue == nil {
  9169. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  9170. }
  9171. oldValue, err := m.oldValue(ctx)
  9172. if err != nil {
  9173. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  9174. }
  9175. return oldValue.AdminPort, nil
  9176. }
  9177. // ResetAdminPort resets all changes to the "admin_port" field.
  9178. func (m *ServerMutation) ResetAdminPort() {
  9179. m.admin_port = nil
  9180. }
  9181. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  9182. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  9183. if m.wxs == nil {
  9184. m.wxs = make(map[uint64]struct{})
  9185. }
  9186. for i := range ids {
  9187. m.wxs[ids[i]] = struct{}{}
  9188. }
  9189. }
  9190. // ClearWxs clears the "wxs" edge to the Wx entity.
  9191. func (m *ServerMutation) ClearWxs() {
  9192. m.clearedwxs = true
  9193. }
  9194. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  9195. func (m *ServerMutation) WxsCleared() bool {
  9196. return m.clearedwxs
  9197. }
  9198. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  9199. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  9200. if m.removedwxs == nil {
  9201. m.removedwxs = make(map[uint64]struct{})
  9202. }
  9203. for i := range ids {
  9204. delete(m.wxs, ids[i])
  9205. m.removedwxs[ids[i]] = struct{}{}
  9206. }
  9207. }
  9208. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  9209. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  9210. for id := range m.removedwxs {
  9211. ids = append(ids, id)
  9212. }
  9213. return
  9214. }
  9215. // WxsIDs returns the "wxs" edge IDs in the mutation.
  9216. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  9217. for id := range m.wxs {
  9218. ids = append(ids, id)
  9219. }
  9220. return
  9221. }
  9222. // ResetWxs resets all changes to the "wxs" edge.
  9223. func (m *ServerMutation) ResetWxs() {
  9224. m.wxs = nil
  9225. m.clearedwxs = false
  9226. m.removedwxs = nil
  9227. }
  9228. // Where appends a list predicates to the ServerMutation builder.
  9229. func (m *ServerMutation) Where(ps ...predicate.Server) {
  9230. m.predicates = append(m.predicates, ps...)
  9231. }
  9232. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  9233. // users can use type-assertion to append predicates that do not depend on any generated package.
  9234. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  9235. p := make([]predicate.Server, len(ps))
  9236. for i := range ps {
  9237. p[i] = ps[i]
  9238. }
  9239. m.Where(p...)
  9240. }
  9241. // Op returns the operation name.
  9242. func (m *ServerMutation) Op() Op {
  9243. return m.op
  9244. }
  9245. // SetOp allows setting the mutation operation.
  9246. func (m *ServerMutation) SetOp(op Op) {
  9247. m.op = op
  9248. }
  9249. // Type returns the node type of this mutation (Server).
  9250. func (m *ServerMutation) Type() string {
  9251. return m.typ
  9252. }
  9253. // Fields returns all fields that were changed during this mutation. Note that in
  9254. // order to get all numeric fields that were incremented/decremented, call
  9255. // AddedFields().
  9256. func (m *ServerMutation) Fields() []string {
  9257. fields := make([]string, 0, 8)
  9258. if m.created_at != nil {
  9259. fields = append(fields, server.FieldCreatedAt)
  9260. }
  9261. if m.updated_at != nil {
  9262. fields = append(fields, server.FieldUpdatedAt)
  9263. }
  9264. if m.status != nil {
  9265. fields = append(fields, server.FieldStatus)
  9266. }
  9267. if m.deleted_at != nil {
  9268. fields = append(fields, server.FieldDeletedAt)
  9269. }
  9270. if m.name != nil {
  9271. fields = append(fields, server.FieldName)
  9272. }
  9273. if m.public_ip != nil {
  9274. fields = append(fields, server.FieldPublicIP)
  9275. }
  9276. if m.private_ip != nil {
  9277. fields = append(fields, server.FieldPrivateIP)
  9278. }
  9279. if m.admin_port != nil {
  9280. fields = append(fields, server.FieldAdminPort)
  9281. }
  9282. return fields
  9283. }
  9284. // Field returns the value of a field with the given name. The second boolean
  9285. // return value indicates that this field was not set, or was not defined in the
  9286. // schema.
  9287. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  9288. switch name {
  9289. case server.FieldCreatedAt:
  9290. return m.CreatedAt()
  9291. case server.FieldUpdatedAt:
  9292. return m.UpdatedAt()
  9293. case server.FieldStatus:
  9294. return m.Status()
  9295. case server.FieldDeletedAt:
  9296. return m.DeletedAt()
  9297. case server.FieldName:
  9298. return m.Name()
  9299. case server.FieldPublicIP:
  9300. return m.PublicIP()
  9301. case server.FieldPrivateIP:
  9302. return m.PrivateIP()
  9303. case server.FieldAdminPort:
  9304. return m.AdminPort()
  9305. }
  9306. return nil, false
  9307. }
  9308. // OldField returns the old value of the field from the database. An error is
  9309. // returned if the mutation operation is not UpdateOne, or the query to the
  9310. // database failed.
  9311. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9312. switch name {
  9313. case server.FieldCreatedAt:
  9314. return m.OldCreatedAt(ctx)
  9315. case server.FieldUpdatedAt:
  9316. return m.OldUpdatedAt(ctx)
  9317. case server.FieldStatus:
  9318. return m.OldStatus(ctx)
  9319. case server.FieldDeletedAt:
  9320. return m.OldDeletedAt(ctx)
  9321. case server.FieldName:
  9322. return m.OldName(ctx)
  9323. case server.FieldPublicIP:
  9324. return m.OldPublicIP(ctx)
  9325. case server.FieldPrivateIP:
  9326. return m.OldPrivateIP(ctx)
  9327. case server.FieldAdminPort:
  9328. return m.OldAdminPort(ctx)
  9329. }
  9330. return nil, fmt.Errorf("unknown Server field %s", name)
  9331. }
  9332. // SetField sets the value of a field with the given name. It returns an error if
  9333. // the field is not defined in the schema, or if the type mismatched the field
  9334. // type.
  9335. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  9336. switch name {
  9337. case server.FieldCreatedAt:
  9338. v, ok := value.(time.Time)
  9339. if !ok {
  9340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9341. }
  9342. m.SetCreatedAt(v)
  9343. return nil
  9344. case server.FieldUpdatedAt:
  9345. v, ok := value.(time.Time)
  9346. if !ok {
  9347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9348. }
  9349. m.SetUpdatedAt(v)
  9350. return nil
  9351. case server.FieldStatus:
  9352. v, ok := value.(uint8)
  9353. if !ok {
  9354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9355. }
  9356. m.SetStatus(v)
  9357. return nil
  9358. case server.FieldDeletedAt:
  9359. v, ok := value.(time.Time)
  9360. if !ok {
  9361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9362. }
  9363. m.SetDeletedAt(v)
  9364. return nil
  9365. case server.FieldName:
  9366. v, ok := value.(string)
  9367. if !ok {
  9368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9369. }
  9370. m.SetName(v)
  9371. return nil
  9372. case server.FieldPublicIP:
  9373. v, ok := value.(string)
  9374. if !ok {
  9375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9376. }
  9377. m.SetPublicIP(v)
  9378. return nil
  9379. case server.FieldPrivateIP:
  9380. v, ok := value.(string)
  9381. if !ok {
  9382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9383. }
  9384. m.SetPrivateIP(v)
  9385. return nil
  9386. case server.FieldAdminPort:
  9387. v, ok := value.(string)
  9388. if !ok {
  9389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9390. }
  9391. m.SetAdminPort(v)
  9392. return nil
  9393. }
  9394. return fmt.Errorf("unknown Server field %s", name)
  9395. }
  9396. // AddedFields returns all numeric fields that were incremented/decremented during
  9397. // this mutation.
  9398. func (m *ServerMutation) AddedFields() []string {
  9399. var fields []string
  9400. if m.addstatus != nil {
  9401. fields = append(fields, server.FieldStatus)
  9402. }
  9403. return fields
  9404. }
  9405. // AddedField returns the numeric value that was incremented/decremented on a field
  9406. // with the given name. The second boolean return value indicates that this field
  9407. // was not set, or was not defined in the schema.
  9408. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  9409. switch name {
  9410. case server.FieldStatus:
  9411. return m.AddedStatus()
  9412. }
  9413. return nil, false
  9414. }
  9415. // AddField adds the value to the field with the given name. It returns an error if
  9416. // the field is not defined in the schema, or if the type mismatched the field
  9417. // type.
  9418. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  9419. switch name {
  9420. case server.FieldStatus:
  9421. v, ok := value.(int8)
  9422. if !ok {
  9423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9424. }
  9425. m.AddStatus(v)
  9426. return nil
  9427. }
  9428. return fmt.Errorf("unknown Server numeric field %s", name)
  9429. }
  9430. // ClearedFields returns all nullable fields that were cleared during this
  9431. // mutation.
  9432. func (m *ServerMutation) ClearedFields() []string {
  9433. var fields []string
  9434. if m.FieldCleared(server.FieldStatus) {
  9435. fields = append(fields, server.FieldStatus)
  9436. }
  9437. if m.FieldCleared(server.FieldDeletedAt) {
  9438. fields = append(fields, server.FieldDeletedAt)
  9439. }
  9440. return fields
  9441. }
  9442. // FieldCleared returns a boolean indicating if a field with the given name was
  9443. // cleared in this mutation.
  9444. func (m *ServerMutation) FieldCleared(name string) bool {
  9445. _, ok := m.clearedFields[name]
  9446. return ok
  9447. }
  9448. // ClearField clears the value of the field with the given name. It returns an
  9449. // error if the field is not defined in the schema.
  9450. func (m *ServerMutation) ClearField(name string) error {
  9451. switch name {
  9452. case server.FieldStatus:
  9453. m.ClearStatus()
  9454. return nil
  9455. case server.FieldDeletedAt:
  9456. m.ClearDeletedAt()
  9457. return nil
  9458. }
  9459. return fmt.Errorf("unknown Server nullable field %s", name)
  9460. }
  9461. // ResetField resets all changes in the mutation for the field with the given name.
  9462. // It returns an error if the field is not defined in the schema.
  9463. func (m *ServerMutation) ResetField(name string) error {
  9464. switch name {
  9465. case server.FieldCreatedAt:
  9466. m.ResetCreatedAt()
  9467. return nil
  9468. case server.FieldUpdatedAt:
  9469. m.ResetUpdatedAt()
  9470. return nil
  9471. case server.FieldStatus:
  9472. m.ResetStatus()
  9473. return nil
  9474. case server.FieldDeletedAt:
  9475. m.ResetDeletedAt()
  9476. return nil
  9477. case server.FieldName:
  9478. m.ResetName()
  9479. return nil
  9480. case server.FieldPublicIP:
  9481. m.ResetPublicIP()
  9482. return nil
  9483. case server.FieldPrivateIP:
  9484. m.ResetPrivateIP()
  9485. return nil
  9486. case server.FieldAdminPort:
  9487. m.ResetAdminPort()
  9488. return nil
  9489. }
  9490. return fmt.Errorf("unknown Server field %s", name)
  9491. }
  9492. // AddedEdges returns all edge names that were set/added in this mutation.
  9493. func (m *ServerMutation) AddedEdges() []string {
  9494. edges := make([]string, 0, 1)
  9495. if m.wxs != nil {
  9496. edges = append(edges, server.EdgeWxs)
  9497. }
  9498. return edges
  9499. }
  9500. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9501. // name in this mutation.
  9502. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  9503. switch name {
  9504. case server.EdgeWxs:
  9505. ids := make([]ent.Value, 0, len(m.wxs))
  9506. for id := range m.wxs {
  9507. ids = append(ids, id)
  9508. }
  9509. return ids
  9510. }
  9511. return nil
  9512. }
  9513. // RemovedEdges returns all edge names that were removed in this mutation.
  9514. func (m *ServerMutation) RemovedEdges() []string {
  9515. edges := make([]string, 0, 1)
  9516. if m.removedwxs != nil {
  9517. edges = append(edges, server.EdgeWxs)
  9518. }
  9519. return edges
  9520. }
  9521. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9522. // the given name in this mutation.
  9523. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  9524. switch name {
  9525. case server.EdgeWxs:
  9526. ids := make([]ent.Value, 0, len(m.removedwxs))
  9527. for id := range m.removedwxs {
  9528. ids = append(ids, id)
  9529. }
  9530. return ids
  9531. }
  9532. return nil
  9533. }
  9534. // ClearedEdges returns all edge names that were cleared in this mutation.
  9535. func (m *ServerMutation) ClearedEdges() []string {
  9536. edges := make([]string, 0, 1)
  9537. if m.clearedwxs {
  9538. edges = append(edges, server.EdgeWxs)
  9539. }
  9540. return edges
  9541. }
  9542. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9543. // was cleared in this mutation.
  9544. func (m *ServerMutation) EdgeCleared(name string) bool {
  9545. switch name {
  9546. case server.EdgeWxs:
  9547. return m.clearedwxs
  9548. }
  9549. return false
  9550. }
  9551. // ClearEdge clears the value of the edge with the given name. It returns an error
  9552. // if that edge is not defined in the schema.
  9553. func (m *ServerMutation) ClearEdge(name string) error {
  9554. switch name {
  9555. }
  9556. return fmt.Errorf("unknown Server unique edge %s", name)
  9557. }
  9558. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9559. // It returns an error if the edge is not defined in the schema.
  9560. func (m *ServerMutation) ResetEdge(name string) error {
  9561. switch name {
  9562. case server.EdgeWxs:
  9563. m.ResetWxs()
  9564. return nil
  9565. }
  9566. return fmt.Errorf("unknown Server edge %s", name)
  9567. }
  9568. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  9569. type SopNodeMutation struct {
  9570. config
  9571. op Op
  9572. typ string
  9573. id *uint64
  9574. created_at *time.Time
  9575. updated_at *time.Time
  9576. status *uint8
  9577. addstatus *int8
  9578. deleted_at *time.Time
  9579. parent_id *uint64
  9580. addparent_id *int64
  9581. name *string
  9582. condition_type *int
  9583. addcondition_type *int
  9584. condition_list *[]string
  9585. appendcondition_list []string
  9586. no_reply_condition *uint64
  9587. addno_reply_condition *int64
  9588. action_message *[]custom_types.Action
  9589. appendaction_message []custom_types.Action
  9590. action_label *[]uint64
  9591. appendaction_label []uint64
  9592. clearedFields map[string]struct{}
  9593. sop_stage *uint64
  9594. clearedsop_stage bool
  9595. node_messages map[uint64]struct{}
  9596. removednode_messages map[uint64]struct{}
  9597. clearednode_messages bool
  9598. done bool
  9599. oldValue func(context.Context) (*SopNode, error)
  9600. predicates []predicate.SopNode
  9601. }
  9602. var _ ent.Mutation = (*SopNodeMutation)(nil)
  9603. // sopnodeOption allows management of the mutation configuration using functional options.
  9604. type sopnodeOption func(*SopNodeMutation)
  9605. // newSopNodeMutation creates new mutation for the SopNode entity.
  9606. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  9607. m := &SopNodeMutation{
  9608. config: c,
  9609. op: op,
  9610. typ: TypeSopNode,
  9611. clearedFields: make(map[string]struct{}),
  9612. }
  9613. for _, opt := range opts {
  9614. opt(m)
  9615. }
  9616. return m
  9617. }
  9618. // withSopNodeID sets the ID field of the mutation.
  9619. func withSopNodeID(id uint64) sopnodeOption {
  9620. return func(m *SopNodeMutation) {
  9621. var (
  9622. err error
  9623. once sync.Once
  9624. value *SopNode
  9625. )
  9626. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  9627. once.Do(func() {
  9628. if m.done {
  9629. err = errors.New("querying old values post mutation is not allowed")
  9630. } else {
  9631. value, err = m.Client().SopNode.Get(ctx, id)
  9632. }
  9633. })
  9634. return value, err
  9635. }
  9636. m.id = &id
  9637. }
  9638. }
  9639. // withSopNode sets the old SopNode of the mutation.
  9640. func withSopNode(node *SopNode) sopnodeOption {
  9641. return func(m *SopNodeMutation) {
  9642. m.oldValue = func(context.Context) (*SopNode, error) {
  9643. return node, nil
  9644. }
  9645. m.id = &node.ID
  9646. }
  9647. }
  9648. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9649. // executed in a transaction (ent.Tx), a transactional client is returned.
  9650. func (m SopNodeMutation) Client() *Client {
  9651. client := &Client{config: m.config}
  9652. client.init()
  9653. return client
  9654. }
  9655. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9656. // it returns an error otherwise.
  9657. func (m SopNodeMutation) Tx() (*Tx, error) {
  9658. if _, ok := m.driver.(*txDriver); !ok {
  9659. return nil, errors.New("ent: mutation is not running in a transaction")
  9660. }
  9661. tx := &Tx{config: m.config}
  9662. tx.init()
  9663. return tx, nil
  9664. }
  9665. // SetID sets the value of the id field. Note that this
  9666. // operation is only accepted on creation of SopNode entities.
  9667. func (m *SopNodeMutation) SetID(id uint64) {
  9668. m.id = &id
  9669. }
  9670. // ID returns the ID value in the mutation. Note that the ID is only available
  9671. // if it was provided to the builder or after it was returned from the database.
  9672. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  9673. if m.id == nil {
  9674. return
  9675. }
  9676. return *m.id, true
  9677. }
  9678. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9679. // That means, if the mutation is applied within a transaction with an isolation level such
  9680. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9681. // or updated by the mutation.
  9682. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  9683. switch {
  9684. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9685. id, exists := m.ID()
  9686. if exists {
  9687. return []uint64{id}, nil
  9688. }
  9689. fallthrough
  9690. case m.op.Is(OpUpdate | OpDelete):
  9691. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  9692. default:
  9693. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9694. }
  9695. }
  9696. // SetCreatedAt sets the "created_at" field.
  9697. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  9698. m.created_at = &t
  9699. }
  9700. // CreatedAt returns the value of the "created_at" field in the mutation.
  9701. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  9702. v := m.created_at
  9703. if v == nil {
  9704. return
  9705. }
  9706. return *v, true
  9707. }
  9708. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  9709. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9711. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9712. if !m.op.Is(OpUpdateOne) {
  9713. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9714. }
  9715. if m.id == nil || m.oldValue == nil {
  9716. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9717. }
  9718. oldValue, err := m.oldValue(ctx)
  9719. if err != nil {
  9720. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9721. }
  9722. return oldValue.CreatedAt, nil
  9723. }
  9724. // ResetCreatedAt resets all changes to the "created_at" field.
  9725. func (m *SopNodeMutation) ResetCreatedAt() {
  9726. m.created_at = nil
  9727. }
  9728. // SetUpdatedAt sets the "updated_at" field.
  9729. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  9730. m.updated_at = &t
  9731. }
  9732. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9733. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  9734. v := m.updated_at
  9735. if v == nil {
  9736. return
  9737. }
  9738. return *v, true
  9739. }
  9740. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  9741. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9743. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9744. if !m.op.Is(OpUpdateOne) {
  9745. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9746. }
  9747. if m.id == nil || m.oldValue == nil {
  9748. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9749. }
  9750. oldValue, err := m.oldValue(ctx)
  9751. if err != nil {
  9752. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9753. }
  9754. return oldValue.UpdatedAt, nil
  9755. }
  9756. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9757. func (m *SopNodeMutation) ResetUpdatedAt() {
  9758. m.updated_at = nil
  9759. }
  9760. // SetStatus sets the "status" field.
  9761. func (m *SopNodeMutation) SetStatus(u uint8) {
  9762. m.status = &u
  9763. m.addstatus = nil
  9764. }
  9765. // Status returns the value of the "status" field in the mutation.
  9766. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  9767. v := m.status
  9768. if v == nil {
  9769. return
  9770. }
  9771. return *v, true
  9772. }
  9773. // OldStatus returns the old "status" field's value of the SopNode entity.
  9774. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9776. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9777. if !m.op.Is(OpUpdateOne) {
  9778. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9779. }
  9780. if m.id == nil || m.oldValue == nil {
  9781. return v, errors.New("OldStatus requires an ID field in the mutation")
  9782. }
  9783. oldValue, err := m.oldValue(ctx)
  9784. if err != nil {
  9785. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9786. }
  9787. return oldValue.Status, nil
  9788. }
  9789. // AddStatus adds u to the "status" field.
  9790. func (m *SopNodeMutation) AddStatus(u int8) {
  9791. if m.addstatus != nil {
  9792. *m.addstatus += u
  9793. } else {
  9794. m.addstatus = &u
  9795. }
  9796. }
  9797. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9798. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  9799. v := m.addstatus
  9800. if v == nil {
  9801. return
  9802. }
  9803. return *v, true
  9804. }
  9805. // ClearStatus clears the value of the "status" field.
  9806. func (m *SopNodeMutation) ClearStatus() {
  9807. m.status = nil
  9808. m.addstatus = nil
  9809. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  9810. }
  9811. // StatusCleared returns if the "status" field was cleared in this mutation.
  9812. func (m *SopNodeMutation) StatusCleared() bool {
  9813. _, ok := m.clearedFields[sopnode.FieldStatus]
  9814. return ok
  9815. }
  9816. // ResetStatus resets all changes to the "status" field.
  9817. func (m *SopNodeMutation) ResetStatus() {
  9818. m.status = nil
  9819. m.addstatus = nil
  9820. delete(m.clearedFields, sopnode.FieldStatus)
  9821. }
  9822. // SetDeletedAt sets the "deleted_at" field.
  9823. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  9824. m.deleted_at = &t
  9825. }
  9826. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9827. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  9828. v := m.deleted_at
  9829. if v == nil {
  9830. return
  9831. }
  9832. return *v, true
  9833. }
  9834. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  9835. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9837. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9838. if !m.op.Is(OpUpdateOne) {
  9839. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9840. }
  9841. if m.id == nil || m.oldValue == nil {
  9842. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9843. }
  9844. oldValue, err := m.oldValue(ctx)
  9845. if err != nil {
  9846. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9847. }
  9848. return oldValue.DeletedAt, nil
  9849. }
  9850. // ClearDeletedAt clears the value of the "deleted_at" field.
  9851. func (m *SopNodeMutation) ClearDeletedAt() {
  9852. m.deleted_at = nil
  9853. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  9854. }
  9855. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9856. func (m *SopNodeMutation) DeletedAtCleared() bool {
  9857. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  9858. return ok
  9859. }
  9860. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9861. func (m *SopNodeMutation) ResetDeletedAt() {
  9862. m.deleted_at = nil
  9863. delete(m.clearedFields, sopnode.FieldDeletedAt)
  9864. }
  9865. // SetStageID sets the "stage_id" field.
  9866. func (m *SopNodeMutation) SetStageID(u uint64) {
  9867. m.sop_stage = &u
  9868. }
  9869. // StageID returns the value of the "stage_id" field in the mutation.
  9870. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  9871. v := m.sop_stage
  9872. if v == nil {
  9873. return
  9874. }
  9875. return *v, true
  9876. }
  9877. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  9878. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9879. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9880. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  9881. if !m.op.Is(OpUpdateOne) {
  9882. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  9883. }
  9884. if m.id == nil || m.oldValue == nil {
  9885. return v, errors.New("OldStageID requires an ID field in the mutation")
  9886. }
  9887. oldValue, err := m.oldValue(ctx)
  9888. if err != nil {
  9889. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  9890. }
  9891. return oldValue.StageID, nil
  9892. }
  9893. // ResetStageID resets all changes to the "stage_id" field.
  9894. func (m *SopNodeMutation) ResetStageID() {
  9895. m.sop_stage = nil
  9896. }
  9897. // SetParentID sets the "parent_id" field.
  9898. func (m *SopNodeMutation) SetParentID(u uint64) {
  9899. m.parent_id = &u
  9900. m.addparent_id = nil
  9901. }
  9902. // ParentID returns the value of the "parent_id" field in the mutation.
  9903. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  9904. v := m.parent_id
  9905. if v == nil {
  9906. return
  9907. }
  9908. return *v, true
  9909. }
  9910. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  9911. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9913. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  9914. if !m.op.Is(OpUpdateOne) {
  9915. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  9916. }
  9917. if m.id == nil || m.oldValue == nil {
  9918. return v, errors.New("OldParentID requires an ID field in the mutation")
  9919. }
  9920. oldValue, err := m.oldValue(ctx)
  9921. if err != nil {
  9922. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  9923. }
  9924. return oldValue.ParentID, nil
  9925. }
  9926. // AddParentID adds u to the "parent_id" field.
  9927. func (m *SopNodeMutation) AddParentID(u int64) {
  9928. if m.addparent_id != nil {
  9929. *m.addparent_id += u
  9930. } else {
  9931. m.addparent_id = &u
  9932. }
  9933. }
  9934. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  9935. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  9936. v := m.addparent_id
  9937. if v == nil {
  9938. return
  9939. }
  9940. return *v, true
  9941. }
  9942. // ResetParentID resets all changes to the "parent_id" field.
  9943. func (m *SopNodeMutation) ResetParentID() {
  9944. m.parent_id = nil
  9945. m.addparent_id = nil
  9946. }
  9947. // SetName sets the "name" field.
  9948. func (m *SopNodeMutation) SetName(s string) {
  9949. m.name = &s
  9950. }
  9951. // Name returns the value of the "name" field in the mutation.
  9952. func (m *SopNodeMutation) Name() (r string, exists bool) {
  9953. v := m.name
  9954. if v == nil {
  9955. return
  9956. }
  9957. return *v, true
  9958. }
  9959. // OldName returns the old "name" field's value of the SopNode entity.
  9960. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9961. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9962. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  9963. if !m.op.Is(OpUpdateOne) {
  9964. return v, errors.New("OldName is only allowed on UpdateOne operations")
  9965. }
  9966. if m.id == nil || m.oldValue == nil {
  9967. return v, errors.New("OldName requires an ID field in the mutation")
  9968. }
  9969. oldValue, err := m.oldValue(ctx)
  9970. if err != nil {
  9971. return v, fmt.Errorf("querying old value for OldName: %w", err)
  9972. }
  9973. return oldValue.Name, nil
  9974. }
  9975. // ResetName resets all changes to the "name" field.
  9976. func (m *SopNodeMutation) ResetName() {
  9977. m.name = nil
  9978. }
  9979. // SetConditionType sets the "condition_type" field.
  9980. func (m *SopNodeMutation) SetConditionType(i int) {
  9981. m.condition_type = &i
  9982. m.addcondition_type = nil
  9983. }
  9984. // ConditionType returns the value of the "condition_type" field in the mutation.
  9985. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  9986. v := m.condition_type
  9987. if v == nil {
  9988. return
  9989. }
  9990. return *v, true
  9991. }
  9992. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  9993. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9995. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  9996. if !m.op.Is(OpUpdateOne) {
  9997. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  9998. }
  9999. if m.id == nil || m.oldValue == nil {
  10000. return v, errors.New("OldConditionType requires an ID field in the mutation")
  10001. }
  10002. oldValue, err := m.oldValue(ctx)
  10003. if err != nil {
  10004. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  10005. }
  10006. return oldValue.ConditionType, nil
  10007. }
  10008. // AddConditionType adds i to the "condition_type" field.
  10009. func (m *SopNodeMutation) AddConditionType(i int) {
  10010. if m.addcondition_type != nil {
  10011. *m.addcondition_type += i
  10012. } else {
  10013. m.addcondition_type = &i
  10014. }
  10015. }
  10016. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  10017. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  10018. v := m.addcondition_type
  10019. if v == nil {
  10020. return
  10021. }
  10022. return *v, true
  10023. }
  10024. // ResetConditionType resets all changes to the "condition_type" field.
  10025. func (m *SopNodeMutation) ResetConditionType() {
  10026. m.condition_type = nil
  10027. m.addcondition_type = nil
  10028. }
  10029. // SetConditionList sets the "condition_list" field.
  10030. func (m *SopNodeMutation) SetConditionList(s []string) {
  10031. m.condition_list = &s
  10032. m.appendcondition_list = nil
  10033. }
  10034. // ConditionList returns the value of the "condition_list" field in the mutation.
  10035. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  10036. v := m.condition_list
  10037. if v == nil {
  10038. return
  10039. }
  10040. return *v, true
  10041. }
  10042. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  10043. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  10044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10045. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  10046. if !m.op.Is(OpUpdateOne) {
  10047. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  10048. }
  10049. if m.id == nil || m.oldValue == nil {
  10050. return v, errors.New("OldConditionList requires an ID field in the mutation")
  10051. }
  10052. oldValue, err := m.oldValue(ctx)
  10053. if err != nil {
  10054. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  10055. }
  10056. return oldValue.ConditionList, nil
  10057. }
  10058. // AppendConditionList adds s to the "condition_list" field.
  10059. func (m *SopNodeMutation) AppendConditionList(s []string) {
  10060. m.appendcondition_list = append(m.appendcondition_list, s...)
  10061. }
  10062. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  10063. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  10064. if len(m.appendcondition_list) == 0 {
  10065. return nil, false
  10066. }
  10067. return m.appendcondition_list, true
  10068. }
  10069. // ClearConditionList clears the value of the "condition_list" field.
  10070. func (m *SopNodeMutation) ClearConditionList() {
  10071. m.condition_list = nil
  10072. m.appendcondition_list = nil
  10073. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  10074. }
  10075. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  10076. func (m *SopNodeMutation) ConditionListCleared() bool {
  10077. _, ok := m.clearedFields[sopnode.FieldConditionList]
  10078. return ok
  10079. }
  10080. // ResetConditionList resets all changes to the "condition_list" field.
  10081. func (m *SopNodeMutation) ResetConditionList() {
  10082. m.condition_list = nil
  10083. m.appendcondition_list = nil
  10084. delete(m.clearedFields, sopnode.FieldConditionList)
  10085. }
  10086. // SetNoReplyCondition sets the "no_reply_condition" field.
  10087. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  10088. m.no_reply_condition = &u
  10089. m.addno_reply_condition = nil
  10090. }
  10091. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  10092. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  10093. v := m.no_reply_condition
  10094. if v == nil {
  10095. return
  10096. }
  10097. return *v, true
  10098. }
  10099. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  10100. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  10101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10102. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  10103. if !m.op.Is(OpUpdateOne) {
  10104. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  10105. }
  10106. if m.id == nil || m.oldValue == nil {
  10107. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  10108. }
  10109. oldValue, err := m.oldValue(ctx)
  10110. if err != nil {
  10111. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  10112. }
  10113. return oldValue.NoReplyCondition, nil
  10114. }
  10115. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  10116. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  10117. if m.addno_reply_condition != nil {
  10118. *m.addno_reply_condition += u
  10119. } else {
  10120. m.addno_reply_condition = &u
  10121. }
  10122. }
  10123. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  10124. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  10125. v := m.addno_reply_condition
  10126. if v == nil {
  10127. return
  10128. }
  10129. return *v, true
  10130. }
  10131. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  10132. func (m *SopNodeMutation) ResetNoReplyCondition() {
  10133. m.no_reply_condition = nil
  10134. m.addno_reply_condition = nil
  10135. }
  10136. // SetActionMessage sets the "action_message" field.
  10137. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  10138. m.action_message = &ct
  10139. m.appendaction_message = nil
  10140. }
  10141. // ActionMessage returns the value of the "action_message" field in the mutation.
  10142. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  10143. v := m.action_message
  10144. if v == nil {
  10145. return
  10146. }
  10147. return *v, true
  10148. }
  10149. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  10150. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  10151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10152. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  10153. if !m.op.Is(OpUpdateOne) {
  10154. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  10155. }
  10156. if m.id == nil || m.oldValue == nil {
  10157. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  10158. }
  10159. oldValue, err := m.oldValue(ctx)
  10160. if err != nil {
  10161. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  10162. }
  10163. return oldValue.ActionMessage, nil
  10164. }
  10165. // AppendActionMessage adds ct to the "action_message" field.
  10166. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  10167. m.appendaction_message = append(m.appendaction_message, ct...)
  10168. }
  10169. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  10170. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  10171. if len(m.appendaction_message) == 0 {
  10172. return nil, false
  10173. }
  10174. return m.appendaction_message, true
  10175. }
  10176. // ClearActionMessage clears the value of the "action_message" field.
  10177. func (m *SopNodeMutation) ClearActionMessage() {
  10178. m.action_message = nil
  10179. m.appendaction_message = nil
  10180. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  10181. }
  10182. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  10183. func (m *SopNodeMutation) ActionMessageCleared() bool {
  10184. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  10185. return ok
  10186. }
  10187. // ResetActionMessage resets all changes to the "action_message" field.
  10188. func (m *SopNodeMutation) ResetActionMessage() {
  10189. m.action_message = nil
  10190. m.appendaction_message = nil
  10191. delete(m.clearedFields, sopnode.FieldActionMessage)
  10192. }
  10193. // SetActionLabel sets the "action_label" field.
  10194. func (m *SopNodeMutation) SetActionLabel(u []uint64) {
  10195. m.action_label = &u
  10196. m.appendaction_label = nil
  10197. }
  10198. // ActionLabel returns the value of the "action_label" field in the mutation.
  10199. func (m *SopNodeMutation) ActionLabel() (r []uint64, exists bool) {
  10200. v := m.action_label
  10201. if v == nil {
  10202. return
  10203. }
  10204. return *v, true
  10205. }
  10206. // OldActionLabel returns the old "action_label" field's value of the SopNode entity.
  10207. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  10208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10209. func (m *SopNodeMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  10210. if !m.op.Is(OpUpdateOne) {
  10211. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  10212. }
  10213. if m.id == nil || m.oldValue == nil {
  10214. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  10215. }
  10216. oldValue, err := m.oldValue(ctx)
  10217. if err != nil {
  10218. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  10219. }
  10220. return oldValue.ActionLabel, nil
  10221. }
  10222. // AppendActionLabel adds u to the "action_label" field.
  10223. func (m *SopNodeMutation) AppendActionLabel(u []uint64) {
  10224. m.appendaction_label = append(m.appendaction_label, u...)
  10225. }
  10226. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  10227. func (m *SopNodeMutation) AppendedActionLabel() ([]uint64, bool) {
  10228. if len(m.appendaction_label) == 0 {
  10229. return nil, false
  10230. }
  10231. return m.appendaction_label, true
  10232. }
  10233. // ClearActionLabel clears the value of the "action_label" field.
  10234. func (m *SopNodeMutation) ClearActionLabel() {
  10235. m.action_label = nil
  10236. m.appendaction_label = nil
  10237. m.clearedFields[sopnode.FieldActionLabel] = struct{}{}
  10238. }
  10239. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  10240. func (m *SopNodeMutation) ActionLabelCleared() bool {
  10241. _, ok := m.clearedFields[sopnode.FieldActionLabel]
  10242. return ok
  10243. }
  10244. // ResetActionLabel resets all changes to the "action_label" field.
  10245. func (m *SopNodeMutation) ResetActionLabel() {
  10246. m.action_label = nil
  10247. m.appendaction_label = nil
  10248. delete(m.clearedFields, sopnode.FieldActionLabel)
  10249. }
  10250. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  10251. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  10252. m.sop_stage = &id
  10253. }
  10254. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  10255. func (m *SopNodeMutation) ClearSopStage() {
  10256. m.clearedsop_stage = true
  10257. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  10258. }
  10259. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  10260. func (m *SopNodeMutation) SopStageCleared() bool {
  10261. return m.clearedsop_stage
  10262. }
  10263. // SopStageID returns the "sop_stage" edge ID in the mutation.
  10264. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  10265. if m.sop_stage != nil {
  10266. return *m.sop_stage, true
  10267. }
  10268. return
  10269. }
  10270. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  10271. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  10272. // SopStageID instead. It exists only for internal usage by the builders.
  10273. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  10274. if id := m.sop_stage; id != nil {
  10275. ids = append(ids, *id)
  10276. }
  10277. return
  10278. }
  10279. // ResetSopStage resets all changes to the "sop_stage" edge.
  10280. func (m *SopNodeMutation) ResetSopStage() {
  10281. m.sop_stage = nil
  10282. m.clearedsop_stage = false
  10283. }
  10284. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  10285. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  10286. if m.node_messages == nil {
  10287. m.node_messages = make(map[uint64]struct{})
  10288. }
  10289. for i := range ids {
  10290. m.node_messages[ids[i]] = struct{}{}
  10291. }
  10292. }
  10293. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  10294. func (m *SopNodeMutation) ClearNodeMessages() {
  10295. m.clearednode_messages = true
  10296. }
  10297. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  10298. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  10299. return m.clearednode_messages
  10300. }
  10301. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  10302. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  10303. if m.removednode_messages == nil {
  10304. m.removednode_messages = make(map[uint64]struct{})
  10305. }
  10306. for i := range ids {
  10307. delete(m.node_messages, ids[i])
  10308. m.removednode_messages[ids[i]] = struct{}{}
  10309. }
  10310. }
  10311. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  10312. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  10313. for id := range m.removednode_messages {
  10314. ids = append(ids, id)
  10315. }
  10316. return
  10317. }
  10318. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  10319. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  10320. for id := range m.node_messages {
  10321. ids = append(ids, id)
  10322. }
  10323. return
  10324. }
  10325. // ResetNodeMessages resets all changes to the "node_messages" edge.
  10326. func (m *SopNodeMutation) ResetNodeMessages() {
  10327. m.node_messages = nil
  10328. m.clearednode_messages = false
  10329. m.removednode_messages = nil
  10330. }
  10331. // Where appends a list predicates to the SopNodeMutation builder.
  10332. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  10333. m.predicates = append(m.predicates, ps...)
  10334. }
  10335. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  10336. // users can use type-assertion to append predicates that do not depend on any generated package.
  10337. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  10338. p := make([]predicate.SopNode, len(ps))
  10339. for i := range ps {
  10340. p[i] = ps[i]
  10341. }
  10342. m.Where(p...)
  10343. }
  10344. // Op returns the operation name.
  10345. func (m *SopNodeMutation) Op() Op {
  10346. return m.op
  10347. }
  10348. // SetOp allows setting the mutation operation.
  10349. func (m *SopNodeMutation) SetOp(op Op) {
  10350. m.op = op
  10351. }
  10352. // Type returns the node type of this mutation (SopNode).
  10353. func (m *SopNodeMutation) Type() string {
  10354. return m.typ
  10355. }
  10356. // Fields returns all fields that were changed during this mutation. Note that in
  10357. // order to get all numeric fields that were incremented/decremented, call
  10358. // AddedFields().
  10359. func (m *SopNodeMutation) Fields() []string {
  10360. fields := make([]string, 0, 12)
  10361. if m.created_at != nil {
  10362. fields = append(fields, sopnode.FieldCreatedAt)
  10363. }
  10364. if m.updated_at != nil {
  10365. fields = append(fields, sopnode.FieldUpdatedAt)
  10366. }
  10367. if m.status != nil {
  10368. fields = append(fields, sopnode.FieldStatus)
  10369. }
  10370. if m.deleted_at != nil {
  10371. fields = append(fields, sopnode.FieldDeletedAt)
  10372. }
  10373. if m.sop_stage != nil {
  10374. fields = append(fields, sopnode.FieldStageID)
  10375. }
  10376. if m.parent_id != nil {
  10377. fields = append(fields, sopnode.FieldParentID)
  10378. }
  10379. if m.name != nil {
  10380. fields = append(fields, sopnode.FieldName)
  10381. }
  10382. if m.condition_type != nil {
  10383. fields = append(fields, sopnode.FieldConditionType)
  10384. }
  10385. if m.condition_list != nil {
  10386. fields = append(fields, sopnode.FieldConditionList)
  10387. }
  10388. if m.no_reply_condition != nil {
  10389. fields = append(fields, sopnode.FieldNoReplyCondition)
  10390. }
  10391. if m.action_message != nil {
  10392. fields = append(fields, sopnode.FieldActionMessage)
  10393. }
  10394. if m.action_label != nil {
  10395. fields = append(fields, sopnode.FieldActionLabel)
  10396. }
  10397. return fields
  10398. }
  10399. // Field returns the value of a field with the given name. The second boolean
  10400. // return value indicates that this field was not set, or was not defined in the
  10401. // schema.
  10402. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  10403. switch name {
  10404. case sopnode.FieldCreatedAt:
  10405. return m.CreatedAt()
  10406. case sopnode.FieldUpdatedAt:
  10407. return m.UpdatedAt()
  10408. case sopnode.FieldStatus:
  10409. return m.Status()
  10410. case sopnode.FieldDeletedAt:
  10411. return m.DeletedAt()
  10412. case sopnode.FieldStageID:
  10413. return m.StageID()
  10414. case sopnode.FieldParentID:
  10415. return m.ParentID()
  10416. case sopnode.FieldName:
  10417. return m.Name()
  10418. case sopnode.FieldConditionType:
  10419. return m.ConditionType()
  10420. case sopnode.FieldConditionList:
  10421. return m.ConditionList()
  10422. case sopnode.FieldNoReplyCondition:
  10423. return m.NoReplyCondition()
  10424. case sopnode.FieldActionMessage:
  10425. return m.ActionMessage()
  10426. case sopnode.FieldActionLabel:
  10427. return m.ActionLabel()
  10428. }
  10429. return nil, false
  10430. }
  10431. // OldField returns the old value of the field from the database. An error is
  10432. // returned if the mutation operation is not UpdateOne, or the query to the
  10433. // database failed.
  10434. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10435. switch name {
  10436. case sopnode.FieldCreatedAt:
  10437. return m.OldCreatedAt(ctx)
  10438. case sopnode.FieldUpdatedAt:
  10439. return m.OldUpdatedAt(ctx)
  10440. case sopnode.FieldStatus:
  10441. return m.OldStatus(ctx)
  10442. case sopnode.FieldDeletedAt:
  10443. return m.OldDeletedAt(ctx)
  10444. case sopnode.FieldStageID:
  10445. return m.OldStageID(ctx)
  10446. case sopnode.FieldParentID:
  10447. return m.OldParentID(ctx)
  10448. case sopnode.FieldName:
  10449. return m.OldName(ctx)
  10450. case sopnode.FieldConditionType:
  10451. return m.OldConditionType(ctx)
  10452. case sopnode.FieldConditionList:
  10453. return m.OldConditionList(ctx)
  10454. case sopnode.FieldNoReplyCondition:
  10455. return m.OldNoReplyCondition(ctx)
  10456. case sopnode.FieldActionMessage:
  10457. return m.OldActionMessage(ctx)
  10458. case sopnode.FieldActionLabel:
  10459. return m.OldActionLabel(ctx)
  10460. }
  10461. return nil, fmt.Errorf("unknown SopNode field %s", name)
  10462. }
  10463. // SetField sets the value of a field with the given name. It returns an error if
  10464. // the field is not defined in the schema, or if the type mismatched the field
  10465. // type.
  10466. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  10467. switch name {
  10468. case sopnode.FieldCreatedAt:
  10469. v, ok := value.(time.Time)
  10470. if !ok {
  10471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10472. }
  10473. m.SetCreatedAt(v)
  10474. return nil
  10475. case sopnode.FieldUpdatedAt:
  10476. v, ok := value.(time.Time)
  10477. if !ok {
  10478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10479. }
  10480. m.SetUpdatedAt(v)
  10481. return nil
  10482. case sopnode.FieldStatus:
  10483. v, ok := value.(uint8)
  10484. if !ok {
  10485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10486. }
  10487. m.SetStatus(v)
  10488. return nil
  10489. case sopnode.FieldDeletedAt:
  10490. v, ok := value.(time.Time)
  10491. if !ok {
  10492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10493. }
  10494. m.SetDeletedAt(v)
  10495. return nil
  10496. case sopnode.FieldStageID:
  10497. v, ok := value.(uint64)
  10498. if !ok {
  10499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10500. }
  10501. m.SetStageID(v)
  10502. return nil
  10503. case sopnode.FieldParentID:
  10504. v, ok := value.(uint64)
  10505. if !ok {
  10506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10507. }
  10508. m.SetParentID(v)
  10509. return nil
  10510. case sopnode.FieldName:
  10511. v, ok := value.(string)
  10512. if !ok {
  10513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10514. }
  10515. m.SetName(v)
  10516. return nil
  10517. case sopnode.FieldConditionType:
  10518. v, ok := value.(int)
  10519. if !ok {
  10520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10521. }
  10522. m.SetConditionType(v)
  10523. return nil
  10524. case sopnode.FieldConditionList:
  10525. v, ok := value.([]string)
  10526. if !ok {
  10527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10528. }
  10529. m.SetConditionList(v)
  10530. return nil
  10531. case sopnode.FieldNoReplyCondition:
  10532. v, ok := value.(uint64)
  10533. if !ok {
  10534. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10535. }
  10536. m.SetNoReplyCondition(v)
  10537. return nil
  10538. case sopnode.FieldActionMessage:
  10539. v, ok := value.([]custom_types.Action)
  10540. if !ok {
  10541. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10542. }
  10543. m.SetActionMessage(v)
  10544. return nil
  10545. case sopnode.FieldActionLabel:
  10546. v, ok := value.([]uint64)
  10547. if !ok {
  10548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10549. }
  10550. m.SetActionLabel(v)
  10551. return nil
  10552. }
  10553. return fmt.Errorf("unknown SopNode field %s", name)
  10554. }
  10555. // AddedFields returns all numeric fields that were incremented/decremented during
  10556. // this mutation.
  10557. func (m *SopNodeMutation) AddedFields() []string {
  10558. var fields []string
  10559. if m.addstatus != nil {
  10560. fields = append(fields, sopnode.FieldStatus)
  10561. }
  10562. if m.addparent_id != nil {
  10563. fields = append(fields, sopnode.FieldParentID)
  10564. }
  10565. if m.addcondition_type != nil {
  10566. fields = append(fields, sopnode.FieldConditionType)
  10567. }
  10568. if m.addno_reply_condition != nil {
  10569. fields = append(fields, sopnode.FieldNoReplyCondition)
  10570. }
  10571. return fields
  10572. }
  10573. // AddedField returns the numeric value that was incremented/decremented on a field
  10574. // with the given name. The second boolean return value indicates that this field
  10575. // was not set, or was not defined in the schema.
  10576. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  10577. switch name {
  10578. case sopnode.FieldStatus:
  10579. return m.AddedStatus()
  10580. case sopnode.FieldParentID:
  10581. return m.AddedParentID()
  10582. case sopnode.FieldConditionType:
  10583. return m.AddedConditionType()
  10584. case sopnode.FieldNoReplyCondition:
  10585. return m.AddedNoReplyCondition()
  10586. }
  10587. return nil, false
  10588. }
  10589. // AddField adds the value to the field with the given name. It returns an error if
  10590. // the field is not defined in the schema, or if the type mismatched the field
  10591. // type.
  10592. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  10593. switch name {
  10594. case sopnode.FieldStatus:
  10595. v, ok := value.(int8)
  10596. if !ok {
  10597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10598. }
  10599. m.AddStatus(v)
  10600. return nil
  10601. case sopnode.FieldParentID:
  10602. v, ok := value.(int64)
  10603. if !ok {
  10604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10605. }
  10606. m.AddParentID(v)
  10607. return nil
  10608. case sopnode.FieldConditionType:
  10609. v, ok := value.(int)
  10610. if !ok {
  10611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10612. }
  10613. m.AddConditionType(v)
  10614. return nil
  10615. case sopnode.FieldNoReplyCondition:
  10616. v, ok := value.(int64)
  10617. if !ok {
  10618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10619. }
  10620. m.AddNoReplyCondition(v)
  10621. return nil
  10622. }
  10623. return fmt.Errorf("unknown SopNode numeric field %s", name)
  10624. }
  10625. // ClearedFields returns all nullable fields that were cleared during this
  10626. // mutation.
  10627. func (m *SopNodeMutation) ClearedFields() []string {
  10628. var fields []string
  10629. if m.FieldCleared(sopnode.FieldStatus) {
  10630. fields = append(fields, sopnode.FieldStatus)
  10631. }
  10632. if m.FieldCleared(sopnode.FieldDeletedAt) {
  10633. fields = append(fields, sopnode.FieldDeletedAt)
  10634. }
  10635. if m.FieldCleared(sopnode.FieldConditionList) {
  10636. fields = append(fields, sopnode.FieldConditionList)
  10637. }
  10638. if m.FieldCleared(sopnode.FieldActionMessage) {
  10639. fields = append(fields, sopnode.FieldActionMessage)
  10640. }
  10641. if m.FieldCleared(sopnode.FieldActionLabel) {
  10642. fields = append(fields, sopnode.FieldActionLabel)
  10643. }
  10644. return fields
  10645. }
  10646. // FieldCleared returns a boolean indicating if a field with the given name was
  10647. // cleared in this mutation.
  10648. func (m *SopNodeMutation) FieldCleared(name string) bool {
  10649. _, ok := m.clearedFields[name]
  10650. return ok
  10651. }
  10652. // ClearField clears the value of the field with the given name. It returns an
  10653. // error if the field is not defined in the schema.
  10654. func (m *SopNodeMutation) ClearField(name string) error {
  10655. switch name {
  10656. case sopnode.FieldStatus:
  10657. m.ClearStatus()
  10658. return nil
  10659. case sopnode.FieldDeletedAt:
  10660. m.ClearDeletedAt()
  10661. return nil
  10662. case sopnode.FieldConditionList:
  10663. m.ClearConditionList()
  10664. return nil
  10665. case sopnode.FieldActionMessage:
  10666. m.ClearActionMessage()
  10667. return nil
  10668. case sopnode.FieldActionLabel:
  10669. m.ClearActionLabel()
  10670. return nil
  10671. }
  10672. return fmt.Errorf("unknown SopNode nullable field %s", name)
  10673. }
  10674. // ResetField resets all changes in the mutation for the field with the given name.
  10675. // It returns an error if the field is not defined in the schema.
  10676. func (m *SopNodeMutation) ResetField(name string) error {
  10677. switch name {
  10678. case sopnode.FieldCreatedAt:
  10679. m.ResetCreatedAt()
  10680. return nil
  10681. case sopnode.FieldUpdatedAt:
  10682. m.ResetUpdatedAt()
  10683. return nil
  10684. case sopnode.FieldStatus:
  10685. m.ResetStatus()
  10686. return nil
  10687. case sopnode.FieldDeletedAt:
  10688. m.ResetDeletedAt()
  10689. return nil
  10690. case sopnode.FieldStageID:
  10691. m.ResetStageID()
  10692. return nil
  10693. case sopnode.FieldParentID:
  10694. m.ResetParentID()
  10695. return nil
  10696. case sopnode.FieldName:
  10697. m.ResetName()
  10698. return nil
  10699. case sopnode.FieldConditionType:
  10700. m.ResetConditionType()
  10701. return nil
  10702. case sopnode.FieldConditionList:
  10703. m.ResetConditionList()
  10704. return nil
  10705. case sopnode.FieldNoReplyCondition:
  10706. m.ResetNoReplyCondition()
  10707. return nil
  10708. case sopnode.FieldActionMessage:
  10709. m.ResetActionMessage()
  10710. return nil
  10711. case sopnode.FieldActionLabel:
  10712. m.ResetActionLabel()
  10713. return nil
  10714. }
  10715. return fmt.Errorf("unknown SopNode field %s", name)
  10716. }
  10717. // AddedEdges returns all edge names that were set/added in this mutation.
  10718. func (m *SopNodeMutation) AddedEdges() []string {
  10719. edges := make([]string, 0, 2)
  10720. if m.sop_stage != nil {
  10721. edges = append(edges, sopnode.EdgeSopStage)
  10722. }
  10723. if m.node_messages != nil {
  10724. edges = append(edges, sopnode.EdgeNodeMessages)
  10725. }
  10726. return edges
  10727. }
  10728. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10729. // name in this mutation.
  10730. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  10731. switch name {
  10732. case sopnode.EdgeSopStage:
  10733. if id := m.sop_stage; id != nil {
  10734. return []ent.Value{*id}
  10735. }
  10736. case sopnode.EdgeNodeMessages:
  10737. ids := make([]ent.Value, 0, len(m.node_messages))
  10738. for id := range m.node_messages {
  10739. ids = append(ids, id)
  10740. }
  10741. return ids
  10742. }
  10743. return nil
  10744. }
  10745. // RemovedEdges returns all edge names that were removed in this mutation.
  10746. func (m *SopNodeMutation) RemovedEdges() []string {
  10747. edges := make([]string, 0, 2)
  10748. if m.removednode_messages != nil {
  10749. edges = append(edges, sopnode.EdgeNodeMessages)
  10750. }
  10751. return edges
  10752. }
  10753. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10754. // the given name in this mutation.
  10755. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  10756. switch name {
  10757. case sopnode.EdgeNodeMessages:
  10758. ids := make([]ent.Value, 0, len(m.removednode_messages))
  10759. for id := range m.removednode_messages {
  10760. ids = append(ids, id)
  10761. }
  10762. return ids
  10763. }
  10764. return nil
  10765. }
  10766. // ClearedEdges returns all edge names that were cleared in this mutation.
  10767. func (m *SopNodeMutation) ClearedEdges() []string {
  10768. edges := make([]string, 0, 2)
  10769. if m.clearedsop_stage {
  10770. edges = append(edges, sopnode.EdgeSopStage)
  10771. }
  10772. if m.clearednode_messages {
  10773. edges = append(edges, sopnode.EdgeNodeMessages)
  10774. }
  10775. return edges
  10776. }
  10777. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10778. // was cleared in this mutation.
  10779. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  10780. switch name {
  10781. case sopnode.EdgeSopStage:
  10782. return m.clearedsop_stage
  10783. case sopnode.EdgeNodeMessages:
  10784. return m.clearednode_messages
  10785. }
  10786. return false
  10787. }
  10788. // ClearEdge clears the value of the edge with the given name. It returns an error
  10789. // if that edge is not defined in the schema.
  10790. func (m *SopNodeMutation) ClearEdge(name string) error {
  10791. switch name {
  10792. case sopnode.EdgeSopStage:
  10793. m.ClearSopStage()
  10794. return nil
  10795. }
  10796. return fmt.Errorf("unknown SopNode unique edge %s", name)
  10797. }
  10798. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10799. // It returns an error if the edge is not defined in the schema.
  10800. func (m *SopNodeMutation) ResetEdge(name string) error {
  10801. switch name {
  10802. case sopnode.EdgeSopStage:
  10803. m.ResetSopStage()
  10804. return nil
  10805. case sopnode.EdgeNodeMessages:
  10806. m.ResetNodeMessages()
  10807. return nil
  10808. }
  10809. return fmt.Errorf("unknown SopNode edge %s", name)
  10810. }
  10811. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  10812. type SopStageMutation struct {
  10813. config
  10814. op Op
  10815. typ string
  10816. id *uint64
  10817. created_at *time.Time
  10818. updated_at *time.Time
  10819. status *uint8
  10820. addstatus *int8
  10821. deleted_at *time.Time
  10822. name *string
  10823. condition_type *int
  10824. addcondition_type *int
  10825. condition_operator *int
  10826. addcondition_operator *int
  10827. condition_list *[]custom_types.Condition
  10828. appendcondition_list []custom_types.Condition
  10829. action_message *[]custom_types.Action
  10830. appendaction_message []custom_types.Action
  10831. action_label *[]uint64
  10832. appendaction_label []uint64
  10833. index_sort *int
  10834. addindex_sort *int
  10835. clearedFields map[string]struct{}
  10836. sop_task *uint64
  10837. clearedsop_task bool
  10838. stage_nodes map[uint64]struct{}
  10839. removedstage_nodes map[uint64]struct{}
  10840. clearedstage_nodes bool
  10841. stage_messages map[uint64]struct{}
  10842. removedstage_messages map[uint64]struct{}
  10843. clearedstage_messages bool
  10844. done bool
  10845. oldValue func(context.Context) (*SopStage, error)
  10846. predicates []predicate.SopStage
  10847. }
  10848. var _ ent.Mutation = (*SopStageMutation)(nil)
  10849. // sopstageOption allows management of the mutation configuration using functional options.
  10850. type sopstageOption func(*SopStageMutation)
  10851. // newSopStageMutation creates new mutation for the SopStage entity.
  10852. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  10853. m := &SopStageMutation{
  10854. config: c,
  10855. op: op,
  10856. typ: TypeSopStage,
  10857. clearedFields: make(map[string]struct{}),
  10858. }
  10859. for _, opt := range opts {
  10860. opt(m)
  10861. }
  10862. return m
  10863. }
  10864. // withSopStageID sets the ID field of the mutation.
  10865. func withSopStageID(id uint64) sopstageOption {
  10866. return func(m *SopStageMutation) {
  10867. var (
  10868. err error
  10869. once sync.Once
  10870. value *SopStage
  10871. )
  10872. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  10873. once.Do(func() {
  10874. if m.done {
  10875. err = errors.New("querying old values post mutation is not allowed")
  10876. } else {
  10877. value, err = m.Client().SopStage.Get(ctx, id)
  10878. }
  10879. })
  10880. return value, err
  10881. }
  10882. m.id = &id
  10883. }
  10884. }
  10885. // withSopStage sets the old SopStage of the mutation.
  10886. func withSopStage(node *SopStage) sopstageOption {
  10887. return func(m *SopStageMutation) {
  10888. m.oldValue = func(context.Context) (*SopStage, error) {
  10889. return node, nil
  10890. }
  10891. m.id = &node.ID
  10892. }
  10893. }
  10894. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10895. // executed in a transaction (ent.Tx), a transactional client is returned.
  10896. func (m SopStageMutation) Client() *Client {
  10897. client := &Client{config: m.config}
  10898. client.init()
  10899. return client
  10900. }
  10901. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10902. // it returns an error otherwise.
  10903. func (m SopStageMutation) Tx() (*Tx, error) {
  10904. if _, ok := m.driver.(*txDriver); !ok {
  10905. return nil, errors.New("ent: mutation is not running in a transaction")
  10906. }
  10907. tx := &Tx{config: m.config}
  10908. tx.init()
  10909. return tx, nil
  10910. }
  10911. // SetID sets the value of the id field. Note that this
  10912. // operation is only accepted on creation of SopStage entities.
  10913. func (m *SopStageMutation) SetID(id uint64) {
  10914. m.id = &id
  10915. }
  10916. // ID returns the ID value in the mutation. Note that the ID is only available
  10917. // if it was provided to the builder or after it was returned from the database.
  10918. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  10919. if m.id == nil {
  10920. return
  10921. }
  10922. return *m.id, true
  10923. }
  10924. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10925. // That means, if the mutation is applied within a transaction with an isolation level such
  10926. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10927. // or updated by the mutation.
  10928. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  10929. switch {
  10930. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10931. id, exists := m.ID()
  10932. if exists {
  10933. return []uint64{id}, nil
  10934. }
  10935. fallthrough
  10936. case m.op.Is(OpUpdate | OpDelete):
  10937. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  10938. default:
  10939. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10940. }
  10941. }
  10942. // SetCreatedAt sets the "created_at" field.
  10943. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  10944. m.created_at = &t
  10945. }
  10946. // CreatedAt returns the value of the "created_at" field in the mutation.
  10947. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  10948. v := m.created_at
  10949. if v == nil {
  10950. return
  10951. }
  10952. return *v, true
  10953. }
  10954. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  10955. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10957. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10958. if !m.op.Is(OpUpdateOne) {
  10959. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10960. }
  10961. if m.id == nil || m.oldValue == nil {
  10962. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10963. }
  10964. oldValue, err := m.oldValue(ctx)
  10965. if err != nil {
  10966. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10967. }
  10968. return oldValue.CreatedAt, nil
  10969. }
  10970. // ResetCreatedAt resets all changes to the "created_at" field.
  10971. func (m *SopStageMutation) ResetCreatedAt() {
  10972. m.created_at = nil
  10973. }
  10974. // SetUpdatedAt sets the "updated_at" field.
  10975. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  10976. m.updated_at = &t
  10977. }
  10978. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10979. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  10980. v := m.updated_at
  10981. if v == nil {
  10982. return
  10983. }
  10984. return *v, true
  10985. }
  10986. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  10987. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10988. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10989. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10990. if !m.op.Is(OpUpdateOne) {
  10991. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10992. }
  10993. if m.id == nil || m.oldValue == nil {
  10994. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10995. }
  10996. oldValue, err := m.oldValue(ctx)
  10997. if err != nil {
  10998. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10999. }
  11000. return oldValue.UpdatedAt, nil
  11001. }
  11002. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11003. func (m *SopStageMutation) ResetUpdatedAt() {
  11004. m.updated_at = nil
  11005. }
  11006. // SetStatus sets the "status" field.
  11007. func (m *SopStageMutation) SetStatus(u uint8) {
  11008. m.status = &u
  11009. m.addstatus = nil
  11010. }
  11011. // Status returns the value of the "status" field in the mutation.
  11012. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  11013. v := m.status
  11014. if v == nil {
  11015. return
  11016. }
  11017. return *v, true
  11018. }
  11019. // OldStatus returns the old "status" field's value of the SopStage entity.
  11020. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11021. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11022. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11023. if !m.op.Is(OpUpdateOne) {
  11024. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11025. }
  11026. if m.id == nil || m.oldValue == nil {
  11027. return v, errors.New("OldStatus requires an ID field in the mutation")
  11028. }
  11029. oldValue, err := m.oldValue(ctx)
  11030. if err != nil {
  11031. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11032. }
  11033. return oldValue.Status, nil
  11034. }
  11035. // AddStatus adds u to the "status" field.
  11036. func (m *SopStageMutation) AddStatus(u int8) {
  11037. if m.addstatus != nil {
  11038. *m.addstatus += u
  11039. } else {
  11040. m.addstatus = &u
  11041. }
  11042. }
  11043. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11044. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  11045. v := m.addstatus
  11046. if v == nil {
  11047. return
  11048. }
  11049. return *v, true
  11050. }
  11051. // ClearStatus clears the value of the "status" field.
  11052. func (m *SopStageMutation) ClearStatus() {
  11053. m.status = nil
  11054. m.addstatus = nil
  11055. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  11056. }
  11057. // StatusCleared returns if the "status" field was cleared in this mutation.
  11058. func (m *SopStageMutation) StatusCleared() bool {
  11059. _, ok := m.clearedFields[sopstage.FieldStatus]
  11060. return ok
  11061. }
  11062. // ResetStatus resets all changes to the "status" field.
  11063. func (m *SopStageMutation) ResetStatus() {
  11064. m.status = nil
  11065. m.addstatus = nil
  11066. delete(m.clearedFields, sopstage.FieldStatus)
  11067. }
  11068. // SetDeletedAt sets the "deleted_at" field.
  11069. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  11070. m.deleted_at = &t
  11071. }
  11072. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11073. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  11074. v := m.deleted_at
  11075. if v == nil {
  11076. return
  11077. }
  11078. return *v, true
  11079. }
  11080. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  11081. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11083. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11084. if !m.op.Is(OpUpdateOne) {
  11085. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11086. }
  11087. if m.id == nil || m.oldValue == nil {
  11088. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11089. }
  11090. oldValue, err := m.oldValue(ctx)
  11091. if err != nil {
  11092. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11093. }
  11094. return oldValue.DeletedAt, nil
  11095. }
  11096. // ClearDeletedAt clears the value of the "deleted_at" field.
  11097. func (m *SopStageMutation) ClearDeletedAt() {
  11098. m.deleted_at = nil
  11099. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  11100. }
  11101. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11102. func (m *SopStageMutation) DeletedAtCleared() bool {
  11103. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  11104. return ok
  11105. }
  11106. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11107. func (m *SopStageMutation) ResetDeletedAt() {
  11108. m.deleted_at = nil
  11109. delete(m.clearedFields, sopstage.FieldDeletedAt)
  11110. }
  11111. // SetTaskID sets the "task_id" field.
  11112. func (m *SopStageMutation) SetTaskID(u uint64) {
  11113. m.sop_task = &u
  11114. }
  11115. // TaskID returns the value of the "task_id" field in the mutation.
  11116. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  11117. v := m.sop_task
  11118. if v == nil {
  11119. return
  11120. }
  11121. return *v, true
  11122. }
  11123. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  11124. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11125. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11126. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  11127. if !m.op.Is(OpUpdateOne) {
  11128. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  11129. }
  11130. if m.id == nil || m.oldValue == nil {
  11131. return v, errors.New("OldTaskID requires an ID field in the mutation")
  11132. }
  11133. oldValue, err := m.oldValue(ctx)
  11134. if err != nil {
  11135. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  11136. }
  11137. return oldValue.TaskID, nil
  11138. }
  11139. // ResetTaskID resets all changes to the "task_id" field.
  11140. func (m *SopStageMutation) ResetTaskID() {
  11141. m.sop_task = nil
  11142. }
  11143. // SetName sets the "name" field.
  11144. func (m *SopStageMutation) SetName(s string) {
  11145. m.name = &s
  11146. }
  11147. // Name returns the value of the "name" field in the mutation.
  11148. func (m *SopStageMutation) Name() (r string, exists bool) {
  11149. v := m.name
  11150. if v == nil {
  11151. return
  11152. }
  11153. return *v, true
  11154. }
  11155. // OldName returns the old "name" field's value of the SopStage entity.
  11156. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11158. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  11159. if !m.op.Is(OpUpdateOne) {
  11160. return v, errors.New("OldName is only allowed on UpdateOne operations")
  11161. }
  11162. if m.id == nil || m.oldValue == nil {
  11163. return v, errors.New("OldName requires an ID field in the mutation")
  11164. }
  11165. oldValue, err := m.oldValue(ctx)
  11166. if err != nil {
  11167. return v, fmt.Errorf("querying old value for OldName: %w", err)
  11168. }
  11169. return oldValue.Name, nil
  11170. }
  11171. // ResetName resets all changes to the "name" field.
  11172. func (m *SopStageMutation) ResetName() {
  11173. m.name = nil
  11174. }
  11175. // SetConditionType sets the "condition_type" field.
  11176. func (m *SopStageMutation) SetConditionType(i int) {
  11177. m.condition_type = &i
  11178. m.addcondition_type = nil
  11179. }
  11180. // ConditionType returns the value of the "condition_type" field in the mutation.
  11181. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  11182. v := m.condition_type
  11183. if v == nil {
  11184. return
  11185. }
  11186. return *v, true
  11187. }
  11188. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  11189. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11191. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  11192. if !m.op.Is(OpUpdateOne) {
  11193. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  11194. }
  11195. if m.id == nil || m.oldValue == nil {
  11196. return v, errors.New("OldConditionType requires an ID field in the mutation")
  11197. }
  11198. oldValue, err := m.oldValue(ctx)
  11199. if err != nil {
  11200. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  11201. }
  11202. return oldValue.ConditionType, nil
  11203. }
  11204. // AddConditionType adds i to the "condition_type" field.
  11205. func (m *SopStageMutation) AddConditionType(i int) {
  11206. if m.addcondition_type != nil {
  11207. *m.addcondition_type += i
  11208. } else {
  11209. m.addcondition_type = &i
  11210. }
  11211. }
  11212. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  11213. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  11214. v := m.addcondition_type
  11215. if v == nil {
  11216. return
  11217. }
  11218. return *v, true
  11219. }
  11220. // ResetConditionType resets all changes to the "condition_type" field.
  11221. func (m *SopStageMutation) ResetConditionType() {
  11222. m.condition_type = nil
  11223. m.addcondition_type = nil
  11224. }
  11225. // SetConditionOperator sets the "condition_operator" field.
  11226. func (m *SopStageMutation) SetConditionOperator(i int) {
  11227. m.condition_operator = &i
  11228. m.addcondition_operator = nil
  11229. }
  11230. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  11231. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  11232. v := m.condition_operator
  11233. if v == nil {
  11234. return
  11235. }
  11236. return *v, true
  11237. }
  11238. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  11239. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11241. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  11242. if !m.op.Is(OpUpdateOne) {
  11243. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  11244. }
  11245. if m.id == nil || m.oldValue == nil {
  11246. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  11247. }
  11248. oldValue, err := m.oldValue(ctx)
  11249. if err != nil {
  11250. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  11251. }
  11252. return oldValue.ConditionOperator, nil
  11253. }
  11254. // AddConditionOperator adds i to the "condition_operator" field.
  11255. func (m *SopStageMutation) AddConditionOperator(i int) {
  11256. if m.addcondition_operator != nil {
  11257. *m.addcondition_operator += i
  11258. } else {
  11259. m.addcondition_operator = &i
  11260. }
  11261. }
  11262. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  11263. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  11264. v := m.addcondition_operator
  11265. if v == nil {
  11266. return
  11267. }
  11268. return *v, true
  11269. }
  11270. // ResetConditionOperator resets all changes to the "condition_operator" field.
  11271. func (m *SopStageMutation) ResetConditionOperator() {
  11272. m.condition_operator = nil
  11273. m.addcondition_operator = nil
  11274. }
  11275. // SetConditionList sets the "condition_list" field.
  11276. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  11277. m.condition_list = &ct
  11278. m.appendcondition_list = nil
  11279. }
  11280. // ConditionList returns the value of the "condition_list" field in the mutation.
  11281. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  11282. v := m.condition_list
  11283. if v == nil {
  11284. return
  11285. }
  11286. return *v, true
  11287. }
  11288. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  11289. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11291. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  11292. if !m.op.Is(OpUpdateOne) {
  11293. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  11294. }
  11295. if m.id == nil || m.oldValue == nil {
  11296. return v, errors.New("OldConditionList requires an ID field in the mutation")
  11297. }
  11298. oldValue, err := m.oldValue(ctx)
  11299. if err != nil {
  11300. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  11301. }
  11302. return oldValue.ConditionList, nil
  11303. }
  11304. // AppendConditionList adds ct to the "condition_list" field.
  11305. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  11306. m.appendcondition_list = append(m.appendcondition_list, ct...)
  11307. }
  11308. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  11309. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  11310. if len(m.appendcondition_list) == 0 {
  11311. return nil, false
  11312. }
  11313. return m.appendcondition_list, true
  11314. }
  11315. // ResetConditionList resets all changes to the "condition_list" field.
  11316. func (m *SopStageMutation) ResetConditionList() {
  11317. m.condition_list = nil
  11318. m.appendcondition_list = nil
  11319. }
  11320. // SetActionMessage sets the "action_message" field.
  11321. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  11322. m.action_message = &ct
  11323. m.appendaction_message = nil
  11324. }
  11325. // ActionMessage returns the value of the "action_message" field in the mutation.
  11326. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  11327. v := m.action_message
  11328. if v == nil {
  11329. return
  11330. }
  11331. return *v, true
  11332. }
  11333. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  11334. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11336. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  11337. if !m.op.Is(OpUpdateOne) {
  11338. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  11339. }
  11340. if m.id == nil || m.oldValue == nil {
  11341. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  11342. }
  11343. oldValue, err := m.oldValue(ctx)
  11344. if err != nil {
  11345. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  11346. }
  11347. return oldValue.ActionMessage, nil
  11348. }
  11349. // AppendActionMessage adds ct to the "action_message" field.
  11350. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  11351. m.appendaction_message = append(m.appendaction_message, ct...)
  11352. }
  11353. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  11354. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  11355. if len(m.appendaction_message) == 0 {
  11356. return nil, false
  11357. }
  11358. return m.appendaction_message, true
  11359. }
  11360. // ClearActionMessage clears the value of the "action_message" field.
  11361. func (m *SopStageMutation) ClearActionMessage() {
  11362. m.action_message = nil
  11363. m.appendaction_message = nil
  11364. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  11365. }
  11366. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  11367. func (m *SopStageMutation) ActionMessageCleared() bool {
  11368. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  11369. return ok
  11370. }
  11371. // ResetActionMessage resets all changes to the "action_message" field.
  11372. func (m *SopStageMutation) ResetActionMessage() {
  11373. m.action_message = nil
  11374. m.appendaction_message = nil
  11375. delete(m.clearedFields, sopstage.FieldActionMessage)
  11376. }
  11377. // SetActionLabel sets the "action_label" field.
  11378. func (m *SopStageMutation) SetActionLabel(u []uint64) {
  11379. m.action_label = &u
  11380. m.appendaction_label = nil
  11381. }
  11382. // ActionLabel returns the value of the "action_label" field in the mutation.
  11383. func (m *SopStageMutation) ActionLabel() (r []uint64, exists bool) {
  11384. v := m.action_label
  11385. if v == nil {
  11386. return
  11387. }
  11388. return *v, true
  11389. }
  11390. // OldActionLabel returns the old "action_label" field's value of the SopStage entity.
  11391. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11393. func (m *SopStageMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  11394. if !m.op.Is(OpUpdateOne) {
  11395. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  11396. }
  11397. if m.id == nil || m.oldValue == nil {
  11398. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  11399. }
  11400. oldValue, err := m.oldValue(ctx)
  11401. if err != nil {
  11402. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  11403. }
  11404. return oldValue.ActionLabel, nil
  11405. }
  11406. // AppendActionLabel adds u to the "action_label" field.
  11407. func (m *SopStageMutation) AppendActionLabel(u []uint64) {
  11408. m.appendaction_label = append(m.appendaction_label, u...)
  11409. }
  11410. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  11411. func (m *SopStageMutation) AppendedActionLabel() ([]uint64, bool) {
  11412. if len(m.appendaction_label) == 0 {
  11413. return nil, false
  11414. }
  11415. return m.appendaction_label, true
  11416. }
  11417. // ClearActionLabel clears the value of the "action_label" field.
  11418. func (m *SopStageMutation) ClearActionLabel() {
  11419. m.action_label = nil
  11420. m.appendaction_label = nil
  11421. m.clearedFields[sopstage.FieldActionLabel] = struct{}{}
  11422. }
  11423. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  11424. func (m *SopStageMutation) ActionLabelCleared() bool {
  11425. _, ok := m.clearedFields[sopstage.FieldActionLabel]
  11426. return ok
  11427. }
  11428. // ResetActionLabel resets all changes to the "action_label" field.
  11429. func (m *SopStageMutation) ResetActionLabel() {
  11430. m.action_label = nil
  11431. m.appendaction_label = nil
  11432. delete(m.clearedFields, sopstage.FieldActionLabel)
  11433. }
  11434. // SetIndexSort sets the "index_sort" field.
  11435. func (m *SopStageMutation) SetIndexSort(i int) {
  11436. m.index_sort = &i
  11437. m.addindex_sort = nil
  11438. }
  11439. // IndexSort returns the value of the "index_sort" field in the mutation.
  11440. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  11441. v := m.index_sort
  11442. if v == nil {
  11443. return
  11444. }
  11445. return *v, true
  11446. }
  11447. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  11448. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11450. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  11451. if !m.op.Is(OpUpdateOne) {
  11452. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  11453. }
  11454. if m.id == nil || m.oldValue == nil {
  11455. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  11456. }
  11457. oldValue, err := m.oldValue(ctx)
  11458. if err != nil {
  11459. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  11460. }
  11461. return oldValue.IndexSort, nil
  11462. }
  11463. // AddIndexSort adds i to the "index_sort" field.
  11464. func (m *SopStageMutation) AddIndexSort(i int) {
  11465. if m.addindex_sort != nil {
  11466. *m.addindex_sort += i
  11467. } else {
  11468. m.addindex_sort = &i
  11469. }
  11470. }
  11471. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  11472. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  11473. v := m.addindex_sort
  11474. if v == nil {
  11475. return
  11476. }
  11477. return *v, true
  11478. }
  11479. // ClearIndexSort clears the value of the "index_sort" field.
  11480. func (m *SopStageMutation) ClearIndexSort() {
  11481. m.index_sort = nil
  11482. m.addindex_sort = nil
  11483. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  11484. }
  11485. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  11486. func (m *SopStageMutation) IndexSortCleared() bool {
  11487. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  11488. return ok
  11489. }
  11490. // ResetIndexSort resets all changes to the "index_sort" field.
  11491. func (m *SopStageMutation) ResetIndexSort() {
  11492. m.index_sort = nil
  11493. m.addindex_sort = nil
  11494. delete(m.clearedFields, sopstage.FieldIndexSort)
  11495. }
  11496. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  11497. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  11498. m.sop_task = &id
  11499. }
  11500. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  11501. func (m *SopStageMutation) ClearSopTask() {
  11502. m.clearedsop_task = true
  11503. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  11504. }
  11505. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  11506. func (m *SopStageMutation) SopTaskCleared() bool {
  11507. return m.clearedsop_task
  11508. }
  11509. // SopTaskID returns the "sop_task" edge ID in the mutation.
  11510. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  11511. if m.sop_task != nil {
  11512. return *m.sop_task, true
  11513. }
  11514. return
  11515. }
  11516. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  11517. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  11518. // SopTaskID instead. It exists only for internal usage by the builders.
  11519. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  11520. if id := m.sop_task; id != nil {
  11521. ids = append(ids, *id)
  11522. }
  11523. return
  11524. }
  11525. // ResetSopTask resets all changes to the "sop_task" edge.
  11526. func (m *SopStageMutation) ResetSopTask() {
  11527. m.sop_task = nil
  11528. m.clearedsop_task = false
  11529. }
  11530. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  11531. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  11532. if m.stage_nodes == nil {
  11533. m.stage_nodes = make(map[uint64]struct{})
  11534. }
  11535. for i := range ids {
  11536. m.stage_nodes[ids[i]] = struct{}{}
  11537. }
  11538. }
  11539. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  11540. func (m *SopStageMutation) ClearStageNodes() {
  11541. m.clearedstage_nodes = true
  11542. }
  11543. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  11544. func (m *SopStageMutation) StageNodesCleared() bool {
  11545. return m.clearedstage_nodes
  11546. }
  11547. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  11548. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  11549. if m.removedstage_nodes == nil {
  11550. m.removedstage_nodes = make(map[uint64]struct{})
  11551. }
  11552. for i := range ids {
  11553. delete(m.stage_nodes, ids[i])
  11554. m.removedstage_nodes[ids[i]] = struct{}{}
  11555. }
  11556. }
  11557. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  11558. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  11559. for id := range m.removedstage_nodes {
  11560. ids = append(ids, id)
  11561. }
  11562. return
  11563. }
  11564. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  11565. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  11566. for id := range m.stage_nodes {
  11567. ids = append(ids, id)
  11568. }
  11569. return
  11570. }
  11571. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  11572. func (m *SopStageMutation) ResetStageNodes() {
  11573. m.stage_nodes = nil
  11574. m.clearedstage_nodes = false
  11575. m.removedstage_nodes = nil
  11576. }
  11577. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  11578. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  11579. if m.stage_messages == nil {
  11580. m.stage_messages = make(map[uint64]struct{})
  11581. }
  11582. for i := range ids {
  11583. m.stage_messages[ids[i]] = struct{}{}
  11584. }
  11585. }
  11586. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  11587. func (m *SopStageMutation) ClearStageMessages() {
  11588. m.clearedstage_messages = true
  11589. }
  11590. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  11591. func (m *SopStageMutation) StageMessagesCleared() bool {
  11592. return m.clearedstage_messages
  11593. }
  11594. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  11595. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  11596. if m.removedstage_messages == nil {
  11597. m.removedstage_messages = make(map[uint64]struct{})
  11598. }
  11599. for i := range ids {
  11600. delete(m.stage_messages, ids[i])
  11601. m.removedstage_messages[ids[i]] = struct{}{}
  11602. }
  11603. }
  11604. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  11605. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  11606. for id := range m.removedstage_messages {
  11607. ids = append(ids, id)
  11608. }
  11609. return
  11610. }
  11611. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  11612. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  11613. for id := range m.stage_messages {
  11614. ids = append(ids, id)
  11615. }
  11616. return
  11617. }
  11618. // ResetStageMessages resets all changes to the "stage_messages" edge.
  11619. func (m *SopStageMutation) ResetStageMessages() {
  11620. m.stage_messages = nil
  11621. m.clearedstage_messages = false
  11622. m.removedstage_messages = nil
  11623. }
  11624. // Where appends a list predicates to the SopStageMutation builder.
  11625. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  11626. m.predicates = append(m.predicates, ps...)
  11627. }
  11628. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  11629. // users can use type-assertion to append predicates that do not depend on any generated package.
  11630. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  11631. p := make([]predicate.SopStage, len(ps))
  11632. for i := range ps {
  11633. p[i] = ps[i]
  11634. }
  11635. m.Where(p...)
  11636. }
  11637. // Op returns the operation name.
  11638. func (m *SopStageMutation) Op() Op {
  11639. return m.op
  11640. }
  11641. // SetOp allows setting the mutation operation.
  11642. func (m *SopStageMutation) SetOp(op Op) {
  11643. m.op = op
  11644. }
  11645. // Type returns the node type of this mutation (SopStage).
  11646. func (m *SopStageMutation) Type() string {
  11647. return m.typ
  11648. }
  11649. // Fields returns all fields that were changed during this mutation. Note that in
  11650. // order to get all numeric fields that were incremented/decremented, call
  11651. // AddedFields().
  11652. func (m *SopStageMutation) Fields() []string {
  11653. fields := make([]string, 0, 12)
  11654. if m.created_at != nil {
  11655. fields = append(fields, sopstage.FieldCreatedAt)
  11656. }
  11657. if m.updated_at != nil {
  11658. fields = append(fields, sopstage.FieldUpdatedAt)
  11659. }
  11660. if m.status != nil {
  11661. fields = append(fields, sopstage.FieldStatus)
  11662. }
  11663. if m.deleted_at != nil {
  11664. fields = append(fields, sopstage.FieldDeletedAt)
  11665. }
  11666. if m.sop_task != nil {
  11667. fields = append(fields, sopstage.FieldTaskID)
  11668. }
  11669. if m.name != nil {
  11670. fields = append(fields, sopstage.FieldName)
  11671. }
  11672. if m.condition_type != nil {
  11673. fields = append(fields, sopstage.FieldConditionType)
  11674. }
  11675. if m.condition_operator != nil {
  11676. fields = append(fields, sopstage.FieldConditionOperator)
  11677. }
  11678. if m.condition_list != nil {
  11679. fields = append(fields, sopstage.FieldConditionList)
  11680. }
  11681. if m.action_message != nil {
  11682. fields = append(fields, sopstage.FieldActionMessage)
  11683. }
  11684. if m.action_label != nil {
  11685. fields = append(fields, sopstage.FieldActionLabel)
  11686. }
  11687. if m.index_sort != nil {
  11688. fields = append(fields, sopstage.FieldIndexSort)
  11689. }
  11690. return fields
  11691. }
  11692. // Field returns the value of a field with the given name. The second boolean
  11693. // return value indicates that this field was not set, or was not defined in the
  11694. // schema.
  11695. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  11696. switch name {
  11697. case sopstage.FieldCreatedAt:
  11698. return m.CreatedAt()
  11699. case sopstage.FieldUpdatedAt:
  11700. return m.UpdatedAt()
  11701. case sopstage.FieldStatus:
  11702. return m.Status()
  11703. case sopstage.FieldDeletedAt:
  11704. return m.DeletedAt()
  11705. case sopstage.FieldTaskID:
  11706. return m.TaskID()
  11707. case sopstage.FieldName:
  11708. return m.Name()
  11709. case sopstage.FieldConditionType:
  11710. return m.ConditionType()
  11711. case sopstage.FieldConditionOperator:
  11712. return m.ConditionOperator()
  11713. case sopstage.FieldConditionList:
  11714. return m.ConditionList()
  11715. case sopstage.FieldActionMessage:
  11716. return m.ActionMessage()
  11717. case sopstage.FieldActionLabel:
  11718. return m.ActionLabel()
  11719. case sopstage.FieldIndexSort:
  11720. return m.IndexSort()
  11721. }
  11722. return nil, false
  11723. }
  11724. // OldField returns the old value of the field from the database. An error is
  11725. // returned if the mutation operation is not UpdateOne, or the query to the
  11726. // database failed.
  11727. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11728. switch name {
  11729. case sopstage.FieldCreatedAt:
  11730. return m.OldCreatedAt(ctx)
  11731. case sopstage.FieldUpdatedAt:
  11732. return m.OldUpdatedAt(ctx)
  11733. case sopstage.FieldStatus:
  11734. return m.OldStatus(ctx)
  11735. case sopstage.FieldDeletedAt:
  11736. return m.OldDeletedAt(ctx)
  11737. case sopstage.FieldTaskID:
  11738. return m.OldTaskID(ctx)
  11739. case sopstage.FieldName:
  11740. return m.OldName(ctx)
  11741. case sopstage.FieldConditionType:
  11742. return m.OldConditionType(ctx)
  11743. case sopstage.FieldConditionOperator:
  11744. return m.OldConditionOperator(ctx)
  11745. case sopstage.FieldConditionList:
  11746. return m.OldConditionList(ctx)
  11747. case sopstage.FieldActionMessage:
  11748. return m.OldActionMessage(ctx)
  11749. case sopstage.FieldActionLabel:
  11750. return m.OldActionLabel(ctx)
  11751. case sopstage.FieldIndexSort:
  11752. return m.OldIndexSort(ctx)
  11753. }
  11754. return nil, fmt.Errorf("unknown SopStage field %s", name)
  11755. }
  11756. // SetField sets the value of a field with the given name. It returns an error if
  11757. // the field is not defined in the schema, or if the type mismatched the field
  11758. // type.
  11759. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  11760. switch name {
  11761. case sopstage.FieldCreatedAt:
  11762. v, ok := value.(time.Time)
  11763. if !ok {
  11764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11765. }
  11766. m.SetCreatedAt(v)
  11767. return nil
  11768. case sopstage.FieldUpdatedAt:
  11769. v, ok := value.(time.Time)
  11770. if !ok {
  11771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11772. }
  11773. m.SetUpdatedAt(v)
  11774. return nil
  11775. case sopstage.FieldStatus:
  11776. v, ok := value.(uint8)
  11777. if !ok {
  11778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11779. }
  11780. m.SetStatus(v)
  11781. return nil
  11782. case sopstage.FieldDeletedAt:
  11783. v, ok := value.(time.Time)
  11784. if !ok {
  11785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11786. }
  11787. m.SetDeletedAt(v)
  11788. return nil
  11789. case sopstage.FieldTaskID:
  11790. v, ok := value.(uint64)
  11791. if !ok {
  11792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11793. }
  11794. m.SetTaskID(v)
  11795. return nil
  11796. case sopstage.FieldName:
  11797. v, ok := value.(string)
  11798. if !ok {
  11799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11800. }
  11801. m.SetName(v)
  11802. return nil
  11803. case sopstage.FieldConditionType:
  11804. v, ok := value.(int)
  11805. if !ok {
  11806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11807. }
  11808. m.SetConditionType(v)
  11809. return nil
  11810. case sopstage.FieldConditionOperator:
  11811. v, ok := value.(int)
  11812. if !ok {
  11813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11814. }
  11815. m.SetConditionOperator(v)
  11816. return nil
  11817. case sopstage.FieldConditionList:
  11818. v, ok := value.([]custom_types.Condition)
  11819. if !ok {
  11820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11821. }
  11822. m.SetConditionList(v)
  11823. return nil
  11824. case sopstage.FieldActionMessage:
  11825. v, ok := value.([]custom_types.Action)
  11826. if !ok {
  11827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11828. }
  11829. m.SetActionMessage(v)
  11830. return nil
  11831. case sopstage.FieldActionLabel:
  11832. v, ok := value.([]uint64)
  11833. if !ok {
  11834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11835. }
  11836. m.SetActionLabel(v)
  11837. return nil
  11838. case sopstage.FieldIndexSort:
  11839. v, ok := value.(int)
  11840. if !ok {
  11841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11842. }
  11843. m.SetIndexSort(v)
  11844. return nil
  11845. }
  11846. return fmt.Errorf("unknown SopStage field %s", name)
  11847. }
  11848. // AddedFields returns all numeric fields that were incremented/decremented during
  11849. // this mutation.
  11850. func (m *SopStageMutation) AddedFields() []string {
  11851. var fields []string
  11852. if m.addstatus != nil {
  11853. fields = append(fields, sopstage.FieldStatus)
  11854. }
  11855. if m.addcondition_type != nil {
  11856. fields = append(fields, sopstage.FieldConditionType)
  11857. }
  11858. if m.addcondition_operator != nil {
  11859. fields = append(fields, sopstage.FieldConditionOperator)
  11860. }
  11861. if m.addindex_sort != nil {
  11862. fields = append(fields, sopstage.FieldIndexSort)
  11863. }
  11864. return fields
  11865. }
  11866. // AddedField returns the numeric value that was incremented/decremented on a field
  11867. // with the given name. The second boolean return value indicates that this field
  11868. // was not set, or was not defined in the schema.
  11869. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  11870. switch name {
  11871. case sopstage.FieldStatus:
  11872. return m.AddedStatus()
  11873. case sopstage.FieldConditionType:
  11874. return m.AddedConditionType()
  11875. case sopstage.FieldConditionOperator:
  11876. return m.AddedConditionOperator()
  11877. case sopstage.FieldIndexSort:
  11878. return m.AddedIndexSort()
  11879. }
  11880. return nil, false
  11881. }
  11882. // AddField adds the value to the field with the given name. It returns an error if
  11883. // the field is not defined in the schema, or if the type mismatched the field
  11884. // type.
  11885. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  11886. switch name {
  11887. case sopstage.FieldStatus:
  11888. v, ok := value.(int8)
  11889. if !ok {
  11890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11891. }
  11892. m.AddStatus(v)
  11893. return nil
  11894. case sopstage.FieldConditionType:
  11895. v, ok := value.(int)
  11896. if !ok {
  11897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11898. }
  11899. m.AddConditionType(v)
  11900. return nil
  11901. case sopstage.FieldConditionOperator:
  11902. v, ok := value.(int)
  11903. if !ok {
  11904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11905. }
  11906. m.AddConditionOperator(v)
  11907. return nil
  11908. case sopstage.FieldIndexSort:
  11909. v, ok := value.(int)
  11910. if !ok {
  11911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11912. }
  11913. m.AddIndexSort(v)
  11914. return nil
  11915. }
  11916. return fmt.Errorf("unknown SopStage numeric field %s", name)
  11917. }
  11918. // ClearedFields returns all nullable fields that were cleared during this
  11919. // mutation.
  11920. func (m *SopStageMutation) ClearedFields() []string {
  11921. var fields []string
  11922. if m.FieldCleared(sopstage.FieldStatus) {
  11923. fields = append(fields, sopstage.FieldStatus)
  11924. }
  11925. if m.FieldCleared(sopstage.FieldDeletedAt) {
  11926. fields = append(fields, sopstage.FieldDeletedAt)
  11927. }
  11928. if m.FieldCleared(sopstage.FieldActionMessage) {
  11929. fields = append(fields, sopstage.FieldActionMessage)
  11930. }
  11931. if m.FieldCleared(sopstage.FieldActionLabel) {
  11932. fields = append(fields, sopstage.FieldActionLabel)
  11933. }
  11934. if m.FieldCleared(sopstage.FieldIndexSort) {
  11935. fields = append(fields, sopstage.FieldIndexSort)
  11936. }
  11937. return fields
  11938. }
  11939. // FieldCleared returns a boolean indicating if a field with the given name was
  11940. // cleared in this mutation.
  11941. func (m *SopStageMutation) FieldCleared(name string) bool {
  11942. _, ok := m.clearedFields[name]
  11943. return ok
  11944. }
  11945. // ClearField clears the value of the field with the given name. It returns an
  11946. // error if the field is not defined in the schema.
  11947. func (m *SopStageMutation) ClearField(name string) error {
  11948. switch name {
  11949. case sopstage.FieldStatus:
  11950. m.ClearStatus()
  11951. return nil
  11952. case sopstage.FieldDeletedAt:
  11953. m.ClearDeletedAt()
  11954. return nil
  11955. case sopstage.FieldActionMessage:
  11956. m.ClearActionMessage()
  11957. return nil
  11958. case sopstage.FieldActionLabel:
  11959. m.ClearActionLabel()
  11960. return nil
  11961. case sopstage.FieldIndexSort:
  11962. m.ClearIndexSort()
  11963. return nil
  11964. }
  11965. return fmt.Errorf("unknown SopStage nullable field %s", name)
  11966. }
  11967. // ResetField resets all changes in the mutation for the field with the given name.
  11968. // It returns an error if the field is not defined in the schema.
  11969. func (m *SopStageMutation) ResetField(name string) error {
  11970. switch name {
  11971. case sopstage.FieldCreatedAt:
  11972. m.ResetCreatedAt()
  11973. return nil
  11974. case sopstage.FieldUpdatedAt:
  11975. m.ResetUpdatedAt()
  11976. return nil
  11977. case sopstage.FieldStatus:
  11978. m.ResetStatus()
  11979. return nil
  11980. case sopstage.FieldDeletedAt:
  11981. m.ResetDeletedAt()
  11982. return nil
  11983. case sopstage.FieldTaskID:
  11984. m.ResetTaskID()
  11985. return nil
  11986. case sopstage.FieldName:
  11987. m.ResetName()
  11988. return nil
  11989. case sopstage.FieldConditionType:
  11990. m.ResetConditionType()
  11991. return nil
  11992. case sopstage.FieldConditionOperator:
  11993. m.ResetConditionOperator()
  11994. return nil
  11995. case sopstage.FieldConditionList:
  11996. m.ResetConditionList()
  11997. return nil
  11998. case sopstage.FieldActionMessage:
  11999. m.ResetActionMessage()
  12000. return nil
  12001. case sopstage.FieldActionLabel:
  12002. m.ResetActionLabel()
  12003. return nil
  12004. case sopstage.FieldIndexSort:
  12005. m.ResetIndexSort()
  12006. return nil
  12007. }
  12008. return fmt.Errorf("unknown SopStage field %s", name)
  12009. }
  12010. // AddedEdges returns all edge names that were set/added in this mutation.
  12011. func (m *SopStageMutation) AddedEdges() []string {
  12012. edges := make([]string, 0, 3)
  12013. if m.sop_task != nil {
  12014. edges = append(edges, sopstage.EdgeSopTask)
  12015. }
  12016. if m.stage_nodes != nil {
  12017. edges = append(edges, sopstage.EdgeStageNodes)
  12018. }
  12019. if m.stage_messages != nil {
  12020. edges = append(edges, sopstage.EdgeStageMessages)
  12021. }
  12022. return edges
  12023. }
  12024. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12025. // name in this mutation.
  12026. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  12027. switch name {
  12028. case sopstage.EdgeSopTask:
  12029. if id := m.sop_task; id != nil {
  12030. return []ent.Value{*id}
  12031. }
  12032. case sopstage.EdgeStageNodes:
  12033. ids := make([]ent.Value, 0, len(m.stage_nodes))
  12034. for id := range m.stage_nodes {
  12035. ids = append(ids, id)
  12036. }
  12037. return ids
  12038. case sopstage.EdgeStageMessages:
  12039. ids := make([]ent.Value, 0, len(m.stage_messages))
  12040. for id := range m.stage_messages {
  12041. ids = append(ids, id)
  12042. }
  12043. return ids
  12044. }
  12045. return nil
  12046. }
  12047. // RemovedEdges returns all edge names that were removed in this mutation.
  12048. func (m *SopStageMutation) RemovedEdges() []string {
  12049. edges := make([]string, 0, 3)
  12050. if m.removedstage_nodes != nil {
  12051. edges = append(edges, sopstage.EdgeStageNodes)
  12052. }
  12053. if m.removedstage_messages != nil {
  12054. edges = append(edges, sopstage.EdgeStageMessages)
  12055. }
  12056. return edges
  12057. }
  12058. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12059. // the given name in this mutation.
  12060. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  12061. switch name {
  12062. case sopstage.EdgeStageNodes:
  12063. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  12064. for id := range m.removedstage_nodes {
  12065. ids = append(ids, id)
  12066. }
  12067. return ids
  12068. case sopstage.EdgeStageMessages:
  12069. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  12070. for id := range m.removedstage_messages {
  12071. ids = append(ids, id)
  12072. }
  12073. return ids
  12074. }
  12075. return nil
  12076. }
  12077. // ClearedEdges returns all edge names that were cleared in this mutation.
  12078. func (m *SopStageMutation) ClearedEdges() []string {
  12079. edges := make([]string, 0, 3)
  12080. if m.clearedsop_task {
  12081. edges = append(edges, sopstage.EdgeSopTask)
  12082. }
  12083. if m.clearedstage_nodes {
  12084. edges = append(edges, sopstage.EdgeStageNodes)
  12085. }
  12086. if m.clearedstage_messages {
  12087. edges = append(edges, sopstage.EdgeStageMessages)
  12088. }
  12089. return edges
  12090. }
  12091. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12092. // was cleared in this mutation.
  12093. func (m *SopStageMutation) EdgeCleared(name string) bool {
  12094. switch name {
  12095. case sopstage.EdgeSopTask:
  12096. return m.clearedsop_task
  12097. case sopstage.EdgeStageNodes:
  12098. return m.clearedstage_nodes
  12099. case sopstage.EdgeStageMessages:
  12100. return m.clearedstage_messages
  12101. }
  12102. return false
  12103. }
  12104. // ClearEdge clears the value of the edge with the given name. It returns an error
  12105. // if that edge is not defined in the schema.
  12106. func (m *SopStageMutation) ClearEdge(name string) error {
  12107. switch name {
  12108. case sopstage.EdgeSopTask:
  12109. m.ClearSopTask()
  12110. return nil
  12111. }
  12112. return fmt.Errorf("unknown SopStage unique edge %s", name)
  12113. }
  12114. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12115. // It returns an error if the edge is not defined in the schema.
  12116. func (m *SopStageMutation) ResetEdge(name string) error {
  12117. switch name {
  12118. case sopstage.EdgeSopTask:
  12119. m.ResetSopTask()
  12120. return nil
  12121. case sopstage.EdgeStageNodes:
  12122. m.ResetStageNodes()
  12123. return nil
  12124. case sopstage.EdgeStageMessages:
  12125. m.ResetStageMessages()
  12126. return nil
  12127. }
  12128. return fmt.Errorf("unknown SopStage edge %s", name)
  12129. }
  12130. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  12131. type SopTaskMutation struct {
  12132. config
  12133. op Op
  12134. typ string
  12135. id *uint64
  12136. created_at *time.Time
  12137. updated_at *time.Time
  12138. status *uint8
  12139. addstatus *int8
  12140. deleted_at *time.Time
  12141. name *string
  12142. bot_wxid_list *[]string
  12143. appendbot_wxid_list []string
  12144. _type *int
  12145. add_type *int
  12146. plan_start_time *time.Time
  12147. plan_end_time *time.Time
  12148. creator_id *string
  12149. organization_id *uint64
  12150. addorganization_id *int64
  12151. clearedFields map[string]struct{}
  12152. task_stages map[uint64]struct{}
  12153. removedtask_stages map[uint64]struct{}
  12154. clearedtask_stages bool
  12155. done bool
  12156. oldValue func(context.Context) (*SopTask, error)
  12157. predicates []predicate.SopTask
  12158. }
  12159. var _ ent.Mutation = (*SopTaskMutation)(nil)
  12160. // soptaskOption allows management of the mutation configuration using functional options.
  12161. type soptaskOption func(*SopTaskMutation)
  12162. // newSopTaskMutation creates new mutation for the SopTask entity.
  12163. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  12164. m := &SopTaskMutation{
  12165. config: c,
  12166. op: op,
  12167. typ: TypeSopTask,
  12168. clearedFields: make(map[string]struct{}),
  12169. }
  12170. for _, opt := range opts {
  12171. opt(m)
  12172. }
  12173. return m
  12174. }
  12175. // withSopTaskID sets the ID field of the mutation.
  12176. func withSopTaskID(id uint64) soptaskOption {
  12177. return func(m *SopTaskMutation) {
  12178. var (
  12179. err error
  12180. once sync.Once
  12181. value *SopTask
  12182. )
  12183. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  12184. once.Do(func() {
  12185. if m.done {
  12186. err = errors.New("querying old values post mutation is not allowed")
  12187. } else {
  12188. value, err = m.Client().SopTask.Get(ctx, id)
  12189. }
  12190. })
  12191. return value, err
  12192. }
  12193. m.id = &id
  12194. }
  12195. }
  12196. // withSopTask sets the old SopTask of the mutation.
  12197. func withSopTask(node *SopTask) soptaskOption {
  12198. return func(m *SopTaskMutation) {
  12199. m.oldValue = func(context.Context) (*SopTask, error) {
  12200. return node, nil
  12201. }
  12202. m.id = &node.ID
  12203. }
  12204. }
  12205. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12206. // executed in a transaction (ent.Tx), a transactional client is returned.
  12207. func (m SopTaskMutation) Client() *Client {
  12208. client := &Client{config: m.config}
  12209. client.init()
  12210. return client
  12211. }
  12212. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12213. // it returns an error otherwise.
  12214. func (m SopTaskMutation) Tx() (*Tx, error) {
  12215. if _, ok := m.driver.(*txDriver); !ok {
  12216. return nil, errors.New("ent: mutation is not running in a transaction")
  12217. }
  12218. tx := &Tx{config: m.config}
  12219. tx.init()
  12220. return tx, nil
  12221. }
  12222. // SetID sets the value of the id field. Note that this
  12223. // operation is only accepted on creation of SopTask entities.
  12224. func (m *SopTaskMutation) SetID(id uint64) {
  12225. m.id = &id
  12226. }
  12227. // ID returns the ID value in the mutation. Note that the ID is only available
  12228. // if it was provided to the builder or after it was returned from the database.
  12229. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  12230. if m.id == nil {
  12231. return
  12232. }
  12233. return *m.id, true
  12234. }
  12235. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12236. // That means, if the mutation is applied within a transaction with an isolation level such
  12237. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12238. // or updated by the mutation.
  12239. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  12240. switch {
  12241. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12242. id, exists := m.ID()
  12243. if exists {
  12244. return []uint64{id}, nil
  12245. }
  12246. fallthrough
  12247. case m.op.Is(OpUpdate | OpDelete):
  12248. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  12249. default:
  12250. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12251. }
  12252. }
  12253. // SetCreatedAt sets the "created_at" field.
  12254. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  12255. m.created_at = &t
  12256. }
  12257. // CreatedAt returns the value of the "created_at" field in the mutation.
  12258. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  12259. v := m.created_at
  12260. if v == nil {
  12261. return
  12262. }
  12263. return *v, true
  12264. }
  12265. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  12266. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12268. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12269. if !m.op.Is(OpUpdateOne) {
  12270. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12271. }
  12272. if m.id == nil || m.oldValue == nil {
  12273. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12274. }
  12275. oldValue, err := m.oldValue(ctx)
  12276. if err != nil {
  12277. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12278. }
  12279. return oldValue.CreatedAt, nil
  12280. }
  12281. // ResetCreatedAt resets all changes to the "created_at" field.
  12282. func (m *SopTaskMutation) ResetCreatedAt() {
  12283. m.created_at = nil
  12284. }
  12285. // SetUpdatedAt sets the "updated_at" field.
  12286. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  12287. m.updated_at = &t
  12288. }
  12289. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12290. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  12291. v := m.updated_at
  12292. if v == nil {
  12293. return
  12294. }
  12295. return *v, true
  12296. }
  12297. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  12298. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12300. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12301. if !m.op.Is(OpUpdateOne) {
  12302. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12303. }
  12304. if m.id == nil || m.oldValue == nil {
  12305. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12306. }
  12307. oldValue, err := m.oldValue(ctx)
  12308. if err != nil {
  12309. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12310. }
  12311. return oldValue.UpdatedAt, nil
  12312. }
  12313. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12314. func (m *SopTaskMutation) ResetUpdatedAt() {
  12315. m.updated_at = nil
  12316. }
  12317. // SetStatus sets the "status" field.
  12318. func (m *SopTaskMutation) SetStatus(u uint8) {
  12319. m.status = &u
  12320. m.addstatus = nil
  12321. }
  12322. // Status returns the value of the "status" field in the mutation.
  12323. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  12324. v := m.status
  12325. if v == nil {
  12326. return
  12327. }
  12328. return *v, true
  12329. }
  12330. // OldStatus returns the old "status" field's value of the SopTask entity.
  12331. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12333. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12334. if !m.op.Is(OpUpdateOne) {
  12335. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12336. }
  12337. if m.id == nil || m.oldValue == nil {
  12338. return v, errors.New("OldStatus requires an ID field in the mutation")
  12339. }
  12340. oldValue, err := m.oldValue(ctx)
  12341. if err != nil {
  12342. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12343. }
  12344. return oldValue.Status, nil
  12345. }
  12346. // AddStatus adds u to the "status" field.
  12347. func (m *SopTaskMutation) AddStatus(u int8) {
  12348. if m.addstatus != nil {
  12349. *m.addstatus += u
  12350. } else {
  12351. m.addstatus = &u
  12352. }
  12353. }
  12354. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12355. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  12356. v := m.addstatus
  12357. if v == nil {
  12358. return
  12359. }
  12360. return *v, true
  12361. }
  12362. // ClearStatus clears the value of the "status" field.
  12363. func (m *SopTaskMutation) ClearStatus() {
  12364. m.status = nil
  12365. m.addstatus = nil
  12366. m.clearedFields[soptask.FieldStatus] = struct{}{}
  12367. }
  12368. // StatusCleared returns if the "status" field was cleared in this mutation.
  12369. func (m *SopTaskMutation) StatusCleared() bool {
  12370. _, ok := m.clearedFields[soptask.FieldStatus]
  12371. return ok
  12372. }
  12373. // ResetStatus resets all changes to the "status" field.
  12374. func (m *SopTaskMutation) ResetStatus() {
  12375. m.status = nil
  12376. m.addstatus = nil
  12377. delete(m.clearedFields, soptask.FieldStatus)
  12378. }
  12379. // SetDeletedAt sets the "deleted_at" field.
  12380. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  12381. m.deleted_at = &t
  12382. }
  12383. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12384. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  12385. v := m.deleted_at
  12386. if v == nil {
  12387. return
  12388. }
  12389. return *v, true
  12390. }
  12391. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  12392. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12394. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12395. if !m.op.Is(OpUpdateOne) {
  12396. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12397. }
  12398. if m.id == nil || m.oldValue == nil {
  12399. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12400. }
  12401. oldValue, err := m.oldValue(ctx)
  12402. if err != nil {
  12403. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12404. }
  12405. return oldValue.DeletedAt, nil
  12406. }
  12407. // ClearDeletedAt clears the value of the "deleted_at" field.
  12408. func (m *SopTaskMutation) ClearDeletedAt() {
  12409. m.deleted_at = nil
  12410. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  12411. }
  12412. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12413. func (m *SopTaskMutation) DeletedAtCleared() bool {
  12414. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  12415. return ok
  12416. }
  12417. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12418. func (m *SopTaskMutation) ResetDeletedAt() {
  12419. m.deleted_at = nil
  12420. delete(m.clearedFields, soptask.FieldDeletedAt)
  12421. }
  12422. // SetName sets the "name" field.
  12423. func (m *SopTaskMutation) SetName(s string) {
  12424. m.name = &s
  12425. }
  12426. // Name returns the value of the "name" field in the mutation.
  12427. func (m *SopTaskMutation) Name() (r string, exists bool) {
  12428. v := m.name
  12429. if v == nil {
  12430. return
  12431. }
  12432. return *v, true
  12433. }
  12434. // OldName returns the old "name" field's value of the SopTask entity.
  12435. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12437. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  12438. if !m.op.Is(OpUpdateOne) {
  12439. return v, errors.New("OldName is only allowed on UpdateOne operations")
  12440. }
  12441. if m.id == nil || m.oldValue == nil {
  12442. return v, errors.New("OldName requires an ID field in the mutation")
  12443. }
  12444. oldValue, err := m.oldValue(ctx)
  12445. if err != nil {
  12446. return v, fmt.Errorf("querying old value for OldName: %w", err)
  12447. }
  12448. return oldValue.Name, nil
  12449. }
  12450. // ResetName resets all changes to the "name" field.
  12451. func (m *SopTaskMutation) ResetName() {
  12452. m.name = nil
  12453. }
  12454. // SetBotWxidList sets the "bot_wxid_list" field.
  12455. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  12456. m.bot_wxid_list = &s
  12457. m.appendbot_wxid_list = nil
  12458. }
  12459. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  12460. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  12461. v := m.bot_wxid_list
  12462. if v == nil {
  12463. return
  12464. }
  12465. return *v, true
  12466. }
  12467. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  12468. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12470. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  12471. if !m.op.Is(OpUpdateOne) {
  12472. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  12473. }
  12474. if m.id == nil || m.oldValue == nil {
  12475. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  12476. }
  12477. oldValue, err := m.oldValue(ctx)
  12478. if err != nil {
  12479. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  12480. }
  12481. return oldValue.BotWxidList, nil
  12482. }
  12483. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  12484. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  12485. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  12486. }
  12487. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  12488. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  12489. if len(m.appendbot_wxid_list) == 0 {
  12490. return nil, false
  12491. }
  12492. return m.appendbot_wxid_list, true
  12493. }
  12494. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  12495. func (m *SopTaskMutation) ClearBotWxidList() {
  12496. m.bot_wxid_list = nil
  12497. m.appendbot_wxid_list = nil
  12498. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  12499. }
  12500. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  12501. func (m *SopTaskMutation) BotWxidListCleared() bool {
  12502. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  12503. return ok
  12504. }
  12505. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  12506. func (m *SopTaskMutation) ResetBotWxidList() {
  12507. m.bot_wxid_list = nil
  12508. m.appendbot_wxid_list = nil
  12509. delete(m.clearedFields, soptask.FieldBotWxidList)
  12510. }
  12511. // SetType sets the "type" field.
  12512. func (m *SopTaskMutation) SetType(i int) {
  12513. m._type = &i
  12514. m.add_type = nil
  12515. }
  12516. // GetType returns the value of the "type" field in the mutation.
  12517. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  12518. v := m._type
  12519. if v == nil {
  12520. return
  12521. }
  12522. return *v, true
  12523. }
  12524. // OldType returns the old "type" field's value of the SopTask entity.
  12525. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12527. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  12528. if !m.op.Is(OpUpdateOne) {
  12529. return v, errors.New("OldType is only allowed on UpdateOne operations")
  12530. }
  12531. if m.id == nil || m.oldValue == nil {
  12532. return v, errors.New("OldType requires an ID field in the mutation")
  12533. }
  12534. oldValue, err := m.oldValue(ctx)
  12535. if err != nil {
  12536. return v, fmt.Errorf("querying old value for OldType: %w", err)
  12537. }
  12538. return oldValue.Type, nil
  12539. }
  12540. // AddType adds i to the "type" field.
  12541. func (m *SopTaskMutation) AddType(i int) {
  12542. if m.add_type != nil {
  12543. *m.add_type += i
  12544. } else {
  12545. m.add_type = &i
  12546. }
  12547. }
  12548. // AddedType returns the value that was added to the "type" field in this mutation.
  12549. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  12550. v := m.add_type
  12551. if v == nil {
  12552. return
  12553. }
  12554. return *v, true
  12555. }
  12556. // ResetType resets all changes to the "type" field.
  12557. func (m *SopTaskMutation) ResetType() {
  12558. m._type = nil
  12559. m.add_type = nil
  12560. }
  12561. // SetPlanStartTime sets the "plan_start_time" field.
  12562. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  12563. m.plan_start_time = &t
  12564. }
  12565. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  12566. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  12567. v := m.plan_start_time
  12568. if v == nil {
  12569. return
  12570. }
  12571. return *v, true
  12572. }
  12573. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  12574. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12576. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  12577. if !m.op.Is(OpUpdateOne) {
  12578. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  12579. }
  12580. if m.id == nil || m.oldValue == nil {
  12581. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  12582. }
  12583. oldValue, err := m.oldValue(ctx)
  12584. if err != nil {
  12585. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  12586. }
  12587. return oldValue.PlanStartTime, nil
  12588. }
  12589. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  12590. func (m *SopTaskMutation) ClearPlanStartTime() {
  12591. m.plan_start_time = nil
  12592. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  12593. }
  12594. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  12595. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  12596. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  12597. return ok
  12598. }
  12599. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  12600. func (m *SopTaskMutation) ResetPlanStartTime() {
  12601. m.plan_start_time = nil
  12602. delete(m.clearedFields, soptask.FieldPlanStartTime)
  12603. }
  12604. // SetPlanEndTime sets the "plan_end_time" field.
  12605. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  12606. m.plan_end_time = &t
  12607. }
  12608. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  12609. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  12610. v := m.plan_end_time
  12611. if v == nil {
  12612. return
  12613. }
  12614. return *v, true
  12615. }
  12616. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  12617. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12619. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  12620. if !m.op.Is(OpUpdateOne) {
  12621. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  12622. }
  12623. if m.id == nil || m.oldValue == nil {
  12624. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  12625. }
  12626. oldValue, err := m.oldValue(ctx)
  12627. if err != nil {
  12628. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  12629. }
  12630. return oldValue.PlanEndTime, nil
  12631. }
  12632. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  12633. func (m *SopTaskMutation) ClearPlanEndTime() {
  12634. m.plan_end_time = nil
  12635. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  12636. }
  12637. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  12638. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  12639. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  12640. return ok
  12641. }
  12642. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  12643. func (m *SopTaskMutation) ResetPlanEndTime() {
  12644. m.plan_end_time = nil
  12645. delete(m.clearedFields, soptask.FieldPlanEndTime)
  12646. }
  12647. // SetCreatorID sets the "creator_id" field.
  12648. func (m *SopTaskMutation) SetCreatorID(s string) {
  12649. m.creator_id = &s
  12650. }
  12651. // CreatorID returns the value of the "creator_id" field in the mutation.
  12652. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  12653. v := m.creator_id
  12654. if v == nil {
  12655. return
  12656. }
  12657. return *v, true
  12658. }
  12659. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  12660. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12662. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  12663. if !m.op.Is(OpUpdateOne) {
  12664. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  12665. }
  12666. if m.id == nil || m.oldValue == nil {
  12667. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  12668. }
  12669. oldValue, err := m.oldValue(ctx)
  12670. if err != nil {
  12671. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  12672. }
  12673. return oldValue.CreatorID, nil
  12674. }
  12675. // ClearCreatorID clears the value of the "creator_id" field.
  12676. func (m *SopTaskMutation) ClearCreatorID() {
  12677. m.creator_id = nil
  12678. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  12679. }
  12680. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  12681. func (m *SopTaskMutation) CreatorIDCleared() bool {
  12682. _, ok := m.clearedFields[soptask.FieldCreatorID]
  12683. return ok
  12684. }
  12685. // ResetCreatorID resets all changes to the "creator_id" field.
  12686. func (m *SopTaskMutation) ResetCreatorID() {
  12687. m.creator_id = nil
  12688. delete(m.clearedFields, soptask.FieldCreatorID)
  12689. }
  12690. // SetOrganizationID sets the "organization_id" field.
  12691. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  12692. m.organization_id = &u
  12693. m.addorganization_id = nil
  12694. }
  12695. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12696. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  12697. v := m.organization_id
  12698. if v == nil {
  12699. return
  12700. }
  12701. return *v, true
  12702. }
  12703. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  12704. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12705. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12706. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12707. if !m.op.Is(OpUpdateOne) {
  12708. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12709. }
  12710. if m.id == nil || m.oldValue == nil {
  12711. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12712. }
  12713. oldValue, err := m.oldValue(ctx)
  12714. if err != nil {
  12715. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12716. }
  12717. return oldValue.OrganizationID, nil
  12718. }
  12719. // AddOrganizationID adds u to the "organization_id" field.
  12720. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  12721. if m.addorganization_id != nil {
  12722. *m.addorganization_id += u
  12723. } else {
  12724. m.addorganization_id = &u
  12725. }
  12726. }
  12727. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12728. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  12729. v := m.addorganization_id
  12730. if v == nil {
  12731. return
  12732. }
  12733. return *v, true
  12734. }
  12735. // ClearOrganizationID clears the value of the "organization_id" field.
  12736. func (m *SopTaskMutation) ClearOrganizationID() {
  12737. m.organization_id = nil
  12738. m.addorganization_id = nil
  12739. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  12740. }
  12741. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12742. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  12743. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  12744. return ok
  12745. }
  12746. // ResetOrganizationID resets all changes to the "organization_id" field.
  12747. func (m *SopTaskMutation) ResetOrganizationID() {
  12748. m.organization_id = nil
  12749. m.addorganization_id = nil
  12750. delete(m.clearedFields, soptask.FieldOrganizationID)
  12751. }
  12752. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  12753. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  12754. if m.task_stages == nil {
  12755. m.task_stages = make(map[uint64]struct{})
  12756. }
  12757. for i := range ids {
  12758. m.task_stages[ids[i]] = struct{}{}
  12759. }
  12760. }
  12761. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  12762. func (m *SopTaskMutation) ClearTaskStages() {
  12763. m.clearedtask_stages = true
  12764. }
  12765. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  12766. func (m *SopTaskMutation) TaskStagesCleared() bool {
  12767. return m.clearedtask_stages
  12768. }
  12769. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  12770. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  12771. if m.removedtask_stages == nil {
  12772. m.removedtask_stages = make(map[uint64]struct{})
  12773. }
  12774. for i := range ids {
  12775. delete(m.task_stages, ids[i])
  12776. m.removedtask_stages[ids[i]] = struct{}{}
  12777. }
  12778. }
  12779. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  12780. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  12781. for id := range m.removedtask_stages {
  12782. ids = append(ids, id)
  12783. }
  12784. return
  12785. }
  12786. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  12787. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  12788. for id := range m.task_stages {
  12789. ids = append(ids, id)
  12790. }
  12791. return
  12792. }
  12793. // ResetTaskStages resets all changes to the "task_stages" edge.
  12794. func (m *SopTaskMutation) ResetTaskStages() {
  12795. m.task_stages = nil
  12796. m.clearedtask_stages = false
  12797. m.removedtask_stages = nil
  12798. }
  12799. // Where appends a list predicates to the SopTaskMutation builder.
  12800. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  12801. m.predicates = append(m.predicates, ps...)
  12802. }
  12803. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  12804. // users can use type-assertion to append predicates that do not depend on any generated package.
  12805. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  12806. p := make([]predicate.SopTask, len(ps))
  12807. for i := range ps {
  12808. p[i] = ps[i]
  12809. }
  12810. m.Where(p...)
  12811. }
  12812. // Op returns the operation name.
  12813. func (m *SopTaskMutation) Op() Op {
  12814. return m.op
  12815. }
  12816. // SetOp allows setting the mutation operation.
  12817. func (m *SopTaskMutation) SetOp(op Op) {
  12818. m.op = op
  12819. }
  12820. // Type returns the node type of this mutation (SopTask).
  12821. func (m *SopTaskMutation) Type() string {
  12822. return m.typ
  12823. }
  12824. // Fields returns all fields that were changed during this mutation. Note that in
  12825. // order to get all numeric fields that were incremented/decremented, call
  12826. // AddedFields().
  12827. func (m *SopTaskMutation) Fields() []string {
  12828. fields := make([]string, 0, 11)
  12829. if m.created_at != nil {
  12830. fields = append(fields, soptask.FieldCreatedAt)
  12831. }
  12832. if m.updated_at != nil {
  12833. fields = append(fields, soptask.FieldUpdatedAt)
  12834. }
  12835. if m.status != nil {
  12836. fields = append(fields, soptask.FieldStatus)
  12837. }
  12838. if m.deleted_at != nil {
  12839. fields = append(fields, soptask.FieldDeletedAt)
  12840. }
  12841. if m.name != nil {
  12842. fields = append(fields, soptask.FieldName)
  12843. }
  12844. if m.bot_wxid_list != nil {
  12845. fields = append(fields, soptask.FieldBotWxidList)
  12846. }
  12847. if m._type != nil {
  12848. fields = append(fields, soptask.FieldType)
  12849. }
  12850. if m.plan_start_time != nil {
  12851. fields = append(fields, soptask.FieldPlanStartTime)
  12852. }
  12853. if m.plan_end_time != nil {
  12854. fields = append(fields, soptask.FieldPlanEndTime)
  12855. }
  12856. if m.creator_id != nil {
  12857. fields = append(fields, soptask.FieldCreatorID)
  12858. }
  12859. if m.organization_id != nil {
  12860. fields = append(fields, soptask.FieldOrganizationID)
  12861. }
  12862. return fields
  12863. }
  12864. // Field returns the value of a field with the given name. The second boolean
  12865. // return value indicates that this field was not set, or was not defined in the
  12866. // schema.
  12867. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  12868. switch name {
  12869. case soptask.FieldCreatedAt:
  12870. return m.CreatedAt()
  12871. case soptask.FieldUpdatedAt:
  12872. return m.UpdatedAt()
  12873. case soptask.FieldStatus:
  12874. return m.Status()
  12875. case soptask.FieldDeletedAt:
  12876. return m.DeletedAt()
  12877. case soptask.FieldName:
  12878. return m.Name()
  12879. case soptask.FieldBotWxidList:
  12880. return m.BotWxidList()
  12881. case soptask.FieldType:
  12882. return m.GetType()
  12883. case soptask.FieldPlanStartTime:
  12884. return m.PlanStartTime()
  12885. case soptask.FieldPlanEndTime:
  12886. return m.PlanEndTime()
  12887. case soptask.FieldCreatorID:
  12888. return m.CreatorID()
  12889. case soptask.FieldOrganizationID:
  12890. return m.OrganizationID()
  12891. }
  12892. return nil, false
  12893. }
  12894. // OldField returns the old value of the field from the database. An error is
  12895. // returned if the mutation operation is not UpdateOne, or the query to the
  12896. // database failed.
  12897. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12898. switch name {
  12899. case soptask.FieldCreatedAt:
  12900. return m.OldCreatedAt(ctx)
  12901. case soptask.FieldUpdatedAt:
  12902. return m.OldUpdatedAt(ctx)
  12903. case soptask.FieldStatus:
  12904. return m.OldStatus(ctx)
  12905. case soptask.FieldDeletedAt:
  12906. return m.OldDeletedAt(ctx)
  12907. case soptask.FieldName:
  12908. return m.OldName(ctx)
  12909. case soptask.FieldBotWxidList:
  12910. return m.OldBotWxidList(ctx)
  12911. case soptask.FieldType:
  12912. return m.OldType(ctx)
  12913. case soptask.FieldPlanStartTime:
  12914. return m.OldPlanStartTime(ctx)
  12915. case soptask.FieldPlanEndTime:
  12916. return m.OldPlanEndTime(ctx)
  12917. case soptask.FieldCreatorID:
  12918. return m.OldCreatorID(ctx)
  12919. case soptask.FieldOrganizationID:
  12920. return m.OldOrganizationID(ctx)
  12921. }
  12922. return nil, fmt.Errorf("unknown SopTask field %s", name)
  12923. }
  12924. // SetField sets the value of a field with the given name. It returns an error if
  12925. // the field is not defined in the schema, or if the type mismatched the field
  12926. // type.
  12927. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  12928. switch name {
  12929. case soptask.FieldCreatedAt:
  12930. v, ok := value.(time.Time)
  12931. if !ok {
  12932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12933. }
  12934. m.SetCreatedAt(v)
  12935. return nil
  12936. case soptask.FieldUpdatedAt:
  12937. v, ok := value.(time.Time)
  12938. if !ok {
  12939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12940. }
  12941. m.SetUpdatedAt(v)
  12942. return nil
  12943. case soptask.FieldStatus:
  12944. v, ok := value.(uint8)
  12945. if !ok {
  12946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12947. }
  12948. m.SetStatus(v)
  12949. return nil
  12950. case soptask.FieldDeletedAt:
  12951. v, ok := value.(time.Time)
  12952. if !ok {
  12953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12954. }
  12955. m.SetDeletedAt(v)
  12956. return nil
  12957. case soptask.FieldName:
  12958. v, ok := value.(string)
  12959. if !ok {
  12960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12961. }
  12962. m.SetName(v)
  12963. return nil
  12964. case soptask.FieldBotWxidList:
  12965. v, ok := value.([]string)
  12966. if !ok {
  12967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12968. }
  12969. m.SetBotWxidList(v)
  12970. return nil
  12971. case soptask.FieldType:
  12972. v, ok := value.(int)
  12973. if !ok {
  12974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12975. }
  12976. m.SetType(v)
  12977. return nil
  12978. case soptask.FieldPlanStartTime:
  12979. v, ok := value.(time.Time)
  12980. if !ok {
  12981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12982. }
  12983. m.SetPlanStartTime(v)
  12984. return nil
  12985. case soptask.FieldPlanEndTime:
  12986. v, ok := value.(time.Time)
  12987. if !ok {
  12988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12989. }
  12990. m.SetPlanEndTime(v)
  12991. return nil
  12992. case soptask.FieldCreatorID:
  12993. v, ok := value.(string)
  12994. if !ok {
  12995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12996. }
  12997. m.SetCreatorID(v)
  12998. return nil
  12999. case soptask.FieldOrganizationID:
  13000. v, ok := value.(uint64)
  13001. if !ok {
  13002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13003. }
  13004. m.SetOrganizationID(v)
  13005. return nil
  13006. }
  13007. return fmt.Errorf("unknown SopTask field %s", name)
  13008. }
  13009. // AddedFields returns all numeric fields that were incremented/decremented during
  13010. // this mutation.
  13011. func (m *SopTaskMutation) AddedFields() []string {
  13012. var fields []string
  13013. if m.addstatus != nil {
  13014. fields = append(fields, soptask.FieldStatus)
  13015. }
  13016. if m.add_type != nil {
  13017. fields = append(fields, soptask.FieldType)
  13018. }
  13019. if m.addorganization_id != nil {
  13020. fields = append(fields, soptask.FieldOrganizationID)
  13021. }
  13022. return fields
  13023. }
  13024. // AddedField returns the numeric value that was incremented/decremented on a field
  13025. // with the given name. The second boolean return value indicates that this field
  13026. // was not set, or was not defined in the schema.
  13027. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  13028. switch name {
  13029. case soptask.FieldStatus:
  13030. return m.AddedStatus()
  13031. case soptask.FieldType:
  13032. return m.AddedType()
  13033. case soptask.FieldOrganizationID:
  13034. return m.AddedOrganizationID()
  13035. }
  13036. return nil, false
  13037. }
  13038. // AddField adds the value to the field with the given name. It returns an error if
  13039. // the field is not defined in the schema, or if the type mismatched the field
  13040. // type.
  13041. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  13042. switch name {
  13043. case soptask.FieldStatus:
  13044. v, ok := value.(int8)
  13045. if !ok {
  13046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13047. }
  13048. m.AddStatus(v)
  13049. return nil
  13050. case soptask.FieldType:
  13051. v, ok := value.(int)
  13052. if !ok {
  13053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13054. }
  13055. m.AddType(v)
  13056. return nil
  13057. case soptask.FieldOrganizationID:
  13058. v, ok := value.(int64)
  13059. if !ok {
  13060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13061. }
  13062. m.AddOrganizationID(v)
  13063. return nil
  13064. }
  13065. return fmt.Errorf("unknown SopTask numeric field %s", name)
  13066. }
  13067. // ClearedFields returns all nullable fields that were cleared during this
  13068. // mutation.
  13069. func (m *SopTaskMutation) ClearedFields() []string {
  13070. var fields []string
  13071. if m.FieldCleared(soptask.FieldStatus) {
  13072. fields = append(fields, soptask.FieldStatus)
  13073. }
  13074. if m.FieldCleared(soptask.FieldDeletedAt) {
  13075. fields = append(fields, soptask.FieldDeletedAt)
  13076. }
  13077. if m.FieldCleared(soptask.FieldBotWxidList) {
  13078. fields = append(fields, soptask.FieldBotWxidList)
  13079. }
  13080. if m.FieldCleared(soptask.FieldPlanStartTime) {
  13081. fields = append(fields, soptask.FieldPlanStartTime)
  13082. }
  13083. if m.FieldCleared(soptask.FieldPlanEndTime) {
  13084. fields = append(fields, soptask.FieldPlanEndTime)
  13085. }
  13086. if m.FieldCleared(soptask.FieldCreatorID) {
  13087. fields = append(fields, soptask.FieldCreatorID)
  13088. }
  13089. if m.FieldCleared(soptask.FieldOrganizationID) {
  13090. fields = append(fields, soptask.FieldOrganizationID)
  13091. }
  13092. return fields
  13093. }
  13094. // FieldCleared returns a boolean indicating if a field with the given name was
  13095. // cleared in this mutation.
  13096. func (m *SopTaskMutation) FieldCleared(name string) bool {
  13097. _, ok := m.clearedFields[name]
  13098. return ok
  13099. }
  13100. // ClearField clears the value of the field with the given name. It returns an
  13101. // error if the field is not defined in the schema.
  13102. func (m *SopTaskMutation) ClearField(name string) error {
  13103. switch name {
  13104. case soptask.FieldStatus:
  13105. m.ClearStatus()
  13106. return nil
  13107. case soptask.FieldDeletedAt:
  13108. m.ClearDeletedAt()
  13109. return nil
  13110. case soptask.FieldBotWxidList:
  13111. m.ClearBotWxidList()
  13112. return nil
  13113. case soptask.FieldPlanStartTime:
  13114. m.ClearPlanStartTime()
  13115. return nil
  13116. case soptask.FieldPlanEndTime:
  13117. m.ClearPlanEndTime()
  13118. return nil
  13119. case soptask.FieldCreatorID:
  13120. m.ClearCreatorID()
  13121. return nil
  13122. case soptask.FieldOrganizationID:
  13123. m.ClearOrganizationID()
  13124. return nil
  13125. }
  13126. return fmt.Errorf("unknown SopTask nullable field %s", name)
  13127. }
  13128. // ResetField resets all changes in the mutation for the field with the given name.
  13129. // It returns an error if the field is not defined in the schema.
  13130. func (m *SopTaskMutation) ResetField(name string) error {
  13131. switch name {
  13132. case soptask.FieldCreatedAt:
  13133. m.ResetCreatedAt()
  13134. return nil
  13135. case soptask.FieldUpdatedAt:
  13136. m.ResetUpdatedAt()
  13137. return nil
  13138. case soptask.FieldStatus:
  13139. m.ResetStatus()
  13140. return nil
  13141. case soptask.FieldDeletedAt:
  13142. m.ResetDeletedAt()
  13143. return nil
  13144. case soptask.FieldName:
  13145. m.ResetName()
  13146. return nil
  13147. case soptask.FieldBotWxidList:
  13148. m.ResetBotWxidList()
  13149. return nil
  13150. case soptask.FieldType:
  13151. m.ResetType()
  13152. return nil
  13153. case soptask.FieldPlanStartTime:
  13154. m.ResetPlanStartTime()
  13155. return nil
  13156. case soptask.FieldPlanEndTime:
  13157. m.ResetPlanEndTime()
  13158. return nil
  13159. case soptask.FieldCreatorID:
  13160. m.ResetCreatorID()
  13161. return nil
  13162. case soptask.FieldOrganizationID:
  13163. m.ResetOrganizationID()
  13164. return nil
  13165. }
  13166. return fmt.Errorf("unknown SopTask field %s", name)
  13167. }
  13168. // AddedEdges returns all edge names that were set/added in this mutation.
  13169. func (m *SopTaskMutation) AddedEdges() []string {
  13170. edges := make([]string, 0, 1)
  13171. if m.task_stages != nil {
  13172. edges = append(edges, soptask.EdgeTaskStages)
  13173. }
  13174. return edges
  13175. }
  13176. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13177. // name in this mutation.
  13178. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  13179. switch name {
  13180. case soptask.EdgeTaskStages:
  13181. ids := make([]ent.Value, 0, len(m.task_stages))
  13182. for id := range m.task_stages {
  13183. ids = append(ids, id)
  13184. }
  13185. return ids
  13186. }
  13187. return nil
  13188. }
  13189. // RemovedEdges returns all edge names that were removed in this mutation.
  13190. func (m *SopTaskMutation) RemovedEdges() []string {
  13191. edges := make([]string, 0, 1)
  13192. if m.removedtask_stages != nil {
  13193. edges = append(edges, soptask.EdgeTaskStages)
  13194. }
  13195. return edges
  13196. }
  13197. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13198. // the given name in this mutation.
  13199. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  13200. switch name {
  13201. case soptask.EdgeTaskStages:
  13202. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  13203. for id := range m.removedtask_stages {
  13204. ids = append(ids, id)
  13205. }
  13206. return ids
  13207. }
  13208. return nil
  13209. }
  13210. // ClearedEdges returns all edge names that were cleared in this mutation.
  13211. func (m *SopTaskMutation) ClearedEdges() []string {
  13212. edges := make([]string, 0, 1)
  13213. if m.clearedtask_stages {
  13214. edges = append(edges, soptask.EdgeTaskStages)
  13215. }
  13216. return edges
  13217. }
  13218. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13219. // was cleared in this mutation.
  13220. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  13221. switch name {
  13222. case soptask.EdgeTaskStages:
  13223. return m.clearedtask_stages
  13224. }
  13225. return false
  13226. }
  13227. // ClearEdge clears the value of the edge with the given name. It returns an error
  13228. // if that edge is not defined in the schema.
  13229. func (m *SopTaskMutation) ClearEdge(name string) error {
  13230. switch name {
  13231. }
  13232. return fmt.Errorf("unknown SopTask unique edge %s", name)
  13233. }
  13234. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13235. // It returns an error if the edge is not defined in the schema.
  13236. func (m *SopTaskMutation) ResetEdge(name string) error {
  13237. switch name {
  13238. case soptask.EdgeTaskStages:
  13239. m.ResetTaskStages()
  13240. return nil
  13241. }
  13242. return fmt.Errorf("unknown SopTask edge %s", name)
  13243. }
  13244. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  13245. type WxMutation struct {
  13246. config
  13247. op Op
  13248. typ string
  13249. id *uint64
  13250. created_at *time.Time
  13251. updated_at *time.Time
  13252. status *uint8
  13253. addstatus *int8
  13254. deleted_at *time.Time
  13255. port *string
  13256. process_id *string
  13257. callback *string
  13258. wxid *string
  13259. account *string
  13260. nickname *string
  13261. tel *string
  13262. head_big *string
  13263. organization_id *uint64
  13264. addorganization_id *int64
  13265. clearedFields map[string]struct{}
  13266. server *uint64
  13267. clearedserver bool
  13268. agent *uint64
  13269. clearedagent bool
  13270. done bool
  13271. oldValue func(context.Context) (*Wx, error)
  13272. predicates []predicate.Wx
  13273. }
  13274. var _ ent.Mutation = (*WxMutation)(nil)
  13275. // wxOption allows management of the mutation configuration using functional options.
  13276. type wxOption func(*WxMutation)
  13277. // newWxMutation creates new mutation for the Wx entity.
  13278. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  13279. m := &WxMutation{
  13280. config: c,
  13281. op: op,
  13282. typ: TypeWx,
  13283. clearedFields: make(map[string]struct{}),
  13284. }
  13285. for _, opt := range opts {
  13286. opt(m)
  13287. }
  13288. return m
  13289. }
  13290. // withWxID sets the ID field of the mutation.
  13291. func withWxID(id uint64) wxOption {
  13292. return func(m *WxMutation) {
  13293. var (
  13294. err error
  13295. once sync.Once
  13296. value *Wx
  13297. )
  13298. m.oldValue = func(ctx context.Context) (*Wx, error) {
  13299. once.Do(func() {
  13300. if m.done {
  13301. err = errors.New("querying old values post mutation is not allowed")
  13302. } else {
  13303. value, err = m.Client().Wx.Get(ctx, id)
  13304. }
  13305. })
  13306. return value, err
  13307. }
  13308. m.id = &id
  13309. }
  13310. }
  13311. // withWx sets the old Wx of the mutation.
  13312. func withWx(node *Wx) wxOption {
  13313. return func(m *WxMutation) {
  13314. m.oldValue = func(context.Context) (*Wx, error) {
  13315. return node, nil
  13316. }
  13317. m.id = &node.ID
  13318. }
  13319. }
  13320. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13321. // executed in a transaction (ent.Tx), a transactional client is returned.
  13322. func (m WxMutation) Client() *Client {
  13323. client := &Client{config: m.config}
  13324. client.init()
  13325. return client
  13326. }
  13327. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13328. // it returns an error otherwise.
  13329. func (m WxMutation) Tx() (*Tx, error) {
  13330. if _, ok := m.driver.(*txDriver); !ok {
  13331. return nil, errors.New("ent: mutation is not running in a transaction")
  13332. }
  13333. tx := &Tx{config: m.config}
  13334. tx.init()
  13335. return tx, nil
  13336. }
  13337. // SetID sets the value of the id field. Note that this
  13338. // operation is only accepted on creation of Wx entities.
  13339. func (m *WxMutation) SetID(id uint64) {
  13340. m.id = &id
  13341. }
  13342. // ID returns the ID value in the mutation. Note that the ID is only available
  13343. // if it was provided to the builder or after it was returned from the database.
  13344. func (m *WxMutation) ID() (id uint64, exists bool) {
  13345. if m.id == nil {
  13346. return
  13347. }
  13348. return *m.id, true
  13349. }
  13350. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13351. // That means, if the mutation is applied within a transaction with an isolation level such
  13352. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13353. // or updated by the mutation.
  13354. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  13355. switch {
  13356. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13357. id, exists := m.ID()
  13358. if exists {
  13359. return []uint64{id}, nil
  13360. }
  13361. fallthrough
  13362. case m.op.Is(OpUpdate | OpDelete):
  13363. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  13364. default:
  13365. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13366. }
  13367. }
  13368. // SetCreatedAt sets the "created_at" field.
  13369. func (m *WxMutation) SetCreatedAt(t time.Time) {
  13370. m.created_at = &t
  13371. }
  13372. // CreatedAt returns the value of the "created_at" field in the mutation.
  13373. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  13374. v := m.created_at
  13375. if v == nil {
  13376. return
  13377. }
  13378. return *v, true
  13379. }
  13380. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  13381. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13383. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13384. if !m.op.Is(OpUpdateOne) {
  13385. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13386. }
  13387. if m.id == nil || m.oldValue == nil {
  13388. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13389. }
  13390. oldValue, err := m.oldValue(ctx)
  13391. if err != nil {
  13392. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13393. }
  13394. return oldValue.CreatedAt, nil
  13395. }
  13396. // ResetCreatedAt resets all changes to the "created_at" field.
  13397. func (m *WxMutation) ResetCreatedAt() {
  13398. m.created_at = nil
  13399. }
  13400. // SetUpdatedAt sets the "updated_at" field.
  13401. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  13402. m.updated_at = &t
  13403. }
  13404. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13405. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  13406. v := m.updated_at
  13407. if v == nil {
  13408. return
  13409. }
  13410. return *v, true
  13411. }
  13412. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  13413. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13415. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13416. if !m.op.Is(OpUpdateOne) {
  13417. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13418. }
  13419. if m.id == nil || m.oldValue == nil {
  13420. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13421. }
  13422. oldValue, err := m.oldValue(ctx)
  13423. if err != nil {
  13424. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13425. }
  13426. return oldValue.UpdatedAt, nil
  13427. }
  13428. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13429. func (m *WxMutation) ResetUpdatedAt() {
  13430. m.updated_at = nil
  13431. }
  13432. // SetStatus sets the "status" field.
  13433. func (m *WxMutation) SetStatus(u uint8) {
  13434. m.status = &u
  13435. m.addstatus = nil
  13436. }
  13437. // Status returns the value of the "status" field in the mutation.
  13438. func (m *WxMutation) Status() (r uint8, exists bool) {
  13439. v := m.status
  13440. if v == nil {
  13441. return
  13442. }
  13443. return *v, true
  13444. }
  13445. // OldStatus returns the old "status" field's value of the Wx entity.
  13446. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13447. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13448. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13449. if !m.op.Is(OpUpdateOne) {
  13450. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13451. }
  13452. if m.id == nil || m.oldValue == nil {
  13453. return v, errors.New("OldStatus requires an ID field in the mutation")
  13454. }
  13455. oldValue, err := m.oldValue(ctx)
  13456. if err != nil {
  13457. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13458. }
  13459. return oldValue.Status, nil
  13460. }
  13461. // AddStatus adds u to the "status" field.
  13462. func (m *WxMutation) AddStatus(u int8) {
  13463. if m.addstatus != nil {
  13464. *m.addstatus += u
  13465. } else {
  13466. m.addstatus = &u
  13467. }
  13468. }
  13469. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13470. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  13471. v := m.addstatus
  13472. if v == nil {
  13473. return
  13474. }
  13475. return *v, true
  13476. }
  13477. // ClearStatus clears the value of the "status" field.
  13478. func (m *WxMutation) ClearStatus() {
  13479. m.status = nil
  13480. m.addstatus = nil
  13481. m.clearedFields[wx.FieldStatus] = struct{}{}
  13482. }
  13483. // StatusCleared returns if the "status" field was cleared in this mutation.
  13484. func (m *WxMutation) StatusCleared() bool {
  13485. _, ok := m.clearedFields[wx.FieldStatus]
  13486. return ok
  13487. }
  13488. // ResetStatus resets all changes to the "status" field.
  13489. func (m *WxMutation) ResetStatus() {
  13490. m.status = nil
  13491. m.addstatus = nil
  13492. delete(m.clearedFields, wx.FieldStatus)
  13493. }
  13494. // SetDeletedAt sets the "deleted_at" field.
  13495. func (m *WxMutation) SetDeletedAt(t time.Time) {
  13496. m.deleted_at = &t
  13497. }
  13498. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13499. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  13500. v := m.deleted_at
  13501. if v == nil {
  13502. return
  13503. }
  13504. return *v, true
  13505. }
  13506. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  13507. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13509. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13510. if !m.op.Is(OpUpdateOne) {
  13511. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13512. }
  13513. if m.id == nil || m.oldValue == nil {
  13514. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13515. }
  13516. oldValue, err := m.oldValue(ctx)
  13517. if err != nil {
  13518. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13519. }
  13520. return oldValue.DeletedAt, nil
  13521. }
  13522. // ClearDeletedAt clears the value of the "deleted_at" field.
  13523. func (m *WxMutation) ClearDeletedAt() {
  13524. m.deleted_at = nil
  13525. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  13526. }
  13527. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13528. func (m *WxMutation) DeletedAtCleared() bool {
  13529. _, ok := m.clearedFields[wx.FieldDeletedAt]
  13530. return ok
  13531. }
  13532. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13533. func (m *WxMutation) ResetDeletedAt() {
  13534. m.deleted_at = nil
  13535. delete(m.clearedFields, wx.FieldDeletedAt)
  13536. }
  13537. // SetServerID sets the "server_id" field.
  13538. func (m *WxMutation) SetServerID(u uint64) {
  13539. m.server = &u
  13540. }
  13541. // ServerID returns the value of the "server_id" field in the mutation.
  13542. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  13543. v := m.server
  13544. if v == nil {
  13545. return
  13546. }
  13547. return *v, true
  13548. }
  13549. // OldServerID returns the old "server_id" field's value of the Wx entity.
  13550. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13552. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  13553. if !m.op.Is(OpUpdateOne) {
  13554. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  13555. }
  13556. if m.id == nil || m.oldValue == nil {
  13557. return v, errors.New("OldServerID requires an ID field in the mutation")
  13558. }
  13559. oldValue, err := m.oldValue(ctx)
  13560. if err != nil {
  13561. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  13562. }
  13563. return oldValue.ServerID, nil
  13564. }
  13565. // ClearServerID clears the value of the "server_id" field.
  13566. func (m *WxMutation) ClearServerID() {
  13567. m.server = nil
  13568. m.clearedFields[wx.FieldServerID] = struct{}{}
  13569. }
  13570. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  13571. func (m *WxMutation) ServerIDCleared() bool {
  13572. _, ok := m.clearedFields[wx.FieldServerID]
  13573. return ok
  13574. }
  13575. // ResetServerID resets all changes to the "server_id" field.
  13576. func (m *WxMutation) ResetServerID() {
  13577. m.server = nil
  13578. delete(m.clearedFields, wx.FieldServerID)
  13579. }
  13580. // SetPort sets the "port" field.
  13581. func (m *WxMutation) SetPort(s string) {
  13582. m.port = &s
  13583. }
  13584. // Port returns the value of the "port" field in the mutation.
  13585. func (m *WxMutation) Port() (r string, exists bool) {
  13586. v := m.port
  13587. if v == nil {
  13588. return
  13589. }
  13590. return *v, true
  13591. }
  13592. // OldPort returns the old "port" field's value of the Wx entity.
  13593. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13595. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  13596. if !m.op.Is(OpUpdateOne) {
  13597. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  13598. }
  13599. if m.id == nil || m.oldValue == nil {
  13600. return v, errors.New("OldPort requires an ID field in the mutation")
  13601. }
  13602. oldValue, err := m.oldValue(ctx)
  13603. if err != nil {
  13604. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  13605. }
  13606. return oldValue.Port, nil
  13607. }
  13608. // ResetPort resets all changes to the "port" field.
  13609. func (m *WxMutation) ResetPort() {
  13610. m.port = nil
  13611. }
  13612. // SetProcessID sets the "process_id" field.
  13613. func (m *WxMutation) SetProcessID(s string) {
  13614. m.process_id = &s
  13615. }
  13616. // ProcessID returns the value of the "process_id" field in the mutation.
  13617. func (m *WxMutation) ProcessID() (r string, exists bool) {
  13618. v := m.process_id
  13619. if v == nil {
  13620. return
  13621. }
  13622. return *v, true
  13623. }
  13624. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  13625. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13627. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  13628. if !m.op.Is(OpUpdateOne) {
  13629. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  13630. }
  13631. if m.id == nil || m.oldValue == nil {
  13632. return v, errors.New("OldProcessID requires an ID field in the mutation")
  13633. }
  13634. oldValue, err := m.oldValue(ctx)
  13635. if err != nil {
  13636. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  13637. }
  13638. return oldValue.ProcessID, nil
  13639. }
  13640. // ResetProcessID resets all changes to the "process_id" field.
  13641. func (m *WxMutation) ResetProcessID() {
  13642. m.process_id = nil
  13643. }
  13644. // SetCallback sets the "callback" field.
  13645. func (m *WxMutation) SetCallback(s string) {
  13646. m.callback = &s
  13647. }
  13648. // Callback returns the value of the "callback" field in the mutation.
  13649. func (m *WxMutation) Callback() (r string, exists bool) {
  13650. v := m.callback
  13651. if v == nil {
  13652. return
  13653. }
  13654. return *v, true
  13655. }
  13656. // OldCallback returns the old "callback" field's value of the Wx entity.
  13657. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13658. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13659. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  13660. if !m.op.Is(OpUpdateOne) {
  13661. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  13662. }
  13663. if m.id == nil || m.oldValue == nil {
  13664. return v, errors.New("OldCallback requires an ID field in the mutation")
  13665. }
  13666. oldValue, err := m.oldValue(ctx)
  13667. if err != nil {
  13668. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  13669. }
  13670. return oldValue.Callback, nil
  13671. }
  13672. // ResetCallback resets all changes to the "callback" field.
  13673. func (m *WxMutation) ResetCallback() {
  13674. m.callback = nil
  13675. }
  13676. // SetWxid sets the "wxid" field.
  13677. func (m *WxMutation) SetWxid(s string) {
  13678. m.wxid = &s
  13679. }
  13680. // Wxid returns the value of the "wxid" field in the mutation.
  13681. func (m *WxMutation) Wxid() (r string, exists bool) {
  13682. v := m.wxid
  13683. if v == nil {
  13684. return
  13685. }
  13686. return *v, true
  13687. }
  13688. // OldWxid returns the old "wxid" field's value of the Wx entity.
  13689. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13691. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  13692. if !m.op.Is(OpUpdateOne) {
  13693. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  13694. }
  13695. if m.id == nil || m.oldValue == nil {
  13696. return v, errors.New("OldWxid requires an ID field in the mutation")
  13697. }
  13698. oldValue, err := m.oldValue(ctx)
  13699. if err != nil {
  13700. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  13701. }
  13702. return oldValue.Wxid, nil
  13703. }
  13704. // ResetWxid resets all changes to the "wxid" field.
  13705. func (m *WxMutation) ResetWxid() {
  13706. m.wxid = nil
  13707. }
  13708. // SetAccount sets the "account" field.
  13709. func (m *WxMutation) SetAccount(s string) {
  13710. m.account = &s
  13711. }
  13712. // Account returns the value of the "account" field in the mutation.
  13713. func (m *WxMutation) Account() (r string, exists bool) {
  13714. v := m.account
  13715. if v == nil {
  13716. return
  13717. }
  13718. return *v, true
  13719. }
  13720. // OldAccount returns the old "account" field's value of the Wx entity.
  13721. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13723. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  13724. if !m.op.Is(OpUpdateOne) {
  13725. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  13726. }
  13727. if m.id == nil || m.oldValue == nil {
  13728. return v, errors.New("OldAccount requires an ID field in the mutation")
  13729. }
  13730. oldValue, err := m.oldValue(ctx)
  13731. if err != nil {
  13732. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  13733. }
  13734. return oldValue.Account, nil
  13735. }
  13736. // ResetAccount resets all changes to the "account" field.
  13737. func (m *WxMutation) ResetAccount() {
  13738. m.account = nil
  13739. }
  13740. // SetNickname sets the "nickname" field.
  13741. func (m *WxMutation) SetNickname(s string) {
  13742. m.nickname = &s
  13743. }
  13744. // Nickname returns the value of the "nickname" field in the mutation.
  13745. func (m *WxMutation) Nickname() (r string, exists bool) {
  13746. v := m.nickname
  13747. if v == nil {
  13748. return
  13749. }
  13750. return *v, true
  13751. }
  13752. // OldNickname returns the old "nickname" field's value of the Wx entity.
  13753. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13755. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  13756. if !m.op.Is(OpUpdateOne) {
  13757. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  13758. }
  13759. if m.id == nil || m.oldValue == nil {
  13760. return v, errors.New("OldNickname requires an ID field in the mutation")
  13761. }
  13762. oldValue, err := m.oldValue(ctx)
  13763. if err != nil {
  13764. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  13765. }
  13766. return oldValue.Nickname, nil
  13767. }
  13768. // ResetNickname resets all changes to the "nickname" field.
  13769. func (m *WxMutation) ResetNickname() {
  13770. m.nickname = nil
  13771. }
  13772. // SetTel sets the "tel" field.
  13773. func (m *WxMutation) SetTel(s string) {
  13774. m.tel = &s
  13775. }
  13776. // Tel returns the value of the "tel" field in the mutation.
  13777. func (m *WxMutation) Tel() (r string, exists bool) {
  13778. v := m.tel
  13779. if v == nil {
  13780. return
  13781. }
  13782. return *v, true
  13783. }
  13784. // OldTel returns the old "tel" field's value of the Wx entity.
  13785. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13787. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  13788. if !m.op.Is(OpUpdateOne) {
  13789. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  13790. }
  13791. if m.id == nil || m.oldValue == nil {
  13792. return v, errors.New("OldTel requires an ID field in the mutation")
  13793. }
  13794. oldValue, err := m.oldValue(ctx)
  13795. if err != nil {
  13796. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  13797. }
  13798. return oldValue.Tel, nil
  13799. }
  13800. // ResetTel resets all changes to the "tel" field.
  13801. func (m *WxMutation) ResetTel() {
  13802. m.tel = nil
  13803. }
  13804. // SetHeadBig sets the "head_big" field.
  13805. func (m *WxMutation) SetHeadBig(s string) {
  13806. m.head_big = &s
  13807. }
  13808. // HeadBig returns the value of the "head_big" field in the mutation.
  13809. func (m *WxMutation) HeadBig() (r string, exists bool) {
  13810. v := m.head_big
  13811. if v == nil {
  13812. return
  13813. }
  13814. return *v, true
  13815. }
  13816. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  13817. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13819. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  13820. if !m.op.Is(OpUpdateOne) {
  13821. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  13822. }
  13823. if m.id == nil || m.oldValue == nil {
  13824. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  13825. }
  13826. oldValue, err := m.oldValue(ctx)
  13827. if err != nil {
  13828. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  13829. }
  13830. return oldValue.HeadBig, nil
  13831. }
  13832. // ResetHeadBig resets all changes to the "head_big" field.
  13833. func (m *WxMutation) ResetHeadBig() {
  13834. m.head_big = nil
  13835. }
  13836. // SetOrganizationID sets the "organization_id" field.
  13837. func (m *WxMutation) SetOrganizationID(u uint64) {
  13838. m.organization_id = &u
  13839. m.addorganization_id = nil
  13840. }
  13841. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13842. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  13843. v := m.organization_id
  13844. if v == nil {
  13845. return
  13846. }
  13847. return *v, true
  13848. }
  13849. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  13850. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13851. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13852. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13853. if !m.op.Is(OpUpdateOne) {
  13854. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13855. }
  13856. if m.id == nil || m.oldValue == nil {
  13857. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13858. }
  13859. oldValue, err := m.oldValue(ctx)
  13860. if err != nil {
  13861. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13862. }
  13863. return oldValue.OrganizationID, nil
  13864. }
  13865. // AddOrganizationID adds u to the "organization_id" field.
  13866. func (m *WxMutation) AddOrganizationID(u int64) {
  13867. if m.addorganization_id != nil {
  13868. *m.addorganization_id += u
  13869. } else {
  13870. m.addorganization_id = &u
  13871. }
  13872. }
  13873. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13874. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  13875. v := m.addorganization_id
  13876. if v == nil {
  13877. return
  13878. }
  13879. return *v, true
  13880. }
  13881. // ClearOrganizationID clears the value of the "organization_id" field.
  13882. func (m *WxMutation) ClearOrganizationID() {
  13883. m.organization_id = nil
  13884. m.addorganization_id = nil
  13885. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  13886. }
  13887. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13888. func (m *WxMutation) OrganizationIDCleared() bool {
  13889. _, ok := m.clearedFields[wx.FieldOrganizationID]
  13890. return ok
  13891. }
  13892. // ResetOrganizationID resets all changes to the "organization_id" field.
  13893. func (m *WxMutation) ResetOrganizationID() {
  13894. m.organization_id = nil
  13895. m.addorganization_id = nil
  13896. delete(m.clearedFields, wx.FieldOrganizationID)
  13897. }
  13898. // SetAgentID sets the "agent_id" field.
  13899. func (m *WxMutation) SetAgentID(u uint64) {
  13900. m.agent = &u
  13901. }
  13902. // AgentID returns the value of the "agent_id" field in the mutation.
  13903. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  13904. v := m.agent
  13905. if v == nil {
  13906. return
  13907. }
  13908. return *v, true
  13909. }
  13910. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  13911. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13913. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  13914. if !m.op.Is(OpUpdateOne) {
  13915. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  13916. }
  13917. if m.id == nil || m.oldValue == nil {
  13918. return v, errors.New("OldAgentID requires an ID field in the mutation")
  13919. }
  13920. oldValue, err := m.oldValue(ctx)
  13921. if err != nil {
  13922. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  13923. }
  13924. return oldValue.AgentID, nil
  13925. }
  13926. // ResetAgentID resets all changes to the "agent_id" field.
  13927. func (m *WxMutation) ResetAgentID() {
  13928. m.agent = nil
  13929. }
  13930. // ClearServer clears the "server" edge to the Server entity.
  13931. func (m *WxMutation) ClearServer() {
  13932. m.clearedserver = true
  13933. m.clearedFields[wx.FieldServerID] = struct{}{}
  13934. }
  13935. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  13936. func (m *WxMutation) ServerCleared() bool {
  13937. return m.ServerIDCleared() || m.clearedserver
  13938. }
  13939. // ServerIDs returns the "server" edge IDs in the mutation.
  13940. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13941. // ServerID instead. It exists only for internal usage by the builders.
  13942. func (m *WxMutation) ServerIDs() (ids []uint64) {
  13943. if id := m.server; id != nil {
  13944. ids = append(ids, *id)
  13945. }
  13946. return
  13947. }
  13948. // ResetServer resets all changes to the "server" edge.
  13949. func (m *WxMutation) ResetServer() {
  13950. m.server = nil
  13951. m.clearedserver = false
  13952. }
  13953. // ClearAgent clears the "agent" edge to the Agent entity.
  13954. func (m *WxMutation) ClearAgent() {
  13955. m.clearedagent = true
  13956. m.clearedFields[wx.FieldAgentID] = struct{}{}
  13957. }
  13958. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  13959. func (m *WxMutation) AgentCleared() bool {
  13960. return m.clearedagent
  13961. }
  13962. // AgentIDs returns the "agent" edge IDs in the mutation.
  13963. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13964. // AgentID instead. It exists only for internal usage by the builders.
  13965. func (m *WxMutation) AgentIDs() (ids []uint64) {
  13966. if id := m.agent; id != nil {
  13967. ids = append(ids, *id)
  13968. }
  13969. return
  13970. }
  13971. // ResetAgent resets all changes to the "agent" edge.
  13972. func (m *WxMutation) ResetAgent() {
  13973. m.agent = nil
  13974. m.clearedagent = false
  13975. }
  13976. // Where appends a list predicates to the WxMutation builder.
  13977. func (m *WxMutation) Where(ps ...predicate.Wx) {
  13978. m.predicates = append(m.predicates, ps...)
  13979. }
  13980. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  13981. // users can use type-assertion to append predicates that do not depend on any generated package.
  13982. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  13983. p := make([]predicate.Wx, len(ps))
  13984. for i := range ps {
  13985. p[i] = ps[i]
  13986. }
  13987. m.Where(p...)
  13988. }
  13989. // Op returns the operation name.
  13990. func (m *WxMutation) Op() Op {
  13991. return m.op
  13992. }
  13993. // SetOp allows setting the mutation operation.
  13994. func (m *WxMutation) SetOp(op Op) {
  13995. m.op = op
  13996. }
  13997. // Type returns the node type of this mutation (Wx).
  13998. func (m *WxMutation) Type() string {
  13999. return m.typ
  14000. }
  14001. // Fields returns all fields that were changed during this mutation. Note that in
  14002. // order to get all numeric fields that were incremented/decremented, call
  14003. // AddedFields().
  14004. func (m *WxMutation) Fields() []string {
  14005. fields := make([]string, 0, 15)
  14006. if m.created_at != nil {
  14007. fields = append(fields, wx.FieldCreatedAt)
  14008. }
  14009. if m.updated_at != nil {
  14010. fields = append(fields, wx.FieldUpdatedAt)
  14011. }
  14012. if m.status != nil {
  14013. fields = append(fields, wx.FieldStatus)
  14014. }
  14015. if m.deleted_at != nil {
  14016. fields = append(fields, wx.FieldDeletedAt)
  14017. }
  14018. if m.server != nil {
  14019. fields = append(fields, wx.FieldServerID)
  14020. }
  14021. if m.port != nil {
  14022. fields = append(fields, wx.FieldPort)
  14023. }
  14024. if m.process_id != nil {
  14025. fields = append(fields, wx.FieldProcessID)
  14026. }
  14027. if m.callback != nil {
  14028. fields = append(fields, wx.FieldCallback)
  14029. }
  14030. if m.wxid != nil {
  14031. fields = append(fields, wx.FieldWxid)
  14032. }
  14033. if m.account != nil {
  14034. fields = append(fields, wx.FieldAccount)
  14035. }
  14036. if m.nickname != nil {
  14037. fields = append(fields, wx.FieldNickname)
  14038. }
  14039. if m.tel != nil {
  14040. fields = append(fields, wx.FieldTel)
  14041. }
  14042. if m.head_big != nil {
  14043. fields = append(fields, wx.FieldHeadBig)
  14044. }
  14045. if m.organization_id != nil {
  14046. fields = append(fields, wx.FieldOrganizationID)
  14047. }
  14048. if m.agent != nil {
  14049. fields = append(fields, wx.FieldAgentID)
  14050. }
  14051. return fields
  14052. }
  14053. // Field returns the value of a field with the given name. The second boolean
  14054. // return value indicates that this field was not set, or was not defined in the
  14055. // schema.
  14056. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  14057. switch name {
  14058. case wx.FieldCreatedAt:
  14059. return m.CreatedAt()
  14060. case wx.FieldUpdatedAt:
  14061. return m.UpdatedAt()
  14062. case wx.FieldStatus:
  14063. return m.Status()
  14064. case wx.FieldDeletedAt:
  14065. return m.DeletedAt()
  14066. case wx.FieldServerID:
  14067. return m.ServerID()
  14068. case wx.FieldPort:
  14069. return m.Port()
  14070. case wx.FieldProcessID:
  14071. return m.ProcessID()
  14072. case wx.FieldCallback:
  14073. return m.Callback()
  14074. case wx.FieldWxid:
  14075. return m.Wxid()
  14076. case wx.FieldAccount:
  14077. return m.Account()
  14078. case wx.FieldNickname:
  14079. return m.Nickname()
  14080. case wx.FieldTel:
  14081. return m.Tel()
  14082. case wx.FieldHeadBig:
  14083. return m.HeadBig()
  14084. case wx.FieldOrganizationID:
  14085. return m.OrganizationID()
  14086. case wx.FieldAgentID:
  14087. return m.AgentID()
  14088. }
  14089. return nil, false
  14090. }
  14091. // OldField returns the old value of the field from the database. An error is
  14092. // returned if the mutation operation is not UpdateOne, or the query to the
  14093. // database failed.
  14094. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14095. switch name {
  14096. case wx.FieldCreatedAt:
  14097. return m.OldCreatedAt(ctx)
  14098. case wx.FieldUpdatedAt:
  14099. return m.OldUpdatedAt(ctx)
  14100. case wx.FieldStatus:
  14101. return m.OldStatus(ctx)
  14102. case wx.FieldDeletedAt:
  14103. return m.OldDeletedAt(ctx)
  14104. case wx.FieldServerID:
  14105. return m.OldServerID(ctx)
  14106. case wx.FieldPort:
  14107. return m.OldPort(ctx)
  14108. case wx.FieldProcessID:
  14109. return m.OldProcessID(ctx)
  14110. case wx.FieldCallback:
  14111. return m.OldCallback(ctx)
  14112. case wx.FieldWxid:
  14113. return m.OldWxid(ctx)
  14114. case wx.FieldAccount:
  14115. return m.OldAccount(ctx)
  14116. case wx.FieldNickname:
  14117. return m.OldNickname(ctx)
  14118. case wx.FieldTel:
  14119. return m.OldTel(ctx)
  14120. case wx.FieldHeadBig:
  14121. return m.OldHeadBig(ctx)
  14122. case wx.FieldOrganizationID:
  14123. return m.OldOrganizationID(ctx)
  14124. case wx.FieldAgentID:
  14125. return m.OldAgentID(ctx)
  14126. }
  14127. return nil, fmt.Errorf("unknown Wx field %s", name)
  14128. }
  14129. // SetField sets the value of a field with the given name. It returns an error if
  14130. // the field is not defined in the schema, or if the type mismatched the field
  14131. // type.
  14132. func (m *WxMutation) SetField(name string, value ent.Value) error {
  14133. switch name {
  14134. case wx.FieldCreatedAt:
  14135. v, ok := value.(time.Time)
  14136. if !ok {
  14137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14138. }
  14139. m.SetCreatedAt(v)
  14140. return nil
  14141. case wx.FieldUpdatedAt:
  14142. v, ok := value.(time.Time)
  14143. if !ok {
  14144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14145. }
  14146. m.SetUpdatedAt(v)
  14147. return nil
  14148. case wx.FieldStatus:
  14149. v, ok := value.(uint8)
  14150. if !ok {
  14151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14152. }
  14153. m.SetStatus(v)
  14154. return nil
  14155. case wx.FieldDeletedAt:
  14156. v, ok := value.(time.Time)
  14157. if !ok {
  14158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14159. }
  14160. m.SetDeletedAt(v)
  14161. return nil
  14162. case wx.FieldServerID:
  14163. v, ok := value.(uint64)
  14164. if !ok {
  14165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14166. }
  14167. m.SetServerID(v)
  14168. return nil
  14169. case wx.FieldPort:
  14170. v, ok := value.(string)
  14171. if !ok {
  14172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14173. }
  14174. m.SetPort(v)
  14175. return nil
  14176. case wx.FieldProcessID:
  14177. v, ok := value.(string)
  14178. if !ok {
  14179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14180. }
  14181. m.SetProcessID(v)
  14182. return nil
  14183. case wx.FieldCallback:
  14184. v, ok := value.(string)
  14185. if !ok {
  14186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14187. }
  14188. m.SetCallback(v)
  14189. return nil
  14190. case wx.FieldWxid:
  14191. v, ok := value.(string)
  14192. if !ok {
  14193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14194. }
  14195. m.SetWxid(v)
  14196. return nil
  14197. case wx.FieldAccount:
  14198. v, ok := value.(string)
  14199. if !ok {
  14200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14201. }
  14202. m.SetAccount(v)
  14203. return nil
  14204. case wx.FieldNickname:
  14205. v, ok := value.(string)
  14206. if !ok {
  14207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14208. }
  14209. m.SetNickname(v)
  14210. return nil
  14211. case wx.FieldTel:
  14212. v, ok := value.(string)
  14213. if !ok {
  14214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14215. }
  14216. m.SetTel(v)
  14217. return nil
  14218. case wx.FieldHeadBig:
  14219. v, ok := value.(string)
  14220. if !ok {
  14221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14222. }
  14223. m.SetHeadBig(v)
  14224. return nil
  14225. case wx.FieldOrganizationID:
  14226. v, ok := value.(uint64)
  14227. if !ok {
  14228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14229. }
  14230. m.SetOrganizationID(v)
  14231. return nil
  14232. case wx.FieldAgentID:
  14233. v, ok := value.(uint64)
  14234. if !ok {
  14235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14236. }
  14237. m.SetAgentID(v)
  14238. return nil
  14239. }
  14240. return fmt.Errorf("unknown Wx field %s", name)
  14241. }
  14242. // AddedFields returns all numeric fields that were incremented/decremented during
  14243. // this mutation.
  14244. func (m *WxMutation) AddedFields() []string {
  14245. var fields []string
  14246. if m.addstatus != nil {
  14247. fields = append(fields, wx.FieldStatus)
  14248. }
  14249. if m.addorganization_id != nil {
  14250. fields = append(fields, wx.FieldOrganizationID)
  14251. }
  14252. return fields
  14253. }
  14254. // AddedField returns the numeric value that was incremented/decremented on a field
  14255. // with the given name. The second boolean return value indicates that this field
  14256. // was not set, or was not defined in the schema.
  14257. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  14258. switch name {
  14259. case wx.FieldStatus:
  14260. return m.AddedStatus()
  14261. case wx.FieldOrganizationID:
  14262. return m.AddedOrganizationID()
  14263. }
  14264. return nil, false
  14265. }
  14266. // AddField adds the value to the field with the given name. It returns an error if
  14267. // the field is not defined in the schema, or if the type mismatched the field
  14268. // type.
  14269. func (m *WxMutation) AddField(name string, value ent.Value) error {
  14270. switch name {
  14271. case wx.FieldStatus:
  14272. v, ok := value.(int8)
  14273. if !ok {
  14274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14275. }
  14276. m.AddStatus(v)
  14277. return nil
  14278. case wx.FieldOrganizationID:
  14279. v, ok := value.(int64)
  14280. if !ok {
  14281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14282. }
  14283. m.AddOrganizationID(v)
  14284. return nil
  14285. }
  14286. return fmt.Errorf("unknown Wx numeric field %s", name)
  14287. }
  14288. // ClearedFields returns all nullable fields that were cleared during this
  14289. // mutation.
  14290. func (m *WxMutation) ClearedFields() []string {
  14291. var fields []string
  14292. if m.FieldCleared(wx.FieldStatus) {
  14293. fields = append(fields, wx.FieldStatus)
  14294. }
  14295. if m.FieldCleared(wx.FieldDeletedAt) {
  14296. fields = append(fields, wx.FieldDeletedAt)
  14297. }
  14298. if m.FieldCleared(wx.FieldServerID) {
  14299. fields = append(fields, wx.FieldServerID)
  14300. }
  14301. if m.FieldCleared(wx.FieldOrganizationID) {
  14302. fields = append(fields, wx.FieldOrganizationID)
  14303. }
  14304. return fields
  14305. }
  14306. // FieldCleared returns a boolean indicating if a field with the given name was
  14307. // cleared in this mutation.
  14308. func (m *WxMutation) FieldCleared(name string) bool {
  14309. _, ok := m.clearedFields[name]
  14310. return ok
  14311. }
  14312. // ClearField clears the value of the field with the given name. It returns an
  14313. // error if the field is not defined in the schema.
  14314. func (m *WxMutation) ClearField(name string) error {
  14315. switch name {
  14316. case wx.FieldStatus:
  14317. m.ClearStatus()
  14318. return nil
  14319. case wx.FieldDeletedAt:
  14320. m.ClearDeletedAt()
  14321. return nil
  14322. case wx.FieldServerID:
  14323. m.ClearServerID()
  14324. return nil
  14325. case wx.FieldOrganizationID:
  14326. m.ClearOrganizationID()
  14327. return nil
  14328. }
  14329. return fmt.Errorf("unknown Wx nullable field %s", name)
  14330. }
  14331. // ResetField resets all changes in the mutation for the field with the given name.
  14332. // It returns an error if the field is not defined in the schema.
  14333. func (m *WxMutation) ResetField(name string) error {
  14334. switch name {
  14335. case wx.FieldCreatedAt:
  14336. m.ResetCreatedAt()
  14337. return nil
  14338. case wx.FieldUpdatedAt:
  14339. m.ResetUpdatedAt()
  14340. return nil
  14341. case wx.FieldStatus:
  14342. m.ResetStatus()
  14343. return nil
  14344. case wx.FieldDeletedAt:
  14345. m.ResetDeletedAt()
  14346. return nil
  14347. case wx.FieldServerID:
  14348. m.ResetServerID()
  14349. return nil
  14350. case wx.FieldPort:
  14351. m.ResetPort()
  14352. return nil
  14353. case wx.FieldProcessID:
  14354. m.ResetProcessID()
  14355. return nil
  14356. case wx.FieldCallback:
  14357. m.ResetCallback()
  14358. return nil
  14359. case wx.FieldWxid:
  14360. m.ResetWxid()
  14361. return nil
  14362. case wx.FieldAccount:
  14363. m.ResetAccount()
  14364. return nil
  14365. case wx.FieldNickname:
  14366. m.ResetNickname()
  14367. return nil
  14368. case wx.FieldTel:
  14369. m.ResetTel()
  14370. return nil
  14371. case wx.FieldHeadBig:
  14372. m.ResetHeadBig()
  14373. return nil
  14374. case wx.FieldOrganizationID:
  14375. m.ResetOrganizationID()
  14376. return nil
  14377. case wx.FieldAgentID:
  14378. m.ResetAgentID()
  14379. return nil
  14380. }
  14381. return fmt.Errorf("unknown Wx field %s", name)
  14382. }
  14383. // AddedEdges returns all edge names that were set/added in this mutation.
  14384. func (m *WxMutation) AddedEdges() []string {
  14385. edges := make([]string, 0, 2)
  14386. if m.server != nil {
  14387. edges = append(edges, wx.EdgeServer)
  14388. }
  14389. if m.agent != nil {
  14390. edges = append(edges, wx.EdgeAgent)
  14391. }
  14392. return edges
  14393. }
  14394. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14395. // name in this mutation.
  14396. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  14397. switch name {
  14398. case wx.EdgeServer:
  14399. if id := m.server; id != nil {
  14400. return []ent.Value{*id}
  14401. }
  14402. case wx.EdgeAgent:
  14403. if id := m.agent; id != nil {
  14404. return []ent.Value{*id}
  14405. }
  14406. }
  14407. return nil
  14408. }
  14409. // RemovedEdges returns all edge names that were removed in this mutation.
  14410. func (m *WxMutation) RemovedEdges() []string {
  14411. edges := make([]string, 0, 2)
  14412. return edges
  14413. }
  14414. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14415. // the given name in this mutation.
  14416. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  14417. return nil
  14418. }
  14419. // ClearedEdges returns all edge names that were cleared in this mutation.
  14420. func (m *WxMutation) ClearedEdges() []string {
  14421. edges := make([]string, 0, 2)
  14422. if m.clearedserver {
  14423. edges = append(edges, wx.EdgeServer)
  14424. }
  14425. if m.clearedagent {
  14426. edges = append(edges, wx.EdgeAgent)
  14427. }
  14428. return edges
  14429. }
  14430. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14431. // was cleared in this mutation.
  14432. func (m *WxMutation) EdgeCleared(name string) bool {
  14433. switch name {
  14434. case wx.EdgeServer:
  14435. return m.clearedserver
  14436. case wx.EdgeAgent:
  14437. return m.clearedagent
  14438. }
  14439. return false
  14440. }
  14441. // ClearEdge clears the value of the edge with the given name. It returns an error
  14442. // if that edge is not defined in the schema.
  14443. func (m *WxMutation) ClearEdge(name string) error {
  14444. switch name {
  14445. case wx.EdgeServer:
  14446. m.ClearServer()
  14447. return nil
  14448. case wx.EdgeAgent:
  14449. m.ClearAgent()
  14450. return nil
  14451. }
  14452. return fmt.Errorf("unknown Wx unique edge %s", name)
  14453. }
  14454. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14455. // It returns an error if the edge is not defined in the schema.
  14456. func (m *WxMutation) ResetEdge(name string) error {
  14457. switch name {
  14458. case wx.EdgeServer:
  14459. m.ResetServer()
  14460. return nil
  14461. case wx.EdgeAgent:
  14462. m.ResetAgent()
  14463. return nil
  14464. }
  14465. return fmt.Errorf("unknown Wx edge %s", name)
  14466. }