mutation.go 454 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571
  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. // ResetBackground resets all changes to the "background" field.
  430. func (m *AgentMutation) ResetBackground() {
  431. m.background = nil
  432. }
  433. // SetExamples sets the "examples" field.
  434. func (m *AgentMutation) SetExamples(s string) {
  435. m.examples = &s
  436. }
  437. // Examples returns the value of the "examples" field in the mutation.
  438. func (m *AgentMutation) Examples() (r string, exists bool) {
  439. v := m.examples
  440. if v == nil {
  441. return
  442. }
  443. return *v, true
  444. }
  445. // OldExamples returns the old "examples" field's value of the Agent entity.
  446. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  447. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  448. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  449. if !m.op.Is(OpUpdateOne) {
  450. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  451. }
  452. if m.id == nil || m.oldValue == nil {
  453. return v, errors.New("OldExamples requires an ID field in the mutation")
  454. }
  455. oldValue, err := m.oldValue(ctx)
  456. if err != nil {
  457. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  458. }
  459. return oldValue.Examples, nil
  460. }
  461. // ResetExamples resets all changes to the "examples" field.
  462. func (m *AgentMutation) ResetExamples() {
  463. m.examples = nil
  464. }
  465. // SetOrganizationID sets the "organization_id" field.
  466. func (m *AgentMutation) SetOrganizationID(u uint64) {
  467. m.organization_id = &u
  468. m.addorganization_id = nil
  469. }
  470. // OrganizationID returns the value of the "organization_id" field in the mutation.
  471. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  472. v := m.organization_id
  473. if v == nil {
  474. return
  475. }
  476. return *v, true
  477. }
  478. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  479. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  481. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  482. if !m.op.Is(OpUpdateOne) {
  483. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  484. }
  485. if m.id == nil || m.oldValue == nil {
  486. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  487. }
  488. oldValue, err := m.oldValue(ctx)
  489. if err != nil {
  490. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  491. }
  492. return oldValue.OrganizationID, nil
  493. }
  494. // AddOrganizationID adds u to the "organization_id" field.
  495. func (m *AgentMutation) AddOrganizationID(u int64) {
  496. if m.addorganization_id != nil {
  497. *m.addorganization_id += u
  498. } else {
  499. m.addorganization_id = &u
  500. }
  501. }
  502. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  503. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  504. v := m.addorganization_id
  505. if v == nil {
  506. return
  507. }
  508. return *v, true
  509. }
  510. // ResetOrganizationID resets all changes to the "organization_id" field.
  511. func (m *AgentMutation) ResetOrganizationID() {
  512. m.organization_id = nil
  513. m.addorganization_id = nil
  514. }
  515. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  516. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  517. if m.wx_agent == nil {
  518. m.wx_agent = make(map[uint64]struct{})
  519. }
  520. for i := range ids {
  521. m.wx_agent[ids[i]] = struct{}{}
  522. }
  523. }
  524. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  525. func (m *AgentMutation) ClearWxAgent() {
  526. m.clearedwx_agent = true
  527. }
  528. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  529. func (m *AgentMutation) WxAgentCleared() bool {
  530. return m.clearedwx_agent
  531. }
  532. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  533. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  534. if m.removedwx_agent == nil {
  535. m.removedwx_agent = make(map[uint64]struct{})
  536. }
  537. for i := range ids {
  538. delete(m.wx_agent, ids[i])
  539. m.removedwx_agent[ids[i]] = struct{}{}
  540. }
  541. }
  542. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  543. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  544. for id := range m.removedwx_agent {
  545. ids = append(ids, id)
  546. }
  547. return
  548. }
  549. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  550. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  551. for id := range m.wx_agent {
  552. ids = append(ids, id)
  553. }
  554. return
  555. }
  556. // ResetWxAgent resets all changes to the "wx_agent" edge.
  557. func (m *AgentMutation) ResetWxAgent() {
  558. m.wx_agent = nil
  559. m.clearedwx_agent = false
  560. m.removedwx_agent = nil
  561. }
  562. // Where appends a list predicates to the AgentMutation builder.
  563. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  564. m.predicates = append(m.predicates, ps...)
  565. }
  566. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  567. // users can use type-assertion to append predicates that do not depend on any generated package.
  568. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  569. p := make([]predicate.Agent, len(ps))
  570. for i := range ps {
  571. p[i] = ps[i]
  572. }
  573. m.Where(p...)
  574. }
  575. // Op returns the operation name.
  576. func (m *AgentMutation) Op() Op {
  577. return m.op
  578. }
  579. // SetOp allows setting the mutation operation.
  580. func (m *AgentMutation) SetOp(op Op) {
  581. m.op = op
  582. }
  583. // Type returns the node type of this mutation (Agent).
  584. func (m *AgentMutation) Type() string {
  585. return m.typ
  586. }
  587. // Fields returns all fields that were changed during this mutation. Note that in
  588. // order to get all numeric fields that were incremented/decremented, call
  589. // AddedFields().
  590. func (m *AgentMutation) Fields() []string {
  591. fields := make([]string, 0, 9)
  592. if m.created_at != nil {
  593. fields = append(fields, agent.FieldCreatedAt)
  594. }
  595. if m.updated_at != nil {
  596. fields = append(fields, agent.FieldUpdatedAt)
  597. }
  598. if m.deleted_at != nil {
  599. fields = append(fields, agent.FieldDeletedAt)
  600. }
  601. if m.name != nil {
  602. fields = append(fields, agent.FieldName)
  603. }
  604. if m.role != nil {
  605. fields = append(fields, agent.FieldRole)
  606. }
  607. if m.status != nil {
  608. fields = append(fields, agent.FieldStatus)
  609. }
  610. if m.background != nil {
  611. fields = append(fields, agent.FieldBackground)
  612. }
  613. if m.examples != nil {
  614. fields = append(fields, agent.FieldExamples)
  615. }
  616. if m.organization_id != nil {
  617. fields = append(fields, agent.FieldOrganizationID)
  618. }
  619. return fields
  620. }
  621. // Field returns the value of a field with the given name. The second boolean
  622. // return value indicates that this field was not set, or was not defined in the
  623. // schema.
  624. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  625. switch name {
  626. case agent.FieldCreatedAt:
  627. return m.CreatedAt()
  628. case agent.FieldUpdatedAt:
  629. return m.UpdatedAt()
  630. case agent.FieldDeletedAt:
  631. return m.DeletedAt()
  632. case agent.FieldName:
  633. return m.Name()
  634. case agent.FieldRole:
  635. return m.Role()
  636. case agent.FieldStatus:
  637. return m.Status()
  638. case agent.FieldBackground:
  639. return m.Background()
  640. case agent.FieldExamples:
  641. return m.Examples()
  642. case agent.FieldOrganizationID:
  643. return m.OrganizationID()
  644. }
  645. return nil, false
  646. }
  647. // OldField returns the old value of the field from the database. An error is
  648. // returned if the mutation operation is not UpdateOne, or the query to the
  649. // database failed.
  650. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  651. switch name {
  652. case agent.FieldCreatedAt:
  653. return m.OldCreatedAt(ctx)
  654. case agent.FieldUpdatedAt:
  655. return m.OldUpdatedAt(ctx)
  656. case agent.FieldDeletedAt:
  657. return m.OldDeletedAt(ctx)
  658. case agent.FieldName:
  659. return m.OldName(ctx)
  660. case agent.FieldRole:
  661. return m.OldRole(ctx)
  662. case agent.FieldStatus:
  663. return m.OldStatus(ctx)
  664. case agent.FieldBackground:
  665. return m.OldBackground(ctx)
  666. case agent.FieldExamples:
  667. return m.OldExamples(ctx)
  668. case agent.FieldOrganizationID:
  669. return m.OldOrganizationID(ctx)
  670. }
  671. return nil, fmt.Errorf("unknown Agent field %s", name)
  672. }
  673. // SetField sets the value of a field with the given name. It returns an error if
  674. // the field is not defined in the schema, or if the type mismatched the field
  675. // type.
  676. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  677. switch name {
  678. case agent.FieldCreatedAt:
  679. v, ok := value.(time.Time)
  680. if !ok {
  681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  682. }
  683. m.SetCreatedAt(v)
  684. return nil
  685. case agent.FieldUpdatedAt:
  686. v, ok := value.(time.Time)
  687. if !ok {
  688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  689. }
  690. m.SetUpdatedAt(v)
  691. return nil
  692. case agent.FieldDeletedAt:
  693. v, ok := value.(time.Time)
  694. if !ok {
  695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  696. }
  697. m.SetDeletedAt(v)
  698. return nil
  699. case agent.FieldName:
  700. v, ok := value.(string)
  701. if !ok {
  702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  703. }
  704. m.SetName(v)
  705. return nil
  706. case agent.FieldRole:
  707. v, ok := value.(string)
  708. if !ok {
  709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  710. }
  711. m.SetRole(v)
  712. return nil
  713. case agent.FieldStatus:
  714. v, ok := value.(int)
  715. if !ok {
  716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  717. }
  718. m.SetStatus(v)
  719. return nil
  720. case agent.FieldBackground:
  721. v, ok := value.(string)
  722. if !ok {
  723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  724. }
  725. m.SetBackground(v)
  726. return nil
  727. case agent.FieldExamples:
  728. v, ok := value.(string)
  729. if !ok {
  730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  731. }
  732. m.SetExamples(v)
  733. return nil
  734. case agent.FieldOrganizationID:
  735. v, ok := value.(uint64)
  736. if !ok {
  737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  738. }
  739. m.SetOrganizationID(v)
  740. return nil
  741. }
  742. return fmt.Errorf("unknown Agent field %s", name)
  743. }
  744. // AddedFields returns all numeric fields that were incremented/decremented during
  745. // this mutation.
  746. func (m *AgentMutation) AddedFields() []string {
  747. var fields []string
  748. if m.addstatus != nil {
  749. fields = append(fields, agent.FieldStatus)
  750. }
  751. if m.addorganization_id != nil {
  752. fields = append(fields, agent.FieldOrganizationID)
  753. }
  754. return fields
  755. }
  756. // AddedField returns the numeric value that was incremented/decremented on a field
  757. // with the given name. The second boolean return value indicates that this field
  758. // was not set, or was not defined in the schema.
  759. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  760. switch name {
  761. case agent.FieldStatus:
  762. return m.AddedStatus()
  763. case agent.FieldOrganizationID:
  764. return m.AddedOrganizationID()
  765. }
  766. return nil, false
  767. }
  768. // AddField adds the value to the field with the given name. It returns an error if
  769. // the field is not defined in the schema, or if the type mismatched the field
  770. // type.
  771. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  772. switch name {
  773. case agent.FieldStatus:
  774. v, ok := value.(int)
  775. if !ok {
  776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  777. }
  778. m.AddStatus(v)
  779. return nil
  780. case agent.FieldOrganizationID:
  781. v, ok := value.(int64)
  782. if !ok {
  783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  784. }
  785. m.AddOrganizationID(v)
  786. return nil
  787. }
  788. return fmt.Errorf("unknown Agent numeric field %s", name)
  789. }
  790. // ClearedFields returns all nullable fields that were cleared during this
  791. // mutation.
  792. func (m *AgentMutation) ClearedFields() []string {
  793. var fields []string
  794. if m.FieldCleared(agent.FieldDeletedAt) {
  795. fields = append(fields, agent.FieldDeletedAt)
  796. }
  797. if m.FieldCleared(agent.FieldStatus) {
  798. fields = append(fields, agent.FieldStatus)
  799. }
  800. return fields
  801. }
  802. // FieldCleared returns a boolean indicating if a field with the given name was
  803. // cleared in this mutation.
  804. func (m *AgentMutation) FieldCleared(name string) bool {
  805. _, ok := m.clearedFields[name]
  806. return ok
  807. }
  808. // ClearField clears the value of the field with the given name. It returns an
  809. // error if the field is not defined in the schema.
  810. func (m *AgentMutation) ClearField(name string) error {
  811. switch name {
  812. case agent.FieldDeletedAt:
  813. m.ClearDeletedAt()
  814. return nil
  815. case agent.FieldStatus:
  816. m.ClearStatus()
  817. return nil
  818. }
  819. return fmt.Errorf("unknown Agent nullable field %s", name)
  820. }
  821. // ResetField resets all changes in the mutation for the field with the given name.
  822. // It returns an error if the field is not defined in the schema.
  823. func (m *AgentMutation) ResetField(name string) error {
  824. switch name {
  825. case agent.FieldCreatedAt:
  826. m.ResetCreatedAt()
  827. return nil
  828. case agent.FieldUpdatedAt:
  829. m.ResetUpdatedAt()
  830. return nil
  831. case agent.FieldDeletedAt:
  832. m.ResetDeletedAt()
  833. return nil
  834. case agent.FieldName:
  835. m.ResetName()
  836. return nil
  837. case agent.FieldRole:
  838. m.ResetRole()
  839. return nil
  840. case agent.FieldStatus:
  841. m.ResetStatus()
  842. return nil
  843. case agent.FieldBackground:
  844. m.ResetBackground()
  845. return nil
  846. case agent.FieldExamples:
  847. m.ResetExamples()
  848. return nil
  849. case agent.FieldOrganizationID:
  850. m.ResetOrganizationID()
  851. return nil
  852. }
  853. return fmt.Errorf("unknown Agent field %s", name)
  854. }
  855. // AddedEdges returns all edge names that were set/added in this mutation.
  856. func (m *AgentMutation) AddedEdges() []string {
  857. edges := make([]string, 0, 1)
  858. if m.wx_agent != nil {
  859. edges = append(edges, agent.EdgeWxAgent)
  860. }
  861. return edges
  862. }
  863. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  864. // name in this mutation.
  865. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  866. switch name {
  867. case agent.EdgeWxAgent:
  868. ids := make([]ent.Value, 0, len(m.wx_agent))
  869. for id := range m.wx_agent {
  870. ids = append(ids, id)
  871. }
  872. return ids
  873. }
  874. return nil
  875. }
  876. // RemovedEdges returns all edge names that were removed in this mutation.
  877. func (m *AgentMutation) RemovedEdges() []string {
  878. edges := make([]string, 0, 1)
  879. if m.removedwx_agent != nil {
  880. edges = append(edges, agent.EdgeWxAgent)
  881. }
  882. return edges
  883. }
  884. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  885. // the given name in this mutation.
  886. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  887. switch name {
  888. case agent.EdgeWxAgent:
  889. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  890. for id := range m.removedwx_agent {
  891. ids = append(ids, id)
  892. }
  893. return ids
  894. }
  895. return nil
  896. }
  897. // ClearedEdges returns all edge names that were cleared in this mutation.
  898. func (m *AgentMutation) ClearedEdges() []string {
  899. edges := make([]string, 0, 1)
  900. if m.clearedwx_agent {
  901. edges = append(edges, agent.EdgeWxAgent)
  902. }
  903. return edges
  904. }
  905. // EdgeCleared returns a boolean which indicates if the edge with the given name
  906. // was cleared in this mutation.
  907. func (m *AgentMutation) EdgeCleared(name string) bool {
  908. switch name {
  909. case agent.EdgeWxAgent:
  910. return m.clearedwx_agent
  911. }
  912. return false
  913. }
  914. // ClearEdge clears the value of the edge with the given name. It returns an error
  915. // if that edge is not defined in the schema.
  916. func (m *AgentMutation) ClearEdge(name string) error {
  917. switch name {
  918. }
  919. return fmt.Errorf("unknown Agent unique edge %s", name)
  920. }
  921. // ResetEdge resets all changes to the edge with the given name in this mutation.
  922. // It returns an error if the edge is not defined in the schema.
  923. func (m *AgentMutation) ResetEdge(name string) error {
  924. switch name {
  925. case agent.EdgeWxAgent:
  926. m.ResetWxAgent()
  927. return nil
  928. }
  929. return fmt.Errorf("unknown Agent edge %s", name)
  930. }
  931. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  932. type BatchMsgMutation struct {
  933. config
  934. op Op
  935. typ string
  936. id *uint64
  937. created_at *time.Time
  938. updated_at *time.Time
  939. deleted_at *time.Time
  940. status *uint8
  941. addstatus *int8
  942. batch_no *string
  943. fromwxid *string
  944. msg *string
  945. tag *string
  946. total *int32
  947. addtotal *int32
  948. success *int32
  949. addsuccess *int32
  950. fail *int32
  951. addfail *int32
  952. start_time *time.Time
  953. stop_time *time.Time
  954. clearedFields map[string]struct{}
  955. done bool
  956. oldValue func(context.Context) (*BatchMsg, error)
  957. predicates []predicate.BatchMsg
  958. }
  959. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  960. // batchmsgOption allows management of the mutation configuration using functional options.
  961. type batchmsgOption func(*BatchMsgMutation)
  962. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  963. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  964. m := &BatchMsgMutation{
  965. config: c,
  966. op: op,
  967. typ: TypeBatchMsg,
  968. clearedFields: make(map[string]struct{}),
  969. }
  970. for _, opt := range opts {
  971. opt(m)
  972. }
  973. return m
  974. }
  975. // withBatchMsgID sets the ID field of the mutation.
  976. func withBatchMsgID(id uint64) batchmsgOption {
  977. return func(m *BatchMsgMutation) {
  978. var (
  979. err error
  980. once sync.Once
  981. value *BatchMsg
  982. )
  983. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  984. once.Do(func() {
  985. if m.done {
  986. err = errors.New("querying old values post mutation is not allowed")
  987. } else {
  988. value, err = m.Client().BatchMsg.Get(ctx, id)
  989. }
  990. })
  991. return value, err
  992. }
  993. m.id = &id
  994. }
  995. }
  996. // withBatchMsg sets the old BatchMsg of the mutation.
  997. func withBatchMsg(node *BatchMsg) batchmsgOption {
  998. return func(m *BatchMsgMutation) {
  999. m.oldValue = func(context.Context) (*BatchMsg, error) {
  1000. return node, nil
  1001. }
  1002. m.id = &node.ID
  1003. }
  1004. }
  1005. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1006. // executed in a transaction (ent.Tx), a transactional client is returned.
  1007. func (m BatchMsgMutation) Client() *Client {
  1008. client := &Client{config: m.config}
  1009. client.init()
  1010. return client
  1011. }
  1012. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1013. // it returns an error otherwise.
  1014. func (m BatchMsgMutation) Tx() (*Tx, error) {
  1015. if _, ok := m.driver.(*txDriver); !ok {
  1016. return nil, errors.New("ent: mutation is not running in a transaction")
  1017. }
  1018. tx := &Tx{config: m.config}
  1019. tx.init()
  1020. return tx, nil
  1021. }
  1022. // SetID sets the value of the id field. Note that this
  1023. // operation is only accepted on creation of BatchMsg entities.
  1024. func (m *BatchMsgMutation) SetID(id uint64) {
  1025. m.id = &id
  1026. }
  1027. // ID returns the ID value in the mutation. Note that the ID is only available
  1028. // if it was provided to the builder or after it was returned from the database.
  1029. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  1030. if m.id == nil {
  1031. return
  1032. }
  1033. return *m.id, true
  1034. }
  1035. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1036. // That means, if the mutation is applied within a transaction with an isolation level such
  1037. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1038. // or updated by the mutation.
  1039. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  1040. switch {
  1041. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1042. id, exists := m.ID()
  1043. if exists {
  1044. return []uint64{id}, nil
  1045. }
  1046. fallthrough
  1047. case m.op.Is(OpUpdate | OpDelete):
  1048. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  1049. default:
  1050. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1051. }
  1052. }
  1053. // SetCreatedAt sets the "created_at" field.
  1054. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  1055. m.created_at = &t
  1056. }
  1057. // CreatedAt returns the value of the "created_at" field in the mutation.
  1058. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  1059. v := m.created_at
  1060. if v == nil {
  1061. return
  1062. }
  1063. return *v, true
  1064. }
  1065. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  1066. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1067. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1068. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  1069. if !m.op.Is(OpUpdateOne) {
  1070. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  1071. }
  1072. if m.id == nil || m.oldValue == nil {
  1073. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  1074. }
  1075. oldValue, err := m.oldValue(ctx)
  1076. if err != nil {
  1077. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  1078. }
  1079. return oldValue.CreatedAt, nil
  1080. }
  1081. // ResetCreatedAt resets all changes to the "created_at" field.
  1082. func (m *BatchMsgMutation) ResetCreatedAt() {
  1083. m.created_at = nil
  1084. }
  1085. // SetUpdatedAt sets the "updated_at" field.
  1086. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  1087. m.updated_at = &t
  1088. }
  1089. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  1090. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  1091. v := m.updated_at
  1092. if v == nil {
  1093. return
  1094. }
  1095. return *v, true
  1096. }
  1097. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  1098. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1099. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1100. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  1101. if !m.op.Is(OpUpdateOne) {
  1102. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  1103. }
  1104. if m.id == nil || m.oldValue == nil {
  1105. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  1106. }
  1107. oldValue, err := m.oldValue(ctx)
  1108. if err != nil {
  1109. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  1110. }
  1111. return oldValue.UpdatedAt, nil
  1112. }
  1113. // ResetUpdatedAt resets all changes to the "updated_at" field.
  1114. func (m *BatchMsgMutation) ResetUpdatedAt() {
  1115. m.updated_at = nil
  1116. }
  1117. // SetDeletedAt sets the "deleted_at" field.
  1118. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  1119. m.deleted_at = &t
  1120. }
  1121. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  1122. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  1123. v := m.deleted_at
  1124. if v == nil {
  1125. return
  1126. }
  1127. return *v, true
  1128. }
  1129. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  1130. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1132. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  1133. if !m.op.Is(OpUpdateOne) {
  1134. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  1135. }
  1136. if m.id == nil || m.oldValue == nil {
  1137. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  1138. }
  1139. oldValue, err := m.oldValue(ctx)
  1140. if err != nil {
  1141. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  1142. }
  1143. return oldValue.DeletedAt, nil
  1144. }
  1145. // ClearDeletedAt clears the value of the "deleted_at" field.
  1146. func (m *BatchMsgMutation) ClearDeletedAt() {
  1147. m.deleted_at = nil
  1148. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  1149. }
  1150. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  1151. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  1152. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  1153. return ok
  1154. }
  1155. // ResetDeletedAt resets all changes to the "deleted_at" field.
  1156. func (m *BatchMsgMutation) ResetDeletedAt() {
  1157. m.deleted_at = nil
  1158. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  1159. }
  1160. // SetStatus sets the "status" field.
  1161. func (m *BatchMsgMutation) SetStatus(u uint8) {
  1162. m.status = &u
  1163. m.addstatus = nil
  1164. }
  1165. // Status returns the value of the "status" field in the mutation.
  1166. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  1167. v := m.status
  1168. if v == nil {
  1169. return
  1170. }
  1171. return *v, true
  1172. }
  1173. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  1174. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1176. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  1177. if !m.op.Is(OpUpdateOne) {
  1178. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  1179. }
  1180. if m.id == nil || m.oldValue == nil {
  1181. return v, errors.New("OldStatus requires an ID field in the mutation")
  1182. }
  1183. oldValue, err := m.oldValue(ctx)
  1184. if err != nil {
  1185. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  1186. }
  1187. return oldValue.Status, nil
  1188. }
  1189. // AddStatus adds u to the "status" field.
  1190. func (m *BatchMsgMutation) AddStatus(u int8) {
  1191. if m.addstatus != nil {
  1192. *m.addstatus += u
  1193. } else {
  1194. m.addstatus = &u
  1195. }
  1196. }
  1197. // AddedStatus returns the value that was added to the "status" field in this mutation.
  1198. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  1199. v := m.addstatus
  1200. if v == nil {
  1201. return
  1202. }
  1203. return *v, true
  1204. }
  1205. // ClearStatus clears the value of the "status" field.
  1206. func (m *BatchMsgMutation) ClearStatus() {
  1207. m.status = nil
  1208. m.addstatus = nil
  1209. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  1210. }
  1211. // StatusCleared returns if the "status" field was cleared in this mutation.
  1212. func (m *BatchMsgMutation) StatusCleared() bool {
  1213. _, ok := m.clearedFields[batchmsg.FieldStatus]
  1214. return ok
  1215. }
  1216. // ResetStatus resets all changes to the "status" field.
  1217. func (m *BatchMsgMutation) ResetStatus() {
  1218. m.status = nil
  1219. m.addstatus = nil
  1220. delete(m.clearedFields, batchmsg.FieldStatus)
  1221. }
  1222. // SetBatchNo sets the "batch_no" field.
  1223. func (m *BatchMsgMutation) SetBatchNo(s string) {
  1224. m.batch_no = &s
  1225. }
  1226. // BatchNo returns the value of the "batch_no" field in the mutation.
  1227. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  1228. v := m.batch_no
  1229. if v == nil {
  1230. return
  1231. }
  1232. return *v, true
  1233. }
  1234. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  1235. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1237. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  1238. if !m.op.Is(OpUpdateOne) {
  1239. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  1240. }
  1241. if m.id == nil || m.oldValue == nil {
  1242. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  1243. }
  1244. oldValue, err := m.oldValue(ctx)
  1245. if err != nil {
  1246. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  1247. }
  1248. return oldValue.BatchNo, nil
  1249. }
  1250. // ClearBatchNo clears the value of the "batch_no" field.
  1251. func (m *BatchMsgMutation) ClearBatchNo() {
  1252. m.batch_no = nil
  1253. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  1254. }
  1255. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  1256. func (m *BatchMsgMutation) BatchNoCleared() bool {
  1257. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  1258. return ok
  1259. }
  1260. // ResetBatchNo resets all changes to the "batch_no" field.
  1261. func (m *BatchMsgMutation) ResetBatchNo() {
  1262. m.batch_no = nil
  1263. delete(m.clearedFields, batchmsg.FieldBatchNo)
  1264. }
  1265. // SetFromwxid sets the "fromwxid" field.
  1266. func (m *BatchMsgMutation) SetFromwxid(s string) {
  1267. m.fromwxid = &s
  1268. }
  1269. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  1270. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  1271. v := m.fromwxid
  1272. if v == nil {
  1273. return
  1274. }
  1275. return *v, true
  1276. }
  1277. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  1278. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1279. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1280. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  1281. if !m.op.Is(OpUpdateOne) {
  1282. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  1283. }
  1284. if m.id == nil || m.oldValue == nil {
  1285. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  1286. }
  1287. oldValue, err := m.oldValue(ctx)
  1288. if err != nil {
  1289. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  1290. }
  1291. return oldValue.Fromwxid, nil
  1292. }
  1293. // ClearFromwxid clears the value of the "fromwxid" field.
  1294. func (m *BatchMsgMutation) ClearFromwxid() {
  1295. m.fromwxid = nil
  1296. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  1297. }
  1298. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  1299. func (m *BatchMsgMutation) FromwxidCleared() bool {
  1300. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  1301. return ok
  1302. }
  1303. // ResetFromwxid resets all changes to the "fromwxid" field.
  1304. func (m *BatchMsgMutation) ResetFromwxid() {
  1305. m.fromwxid = nil
  1306. delete(m.clearedFields, batchmsg.FieldFromwxid)
  1307. }
  1308. // SetMsg sets the "msg" field.
  1309. func (m *BatchMsgMutation) SetMsg(s string) {
  1310. m.msg = &s
  1311. }
  1312. // Msg returns the value of the "msg" field in the mutation.
  1313. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  1314. v := m.msg
  1315. if v == nil {
  1316. return
  1317. }
  1318. return *v, true
  1319. }
  1320. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  1321. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1322. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1323. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  1324. if !m.op.Is(OpUpdateOne) {
  1325. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  1326. }
  1327. if m.id == nil || m.oldValue == nil {
  1328. return v, errors.New("OldMsg requires an ID field in the mutation")
  1329. }
  1330. oldValue, err := m.oldValue(ctx)
  1331. if err != nil {
  1332. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  1333. }
  1334. return oldValue.Msg, nil
  1335. }
  1336. // ClearMsg clears the value of the "msg" field.
  1337. func (m *BatchMsgMutation) ClearMsg() {
  1338. m.msg = nil
  1339. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  1340. }
  1341. // MsgCleared returns if the "msg" field was cleared in this mutation.
  1342. func (m *BatchMsgMutation) MsgCleared() bool {
  1343. _, ok := m.clearedFields[batchmsg.FieldMsg]
  1344. return ok
  1345. }
  1346. // ResetMsg resets all changes to the "msg" field.
  1347. func (m *BatchMsgMutation) ResetMsg() {
  1348. m.msg = nil
  1349. delete(m.clearedFields, batchmsg.FieldMsg)
  1350. }
  1351. // SetTag sets the "tag" field.
  1352. func (m *BatchMsgMutation) SetTag(s string) {
  1353. m.tag = &s
  1354. }
  1355. // Tag returns the value of the "tag" field in the mutation.
  1356. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  1357. v := m.tag
  1358. if v == nil {
  1359. return
  1360. }
  1361. return *v, true
  1362. }
  1363. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  1364. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1366. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  1367. if !m.op.Is(OpUpdateOne) {
  1368. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  1369. }
  1370. if m.id == nil || m.oldValue == nil {
  1371. return v, errors.New("OldTag requires an ID field in the mutation")
  1372. }
  1373. oldValue, err := m.oldValue(ctx)
  1374. if err != nil {
  1375. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  1376. }
  1377. return oldValue.Tag, nil
  1378. }
  1379. // ClearTag clears the value of the "tag" field.
  1380. func (m *BatchMsgMutation) ClearTag() {
  1381. m.tag = nil
  1382. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  1383. }
  1384. // TagCleared returns if the "tag" field was cleared in this mutation.
  1385. func (m *BatchMsgMutation) TagCleared() bool {
  1386. _, ok := m.clearedFields[batchmsg.FieldTag]
  1387. return ok
  1388. }
  1389. // ResetTag resets all changes to the "tag" field.
  1390. func (m *BatchMsgMutation) ResetTag() {
  1391. m.tag = nil
  1392. delete(m.clearedFields, batchmsg.FieldTag)
  1393. }
  1394. // SetTotal sets the "total" field.
  1395. func (m *BatchMsgMutation) SetTotal(i int32) {
  1396. m.total = &i
  1397. m.addtotal = nil
  1398. }
  1399. // Total returns the value of the "total" field in the mutation.
  1400. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  1401. v := m.total
  1402. if v == nil {
  1403. return
  1404. }
  1405. return *v, true
  1406. }
  1407. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  1408. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1410. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  1411. if !m.op.Is(OpUpdateOne) {
  1412. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  1413. }
  1414. if m.id == nil || m.oldValue == nil {
  1415. return v, errors.New("OldTotal requires an ID field in the mutation")
  1416. }
  1417. oldValue, err := m.oldValue(ctx)
  1418. if err != nil {
  1419. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  1420. }
  1421. return oldValue.Total, nil
  1422. }
  1423. // AddTotal adds i to the "total" field.
  1424. func (m *BatchMsgMutation) AddTotal(i int32) {
  1425. if m.addtotal != nil {
  1426. *m.addtotal += i
  1427. } else {
  1428. m.addtotal = &i
  1429. }
  1430. }
  1431. // AddedTotal returns the value that was added to the "total" field in this mutation.
  1432. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  1433. v := m.addtotal
  1434. if v == nil {
  1435. return
  1436. }
  1437. return *v, true
  1438. }
  1439. // ClearTotal clears the value of the "total" field.
  1440. func (m *BatchMsgMutation) ClearTotal() {
  1441. m.total = nil
  1442. m.addtotal = nil
  1443. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  1444. }
  1445. // TotalCleared returns if the "total" field was cleared in this mutation.
  1446. func (m *BatchMsgMutation) TotalCleared() bool {
  1447. _, ok := m.clearedFields[batchmsg.FieldTotal]
  1448. return ok
  1449. }
  1450. // ResetTotal resets all changes to the "total" field.
  1451. func (m *BatchMsgMutation) ResetTotal() {
  1452. m.total = nil
  1453. m.addtotal = nil
  1454. delete(m.clearedFields, batchmsg.FieldTotal)
  1455. }
  1456. // SetSuccess sets the "success" field.
  1457. func (m *BatchMsgMutation) SetSuccess(i int32) {
  1458. m.success = &i
  1459. m.addsuccess = nil
  1460. }
  1461. // Success returns the value of the "success" field in the mutation.
  1462. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  1463. v := m.success
  1464. if v == nil {
  1465. return
  1466. }
  1467. return *v, true
  1468. }
  1469. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  1470. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1472. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  1473. if !m.op.Is(OpUpdateOne) {
  1474. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  1475. }
  1476. if m.id == nil || m.oldValue == nil {
  1477. return v, errors.New("OldSuccess requires an ID field in the mutation")
  1478. }
  1479. oldValue, err := m.oldValue(ctx)
  1480. if err != nil {
  1481. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  1482. }
  1483. return oldValue.Success, nil
  1484. }
  1485. // AddSuccess adds i to the "success" field.
  1486. func (m *BatchMsgMutation) AddSuccess(i int32) {
  1487. if m.addsuccess != nil {
  1488. *m.addsuccess += i
  1489. } else {
  1490. m.addsuccess = &i
  1491. }
  1492. }
  1493. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  1494. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  1495. v := m.addsuccess
  1496. if v == nil {
  1497. return
  1498. }
  1499. return *v, true
  1500. }
  1501. // ClearSuccess clears the value of the "success" field.
  1502. func (m *BatchMsgMutation) ClearSuccess() {
  1503. m.success = nil
  1504. m.addsuccess = nil
  1505. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  1506. }
  1507. // SuccessCleared returns if the "success" field was cleared in this mutation.
  1508. func (m *BatchMsgMutation) SuccessCleared() bool {
  1509. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  1510. return ok
  1511. }
  1512. // ResetSuccess resets all changes to the "success" field.
  1513. func (m *BatchMsgMutation) ResetSuccess() {
  1514. m.success = nil
  1515. m.addsuccess = nil
  1516. delete(m.clearedFields, batchmsg.FieldSuccess)
  1517. }
  1518. // SetFail sets the "fail" field.
  1519. func (m *BatchMsgMutation) SetFail(i int32) {
  1520. m.fail = &i
  1521. m.addfail = nil
  1522. }
  1523. // Fail returns the value of the "fail" field in the mutation.
  1524. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  1525. v := m.fail
  1526. if v == nil {
  1527. return
  1528. }
  1529. return *v, true
  1530. }
  1531. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  1532. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1534. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  1535. if !m.op.Is(OpUpdateOne) {
  1536. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  1537. }
  1538. if m.id == nil || m.oldValue == nil {
  1539. return v, errors.New("OldFail requires an ID field in the mutation")
  1540. }
  1541. oldValue, err := m.oldValue(ctx)
  1542. if err != nil {
  1543. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  1544. }
  1545. return oldValue.Fail, nil
  1546. }
  1547. // AddFail adds i to the "fail" field.
  1548. func (m *BatchMsgMutation) AddFail(i int32) {
  1549. if m.addfail != nil {
  1550. *m.addfail += i
  1551. } else {
  1552. m.addfail = &i
  1553. }
  1554. }
  1555. // AddedFail returns the value that was added to the "fail" field in this mutation.
  1556. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  1557. v := m.addfail
  1558. if v == nil {
  1559. return
  1560. }
  1561. return *v, true
  1562. }
  1563. // ClearFail clears the value of the "fail" field.
  1564. func (m *BatchMsgMutation) ClearFail() {
  1565. m.fail = nil
  1566. m.addfail = nil
  1567. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  1568. }
  1569. // FailCleared returns if the "fail" field was cleared in this mutation.
  1570. func (m *BatchMsgMutation) FailCleared() bool {
  1571. _, ok := m.clearedFields[batchmsg.FieldFail]
  1572. return ok
  1573. }
  1574. // ResetFail resets all changes to the "fail" field.
  1575. func (m *BatchMsgMutation) ResetFail() {
  1576. m.fail = nil
  1577. m.addfail = nil
  1578. delete(m.clearedFields, batchmsg.FieldFail)
  1579. }
  1580. // SetStartTime sets the "start_time" field.
  1581. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  1582. m.start_time = &t
  1583. }
  1584. // StartTime returns the value of the "start_time" field in the mutation.
  1585. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  1586. v := m.start_time
  1587. if v == nil {
  1588. return
  1589. }
  1590. return *v, true
  1591. }
  1592. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  1593. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1595. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  1596. if !m.op.Is(OpUpdateOne) {
  1597. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  1598. }
  1599. if m.id == nil || m.oldValue == nil {
  1600. return v, errors.New("OldStartTime requires an ID field in the mutation")
  1601. }
  1602. oldValue, err := m.oldValue(ctx)
  1603. if err != nil {
  1604. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  1605. }
  1606. return oldValue.StartTime, nil
  1607. }
  1608. // ClearStartTime clears the value of the "start_time" field.
  1609. func (m *BatchMsgMutation) ClearStartTime() {
  1610. m.start_time = nil
  1611. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  1612. }
  1613. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  1614. func (m *BatchMsgMutation) StartTimeCleared() bool {
  1615. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  1616. return ok
  1617. }
  1618. // ResetStartTime resets all changes to the "start_time" field.
  1619. func (m *BatchMsgMutation) ResetStartTime() {
  1620. m.start_time = nil
  1621. delete(m.clearedFields, batchmsg.FieldStartTime)
  1622. }
  1623. // SetStopTime sets the "stop_time" field.
  1624. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  1625. m.stop_time = &t
  1626. }
  1627. // StopTime returns the value of the "stop_time" field in the mutation.
  1628. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  1629. v := m.stop_time
  1630. if v == nil {
  1631. return
  1632. }
  1633. return *v, true
  1634. }
  1635. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  1636. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1638. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  1639. if !m.op.Is(OpUpdateOne) {
  1640. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  1641. }
  1642. if m.id == nil || m.oldValue == nil {
  1643. return v, errors.New("OldStopTime requires an ID field in the mutation")
  1644. }
  1645. oldValue, err := m.oldValue(ctx)
  1646. if err != nil {
  1647. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  1648. }
  1649. return oldValue.StopTime, nil
  1650. }
  1651. // ClearStopTime clears the value of the "stop_time" field.
  1652. func (m *BatchMsgMutation) ClearStopTime() {
  1653. m.stop_time = nil
  1654. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  1655. }
  1656. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  1657. func (m *BatchMsgMutation) StopTimeCleared() bool {
  1658. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  1659. return ok
  1660. }
  1661. // ResetStopTime resets all changes to the "stop_time" field.
  1662. func (m *BatchMsgMutation) ResetStopTime() {
  1663. m.stop_time = nil
  1664. delete(m.clearedFields, batchmsg.FieldStopTime)
  1665. }
  1666. // Where appends a list predicates to the BatchMsgMutation builder.
  1667. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  1668. m.predicates = append(m.predicates, ps...)
  1669. }
  1670. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  1671. // users can use type-assertion to append predicates that do not depend on any generated package.
  1672. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  1673. p := make([]predicate.BatchMsg, len(ps))
  1674. for i := range ps {
  1675. p[i] = ps[i]
  1676. }
  1677. m.Where(p...)
  1678. }
  1679. // Op returns the operation name.
  1680. func (m *BatchMsgMutation) Op() Op {
  1681. return m.op
  1682. }
  1683. // SetOp allows setting the mutation operation.
  1684. func (m *BatchMsgMutation) SetOp(op Op) {
  1685. m.op = op
  1686. }
  1687. // Type returns the node type of this mutation (BatchMsg).
  1688. func (m *BatchMsgMutation) Type() string {
  1689. return m.typ
  1690. }
  1691. // Fields returns all fields that were changed during this mutation. Note that in
  1692. // order to get all numeric fields that were incremented/decremented, call
  1693. // AddedFields().
  1694. func (m *BatchMsgMutation) Fields() []string {
  1695. fields := make([]string, 0, 13)
  1696. if m.created_at != nil {
  1697. fields = append(fields, batchmsg.FieldCreatedAt)
  1698. }
  1699. if m.updated_at != nil {
  1700. fields = append(fields, batchmsg.FieldUpdatedAt)
  1701. }
  1702. if m.deleted_at != nil {
  1703. fields = append(fields, batchmsg.FieldDeletedAt)
  1704. }
  1705. if m.status != nil {
  1706. fields = append(fields, batchmsg.FieldStatus)
  1707. }
  1708. if m.batch_no != nil {
  1709. fields = append(fields, batchmsg.FieldBatchNo)
  1710. }
  1711. if m.fromwxid != nil {
  1712. fields = append(fields, batchmsg.FieldFromwxid)
  1713. }
  1714. if m.msg != nil {
  1715. fields = append(fields, batchmsg.FieldMsg)
  1716. }
  1717. if m.tag != nil {
  1718. fields = append(fields, batchmsg.FieldTag)
  1719. }
  1720. if m.total != nil {
  1721. fields = append(fields, batchmsg.FieldTotal)
  1722. }
  1723. if m.success != nil {
  1724. fields = append(fields, batchmsg.FieldSuccess)
  1725. }
  1726. if m.fail != nil {
  1727. fields = append(fields, batchmsg.FieldFail)
  1728. }
  1729. if m.start_time != nil {
  1730. fields = append(fields, batchmsg.FieldStartTime)
  1731. }
  1732. if m.stop_time != nil {
  1733. fields = append(fields, batchmsg.FieldStopTime)
  1734. }
  1735. return fields
  1736. }
  1737. // Field returns the value of a field with the given name. The second boolean
  1738. // return value indicates that this field was not set, or was not defined in the
  1739. // schema.
  1740. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  1741. switch name {
  1742. case batchmsg.FieldCreatedAt:
  1743. return m.CreatedAt()
  1744. case batchmsg.FieldUpdatedAt:
  1745. return m.UpdatedAt()
  1746. case batchmsg.FieldDeletedAt:
  1747. return m.DeletedAt()
  1748. case batchmsg.FieldStatus:
  1749. return m.Status()
  1750. case batchmsg.FieldBatchNo:
  1751. return m.BatchNo()
  1752. case batchmsg.FieldFromwxid:
  1753. return m.Fromwxid()
  1754. case batchmsg.FieldMsg:
  1755. return m.Msg()
  1756. case batchmsg.FieldTag:
  1757. return m.Tag()
  1758. case batchmsg.FieldTotal:
  1759. return m.Total()
  1760. case batchmsg.FieldSuccess:
  1761. return m.Success()
  1762. case batchmsg.FieldFail:
  1763. return m.Fail()
  1764. case batchmsg.FieldStartTime:
  1765. return m.StartTime()
  1766. case batchmsg.FieldStopTime:
  1767. return m.StopTime()
  1768. }
  1769. return nil, false
  1770. }
  1771. // OldField returns the old value of the field from the database. An error is
  1772. // returned if the mutation operation is not UpdateOne, or the query to the
  1773. // database failed.
  1774. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1775. switch name {
  1776. case batchmsg.FieldCreatedAt:
  1777. return m.OldCreatedAt(ctx)
  1778. case batchmsg.FieldUpdatedAt:
  1779. return m.OldUpdatedAt(ctx)
  1780. case batchmsg.FieldDeletedAt:
  1781. return m.OldDeletedAt(ctx)
  1782. case batchmsg.FieldStatus:
  1783. return m.OldStatus(ctx)
  1784. case batchmsg.FieldBatchNo:
  1785. return m.OldBatchNo(ctx)
  1786. case batchmsg.FieldFromwxid:
  1787. return m.OldFromwxid(ctx)
  1788. case batchmsg.FieldMsg:
  1789. return m.OldMsg(ctx)
  1790. case batchmsg.FieldTag:
  1791. return m.OldTag(ctx)
  1792. case batchmsg.FieldTotal:
  1793. return m.OldTotal(ctx)
  1794. case batchmsg.FieldSuccess:
  1795. return m.OldSuccess(ctx)
  1796. case batchmsg.FieldFail:
  1797. return m.OldFail(ctx)
  1798. case batchmsg.FieldStartTime:
  1799. return m.OldStartTime(ctx)
  1800. case batchmsg.FieldStopTime:
  1801. return m.OldStopTime(ctx)
  1802. }
  1803. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  1804. }
  1805. // SetField sets the value of a field with the given name. It returns an error if
  1806. // the field is not defined in the schema, or if the type mismatched the field
  1807. // type.
  1808. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  1809. switch name {
  1810. case batchmsg.FieldCreatedAt:
  1811. v, ok := value.(time.Time)
  1812. if !ok {
  1813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1814. }
  1815. m.SetCreatedAt(v)
  1816. return nil
  1817. case batchmsg.FieldUpdatedAt:
  1818. v, ok := value.(time.Time)
  1819. if !ok {
  1820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1821. }
  1822. m.SetUpdatedAt(v)
  1823. return nil
  1824. case batchmsg.FieldDeletedAt:
  1825. v, ok := value.(time.Time)
  1826. if !ok {
  1827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1828. }
  1829. m.SetDeletedAt(v)
  1830. return nil
  1831. case batchmsg.FieldStatus:
  1832. v, ok := value.(uint8)
  1833. if !ok {
  1834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1835. }
  1836. m.SetStatus(v)
  1837. return nil
  1838. case batchmsg.FieldBatchNo:
  1839. v, ok := value.(string)
  1840. if !ok {
  1841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1842. }
  1843. m.SetBatchNo(v)
  1844. return nil
  1845. case batchmsg.FieldFromwxid:
  1846. v, ok := value.(string)
  1847. if !ok {
  1848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1849. }
  1850. m.SetFromwxid(v)
  1851. return nil
  1852. case batchmsg.FieldMsg:
  1853. v, ok := value.(string)
  1854. if !ok {
  1855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1856. }
  1857. m.SetMsg(v)
  1858. return nil
  1859. case batchmsg.FieldTag:
  1860. v, ok := value.(string)
  1861. if !ok {
  1862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1863. }
  1864. m.SetTag(v)
  1865. return nil
  1866. case batchmsg.FieldTotal:
  1867. v, ok := value.(int32)
  1868. if !ok {
  1869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1870. }
  1871. m.SetTotal(v)
  1872. return nil
  1873. case batchmsg.FieldSuccess:
  1874. v, ok := value.(int32)
  1875. if !ok {
  1876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1877. }
  1878. m.SetSuccess(v)
  1879. return nil
  1880. case batchmsg.FieldFail:
  1881. v, ok := value.(int32)
  1882. if !ok {
  1883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1884. }
  1885. m.SetFail(v)
  1886. return nil
  1887. case batchmsg.FieldStartTime:
  1888. v, ok := value.(time.Time)
  1889. if !ok {
  1890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1891. }
  1892. m.SetStartTime(v)
  1893. return nil
  1894. case batchmsg.FieldStopTime:
  1895. v, ok := value.(time.Time)
  1896. if !ok {
  1897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1898. }
  1899. m.SetStopTime(v)
  1900. return nil
  1901. }
  1902. return fmt.Errorf("unknown BatchMsg field %s", name)
  1903. }
  1904. // AddedFields returns all numeric fields that were incremented/decremented during
  1905. // this mutation.
  1906. func (m *BatchMsgMutation) AddedFields() []string {
  1907. var fields []string
  1908. if m.addstatus != nil {
  1909. fields = append(fields, batchmsg.FieldStatus)
  1910. }
  1911. if m.addtotal != nil {
  1912. fields = append(fields, batchmsg.FieldTotal)
  1913. }
  1914. if m.addsuccess != nil {
  1915. fields = append(fields, batchmsg.FieldSuccess)
  1916. }
  1917. if m.addfail != nil {
  1918. fields = append(fields, batchmsg.FieldFail)
  1919. }
  1920. return fields
  1921. }
  1922. // AddedField returns the numeric value that was incremented/decremented on a field
  1923. // with the given name. The second boolean return value indicates that this field
  1924. // was not set, or was not defined in the schema.
  1925. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  1926. switch name {
  1927. case batchmsg.FieldStatus:
  1928. return m.AddedStatus()
  1929. case batchmsg.FieldTotal:
  1930. return m.AddedTotal()
  1931. case batchmsg.FieldSuccess:
  1932. return m.AddedSuccess()
  1933. case batchmsg.FieldFail:
  1934. return m.AddedFail()
  1935. }
  1936. return nil, false
  1937. }
  1938. // AddField adds the value to the field with the given name. It returns an error if
  1939. // the field is not defined in the schema, or if the type mismatched the field
  1940. // type.
  1941. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  1942. switch name {
  1943. case batchmsg.FieldStatus:
  1944. v, ok := value.(int8)
  1945. if !ok {
  1946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1947. }
  1948. m.AddStatus(v)
  1949. return nil
  1950. case batchmsg.FieldTotal:
  1951. v, ok := value.(int32)
  1952. if !ok {
  1953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1954. }
  1955. m.AddTotal(v)
  1956. return nil
  1957. case batchmsg.FieldSuccess:
  1958. v, ok := value.(int32)
  1959. if !ok {
  1960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1961. }
  1962. m.AddSuccess(v)
  1963. return nil
  1964. case batchmsg.FieldFail:
  1965. v, ok := value.(int32)
  1966. if !ok {
  1967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1968. }
  1969. m.AddFail(v)
  1970. return nil
  1971. }
  1972. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  1973. }
  1974. // ClearedFields returns all nullable fields that were cleared during this
  1975. // mutation.
  1976. func (m *BatchMsgMutation) ClearedFields() []string {
  1977. var fields []string
  1978. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  1979. fields = append(fields, batchmsg.FieldDeletedAt)
  1980. }
  1981. if m.FieldCleared(batchmsg.FieldStatus) {
  1982. fields = append(fields, batchmsg.FieldStatus)
  1983. }
  1984. if m.FieldCleared(batchmsg.FieldBatchNo) {
  1985. fields = append(fields, batchmsg.FieldBatchNo)
  1986. }
  1987. if m.FieldCleared(batchmsg.FieldFromwxid) {
  1988. fields = append(fields, batchmsg.FieldFromwxid)
  1989. }
  1990. if m.FieldCleared(batchmsg.FieldMsg) {
  1991. fields = append(fields, batchmsg.FieldMsg)
  1992. }
  1993. if m.FieldCleared(batchmsg.FieldTag) {
  1994. fields = append(fields, batchmsg.FieldTag)
  1995. }
  1996. if m.FieldCleared(batchmsg.FieldTotal) {
  1997. fields = append(fields, batchmsg.FieldTotal)
  1998. }
  1999. if m.FieldCleared(batchmsg.FieldSuccess) {
  2000. fields = append(fields, batchmsg.FieldSuccess)
  2001. }
  2002. if m.FieldCleared(batchmsg.FieldFail) {
  2003. fields = append(fields, batchmsg.FieldFail)
  2004. }
  2005. if m.FieldCleared(batchmsg.FieldStartTime) {
  2006. fields = append(fields, batchmsg.FieldStartTime)
  2007. }
  2008. if m.FieldCleared(batchmsg.FieldStopTime) {
  2009. fields = append(fields, batchmsg.FieldStopTime)
  2010. }
  2011. return fields
  2012. }
  2013. // FieldCleared returns a boolean indicating if a field with the given name was
  2014. // cleared in this mutation.
  2015. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  2016. _, ok := m.clearedFields[name]
  2017. return ok
  2018. }
  2019. // ClearField clears the value of the field with the given name. It returns an
  2020. // error if the field is not defined in the schema.
  2021. func (m *BatchMsgMutation) ClearField(name string) error {
  2022. switch name {
  2023. case batchmsg.FieldDeletedAt:
  2024. m.ClearDeletedAt()
  2025. return nil
  2026. case batchmsg.FieldStatus:
  2027. m.ClearStatus()
  2028. return nil
  2029. case batchmsg.FieldBatchNo:
  2030. m.ClearBatchNo()
  2031. return nil
  2032. case batchmsg.FieldFromwxid:
  2033. m.ClearFromwxid()
  2034. return nil
  2035. case batchmsg.FieldMsg:
  2036. m.ClearMsg()
  2037. return nil
  2038. case batchmsg.FieldTag:
  2039. m.ClearTag()
  2040. return nil
  2041. case batchmsg.FieldTotal:
  2042. m.ClearTotal()
  2043. return nil
  2044. case batchmsg.FieldSuccess:
  2045. m.ClearSuccess()
  2046. return nil
  2047. case batchmsg.FieldFail:
  2048. m.ClearFail()
  2049. return nil
  2050. case batchmsg.FieldStartTime:
  2051. m.ClearStartTime()
  2052. return nil
  2053. case batchmsg.FieldStopTime:
  2054. m.ClearStopTime()
  2055. return nil
  2056. }
  2057. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  2058. }
  2059. // ResetField resets all changes in the mutation for the field with the given name.
  2060. // It returns an error if the field is not defined in the schema.
  2061. func (m *BatchMsgMutation) ResetField(name string) error {
  2062. switch name {
  2063. case batchmsg.FieldCreatedAt:
  2064. m.ResetCreatedAt()
  2065. return nil
  2066. case batchmsg.FieldUpdatedAt:
  2067. m.ResetUpdatedAt()
  2068. return nil
  2069. case batchmsg.FieldDeletedAt:
  2070. m.ResetDeletedAt()
  2071. return nil
  2072. case batchmsg.FieldStatus:
  2073. m.ResetStatus()
  2074. return nil
  2075. case batchmsg.FieldBatchNo:
  2076. m.ResetBatchNo()
  2077. return nil
  2078. case batchmsg.FieldFromwxid:
  2079. m.ResetFromwxid()
  2080. return nil
  2081. case batchmsg.FieldMsg:
  2082. m.ResetMsg()
  2083. return nil
  2084. case batchmsg.FieldTag:
  2085. m.ResetTag()
  2086. return nil
  2087. case batchmsg.FieldTotal:
  2088. m.ResetTotal()
  2089. return nil
  2090. case batchmsg.FieldSuccess:
  2091. m.ResetSuccess()
  2092. return nil
  2093. case batchmsg.FieldFail:
  2094. m.ResetFail()
  2095. return nil
  2096. case batchmsg.FieldStartTime:
  2097. m.ResetStartTime()
  2098. return nil
  2099. case batchmsg.FieldStopTime:
  2100. m.ResetStopTime()
  2101. return nil
  2102. }
  2103. return fmt.Errorf("unknown BatchMsg field %s", name)
  2104. }
  2105. // AddedEdges returns all edge names that were set/added in this mutation.
  2106. func (m *BatchMsgMutation) AddedEdges() []string {
  2107. edges := make([]string, 0, 0)
  2108. return edges
  2109. }
  2110. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2111. // name in this mutation.
  2112. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  2113. return nil
  2114. }
  2115. // RemovedEdges returns all edge names that were removed in this mutation.
  2116. func (m *BatchMsgMutation) RemovedEdges() []string {
  2117. edges := make([]string, 0, 0)
  2118. return edges
  2119. }
  2120. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2121. // the given name in this mutation.
  2122. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  2123. return nil
  2124. }
  2125. // ClearedEdges returns all edge names that were cleared in this mutation.
  2126. func (m *BatchMsgMutation) ClearedEdges() []string {
  2127. edges := make([]string, 0, 0)
  2128. return edges
  2129. }
  2130. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2131. // was cleared in this mutation.
  2132. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  2133. return false
  2134. }
  2135. // ClearEdge clears the value of the edge with the given name. It returns an error
  2136. // if that edge is not defined in the schema.
  2137. func (m *BatchMsgMutation) ClearEdge(name string) error {
  2138. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  2139. }
  2140. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2141. // It returns an error if the edge is not defined in the schema.
  2142. func (m *BatchMsgMutation) ResetEdge(name string) error {
  2143. return fmt.Errorf("unknown BatchMsg edge %s", name)
  2144. }
  2145. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  2146. type ContactMutation struct {
  2147. config
  2148. op Op
  2149. typ string
  2150. id *uint64
  2151. created_at *time.Time
  2152. updated_at *time.Time
  2153. status *uint8
  2154. addstatus *int8
  2155. deleted_at *time.Time
  2156. wx_wxid *string
  2157. _type *int
  2158. add_type *int
  2159. wxid *string
  2160. account *string
  2161. nickname *string
  2162. markname *string
  2163. headimg *string
  2164. sex *int
  2165. addsex *int
  2166. starrole *string
  2167. dontseeit *int
  2168. adddontseeit *int
  2169. dontseeme *int
  2170. adddontseeme *int
  2171. lag *string
  2172. gid *string
  2173. gname *string
  2174. v3 *string
  2175. organization_id *uint64
  2176. addorganization_id *int64
  2177. clearedFields map[string]struct{}
  2178. contact_relationships map[uint64]struct{}
  2179. removedcontact_relationships map[uint64]struct{}
  2180. clearedcontact_relationships bool
  2181. contact_messages map[uint64]struct{}
  2182. removedcontact_messages map[uint64]struct{}
  2183. clearedcontact_messages bool
  2184. done bool
  2185. oldValue func(context.Context) (*Contact, error)
  2186. predicates []predicate.Contact
  2187. }
  2188. var _ ent.Mutation = (*ContactMutation)(nil)
  2189. // contactOption allows management of the mutation configuration using functional options.
  2190. type contactOption func(*ContactMutation)
  2191. // newContactMutation creates new mutation for the Contact entity.
  2192. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  2193. m := &ContactMutation{
  2194. config: c,
  2195. op: op,
  2196. typ: TypeContact,
  2197. clearedFields: make(map[string]struct{}),
  2198. }
  2199. for _, opt := range opts {
  2200. opt(m)
  2201. }
  2202. return m
  2203. }
  2204. // withContactID sets the ID field of the mutation.
  2205. func withContactID(id uint64) contactOption {
  2206. return func(m *ContactMutation) {
  2207. var (
  2208. err error
  2209. once sync.Once
  2210. value *Contact
  2211. )
  2212. m.oldValue = func(ctx context.Context) (*Contact, error) {
  2213. once.Do(func() {
  2214. if m.done {
  2215. err = errors.New("querying old values post mutation is not allowed")
  2216. } else {
  2217. value, err = m.Client().Contact.Get(ctx, id)
  2218. }
  2219. })
  2220. return value, err
  2221. }
  2222. m.id = &id
  2223. }
  2224. }
  2225. // withContact sets the old Contact of the mutation.
  2226. func withContact(node *Contact) contactOption {
  2227. return func(m *ContactMutation) {
  2228. m.oldValue = func(context.Context) (*Contact, error) {
  2229. return node, nil
  2230. }
  2231. m.id = &node.ID
  2232. }
  2233. }
  2234. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2235. // executed in a transaction (ent.Tx), a transactional client is returned.
  2236. func (m ContactMutation) Client() *Client {
  2237. client := &Client{config: m.config}
  2238. client.init()
  2239. return client
  2240. }
  2241. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2242. // it returns an error otherwise.
  2243. func (m ContactMutation) Tx() (*Tx, error) {
  2244. if _, ok := m.driver.(*txDriver); !ok {
  2245. return nil, errors.New("ent: mutation is not running in a transaction")
  2246. }
  2247. tx := &Tx{config: m.config}
  2248. tx.init()
  2249. return tx, nil
  2250. }
  2251. // SetID sets the value of the id field. Note that this
  2252. // operation is only accepted on creation of Contact entities.
  2253. func (m *ContactMutation) SetID(id uint64) {
  2254. m.id = &id
  2255. }
  2256. // ID returns the ID value in the mutation. Note that the ID is only available
  2257. // if it was provided to the builder or after it was returned from the database.
  2258. func (m *ContactMutation) ID() (id uint64, exists bool) {
  2259. if m.id == nil {
  2260. return
  2261. }
  2262. return *m.id, true
  2263. }
  2264. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2265. // That means, if the mutation is applied within a transaction with an isolation level such
  2266. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2267. // or updated by the mutation.
  2268. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  2269. switch {
  2270. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2271. id, exists := m.ID()
  2272. if exists {
  2273. return []uint64{id}, nil
  2274. }
  2275. fallthrough
  2276. case m.op.Is(OpUpdate | OpDelete):
  2277. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  2278. default:
  2279. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2280. }
  2281. }
  2282. // SetCreatedAt sets the "created_at" field.
  2283. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  2284. m.created_at = &t
  2285. }
  2286. // CreatedAt returns the value of the "created_at" field in the mutation.
  2287. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  2288. v := m.created_at
  2289. if v == nil {
  2290. return
  2291. }
  2292. return *v, true
  2293. }
  2294. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  2295. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2296. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2297. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2298. if !m.op.Is(OpUpdateOne) {
  2299. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2300. }
  2301. if m.id == nil || m.oldValue == nil {
  2302. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2303. }
  2304. oldValue, err := m.oldValue(ctx)
  2305. if err != nil {
  2306. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2307. }
  2308. return oldValue.CreatedAt, nil
  2309. }
  2310. // ResetCreatedAt resets all changes to the "created_at" field.
  2311. func (m *ContactMutation) ResetCreatedAt() {
  2312. m.created_at = nil
  2313. }
  2314. // SetUpdatedAt sets the "updated_at" field.
  2315. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  2316. m.updated_at = &t
  2317. }
  2318. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2319. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  2320. v := m.updated_at
  2321. if v == nil {
  2322. return
  2323. }
  2324. return *v, true
  2325. }
  2326. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  2327. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2329. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2330. if !m.op.Is(OpUpdateOne) {
  2331. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2332. }
  2333. if m.id == nil || m.oldValue == nil {
  2334. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2335. }
  2336. oldValue, err := m.oldValue(ctx)
  2337. if err != nil {
  2338. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2339. }
  2340. return oldValue.UpdatedAt, nil
  2341. }
  2342. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2343. func (m *ContactMutation) ResetUpdatedAt() {
  2344. m.updated_at = nil
  2345. }
  2346. // SetStatus sets the "status" field.
  2347. func (m *ContactMutation) SetStatus(u uint8) {
  2348. m.status = &u
  2349. m.addstatus = nil
  2350. }
  2351. // Status returns the value of the "status" field in the mutation.
  2352. func (m *ContactMutation) Status() (r uint8, exists bool) {
  2353. v := m.status
  2354. if v == nil {
  2355. return
  2356. }
  2357. return *v, true
  2358. }
  2359. // OldStatus returns the old "status" field's value of the Contact entity.
  2360. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2362. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  2363. if !m.op.Is(OpUpdateOne) {
  2364. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  2365. }
  2366. if m.id == nil || m.oldValue == nil {
  2367. return v, errors.New("OldStatus requires an ID field in the mutation")
  2368. }
  2369. oldValue, err := m.oldValue(ctx)
  2370. if err != nil {
  2371. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  2372. }
  2373. return oldValue.Status, nil
  2374. }
  2375. // AddStatus adds u to the "status" field.
  2376. func (m *ContactMutation) AddStatus(u int8) {
  2377. if m.addstatus != nil {
  2378. *m.addstatus += u
  2379. } else {
  2380. m.addstatus = &u
  2381. }
  2382. }
  2383. // AddedStatus returns the value that was added to the "status" field in this mutation.
  2384. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  2385. v := m.addstatus
  2386. if v == nil {
  2387. return
  2388. }
  2389. return *v, true
  2390. }
  2391. // ClearStatus clears the value of the "status" field.
  2392. func (m *ContactMutation) ClearStatus() {
  2393. m.status = nil
  2394. m.addstatus = nil
  2395. m.clearedFields[contact.FieldStatus] = struct{}{}
  2396. }
  2397. // StatusCleared returns if the "status" field was cleared in this mutation.
  2398. func (m *ContactMutation) StatusCleared() bool {
  2399. _, ok := m.clearedFields[contact.FieldStatus]
  2400. return ok
  2401. }
  2402. // ResetStatus resets all changes to the "status" field.
  2403. func (m *ContactMutation) ResetStatus() {
  2404. m.status = nil
  2405. m.addstatus = nil
  2406. delete(m.clearedFields, contact.FieldStatus)
  2407. }
  2408. // SetDeletedAt sets the "deleted_at" field.
  2409. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  2410. m.deleted_at = &t
  2411. }
  2412. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2413. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  2414. v := m.deleted_at
  2415. if v == nil {
  2416. return
  2417. }
  2418. return *v, true
  2419. }
  2420. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  2421. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2423. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2424. if !m.op.Is(OpUpdateOne) {
  2425. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2426. }
  2427. if m.id == nil || m.oldValue == nil {
  2428. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2429. }
  2430. oldValue, err := m.oldValue(ctx)
  2431. if err != nil {
  2432. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2433. }
  2434. return oldValue.DeletedAt, nil
  2435. }
  2436. // ClearDeletedAt clears the value of the "deleted_at" field.
  2437. func (m *ContactMutation) ClearDeletedAt() {
  2438. m.deleted_at = nil
  2439. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  2440. }
  2441. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2442. func (m *ContactMutation) DeletedAtCleared() bool {
  2443. _, ok := m.clearedFields[contact.FieldDeletedAt]
  2444. return ok
  2445. }
  2446. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2447. func (m *ContactMutation) ResetDeletedAt() {
  2448. m.deleted_at = nil
  2449. delete(m.clearedFields, contact.FieldDeletedAt)
  2450. }
  2451. // SetWxWxid sets the "wx_wxid" field.
  2452. func (m *ContactMutation) SetWxWxid(s string) {
  2453. m.wx_wxid = &s
  2454. }
  2455. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  2456. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  2457. v := m.wx_wxid
  2458. if v == nil {
  2459. return
  2460. }
  2461. return *v, true
  2462. }
  2463. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  2464. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2466. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  2467. if !m.op.Is(OpUpdateOne) {
  2468. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  2469. }
  2470. if m.id == nil || m.oldValue == nil {
  2471. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  2472. }
  2473. oldValue, err := m.oldValue(ctx)
  2474. if err != nil {
  2475. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  2476. }
  2477. return oldValue.WxWxid, nil
  2478. }
  2479. // ClearWxWxid clears the value of the "wx_wxid" field.
  2480. func (m *ContactMutation) ClearWxWxid() {
  2481. m.wx_wxid = nil
  2482. m.clearedFields[contact.FieldWxWxid] = struct{}{}
  2483. }
  2484. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  2485. func (m *ContactMutation) WxWxidCleared() bool {
  2486. _, ok := m.clearedFields[contact.FieldWxWxid]
  2487. return ok
  2488. }
  2489. // ResetWxWxid resets all changes to the "wx_wxid" field.
  2490. func (m *ContactMutation) ResetWxWxid() {
  2491. m.wx_wxid = nil
  2492. delete(m.clearedFields, contact.FieldWxWxid)
  2493. }
  2494. // SetType sets the "type" field.
  2495. func (m *ContactMutation) SetType(i int) {
  2496. m._type = &i
  2497. m.add_type = nil
  2498. }
  2499. // GetType returns the value of the "type" field in the mutation.
  2500. func (m *ContactMutation) GetType() (r int, exists bool) {
  2501. v := m._type
  2502. if v == nil {
  2503. return
  2504. }
  2505. return *v, true
  2506. }
  2507. // OldType returns the old "type" field's value of the Contact entity.
  2508. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2510. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  2511. if !m.op.Is(OpUpdateOne) {
  2512. return v, errors.New("OldType is only allowed on UpdateOne operations")
  2513. }
  2514. if m.id == nil || m.oldValue == nil {
  2515. return v, errors.New("OldType requires an ID field in the mutation")
  2516. }
  2517. oldValue, err := m.oldValue(ctx)
  2518. if err != nil {
  2519. return v, fmt.Errorf("querying old value for OldType: %w", err)
  2520. }
  2521. return oldValue.Type, nil
  2522. }
  2523. // AddType adds i to the "type" field.
  2524. func (m *ContactMutation) AddType(i int) {
  2525. if m.add_type != nil {
  2526. *m.add_type += i
  2527. } else {
  2528. m.add_type = &i
  2529. }
  2530. }
  2531. // AddedType returns the value that was added to the "type" field in this mutation.
  2532. func (m *ContactMutation) AddedType() (r int, exists bool) {
  2533. v := m.add_type
  2534. if v == nil {
  2535. return
  2536. }
  2537. return *v, true
  2538. }
  2539. // ClearType clears the value of the "type" field.
  2540. func (m *ContactMutation) ClearType() {
  2541. m._type = nil
  2542. m.add_type = nil
  2543. m.clearedFields[contact.FieldType] = struct{}{}
  2544. }
  2545. // TypeCleared returns if the "type" field was cleared in this mutation.
  2546. func (m *ContactMutation) TypeCleared() bool {
  2547. _, ok := m.clearedFields[contact.FieldType]
  2548. return ok
  2549. }
  2550. // ResetType resets all changes to the "type" field.
  2551. func (m *ContactMutation) ResetType() {
  2552. m._type = nil
  2553. m.add_type = nil
  2554. delete(m.clearedFields, contact.FieldType)
  2555. }
  2556. // SetWxid sets the "wxid" field.
  2557. func (m *ContactMutation) SetWxid(s string) {
  2558. m.wxid = &s
  2559. }
  2560. // Wxid returns the value of the "wxid" field in the mutation.
  2561. func (m *ContactMutation) Wxid() (r string, exists bool) {
  2562. v := m.wxid
  2563. if v == nil {
  2564. return
  2565. }
  2566. return *v, true
  2567. }
  2568. // OldWxid returns the old "wxid" field's value of the Contact entity.
  2569. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2571. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  2572. if !m.op.Is(OpUpdateOne) {
  2573. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  2574. }
  2575. if m.id == nil || m.oldValue == nil {
  2576. return v, errors.New("OldWxid requires an ID field in the mutation")
  2577. }
  2578. oldValue, err := m.oldValue(ctx)
  2579. if err != nil {
  2580. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  2581. }
  2582. return oldValue.Wxid, nil
  2583. }
  2584. // ResetWxid resets all changes to the "wxid" field.
  2585. func (m *ContactMutation) ResetWxid() {
  2586. m.wxid = nil
  2587. }
  2588. // SetAccount sets the "account" field.
  2589. func (m *ContactMutation) SetAccount(s string) {
  2590. m.account = &s
  2591. }
  2592. // Account returns the value of the "account" field in the mutation.
  2593. func (m *ContactMutation) Account() (r string, exists bool) {
  2594. v := m.account
  2595. if v == nil {
  2596. return
  2597. }
  2598. return *v, true
  2599. }
  2600. // OldAccount returns the old "account" field's value of the Contact entity.
  2601. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2603. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  2604. if !m.op.Is(OpUpdateOne) {
  2605. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  2606. }
  2607. if m.id == nil || m.oldValue == nil {
  2608. return v, errors.New("OldAccount requires an ID field in the mutation")
  2609. }
  2610. oldValue, err := m.oldValue(ctx)
  2611. if err != nil {
  2612. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  2613. }
  2614. return oldValue.Account, nil
  2615. }
  2616. // ResetAccount resets all changes to the "account" field.
  2617. func (m *ContactMutation) ResetAccount() {
  2618. m.account = nil
  2619. }
  2620. // SetNickname sets the "nickname" field.
  2621. func (m *ContactMutation) SetNickname(s string) {
  2622. m.nickname = &s
  2623. }
  2624. // Nickname returns the value of the "nickname" field in the mutation.
  2625. func (m *ContactMutation) Nickname() (r string, exists bool) {
  2626. v := m.nickname
  2627. if v == nil {
  2628. return
  2629. }
  2630. return *v, true
  2631. }
  2632. // OldNickname returns the old "nickname" field's value of the Contact entity.
  2633. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2635. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  2636. if !m.op.Is(OpUpdateOne) {
  2637. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  2638. }
  2639. if m.id == nil || m.oldValue == nil {
  2640. return v, errors.New("OldNickname requires an ID field in the mutation")
  2641. }
  2642. oldValue, err := m.oldValue(ctx)
  2643. if err != nil {
  2644. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  2645. }
  2646. return oldValue.Nickname, nil
  2647. }
  2648. // ResetNickname resets all changes to the "nickname" field.
  2649. func (m *ContactMutation) ResetNickname() {
  2650. m.nickname = nil
  2651. }
  2652. // SetMarkname sets the "markname" field.
  2653. func (m *ContactMutation) SetMarkname(s string) {
  2654. m.markname = &s
  2655. }
  2656. // Markname returns the value of the "markname" field in the mutation.
  2657. func (m *ContactMutation) Markname() (r string, exists bool) {
  2658. v := m.markname
  2659. if v == nil {
  2660. return
  2661. }
  2662. return *v, true
  2663. }
  2664. // OldMarkname returns the old "markname" field's value of the Contact entity.
  2665. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2667. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  2668. if !m.op.Is(OpUpdateOne) {
  2669. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  2670. }
  2671. if m.id == nil || m.oldValue == nil {
  2672. return v, errors.New("OldMarkname requires an ID field in the mutation")
  2673. }
  2674. oldValue, err := m.oldValue(ctx)
  2675. if err != nil {
  2676. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  2677. }
  2678. return oldValue.Markname, nil
  2679. }
  2680. // ResetMarkname resets all changes to the "markname" field.
  2681. func (m *ContactMutation) ResetMarkname() {
  2682. m.markname = nil
  2683. }
  2684. // SetHeadimg sets the "headimg" field.
  2685. func (m *ContactMutation) SetHeadimg(s string) {
  2686. m.headimg = &s
  2687. }
  2688. // Headimg returns the value of the "headimg" field in the mutation.
  2689. func (m *ContactMutation) Headimg() (r string, exists bool) {
  2690. v := m.headimg
  2691. if v == nil {
  2692. return
  2693. }
  2694. return *v, true
  2695. }
  2696. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  2697. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2699. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  2700. if !m.op.Is(OpUpdateOne) {
  2701. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  2702. }
  2703. if m.id == nil || m.oldValue == nil {
  2704. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  2705. }
  2706. oldValue, err := m.oldValue(ctx)
  2707. if err != nil {
  2708. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  2709. }
  2710. return oldValue.Headimg, nil
  2711. }
  2712. // ResetHeadimg resets all changes to the "headimg" field.
  2713. func (m *ContactMutation) ResetHeadimg() {
  2714. m.headimg = nil
  2715. }
  2716. // SetSex sets the "sex" field.
  2717. func (m *ContactMutation) SetSex(i int) {
  2718. m.sex = &i
  2719. m.addsex = nil
  2720. }
  2721. // Sex returns the value of the "sex" field in the mutation.
  2722. func (m *ContactMutation) Sex() (r int, exists bool) {
  2723. v := m.sex
  2724. if v == nil {
  2725. return
  2726. }
  2727. return *v, true
  2728. }
  2729. // OldSex returns the old "sex" field's value of the Contact entity.
  2730. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2732. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  2733. if !m.op.Is(OpUpdateOne) {
  2734. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  2735. }
  2736. if m.id == nil || m.oldValue == nil {
  2737. return v, errors.New("OldSex requires an ID field in the mutation")
  2738. }
  2739. oldValue, err := m.oldValue(ctx)
  2740. if err != nil {
  2741. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  2742. }
  2743. return oldValue.Sex, nil
  2744. }
  2745. // AddSex adds i to the "sex" field.
  2746. func (m *ContactMutation) AddSex(i int) {
  2747. if m.addsex != nil {
  2748. *m.addsex += i
  2749. } else {
  2750. m.addsex = &i
  2751. }
  2752. }
  2753. // AddedSex returns the value that was added to the "sex" field in this mutation.
  2754. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  2755. v := m.addsex
  2756. if v == nil {
  2757. return
  2758. }
  2759. return *v, true
  2760. }
  2761. // ResetSex resets all changes to the "sex" field.
  2762. func (m *ContactMutation) ResetSex() {
  2763. m.sex = nil
  2764. m.addsex = nil
  2765. }
  2766. // SetStarrole sets the "starrole" field.
  2767. func (m *ContactMutation) SetStarrole(s string) {
  2768. m.starrole = &s
  2769. }
  2770. // Starrole returns the value of the "starrole" field in the mutation.
  2771. func (m *ContactMutation) Starrole() (r string, exists bool) {
  2772. v := m.starrole
  2773. if v == nil {
  2774. return
  2775. }
  2776. return *v, true
  2777. }
  2778. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  2779. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2781. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  2782. if !m.op.Is(OpUpdateOne) {
  2783. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  2784. }
  2785. if m.id == nil || m.oldValue == nil {
  2786. return v, errors.New("OldStarrole requires an ID field in the mutation")
  2787. }
  2788. oldValue, err := m.oldValue(ctx)
  2789. if err != nil {
  2790. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  2791. }
  2792. return oldValue.Starrole, nil
  2793. }
  2794. // ResetStarrole resets all changes to the "starrole" field.
  2795. func (m *ContactMutation) ResetStarrole() {
  2796. m.starrole = nil
  2797. }
  2798. // SetDontseeit sets the "dontseeit" field.
  2799. func (m *ContactMutation) SetDontseeit(i int) {
  2800. m.dontseeit = &i
  2801. m.adddontseeit = nil
  2802. }
  2803. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  2804. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  2805. v := m.dontseeit
  2806. if v == nil {
  2807. return
  2808. }
  2809. return *v, true
  2810. }
  2811. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  2812. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2814. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  2815. if !m.op.Is(OpUpdateOne) {
  2816. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  2817. }
  2818. if m.id == nil || m.oldValue == nil {
  2819. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  2820. }
  2821. oldValue, err := m.oldValue(ctx)
  2822. if err != nil {
  2823. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  2824. }
  2825. return oldValue.Dontseeit, nil
  2826. }
  2827. // AddDontseeit adds i to the "dontseeit" field.
  2828. func (m *ContactMutation) AddDontseeit(i int) {
  2829. if m.adddontseeit != nil {
  2830. *m.adddontseeit += i
  2831. } else {
  2832. m.adddontseeit = &i
  2833. }
  2834. }
  2835. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  2836. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  2837. v := m.adddontseeit
  2838. if v == nil {
  2839. return
  2840. }
  2841. return *v, true
  2842. }
  2843. // ResetDontseeit resets all changes to the "dontseeit" field.
  2844. func (m *ContactMutation) ResetDontseeit() {
  2845. m.dontseeit = nil
  2846. m.adddontseeit = nil
  2847. }
  2848. // SetDontseeme sets the "dontseeme" field.
  2849. func (m *ContactMutation) SetDontseeme(i int) {
  2850. m.dontseeme = &i
  2851. m.adddontseeme = nil
  2852. }
  2853. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  2854. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  2855. v := m.dontseeme
  2856. if v == nil {
  2857. return
  2858. }
  2859. return *v, true
  2860. }
  2861. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  2862. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2864. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  2865. if !m.op.Is(OpUpdateOne) {
  2866. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  2867. }
  2868. if m.id == nil || m.oldValue == nil {
  2869. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  2870. }
  2871. oldValue, err := m.oldValue(ctx)
  2872. if err != nil {
  2873. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  2874. }
  2875. return oldValue.Dontseeme, nil
  2876. }
  2877. // AddDontseeme adds i to the "dontseeme" field.
  2878. func (m *ContactMutation) AddDontseeme(i int) {
  2879. if m.adddontseeme != nil {
  2880. *m.adddontseeme += i
  2881. } else {
  2882. m.adddontseeme = &i
  2883. }
  2884. }
  2885. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  2886. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  2887. v := m.adddontseeme
  2888. if v == nil {
  2889. return
  2890. }
  2891. return *v, true
  2892. }
  2893. // ResetDontseeme resets all changes to the "dontseeme" field.
  2894. func (m *ContactMutation) ResetDontseeme() {
  2895. m.dontseeme = nil
  2896. m.adddontseeme = nil
  2897. }
  2898. // SetLag sets the "lag" field.
  2899. func (m *ContactMutation) SetLag(s string) {
  2900. m.lag = &s
  2901. }
  2902. // Lag returns the value of the "lag" field in the mutation.
  2903. func (m *ContactMutation) Lag() (r string, exists bool) {
  2904. v := m.lag
  2905. if v == nil {
  2906. return
  2907. }
  2908. return *v, true
  2909. }
  2910. // OldLag returns the old "lag" field's value of the Contact entity.
  2911. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2913. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  2914. if !m.op.Is(OpUpdateOne) {
  2915. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  2916. }
  2917. if m.id == nil || m.oldValue == nil {
  2918. return v, errors.New("OldLag requires an ID field in the mutation")
  2919. }
  2920. oldValue, err := m.oldValue(ctx)
  2921. if err != nil {
  2922. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  2923. }
  2924. return oldValue.Lag, nil
  2925. }
  2926. // ResetLag resets all changes to the "lag" field.
  2927. func (m *ContactMutation) ResetLag() {
  2928. m.lag = nil
  2929. }
  2930. // SetGid sets the "gid" field.
  2931. func (m *ContactMutation) SetGid(s string) {
  2932. m.gid = &s
  2933. }
  2934. // Gid returns the value of the "gid" field in the mutation.
  2935. func (m *ContactMutation) Gid() (r string, exists bool) {
  2936. v := m.gid
  2937. if v == nil {
  2938. return
  2939. }
  2940. return *v, true
  2941. }
  2942. // OldGid returns the old "gid" field's value of the Contact entity.
  2943. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2945. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  2946. if !m.op.Is(OpUpdateOne) {
  2947. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  2948. }
  2949. if m.id == nil || m.oldValue == nil {
  2950. return v, errors.New("OldGid requires an ID field in the mutation")
  2951. }
  2952. oldValue, err := m.oldValue(ctx)
  2953. if err != nil {
  2954. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  2955. }
  2956. return oldValue.Gid, nil
  2957. }
  2958. // ResetGid resets all changes to the "gid" field.
  2959. func (m *ContactMutation) ResetGid() {
  2960. m.gid = nil
  2961. }
  2962. // SetGname sets the "gname" field.
  2963. func (m *ContactMutation) SetGname(s string) {
  2964. m.gname = &s
  2965. }
  2966. // Gname returns the value of the "gname" field in the mutation.
  2967. func (m *ContactMutation) Gname() (r string, exists bool) {
  2968. v := m.gname
  2969. if v == nil {
  2970. return
  2971. }
  2972. return *v, true
  2973. }
  2974. // OldGname returns the old "gname" field's value of the Contact entity.
  2975. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2977. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  2978. if !m.op.Is(OpUpdateOne) {
  2979. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  2980. }
  2981. if m.id == nil || m.oldValue == nil {
  2982. return v, errors.New("OldGname requires an ID field in the mutation")
  2983. }
  2984. oldValue, err := m.oldValue(ctx)
  2985. if err != nil {
  2986. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  2987. }
  2988. return oldValue.Gname, nil
  2989. }
  2990. // ResetGname resets all changes to the "gname" field.
  2991. func (m *ContactMutation) ResetGname() {
  2992. m.gname = nil
  2993. }
  2994. // SetV3 sets the "v3" field.
  2995. func (m *ContactMutation) SetV3(s string) {
  2996. m.v3 = &s
  2997. }
  2998. // V3 returns the value of the "v3" field in the mutation.
  2999. func (m *ContactMutation) V3() (r string, exists bool) {
  3000. v := m.v3
  3001. if v == nil {
  3002. return
  3003. }
  3004. return *v, true
  3005. }
  3006. // OldV3 returns the old "v3" field's value of the Contact entity.
  3007. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3009. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  3010. if !m.op.Is(OpUpdateOne) {
  3011. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  3012. }
  3013. if m.id == nil || m.oldValue == nil {
  3014. return v, errors.New("OldV3 requires an ID field in the mutation")
  3015. }
  3016. oldValue, err := m.oldValue(ctx)
  3017. if err != nil {
  3018. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  3019. }
  3020. return oldValue.V3, nil
  3021. }
  3022. // ResetV3 resets all changes to the "v3" field.
  3023. func (m *ContactMutation) ResetV3() {
  3024. m.v3 = nil
  3025. }
  3026. // SetOrganizationID sets the "organization_id" field.
  3027. func (m *ContactMutation) SetOrganizationID(u uint64) {
  3028. m.organization_id = &u
  3029. m.addorganization_id = nil
  3030. }
  3031. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3032. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  3033. v := m.organization_id
  3034. if v == nil {
  3035. return
  3036. }
  3037. return *v, true
  3038. }
  3039. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  3040. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3042. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3043. if !m.op.Is(OpUpdateOne) {
  3044. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3045. }
  3046. if m.id == nil || m.oldValue == nil {
  3047. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3048. }
  3049. oldValue, err := m.oldValue(ctx)
  3050. if err != nil {
  3051. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3052. }
  3053. return oldValue.OrganizationID, nil
  3054. }
  3055. // AddOrganizationID adds u to the "organization_id" field.
  3056. func (m *ContactMutation) AddOrganizationID(u int64) {
  3057. if m.addorganization_id != nil {
  3058. *m.addorganization_id += u
  3059. } else {
  3060. m.addorganization_id = &u
  3061. }
  3062. }
  3063. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3064. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  3065. v := m.addorganization_id
  3066. if v == nil {
  3067. return
  3068. }
  3069. return *v, true
  3070. }
  3071. // ClearOrganizationID clears the value of the "organization_id" field.
  3072. func (m *ContactMutation) ClearOrganizationID() {
  3073. m.organization_id = nil
  3074. m.addorganization_id = nil
  3075. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  3076. }
  3077. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3078. func (m *ContactMutation) OrganizationIDCleared() bool {
  3079. _, ok := m.clearedFields[contact.FieldOrganizationID]
  3080. return ok
  3081. }
  3082. // ResetOrganizationID resets all changes to the "organization_id" field.
  3083. func (m *ContactMutation) ResetOrganizationID() {
  3084. m.organization_id = nil
  3085. m.addorganization_id = nil
  3086. delete(m.clearedFields, contact.FieldOrganizationID)
  3087. }
  3088. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  3089. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  3090. if m.contact_relationships == nil {
  3091. m.contact_relationships = make(map[uint64]struct{})
  3092. }
  3093. for i := range ids {
  3094. m.contact_relationships[ids[i]] = struct{}{}
  3095. }
  3096. }
  3097. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  3098. func (m *ContactMutation) ClearContactRelationships() {
  3099. m.clearedcontact_relationships = true
  3100. }
  3101. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  3102. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  3103. return m.clearedcontact_relationships
  3104. }
  3105. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  3106. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  3107. if m.removedcontact_relationships == nil {
  3108. m.removedcontact_relationships = make(map[uint64]struct{})
  3109. }
  3110. for i := range ids {
  3111. delete(m.contact_relationships, ids[i])
  3112. m.removedcontact_relationships[ids[i]] = struct{}{}
  3113. }
  3114. }
  3115. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  3116. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  3117. for id := range m.removedcontact_relationships {
  3118. ids = append(ids, id)
  3119. }
  3120. return
  3121. }
  3122. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  3123. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  3124. for id := range m.contact_relationships {
  3125. ids = append(ids, id)
  3126. }
  3127. return
  3128. }
  3129. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  3130. func (m *ContactMutation) ResetContactRelationships() {
  3131. m.contact_relationships = nil
  3132. m.clearedcontact_relationships = false
  3133. m.removedcontact_relationships = nil
  3134. }
  3135. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  3136. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  3137. if m.contact_messages == nil {
  3138. m.contact_messages = make(map[uint64]struct{})
  3139. }
  3140. for i := range ids {
  3141. m.contact_messages[ids[i]] = struct{}{}
  3142. }
  3143. }
  3144. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  3145. func (m *ContactMutation) ClearContactMessages() {
  3146. m.clearedcontact_messages = true
  3147. }
  3148. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  3149. func (m *ContactMutation) ContactMessagesCleared() bool {
  3150. return m.clearedcontact_messages
  3151. }
  3152. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  3153. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  3154. if m.removedcontact_messages == nil {
  3155. m.removedcontact_messages = make(map[uint64]struct{})
  3156. }
  3157. for i := range ids {
  3158. delete(m.contact_messages, ids[i])
  3159. m.removedcontact_messages[ids[i]] = struct{}{}
  3160. }
  3161. }
  3162. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  3163. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  3164. for id := range m.removedcontact_messages {
  3165. ids = append(ids, id)
  3166. }
  3167. return
  3168. }
  3169. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  3170. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  3171. for id := range m.contact_messages {
  3172. ids = append(ids, id)
  3173. }
  3174. return
  3175. }
  3176. // ResetContactMessages resets all changes to the "contact_messages" edge.
  3177. func (m *ContactMutation) ResetContactMessages() {
  3178. m.contact_messages = nil
  3179. m.clearedcontact_messages = false
  3180. m.removedcontact_messages = nil
  3181. }
  3182. // Where appends a list predicates to the ContactMutation builder.
  3183. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  3184. m.predicates = append(m.predicates, ps...)
  3185. }
  3186. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  3187. // users can use type-assertion to append predicates that do not depend on any generated package.
  3188. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  3189. p := make([]predicate.Contact, len(ps))
  3190. for i := range ps {
  3191. p[i] = ps[i]
  3192. }
  3193. m.Where(p...)
  3194. }
  3195. // Op returns the operation name.
  3196. func (m *ContactMutation) Op() Op {
  3197. return m.op
  3198. }
  3199. // SetOp allows setting the mutation operation.
  3200. func (m *ContactMutation) SetOp(op Op) {
  3201. m.op = op
  3202. }
  3203. // Type returns the node type of this mutation (Contact).
  3204. func (m *ContactMutation) Type() string {
  3205. return m.typ
  3206. }
  3207. // Fields returns all fields that were changed during this mutation. Note that in
  3208. // order to get all numeric fields that were incremented/decremented, call
  3209. // AddedFields().
  3210. func (m *ContactMutation) Fields() []string {
  3211. fields := make([]string, 0, 20)
  3212. if m.created_at != nil {
  3213. fields = append(fields, contact.FieldCreatedAt)
  3214. }
  3215. if m.updated_at != nil {
  3216. fields = append(fields, contact.FieldUpdatedAt)
  3217. }
  3218. if m.status != nil {
  3219. fields = append(fields, contact.FieldStatus)
  3220. }
  3221. if m.deleted_at != nil {
  3222. fields = append(fields, contact.FieldDeletedAt)
  3223. }
  3224. if m.wx_wxid != nil {
  3225. fields = append(fields, contact.FieldWxWxid)
  3226. }
  3227. if m._type != nil {
  3228. fields = append(fields, contact.FieldType)
  3229. }
  3230. if m.wxid != nil {
  3231. fields = append(fields, contact.FieldWxid)
  3232. }
  3233. if m.account != nil {
  3234. fields = append(fields, contact.FieldAccount)
  3235. }
  3236. if m.nickname != nil {
  3237. fields = append(fields, contact.FieldNickname)
  3238. }
  3239. if m.markname != nil {
  3240. fields = append(fields, contact.FieldMarkname)
  3241. }
  3242. if m.headimg != nil {
  3243. fields = append(fields, contact.FieldHeadimg)
  3244. }
  3245. if m.sex != nil {
  3246. fields = append(fields, contact.FieldSex)
  3247. }
  3248. if m.starrole != nil {
  3249. fields = append(fields, contact.FieldStarrole)
  3250. }
  3251. if m.dontseeit != nil {
  3252. fields = append(fields, contact.FieldDontseeit)
  3253. }
  3254. if m.dontseeme != nil {
  3255. fields = append(fields, contact.FieldDontseeme)
  3256. }
  3257. if m.lag != nil {
  3258. fields = append(fields, contact.FieldLag)
  3259. }
  3260. if m.gid != nil {
  3261. fields = append(fields, contact.FieldGid)
  3262. }
  3263. if m.gname != nil {
  3264. fields = append(fields, contact.FieldGname)
  3265. }
  3266. if m.v3 != nil {
  3267. fields = append(fields, contact.FieldV3)
  3268. }
  3269. if m.organization_id != nil {
  3270. fields = append(fields, contact.FieldOrganizationID)
  3271. }
  3272. return fields
  3273. }
  3274. // Field returns the value of a field with the given name. The second boolean
  3275. // return value indicates that this field was not set, or was not defined in the
  3276. // schema.
  3277. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  3278. switch name {
  3279. case contact.FieldCreatedAt:
  3280. return m.CreatedAt()
  3281. case contact.FieldUpdatedAt:
  3282. return m.UpdatedAt()
  3283. case contact.FieldStatus:
  3284. return m.Status()
  3285. case contact.FieldDeletedAt:
  3286. return m.DeletedAt()
  3287. case contact.FieldWxWxid:
  3288. return m.WxWxid()
  3289. case contact.FieldType:
  3290. return m.GetType()
  3291. case contact.FieldWxid:
  3292. return m.Wxid()
  3293. case contact.FieldAccount:
  3294. return m.Account()
  3295. case contact.FieldNickname:
  3296. return m.Nickname()
  3297. case contact.FieldMarkname:
  3298. return m.Markname()
  3299. case contact.FieldHeadimg:
  3300. return m.Headimg()
  3301. case contact.FieldSex:
  3302. return m.Sex()
  3303. case contact.FieldStarrole:
  3304. return m.Starrole()
  3305. case contact.FieldDontseeit:
  3306. return m.Dontseeit()
  3307. case contact.FieldDontseeme:
  3308. return m.Dontseeme()
  3309. case contact.FieldLag:
  3310. return m.Lag()
  3311. case contact.FieldGid:
  3312. return m.Gid()
  3313. case contact.FieldGname:
  3314. return m.Gname()
  3315. case contact.FieldV3:
  3316. return m.V3()
  3317. case contact.FieldOrganizationID:
  3318. return m.OrganizationID()
  3319. }
  3320. return nil, false
  3321. }
  3322. // OldField returns the old value of the field from the database. An error is
  3323. // returned if the mutation operation is not UpdateOne, or the query to the
  3324. // database failed.
  3325. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3326. switch name {
  3327. case contact.FieldCreatedAt:
  3328. return m.OldCreatedAt(ctx)
  3329. case contact.FieldUpdatedAt:
  3330. return m.OldUpdatedAt(ctx)
  3331. case contact.FieldStatus:
  3332. return m.OldStatus(ctx)
  3333. case contact.FieldDeletedAt:
  3334. return m.OldDeletedAt(ctx)
  3335. case contact.FieldWxWxid:
  3336. return m.OldWxWxid(ctx)
  3337. case contact.FieldType:
  3338. return m.OldType(ctx)
  3339. case contact.FieldWxid:
  3340. return m.OldWxid(ctx)
  3341. case contact.FieldAccount:
  3342. return m.OldAccount(ctx)
  3343. case contact.FieldNickname:
  3344. return m.OldNickname(ctx)
  3345. case contact.FieldMarkname:
  3346. return m.OldMarkname(ctx)
  3347. case contact.FieldHeadimg:
  3348. return m.OldHeadimg(ctx)
  3349. case contact.FieldSex:
  3350. return m.OldSex(ctx)
  3351. case contact.FieldStarrole:
  3352. return m.OldStarrole(ctx)
  3353. case contact.FieldDontseeit:
  3354. return m.OldDontseeit(ctx)
  3355. case contact.FieldDontseeme:
  3356. return m.OldDontseeme(ctx)
  3357. case contact.FieldLag:
  3358. return m.OldLag(ctx)
  3359. case contact.FieldGid:
  3360. return m.OldGid(ctx)
  3361. case contact.FieldGname:
  3362. return m.OldGname(ctx)
  3363. case contact.FieldV3:
  3364. return m.OldV3(ctx)
  3365. case contact.FieldOrganizationID:
  3366. return m.OldOrganizationID(ctx)
  3367. }
  3368. return nil, fmt.Errorf("unknown Contact field %s", name)
  3369. }
  3370. // SetField sets the value of a field with the given name. It returns an error if
  3371. // the field is not defined in the schema, or if the type mismatched the field
  3372. // type.
  3373. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  3374. switch name {
  3375. case contact.FieldCreatedAt:
  3376. v, ok := value.(time.Time)
  3377. if !ok {
  3378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3379. }
  3380. m.SetCreatedAt(v)
  3381. return nil
  3382. case contact.FieldUpdatedAt:
  3383. v, ok := value.(time.Time)
  3384. if !ok {
  3385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3386. }
  3387. m.SetUpdatedAt(v)
  3388. return nil
  3389. case contact.FieldStatus:
  3390. v, ok := value.(uint8)
  3391. if !ok {
  3392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3393. }
  3394. m.SetStatus(v)
  3395. return nil
  3396. case contact.FieldDeletedAt:
  3397. v, ok := value.(time.Time)
  3398. if !ok {
  3399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3400. }
  3401. m.SetDeletedAt(v)
  3402. return nil
  3403. case contact.FieldWxWxid:
  3404. v, ok := value.(string)
  3405. if !ok {
  3406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3407. }
  3408. m.SetWxWxid(v)
  3409. return nil
  3410. case contact.FieldType:
  3411. v, ok := value.(int)
  3412. if !ok {
  3413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3414. }
  3415. m.SetType(v)
  3416. return nil
  3417. case contact.FieldWxid:
  3418. v, ok := value.(string)
  3419. if !ok {
  3420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3421. }
  3422. m.SetWxid(v)
  3423. return nil
  3424. case contact.FieldAccount:
  3425. v, ok := value.(string)
  3426. if !ok {
  3427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3428. }
  3429. m.SetAccount(v)
  3430. return nil
  3431. case contact.FieldNickname:
  3432. v, ok := value.(string)
  3433. if !ok {
  3434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3435. }
  3436. m.SetNickname(v)
  3437. return nil
  3438. case contact.FieldMarkname:
  3439. v, ok := value.(string)
  3440. if !ok {
  3441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3442. }
  3443. m.SetMarkname(v)
  3444. return nil
  3445. case contact.FieldHeadimg:
  3446. v, ok := value.(string)
  3447. if !ok {
  3448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3449. }
  3450. m.SetHeadimg(v)
  3451. return nil
  3452. case contact.FieldSex:
  3453. v, ok := value.(int)
  3454. if !ok {
  3455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3456. }
  3457. m.SetSex(v)
  3458. return nil
  3459. case contact.FieldStarrole:
  3460. v, ok := value.(string)
  3461. if !ok {
  3462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3463. }
  3464. m.SetStarrole(v)
  3465. return nil
  3466. case contact.FieldDontseeit:
  3467. v, ok := value.(int)
  3468. if !ok {
  3469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3470. }
  3471. m.SetDontseeit(v)
  3472. return nil
  3473. case contact.FieldDontseeme:
  3474. v, ok := value.(int)
  3475. if !ok {
  3476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3477. }
  3478. m.SetDontseeme(v)
  3479. return nil
  3480. case contact.FieldLag:
  3481. v, ok := value.(string)
  3482. if !ok {
  3483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3484. }
  3485. m.SetLag(v)
  3486. return nil
  3487. case contact.FieldGid:
  3488. v, ok := value.(string)
  3489. if !ok {
  3490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3491. }
  3492. m.SetGid(v)
  3493. return nil
  3494. case contact.FieldGname:
  3495. v, ok := value.(string)
  3496. if !ok {
  3497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3498. }
  3499. m.SetGname(v)
  3500. return nil
  3501. case contact.FieldV3:
  3502. v, ok := value.(string)
  3503. if !ok {
  3504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3505. }
  3506. m.SetV3(v)
  3507. return nil
  3508. case contact.FieldOrganizationID:
  3509. v, ok := value.(uint64)
  3510. if !ok {
  3511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3512. }
  3513. m.SetOrganizationID(v)
  3514. return nil
  3515. }
  3516. return fmt.Errorf("unknown Contact field %s", name)
  3517. }
  3518. // AddedFields returns all numeric fields that were incremented/decremented during
  3519. // this mutation.
  3520. func (m *ContactMutation) AddedFields() []string {
  3521. var fields []string
  3522. if m.addstatus != nil {
  3523. fields = append(fields, contact.FieldStatus)
  3524. }
  3525. if m.add_type != nil {
  3526. fields = append(fields, contact.FieldType)
  3527. }
  3528. if m.addsex != nil {
  3529. fields = append(fields, contact.FieldSex)
  3530. }
  3531. if m.adddontseeit != nil {
  3532. fields = append(fields, contact.FieldDontseeit)
  3533. }
  3534. if m.adddontseeme != nil {
  3535. fields = append(fields, contact.FieldDontseeme)
  3536. }
  3537. if m.addorganization_id != nil {
  3538. fields = append(fields, contact.FieldOrganizationID)
  3539. }
  3540. return fields
  3541. }
  3542. // AddedField returns the numeric value that was incremented/decremented on a field
  3543. // with the given name. The second boolean return value indicates that this field
  3544. // was not set, or was not defined in the schema.
  3545. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  3546. switch name {
  3547. case contact.FieldStatus:
  3548. return m.AddedStatus()
  3549. case contact.FieldType:
  3550. return m.AddedType()
  3551. case contact.FieldSex:
  3552. return m.AddedSex()
  3553. case contact.FieldDontseeit:
  3554. return m.AddedDontseeit()
  3555. case contact.FieldDontseeme:
  3556. return m.AddedDontseeme()
  3557. case contact.FieldOrganizationID:
  3558. return m.AddedOrganizationID()
  3559. }
  3560. return nil, false
  3561. }
  3562. // AddField adds the value to the field with the given name. It returns an error if
  3563. // the field is not defined in the schema, or if the type mismatched the field
  3564. // type.
  3565. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  3566. switch name {
  3567. case contact.FieldStatus:
  3568. v, ok := value.(int8)
  3569. if !ok {
  3570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3571. }
  3572. m.AddStatus(v)
  3573. return nil
  3574. case contact.FieldType:
  3575. v, ok := value.(int)
  3576. if !ok {
  3577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3578. }
  3579. m.AddType(v)
  3580. return nil
  3581. case contact.FieldSex:
  3582. v, ok := value.(int)
  3583. if !ok {
  3584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3585. }
  3586. m.AddSex(v)
  3587. return nil
  3588. case contact.FieldDontseeit:
  3589. v, ok := value.(int)
  3590. if !ok {
  3591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3592. }
  3593. m.AddDontseeit(v)
  3594. return nil
  3595. case contact.FieldDontseeme:
  3596. v, ok := value.(int)
  3597. if !ok {
  3598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3599. }
  3600. m.AddDontseeme(v)
  3601. return nil
  3602. case contact.FieldOrganizationID:
  3603. v, ok := value.(int64)
  3604. if !ok {
  3605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3606. }
  3607. m.AddOrganizationID(v)
  3608. return nil
  3609. }
  3610. return fmt.Errorf("unknown Contact numeric field %s", name)
  3611. }
  3612. // ClearedFields returns all nullable fields that were cleared during this
  3613. // mutation.
  3614. func (m *ContactMutation) ClearedFields() []string {
  3615. var fields []string
  3616. if m.FieldCleared(contact.FieldStatus) {
  3617. fields = append(fields, contact.FieldStatus)
  3618. }
  3619. if m.FieldCleared(contact.FieldDeletedAt) {
  3620. fields = append(fields, contact.FieldDeletedAt)
  3621. }
  3622. if m.FieldCleared(contact.FieldWxWxid) {
  3623. fields = append(fields, contact.FieldWxWxid)
  3624. }
  3625. if m.FieldCleared(contact.FieldType) {
  3626. fields = append(fields, contact.FieldType)
  3627. }
  3628. if m.FieldCleared(contact.FieldOrganizationID) {
  3629. fields = append(fields, contact.FieldOrganizationID)
  3630. }
  3631. return fields
  3632. }
  3633. // FieldCleared returns a boolean indicating if a field with the given name was
  3634. // cleared in this mutation.
  3635. func (m *ContactMutation) FieldCleared(name string) bool {
  3636. _, ok := m.clearedFields[name]
  3637. return ok
  3638. }
  3639. // ClearField clears the value of the field with the given name. It returns an
  3640. // error if the field is not defined in the schema.
  3641. func (m *ContactMutation) ClearField(name string) error {
  3642. switch name {
  3643. case contact.FieldStatus:
  3644. m.ClearStatus()
  3645. return nil
  3646. case contact.FieldDeletedAt:
  3647. m.ClearDeletedAt()
  3648. return nil
  3649. case contact.FieldWxWxid:
  3650. m.ClearWxWxid()
  3651. return nil
  3652. case contact.FieldType:
  3653. m.ClearType()
  3654. return nil
  3655. case contact.FieldOrganizationID:
  3656. m.ClearOrganizationID()
  3657. return nil
  3658. }
  3659. return fmt.Errorf("unknown Contact nullable field %s", name)
  3660. }
  3661. // ResetField resets all changes in the mutation for the field with the given name.
  3662. // It returns an error if the field is not defined in the schema.
  3663. func (m *ContactMutation) ResetField(name string) error {
  3664. switch name {
  3665. case contact.FieldCreatedAt:
  3666. m.ResetCreatedAt()
  3667. return nil
  3668. case contact.FieldUpdatedAt:
  3669. m.ResetUpdatedAt()
  3670. return nil
  3671. case contact.FieldStatus:
  3672. m.ResetStatus()
  3673. return nil
  3674. case contact.FieldDeletedAt:
  3675. m.ResetDeletedAt()
  3676. return nil
  3677. case contact.FieldWxWxid:
  3678. m.ResetWxWxid()
  3679. return nil
  3680. case contact.FieldType:
  3681. m.ResetType()
  3682. return nil
  3683. case contact.FieldWxid:
  3684. m.ResetWxid()
  3685. return nil
  3686. case contact.FieldAccount:
  3687. m.ResetAccount()
  3688. return nil
  3689. case contact.FieldNickname:
  3690. m.ResetNickname()
  3691. return nil
  3692. case contact.FieldMarkname:
  3693. m.ResetMarkname()
  3694. return nil
  3695. case contact.FieldHeadimg:
  3696. m.ResetHeadimg()
  3697. return nil
  3698. case contact.FieldSex:
  3699. m.ResetSex()
  3700. return nil
  3701. case contact.FieldStarrole:
  3702. m.ResetStarrole()
  3703. return nil
  3704. case contact.FieldDontseeit:
  3705. m.ResetDontseeit()
  3706. return nil
  3707. case contact.FieldDontseeme:
  3708. m.ResetDontseeme()
  3709. return nil
  3710. case contact.FieldLag:
  3711. m.ResetLag()
  3712. return nil
  3713. case contact.FieldGid:
  3714. m.ResetGid()
  3715. return nil
  3716. case contact.FieldGname:
  3717. m.ResetGname()
  3718. return nil
  3719. case contact.FieldV3:
  3720. m.ResetV3()
  3721. return nil
  3722. case contact.FieldOrganizationID:
  3723. m.ResetOrganizationID()
  3724. return nil
  3725. }
  3726. return fmt.Errorf("unknown Contact field %s", name)
  3727. }
  3728. // AddedEdges returns all edge names that were set/added in this mutation.
  3729. func (m *ContactMutation) AddedEdges() []string {
  3730. edges := make([]string, 0, 2)
  3731. if m.contact_relationships != nil {
  3732. edges = append(edges, contact.EdgeContactRelationships)
  3733. }
  3734. if m.contact_messages != nil {
  3735. edges = append(edges, contact.EdgeContactMessages)
  3736. }
  3737. return edges
  3738. }
  3739. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3740. // name in this mutation.
  3741. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  3742. switch name {
  3743. case contact.EdgeContactRelationships:
  3744. ids := make([]ent.Value, 0, len(m.contact_relationships))
  3745. for id := range m.contact_relationships {
  3746. ids = append(ids, id)
  3747. }
  3748. return ids
  3749. case contact.EdgeContactMessages:
  3750. ids := make([]ent.Value, 0, len(m.contact_messages))
  3751. for id := range m.contact_messages {
  3752. ids = append(ids, id)
  3753. }
  3754. return ids
  3755. }
  3756. return nil
  3757. }
  3758. // RemovedEdges returns all edge names that were removed in this mutation.
  3759. func (m *ContactMutation) RemovedEdges() []string {
  3760. edges := make([]string, 0, 2)
  3761. if m.removedcontact_relationships != nil {
  3762. edges = append(edges, contact.EdgeContactRelationships)
  3763. }
  3764. if m.removedcontact_messages != nil {
  3765. edges = append(edges, contact.EdgeContactMessages)
  3766. }
  3767. return edges
  3768. }
  3769. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3770. // the given name in this mutation.
  3771. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  3772. switch name {
  3773. case contact.EdgeContactRelationships:
  3774. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  3775. for id := range m.removedcontact_relationships {
  3776. ids = append(ids, id)
  3777. }
  3778. return ids
  3779. case contact.EdgeContactMessages:
  3780. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  3781. for id := range m.removedcontact_messages {
  3782. ids = append(ids, id)
  3783. }
  3784. return ids
  3785. }
  3786. return nil
  3787. }
  3788. // ClearedEdges returns all edge names that were cleared in this mutation.
  3789. func (m *ContactMutation) ClearedEdges() []string {
  3790. edges := make([]string, 0, 2)
  3791. if m.clearedcontact_relationships {
  3792. edges = append(edges, contact.EdgeContactRelationships)
  3793. }
  3794. if m.clearedcontact_messages {
  3795. edges = append(edges, contact.EdgeContactMessages)
  3796. }
  3797. return edges
  3798. }
  3799. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3800. // was cleared in this mutation.
  3801. func (m *ContactMutation) EdgeCleared(name string) bool {
  3802. switch name {
  3803. case contact.EdgeContactRelationships:
  3804. return m.clearedcontact_relationships
  3805. case contact.EdgeContactMessages:
  3806. return m.clearedcontact_messages
  3807. }
  3808. return false
  3809. }
  3810. // ClearEdge clears the value of the edge with the given name. It returns an error
  3811. // if that edge is not defined in the schema.
  3812. func (m *ContactMutation) ClearEdge(name string) error {
  3813. switch name {
  3814. }
  3815. return fmt.Errorf("unknown Contact unique edge %s", name)
  3816. }
  3817. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3818. // It returns an error if the edge is not defined in the schema.
  3819. func (m *ContactMutation) ResetEdge(name string) error {
  3820. switch name {
  3821. case contact.EdgeContactRelationships:
  3822. m.ResetContactRelationships()
  3823. return nil
  3824. case contact.EdgeContactMessages:
  3825. m.ResetContactMessages()
  3826. return nil
  3827. }
  3828. return fmt.Errorf("unknown Contact edge %s", name)
  3829. }
  3830. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  3831. type LabelMutation struct {
  3832. config
  3833. op Op
  3834. typ string
  3835. id *uint64
  3836. created_at *time.Time
  3837. updated_at *time.Time
  3838. status *uint8
  3839. addstatus *int8
  3840. _type *int
  3841. add_type *int
  3842. name *string
  3843. from *int
  3844. addfrom *int
  3845. mode *int
  3846. addmode *int
  3847. conditions *string
  3848. organization_id *uint64
  3849. addorganization_id *int64
  3850. clearedFields map[string]struct{}
  3851. label_relationships map[uint64]struct{}
  3852. removedlabel_relationships map[uint64]struct{}
  3853. clearedlabel_relationships bool
  3854. done bool
  3855. oldValue func(context.Context) (*Label, error)
  3856. predicates []predicate.Label
  3857. }
  3858. var _ ent.Mutation = (*LabelMutation)(nil)
  3859. // labelOption allows management of the mutation configuration using functional options.
  3860. type labelOption func(*LabelMutation)
  3861. // newLabelMutation creates new mutation for the Label entity.
  3862. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  3863. m := &LabelMutation{
  3864. config: c,
  3865. op: op,
  3866. typ: TypeLabel,
  3867. clearedFields: make(map[string]struct{}),
  3868. }
  3869. for _, opt := range opts {
  3870. opt(m)
  3871. }
  3872. return m
  3873. }
  3874. // withLabelID sets the ID field of the mutation.
  3875. func withLabelID(id uint64) labelOption {
  3876. return func(m *LabelMutation) {
  3877. var (
  3878. err error
  3879. once sync.Once
  3880. value *Label
  3881. )
  3882. m.oldValue = func(ctx context.Context) (*Label, error) {
  3883. once.Do(func() {
  3884. if m.done {
  3885. err = errors.New("querying old values post mutation is not allowed")
  3886. } else {
  3887. value, err = m.Client().Label.Get(ctx, id)
  3888. }
  3889. })
  3890. return value, err
  3891. }
  3892. m.id = &id
  3893. }
  3894. }
  3895. // withLabel sets the old Label of the mutation.
  3896. func withLabel(node *Label) labelOption {
  3897. return func(m *LabelMutation) {
  3898. m.oldValue = func(context.Context) (*Label, error) {
  3899. return node, nil
  3900. }
  3901. m.id = &node.ID
  3902. }
  3903. }
  3904. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3905. // executed in a transaction (ent.Tx), a transactional client is returned.
  3906. func (m LabelMutation) Client() *Client {
  3907. client := &Client{config: m.config}
  3908. client.init()
  3909. return client
  3910. }
  3911. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3912. // it returns an error otherwise.
  3913. func (m LabelMutation) Tx() (*Tx, error) {
  3914. if _, ok := m.driver.(*txDriver); !ok {
  3915. return nil, errors.New("ent: mutation is not running in a transaction")
  3916. }
  3917. tx := &Tx{config: m.config}
  3918. tx.init()
  3919. return tx, nil
  3920. }
  3921. // SetID sets the value of the id field. Note that this
  3922. // operation is only accepted on creation of Label entities.
  3923. func (m *LabelMutation) SetID(id uint64) {
  3924. m.id = &id
  3925. }
  3926. // ID returns the ID value in the mutation. Note that the ID is only available
  3927. // if it was provided to the builder or after it was returned from the database.
  3928. func (m *LabelMutation) ID() (id uint64, exists bool) {
  3929. if m.id == nil {
  3930. return
  3931. }
  3932. return *m.id, true
  3933. }
  3934. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3935. // That means, if the mutation is applied within a transaction with an isolation level such
  3936. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3937. // or updated by the mutation.
  3938. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  3939. switch {
  3940. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3941. id, exists := m.ID()
  3942. if exists {
  3943. return []uint64{id}, nil
  3944. }
  3945. fallthrough
  3946. case m.op.Is(OpUpdate | OpDelete):
  3947. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  3948. default:
  3949. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3950. }
  3951. }
  3952. // SetCreatedAt sets the "created_at" field.
  3953. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  3954. m.created_at = &t
  3955. }
  3956. // CreatedAt returns the value of the "created_at" field in the mutation.
  3957. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  3958. v := m.created_at
  3959. if v == nil {
  3960. return
  3961. }
  3962. return *v, true
  3963. }
  3964. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  3965. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3967. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3968. if !m.op.Is(OpUpdateOne) {
  3969. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3970. }
  3971. if m.id == nil || m.oldValue == nil {
  3972. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3973. }
  3974. oldValue, err := m.oldValue(ctx)
  3975. if err != nil {
  3976. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3977. }
  3978. return oldValue.CreatedAt, nil
  3979. }
  3980. // ResetCreatedAt resets all changes to the "created_at" field.
  3981. func (m *LabelMutation) ResetCreatedAt() {
  3982. m.created_at = nil
  3983. }
  3984. // SetUpdatedAt sets the "updated_at" field.
  3985. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  3986. m.updated_at = &t
  3987. }
  3988. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3989. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  3990. v := m.updated_at
  3991. if v == nil {
  3992. return
  3993. }
  3994. return *v, true
  3995. }
  3996. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  3997. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3999. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4000. if !m.op.Is(OpUpdateOne) {
  4001. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4002. }
  4003. if m.id == nil || m.oldValue == nil {
  4004. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4005. }
  4006. oldValue, err := m.oldValue(ctx)
  4007. if err != nil {
  4008. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4009. }
  4010. return oldValue.UpdatedAt, nil
  4011. }
  4012. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4013. func (m *LabelMutation) ResetUpdatedAt() {
  4014. m.updated_at = nil
  4015. }
  4016. // SetStatus sets the "status" field.
  4017. func (m *LabelMutation) SetStatus(u uint8) {
  4018. m.status = &u
  4019. m.addstatus = nil
  4020. }
  4021. // Status returns the value of the "status" field in the mutation.
  4022. func (m *LabelMutation) Status() (r uint8, exists bool) {
  4023. v := m.status
  4024. if v == nil {
  4025. return
  4026. }
  4027. return *v, true
  4028. }
  4029. // OldStatus returns the old "status" field's value of the Label entity.
  4030. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4032. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4033. if !m.op.Is(OpUpdateOne) {
  4034. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4035. }
  4036. if m.id == nil || m.oldValue == nil {
  4037. return v, errors.New("OldStatus requires an ID field in the mutation")
  4038. }
  4039. oldValue, err := m.oldValue(ctx)
  4040. if err != nil {
  4041. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4042. }
  4043. return oldValue.Status, nil
  4044. }
  4045. // AddStatus adds u to the "status" field.
  4046. func (m *LabelMutation) AddStatus(u int8) {
  4047. if m.addstatus != nil {
  4048. *m.addstatus += u
  4049. } else {
  4050. m.addstatus = &u
  4051. }
  4052. }
  4053. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4054. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  4055. v := m.addstatus
  4056. if v == nil {
  4057. return
  4058. }
  4059. return *v, true
  4060. }
  4061. // ClearStatus clears the value of the "status" field.
  4062. func (m *LabelMutation) ClearStatus() {
  4063. m.status = nil
  4064. m.addstatus = nil
  4065. m.clearedFields[label.FieldStatus] = struct{}{}
  4066. }
  4067. // StatusCleared returns if the "status" field was cleared in this mutation.
  4068. func (m *LabelMutation) StatusCleared() bool {
  4069. _, ok := m.clearedFields[label.FieldStatus]
  4070. return ok
  4071. }
  4072. // ResetStatus resets all changes to the "status" field.
  4073. func (m *LabelMutation) ResetStatus() {
  4074. m.status = nil
  4075. m.addstatus = nil
  4076. delete(m.clearedFields, label.FieldStatus)
  4077. }
  4078. // SetType sets the "type" field.
  4079. func (m *LabelMutation) SetType(i int) {
  4080. m._type = &i
  4081. m.add_type = nil
  4082. }
  4083. // GetType returns the value of the "type" field in the mutation.
  4084. func (m *LabelMutation) GetType() (r int, exists bool) {
  4085. v := m._type
  4086. if v == nil {
  4087. return
  4088. }
  4089. return *v, true
  4090. }
  4091. // OldType returns the old "type" field's value of the Label entity.
  4092. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4093. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4094. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  4095. if !m.op.Is(OpUpdateOne) {
  4096. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4097. }
  4098. if m.id == nil || m.oldValue == nil {
  4099. return v, errors.New("OldType requires an ID field in the mutation")
  4100. }
  4101. oldValue, err := m.oldValue(ctx)
  4102. if err != nil {
  4103. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4104. }
  4105. return oldValue.Type, nil
  4106. }
  4107. // AddType adds i to the "type" field.
  4108. func (m *LabelMutation) AddType(i int) {
  4109. if m.add_type != nil {
  4110. *m.add_type += i
  4111. } else {
  4112. m.add_type = &i
  4113. }
  4114. }
  4115. // AddedType returns the value that was added to the "type" field in this mutation.
  4116. func (m *LabelMutation) AddedType() (r int, exists bool) {
  4117. v := m.add_type
  4118. if v == nil {
  4119. return
  4120. }
  4121. return *v, true
  4122. }
  4123. // ResetType resets all changes to the "type" field.
  4124. func (m *LabelMutation) ResetType() {
  4125. m._type = nil
  4126. m.add_type = nil
  4127. }
  4128. // SetName sets the "name" field.
  4129. func (m *LabelMutation) SetName(s string) {
  4130. m.name = &s
  4131. }
  4132. // Name returns the value of the "name" field in the mutation.
  4133. func (m *LabelMutation) Name() (r string, exists bool) {
  4134. v := m.name
  4135. if v == nil {
  4136. return
  4137. }
  4138. return *v, true
  4139. }
  4140. // OldName returns the old "name" field's value of the Label entity.
  4141. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4143. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  4144. if !m.op.Is(OpUpdateOne) {
  4145. return v, errors.New("OldName is only allowed on UpdateOne operations")
  4146. }
  4147. if m.id == nil || m.oldValue == nil {
  4148. return v, errors.New("OldName requires an ID field in the mutation")
  4149. }
  4150. oldValue, err := m.oldValue(ctx)
  4151. if err != nil {
  4152. return v, fmt.Errorf("querying old value for OldName: %w", err)
  4153. }
  4154. return oldValue.Name, nil
  4155. }
  4156. // ResetName resets all changes to the "name" field.
  4157. func (m *LabelMutation) ResetName() {
  4158. m.name = nil
  4159. }
  4160. // SetFrom sets the "from" field.
  4161. func (m *LabelMutation) SetFrom(i int) {
  4162. m.from = &i
  4163. m.addfrom = nil
  4164. }
  4165. // From returns the value of the "from" field in the mutation.
  4166. func (m *LabelMutation) From() (r int, exists bool) {
  4167. v := m.from
  4168. if v == nil {
  4169. return
  4170. }
  4171. return *v, true
  4172. }
  4173. // OldFrom returns the old "from" field's value of the Label entity.
  4174. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4176. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  4177. if !m.op.Is(OpUpdateOne) {
  4178. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  4179. }
  4180. if m.id == nil || m.oldValue == nil {
  4181. return v, errors.New("OldFrom requires an ID field in the mutation")
  4182. }
  4183. oldValue, err := m.oldValue(ctx)
  4184. if err != nil {
  4185. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  4186. }
  4187. return oldValue.From, nil
  4188. }
  4189. // AddFrom adds i to the "from" field.
  4190. func (m *LabelMutation) AddFrom(i int) {
  4191. if m.addfrom != nil {
  4192. *m.addfrom += i
  4193. } else {
  4194. m.addfrom = &i
  4195. }
  4196. }
  4197. // AddedFrom returns the value that was added to the "from" field in this mutation.
  4198. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  4199. v := m.addfrom
  4200. if v == nil {
  4201. return
  4202. }
  4203. return *v, true
  4204. }
  4205. // ResetFrom resets all changes to the "from" field.
  4206. func (m *LabelMutation) ResetFrom() {
  4207. m.from = nil
  4208. m.addfrom = nil
  4209. }
  4210. // SetMode sets the "mode" field.
  4211. func (m *LabelMutation) SetMode(i int) {
  4212. m.mode = &i
  4213. m.addmode = nil
  4214. }
  4215. // Mode returns the value of the "mode" field in the mutation.
  4216. func (m *LabelMutation) Mode() (r int, exists bool) {
  4217. v := m.mode
  4218. if v == nil {
  4219. return
  4220. }
  4221. return *v, true
  4222. }
  4223. // OldMode returns the old "mode" field's value of the Label entity.
  4224. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4225. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4226. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  4227. if !m.op.Is(OpUpdateOne) {
  4228. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  4229. }
  4230. if m.id == nil || m.oldValue == nil {
  4231. return v, errors.New("OldMode requires an ID field in the mutation")
  4232. }
  4233. oldValue, err := m.oldValue(ctx)
  4234. if err != nil {
  4235. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  4236. }
  4237. return oldValue.Mode, nil
  4238. }
  4239. // AddMode adds i to the "mode" field.
  4240. func (m *LabelMutation) AddMode(i int) {
  4241. if m.addmode != nil {
  4242. *m.addmode += i
  4243. } else {
  4244. m.addmode = &i
  4245. }
  4246. }
  4247. // AddedMode returns the value that was added to the "mode" field in this mutation.
  4248. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  4249. v := m.addmode
  4250. if v == nil {
  4251. return
  4252. }
  4253. return *v, true
  4254. }
  4255. // ResetMode resets all changes to the "mode" field.
  4256. func (m *LabelMutation) ResetMode() {
  4257. m.mode = nil
  4258. m.addmode = nil
  4259. }
  4260. // SetConditions sets the "conditions" field.
  4261. func (m *LabelMutation) SetConditions(s string) {
  4262. m.conditions = &s
  4263. }
  4264. // Conditions returns the value of the "conditions" field in the mutation.
  4265. func (m *LabelMutation) Conditions() (r string, exists bool) {
  4266. v := m.conditions
  4267. if v == nil {
  4268. return
  4269. }
  4270. return *v, true
  4271. }
  4272. // OldConditions returns the old "conditions" field's value of the Label entity.
  4273. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4275. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  4276. if !m.op.Is(OpUpdateOne) {
  4277. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  4278. }
  4279. if m.id == nil || m.oldValue == nil {
  4280. return v, errors.New("OldConditions requires an ID field in the mutation")
  4281. }
  4282. oldValue, err := m.oldValue(ctx)
  4283. if err != nil {
  4284. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  4285. }
  4286. return oldValue.Conditions, nil
  4287. }
  4288. // ClearConditions clears the value of the "conditions" field.
  4289. func (m *LabelMutation) ClearConditions() {
  4290. m.conditions = nil
  4291. m.clearedFields[label.FieldConditions] = struct{}{}
  4292. }
  4293. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  4294. func (m *LabelMutation) ConditionsCleared() bool {
  4295. _, ok := m.clearedFields[label.FieldConditions]
  4296. return ok
  4297. }
  4298. // ResetConditions resets all changes to the "conditions" field.
  4299. func (m *LabelMutation) ResetConditions() {
  4300. m.conditions = nil
  4301. delete(m.clearedFields, label.FieldConditions)
  4302. }
  4303. // SetOrganizationID sets the "organization_id" field.
  4304. func (m *LabelMutation) SetOrganizationID(u uint64) {
  4305. m.organization_id = &u
  4306. m.addorganization_id = nil
  4307. }
  4308. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4309. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  4310. v := m.organization_id
  4311. if v == nil {
  4312. return
  4313. }
  4314. return *v, true
  4315. }
  4316. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  4317. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4319. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4320. if !m.op.Is(OpUpdateOne) {
  4321. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4322. }
  4323. if m.id == nil || m.oldValue == nil {
  4324. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4325. }
  4326. oldValue, err := m.oldValue(ctx)
  4327. if err != nil {
  4328. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4329. }
  4330. return oldValue.OrganizationID, nil
  4331. }
  4332. // AddOrganizationID adds u to the "organization_id" field.
  4333. func (m *LabelMutation) AddOrganizationID(u int64) {
  4334. if m.addorganization_id != nil {
  4335. *m.addorganization_id += u
  4336. } else {
  4337. m.addorganization_id = &u
  4338. }
  4339. }
  4340. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4341. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  4342. v := m.addorganization_id
  4343. if v == nil {
  4344. return
  4345. }
  4346. return *v, true
  4347. }
  4348. // ClearOrganizationID clears the value of the "organization_id" field.
  4349. func (m *LabelMutation) ClearOrganizationID() {
  4350. m.organization_id = nil
  4351. m.addorganization_id = nil
  4352. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  4353. }
  4354. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  4355. func (m *LabelMutation) OrganizationIDCleared() bool {
  4356. _, ok := m.clearedFields[label.FieldOrganizationID]
  4357. return ok
  4358. }
  4359. // ResetOrganizationID resets all changes to the "organization_id" field.
  4360. func (m *LabelMutation) ResetOrganizationID() {
  4361. m.organization_id = nil
  4362. m.addorganization_id = nil
  4363. delete(m.clearedFields, label.FieldOrganizationID)
  4364. }
  4365. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  4366. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  4367. if m.label_relationships == nil {
  4368. m.label_relationships = make(map[uint64]struct{})
  4369. }
  4370. for i := range ids {
  4371. m.label_relationships[ids[i]] = struct{}{}
  4372. }
  4373. }
  4374. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  4375. func (m *LabelMutation) ClearLabelRelationships() {
  4376. m.clearedlabel_relationships = true
  4377. }
  4378. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  4379. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  4380. return m.clearedlabel_relationships
  4381. }
  4382. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  4383. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  4384. if m.removedlabel_relationships == nil {
  4385. m.removedlabel_relationships = make(map[uint64]struct{})
  4386. }
  4387. for i := range ids {
  4388. delete(m.label_relationships, ids[i])
  4389. m.removedlabel_relationships[ids[i]] = struct{}{}
  4390. }
  4391. }
  4392. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  4393. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  4394. for id := range m.removedlabel_relationships {
  4395. ids = append(ids, id)
  4396. }
  4397. return
  4398. }
  4399. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  4400. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  4401. for id := range m.label_relationships {
  4402. ids = append(ids, id)
  4403. }
  4404. return
  4405. }
  4406. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  4407. func (m *LabelMutation) ResetLabelRelationships() {
  4408. m.label_relationships = nil
  4409. m.clearedlabel_relationships = false
  4410. m.removedlabel_relationships = nil
  4411. }
  4412. // Where appends a list predicates to the LabelMutation builder.
  4413. func (m *LabelMutation) Where(ps ...predicate.Label) {
  4414. m.predicates = append(m.predicates, ps...)
  4415. }
  4416. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  4417. // users can use type-assertion to append predicates that do not depend on any generated package.
  4418. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  4419. p := make([]predicate.Label, len(ps))
  4420. for i := range ps {
  4421. p[i] = ps[i]
  4422. }
  4423. m.Where(p...)
  4424. }
  4425. // Op returns the operation name.
  4426. func (m *LabelMutation) Op() Op {
  4427. return m.op
  4428. }
  4429. // SetOp allows setting the mutation operation.
  4430. func (m *LabelMutation) SetOp(op Op) {
  4431. m.op = op
  4432. }
  4433. // Type returns the node type of this mutation (Label).
  4434. func (m *LabelMutation) Type() string {
  4435. return m.typ
  4436. }
  4437. // Fields returns all fields that were changed during this mutation. Note that in
  4438. // order to get all numeric fields that were incremented/decremented, call
  4439. // AddedFields().
  4440. func (m *LabelMutation) Fields() []string {
  4441. fields := make([]string, 0, 9)
  4442. if m.created_at != nil {
  4443. fields = append(fields, label.FieldCreatedAt)
  4444. }
  4445. if m.updated_at != nil {
  4446. fields = append(fields, label.FieldUpdatedAt)
  4447. }
  4448. if m.status != nil {
  4449. fields = append(fields, label.FieldStatus)
  4450. }
  4451. if m._type != nil {
  4452. fields = append(fields, label.FieldType)
  4453. }
  4454. if m.name != nil {
  4455. fields = append(fields, label.FieldName)
  4456. }
  4457. if m.from != nil {
  4458. fields = append(fields, label.FieldFrom)
  4459. }
  4460. if m.mode != nil {
  4461. fields = append(fields, label.FieldMode)
  4462. }
  4463. if m.conditions != nil {
  4464. fields = append(fields, label.FieldConditions)
  4465. }
  4466. if m.organization_id != nil {
  4467. fields = append(fields, label.FieldOrganizationID)
  4468. }
  4469. return fields
  4470. }
  4471. // Field returns the value of a field with the given name. The second boolean
  4472. // return value indicates that this field was not set, or was not defined in the
  4473. // schema.
  4474. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  4475. switch name {
  4476. case label.FieldCreatedAt:
  4477. return m.CreatedAt()
  4478. case label.FieldUpdatedAt:
  4479. return m.UpdatedAt()
  4480. case label.FieldStatus:
  4481. return m.Status()
  4482. case label.FieldType:
  4483. return m.GetType()
  4484. case label.FieldName:
  4485. return m.Name()
  4486. case label.FieldFrom:
  4487. return m.From()
  4488. case label.FieldMode:
  4489. return m.Mode()
  4490. case label.FieldConditions:
  4491. return m.Conditions()
  4492. case label.FieldOrganizationID:
  4493. return m.OrganizationID()
  4494. }
  4495. return nil, false
  4496. }
  4497. // OldField returns the old value of the field from the database. An error is
  4498. // returned if the mutation operation is not UpdateOne, or the query to the
  4499. // database failed.
  4500. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4501. switch name {
  4502. case label.FieldCreatedAt:
  4503. return m.OldCreatedAt(ctx)
  4504. case label.FieldUpdatedAt:
  4505. return m.OldUpdatedAt(ctx)
  4506. case label.FieldStatus:
  4507. return m.OldStatus(ctx)
  4508. case label.FieldType:
  4509. return m.OldType(ctx)
  4510. case label.FieldName:
  4511. return m.OldName(ctx)
  4512. case label.FieldFrom:
  4513. return m.OldFrom(ctx)
  4514. case label.FieldMode:
  4515. return m.OldMode(ctx)
  4516. case label.FieldConditions:
  4517. return m.OldConditions(ctx)
  4518. case label.FieldOrganizationID:
  4519. return m.OldOrganizationID(ctx)
  4520. }
  4521. return nil, fmt.Errorf("unknown Label field %s", name)
  4522. }
  4523. // SetField sets the value of a field with the given name. It returns an error if
  4524. // the field is not defined in the schema, or if the type mismatched the field
  4525. // type.
  4526. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  4527. switch name {
  4528. case label.FieldCreatedAt:
  4529. v, ok := value.(time.Time)
  4530. if !ok {
  4531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4532. }
  4533. m.SetCreatedAt(v)
  4534. return nil
  4535. case label.FieldUpdatedAt:
  4536. v, ok := value.(time.Time)
  4537. if !ok {
  4538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4539. }
  4540. m.SetUpdatedAt(v)
  4541. return nil
  4542. case label.FieldStatus:
  4543. v, ok := value.(uint8)
  4544. if !ok {
  4545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4546. }
  4547. m.SetStatus(v)
  4548. return nil
  4549. case label.FieldType:
  4550. v, ok := value.(int)
  4551. if !ok {
  4552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4553. }
  4554. m.SetType(v)
  4555. return nil
  4556. case label.FieldName:
  4557. v, ok := value.(string)
  4558. if !ok {
  4559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4560. }
  4561. m.SetName(v)
  4562. return nil
  4563. case label.FieldFrom:
  4564. v, ok := value.(int)
  4565. if !ok {
  4566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4567. }
  4568. m.SetFrom(v)
  4569. return nil
  4570. case label.FieldMode:
  4571. v, ok := value.(int)
  4572. if !ok {
  4573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4574. }
  4575. m.SetMode(v)
  4576. return nil
  4577. case label.FieldConditions:
  4578. v, ok := value.(string)
  4579. if !ok {
  4580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4581. }
  4582. m.SetConditions(v)
  4583. return nil
  4584. case label.FieldOrganizationID:
  4585. v, ok := value.(uint64)
  4586. if !ok {
  4587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4588. }
  4589. m.SetOrganizationID(v)
  4590. return nil
  4591. }
  4592. return fmt.Errorf("unknown Label field %s", name)
  4593. }
  4594. // AddedFields returns all numeric fields that were incremented/decremented during
  4595. // this mutation.
  4596. func (m *LabelMutation) AddedFields() []string {
  4597. var fields []string
  4598. if m.addstatus != nil {
  4599. fields = append(fields, label.FieldStatus)
  4600. }
  4601. if m.add_type != nil {
  4602. fields = append(fields, label.FieldType)
  4603. }
  4604. if m.addfrom != nil {
  4605. fields = append(fields, label.FieldFrom)
  4606. }
  4607. if m.addmode != nil {
  4608. fields = append(fields, label.FieldMode)
  4609. }
  4610. if m.addorganization_id != nil {
  4611. fields = append(fields, label.FieldOrganizationID)
  4612. }
  4613. return fields
  4614. }
  4615. // AddedField returns the numeric value that was incremented/decremented on a field
  4616. // with the given name. The second boolean return value indicates that this field
  4617. // was not set, or was not defined in the schema.
  4618. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  4619. switch name {
  4620. case label.FieldStatus:
  4621. return m.AddedStatus()
  4622. case label.FieldType:
  4623. return m.AddedType()
  4624. case label.FieldFrom:
  4625. return m.AddedFrom()
  4626. case label.FieldMode:
  4627. return m.AddedMode()
  4628. case label.FieldOrganizationID:
  4629. return m.AddedOrganizationID()
  4630. }
  4631. return nil, false
  4632. }
  4633. // AddField adds the value to the field with the given name. It returns an error if
  4634. // the field is not defined in the schema, or if the type mismatched the field
  4635. // type.
  4636. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  4637. switch name {
  4638. case label.FieldStatus:
  4639. v, ok := value.(int8)
  4640. if !ok {
  4641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4642. }
  4643. m.AddStatus(v)
  4644. return nil
  4645. case label.FieldType:
  4646. v, ok := value.(int)
  4647. if !ok {
  4648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4649. }
  4650. m.AddType(v)
  4651. return nil
  4652. case label.FieldFrom:
  4653. v, ok := value.(int)
  4654. if !ok {
  4655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4656. }
  4657. m.AddFrom(v)
  4658. return nil
  4659. case label.FieldMode:
  4660. v, ok := value.(int)
  4661. if !ok {
  4662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4663. }
  4664. m.AddMode(v)
  4665. return nil
  4666. case label.FieldOrganizationID:
  4667. v, ok := value.(int64)
  4668. if !ok {
  4669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4670. }
  4671. m.AddOrganizationID(v)
  4672. return nil
  4673. }
  4674. return fmt.Errorf("unknown Label numeric field %s", name)
  4675. }
  4676. // ClearedFields returns all nullable fields that were cleared during this
  4677. // mutation.
  4678. func (m *LabelMutation) ClearedFields() []string {
  4679. var fields []string
  4680. if m.FieldCleared(label.FieldStatus) {
  4681. fields = append(fields, label.FieldStatus)
  4682. }
  4683. if m.FieldCleared(label.FieldConditions) {
  4684. fields = append(fields, label.FieldConditions)
  4685. }
  4686. if m.FieldCleared(label.FieldOrganizationID) {
  4687. fields = append(fields, label.FieldOrganizationID)
  4688. }
  4689. return fields
  4690. }
  4691. // FieldCleared returns a boolean indicating if a field with the given name was
  4692. // cleared in this mutation.
  4693. func (m *LabelMutation) FieldCleared(name string) bool {
  4694. _, ok := m.clearedFields[name]
  4695. return ok
  4696. }
  4697. // ClearField clears the value of the field with the given name. It returns an
  4698. // error if the field is not defined in the schema.
  4699. func (m *LabelMutation) ClearField(name string) error {
  4700. switch name {
  4701. case label.FieldStatus:
  4702. m.ClearStatus()
  4703. return nil
  4704. case label.FieldConditions:
  4705. m.ClearConditions()
  4706. return nil
  4707. case label.FieldOrganizationID:
  4708. m.ClearOrganizationID()
  4709. return nil
  4710. }
  4711. return fmt.Errorf("unknown Label nullable field %s", name)
  4712. }
  4713. // ResetField resets all changes in the mutation for the field with the given name.
  4714. // It returns an error if the field is not defined in the schema.
  4715. func (m *LabelMutation) ResetField(name string) error {
  4716. switch name {
  4717. case label.FieldCreatedAt:
  4718. m.ResetCreatedAt()
  4719. return nil
  4720. case label.FieldUpdatedAt:
  4721. m.ResetUpdatedAt()
  4722. return nil
  4723. case label.FieldStatus:
  4724. m.ResetStatus()
  4725. return nil
  4726. case label.FieldType:
  4727. m.ResetType()
  4728. return nil
  4729. case label.FieldName:
  4730. m.ResetName()
  4731. return nil
  4732. case label.FieldFrom:
  4733. m.ResetFrom()
  4734. return nil
  4735. case label.FieldMode:
  4736. m.ResetMode()
  4737. return nil
  4738. case label.FieldConditions:
  4739. m.ResetConditions()
  4740. return nil
  4741. case label.FieldOrganizationID:
  4742. m.ResetOrganizationID()
  4743. return nil
  4744. }
  4745. return fmt.Errorf("unknown Label field %s", name)
  4746. }
  4747. // AddedEdges returns all edge names that were set/added in this mutation.
  4748. func (m *LabelMutation) AddedEdges() []string {
  4749. edges := make([]string, 0, 1)
  4750. if m.label_relationships != nil {
  4751. edges = append(edges, label.EdgeLabelRelationships)
  4752. }
  4753. return edges
  4754. }
  4755. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4756. // name in this mutation.
  4757. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  4758. switch name {
  4759. case label.EdgeLabelRelationships:
  4760. ids := make([]ent.Value, 0, len(m.label_relationships))
  4761. for id := range m.label_relationships {
  4762. ids = append(ids, id)
  4763. }
  4764. return ids
  4765. }
  4766. return nil
  4767. }
  4768. // RemovedEdges returns all edge names that were removed in this mutation.
  4769. func (m *LabelMutation) RemovedEdges() []string {
  4770. edges := make([]string, 0, 1)
  4771. if m.removedlabel_relationships != nil {
  4772. edges = append(edges, label.EdgeLabelRelationships)
  4773. }
  4774. return edges
  4775. }
  4776. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4777. // the given name in this mutation.
  4778. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  4779. switch name {
  4780. case label.EdgeLabelRelationships:
  4781. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  4782. for id := range m.removedlabel_relationships {
  4783. ids = append(ids, id)
  4784. }
  4785. return ids
  4786. }
  4787. return nil
  4788. }
  4789. // ClearedEdges returns all edge names that were cleared in this mutation.
  4790. func (m *LabelMutation) ClearedEdges() []string {
  4791. edges := make([]string, 0, 1)
  4792. if m.clearedlabel_relationships {
  4793. edges = append(edges, label.EdgeLabelRelationships)
  4794. }
  4795. return edges
  4796. }
  4797. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4798. // was cleared in this mutation.
  4799. func (m *LabelMutation) EdgeCleared(name string) bool {
  4800. switch name {
  4801. case label.EdgeLabelRelationships:
  4802. return m.clearedlabel_relationships
  4803. }
  4804. return false
  4805. }
  4806. // ClearEdge clears the value of the edge with the given name. It returns an error
  4807. // if that edge is not defined in the schema.
  4808. func (m *LabelMutation) ClearEdge(name string) error {
  4809. switch name {
  4810. }
  4811. return fmt.Errorf("unknown Label unique edge %s", name)
  4812. }
  4813. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4814. // It returns an error if the edge is not defined in the schema.
  4815. func (m *LabelMutation) ResetEdge(name string) error {
  4816. switch name {
  4817. case label.EdgeLabelRelationships:
  4818. m.ResetLabelRelationships()
  4819. return nil
  4820. }
  4821. return fmt.Errorf("unknown Label edge %s", name)
  4822. }
  4823. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  4824. type LabelRelationshipMutation struct {
  4825. config
  4826. op Op
  4827. typ string
  4828. id *uint64
  4829. created_at *time.Time
  4830. updated_at *time.Time
  4831. status *uint8
  4832. addstatus *int8
  4833. deleted_at *time.Time
  4834. organization_id *uint64
  4835. addorganization_id *int64
  4836. clearedFields map[string]struct{}
  4837. contacts *uint64
  4838. clearedcontacts bool
  4839. labels *uint64
  4840. clearedlabels bool
  4841. done bool
  4842. oldValue func(context.Context) (*LabelRelationship, error)
  4843. predicates []predicate.LabelRelationship
  4844. }
  4845. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  4846. // labelrelationshipOption allows management of the mutation configuration using functional options.
  4847. type labelrelationshipOption func(*LabelRelationshipMutation)
  4848. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  4849. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  4850. m := &LabelRelationshipMutation{
  4851. config: c,
  4852. op: op,
  4853. typ: TypeLabelRelationship,
  4854. clearedFields: make(map[string]struct{}),
  4855. }
  4856. for _, opt := range opts {
  4857. opt(m)
  4858. }
  4859. return m
  4860. }
  4861. // withLabelRelationshipID sets the ID field of the mutation.
  4862. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  4863. return func(m *LabelRelationshipMutation) {
  4864. var (
  4865. err error
  4866. once sync.Once
  4867. value *LabelRelationship
  4868. )
  4869. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  4870. once.Do(func() {
  4871. if m.done {
  4872. err = errors.New("querying old values post mutation is not allowed")
  4873. } else {
  4874. value, err = m.Client().LabelRelationship.Get(ctx, id)
  4875. }
  4876. })
  4877. return value, err
  4878. }
  4879. m.id = &id
  4880. }
  4881. }
  4882. // withLabelRelationship sets the old LabelRelationship of the mutation.
  4883. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  4884. return func(m *LabelRelationshipMutation) {
  4885. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  4886. return node, nil
  4887. }
  4888. m.id = &node.ID
  4889. }
  4890. }
  4891. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4892. // executed in a transaction (ent.Tx), a transactional client is returned.
  4893. func (m LabelRelationshipMutation) Client() *Client {
  4894. client := &Client{config: m.config}
  4895. client.init()
  4896. return client
  4897. }
  4898. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4899. // it returns an error otherwise.
  4900. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  4901. if _, ok := m.driver.(*txDriver); !ok {
  4902. return nil, errors.New("ent: mutation is not running in a transaction")
  4903. }
  4904. tx := &Tx{config: m.config}
  4905. tx.init()
  4906. return tx, nil
  4907. }
  4908. // SetID sets the value of the id field. Note that this
  4909. // operation is only accepted on creation of LabelRelationship entities.
  4910. func (m *LabelRelationshipMutation) SetID(id uint64) {
  4911. m.id = &id
  4912. }
  4913. // ID returns the ID value in the mutation. Note that the ID is only available
  4914. // if it was provided to the builder or after it was returned from the database.
  4915. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  4916. if m.id == nil {
  4917. return
  4918. }
  4919. return *m.id, true
  4920. }
  4921. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4922. // That means, if the mutation is applied within a transaction with an isolation level such
  4923. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4924. // or updated by the mutation.
  4925. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  4926. switch {
  4927. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4928. id, exists := m.ID()
  4929. if exists {
  4930. return []uint64{id}, nil
  4931. }
  4932. fallthrough
  4933. case m.op.Is(OpUpdate | OpDelete):
  4934. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  4935. default:
  4936. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4937. }
  4938. }
  4939. // SetCreatedAt sets the "created_at" field.
  4940. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  4941. m.created_at = &t
  4942. }
  4943. // CreatedAt returns the value of the "created_at" field in the mutation.
  4944. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  4945. v := m.created_at
  4946. if v == nil {
  4947. return
  4948. }
  4949. return *v, true
  4950. }
  4951. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  4952. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  4953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4954. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4955. if !m.op.Is(OpUpdateOne) {
  4956. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4957. }
  4958. if m.id == nil || m.oldValue == nil {
  4959. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4960. }
  4961. oldValue, err := m.oldValue(ctx)
  4962. if err != nil {
  4963. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4964. }
  4965. return oldValue.CreatedAt, nil
  4966. }
  4967. // ResetCreatedAt resets all changes to the "created_at" field.
  4968. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  4969. m.created_at = nil
  4970. }
  4971. // SetUpdatedAt sets the "updated_at" field.
  4972. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  4973. m.updated_at = &t
  4974. }
  4975. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4976. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  4977. v := m.updated_at
  4978. if v == nil {
  4979. return
  4980. }
  4981. return *v, true
  4982. }
  4983. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  4984. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  4985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4986. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4987. if !m.op.Is(OpUpdateOne) {
  4988. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4989. }
  4990. if m.id == nil || m.oldValue == nil {
  4991. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4992. }
  4993. oldValue, err := m.oldValue(ctx)
  4994. if err != nil {
  4995. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4996. }
  4997. return oldValue.UpdatedAt, nil
  4998. }
  4999. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5000. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  5001. m.updated_at = nil
  5002. }
  5003. // SetStatus sets the "status" field.
  5004. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  5005. m.status = &u
  5006. m.addstatus = nil
  5007. }
  5008. // Status returns the value of the "status" field in the mutation.
  5009. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  5010. v := m.status
  5011. if v == nil {
  5012. return
  5013. }
  5014. return *v, true
  5015. }
  5016. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  5017. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5019. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5020. if !m.op.Is(OpUpdateOne) {
  5021. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5022. }
  5023. if m.id == nil || m.oldValue == nil {
  5024. return v, errors.New("OldStatus requires an ID field in the mutation")
  5025. }
  5026. oldValue, err := m.oldValue(ctx)
  5027. if err != nil {
  5028. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5029. }
  5030. return oldValue.Status, nil
  5031. }
  5032. // AddStatus adds u to the "status" field.
  5033. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  5034. if m.addstatus != nil {
  5035. *m.addstatus += u
  5036. } else {
  5037. m.addstatus = &u
  5038. }
  5039. }
  5040. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5041. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  5042. v := m.addstatus
  5043. if v == nil {
  5044. return
  5045. }
  5046. return *v, true
  5047. }
  5048. // ClearStatus clears the value of the "status" field.
  5049. func (m *LabelRelationshipMutation) ClearStatus() {
  5050. m.status = nil
  5051. m.addstatus = nil
  5052. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  5053. }
  5054. // StatusCleared returns if the "status" field was cleared in this mutation.
  5055. func (m *LabelRelationshipMutation) StatusCleared() bool {
  5056. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  5057. return ok
  5058. }
  5059. // ResetStatus resets all changes to the "status" field.
  5060. func (m *LabelRelationshipMutation) ResetStatus() {
  5061. m.status = nil
  5062. m.addstatus = nil
  5063. delete(m.clearedFields, labelrelationship.FieldStatus)
  5064. }
  5065. // SetDeletedAt sets the "deleted_at" field.
  5066. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  5067. m.deleted_at = &t
  5068. }
  5069. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5070. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  5071. v := m.deleted_at
  5072. if v == nil {
  5073. return
  5074. }
  5075. return *v, true
  5076. }
  5077. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  5078. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5080. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5081. if !m.op.Is(OpUpdateOne) {
  5082. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5083. }
  5084. if m.id == nil || m.oldValue == nil {
  5085. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5086. }
  5087. oldValue, err := m.oldValue(ctx)
  5088. if err != nil {
  5089. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5090. }
  5091. return oldValue.DeletedAt, nil
  5092. }
  5093. // ClearDeletedAt clears the value of the "deleted_at" field.
  5094. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  5095. m.deleted_at = nil
  5096. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  5097. }
  5098. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5099. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  5100. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  5101. return ok
  5102. }
  5103. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5104. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  5105. m.deleted_at = nil
  5106. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  5107. }
  5108. // SetLabelID sets the "label_id" field.
  5109. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  5110. m.labels = &u
  5111. }
  5112. // LabelID returns the value of the "label_id" field in the mutation.
  5113. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  5114. v := m.labels
  5115. if v == nil {
  5116. return
  5117. }
  5118. return *v, true
  5119. }
  5120. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  5121. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5122. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5123. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  5124. if !m.op.Is(OpUpdateOne) {
  5125. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  5126. }
  5127. if m.id == nil || m.oldValue == nil {
  5128. return v, errors.New("OldLabelID requires an ID field in the mutation")
  5129. }
  5130. oldValue, err := m.oldValue(ctx)
  5131. if err != nil {
  5132. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  5133. }
  5134. return oldValue.LabelID, nil
  5135. }
  5136. // ResetLabelID resets all changes to the "label_id" field.
  5137. func (m *LabelRelationshipMutation) ResetLabelID() {
  5138. m.labels = nil
  5139. }
  5140. // SetContactID sets the "contact_id" field.
  5141. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  5142. m.contacts = &u
  5143. }
  5144. // ContactID returns the value of the "contact_id" field in the mutation.
  5145. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  5146. v := m.contacts
  5147. if v == nil {
  5148. return
  5149. }
  5150. return *v, true
  5151. }
  5152. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  5153. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5155. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  5156. if !m.op.Is(OpUpdateOne) {
  5157. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  5158. }
  5159. if m.id == nil || m.oldValue == nil {
  5160. return v, errors.New("OldContactID requires an ID field in the mutation")
  5161. }
  5162. oldValue, err := m.oldValue(ctx)
  5163. if err != nil {
  5164. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  5165. }
  5166. return oldValue.ContactID, nil
  5167. }
  5168. // ResetContactID resets all changes to the "contact_id" field.
  5169. func (m *LabelRelationshipMutation) ResetContactID() {
  5170. m.contacts = nil
  5171. }
  5172. // SetOrganizationID sets the "organization_id" field.
  5173. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  5174. m.organization_id = &u
  5175. m.addorganization_id = nil
  5176. }
  5177. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5178. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  5179. v := m.organization_id
  5180. if v == nil {
  5181. return
  5182. }
  5183. return *v, true
  5184. }
  5185. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  5186. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5188. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5189. if !m.op.Is(OpUpdateOne) {
  5190. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5191. }
  5192. if m.id == nil || m.oldValue == nil {
  5193. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5194. }
  5195. oldValue, err := m.oldValue(ctx)
  5196. if err != nil {
  5197. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5198. }
  5199. return oldValue.OrganizationID, nil
  5200. }
  5201. // AddOrganizationID adds u to the "organization_id" field.
  5202. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  5203. if m.addorganization_id != nil {
  5204. *m.addorganization_id += u
  5205. } else {
  5206. m.addorganization_id = &u
  5207. }
  5208. }
  5209. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5210. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  5211. v := m.addorganization_id
  5212. if v == nil {
  5213. return
  5214. }
  5215. return *v, true
  5216. }
  5217. // ClearOrganizationID clears the value of the "organization_id" field.
  5218. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  5219. m.organization_id = nil
  5220. m.addorganization_id = nil
  5221. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  5222. }
  5223. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  5224. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  5225. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  5226. return ok
  5227. }
  5228. // ResetOrganizationID resets all changes to the "organization_id" field.
  5229. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  5230. m.organization_id = nil
  5231. m.addorganization_id = nil
  5232. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  5233. }
  5234. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  5235. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  5236. m.contacts = &id
  5237. }
  5238. // ClearContacts clears the "contacts" edge to the Contact entity.
  5239. func (m *LabelRelationshipMutation) ClearContacts() {
  5240. m.clearedcontacts = true
  5241. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  5242. }
  5243. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  5244. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  5245. return m.clearedcontacts
  5246. }
  5247. // ContactsID returns the "contacts" edge ID in the mutation.
  5248. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  5249. if m.contacts != nil {
  5250. return *m.contacts, true
  5251. }
  5252. return
  5253. }
  5254. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  5255. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  5256. // ContactsID instead. It exists only for internal usage by the builders.
  5257. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  5258. if id := m.contacts; id != nil {
  5259. ids = append(ids, *id)
  5260. }
  5261. return
  5262. }
  5263. // ResetContacts resets all changes to the "contacts" edge.
  5264. func (m *LabelRelationshipMutation) ResetContacts() {
  5265. m.contacts = nil
  5266. m.clearedcontacts = false
  5267. }
  5268. // SetLabelsID sets the "labels" edge to the Label entity by id.
  5269. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  5270. m.labels = &id
  5271. }
  5272. // ClearLabels clears the "labels" edge to the Label entity.
  5273. func (m *LabelRelationshipMutation) ClearLabels() {
  5274. m.clearedlabels = true
  5275. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  5276. }
  5277. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  5278. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  5279. return m.clearedlabels
  5280. }
  5281. // LabelsID returns the "labels" edge ID in the mutation.
  5282. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  5283. if m.labels != nil {
  5284. return *m.labels, true
  5285. }
  5286. return
  5287. }
  5288. // LabelsIDs returns the "labels" edge IDs in the mutation.
  5289. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  5290. // LabelsID instead. It exists only for internal usage by the builders.
  5291. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  5292. if id := m.labels; id != nil {
  5293. ids = append(ids, *id)
  5294. }
  5295. return
  5296. }
  5297. // ResetLabels resets all changes to the "labels" edge.
  5298. func (m *LabelRelationshipMutation) ResetLabels() {
  5299. m.labels = nil
  5300. m.clearedlabels = false
  5301. }
  5302. // Where appends a list predicates to the LabelRelationshipMutation builder.
  5303. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  5304. m.predicates = append(m.predicates, ps...)
  5305. }
  5306. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  5307. // users can use type-assertion to append predicates that do not depend on any generated package.
  5308. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  5309. p := make([]predicate.LabelRelationship, len(ps))
  5310. for i := range ps {
  5311. p[i] = ps[i]
  5312. }
  5313. m.Where(p...)
  5314. }
  5315. // Op returns the operation name.
  5316. func (m *LabelRelationshipMutation) Op() Op {
  5317. return m.op
  5318. }
  5319. // SetOp allows setting the mutation operation.
  5320. func (m *LabelRelationshipMutation) SetOp(op Op) {
  5321. m.op = op
  5322. }
  5323. // Type returns the node type of this mutation (LabelRelationship).
  5324. func (m *LabelRelationshipMutation) Type() string {
  5325. return m.typ
  5326. }
  5327. // Fields returns all fields that were changed during this mutation. Note that in
  5328. // order to get all numeric fields that were incremented/decremented, call
  5329. // AddedFields().
  5330. func (m *LabelRelationshipMutation) Fields() []string {
  5331. fields := make([]string, 0, 7)
  5332. if m.created_at != nil {
  5333. fields = append(fields, labelrelationship.FieldCreatedAt)
  5334. }
  5335. if m.updated_at != nil {
  5336. fields = append(fields, labelrelationship.FieldUpdatedAt)
  5337. }
  5338. if m.status != nil {
  5339. fields = append(fields, labelrelationship.FieldStatus)
  5340. }
  5341. if m.deleted_at != nil {
  5342. fields = append(fields, labelrelationship.FieldDeletedAt)
  5343. }
  5344. if m.labels != nil {
  5345. fields = append(fields, labelrelationship.FieldLabelID)
  5346. }
  5347. if m.contacts != nil {
  5348. fields = append(fields, labelrelationship.FieldContactID)
  5349. }
  5350. if m.organization_id != nil {
  5351. fields = append(fields, labelrelationship.FieldOrganizationID)
  5352. }
  5353. return fields
  5354. }
  5355. // Field returns the value of a field with the given name. The second boolean
  5356. // return value indicates that this field was not set, or was not defined in the
  5357. // schema.
  5358. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  5359. switch name {
  5360. case labelrelationship.FieldCreatedAt:
  5361. return m.CreatedAt()
  5362. case labelrelationship.FieldUpdatedAt:
  5363. return m.UpdatedAt()
  5364. case labelrelationship.FieldStatus:
  5365. return m.Status()
  5366. case labelrelationship.FieldDeletedAt:
  5367. return m.DeletedAt()
  5368. case labelrelationship.FieldLabelID:
  5369. return m.LabelID()
  5370. case labelrelationship.FieldContactID:
  5371. return m.ContactID()
  5372. case labelrelationship.FieldOrganizationID:
  5373. return m.OrganizationID()
  5374. }
  5375. return nil, false
  5376. }
  5377. // OldField returns the old value of the field from the database. An error is
  5378. // returned if the mutation operation is not UpdateOne, or the query to the
  5379. // database failed.
  5380. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5381. switch name {
  5382. case labelrelationship.FieldCreatedAt:
  5383. return m.OldCreatedAt(ctx)
  5384. case labelrelationship.FieldUpdatedAt:
  5385. return m.OldUpdatedAt(ctx)
  5386. case labelrelationship.FieldStatus:
  5387. return m.OldStatus(ctx)
  5388. case labelrelationship.FieldDeletedAt:
  5389. return m.OldDeletedAt(ctx)
  5390. case labelrelationship.FieldLabelID:
  5391. return m.OldLabelID(ctx)
  5392. case labelrelationship.FieldContactID:
  5393. return m.OldContactID(ctx)
  5394. case labelrelationship.FieldOrganizationID:
  5395. return m.OldOrganizationID(ctx)
  5396. }
  5397. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  5398. }
  5399. // SetField sets the value of a field with the given name. It returns an error if
  5400. // the field is not defined in the schema, or if the type mismatched the field
  5401. // type.
  5402. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  5403. switch name {
  5404. case labelrelationship.FieldCreatedAt:
  5405. v, ok := value.(time.Time)
  5406. if !ok {
  5407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5408. }
  5409. m.SetCreatedAt(v)
  5410. return nil
  5411. case labelrelationship.FieldUpdatedAt:
  5412. v, ok := value.(time.Time)
  5413. if !ok {
  5414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5415. }
  5416. m.SetUpdatedAt(v)
  5417. return nil
  5418. case labelrelationship.FieldStatus:
  5419. v, ok := value.(uint8)
  5420. if !ok {
  5421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5422. }
  5423. m.SetStatus(v)
  5424. return nil
  5425. case labelrelationship.FieldDeletedAt:
  5426. v, ok := value.(time.Time)
  5427. if !ok {
  5428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5429. }
  5430. m.SetDeletedAt(v)
  5431. return nil
  5432. case labelrelationship.FieldLabelID:
  5433. v, ok := value.(uint64)
  5434. if !ok {
  5435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5436. }
  5437. m.SetLabelID(v)
  5438. return nil
  5439. case labelrelationship.FieldContactID:
  5440. v, ok := value.(uint64)
  5441. if !ok {
  5442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5443. }
  5444. m.SetContactID(v)
  5445. return nil
  5446. case labelrelationship.FieldOrganizationID:
  5447. v, ok := value.(uint64)
  5448. if !ok {
  5449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5450. }
  5451. m.SetOrganizationID(v)
  5452. return nil
  5453. }
  5454. return fmt.Errorf("unknown LabelRelationship field %s", name)
  5455. }
  5456. // AddedFields returns all numeric fields that were incremented/decremented during
  5457. // this mutation.
  5458. func (m *LabelRelationshipMutation) AddedFields() []string {
  5459. var fields []string
  5460. if m.addstatus != nil {
  5461. fields = append(fields, labelrelationship.FieldStatus)
  5462. }
  5463. if m.addorganization_id != nil {
  5464. fields = append(fields, labelrelationship.FieldOrganizationID)
  5465. }
  5466. return fields
  5467. }
  5468. // AddedField returns the numeric value that was incremented/decremented on a field
  5469. // with the given name. The second boolean return value indicates that this field
  5470. // was not set, or was not defined in the schema.
  5471. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  5472. switch name {
  5473. case labelrelationship.FieldStatus:
  5474. return m.AddedStatus()
  5475. case labelrelationship.FieldOrganizationID:
  5476. return m.AddedOrganizationID()
  5477. }
  5478. return nil, false
  5479. }
  5480. // AddField adds the value to the field with the given name. It returns an error if
  5481. // the field is not defined in the schema, or if the type mismatched the field
  5482. // type.
  5483. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  5484. switch name {
  5485. case labelrelationship.FieldStatus:
  5486. v, ok := value.(int8)
  5487. if !ok {
  5488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5489. }
  5490. m.AddStatus(v)
  5491. return nil
  5492. case labelrelationship.FieldOrganizationID:
  5493. v, ok := value.(int64)
  5494. if !ok {
  5495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5496. }
  5497. m.AddOrganizationID(v)
  5498. return nil
  5499. }
  5500. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  5501. }
  5502. // ClearedFields returns all nullable fields that were cleared during this
  5503. // mutation.
  5504. func (m *LabelRelationshipMutation) ClearedFields() []string {
  5505. var fields []string
  5506. if m.FieldCleared(labelrelationship.FieldStatus) {
  5507. fields = append(fields, labelrelationship.FieldStatus)
  5508. }
  5509. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  5510. fields = append(fields, labelrelationship.FieldDeletedAt)
  5511. }
  5512. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  5513. fields = append(fields, labelrelationship.FieldOrganizationID)
  5514. }
  5515. return fields
  5516. }
  5517. // FieldCleared returns a boolean indicating if a field with the given name was
  5518. // cleared in this mutation.
  5519. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  5520. _, ok := m.clearedFields[name]
  5521. return ok
  5522. }
  5523. // ClearField clears the value of the field with the given name. It returns an
  5524. // error if the field is not defined in the schema.
  5525. func (m *LabelRelationshipMutation) ClearField(name string) error {
  5526. switch name {
  5527. case labelrelationship.FieldStatus:
  5528. m.ClearStatus()
  5529. return nil
  5530. case labelrelationship.FieldDeletedAt:
  5531. m.ClearDeletedAt()
  5532. return nil
  5533. case labelrelationship.FieldOrganizationID:
  5534. m.ClearOrganizationID()
  5535. return nil
  5536. }
  5537. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  5538. }
  5539. // ResetField resets all changes in the mutation for the field with the given name.
  5540. // It returns an error if the field is not defined in the schema.
  5541. func (m *LabelRelationshipMutation) ResetField(name string) error {
  5542. switch name {
  5543. case labelrelationship.FieldCreatedAt:
  5544. m.ResetCreatedAt()
  5545. return nil
  5546. case labelrelationship.FieldUpdatedAt:
  5547. m.ResetUpdatedAt()
  5548. return nil
  5549. case labelrelationship.FieldStatus:
  5550. m.ResetStatus()
  5551. return nil
  5552. case labelrelationship.FieldDeletedAt:
  5553. m.ResetDeletedAt()
  5554. return nil
  5555. case labelrelationship.FieldLabelID:
  5556. m.ResetLabelID()
  5557. return nil
  5558. case labelrelationship.FieldContactID:
  5559. m.ResetContactID()
  5560. return nil
  5561. case labelrelationship.FieldOrganizationID:
  5562. m.ResetOrganizationID()
  5563. return nil
  5564. }
  5565. return fmt.Errorf("unknown LabelRelationship field %s", name)
  5566. }
  5567. // AddedEdges returns all edge names that were set/added in this mutation.
  5568. func (m *LabelRelationshipMutation) AddedEdges() []string {
  5569. edges := make([]string, 0, 2)
  5570. if m.contacts != nil {
  5571. edges = append(edges, labelrelationship.EdgeContacts)
  5572. }
  5573. if m.labels != nil {
  5574. edges = append(edges, labelrelationship.EdgeLabels)
  5575. }
  5576. return edges
  5577. }
  5578. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5579. // name in this mutation.
  5580. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  5581. switch name {
  5582. case labelrelationship.EdgeContacts:
  5583. if id := m.contacts; id != nil {
  5584. return []ent.Value{*id}
  5585. }
  5586. case labelrelationship.EdgeLabels:
  5587. if id := m.labels; id != nil {
  5588. return []ent.Value{*id}
  5589. }
  5590. }
  5591. return nil
  5592. }
  5593. // RemovedEdges returns all edge names that were removed in this mutation.
  5594. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  5595. edges := make([]string, 0, 2)
  5596. return edges
  5597. }
  5598. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5599. // the given name in this mutation.
  5600. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  5601. return nil
  5602. }
  5603. // ClearedEdges returns all edge names that were cleared in this mutation.
  5604. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  5605. edges := make([]string, 0, 2)
  5606. if m.clearedcontacts {
  5607. edges = append(edges, labelrelationship.EdgeContacts)
  5608. }
  5609. if m.clearedlabels {
  5610. edges = append(edges, labelrelationship.EdgeLabels)
  5611. }
  5612. return edges
  5613. }
  5614. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5615. // was cleared in this mutation.
  5616. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  5617. switch name {
  5618. case labelrelationship.EdgeContacts:
  5619. return m.clearedcontacts
  5620. case labelrelationship.EdgeLabels:
  5621. return m.clearedlabels
  5622. }
  5623. return false
  5624. }
  5625. // ClearEdge clears the value of the edge with the given name. It returns an error
  5626. // if that edge is not defined in the schema.
  5627. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  5628. switch name {
  5629. case labelrelationship.EdgeContacts:
  5630. m.ClearContacts()
  5631. return nil
  5632. case labelrelationship.EdgeLabels:
  5633. m.ClearLabels()
  5634. return nil
  5635. }
  5636. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  5637. }
  5638. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5639. // It returns an error if the edge is not defined in the schema.
  5640. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  5641. switch name {
  5642. case labelrelationship.EdgeContacts:
  5643. m.ResetContacts()
  5644. return nil
  5645. case labelrelationship.EdgeLabels:
  5646. m.ResetLabels()
  5647. return nil
  5648. }
  5649. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  5650. }
  5651. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  5652. type MessageMutation struct {
  5653. config
  5654. op Op
  5655. typ string
  5656. id *int
  5657. wx_wxid *string
  5658. wxid *string
  5659. content *string
  5660. clearedFields map[string]struct{}
  5661. done bool
  5662. oldValue func(context.Context) (*Message, error)
  5663. predicates []predicate.Message
  5664. }
  5665. var _ ent.Mutation = (*MessageMutation)(nil)
  5666. // messageOption allows management of the mutation configuration using functional options.
  5667. type messageOption func(*MessageMutation)
  5668. // newMessageMutation creates new mutation for the Message entity.
  5669. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  5670. m := &MessageMutation{
  5671. config: c,
  5672. op: op,
  5673. typ: TypeMessage,
  5674. clearedFields: make(map[string]struct{}),
  5675. }
  5676. for _, opt := range opts {
  5677. opt(m)
  5678. }
  5679. return m
  5680. }
  5681. // withMessageID sets the ID field of the mutation.
  5682. func withMessageID(id int) messageOption {
  5683. return func(m *MessageMutation) {
  5684. var (
  5685. err error
  5686. once sync.Once
  5687. value *Message
  5688. )
  5689. m.oldValue = func(ctx context.Context) (*Message, error) {
  5690. once.Do(func() {
  5691. if m.done {
  5692. err = errors.New("querying old values post mutation is not allowed")
  5693. } else {
  5694. value, err = m.Client().Message.Get(ctx, id)
  5695. }
  5696. })
  5697. return value, err
  5698. }
  5699. m.id = &id
  5700. }
  5701. }
  5702. // withMessage sets the old Message of the mutation.
  5703. func withMessage(node *Message) messageOption {
  5704. return func(m *MessageMutation) {
  5705. m.oldValue = func(context.Context) (*Message, error) {
  5706. return node, nil
  5707. }
  5708. m.id = &node.ID
  5709. }
  5710. }
  5711. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5712. // executed in a transaction (ent.Tx), a transactional client is returned.
  5713. func (m MessageMutation) Client() *Client {
  5714. client := &Client{config: m.config}
  5715. client.init()
  5716. return client
  5717. }
  5718. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5719. // it returns an error otherwise.
  5720. func (m MessageMutation) Tx() (*Tx, error) {
  5721. if _, ok := m.driver.(*txDriver); !ok {
  5722. return nil, errors.New("ent: mutation is not running in a transaction")
  5723. }
  5724. tx := &Tx{config: m.config}
  5725. tx.init()
  5726. return tx, nil
  5727. }
  5728. // ID returns the ID value in the mutation. Note that the ID is only available
  5729. // if it was provided to the builder or after it was returned from the database.
  5730. func (m *MessageMutation) ID() (id int, exists bool) {
  5731. if m.id == nil {
  5732. return
  5733. }
  5734. return *m.id, true
  5735. }
  5736. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5737. // That means, if the mutation is applied within a transaction with an isolation level such
  5738. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5739. // or updated by the mutation.
  5740. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  5741. switch {
  5742. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5743. id, exists := m.ID()
  5744. if exists {
  5745. return []int{id}, nil
  5746. }
  5747. fallthrough
  5748. case m.op.Is(OpUpdate | OpDelete):
  5749. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  5750. default:
  5751. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5752. }
  5753. }
  5754. // SetWxWxid sets the "wx_wxid" field.
  5755. func (m *MessageMutation) SetWxWxid(s string) {
  5756. m.wx_wxid = &s
  5757. }
  5758. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  5759. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  5760. v := m.wx_wxid
  5761. if v == nil {
  5762. return
  5763. }
  5764. return *v, true
  5765. }
  5766. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  5767. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  5768. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5769. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  5770. if !m.op.Is(OpUpdateOne) {
  5771. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  5772. }
  5773. if m.id == nil || m.oldValue == nil {
  5774. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  5775. }
  5776. oldValue, err := m.oldValue(ctx)
  5777. if err != nil {
  5778. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  5779. }
  5780. return oldValue.WxWxid, nil
  5781. }
  5782. // ClearWxWxid clears the value of the "wx_wxid" field.
  5783. func (m *MessageMutation) ClearWxWxid() {
  5784. m.wx_wxid = nil
  5785. m.clearedFields[message.FieldWxWxid] = struct{}{}
  5786. }
  5787. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  5788. func (m *MessageMutation) WxWxidCleared() bool {
  5789. _, ok := m.clearedFields[message.FieldWxWxid]
  5790. return ok
  5791. }
  5792. // ResetWxWxid resets all changes to the "wx_wxid" field.
  5793. func (m *MessageMutation) ResetWxWxid() {
  5794. m.wx_wxid = nil
  5795. delete(m.clearedFields, message.FieldWxWxid)
  5796. }
  5797. // SetWxid sets the "wxid" field.
  5798. func (m *MessageMutation) SetWxid(s string) {
  5799. m.wxid = &s
  5800. }
  5801. // Wxid returns the value of the "wxid" field in the mutation.
  5802. func (m *MessageMutation) Wxid() (r string, exists bool) {
  5803. v := m.wxid
  5804. if v == nil {
  5805. return
  5806. }
  5807. return *v, true
  5808. }
  5809. // OldWxid returns the old "wxid" field's value of the Message entity.
  5810. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  5811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5812. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  5813. if !m.op.Is(OpUpdateOne) {
  5814. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  5815. }
  5816. if m.id == nil || m.oldValue == nil {
  5817. return v, errors.New("OldWxid requires an ID field in the mutation")
  5818. }
  5819. oldValue, err := m.oldValue(ctx)
  5820. if err != nil {
  5821. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  5822. }
  5823. return oldValue.Wxid, nil
  5824. }
  5825. // ResetWxid resets all changes to the "wxid" field.
  5826. func (m *MessageMutation) ResetWxid() {
  5827. m.wxid = nil
  5828. }
  5829. // SetContent sets the "content" field.
  5830. func (m *MessageMutation) SetContent(s string) {
  5831. m.content = &s
  5832. }
  5833. // Content returns the value of the "content" field in the mutation.
  5834. func (m *MessageMutation) Content() (r string, exists bool) {
  5835. v := m.content
  5836. if v == nil {
  5837. return
  5838. }
  5839. return *v, true
  5840. }
  5841. // OldContent returns the old "content" field's value of the Message entity.
  5842. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  5843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5844. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  5845. if !m.op.Is(OpUpdateOne) {
  5846. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  5847. }
  5848. if m.id == nil || m.oldValue == nil {
  5849. return v, errors.New("OldContent requires an ID field in the mutation")
  5850. }
  5851. oldValue, err := m.oldValue(ctx)
  5852. if err != nil {
  5853. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  5854. }
  5855. return oldValue.Content, nil
  5856. }
  5857. // ResetContent resets all changes to the "content" field.
  5858. func (m *MessageMutation) ResetContent() {
  5859. m.content = nil
  5860. }
  5861. // Where appends a list predicates to the MessageMutation builder.
  5862. func (m *MessageMutation) Where(ps ...predicate.Message) {
  5863. m.predicates = append(m.predicates, ps...)
  5864. }
  5865. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  5866. // users can use type-assertion to append predicates that do not depend on any generated package.
  5867. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  5868. p := make([]predicate.Message, len(ps))
  5869. for i := range ps {
  5870. p[i] = ps[i]
  5871. }
  5872. m.Where(p...)
  5873. }
  5874. // Op returns the operation name.
  5875. func (m *MessageMutation) Op() Op {
  5876. return m.op
  5877. }
  5878. // SetOp allows setting the mutation operation.
  5879. func (m *MessageMutation) SetOp(op Op) {
  5880. m.op = op
  5881. }
  5882. // Type returns the node type of this mutation (Message).
  5883. func (m *MessageMutation) Type() string {
  5884. return m.typ
  5885. }
  5886. // Fields returns all fields that were changed during this mutation. Note that in
  5887. // order to get all numeric fields that were incremented/decremented, call
  5888. // AddedFields().
  5889. func (m *MessageMutation) Fields() []string {
  5890. fields := make([]string, 0, 3)
  5891. if m.wx_wxid != nil {
  5892. fields = append(fields, message.FieldWxWxid)
  5893. }
  5894. if m.wxid != nil {
  5895. fields = append(fields, message.FieldWxid)
  5896. }
  5897. if m.content != nil {
  5898. fields = append(fields, message.FieldContent)
  5899. }
  5900. return fields
  5901. }
  5902. // Field returns the value of a field with the given name. The second boolean
  5903. // return value indicates that this field was not set, or was not defined in the
  5904. // schema.
  5905. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  5906. switch name {
  5907. case message.FieldWxWxid:
  5908. return m.WxWxid()
  5909. case message.FieldWxid:
  5910. return m.Wxid()
  5911. case message.FieldContent:
  5912. return m.Content()
  5913. }
  5914. return nil, false
  5915. }
  5916. // OldField returns the old value of the field from the database. An error is
  5917. // returned if the mutation operation is not UpdateOne, or the query to the
  5918. // database failed.
  5919. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5920. switch name {
  5921. case message.FieldWxWxid:
  5922. return m.OldWxWxid(ctx)
  5923. case message.FieldWxid:
  5924. return m.OldWxid(ctx)
  5925. case message.FieldContent:
  5926. return m.OldContent(ctx)
  5927. }
  5928. return nil, fmt.Errorf("unknown Message field %s", name)
  5929. }
  5930. // SetField sets the value of a field with the given name. It returns an error if
  5931. // the field is not defined in the schema, or if the type mismatched the field
  5932. // type.
  5933. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  5934. switch name {
  5935. case message.FieldWxWxid:
  5936. v, ok := value.(string)
  5937. if !ok {
  5938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5939. }
  5940. m.SetWxWxid(v)
  5941. return nil
  5942. case message.FieldWxid:
  5943. v, ok := value.(string)
  5944. if !ok {
  5945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5946. }
  5947. m.SetWxid(v)
  5948. return nil
  5949. case message.FieldContent:
  5950. v, ok := value.(string)
  5951. if !ok {
  5952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5953. }
  5954. m.SetContent(v)
  5955. return nil
  5956. }
  5957. return fmt.Errorf("unknown Message field %s", name)
  5958. }
  5959. // AddedFields returns all numeric fields that were incremented/decremented during
  5960. // this mutation.
  5961. func (m *MessageMutation) AddedFields() []string {
  5962. return nil
  5963. }
  5964. // AddedField returns the numeric value that was incremented/decremented on a field
  5965. // with the given name. The second boolean return value indicates that this field
  5966. // was not set, or was not defined in the schema.
  5967. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  5968. return nil, false
  5969. }
  5970. // AddField adds the value to the field with the given name. It returns an error if
  5971. // the field is not defined in the schema, or if the type mismatched the field
  5972. // type.
  5973. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  5974. switch name {
  5975. }
  5976. return fmt.Errorf("unknown Message numeric field %s", name)
  5977. }
  5978. // ClearedFields returns all nullable fields that were cleared during this
  5979. // mutation.
  5980. func (m *MessageMutation) ClearedFields() []string {
  5981. var fields []string
  5982. if m.FieldCleared(message.FieldWxWxid) {
  5983. fields = append(fields, message.FieldWxWxid)
  5984. }
  5985. return fields
  5986. }
  5987. // FieldCleared returns a boolean indicating if a field with the given name was
  5988. // cleared in this mutation.
  5989. func (m *MessageMutation) FieldCleared(name string) bool {
  5990. _, ok := m.clearedFields[name]
  5991. return ok
  5992. }
  5993. // ClearField clears the value of the field with the given name. It returns an
  5994. // error if the field is not defined in the schema.
  5995. func (m *MessageMutation) ClearField(name string) error {
  5996. switch name {
  5997. case message.FieldWxWxid:
  5998. m.ClearWxWxid()
  5999. return nil
  6000. }
  6001. return fmt.Errorf("unknown Message nullable field %s", name)
  6002. }
  6003. // ResetField resets all changes in the mutation for the field with the given name.
  6004. // It returns an error if the field is not defined in the schema.
  6005. func (m *MessageMutation) ResetField(name string) error {
  6006. switch name {
  6007. case message.FieldWxWxid:
  6008. m.ResetWxWxid()
  6009. return nil
  6010. case message.FieldWxid:
  6011. m.ResetWxid()
  6012. return nil
  6013. case message.FieldContent:
  6014. m.ResetContent()
  6015. return nil
  6016. }
  6017. return fmt.Errorf("unknown Message field %s", name)
  6018. }
  6019. // AddedEdges returns all edge names that were set/added in this mutation.
  6020. func (m *MessageMutation) AddedEdges() []string {
  6021. edges := make([]string, 0, 0)
  6022. return edges
  6023. }
  6024. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6025. // name in this mutation.
  6026. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  6027. return nil
  6028. }
  6029. // RemovedEdges returns all edge names that were removed in this mutation.
  6030. func (m *MessageMutation) RemovedEdges() []string {
  6031. edges := make([]string, 0, 0)
  6032. return edges
  6033. }
  6034. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6035. // the given name in this mutation.
  6036. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  6037. return nil
  6038. }
  6039. // ClearedEdges returns all edge names that were cleared in this mutation.
  6040. func (m *MessageMutation) ClearedEdges() []string {
  6041. edges := make([]string, 0, 0)
  6042. return edges
  6043. }
  6044. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6045. // was cleared in this mutation.
  6046. func (m *MessageMutation) EdgeCleared(name string) bool {
  6047. return false
  6048. }
  6049. // ClearEdge clears the value of the edge with the given name. It returns an error
  6050. // if that edge is not defined in the schema.
  6051. func (m *MessageMutation) ClearEdge(name string) error {
  6052. return fmt.Errorf("unknown Message unique edge %s", name)
  6053. }
  6054. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6055. // It returns an error if the edge is not defined in the schema.
  6056. func (m *MessageMutation) ResetEdge(name string) error {
  6057. return fmt.Errorf("unknown Message edge %s", name)
  6058. }
  6059. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  6060. type MessageRecordsMutation struct {
  6061. config
  6062. op Op
  6063. typ string
  6064. id *uint64
  6065. created_at *time.Time
  6066. updated_at *time.Time
  6067. status *uint8
  6068. addstatus *int8
  6069. deleted_at *time.Time
  6070. bot_wxid *string
  6071. contact_type *int
  6072. addcontact_type *int
  6073. contact_wxid *string
  6074. content_type *int
  6075. addcontent_type *int
  6076. content *string
  6077. meta *custom_types.Meta
  6078. error_detail *string
  6079. send_time *time.Time
  6080. source_type *int
  6081. addsource_type *int
  6082. organization_id *uint64
  6083. addorganization_id *int64
  6084. clearedFields map[string]struct{}
  6085. sop_stage *uint64
  6086. clearedsop_stage bool
  6087. sop_node *uint64
  6088. clearedsop_node bool
  6089. message_contact *uint64
  6090. clearedmessage_contact bool
  6091. done bool
  6092. oldValue func(context.Context) (*MessageRecords, error)
  6093. predicates []predicate.MessageRecords
  6094. }
  6095. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  6096. // messagerecordsOption allows management of the mutation configuration using functional options.
  6097. type messagerecordsOption func(*MessageRecordsMutation)
  6098. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  6099. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  6100. m := &MessageRecordsMutation{
  6101. config: c,
  6102. op: op,
  6103. typ: TypeMessageRecords,
  6104. clearedFields: make(map[string]struct{}),
  6105. }
  6106. for _, opt := range opts {
  6107. opt(m)
  6108. }
  6109. return m
  6110. }
  6111. // withMessageRecordsID sets the ID field of the mutation.
  6112. func withMessageRecordsID(id uint64) messagerecordsOption {
  6113. return func(m *MessageRecordsMutation) {
  6114. var (
  6115. err error
  6116. once sync.Once
  6117. value *MessageRecords
  6118. )
  6119. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  6120. once.Do(func() {
  6121. if m.done {
  6122. err = errors.New("querying old values post mutation is not allowed")
  6123. } else {
  6124. value, err = m.Client().MessageRecords.Get(ctx, id)
  6125. }
  6126. })
  6127. return value, err
  6128. }
  6129. m.id = &id
  6130. }
  6131. }
  6132. // withMessageRecords sets the old MessageRecords of the mutation.
  6133. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  6134. return func(m *MessageRecordsMutation) {
  6135. m.oldValue = func(context.Context) (*MessageRecords, error) {
  6136. return node, nil
  6137. }
  6138. m.id = &node.ID
  6139. }
  6140. }
  6141. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6142. // executed in a transaction (ent.Tx), a transactional client is returned.
  6143. func (m MessageRecordsMutation) Client() *Client {
  6144. client := &Client{config: m.config}
  6145. client.init()
  6146. return client
  6147. }
  6148. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6149. // it returns an error otherwise.
  6150. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  6151. if _, ok := m.driver.(*txDriver); !ok {
  6152. return nil, errors.New("ent: mutation is not running in a transaction")
  6153. }
  6154. tx := &Tx{config: m.config}
  6155. tx.init()
  6156. return tx, nil
  6157. }
  6158. // SetID sets the value of the id field. Note that this
  6159. // operation is only accepted on creation of MessageRecords entities.
  6160. func (m *MessageRecordsMutation) SetID(id uint64) {
  6161. m.id = &id
  6162. }
  6163. // ID returns the ID value in the mutation. Note that the ID is only available
  6164. // if it was provided to the builder or after it was returned from the database.
  6165. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  6166. if m.id == nil {
  6167. return
  6168. }
  6169. return *m.id, true
  6170. }
  6171. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6172. // That means, if the mutation is applied within a transaction with an isolation level such
  6173. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6174. // or updated by the mutation.
  6175. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  6176. switch {
  6177. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6178. id, exists := m.ID()
  6179. if exists {
  6180. return []uint64{id}, nil
  6181. }
  6182. fallthrough
  6183. case m.op.Is(OpUpdate | OpDelete):
  6184. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  6185. default:
  6186. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6187. }
  6188. }
  6189. // SetCreatedAt sets the "created_at" field.
  6190. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  6191. m.created_at = &t
  6192. }
  6193. // CreatedAt returns the value of the "created_at" field in the mutation.
  6194. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  6195. v := m.created_at
  6196. if v == nil {
  6197. return
  6198. }
  6199. return *v, true
  6200. }
  6201. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  6202. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6204. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6205. if !m.op.Is(OpUpdateOne) {
  6206. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6207. }
  6208. if m.id == nil || m.oldValue == nil {
  6209. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6210. }
  6211. oldValue, err := m.oldValue(ctx)
  6212. if err != nil {
  6213. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6214. }
  6215. return oldValue.CreatedAt, nil
  6216. }
  6217. // ResetCreatedAt resets all changes to the "created_at" field.
  6218. func (m *MessageRecordsMutation) ResetCreatedAt() {
  6219. m.created_at = nil
  6220. }
  6221. // SetUpdatedAt sets the "updated_at" field.
  6222. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  6223. m.updated_at = &t
  6224. }
  6225. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6226. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  6227. v := m.updated_at
  6228. if v == nil {
  6229. return
  6230. }
  6231. return *v, true
  6232. }
  6233. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  6234. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6236. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6237. if !m.op.Is(OpUpdateOne) {
  6238. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6239. }
  6240. if m.id == nil || m.oldValue == nil {
  6241. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6242. }
  6243. oldValue, err := m.oldValue(ctx)
  6244. if err != nil {
  6245. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6246. }
  6247. return oldValue.UpdatedAt, nil
  6248. }
  6249. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6250. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  6251. m.updated_at = nil
  6252. }
  6253. // SetStatus sets the "status" field.
  6254. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  6255. m.status = &u
  6256. m.addstatus = nil
  6257. }
  6258. // Status returns the value of the "status" field in the mutation.
  6259. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  6260. v := m.status
  6261. if v == nil {
  6262. return
  6263. }
  6264. return *v, true
  6265. }
  6266. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  6267. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6269. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  6270. if !m.op.Is(OpUpdateOne) {
  6271. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  6272. }
  6273. if m.id == nil || m.oldValue == nil {
  6274. return v, errors.New("OldStatus requires an ID field in the mutation")
  6275. }
  6276. oldValue, err := m.oldValue(ctx)
  6277. if err != nil {
  6278. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  6279. }
  6280. return oldValue.Status, nil
  6281. }
  6282. // AddStatus adds u to the "status" field.
  6283. func (m *MessageRecordsMutation) AddStatus(u int8) {
  6284. if m.addstatus != nil {
  6285. *m.addstatus += u
  6286. } else {
  6287. m.addstatus = &u
  6288. }
  6289. }
  6290. // AddedStatus returns the value that was added to the "status" field in this mutation.
  6291. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  6292. v := m.addstatus
  6293. if v == nil {
  6294. return
  6295. }
  6296. return *v, true
  6297. }
  6298. // ClearStatus clears the value of the "status" field.
  6299. func (m *MessageRecordsMutation) ClearStatus() {
  6300. m.status = nil
  6301. m.addstatus = nil
  6302. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  6303. }
  6304. // StatusCleared returns if the "status" field was cleared in this mutation.
  6305. func (m *MessageRecordsMutation) StatusCleared() bool {
  6306. _, ok := m.clearedFields[messagerecords.FieldStatus]
  6307. return ok
  6308. }
  6309. // ResetStatus resets all changes to the "status" field.
  6310. func (m *MessageRecordsMutation) ResetStatus() {
  6311. m.status = nil
  6312. m.addstatus = nil
  6313. delete(m.clearedFields, messagerecords.FieldStatus)
  6314. }
  6315. // SetDeletedAt sets the "deleted_at" field.
  6316. func (m *MessageRecordsMutation) SetDeletedAt(t time.Time) {
  6317. m.deleted_at = &t
  6318. }
  6319. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6320. func (m *MessageRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  6321. v := m.deleted_at
  6322. if v == nil {
  6323. return
  6324. }
  6325. return *v, true
  6326. }
  6327. // OldDeletedAt returns the old "deleted_at" field's value of the MessageRecords entity.
  6328. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6330. func (m *MessageRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6331. if !m.op.Is(OpUpdateOne) {
  6332. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6333. }
  6334. if m.id == nil || m.oldValue == nil {
  6335. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6336. }
  6337. oldValue, err := m.oldValue(ctx)
  6338. if err != nil {
  6339. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6340. }
  6341. return oldValue.DeletedAt, nil
  6342. }
  6343. // ClearDeletedAt clears the value of the "deleted_at" field.
  6344. func (m *MessageRecordsMutation) ClearDeletedAt() {
  6345. m.deleted_at = nil
  6346. m.clearedFields[messagerecords.FieldDeletedAt] = struct{}{}
  6347. }
  6348. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6349. func (m *MessageRecordsMutation) DeletedAtCleared() bool {
  6350. _, ok := m.clearedFields[messagerecords.FieldDeletedAt]
  6351. return ok
  6352. }
  6353. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6354. func (m *MessageRecordsMutation) ResetDeletedAt() {
  6355. m.deleted_at = nil
  6356. delete(m.clearedFields, messagerecords.FieldDeletedAt)
  6357. }
  6358. // SetBotWxid sets the "bot_wxid" field.
  6359. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  6360. m.bot_wxid = &s
  6361. }
  6362. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  6363. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  6364. v := m.bot_wxid
  6365. if v == nil {
  6366. return
  6367. }
  6368. return *v, true
  6369. }
  6370. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  6371. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6372. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6373. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  6374. if !m.op.Is(OpUpdateOne) {
  6375. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  6376. }
  6377. if m.id == nil || m.oldValue == nil {
  6378. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  6379. }
  6380. oldValue, err := m.oldValue(ctx)
  6381. if err != nil {
  6382. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  6383. }
  6384. return oldValue.BotWxid, nil
  6385. }
  6386. // ResetBotWxid resets all changes to the "bot_wxid" field.
  6387. func (m *MessageRecordsMutation) ResetBotWxid() {
  6388. m.bot_wxid = nil
  6389. }
  6390. // SetContactID sets the "contact_id" field.
  6391. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  6392. m.message_contact = &u
  6393. }
  6394. // ContactID returns the value of the "contact_id" field in the mutation.
  6395. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  6396. v := m.message_contact
  6397. if v == nil {
  6398. return
  6399. }
  6400. return *v, true
  6401. }
  6402. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  6403. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6405. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  6406. if !m.op.Is(OpUpdateOne) {
  6407. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  6408. }
  6409. if m.id == nil || m.oldValue == nil {
  6410. return v, errors.New("OldContactID requires an ID field in the mutation")
  6411. }
  6412. oldValue, err := m.oldValue(ctx)
  6413. if err != nil {
  6414. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  6415. }
  6416. return oldValue.ContactID, nil
  6417. }
  6418. // ClearContactID clears the value of the "contact_id" field.
  6419. func (m *MessageRecordsMutation) ClearContactID() {
  6420. m.message_contact = nil
  6421. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  6422. }
  6423. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  6424. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  6425. _, ok := m.clearedFields[messagerecords.FieldContactID]
  6426. return ok
  6427. }
  6428. // ResetContactID resets all changes to the "contact_id" field.
  6429. func (m *MessageRecordsMutation) ResetContactID() {
  6430. m.message_contact = nil
  6431. delete(m.clearedFields, messagerecords.FieldContactID)
  6432. }
  6433. // SetContactType sets the "contact_type" field.
  6434. func (m *MessageRecordsMutation) SetContactType(i int) {
  6435. m.contact_type = &i
  6436. m.addcontact_type = nil
  6437. }
  6438. // ContactType returns the value of the "contact_type" field in the mutation.
  6439. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  6440. v := m.contact_type
  6441. if v == nil {
  6442. return
  6443. }
  6444. return *v, true
  6445. }
  6446. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  6447. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6449. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  6450. if !m.op.Is(OpUpdateOne) {
  6451. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  6452. }
  6453. if m.id == nil || m.oldValue == nil {
  6454. return v, errors.New("OldContactType requires an ID field in the mutation")
  6455. }
  6456. oldValue, err := m.oldValue(ctx)
  6457. if err != nil {
  6458. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  6459. }
  6460. return oldValue.ContactType, nil
  6461. }
  6462. // AddContactType adds i to the "contact_type" field.
  6463. func (m *MessageRecordsMutation) AddContactType(i int) {
  6464. if m.addcontact_type != nil {
  6465. *m.addcontact_type += i
  6466. } else {
  6467. m.addcontact_type = &i
  6468. }
  6469. }
  6470. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  6471. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  6472. v := m.addcontact_type
  6473. if v == nil {
  6474. return
  6475. }
  6476. return *v, true
  6477. }
  6478. // ResetContactType resets all changes to the "contact_type" field.
  6479. func (m *MessageRecordsMutation) ResetContactType() {
  6480. m.contact_type = nil
  6481. m.addcontact_type = nil
  6482. }
  6483. // SetContactWxid sets the "contact_wxid" field.
  6484. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  6485. m.contact_wxid = &s
  6486. }
  6487. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  6488. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  6489. v := m.contact_wxid
  6490. if v == nil {
  6491. return
  6492. }
  6493. return *v, true
  6494. }
  6495. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  6496. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6497. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6498. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  6499. if !m.op.Is(OpUpdateOne) {
  6500. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  6501. }
  6502. if m.id == nil || m.oldValue == nil {
  6503. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  6504. }
  6505. oldValue, err := m.oldValue(ctx)
  6506. if err != nil {
  6507. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  6508. }
  6509. return oldValue.ContactWxid, nil
  6510. }
  6511. // ResetContactWxid resets all changes to the "contact_wxid" field.
  6512. func (m *MessageRecordsMutation) ResetContactWxid() {
  6513. m.contact_wxid = nil
  6514. }
  6515. // SetContentType sets the "content_type" field.
  6516. func (m *MessageRecordsMutation) SetContentType(i int) {
  6517. m.content_type = &i
  6518. m.addcontent_type = nil
  6519. }
  6520. // ContentType returns the value of the "content_type" field in the mutation.
  6521. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  6522. v := m.content_type
  6523. if v == nil {
  6524. return
  6525. }
  6526. return *v, true
  6527. }
  6528. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  6529. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6531. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  6532. if !m.op.Is(OpUpdateOne) {
  6533. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  6534. }
  6535. if m.id == nil || m.oldValue == nil {
  6536. return v, errors.New("OldContentType requires an ID field in the mutation")
  6537. }
  6538. oldValue, err := m.oldValue(ctx)
  6539. if err != nil {
  6540. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  6541. }
  6542. return oldValue.ContentType, nil
  6543. }
  6544. // AddContentType adds i to the "content_type" field.
  6545. func (m *MessageRecordsMutation) AddContentType(i int) {
  6546. if m.addcontent_type != nil {
  6547. *m.addcontent_type += i
  6548. } else {
  6549. m.addcontent_type = &i
  6550. }
  6551. }
  6552. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  6553. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  6554. v := m.addcontent_type
  6555. if v == nil {
  6556. return
  6557. }
  6558. return *v, true
  6559. }
  6560. // ResetContentType resets all changes to the "content_type" field.
  6561. func (m *MessageRecordsMutation) ResetContentType() {
  6562. m.content_type = nil
  6563. m.addcontent_type = nil
  6564. }
  6565. // SetContent sets the "content" field.
  6566. func (m *MessageRecordsMutation) SetContent(s string) {
  6567. m.content = &s
  6568. }
  6569. // Content returns the value of the "content" field in the mutation.
  6570. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  6571. v := m.content
  6572. if v == nil {
  6573. return
  6574. }
  6575. return *v, true
  6576. }
  6577. // OldContent returns the old "content" field's value of the MessageRecords entity.
  6578. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6579. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6580. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  6581. if !m.op.Is(OpUpdateOne) {
  6582. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6583. }
  6584. if m.id == nil || m.oldValue == nil {
  6585. return v, errors.New("OldContent requires an ID field in the mutation")
  6586. }
  6587. oldValue, err := m.oldValue(ctx)
  6588. if err != nil {
  6589. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  6590. }
  6591. return oldValue.Content, nil
  6592. }
  6593. // ResetContent resets all changes to the "content" field.
  6594. func (m *MessageRecordsMutation) ResetContent() {
  6595. m.content = nil
  6596. }
  6597. // SetMeta sets the "meta" field.
  6598. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  6599. m.meta = &ct
  6600. }
  6601. // Meta returns the value of the "meta" field in the mutation.
  6602. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  6603. v := m.meta
  6604. if v == nil {
  6605. return
  6606. }
  6607. return *v, true
  6608. }
  6609. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  6610. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6612. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  6613. if !m.op.Is(OpUpdateOne) {
  6614. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  6615. }
  6616. if m.id == nil || m.oldValue == nil {
  6617. return v, errors.New("OldMeta requires an ID field in the mutation")
  6618. }
  6619. oldValue, err := m.oldValue(ctx)
  6620. if err != nil {
  6621. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  6622. }
  6623. return oldValue.Meta, nil
  6624. }
  6625. // ClearMeta clears the value of the "meta" field.
  6626. func (m *MessageRecordsMutation) ClearMeta() {
  6627. m.meta = nil
  6628. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  6629. }
  6630. // MetaCleared returns if the "meta" field was cleared in this mutation.
  6631. func (m *MessageRecordsMutation) MetaCleared() bool {
  6632. _, ok := m.clearedFields[messagerecords.FieldMeta]
  6633. return ok
  6634. }
  6635. // ResetMeta resets all changes to the "meta" field.
  6636. func (m *MessageRecordsMutation) ResetMeta() {
  6637. m.meta = nil
  6638. delete(m.clearedFields, messagerecords.FieldMeta)
  6639. }
  6640. // SetErrorDetail sets the "error_detail" field.
  6641. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  6642. m.error_detail = &s
  6643. }
  6644. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  6645. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  6646. v := m.error_detail
  6647. if v == nil {
  6648. return
  6649. }
  6650. return *v, true
  6651. }
  6652. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  6653. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6655. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  6656. if !m.op.Is(OpUpdateOne) {
  6657. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  6658. }
  6659. if m.id == nil || m.oldValue == nil {
  6660. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  6661. }
  6662. oldValue, err := m.oldValue(ctx)
  6663. if err != nil {
  6664. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  6665. }
  6666. return oldValue.ErrorDetail, nil
  6667. }
  6668. // ResetErrorDetail resets all changes to the "error_detail" field.
  6669. func (m *MessageRecordsMutation) ResetErrorDetail() {
  6670. m.error_detail = nil
  6671. }
  6672. // SetSendTime sets the "send_time" field.
  6673. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  6674. m.send_time = &t
  6675. }
  6676. // SendTime returns the value of the "send_time" field in the mutation.
  6677. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  6678. v := m.send_time
  6679. if v == nil {
  6680. return
  6681. }
  6682. return *v, true
  6683. }
  6684. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  6685. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6687. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  6688. if !m.op.Is(OpUpdateOne) {
  6689. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  6690. }
  6691. if m.id == nil || m.oldValue == nil {
  6692. return v, errors.New("OldSendTime requires an ID field in the mutation")
  6693. }
  6694. oldValue, err := m.oldValue(ctx)
  6695. if err != nil {
  6696. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  6697. }
  6698. return oldValue.SendTime, nil
  6699. }
  6700. // ClearSendTime clears the value of the "send_time" field.
  6701. func (m *MessageRecordsMutation) ClearSendTime() {
  6702. m.send_time = nil
  6703. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  6704. }
  6705. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  6706. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  6707. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  6708. return ok
  6709. }
  6710. // ResetSendTime resets all changes to the "send_time" field.
  6711. func (m *MessageRecordsMutation) ResetSendTime() {
  6712. m.send_time = nil
  6713. delete(m.clearedFields, messagerecords.FieldSendTime)
  6714. }
  6715. // SetSourceType sets the "source_type" field.
  6716. func (m *MessageRecordsMutation) SetSourceType(i int) {
  6717. m.source_type = &i
  6718. m.addsource_type = nil
  6719. }
  6720. // SourceType returns the value of the "source_type" field in the mutation.
  6721. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  6722. v := m.source_type
  6723. if v == nil {
  6724. return
  6725. }
  6726. return *v, true
  6727. }
  6728. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  6729. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6731. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  6732. if !m.op.Is(OpUpdateOne) {
  6733. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  6734. }
  6735. if m.id == nil || m.oldValue == nil {
  6736. return v, errors.New("OldSourceType requires an ID field in the mutation")
  6737. }
  6738. oldValue, err := m.oldValue(ctx)
  6739. if err != nil {
  6740. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  6741. }
  6742. return oldValue.SourceType, nil
  6743. }
  6744. // AddSourceType adds i to the "source_type" field.
  6745. func (m *MessageRecordsMutation) AddSourceType(i int) {
  6746. if m.addsource_type != nil {
  6747. *m.addsource_type += i
  6748. } else {
  6749. m.addsource_type = &i
  6750. }
  6751. }
  6752. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  6753. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  6754. v := m.addsource_type
  6755. if v == nil {
  6756. return
  6757. }
  6758. return *v, true
  6759. }
  6760. // ResetSourceType resets all changes to the "source_type" field.
  6761. func (m *MessageRecordsMutation) ResetSourceType() {
  6762. m.source_type = nil
  6763. m.addsource_type = nil
  6764. }
  6765. // SetSourceID sets the "source_id" field.
  6766. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  6767. m.sop_stage = &u
  6768. }
  6769. // SourceID returns the value of the "source_id" field in the mutation.
  6770. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  6771. v := m.sop_stage
  6772. if v == nil {
  6773. return
  6774. }
  6775. return *v, true
  6776. }
  6777. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  6778. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6780. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  6781. if !m.op.Is(OpUpdateOne) {
  6782. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  6783. }
  6784. if m.id == nil || m.oldValue == nil {
  6785. return v, errors.New("OldSourceID requires an ID field in the mutation")
  6786. }
  6787. oldValue, err := m.oldValue(ctx)
  6788. if err != nil {
  6789. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  6790. }
  6791. return oldValue.SourceID, nil
  6792. }
  6793. // ClearSourceID clears the value of the "source_id" field.
  6794. func (m *MessageRecordsMutation) ClearSourceID() {
  6795. m.sop_stage = nil
  6796. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  6797. }
  6798. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  6799. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  6800. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  6801. return ok
  6802. }
  6803. // ResetSourceID resets all changes to the "source_id" field.
  6804. func (m *MessageRecordsMutation) ResetSourceID() {
  6805. m.sop_stage = nil
  6806. delete(m.clearedFields, messagerecords.FieldSourceID)
  6807. }
  6808. // SetSubSourceID sets the "sub_source_id" field.
  6809. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  6810. m.sop_node = &u
  6811. }
  6812. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  6813. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  6814. v := m.sop_node
  6815. if v == nil {
  6816. return
  6817. }
  6818. return *v, true
  6819. }
  6820. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  6821. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6823. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  6824. if !m.op.Is(OpUpdateOne) {
  6825. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  6826. }
  6827. if m.id == nil || m.oldValue == nil {
  6828. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  6829. }
  6830. oldValue, err := m.oldValue(ctx)
  6831. if err != nil {
  6832. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  6833. }
  6834. return oldValue.SubSourceID, nil
  6835. }
  6836. // ClearSubSourceID clears the value of the "sub_source_id" field.
  6837. func (m *MessageRecordsMutation) ClearSubSourceID() {
  6838. m.sop_node = nil
  6839. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  6840. }
  6841. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  6842. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  6843. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  6844. return ok
  6845. }
  6846. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  6847. func (m *MessageRecordsMutation) ResetSubSourceID() {
  6848. m.sop_node = nil
  6849. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  6850. }
  6851. // SetOrganizationID sets the "organization_id" field.
  6852. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  6853. m.organization_id = &u
  6854. m.addorganization_id = nil
  6855. }
  6856. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6857. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  6858. v := m.organization_id
  6859. if v == nil {
  6860. return
  6861. }
  6862. return *v, true
  6863. }
  6864. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  6865. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6867. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6868. if !m.op.Is(OpUpdateOne) {
  6869. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6870. }
  6871. if m.id == nil || m.oldValue == nil {
  6872. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6873. }
  6874. oldValue, err := m.oldValue(ctx)
  6875. if err != nil {
  6876. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6877. }
  6878. return oldValue.OrganizationID, nil
  6879. }
  6880. // AddOrganizationID adds u to the "organization_id" field.
  6881. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  6882. if m.addorganization_id != nil {
  6883. *m.addorganization_id += u
  6884. } else {
  6885. m.addorganization_id = &u
  6886. }
  6887. }
  6888. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6889. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  6890. v := m.addorganization_id
  6891. if v == nil {
  6892. return
  6893. }
  6894. return *v, true
  6895. }
  6896. // ClearOrganizationID clears the value of the "organization_id" field.
  6897. func (m *MessageRecordsMutation) ClearOrganizationID() {
  6898. m.organization_id = nil
  6899. m.addorganization_id = nil
  6900. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  6901. }
  6902. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  6903. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  6904. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  6905. return ok
  6906. }
  6907. // ResetOrganizationID resets all changes to the "organization_id" field.
  6908. func (m *MessageRecordsMutation) ResetOrganizationID() {
  6909. m.organization_id = nil
  6910. m.addorganization_id = nil
  6911. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  6912. }
  6913. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  6914. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  6915. m.sop_stage = &id
  6916. }
  6917. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  6918. func (m *MessageRecordsMutation) ClearSopStage() {
  6919. m.clearedsop_stage = true
  6920. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  6921. }
  6922. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  6923. func (m *MessageRecordsMutation) SopStageCleared() bool {
  6924. return m.SourceIDCleared() || m.clearedsop_stage
  6925. }
  6926. // SopStageID returns the "sop_stage" edge ID in the mutation.
  6927. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  6928. if m.sop_stage != nil {
  6929. return *m.sop_stage, true
  6930. }
  6931. return
  6932. }
  6933. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  6934. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  6935. // SopStageID instead. It exists only for internal usage by the builders.
  6936. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  6937. if id := m.sop_stage; id != nil {
  6938. ids = append(ids, *id)
  6939. }
  6940. return
  6941. }
  6942. // ResetSopStage resets all changes to the "sop_stage" edge.
  6943. func (m *MessageRecordsMutation) ResetSopStage() {
  6944. m.sop_stage = nil
  6945. m.clearedsop_stage = false
  6946. }
  6947. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  6948. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  6949. m.sop_node = &id
  6950. }
  6951. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  6952. func (m *MessageRecordsMutation) ClearSopNode() {
  6953. m.clearedsop_node = true
  6954. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  6955. }
  6956. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  6957. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  6958. return m.SubSourceIDCleared() || m.clearedsop_node
  6959. }
  6960. // SopNodeID returns the "sop_node" edge ID in the mutation.
  6961. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  6962. if m.sop_node != nil {
  6963. return *m.sop_node, true
  6964. }
  6965. return
  6966. }
  6967. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  6968. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  6969. // SopNodeID instead. It exists only for internal usage by the builders.
  6970. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  6971. if id := m.sop_node; id != nil {
  6972. ids = append(ids, *id)
  6973. }
  6974. return
  6975. }
  6976. // ResetSopNode resets all changes to the "sop_node" edge.
  6977. func (m *MessageRecordsMutation) ResetSopNode() {
  6978. m.sop_node = nil
  6979. m.clearedsop_node = false
  6980. }
  6981. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  6982. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  6983. m.message_contact = &id
  6984. }
  6985. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  6986. func (m *MessageRecordsMutation) ClearMessageContact() {
  6987. m.clearedmessage_contact = true
  6988. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  6989. }
  6990. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  6991. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  6992. return m.ContactIDCleared() || m.clearedmessage_contact
  6993. }
  6994. // MessageContactID returns the "message_contact" edge ID in the mutation.
  6995. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  6996. if m.message_contact != nil {
  6997. return *m.message_contact, true
  6998. }
  6999. return
  7000. }
  7001. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  7002. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  7003. // MessageContactID instead. It exists only for internal usage by the builders.
  7004. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  7005. if id := m.message_contact; id != nil {
  7006. ids = append(ids, *id)
  7007. }
  7008. return
  7009. }
  7010. // ResetMessageContact resets all changes to the "message_contact" edge.
  7011. func (m *MessageRecordsMutation) ResetMessageContact() {
  7012. m.message_contact = nil
  7013. m.clearedmessage_contact = false
  7014. }
  7015. // Where appends a list predicates to the MessageRecordsMutation builder.
  7016. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  7017. m.predicates = append(m.predicates, ps...)
  7018. }
  7019. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  7020. // users can use type-assertion to append predicates that do not depend on any generated package.
  7021. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  7022. p := make([]predicate.MessageRecords, len(ps))
  7023. for i := range ps {
  7024. p[i] = ps[i]
  7025. }
  7026. m.Where(p...)
  7027. }
  7028. // Op returns the operation name.
  7029. func (m *MessageRecordsMutation) Op() Op {
  7030. return m.op
  7031. }
  7032. // SetOp allows setting the mutation operation.
  7033. func (m *MessageRecordsMutation) SetOp(op Op) {
  7034. m.op = op
  7035. }
  7036. // Type returns the node type of this mutation (MessageRecords).
  7037. func (m *MessageRecordsMutation) Type() string {
  7038. return m.typ
  7039. }
  7040. // Fields returns all fields that were changed during this mutation. Note that in
  7041. // order to get all numeric fields that were incremented/decremented, call
  7042. // AddedFields().
  7043. func (m *MessageRecordsMutation) Fields() []string {
  7044. fields := make([]string, 0, 17)
  7045. if m.created_at != nil {
  7046. fields = append(fields, messagerecords.FieldCreatedAt)
  7047. }
  7048. if m.updated_at != nil {
  7049. fields = append(fields, messagerecords.FieldUpdatedAt)
  7050. }
  7051. if m.status != nil {
  7052. fields = append(fields, messagerecords.FieldStatus)
  7053. }
  7054. if m.deleted_at != nil {
  7055. fields = append(fields, messagerecords.FieldDeletedAt)
  7056. }
  7057. if m.bot_wxid != nil {
  7058. fields = append(fields, messagerecords.FieldBotWxid)
  7059. }
  7060. if m.message_contact != nil {
  7061. fields = append(fields, messagerecords.FieldContactID)
  7062. }
  7063. if m.contact_type != nil {
  7064. fields = append(fields, messagerecords.FieldContactType)
  7065. }
  7066. if m.contact_wxid != nil {
  7067. fields = append(fields, messagerecords.FieldContactWxid)
  7068. }
  7069. if m.content_type != nil {
  7070. fields = append(fields, messagerecords.FieldContentType)
  7071. }
  7072. if m.content != nil {
  7073. fields = append(fields, messagerecords.FieldContent)
  7074. }
  7075. if m.meta != nil {
  7076. fields = append(fields, messagerecords.FieldMeta)
  7077. }
  7078. if m.error_detail != nil {
  7079. fields = append(fields, messagerecords.FieldErrorDetail)
  7080. }
  7081. if m.send_time != nil {
  7082. fields = append(fields, messagerecords.FieldSendTime)
  7083. }
  7084. if m.source_type != nil {
  7085. fields = append(fields, messagerecords.FieldSourceType)
  7086. }
  7087. if m.sop_stage != nil {
  7088. fields = append(fields, messagerecords.FieldSourceID)
  7089. }
  7090. if m.sop_node != nil {
  7091. fields = append(fields, messagerecords.FieldSubSourceID)
  7092. }
  7093. if m.organization_id != nil {
  7094. fields = append(fields, messagerecords.FieldOrganizationID)
  7095. }
  7096. return fields
  7097. }
  7098. // Field returns the value of a field with the given name. The second boolean
  7099. // return value indicates that this field was not set, or was not defined in the
  7100. // schema.
  7101. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  7102. switch name {
  7103. case messagerecords.FieldCreatedAt:
  7104. return m.CreatedAt()
  7105. case messagerecords.FieldUpdatedAt:
  7106. return m.UpdatedAt()
  7107. case messagerecords.FieldStatus:
  7108. return m.Status()
  7109. case messagerecords.FieldDeletedAt:
  7110. return m.DeletedAt()
  7111. case messagerecords.FieldBotWxid:
  7112. return m.BotWxid()
  7113. case messagerecords.FieldContactID:
  7114. return m.ContactID()
  7115. case messagerecords.FieldContactType:
  7116. return m.ContactType()
  7117. case messagerecords.FieldContactWxid:
  7118. return m.ContactWxid()
  7119. case messagerecords.FieldContentType:
  7120. return m.ContentType()
  7121. case messagerecords.FieldContent:
  7122. return m.Content()
  7123. case messagerecords.FieldMeta:
  7124. return m.Meta()
  7125. case messagerecords.FieldErrorDetail:
  7126. return m.ErrorDetail()
  7127. case messagerecords.FieldSendTime:
  7128. return m.SendTime()
  7129. case messagerecords.FieldSourceType:
  7130. return m.SourceType()
  7131. case messagerecords.FieldSourceID:
  7132. return m.SourceID()
  7133. case messagerecords.FieldSubSourceID:
  7134. return m.SubSourceID()
  7135. case messagerecords.FieldOrganizationID:
  7136. return m.OrganizationID()
  7137. }
  7138. return nil, false
  7139. }
  7140. // OldField returns the old value of the field from the database. An error is
  7141. // returned if the mutation operation is not UpdateOne, or the query to the
  7142. // database failed.
  7143. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7144. switch name {
  7145. case messagerecords.FieldCreatedAt:
  7146. return m.OldCreatedAt(ctx)
  7147. case messagerecords.FieldUpdatedAt:
  7148. return m.OldUpdatedAt(ctx)
  7149. case messagerecords.FieldStatus:
  7150. return m.OldStatus(ctx)
  7151. case messagerecords.FieldDeletedAt:
  7152. return m.OldDeletedAt(ctx)
  7153. case messagerecords.FieldBotWxid:
  7154. return m.OldBotWxid(ctx)
  7155. case messagerecords.FieldContactID:
  7156. return m.OldContactID(ctx)
  7157. case messagerecords.FieldContactType:
  7158. return m.OldContactType(ctx)
  7159. case messagerecords.FieldContactWxid:
  7160. return m.OldContactWxid(ctx)
  7161. case messagerecords.FieldContentType:
  7162. return m.OldContentType(ctx)
  7163. case messagerecords.FieldContent:
  7164. return m.OldContent(ctx)
  7165. case messagerecords.FieldMeta:
  7166. return m.OldMeta(ctx)
  7167. case messagerecords.FieldErrorDetail:
  7168. return m.OldErrorDetail(ctx)
  7169. case messagerecords.FieldSendTime:
  7170. return m.OldSendTime(ctx)
  7171. case messagerecords.FieldSourceType:
  7172. return m.OldSourceType(ctx)
  7173. case messagerecords.FieldSourceID:
  7174. return m.OldSourceID(ctx)
  7175. case messagerecords.FieldSubSourceID:
  7176. return m.OldSubSourceID(ctx)
  7177. case messagerecords.FieldOrganizationID:
  7178. return m.OldOrganizationID(ctx)
  7179. }
  7180. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  7181. }
  7182. // SetField sets the value of a field with the given name. It returns an error if
  7183. // the field is not defined in the schema, or if the type mismatched the field
  7184. // type.
  7185. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  7186. switch name {
  7187. case messagerecords.FieldCreatedAt:
  7188. v, ok := value.(time.Time)
  7189. if !ok {
  7190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7191. }
  7192. m.SetCreatedAt(v)
  7193. return nil
  7194. case messagerecords.FieldUpdatedAt:
  7195. v, ok := value.(time.Time)
  7196. if !ok {
  7197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7198. }
  7199. m.SetUpdatedAt(v)
  7200. return nil
  7201. case messagerecords.FieldStatus:
  7202. v, ok := value.(uint8)
  7203. if !ok {
  7204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7205. }
  7206. m.SetStatus(v)
  7207. return nil
  7208. case messagerecords.FieldDeletedAt:
  7209. v, ok := value.(time.Time)
  7210. if !ok {
  7211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7212. }
  7213. m.SetDeletedAt(v)
  7214. return nil
  7215. case messagerecords.FieldBotWxid:
  7216. v, ok := value.(string)
  7217. if !ok {
  7218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7219. }
  7220. m.SetBotWxid(v)
  7221. return nil
  7222. case messagerecords.FieldContactID:
  7223. v, ok := value.(uint64)
  7224. if !ok {
  7225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7226. }
  7227. m.SetContactID(v)
  7228. return nil
  7229. case messagerecords.FieldContactType:
  7230. v, ok := value.(int)
  7231. if !ok {
  7232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7233. }
  7234. m.SetContactType(v)
  7235. return nil
  7236. case messagerecords.FieldContactWxid:
  7237. v, ok := value.(string)
  7238. if !ok {
  7239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7240. }
  7241. m.SetContactWxid(v)
  7242. return nil
  7243. case messagerecords.FieldContentType:
  7244. v, ok := value.(int)
  7245. if !ok {
  7246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7247. }
  7248. m.SetContentType(v)
  7249. return nil
  7250. case messagerecords.FieldContent:
  7251. v, ok := value.(string)
  7252. if !ok {
  7253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7254. }
  7255. m.SetContent(v)
  7256. return nil
  7257. case messagerecords.FieldMeta:
  7258. v, ok := value.(custom_types.Meta)
  7259. if !ok {
  7260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7261. }
  7262. m.SetMeta(v)
  7263. return nil
  7264. case messagerecords.FieldErrorDetail:
  7265. v, ok := value.(string)
  7266. if !ok {
  7267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7268. }
  7269. m.SetErrorDetail(v)
  7270. return nil
  7271. case messagerecords.FieldSendTime:
  7272. v, ok := value.(time.Time)
  7273. if !ok {
  7274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7275. }
  7276. m.SetSendTime(v)
  7277. return nil
  7278. case messagerecords.FieldSourceType:
  7279. v, ok := value.(int)
  7280. if !ok {
  7281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7282. }
  7283. m.SetSourceType(v)
  7284. return nil
  7285. case messagerecords.FieldSourceID:
  7286. v, ok := value.(uint64)
  7287. if !ok {
  7288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7289. }
  7290. m.SetSourceID(v)
  7291. return nil
  7292. case messagerecords.FieldSubSourceID:
  7293. v, ok := value.(uint64)
  7294. if !ok {
  7295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7296. }
  7297. m.SetSubSourceID(v)
  7298. return nil
  7299. case messagerecords.FieldOrganizationID:
  7300. v, ok := value.(uint64)
  7301. if !ok {
  7302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7303. }
  7304. m.SetOrganizationID(v)
  7305. return nil
  7306. }
  7307. return fmt.Errorf("unknown MessageRecords field %s", name)
  7308. }
  7309. // AddedFields returns all numeric fields that were incremented/decremented during
  7310. // this mutation.
  7311. func (m *MessageRecordsMutation) AddedFields() []string {
  7312. var fields []string
  7313. if m.addstatus != nil {
  7314. fields = append(fields, messagerecords.FieldStatus)
  7315. }
  7316. if m.addcontact_type != nil {
  7317. fields = append(fields, messagerecords.FieldContactType)
  7318. }
  7319. if m.addcontent_type != nil {
  7320. fields = append(fields, messagerecords.FieldContentType)
  7321. }
  7322. if m.addsource_type != nil {
  7323. fields = append(fields, messagerecords.FieldSourceType)
  7324. }
  7325. if m.addorganization_id != nil {
  7326. fields = append(fields, messagerecords.FieldOrganizationID)
  7327. }
  7328. return fields
  7329. }
  7330. // AddedField returns the numeric value that was incremented/decremented on a field
  7331. // with the given name. The second boolean return value indicates that this field
  7332. // was not set, or was not defined in the schema.
  7333. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  7334. switch name {
  7335. case messagerecords.FieldStatus:
  7336. return m.AddedStatus()
  7337. case messagerecords.FieldContactType:
  7338. return m.AddedContactType()
  7339. case messagerecords.FieldContentType:
  7340. return m.AddedContentType()
  7341. case messagerecords.FieldSourceType:
  7342. return m.AddedSourceType()
  7343. case messagerecords.FieldOrganizationID:
  7344. return m.AddedOrganizationID()
  7345. }
  7346. return nil, false
  7347. }
  7348. // AddField adds the value to the field with the given name. It returns an error if
  7349. // the field is not defined in the schema, or if the type mismatched the field
  7350. // type.
  7351. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  7352. switch name {
  7353. case messagerecords.FieldStatus:
  7354. v, ok := value.(int8)
  7355. if !ok {
  7356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7357. }
  7358. m.AddStatus(v)
  7359. return nil
  7360. case messagerecords.FieldContactType:
  7361. v, ok := value.(int)
  7362. if !ok {
  7363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7364. }
  7365. m.AddContactType(v)
  7366. return nil
  7367. case messagerecords.FieldContentType:
  7368. v, ok := value.(int)
  7369. if !ok {
  7370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7371. }
  7372. m.AddContentType(v)
  7373. return nil
  7374. case messagerecords.FieldSourceType:
  7375. v, ok := value.(int)
  7376. if !ok {
  7377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7378. }
  7379. m.AddSourceType(v)
  7380. return nil
  7381. case messagerecords.FieldOrganizationID:
  7382. v, ok := value.(int64)
  7383. if !ok {
  7384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7385. }
  7386. m.AddOrganizationID(v)
  7387. return nil
  7388. }
  7389. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  7390. }
  7391. // ClearedFields returns all nullable fields that were cleared during this
  7392. // mutation.
  7393. func (m *MessageRecordsMutation) ClearedFields() []string {
  7394. var fields []string
  7395. if m.FieldCleared(messagerecords.FieldStatus) {
  7396. fields = append(fields, messagerecords.FieldStatus)
  7397. }
  7398. if m.FieldCleared(messagerecords.FieldDeletedAt) {
  7399. fields = append(fields, messagerecords.FieldDeletedAt)
  7400. }
  7401. if m.FieldCleared(messagerecords.FieldContactID) {
  7402. fields = append(fields, messagerecords.FieldContactID)
  7403. }
  7404. if m.FieldCleared(messagerecords.FieldMeta) {
  7405. fields = append(fields, messagerecords.FieldMeta)
  7406. }
  7407. if m.FieldCleared(messagerecords.FieldSendTime) {
  7408. fields = append(fields, messagerecords.FieldSendTime)
  7409. }
  7410. if m.FieldCleared(messagerecords.FieldSourceID) {
  7411. fields = append(fields, messagerecords.FieldSourceID)
  7412. }
  7413. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  7414. fields = append(fields, messagerecords.FieldSubSourceID)
  7415. }
  7416. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  7417. fields = append(fields, messagerecords.FieldOrganizationID)
  7418. }
  7419. return fields
  7420. }
  7421. // FieldCleared returns a boolean indicating if a field with the given name was
  7422. // cleared in this mutation.
  7423. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  7424. _, ok := m.clearedFields[name]
  7425. return ok
  7426. }
  7427. // ClearField clears the value of the field with the given name. It returns an
  7428. // error if the field is not defined in the schema.
  7429. func (m *MessageRecordsMutation) ClearField(name string) error {
  7430. switch name {
  7431. case messagerecords.FieldStatus:
  7432. m.ClearStatus()
  7433. return nil
  7434. case messagerecords.FieldDeletedAt:
  7435. m.ClearDeletedAt()
  7436. return nil
  7437. case messagerecords.FieldContactID:
  7438. m.ClearContactID()
  7439. return nil
  7440. case messagerecords.FieldMeta:
  7441. m.ClearMeta()
  7442. return nil
  7443. case messagerecords.FieldSendTime:
  7444. m.ClearSendTime()
  7445. return nil
  7446. case messagerecords.FieldSourceID:
  7447. m.ClearSourceID()
  7448. return nil
  7449. case messagerecords.FieldSubSourceID:
  7450. m.ClearSubSourceID()
  7451. return nil
  7452. case messagerecords.FieldOrganizationID:
  7453. m.ClearOrganizationID()
  7454. return nil
  7455. }
  7456. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  7457. }
  7458. // ResetField resets all changes in the mutation for the field with the given name.
  7459. // It returns an error if the field is not defined in the schema.
  7460. func (m *MessageRecordsMutation) ResetField(name string) error {
  7461. switch name {
  7462. case messagerecords.FieldCreatedAt:
  7463. m.ResetCreatedAt()
  7464. return nil
  7465. case messagerecords.FieldUpdatedAt:
  7466. m.ResetUpdatedAt()
  7467. return nil
  7468. case messagerecords.FieldStatus:
  7469. m.ResetStatus()
  7470. return nil
  7471. case messagerecords.FieldDeletedAt:
  7472. m.ResetDeletedAt()
  7473. return nil
  7474. case messagerecords.FieldBotWxid:
  7475. m.ResetBotWxid()
  7476. return nil
  7477. case messagerecords.FieldContactID:
  7478. m.ResetContactID()
  7479. return nil
  7480. case messagerecords.FieldContactType:
  7481. m.ResetContactType()
  7482. return nil
  7483. case messagerecords.FieldContactWxid:
  7484. m.ResetContactWxid()
  7485. return nil
  7486. case messagerecords.FieldContentType:
  7487. m.ResetContentType()
  7488. return nil
  7489. case messagerecords.FieldContent:
  7490. m.ResetContent()
  7491. return nil
  7492. case messagerecords.FieldMeta:
  7493. m.ResetMeta()
  7494. return nil
  7495. case messagerecords.FieldErrorDetail:
  7496. m.ResetErrorDetail()
  7497. return nil
  7498. case messagerecords.FieldSendTime:
  7499. m.ResetSendTime()
  7500. return nil
  7501. case messagerecords.FieldSourceType:
  7502. m.ResetSourceType()
  7503. return nil
  7504. case messagerecords.FieldSourceID:
  7505. m.ResetSourceID()
  7506. return nil
  7507. case messagerecords.FieldSubSourceID:
  7508. m.ResetSubSourceID()
  7509. return nil
  7510. case messagerecords.FieldOrganizationID:
  7511. m.ResetOrganizationID()
  7512. return nil
  7513. }
  7514. return fmt.Errorf("unknown MessageRecords field %s", name)
  7515. }
  7516. // AddedEdges returns all edge names that were set/added in this mutation.
  7517. func (m *MessageRecordsMutation) AddedEdges() []string {
  7518. edges := make([]string, 0, 3)
  7519. if m.sop_stage != nil {
  7520. edges = append(edges, messagerecords.EdgeSopStage)
  7521. }
  7522. if m.sop_node != nil {
  7523. edges = append(edges, messagerecords.EdgeSopNode)
  7524. }
  7525. if m.message_contact != nil {
  7526. edges = append(edges, messagerecords.EdgeMessageContact)
  7527. }
  7528. return edges
  7529. }
  7530. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7531. // name in this mutation.
  7532. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  7533. switch name {
  7534. case messagerecords.EdgeSopStage:
  7535. if id := m.sop_stage; id != nil {
  7536. return []ent.Value{*id}
  7537. }
  7538. case messagerecords.EdgeSopNode:
  7539. if id := m.sop_node; id != nil {
  7540. return []ent.Value{*id}
  7541. }
  7542. case messagerecords.EdgeMessageContact:
  7543. if id := m.message_contact; id != nil {
  7544. return []ent.Value{*id}
  7545. }
  7546. }
  7547. return nil
  7548. }
  7549. // RemovedEdges returns all edge names that were removed in this mutation.
  7550. func (m *MessageRecordsMutation) RemovedEdges() []string {
  7551. edges := make([]string, 0, 3)
  7552. return edges
  7553. }
  7554. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7555. // the given name in this mutation.
  7556. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  7557. return nil
  7558. }
  7559. // ClearedEdges returns all edge names that were cleared in this mutation.
  7560. func (m *MessageRecordsMutation) ClearedEdges() []string {
  7561. edges := make([]string, 0, 3)
  7562. if m.clearedsop_stage {
  7563. edges = append(edges, messagerecords.EdgeSopStage)
  7564. }
  7565. if m.clearedsop_node {
  7566. edges = append(edges, messagerecords.EdgeSopNode)
  7567. }
  7568. if m.clearedmessage_contact {
  7569. edges = append(edges, messagerecords.EdgeMessageContact)
  7570. }
  7571. return edges
  7572. }
  7573. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7574. // was cleared in this mutation.
  7575. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  7576. switch name {
  7577. case messagerecords.EdgeSopStage:
  7578. return m.clearedsop_stage
  7579. case messagerecords.EdgeSopNode:
  7580. return m.clearedsop_node
  7581. case messagerecords.EdgeMessageContact:
  7582. return m.clearedmessage_contact
  7583. }
  7584. return false
  7585. }
  7586. // ClearEdge clears the value of the edge with the given name. It returns an error
  7587. // if that edge is not defined in the schema.
  7588. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  7589. switch name {
  7590. case messagerecords.EdgeSopStage:
  7591. m.ClearSopStage()
  7592. return nil
  7593. case messagerecords.EdgeSopNode:
  7594. m.ClearSopNode()
  7595. return nil
  7596. case messagerecords.EdgeMessageContact:
  7597. m.ClearMessageContact()
  7598. return nil
  7599. }
  7600. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  7601. }
  7602. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7603. // It returns an error if the edge is not defined in the schema.
  7604. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  7605. switch name {
  7606. case messagerecords.EdgeSopStage:
  7607. m.ResetSopStage()
  7608. return nil
  7609. case messagerecords.EdgeSopNode:
  7610. m.ResetSopNode()
  7611. return nil
  7612. case messagerecords.EdgeMessageContact:
  7613. m.ResetMessageContact()
  7614. return nil
  7615. }
  7616. return fmt.Errorf("unknown MessageRecords edge %s", name)
  7617. }
  7618. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  7619. type MsgMutation struct {
  7620. config
  7621. op Op
  7622. typ string
  7623. id *uint64
  7624. created_at *time.Time
  7625. updated_at *time.Time
  7626. deleted_at *time.Time
  7627. status *uint8
  7628. addstatus *int8
  7629. fromwxid *string
  7630. toid *string
  7631. msgtype *int32
  7632. addmsgtype *int32
  7633. msg *string
  7634. batch_no *string
  7635. clearedFields map[string]struct{}
  7636. done bool
  7637. oldValue func(context.Context) (*Msg, error)
  7638. predicates []predicate.Msg
  7639. }
  7640. var _ ent.Mutation = (*MsgMutation)(nil)
  7641. // msgOption allows management of the mutation configuration using functional options.
  7642. type msgOption func(*MsgMutation)
  7643. // newMsgMutation creates new mutation for the Msg entity.
  7644. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  7645. m := &MsgMutation{
  7646. config: c,
  7647. op: op,
  7648. typ: TypeMsg,
  7649. clearedFields: make(map[string]struct{}),
  7650. }
  7651. for _, opt := range opts {
  7652. opt(m)
  7653. }
  7654. return m
  7655. }
  7656. // withMsgID sets the ID field of the mutation.
  7657. func withMsgID(id uint64) msgOption {
  7658. return func(m *MsgMutation) {
  7659. var (
  7660. err error
  7661. once sync.Once
  7662. value *Msg
  7663. )
  7664. m.oldValue = func(ctx context.Context) (*Msg, error) {
  7665. once.Do(func() {
  7666. if m.done {
  7667. err = errors.New("querying old values post mutation is not allowed")
  7668. } else {
  7669. value, err = m.Client().Msg.Get(ctx, id)
  7670. }
  7671. })
  7672. return value, err
  7673. }
  7674. m.id = &id
  7675. }
  7676. }
  7677. // withMsg sets the old Msg of the mutation.
  7678. func withMsg(node *Msg) msgOption {
  7679. return func(m *MsgMutation) {
  7680. m.oldValue = func(context.Context) (*Msg, error) {
  7681. return node, nil
  7682. }
  7683. m.id = &node.ID
  7684. }
  7685. }
  7686. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7687. // executed in a transaction (ent.Tx), a transactional client is returned.
  7688. func (m MsgMutation) Client() *Client {
  7689. client := &Client{config: m.config}
  7690. client.init()
  7691. return client
  7692. }
  7693. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7694. // it returns an error otherwise.
  7695. func (m MsgMutation) Tx() (*Tx, error) {
  7696. if _, ok := m.driver.(*txDriver); !ok {
  7697. return nil, errors.New("ent: mutation is not running in a transaction")
  7698. }
  7699. tx := &Tx{config: m.config}
  7700. tx.init()
  7701. return tx, nil
  7702. }
  7703. // SetID sets the value of the id field. Note that this
  7704. // operation is only accepted on creation of Msg entities.
  7705. func (m *MsgMutation) SetID(id uint64) {
  7706. m.id = &id
  7707. }
  7708. // ID returns the ID value in the mutation. Note that the ID is only available
  7709. // if it was provided to the builder or after it was returned from the database.
  7710. func (m *MsgMutation) ID() (id uint64, exists bool) {
  7711. if m.id == nil {
  7712. return
  7713. }
  7714. return *m.id, true
  7715. }
  7716. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7717. // That means, if the mutation is applied within a transaction with an isolation level such
  7718. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7719. // or updated by the mutation.
  7720. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  7721. switch {
  7722. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7723. id, exists := m.ID()
  7724. if exists {
  7725. return []uint64{id}, nil
  7726. }
  7727. fallthrough
  7728. case m.op.Is(OpUpdate | OpDelete):
  7729. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  7730. default:
  7731. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7732. }
  7733. }
  7734. // SetCreatedAt sets the "created_at" field.
  7735. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  7736. m.created_at = &t
  7737. }
  7738. // CreatedAt returns the value of the "created_at" field in the mutation.
  7739. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  7740. v := m.created_at
  7741. if v == nil {
  7742. return
  7743. }
  7744. return *v, true
  7745. }
  7746. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  7747. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7749. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7750. if !m.op.Is(OpUpdateOne) {
  7751. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7752. }
  7753. if m.id == nil || m.oldValue == nil {
  7754. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7755. }
  7756. oldValue, err := m.oldValue(ctx)
  7757. if err != nil {
  7758. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7759. }
  7760. return oldValue.CreatedAt, nil
  7761. }
  7762. // ResetCreatedAt resets all changes to the "created_at" field.
  7763. func (m *MsgMutation) ResetCreatedAt() {
  7764. m.created_at = nil
  7765. }
  7766. // SetUpdatedAt sets the "updated_at" field.
  7767. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  7768. m.updated_at = &t
  7769. }
  7770. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7771. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  7772. v := m.updated_at
  7773. if v == nil {
  7774. return
  7775. }
  7776. return *v, true
  7777. }
  7778. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  7779. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7781. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7782. if !m.op.Is(OpUpdateOne) {
  7783. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7784. }
  7785. if m.id == nil || m.oldValue == nil {
  7786. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7787. }
  7788. oldValue, err := m.oldValue(ctx)
  7789. if err != nil {
  7790. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7791. }
  7792. return oldValue.UpdatedAt, nil
  7793. }
  7794. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7795. func (m *MsgMutation) ResetUpdatedAt() {
  7796. m.updated_at = nil
  7797. }
  7798. // SetDeletedAt sets the "deleted_at" field.
  7799. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  7800. m.deleted_at = &t
  7801. }
  7802. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7803. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  7804. v := m.deleted_at
  7805. if v == nil {
  7806. return
  7807. }
  7808. return *v, true
  7809. }
  7810. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  7811. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7813. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7814. if !m.op.Is(OpUpdateOne) {
  7815. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7816. }
  7817. if m.id == nil || m.oldValue == nil {
  7818. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7819. }
  7820. oldValue, err := m.oldValue(ctx)
  7821. if err != nil {
  7822. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7823. }
  7824. return oldValue.DeletedAt, nil
  7825. }
  7826. // ClearDeletedAt clears the value of the "deleted_at" field.
  7827. func (m *MsgMutation) ClearDeletedAt() {
  7828. m.deleted_at = nil
  7829. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  7830. }
  7831. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7832. func (m *MsgMutation) DeletedAtCleared() bool {
  7833. _, ok := m.clearedFields[msg.FieldDeletedAt]
  7834. return ok
  7835. }
  7836. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7837. func (m *MsgMutation) ResetDeletedAt() {
  7838. m.deleted_at = nil
  7839. delete(m.clearedFields, msg.FieldDeletedAt)
  7840. }
  7841. // SetStatus sets the "status" field.
  7842. func (m *MsgMutation) SetStatus(u uint8) {
  7843. m.status = &u
  7844. m.addstatus = nil
  7845. }
  7846. // Status returns the value of the "status" field in the mutation.
  7847. func (m *MsgMutation) Status() (r uint8, exists bool) {
  7848. v := m.status
  7849. if v == nil {
  7850. return
  7851. }
  7852. return *v, true
  7853. }
  7854. // OldStatus returns the old "status" field's value of the Msg entity.
  7855. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7857. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7858. if !m.op.Is(OpUpdateOne) {
  7859. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7860. }
  7861. if m.id == nil || m.oldValue == nil {
  7862. return v, errors.New("OldStatus requires an ID field in the mutation")
  7863. }
  7864. oldValue, err := m.oldValue(ctx)
  7865. if err != nil {
  7866. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7867. }
  7868. return oldValue.Status, nil
  7869. }
  7870. // AddStatus adds u to the "status" field.
  7871. func (m *MsgMutation) AddStatus(u int8) {
  7872. if m.addstatus != nil {
  7873. *m.addstatus += u
  7874. } else {
  7875. m.addstatus = &u
  7876. }
  7877. }
  7878. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7879. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  7880. v := m.addstatus
  7881. if v == nil {
  7882. return
  7883. }
  7884. return *v, true
  7885. }
  7886. // ClearStatus clears the value of the "status" field.
  7887. func (m *MsgMutation) ClearStatus() {
  7888. m.status = nil
  7889. m.addstatus = nil
  7890. m.clearedFields[msg.FieldStatus] = struct{}{}
  7891. }
  7892. // StatusCleared returns if the "status" field was cleared in this mutation.
  7893. func (m *MsgMutation) StatusCleared() bool {
  7894. _, ok := m.clearedFields[msg.FieldStatus]
  7895. return ok
  7896. }
  7897. // ResetStatus resets all changes to the "status" field.
  7898. func (m *MsgMutation) ResetStatus() {
  7899. m.status = nil
  7900. m.addstatus = nil
  7901. delete(m.clearedFields, msg.FieldStatus)
  7902. }
  7903. // SetFromwxid sets the "fromwxid" field.
  7904. func (m *MsgMutation) SetFromwxid(s string) {
  7905. m.fromwxid = &s
  7906. }
  7907. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  7908. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  7909. v := m.fromwxid
  7910. if v == nil {
  7911. return
  7912. }
  7913. return *v, true
  7914. }
  7915. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  7916. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7918. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  7919. if !m.op.Is(OpUpdateOne) {
  7920. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  7921. }
  7922. if m.id == nil || m.oldValue == nil {
  7923. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  7924. }
  7925. oldValue, err := m.oldValue(ctx)
  7926. if err != nil {
  7927. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  7928. }
  7929. return oldValue.Fromwxid, nil
  7930. }
  7931. // ClearFromwxid clears the value of the "fromwxid" field.
  7932. func (m *MsgMutation) ClearFromwxid() {
  7933. m.fromwxid = nil
  7934. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  7935. }
  7936. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  7937. func (m *MsgMutation) FromwxidCleared() bool {
  7938. _, ok := m.clearedFields[msg.FieldFromwxid]
  7939. return ok
  7940. }
  7941. // ResetFromwxid resets all changes to the "fromwxid" field.
  7942. func (m *MsgMutation) ResetFromwxid() {
  7943. m.fromwxid = nil
  7944. delete(m.clearedFields, msg.FieldFromwxid)
  7945. }
  7946. // SetToid sets the "toid" field.
  7947. func (m *MsgMutation) SetToid(s string) {
  7948. m.toid = &s
  7949. }
  7950. // Toid returns the value of the "toid" field in the mutation.
  7951. func (m *MsgMutation) Toid() (r string, exists bool) {
  7952. v := m.toid
  7953. if v == nil {
  7954. return
  7955. }
  7956. return *v, true
  7957. }
  7958. // OldToid returns the old "toid" field's value of the Msg entity.
  7959. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7960. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7961. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  7962. if !m.op.Is(OpUpdateOne) {
  7963. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  7964. }
  7965. if m.id == nil || m.oldValue == nil {
  7966. return v, errors.New("OldToid requires an ID field in the mutation")
  7967. }
  7968. oldValue, err := m.oldValue(ctx)
  7969. if err != nil {
  7970. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  7971. }
  7972. return oldValue.Toid, nil
  7973. }
  7974. // ClearToid clears the value of the "toid" field.
  7975. func (m *MsgMutation) ClearToid() {
  7976. m.toid = nil
  7977. m.clearedFields[msg.FieldToid] = struct{}{}
  7978. }
  7979. // ToidCleared returns if the "toid" field was cleared in this mutation.
  7980. func (m *MsgMutation) ToidCleared() bool {
  7981. _, ok := m.clearedFields[msg.FieldToid]
  7982. return ok
  7983. }
  7984. // ResetToid resets all changes to the "toid" field.
  7985. func (m *MsgMutation) ResetToid() {
  7986. m.toid = nil
  7987. delete(m.clearedFields, msg.FieldToid)
  7988. }
  7989. // SetMsgtype sets the "msgtype" field.
  7990. func (m *MsgMutation) SetMsgtype(i int32) {
  7991. m.msgtype = &i
  7992. m.addmsgtype = nil
  7993. }
  7994. // Msgtype returns the value of the "msgtype" field in the mutation.
  7995. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  7996. v := m.msgtype
  7997. if v == nil {
  7998. return
  7999. }
  8000. return *v, true
  8001. }
  8002. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  8003. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  8004. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8005. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  8006. if !m.op.Is(OpUpdateOne) {
  8007. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  8008. }
  8009. if m.id == nil || m.oldValue == nil {
  8010. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  8011. }
  8012. oldValue, err := m.oldValue(ctx)
  8013. if err != nil {
  8014. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  8015. }
  8016. return oldValue.Msgtype, nil
  8017. }
  8018. // AddMsgtype adds i to the "msgtype" field.
  8019. func (m *MsgMutation) AddMsgtype(i int32) {
  8020. if m.addmsgtype != nil {
  8021. *m.addmsgtype += i
  8022. } else {
  8023. m.addmsgtype = &i
  8024. }
  8025. }
  8026. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  8027. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  8028. v := m.addmsgtype
  8029. if v == nil {
  8030. return
  8031. }
  8032. return *v, true
  8033. }
  8034. // ClearMsgtype clears the value of the "msgtype" field.
  8035. func (m *MsgMutation) ClearMsgtype() {
  8036. m.msgtype = nil
  8037. m.addmsgtype = nil
  8038. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  8039. }
  8040. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  8041. func (m *MsgMutation) MsgtypeCleared() bool {
  8042. _, ok := m.clearedFields[msg.FieldMsgtype]
  8043. return ok
  8044. }
  8045. // ResetMsgtype resets all changes to the "msgtype" field.
  8046. func (m *MsgMutation) ResetMsgtype() {
  8047. m.msgtype = nil
  8048. m.addmsgtype = nil
  8049. delete(m.clearedFields, msg.FieldMsgtype)
  8050. }
  8051. // SetMsg sets the "msg" field.
  8052. func (m *MsgMutation) SetMsg(s string) {
  8053. m.msg = &s
  8054. }
  8055. // Msg returns the value of the "msg" field in the mutation.
  8056. func (m *MsgMutation) Msg() (r string, exists bool) {
  8057. v := m.msg
  8058. if v == nil {
  8059. return
  8060. }
  8061. return *v, true
  8062. }
  8063. // OldMsg returns the old "msg" field's value of the Msg entity.
  8064. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  8065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8066. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  8067. if !m.op.Is(OpUpdateOne) {
  8068. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  8069. }
  8070. if m.id == nil || m.oldValue == nil {
  8071. return v, errors.New("OldMsg requires an ID field in the mutation")
  8072. }
  8073. oldValue, err := m.oldValue(ctx)
  8074. if err != nil {
  8075. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  8076. }
  8077. return oldValue.Msg, nil
  8078. }
  8079. // ClearMsg clears the value of the "msg" field.
  8080. func (m *MsgMutation) ClearMsg() {
  8081. m.msg = nil
  8082. m.clearedFields[msg.FieldMsg] = struct{}{}
  8083. }
  8084. // MsgCleared returns if the "msg" field was cleared in this mutation.
  8085. func (m *MsgMutation) MsgCleared() bool {
  8086. _, ok := m.clearedFields[msg.FieldMsg]
  8087. return ok
  8088. }
  8089. // ResetMsg resets all changes to the "msg" field.
  8090. func (m *MsgMutation) ResetMsg() {
  8091. m.msg = nil
  8092. delete(m.clearedFields, msg.FieldMsg)
  8093. }
  8094. // SetBatchNo sets the "batch_no" field.
  8095. func (m *MsgMutation) SetBatchNo(s string) {
  8096. m.batch_no = &s
  8097. }
  8098. // BatchNo returns the value of the "batch_no" field in the mutation.
  8099. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  8100. v := m.batch_no
  8101. if v == nil {
  8102. return
  8103. }
  8104. return *v, true
  8105. }
  8106. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  8107. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  8108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8109. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  8110. if !m.op.Is(OpUpdateOne) {
  8111. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  8112. }
  8113. if m.id == nil || m.oldValue == nil {
  8114. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  8115. }
  8116. oldValue, err := m.oldValue(ctx)
  8117. if err != nil {
  8118. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  8119. }
  8120. return oldValue.BatchNo, nil
  8121. }
  8122. // ClearBatchNo clears the value of the "batch_no" field.
  8123. func (m *MsgMutation) ClearBatchNo() {
  8124. m.batch_no = nil
  8125. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  8126. }
  8127. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  8128. func (m *MsgMutation) BatchNoCleared() bool {
  8129. _, ok := m.clearedFields[msg.FieldBatchNo]
  8130. return ok
  8131. }
  8132. // ResetBatchNo resets all changes to the "batch_no" field.
  8133. func (m *MsgMutation) ResetBatchNo() {
  8134. m.batch_no = nil
  8135. delete(m.clearedFields, msg.FieldBatchNo)
  8136. }
  8137. // Where appends a list predicates to the MsgMutation builder.
  8138. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  8139. m.predicates = append(m.predicates, ps...)
  8140. }
  8141. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  8142. // users can use type-assertion to append predicates that do not depend on any generated package.
  8143. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  8144. p := make([]predicate.Msg, len(ps))
  8145. for i := range ps {
  8146. p[i] = ps[i]
  8147. }
  8148. m.Where(p...)
  8149. }
  8150. // Op returns the operation name.
  8151. func (m *MsgMutation) Op() Op {
  8152. return m.op
  8153. }
  8154. // SetOp allows setting the mutation operation.
  8155. func (m *MsgMutation) SetOp(op Op) {
  8156. m.op = op
  8157. }
  8158. // Type returns the node type of this mutation (Msg).
  8159. func (m *MsgMutation) Type() string {
  8160. return m.typ
  8161. }
  8162. // Fields returns all fields that were changed during this mutation. Note that in
  8163. // order to get all numeric fields that were incremented/decremented, call
  8164. // AddedFields().
  8165. func (m *MsgMutation) Fields() []string {
  8166. fields := make([]string, 0, 9)
  8167. if m.created_at != nil {
  8168. fields = append(fields, msg.FieldCreatedAt)
  8169. }
  8170. if m.updated_at != nil {
  8171. fields = append(fields, msg.FieldUpdatedAt)
  8172. }
  8173. if m.deleted_at != nil {
  8174. fields = append(fields, msg.FieldDeletedAt)
  8175. }
  8176. if m.status != nil {
  8177. fields = append(fields, msg.FieldStatus)
  8178. }
  8179. if m.fromwxid != nil {
  8180. fields = append(fields, msg.FieldFromwxid)
  8181. }
  8182. if m.toid != nil {
  8183. fields = append(fields, msg.FieldToid)
  8184. }
  8185. if m.msgtype != nil {
  8186. fields = append(fields, msg.FieldMsgtype)
  8187. }
  8188. if m.msg != nil {
  8189. fields = append(fields, msg.FieldMsg)
  8190. }
  8191. if m.batch_no != nil {
  8192. fields = append(fields, msg.FieldBatchNo)
  8193. }
  8194. return fields
  8195. }
  8196. // Field returns the value of a field with the given name. The second boolean
  8197. // return value indicates that this field was not set, or was not defined in the
  8198. // schema.
  8199. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  8200. switch name {
  8201. case msg.FieldCreatedAt:
  8202. return m.CreatedAt()
  8203. case msg.FieldUpdatedAt:
  8204. return m.UpdatedAt()
  8205. case msg.FieldDeletedAt:
  8206. return m.DeletedAt()
  8207. case msg.FieldStatus:
  8208. return m.Status()
  8209. case msg.FieldFromwxid:
  8210. return m.Fromwxid()
  8211. case msg.FieldToid:
  8212. return m.Toid()
  8213. case msg.FieldMsgtype:
  8214. return m.Msgtype()
  8215. case msg.FieldMsg:
  8216. return m.Msg()
  8217. case msg.FieldBatchNo:
  8218. return m.BatchNo()
  8219. }
  8220. return nil, false
  8221. }
  8222. // OldField returns the old value of the field from the database. An error is
  8223. // returned if the mutation operation is not UpdateOne, or the query to the
  8224. // database failed.
  8225. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8226. switch name {
  8227. case msg.FieldCreatedAt:
  8228. return m.OldCreatedAt(ctx)
  8229. case msg.FieldUpdatedAt:
  8230. return m.OldUpdatedAt(ctx)
  8231. case msg.FieldDeletedAt:
  8232. return m.OldDeletedAt(ctx)
  8233. case msg.FieldStatus:
  8234. return m.OldStatus(ctx)
  8235. case msg.FieldFromwxid:
  8236. return m.OldFromwxid(ctx)
  8237. case msg.FieldToid:
  8238. return m.OldToid(ctx)
  8239. case msg.FieldMsgtype:
  8240. return m.OldMsgtype(ctx)
  8241. case msg.FieldMsg:
  8242. return m.OldMsg(ctx)
  8243. case msg.FieldBatchNo:
  8244. return m.OldBatchNo(ctx)
  8245. }
  8246. return nil, fmt.Errorf("unknown Msg field %s", name)
  8247. }
  8248. // SetField sets the value of a field with the given name. It returns an error if
  8249. // the field is not defined in the schema, or if the type mismatched the field
  8250. // type.
  8251. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  8252. switch name {
  8253. case msg.FieldCreatedAt:
  8254. v, ok := value.(time.Time)
  8255. if !ok {
  8256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8257. }
  8258. m.SetCreatedAt(v)
  8259. return nil
  8260. case msg.FieldUpdatedAt:
  8261. v, ok := value.(time.Time)
  8262. if !ok {
  8263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8264. }
  8265. m.SetUpdatedAt(v)
  8266. return nil
  8267. case msg.FieldDeletedAt:
  8268. v, ok := value.(time.Time)
  8269. if !ok {
  8270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8271. }
  8272. m.SetDeletedAt(v)
  8273. return nil
  8274. case msg.FieldStatus:
  8275. v, ok := value.(uint8)
  8276. if !ok {
  8277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8278. }
  8279. m.SetStatus(v)
  8280. return nil
  8281. case msg.FieldFromwxid:
  8282. v, ok := value.(string)
  8283. if !ok {
  8284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8285. }
  8286. m.SetFromwxid(v)
  8287. return nil
  8288. case msg.FieldToid:
  8289. v, ok := value.(string)
  8290. if !ok {
  8291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8292. }
  8293. m.SetToid(v)
  8294. return nil
  8295. case msg.FieldMsgtype:
  8296. v, ok := value.(int32)
  8297. if !ok {
  8298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8299. }
  8300. m.SetMsgtype(v)
  8301. return nil
  8302. case msg.FieldMsg:
  8303. v, ok := value.(string)
  8304. if !ok {
  8305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8306. }
  8307. m.SetMsg(v)
  8308. return nil
  8309. case msg.FieldBatchNo:
  8310. v, ok := value.(string)
  8311. if !ok {
  8312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8313. }
  8314. m.SetBatchNo(v)
  8315. return nil
  8316. }
  8317. return fmt.Errorf("unknown Msg field %s", name)
  8318. }
  8319. // AddedFields returns all numeric fields that were incremented/decremented during
  8320. // this mutation.
  8321. func (m *MsgMutation) AddedFields() []string {
  8322. var fields []string
  8323. if m.addstatus != nil {
  8324. fields = append(fields, msg.FieldStatus)
  8325. }
  8326. if m.addmsgtype != nil {
  8327. fields = append(fields, msg.FieldMsgtype)
  8328. }
  8329. return fields
  8330. }
  8331. // AddedField returns the numeric value that was incremented/decremented on a field
  8332. // with the given name. The second boolean return value indicates that this field
  8333. // was not set, or was not defined in the schema.
  8334. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  8335. switch name {
  8336. case msg.FieldStatus:
  8337. return m.AddedStatus()
  8338. case msg.FieldMsgtype:
  8339. return m.AddedMsgtype()
  8340. }
  8341. return nil, false
  8342. }
  8343. // AddField adds the value to the field with the given name. It returns an error if
  8344. // the field is not defined in the schema, or if the type mismatched the field
  8345. // type.
  8346. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  8347. switch name {
  8348. case msg.FieldStatus:
  8349. v, ok := value.(int8)
  8350. if !ok {
  8351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8352. }
  8353. m.AddStatus(v)
  8354. return nil
  8355. case msg.FieldMsgtype:
  8356. v, ok := value.(int32)
  8357. if !ok {
  8358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8359. }
  8360. m.AddMsgtype(v)
  8361. return nil
  8362. }
  8363. return fmt.Errorf("unknown Msg numeric field %s", name)
  8364. }
  8365. // ClearedFields returns all nullable fields that were cleared during this
  8366. // mutation.
  8367. func (m *MsgMutation) ClearedFields() []string {
  8368. var fields []string
  8369. if m.FieldCleared(msg.FieldDeletedAt) {
  8370. fields = append(fields, msg.FieldDeletedAt)
  8371. }
  8372. if m.FieldCleared(msg.FieldStatus) {
  8373. fields = append(fields, msg.FieldStatus)
  8374. }
  8375. if m.FieldCleared(msg.FieldFromwxid) {
  8376. fields = append(fields, msg.FieldFromwxid)
  8377. }
  8378. if m.FieldCleared(msg.FieldToid) {
  8379. fields = append(fields, msg.FieldToid)
  8380. }
  8381. if m.FieldCleared(msg.FieldMsgtype) {
  8382. fields = append(fields, msg.FieldMsgtype)
  8383. }
  8384. if m.FieldCleared(msg.FieldMsg) {
  8385. fields = append(fields, msg.FieldMsg)
  8386. }
  8387. if m.FieldCleared(msg.FieldBatchNo) {
  8388. fields = append(fields, msg.FieldBatchNo)
  8389. }
  8390. return fields
  8391. }
  8392. // FieldCleared returns a boolean indicating if a field with the given name was
  8393. // cleared in this mutation.
  8394. func (m *MsgMutation) FieldCleared(name string) bool {
  8395. _, ok := m.clearedFields[name]
  8396. return ok
  8397. }
  8398. // ClearField clears the value of the field with the given name. It returns an
  8399. // error if the field is not defined in the schema.
  8400. func (m *MsgMutation) ClearField(name string) error {
  8401. switch name {
  8402. case msg.FieldDeletedAt:
  8403. m.ClearDeletedAt()
  8404. return nil
  8405. case msg.FieldStatus:
  8406. m.ClearStatus()
  8407. return nil
  8408. case msg.FieldFromwxid:
  8409. m.ClearFromwxid()
  8410. return nil
  8411. case msg.FieldToid:
  8412. m.ClearToid()
  8413. return nil
  8414. case msg.FieldMsgtype:
  8415. m.ClearMsgtype()
  8416. return nil
  8417. case msg.FieldMsg:
  8418. m.ClearMsg()
  8419. return nil
  8420. case msg.FieldBatchNo:
  8421. m.ClearBatchNo()
  8422. return nil
  8423. }
  8424. return fmt.Errorf("unknown Msg nullable field %s", name)
  8425. }
  8426. // ResetField resets all changes in the mutation for the field with the given name.
  8427. // It returns an error if the field is not defined in the schema.
  8428. func (m *MsgMutation) ResetField(name string) error {
  8429. switch name {
  8430. case msg.FieldCreatedAt:
  8431. m.ResetCreatedAt()
  8432. return nil
  8433. case msg.FieldUpdatedAt:
  8434. m.ResetUpdatedAt()
  8435. return nil
  8436. case msg.FieldDeletedAt:
  8437. m.ResetDeletedAt()
  8438. return nil
  8439. case msg.FieldStatus:
  8440. m.ResetStatus()
  8441. return nil
  8442. case msg.FieldFromwxid:
  8443. m.ResetFromwxid()
  8444. return nil
  8445. case msg.FieldToid:
  8446. m.ResetToid()
  8447. return nil
  8448. case msg.FieldMsgtype:
  8449. m.ResetMsgtype()
  8450. return nil
  8451. case msg.FieldMsg:
  8452. m.ResetMsg()
  8453. return nil
  8454. case msg.FieldBatchNo:
  8455. m.ResetBatchNo()
  8456. return nil
  8457. }
  8458. return fmt.Errorf("unknown Msg field %s", name)
  8459. }
  8460. // AddedEdges returns all edge names that were set/added in this mutation.
  8461. func (m *MsgMutation) AddedEdges() []string {
  8462. edges := make([]string, 0, 0)
  8463. return edges
  8464. }
  8465. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8466. // name in this mutation.
  8467. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  8468. return nil
  8469. }
  8470. // RemovedEdges returns all edge names that were removed in this mutation.
  8471. func (m *MsgMutation) RemovedEdges() []string {
  8472. edges := make([]string, 0, 0)
  8473. return edges
  8474. }
  8475. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8476. // the given name in this mutation.
  8477. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  8478. return nil
  8479. }
  8480. // ClearedEdges returns all edge names that were cleared in this mutation.
  8481. func (m *MsgMutation) ClearedEdges() []string {
  8482. edges := make([]string, 0, 0)
  8483. return edges
  8484. }
  8485. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8486. // was cleared in this mutation.
  8487. func (m *MsgMutation) EdgeCleared(name string) bool {
  8488. return false
  8489. }
  8490. // ClearEdge clears the value of the edge with the given name. It returns an error
  8491. // if that edge is not defined in the schema.
  8492. func (m *MsgMutation) ClearEdge(name string) error {
  8493. return fmt.Errorf("unknown Msg unique edge %s", name)
  8494. }
  8495. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8496. // It returns an error if the edge is not defined in the schema.
  8497. func (m *MsgMutation) ResetEdge(name string) error {
  8498. return fmt.Errorf("unknown Msg edge %s", name)
  8499. }
  8500. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  8501. type ServerMutation struct {
  8502. config
  8503. op Op
  8504. typ string
  8505. id *uint64
  8506. created_at *time.Time
  8507. updated_at *time.Time
  8508. status *uint8
  8509. addstatus *int8
  8510. deleted_at *time.Time
  8511. name *string
  8512. public_ip *string
  8513. private_ip *string
  8514. admin_port *string
  8515. clearedFields map[string]struct{}
  8516. wxs map[uint64]struct{}
  8517. removedwxs map[uint64]struct{}
  8518. clearedwxs bool
  8519. done bool
  8520. oldValue func(context.Context) (*Server, error)
  8521. predicates []predicate.Server
  8522. }
  8523. var _ ent.Mutation = (*ServerMutation)(nil)
  8524. // serverOption allows management of the mutation configuration using functional options.
  8525. type serverOption func(*ServerMutation)
  8526. // newServerMutation creates new mutation for the Server entity.
  8527. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  8528. m := &ServerMutation{
  8529. config: c,
  8530. op: op,
  8531. typ: TypeServer,
  8532. clearedFields: make(map[string]struct{}),
  8533. }
  8534. for _, opt := range opts {
  8535. opt(m)
  8536. }
  8537. return m
  8538. }
  8539. // withServerID sets the ID field of the mutation.
  8540. func withServerID(id uint64) serverOption {
  8541. return func(m *ServerMutation) {
  8542. var (
  8543. err error
  8544. once sync.Once
  8545. value *Server
  8546. )
  8547. m.oldValue = func(ctx context.Context) (*Server, error) {
  8548. once.Do(func() {
  8549. if m.done {
  8550. err = errors.New("querying old values post mutation is not allowed")
  8551. } else {
  8552. value, err = m.Client().Server.Get(ctx, id)
  8553. }
  8554. })
  8555. return value, err
  8556. }
  8557. m.id = &id
  8558. }
  8559. }
  8560. // withServer sets the old Server of the mutation.
  8561. func withServer(node *Server) serverOption {
  8562. return func(m *ServerMutation) {
  8563. m.oldValue = func(context.Context) (*Server, error) {
  8564. return node, nil
  8565. }
  8566. m.id = &node.ID
  8567. }
  8568. }
  8569. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8570. // executed in a transaction (ent.Tx), a transactional client is returned.
  8571. func (m ServerMutation) Client() *Client {
  8572. client := &Client{config: m.config}
  8573. client.init()
  8574. return client
  8575. }
  8576. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8577. // it returns an error otherwise.
  8578. func (m ServerMutation) Tx() (*Tx, error) {
  8579. if _, ok := m.driver.(*txDriver); !ok {
  8580. return nil, errors.New("ent: mutation is not running in a transaction")
  8581. }
  8582. tx := &Tx{config: m.config}
  8583. tx.init()
  8584. return tx, nil
  8585. }
  8586. // SetID sets the value of the id field. Note that this
  8587. // operation is only accepted on creation of Server entities.
  8588. func (m *ServerMutation) SetID(id uint64) {
  8589. m.id = &id
  8590. }
  8591. // ID returns the ID value in the mutation. Note that the ID is only available
  8592. // if it was provided to the builder or after it was returned from the database.
  8593. func (m *ServerMutation) ID() (id uint64, exists bool) {
  8594. if m.id == nil {
  8595. return
  8596. }
  8597. return *m.id, true
  8598. }
  8599. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8600. // That means, if the mutation is applied within a transaction with an isolation level such
  8601. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8602. // or updated by the mutation.
  8603. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  8604. switch {
  8605. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8606. id, exists := m.ID()
  8607. if exists {
  8608. return []uint64{id}, nil
  8609. }
  8610. fallthrough
  8611. case m.op.Is(OpUpdate | OpDelete):
  8612. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  8613. default:
  8614. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8615. }
  8616. }
  8617. // SetCreatedAt sets the "created_at" field.
  8618. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  8619. m.created_at = &t
  8620. }
  8621. // CreatedAt returns the value of the "created_at" field in the mutation.
  8622. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  8623. v := m.created_at
  8624. if v == nil {
  8625. return
  8626. }
  8627. return *v, true
  8628. }
  8629. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  8630. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8632. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8633. if !m.op.Is(OpUpdateOne) {
  8634. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8635. }
  8636. if m.id == nil || m.oldValue == nil {
  8637. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8638. }
  8639. oldValue, err := m.oldValue(ctx)
  8640. if err != nil {
  8641. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8642. }
  8643. return oldValue.CreatedAt, nil
  8644. }
  8645. // ResetCreatedAt resets all changes to the "created_at" field.
  8646. func (m *ServerMutation) ResetCreatedAt() {
  8647. m.created_at = nil
  8648. }
  8649. // SetUpdatedAt sets the "updated_at" field.
  8650. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  8651. m.updated_at = &t
  8652. }
  8653. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8654. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  8655. v := m.updated_at
  8656. if v == nil {
  8657. return
  8658. }
  8659. return *v, true
  8660. }
  8661. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  8662. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8664. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8665. if !m.op.Is(OpUpdateOne) {
  8666. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8667. }
  8668. if m.id == nil || m.oldValue == nil {
  8669. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8670. }
  8671. oldValue, err := m.oldValue(ctx)
  8672. if err != nil {
  8673. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8674. }
  8675. return oldValue.UpdatedAt, nil
  8676. }
  8677. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8678. func (m *ServerMutation) ResetUpdatedAt() {
  8679. m.updated_at = nil
  8680. }
  8681. // SetStatus sets the "status" field.
  8682. func (m *ServerMutation) SetStatus(u uint8) {
  8683. m.status = &u
  8684. m.addstatus = nil
  8685. }
  8686. // Status returns the value of the "status" field in the mutation.
  8687. func (m *ServerMutation) Status() (r uint8, exists bool) {
  8688. v := m.status
  8689. if v == nil {
  8690. return
  8691. }
  8692. return *v, true
  8693. }
  8694. // OldStatus returns the old "status" field's value of the Server entity.
  8695. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8697. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  8698. if !m.op.Is(OpUpdateOne) {
  8699. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  8700. }
  8701. if m.id == nil || m.oldValue == nil {
  8702. return v, errors.New("OldStatus requires an ID field in the mutation")
  8703. }
  8704. oldValue, err := m.oldValue(ctx)
  8705. if err != nil {
  8706. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  8707. }
  8708. return oldValue.Status, nil
  8709. }
  8710. // AddStatus adds u to the "status" field.
  8711. func (m *ServerMutation) AddStatus(u int8) {
  8712. if m.addstatus != nil {
  8713. *m.addstatus += u
  8714. } else {
  8715. m.addstatus = &u
  8716. }
  8717. }
  8718. // AddedStatus returns the value that was added to the "status" field in this mutation.
  8719. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  8720. v := m.addstatus
  8721. if v == nil {
  8722. return
  8723. }
  8724. return *v, true
  8725. }
  8726. // ClearStatus clears the value of the "status" field.
  8727. func (m *ServerMutation) ClearStatus() {
  8728. m.status = nil
  8729. m.addstatus = nil
  8730. m.clearedFields[server.FieldStatus] = struct{}{}
  8731. }
  8732. // StatusCleared returns if the "status" field was cleared in this mutation.
  8733. func (m *ServerMutation) StatusCleared() bool {
  8734. _, ok := m.clearedFields[server.FieldStatus]
  8735. return ok
  8736. }
  8737. // ResetStatus resets all changes to the "status" field.
  8738. func (m *ServerMutation) ResetStatus() {
  8739. m.status = nil
  8740. m.addstatus = nil
  8741. delete(m.clearedFields, server.FieldStatus)
  8742. }
  8743. // SetDeletedAt sets the "deleted_at" field.
  8744. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  8745. m.deleted_at = &t
  8746. }
  8747. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8748. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  8749. v := m.deleted_at
  8750. if v == nil {
  8751. return
  8752. }
  8753. return *v, true
  8754. }
  8755. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  8756. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8758. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8759. if !m.op.Is(OpUpdateOne) {
  8760. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8761. }
  8762. if m.id == nil || m.oldValue == nil {
  8763. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8764. }
  8765. oldValue, err := m.oldValue(ctx)
  8766. if err != nil {
  8767. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8768. }
  8769. return oldValue.DeletedAt, nil
  8770. }
  8771. // ClearDeletedAt clears the value of the "deleted_at" field.
  8772. func (m *ServerMutation) ClearDeletedAt() {
  8773. m.deleted_at = nil
  8774. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  8775. }
  8776. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8777. func (m *ServerMutation) DeletedAtCleared() bool {
  8778. _, ok := m.clearedFields[server.FieldDeletedAt]
  8779. return ok
  8780. }
  8781. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8782. func (m *ServerMutation) ResetDeletedAt() {
  8783. m.deleted_at = nil
  8784. delete(m.clearedFields, server.FieldDeletedAt)
  8785. }
  8786. // SetName sets the "name" field.
  8787. func (m *ServerMutation) SetName(s string) {
  8788. m.name = &s
  8789. }
  8790. // Name returns the value of the "name" field in the mutation.
  8791. func (m *ServerMutation) Name() (r string, exists bool) {
  8792. v := m.name
  8793. if v == nil {
  8794. return
  8795. }
  8796. return *v, true
  8797. }
  8798. // OldName returns the old "name" field's value of the Server entity.
  8799. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8801. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  8802. if !m.op.Is(OpUpdateOne) {
  8803. return v, errors.New("OldName is only allowed on UpdateOne operations")
  8804. }
  8805. if m.id == nil || m.oldValue == nil {
  8806. return v, errors.New("OldName requires an ID field in the mutation")
  8807. }
  8808. oldValue, err := m.oldValue(ctx)
  8809. if err != nil {
  8810. return v, fmt.Errorf("querying old value for OldName: %w", err)
  8811. }
  8812. return oldValue.Name, nil
  8813. }
  8814. // ResetName resets all changes to the "name" field.
  8815. func (m *ServerMutation) ResetName() {
  8816. m.name = nil
  8817. }
  8818. // SetPublicIP sets the "public_ip" field.
  8819. func (m *ServerMutation) SetPublicIP(s string) {
  8820. m.public_ip = &s
  8821. }
  8822. // PublicIP returns the value of the "public_ip" field in the mutation.
  8823. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  8824. v := m.public_ip
  8825. if v == nil {
  8826. return
  8827. }
  8828. return *v, true
  8829. }
  8830. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  8831. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8833. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  8834. if !m.op.Is(OpUpdateOne) {
  8835. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  8836. }
  8837. if m.id == nil || m.oldValue == nil {
  8838. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  8839. }
  8840. oldValue, err := m.oldValue(ctx)
  8841. if err != nil {
  8842. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  8843. }
  8844. return oldValue.PublicIP, nil
  8845. }
  8846. // ResetPublicIP resets all changes to the "public_ip" field.
  8847. func (m *ServerMutation) ResetPublicIP() {
  8848. m.public_ip = nil
  8849. }
  8850. // SetPrivateIP sets the "private_ip" field.
  8851. func (m *ServerMutation) SetPrivateIP(s string) {
  8852. m.private_ip = &s
  8853. }
  8854. // PrivateIP returns the value of the "private_ip" field in the mutation.
  8855. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  8856. v := m.private_ip
  8857. if v == nil {
  8858. return
  8859. }
  8860. return *v, true
  8861. }
  8862. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  8863. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8865. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  8866. if !m.op.Is(OpUpdateOne) {
  8867. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  8868. }
  8869. if m.id == nil || m.oldValue == nil {
  8870. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  8871. }
  8872. oldValue, err := m.oldValue(ctx)
  8873. if err != nil {
  8874. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  8875. }
  8876. return oldValue.PrivateIP, nil
  8877. }
  8878. // ResetPrivateIP resets all changes to the "private_ip" field.
  8879. func (m *ServerMutation) ResetPrivateIP() {
  8880. m.private_ip = nil
  8881. }
  8882. // SetAdminPort sets the "admin_port" field.
  8883. func (m *ServerMutation) SetAdminPort(s string) {
  8884. m.admin_port = &s
  8885. }
  8886. // AdminPort returns the value of the "admin_port" field in the mutation.
  8887. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  8888. v := m.admin_port
  8889. if v == nil {
  8890. return
  8891. }
  8892. return *v, true
  8893. }
  8894. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  8895. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8897. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  8898. if !m.op.Is(OpUpdateOne) {
  8899. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  8900. }
  8901. if m.id == nil || m.oldValue == nil {
  8902. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  8903. }
  8904. oldValue, err := m.oldValue(ctx)
  8905. if err != nil {
  8906. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  8907. }
  8908. return oldValue.AdminPort, nil
  8909. }
  8910. // ResetAdminPort resets all changes to the "admin_port" field.
  8911. func (m *ServerMutation) ResetAdminPort() {
  8912. m.admin_port = nil
  8913. }
  8914. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  8915. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  8916. if m.wxs == nil {
  8917. m.wxs = make(map[uint64]struct{})
  8918. }
  8919. for i := range ids {
  8920. m.wxs[ids[i]] = struct{}{}
  8921. }
  8922. }
  8923. // ClearWxs clears the "wxs" edge to the Wx entity.
  8924. func (m *ServerMutation) ClearWxs() {
  8925. m.clearedwxs = true
  8926. }
  8927. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  8928. func (m *ServerMutation) WxsCleared() bool {
  8929. return m.clearedwxs
  8930. }
  8931. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  8932. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  8933. if m.removedwxs == nil {
  8934. m.removedwxs = make(map[uint64]struct{})
  8935. }
  8936. for i := range ids {
  8937. delete(m.wxs, ids[i])
  8938. m.removedwxs[ids[i]] = struct{}{}
  8939. }
  8940. }
  8941. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  8942. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  8943. for id := range m.removedwxs {
  8944. ids = append(ids, id)
  8945. }
  8946. return
  8947. }
  8948. // WxsIDs returns the "wxs" edge IDs in the mutation.
  8949. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  8950. for id := range m.wxs {
  8951. ids = append(ids, id)
  8952. }
  8953. return
  8954. }
  8955. // ResetWxs resets all changes to the "wxs" edge.
  8956. func (m *ServerMutation) ResetWxs() {
  8957. m.wxs = nil
  8958. m.clearedwxs = false
  8959. m.removedwxs = nil
  8960. }
  8961. // Where appends a list predicates to the ServerMutation builder.
  8962. func (m *ServerMutation) Where(ps ...predicate.Server) {
  8963. m.predicates = append(m.predicates, ps...)
  8964. }
  8965. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  8966. // users can use type-assertion to append predicates that do not depend on any generated package.
  8967. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  8968. p := make([]predicate.Server, len(ps))
  8969. for i := range ps {
  8970. p[i] = ps[i]
  8971. }
  8972. m.Where(p...)
  8973. }
  8974. // Op returns the operation name.
  8975. func (m *ServerMutation) Op() Op {
  8976. return m.op
  8977. }
  8978. // SetOp allows setting the mutation operation.
  8979. func (m *ServerMutation) SetOp(op Op) {
  8980. m.op = op
  8981. }
  8982. // Type returns the node type of this mutation (Server).
  8983. func (m *ServerMutation) Type() string {
  8984. return m.typ
  8985. }
  8986. // Fields returns all fields that were changed during this mutation. Note that in
  8987. // order to get all numeric fields that were incremented/decremented, call
  8988. // AddedFields().
  8989. func (m *ServerMutation) Fields() []string {
  8990. fields := make([]string, 0, 8)
  8991. if m.created_at != nil {
  8992. fields = append(fields, server.FieldCreatedAt)
  8993. }
  8994. if m.updated_at != nil {
  8995. fields = append(fields, server.FieldUpdatedAt)
  8996. }
  8997. if m.status != nil {
  8998. fields = append(fields, server.FieldStatus)
  8999. }
  9000. if m.deleted_at != nil {
  9001. fields = append(fields, server.FieldDeletedAt)
  9002. }
  9003. if m.name != nil {
  9004. fields = append(fields, server.FieldName)
  9005. }
  9006. if m.public_ip != nil {
  9007. fields = append(fields, server.FieldPublicIP)
  9008. }
  9009. if m.private_ip != nil {
  9010. fields = append(fields, server.FieldPrivateIP)
  9011. }
  9012. if m.admin_port != nil {
  9013. fields = append(fields, server.FieldAdminPort)
  9014. }
  9015. return fields
  9016. }
  9017. // Field returns the value of a field with the given name. The second boolean
  9018. // return value indicates that this field was not set, or was not defined in the
  9019. // schema.
  9020. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  9021. switch name {
  9022. case server.FieldCreatedAt:
  9023. return m.CreatedAt()
  9024. case server.FieldUpdatedAt:
  9025. return m.UpdatedAt()
  9026. case server.FieldStatus:
  9027. return m.Status()
  9028. case server.FieldDeletedAt:
  9029. return m.DeletedAt()
  9030. case server.FieldName:
  9031. return m.Name()
  9032. case server.FieldPublicIP:
  9033. return m.PublicIP()
  9034. case server.FieldPrivateIP:
  9035. return m.PrivateIP()
  9036. case server.FieldAdminPort:
  9037. return m.AdminPort()
  9038. }
  9039. return nil, false
  9040. }
  9041. // OldField returns the old value of the field from the database. An error is
  9042. // returned if the mutation operation is not UpdateOne, or the query to the
  9043. // database failed.
  9044. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9045. switch name {
  9046. case server.FieldCreatedAt:
  9047. return m.OldCreatedAt(ctx)
  9048. case server.FieldUpdatedAt:
  9049. return m.OldUpdatedAt(ctx)
  9050. case server.FieldStatus:
  9051. return m.OldStatus(ctx)
  9052. case server.FieldDeletedAt:
  9053. return m.OldDeletedAt(ctx)
  9054. case server.FieldName:
  9055. return m.OldName(ctx)
  9056. case server.FieldPublicIP:
  9057. return m.OldPublicIP(ctx)
  9058. case server.FieldPrivateIP:
  9059. return m.OldPrivateIP(ctx)
  9060. case server.FieldAdminPort:
  9061. return m.OldAdminPort(ctx)
  9062. }
  9063. return nil, fmt.Errorf("unknown Server field %s", name)
  9064. }
  9065. // SetField sets the value of a field with the given name. It returns an error if
  9066. // the field is not defined in the schema, or if the type mismatched the field
  9067. // type.
  9068. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  9069. switch name {
  9070. case server.FieldCreatedAt:
  9071. v, ok := value.(time.Time)
  9072. if !ok {
  9073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9074. }
  9075. m.SetCreatedAt(v)
  9076. return nil
  9077. case server.FieldUpdatedAt:
  9078. v, ok := value.(time.Time)
  9079. if !ok {
  9080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9081. }
  9082. m.SetUpdatedAt(v)
  9083. return nil
  9084. case server.FieldStatus:
  9085. v, ok := value.(uint8)
  9086. if !ok {
  9087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9088. }
  9089. m.SetStatus(v)
  9090. return nil
  9091. case server.FieldDeletedAt:
  9092. v, ok := value.(time.Time)
  9093. if !ok {
  9094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9095. }
  9096. m.SetDeletedAt(v)
  9097. return nil
  9098. case server.FieldName:
  9099. v, ok := value.(string)
  9100. if !ok {
  9101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9102. }
  9103. m.SetName(v)
  9104. return nil
  9105. case server.FieldPublicIP:
  9106. v, ok := value.(string)
  9107. if !ok {
  9108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9109. }
  9110. m.SetPublicIP(v)
  9111. return nil
  9112. case server.FieldPrivateIP:
  9113. v, ok := value.(string)
  9114. if !ok {
  9115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9116. }
  9117. m.SetPrivateIP(v)
  9118. return nil
  9119. case server.FieldAdminPort:
  9120. v, ok := value.(string)
  9121. if !ok {
  9122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9123. }
  9124. m.SetAdminPort(v)
  9125. return nil
  9126. }
  9127. return fmt.Errorf("unknown Server field %s", name)
  9128. }
  9129. // AddedFields returns all numeric fields that were incremented/decremented during
  9130. // this mutation.
  9131. func (m *ServerMutation) AddedFields() []string {
  9132. var fields []string
  9133. if m.addstatus != nil {
  9134. fields = append(fields, server.FieldStatus)
  9135. }
  9136. return fields
  9137. }
  9138. // AddedField returns the numeric value that was incremented/decremented on a field
  9139. // with the given name. The second boolean return value indicates that this field
  9140. // was not set, or was not defined in the schema.
  9141. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  9142. switch name {
  9143. case server.FieldStatus:
  9144. return m.AddedStatus()
  9145. }
  9146. return nil, false
  9147. }
  9148. // AddField adds the value to the field with the given name. It returns an error if
  9149. // the field is not defined in the schema, or if the type mismatched the field
  9150. // type.
  9151. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  9152. switch name {
  9153. case server.FieldStatus:
  9154. v, ok := value.(int8)
  9155. if !ok {
  9156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9157. }
  9158. m.AddStatus(v)
  9159. return nil
  9160. }
  9161. return fmt.Errorf("unknown Server numeric field %s", name)
  9162. }
  9163. // ClearedFields returns all nullable fields that were cleared during this
  9164. // mutation.
  9165. func (m *ServerMutation) ClearedFields() []string {
  9166. var fields []string
  9167. if m.FieldCleared(server.FieldStatus) {
  9168. fields = append(fields, server.FieldStatus)
  9169. }
  9170. if m.FieldCleared(server.FieldDeletedAt) {
  9171. fields = append(fields, server.FieldDeletedAt)
  9172. }
  9173. return fields
  9174. }
  9175. // FieldCleared returns a boolean indicating if a field with the given name was
  9176. // cleared in this mutation.
  9177. func (m *ServerMutation) FieldCleared(name string) bool {
  9178. _, ok := m.clearedFields[name]
  9179. return ok
  9180. }
  9181. // ClearField clears the value of the field with the given name. It returns an
  9182. // error if the field is not defined in the schema.
  9183. func (m *ServerMutation) ClearField(name string) error {
  9184. switch name {
  9185. case server.FieldStatus:
  9186. m.ClearStatus()
  9187. return nil
  9188. case server.FieldDeletedAt:
  9189. m.ClearDeletedAt()
  9190. return nil
  9191. }
  9192. return fmt.Errorf("unknown Server nullable field %s", name)
  9193. }
  9194. // ResetField resets all changes in the mutation for the field with the given name.
  9195. // It returns an error if the field is not defined in the schema.
  9196. func (m *ServerMutation) ResetField(name string) error {
  9197. switch name {
  9198. case server.FieldCreatedAt:
  9199. m.ResetCreatedAt()
  9200. return nil
  9201. case server.FieldUpdatedAt:
  9202. m.ResetUpdatedAt()
  9203. return nil
  9204. case server.FieldStatus:
  9205. m.ResetStatus()
  9206. return nil
  9207. case server.FieldDeletedAt:
  9208. m.ResetDeletedAt()
  9209. return nil
  9210. case server.FieldName:
  9211. m.ResetName()
  9212. return nil
  9213. case server.FieldPublicIP:
  9214. m.ResetPublicIP()
  9215. return nil
  9216. case server.FieldPrivateIP:
  9217. m.ResetPrivateIP()
  9218. return nil
  9219. case server.FieldAdminPort:
  9220. m.ResetAdminPort()
  9221. return nil
  9222. }
  9223. return fmt.Errorf("unknown Server field %s", name)
  9224. }
  9225. // AddedEdges returns all edge names that were set/added in this mutation.
  9226. func (m *ServerMutation) AddedEdges() []string {
  9227. edges := make([]string, 0, 1)
  9228. if m.wxs != nil {
  9229. edges = append(edges, server.EdgeWxs)
  9230. }
  9231. return edges
  9232. }
  9233. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9234. // name in this mutation.
  9235. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  9236. switch name {
  9237. case server.EdgeWxs:
  9238. ids := make([]ent.Value, 0, len(m.wxs))
  9239. for id := range m.wxs {
  9240. ids = append(ids, id)
  9241. }
  9242. return ids
  9243. }
  9244. return nil
  9245. }
  9246. // RemovedEdges returns all edge names that were removed in this mutation.
  9247. func (m *ServerMutation) RemovedEdges() []string {
  9248. edges := make([]string, 0, 1)
  9249. if m.removedwxs != nil {
  9250. edges = append(edges, server.EdgeWxs)
  9251. }
  9252. return edges
  9253. }
  9254. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9255. // the given name in this mutation.
  9256. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  9257. switch name {
  9258. case server.EdgeWxs:
  9259. ids := make([]ent.Value, 0, len(m.removedwxs))
  9260. for id := range m.removedwxs {
  9261. ids = append(ids, id)
  9262. }
  9263. return ids
  9264. }
  9265. return nil
  9266. }
  9267. // ClearedEdges returns all edge names that were cleared in this mutation.
  9268. func (m *ServerMutation) ClearedEdges() []string {
  9269. edges := make([]string, 0, 1)
  9270. if m.clearedwxs {
  9271. edges = append(edges, server.EdgeWxs)
  9272. }
  9273. return edges
  9274. }
  9275. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9276. // was cleared in this mutation.
  9277. func (m *ServerMutation) EdgeCleared(name string) bool {
  9278. switch name {
  9279. case server.EdgeWxs:
  9280. return m.clearedwxs
  9281. }
  9282. return false
  9283. }
  9284. // ClearEdge clears the value of the edge with the given name. It returns an error
  9285. // if that edge is not defined in the schema.
  9286. func (m *ServerMutation) ClearEdge(name string) error {
  9287. switch name {
  9288. }
  9289. return fmt.Errorf("unknown Server unique edge %s", name)
  9290. }
  9291. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9292. // It returns an error if the edge is not defined in the schema.
  9293. func (m *ServerMutation) ResetEdge(name string) error {
  9294. switch name {
  9295. case server.EdgeWxs:
  9296. m.ResetWxs()
  9297. return nil
  9298. }
  9299. return fmt.Errorf("unknown Server edge %s", name)
  9300. }
  9301. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  9302. type SopNodeMutation struct {
  9303. config
  9304. op Op
  9305. typ string
  9306. id *uint64
  9307. created_at *time.Time
  9308. updated_at *time.Time
  9309. status *uint8
  9310. addstatus *int8
  9311. deleted_at *time.Time
  9312. parent_id *uint64
  9313. addparent_id *int64
  9314. name *string
  9315. condition_type *int
  9316. addcondition_type *int
  9317. condition_list *[]string
  9318. appendcondition_list []string
  9319. no_reply_condition *uint64
  9320. addno_reply_condition *int64
  9321. action_message *[]custom_types.Action
  9322. appendaction_message []custom_types.Action
  9323. action_label *[]uint64
  9324. appendaction_label []uint64
  9325. clearedFields map[string]struct{}
  9326. sop_stage *uint64
  9327. clearedsop_stage bool
  9328. node_messages map[uint64]struct{}
  9329. removednode_messages map[uint64]struct{}
  9330. clearednode_messages bool
  9331. done bool
  9332. oldValue func(context.Context) (*SopNode, error)
  9333. predicates []predicate.SopNode
  9334. }
  9335. var _ ent.Mutation = (*SopNodeMutation)(nil)
  9336. // sopnodeOption allows management of the mutation configuration using functional options.
  9337. type sopnodeOption func(*SopNodeMutation)
  9338. // newSopNodeMutation creates new mutation for the SopNode entity.
  9339. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  9340. m := &SopNodeMutation{
  9341. config: c,
  9342. op: op,
  9343. typ: TypeSopNode,
  9344. clearedFields: make(map[string]struct{}),
  9345. }
  9346. for _, opt := range opts {
  9347. opt(m)
  9348. }
  9349. return m
  9350. }
  9351. // withSopNodeID sets the ID field of the mutation.
  9352. func withSopNodeID(id uint64) sopnodeOption {
  9353. return func(m *SopNodeMutation) {
  9354. var (
  9355. err error
  9356. once sync.Once
  9357. value *SopNode
  9358. )
  9359. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  9360. once.Do(func() {
  9361. if m.done {
  9362. err = errors.New("querying old values post mutation is not allowed")
  9363. } else {
  9364. value, err = m.Client().SopNode.Get(ctx, id)
  9365. }
  9366. })
  9367. return value, err
  9368. }
  9369. m.id = &id
  9370. }
  9371. }
  9372. // withSopNode sets the old SopNode of the mutation.
  9373. func withSopNode(node *SopNode) sopnodeOption {
  9374. return func(m *SopNodeMutation) {
  9375. m.oldValue = func(context.Context) (*SopNode, error) {
  9376. return node, nil
  9377. }
  9378. m.id = &node.ID
  9379. }
  9380. }
  9381. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9382. // executed in a transaction (ent.Tx), a transactional client is returned.
  9383. func (m SopNodeMutation) Client() *Client {
  9384. client := &Client{config: m.config}
  9385. client.init()
  9386. return client
  9387. }
  9388. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9389. // it returns an error otherwise.
  9390. func (m SopNodeMutation) Tx() (*Tx, error) {
  9391. if _, ok := m.driver.(*txDriver); !ok {
  9392. return nil, errors.New("ent: mutation is not running in a transaction")
  9393. }
  9394. tx := &Tx{config: m.config}
  9395. tx.init()
  9396. return tx, nil
  9397. }
  9398. // SetID sets the value of the id field. Note that this
  9399. // operation is only accepted on creation of SopNode entities.
  9400. func (m *SopNodeMutation) SetID(id uint64) {
  9401. m.id = &id
  9402. }
  9403. // ID returns the ID value in the mutation. Note that the ID is only available
  9404. // if it was provided to the builder or after it was returned from the database.
  9405. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  9406. if m.id == nil {
  9407. return
  9408. }
  9409. return *m.id, true
  9410. }
  9411. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9412. // That means, if the mutation is applied within a transaction with an isolation level such
  9413. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9414. // or updated by the mutation.
  9415. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  9416. switch {
  9417. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9418. id, exists := m.ID()
  9419. if exists {
  9420. return []uint64{id}, nil
  9421. }
  9422. fallthrough
  9423. case m.op.Is(OpUpdate | OpDelete):
  9424. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  9425. default:
  9426. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9427. }
  9428. }
  9429. // SetCreatedAt sets the "created_at" field.
  9430. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  9431. m.created_at = &t
  9432. }
  9433. // CreatedAt returns the value of the "created_at" field in the mutation.
  9434. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  9435. v := m.created_at
  9436. if v == nil {
  9437. return
  9438. }
  9439. return *v, true
  9440. }
  9441. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  9442. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9444. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9445. if !m.op.Is(OpUpdateOne) {
  9446. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9447. }
  9448. if m.id == nil || m.oldValue == nil {
  9449. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9450. }
  9451. oldValue, err := m.oldValue(ctx)
  9452. if err != nil {
  9453. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9454. }
  9455. return oldValue.CreatedAt, nil
  9456. }
  9457. // ResetCreatedAt resets all changes to the "created_at" field.
  9458. func (m *SopNodeMutation) ResetCreatedAt() {
  9459. m.created_at = nil
  9460. }
  9461. // SetUpdatedAt sets the "updated_at" field.
  9462. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  9463. m.updated_at = &t
  9464. }
  9465. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9466. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  9467. v := m.updated_at
  9468. if v == nil {
  9469. return
  9470. }
  9471. return *v, true
  9472. }
  9473. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  9474. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9476. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9477. if !m.op.Is(OpUpdateOne) {
  9478. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9479. }
  9480. if m.id == nil || m.oldValue == nil {
  9481. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9482. }
  9483. oldValue, err := m.oldValue(ctx)
  9484. if err != nil {
  9485. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9486. }
  9487. return oldValue.UpdatedAt, nil
  9488. }
  9489. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9490. func (m *SopNodeMutation) ResetUpdatedAt() {
  9491. m.updated_at = nil
  9492. }
  9493. // SetStatus sets the "status" field.
  9494. func (m *SopNodeMutation) SetStatus(u uint8) {
  9495. m.status = &u
  9496. m.addstatus = nil
  9497. }
  9498. // Status returns the value of the "status" field in the mutation.
  9499. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  9500. v := m.status
  9501. if v == nil {
  9502. return
  9503. }
  9504. return *v, true
  9505. }
  9506. // OldStatus returns the old "status" field's value of the SopNode entity.
  9507. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9509. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9510. if !m.op.Is(OpUpdateOne) {
  9511. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9512. }
  9513. if m.id == nil || m.oldValue == nil {
  9514. return v, errors.New("OldStatus requires an ID field in the mutation")
  9515. }
  9516. oldValue, err := m.oldValue(ctx)
  9517. if err != nil {
  9518. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9519. }
  9520. return oldValue.Status, nil
  9521. }
  9522. // AddStatus adds u to the "status" field.
  9523. func (m *SopNodeMutation) AddStatus(u int8) {
  9524. if m.addstatus != nil {
  9525. *m.addstatus += u
  9526. } else {
  9527. m.addstatus = &u
  9528. }
  9529. }
  9530. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9531. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  9532. v := m.addstatus
  9533. if v == nil {
  9534. return
  9535. }
  9536. return *v, true
  9537. }
  9538. // ClearStatus clears the value of the "status" field.
  9539. func (m *SopNodeMutation) ClearStatus() {
  9540. m.status = nil
  9541. m.addstatus = nil
  9542. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  9543. }
  9544. // StatusCleared returns if the "status" field was cleared in this mutation.
  9545. func (m *SopNodeMutation) StatusCleared() bool {
  9546. _, ok := m.clearedFields[sopnode.FieldStatus]
  9547. return ok
  9548. }
  9549. // ResetStatus resets all changes to the "status" field.
  9550. func (m *SopNodeMutation) ResetStatus() {
  9551. m.status = nil
  9552. m.addstatus = nil
  9553. delete(m.clearedFields, sopnode.FieldStatus)
  9554. }
  9555. // SetDeletedAt sets the "deleted_at" field.
  9556. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  9557. m.deleted_at = &t
  9558. }
  9559. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9560. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  9561. v := m.deleted_at
  9562. if v == nil {
  9563. return
  9564. }
  9565. return *v, true
  9566. }
  9567. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  9568. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9569. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9570. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9571. if !m.op.Is(OpUpdateOne) {
  9572. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9573. }
  9574. if m.id == nil || m.oldValue == nil {
  9575. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9576. }
  9577. oldValue, err := m.oldValue(ctx)
  9578. if err != nil {
  9579. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9580. }
  9581. return oldValue.DeletedAt, nil
  9582. }
  9583. // ClearDeletedAt clears the value of the "deleted_at" field.
  9584. func (m *SopNodeMutation) ClearDeletedAt() {
  9585. m.deleted_at = nil
  9586. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  9587. }
  9588. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9589. func (m *SopNodeMutation) DeletedAtCleared() bool {
  9590. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  9591. return ok
  9592. }
  9593. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9594. func (m *SopNodeMutation) ResetDeletedAt() {
  9595. m.deleted_at = nil
  9596. delete(m.clearedFields, sopnode.FieldDeletedAt)
  9597. }
  9598. // SetStageID sets the "stage_id" field.
  9599. func (m *SopNodeMutation) SetStageID(u uint64) {
  9600. m.sop_stage = &u
  9601. }
  9602. // StageID returns the value of the "stage_id" field in the mutation.
  9603. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  9604. v := m.sop_stage
  9605. if v == nil {
  9606. return
  9607. }
  9608. return *v, true
  9609. }
  9610. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  9611. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9613. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  9614. if !m.op.Is(OpUpdateOne) {
  9615. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  9616. }
  9617. if m.id == nil || m.oldValue == nil {
  9618. return v, errors.New("OldStageID requires an ID field in the mutation")
  9619. }
  9620. oldValue, err := m.oldValue(ctx)
  9621. if err != nil {
  9622. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  9623. }
  9624. return oldValue.StageID, nil
  9625. }
  9626. // ResetStageID resets all changes to the "stage_id" field.
  9627. func (m *SopNodeMutation) ResetStageID() {
  9628. m.sop_stage = nil
  9629. }
  9630. // SetParentID sets the "parent_id" field.
  9631. func (m *SopNodeMutation) SetParentID(u uint64) {
  9632. m.parent_id = &u
  9633. m.addparent_id = nil
  9634. }
  9635. // ParentID returns the value of the "parent_id" field in the mutation.
  9636. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  9637. v := m.parent_id
  9638. if v == nil {
  9639. return
  9640. }
  9641. return *v, true
  9642. }
  9643. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  9644. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9646. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  9647. if !m.op.Is(OpUpdateOne) {
  9648. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  9649. }
  9650. if m.id == nil || m.oldValue == nil {
  9651. return v, errors.New("OldParentID requires an ID field in the mutation")
  9652. }
  9653. oldValue, err := m.oldValue(ctx)
  9654. if err != nil {
  9655. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  9656. }
  9657. return oldValue.ParentID, nil
  9658. }
  9659. // AddParentID adds u to the "parent_id" field.
  9660. func (m *SopNodeMutation) AddParentID(u int64) {
  9661. if m.addparent_id != nil {
  9662. *m.addparent_id += u
  9663. } else {
  9664. m.addparent_id = &u
  9665. }
  9666. }
  9667. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  9668. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  9669. v := m.addparent_id
  9670. if v == nil {
  9671. return
  9672. }
  9673. return *v, true
  9674. }
  9675. // ResetParentID resets all changes to the "parent_id" field.
  9676. func (m *SopNodeMutation) ResetParentID() {
  9677. m.parent_id = nil
  9678. m.addparent_id = nil
  9679. }
  9680. // SetName sets the "name" field.
  9681. func (m *SopNodeMutation) SetName(s string) {
  9682. m.name = &s
  9683. }
  9684. // Name returns the value of the "name" field in the mutation.
  9685. func (m *SopNodeMutation) Name() (r string, exists bool) {
  9686. v := m.name
  9687. if v == nil {
  9688. return
  9689. }
  9690. return *v, true
  9691. }
  9692. // OldName returns the old "name" field's value of the SopNode entity.
  9693. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9695. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  9696. if !m.op.Is(OpUpdateOne) {
  9697. return v, errors.New("OldName is only allowed on UpdateOne operations")
  9698. }
  9699. if m.id == nil || m.oldValue == nil {
  9700. return v, errors.New("OldName requires an ID field in the mutation")
  9701. }
  9702. oldValue, err := m.oldValue(ctx)
  9703. if err != nil {
  9704. return v, fmt.Errorf("querying old value for OldName: %w", err)
  9705. }
  9706. return oldValue.Name, nil
  9707. }
  9708. // ResetName resets all changes to the "name" field.
  9709. func (m *SopNodeMutation) ResetName() {
  9710. m.name = nil
  9711. }
  9712. // SetConditionType sets the "condition_type" field.
  9713. func (m *SopNodeMutation) SetConditionType(i int) {
  9714. m.condition_type = &i
  9715. m.addcondition_type = nil
  9716. }
  9717. // ConditionType returns the value of the "condition_type" field in the mutation.
  9718. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  9719. v := m.condition_type
  9720. if v == nil {
  9721. return
  9722. }
  9723. return *v, true
  9724. }
  9725. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  9726. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9728. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  9729. if !m.op.Is(OpUpdateOne) {
  9730. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  9731. }
  9732. if m.id == nil || m.oldValue == nil {
  9733. return v, errors.New("OldConditionType requires an ID field in the mutation")
  9734. }
  9735. oldValue, err := m.oldValue(ctx)
  9736. if err != nil {
  9737. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  9738. }
  9739. return oldValue.ConditionType, nil
  9740. }
  9741. // AddConditionType adds i to the "condition_type" field.
  9742. func (m *SopNodeMutation) AddConditionType(i int) {
  9743. if m.addcondition_type != nil {
  9744. *m.addcondition_type += i
  9745. } else {
  9746. m.addcondition_type = &i
  9747. }
  9748. }
  9749. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  9750. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  9751. v := m.addcondition_type
  9752. if v == nil {
  9753. return
  9754. }
  9755. return *v, true
  9756. }
  9757. // ResetConditionType resets all changes to the "condition_type" field.
  9758. func (m *SopNodeMutation) ResetConditionType() {
  9759. m.condition_type = nil
  9760. m.addcondition_type = nil
  9761. }
  9762. // SetConditionList sets the "condition_list" field.
  9763. func (m *SopNodeMutation) SetConditionList(s []string) {
  9764. m.condition_list = &s
  9765. m.appendcondition_list = nil
  9766. }
  9767. // ConditionList returns the value of the "condition_list" field in the mutation.
  9768. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  9769. v := m.condition_list
  9770. if v == nil {
  9771. return
  9772. }
  9773. return *v, true
  9774. }
  9775. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  9776. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9778. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  9779. if !m.op.Is(OpUpdateOne) {
  9780. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  9781. }
  9782. if m.id == nil || m.oldValue == nil {
  9783. return v, errors.New("OldConditionList requires an ID field in the mutation")
  9784. }
  9785. oldValue, err := m.oldValue(ctx)
  9786. if err != nil {
  9787. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  9788. }
  9789. return oldValue.ConditionList, nil
  9790. }
  9791. // AppendConditionList adds s to the "condition_list" field.
  9792. func (m *SopNodeMutation) AppendConditionList(s []string) {
  9793. m.appendcondition_list = append(m.appendcondition_list, s...)
  9794. }
  9795. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  9796. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  9797. if len(m.appendcondition_list) == 0 {
  9798. return nil, false
  9799. }
  9800. return m.appendcondition_list, true
  9801. }
  9802. // ClearConditionList clears the value of the "condition_list" field.
  9803. func (m *SopNodeMutation) ClearConditionList() {
  9804. m.condition_list = nil
  9805. m.appendcondition_list = nil
  9806. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  9807. }
  9808. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  9809. func (m *SopNodeMutation) ConditionListCleared() bool {
  9810. _, ok := m.clearedFields[sopnode.FieldConditionList]
  9811. return ok
  9812. }
  9813. // ResetConditionList resets all changes to the "condition_list" field.
  9814. func (m *SopNodeMutation) ResetConditionList() {
  9815. m.condition_list = nil
  9816. m.appendcondition_list = nil
  9817. delete(m.clearedFields, sopnode.FieldConditionList)
  9818. }
  9819. // SetNoReplyCondition sets the "no_reply_condition" field.
  9820. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  9821. m.no_reply_condition = &u
  9822. m.addno_reply_condition = nil
  9823. }
  9824. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  9825. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  9826. v := m.no_reply_condition
  9827. if v == nil {
  9828. return
  9829. }
  9830. return *v, true
  9831. }
  9832. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  9833. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9835. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  9836. if !m.op.Is(OpUpdateOne) {
  9837. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  9838. }
  9839. if m.id == nil || m.oldValue == nil {
  9840. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  9841. }
  9842. oldValue, err := m.oldValue(ctx)
  9843. if err != nil {
  9844. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  9845. }
  9846. return oldValue.NoReplyCondition, nil
  9847. }
  9848. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  9849. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  9850. if m.addno_reply_condition != nil {
  9851. *m.addno_reply_condition += u
  9852. } else {
  9853. m.addno_reply_condition = &u
  9854. }
  9855. }
  9856. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  9857. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  9858. v := m.addno_reply_condition
  9859. if v == nil {
  9860. return
  9861. }
  9862. return *v, true
  9863. }
  9864. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  9865. func (m *SopNodeMutation) ResetNoReplyCondition() {
  9866. m.no_reply_condition = nil
  9867. m.addno_reply_condition = nil
  9868. }
  9869. // SetActionMessage sets the "action_message" field.
  9870. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  9871. m.action_message = &ct
  9872. m.appendaction_message = nil
  9873. }
  9874. // ActionMessage returns the value of the "action_message" field in the mutation.
  9875. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  9876. v := m.action_message
  9877. if v == nil {
  9878. return
  9879. }
  9880. return *v, true
  9881. }
  9882. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  9883. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9884. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9885. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  9886. if !m.op.Is(OpUpdateOne) {
  9887. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  9888. }
  9889. if m.id == nil || m.oldValue == nil {
  9890. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  9891. }
  9892. oldValue, err := m.oldValue(ctx)
  9893. if err != nil {
  9894. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  9895. }
  9896. return oldValue.ActionMessage, nil
  9897. }
  9898. // AppendActionMessage adds ct to the "action_message" field.
  9899. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  9900. m.appendaction_message = append(m.appendaction_message, ct...)
  9901. }
  9902. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  9903. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  9904. if len(m.appendaction_message) == 0 {
  9905. return nil, false
  9906. }
  9907. return m.appendaction_message, true
  9908. }
  9909. // ClearActionMessage clears the value of the "action_message" field.
  9910. func (m *SopNodeMutation) ClearActionMessage() {
  9911. m.action_message = nil
  9912. m.appendaction_message = nil
  9913. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  9914. }
  9915. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  9916. func (m *SopNodeMutation) ActionMessageCleared() bool {
  9917. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  9918. return ok
  9919. }
  9920. // ResetActionMessage resets all changes to the "action_message" field.
  9921. func (m *SopNodeMutation) ResetActionMessage() {
  9922. m.action_message = nil
  9923. m.appendaction_message = nil
  9924. delete(m.clearedFields, sopnode.FieldActionMessage)
  9925. }
  9926. // SetActionLabel sets the "action_label" field.
  9927. func (m *SopNodeMutation) SetActionLabel(u []uint64) {
  9928. m.action_label = &u
  9929. m.appendaction_label = nil
  9930. }
  9931. // ActionLabel returns the value of the "action_label" field in the mutation.
  9932. func (m *SopNodeMutation) ActionLabel() (r []uint64, exists bool) {
  9933. v := m.action_label
  9934. if v == nil {
  9935. return
  9936. }
  9937. return *v, true
  9938. }
  9939. // OldActionLabel returns the old "action_label" field's value of the SopNode entity.
  9940. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9942. func (m *SopNodeMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  9943. if !m.op.Is(OpUpdateOne) {
  9944. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  9945. }
  9946. if m.id == nil || m.oldValue == nil {
  9947. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  9948. }
  9949. oldValue, err := m.oldValue(ctx)
  9950. if err != nil {
  9951. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  9952. }
  9953. return oldValue.ActionLabel, nil
  9954. }
  9955. // AppendActionLabel adds u to the "action_label" field.
  9956. func (m *SopNodeMutation) AppendActionLabel(u []uint64) {
  9957. m.appendaction_label = append(m.appendaction_label, u...)
  9958. }
  9959. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  9960. func (m *SopNodeMutation) AppendedActionLabel() ([]uint64, bool) {
  9961. if len(m.appendaction_label) == 0 {
  9962. return nil, false
  9963. }
  9964. return m.appendaction_label, true
  9965. }
  9966. // ClearActionLabel clears the value of the "action_label" field.
  9967. func (m *SopNodeMutation) ClearActionLabel() {
  9968. m.action_label = nil
  9969. m.appendaction_label = nil
  9970. m.clearedFields[sopnode.FieldActionLabel] = struct{}{}
  9971. }
  9972. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  9973. func (m *SopNodeMutation) ActionLabelCleared() bool {
  9974. _, ok := m.clearedFields[sopnode.FieldActionLabel]
  9975. return ok
  9976. }
  9977. // ResetActionLabel resets all changes to the "action_label" field.
  9978. func (m *SopNodeMutation) ResetActionLabel() {
  9979. m.action_label = nil
  9980. m.appendaction_label = nil
  9981. delete(m.clearedFields, sopnode.FieldActionLabel)
  9982. }
  9983. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  9984. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  9985. m.sop_stage = &id
  9986. }
  9987. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  9988. func (m *SopNodeMutation) ClearSopStage() {
  9989. m.clearedsop_stage = true
  9990. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  9991. }
  9992. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  9993. func (m *SopNodeMutation) SopStageCleared() bool {
  9994. return m.clearedsop_stage
  9995. }
  9996. // SopStageID returns the "sop_stage" edge ID in the mutation.
  9997. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  9998. if m.sop_stage != nil {
  9999. return *m.sop_stage, true
  10000. }
  10001. return
  10002. }
  10003. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  10004. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  10005. // SopStageID instead. It exists only for internal usage by the builders.
  10006. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  10007. if id := m.sop_stage; id != nil {
  10008. ids = append(ids, *id)
  10009. }
  10010. return
  10011. }
  10012. // ResetSopStage resets all changes to the "sop_stage" edge.
  10013. func (m *SopNodeMutation) ResetSopStage() {
  10014. m.sop_stage = nil
  10015. m.clearedsop_stage = false
  10016. }
  10017. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  10018. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  10019. if m.node_messages == nil {
  10020. m.node_messages = make(map[uint64]struct{})
  10021. }
  10022. for i := range ids {
  10023. m.node_messages[ids[i]] = struct{}{}
  10024. }
  10025. }
  10026. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  10027. func (m *SopNodeMutation) ClearNodeMessages() {
  10028. m.clearednode_messages = true
  10029. }
  10030. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  10031. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  10032. return m.clearednode_messages
  10033. }
  10034. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  10035. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  10036. if m.removednode_messages == nil {
  10037. m.removednode_messages = make(map[uint64]struct{})
  10038. }
  10039. for i := range ids {
  10040. delete(m.node_messages, ids[i])
  10041. m.removednode_messages[ids[i]] = struct{}{}
  10042. }
  10043. }
  10044. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  10045. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  10046. for id := range m.removednode_messages {
  10047. ids = append(ids, id)
  10048. }
  10049. return
  10050. }
  10051. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  10052. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  10053. for id := range m.node_messages {
  10054. ids = append(ids, id)
  10055. }
  10056. return
  10057. }
  10058. // ResetNodeMessages resets all changes to the "node_messages" edge.
  10059. func (m *SopNodeMutation) ResetNodeMessages() {
  10060. m.node_messages = nil
  10061. m.clearednode_messages = false
  10062. m.removednode_messages = nil
  10063. }
  10064. // Where appends a list predicates to the SopNodeMutation builder.
  10065. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  10066. m.predicates = append(m.predicates, ps...)
  10067. }
  10068. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  10069. // users can use type-assertion to append predicates that do not depend on any generated package.
  10070. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  10071. p := make([]predicate.SopNode, len(ps))
  10072. for i := range ps {
  10073. p[i] = ps[i]
  10074. }
  10075. m.Where(p...)
  10076. }
  10077. // Op returns the operation name.
  10078. func (m *SopNodeMutation) Op() Op {
  10079. return m.op
  10080. }
  10081. // SetOp allows setting the mutation operation.
  10082. func (m *SopNodeMutation) SetOp(op Op) {
  10083. m.op = op
  10084. }
  10085. // Type returns the node type of this mutation (SopNode).
  10086. func (m *SopNodeMutation) Type() string {
  10087. return m.typ
  10088. }
  10089. // Fields returns all fields that were changed during this mutation. Note that in
  10090. // order to get all numeric fields that were incremented/decremented, call
  10091. // AddedFields().
  10092. func (m *SopNodeMutation) Fields() []string {
  10093. fields := make([]string, 0, 12)
  10094. if m.created_at != nil {
  10095. fields = append(fields, sopnode.FieldCreatedAt)
  10096. }
  10097. if m.updated_at != nil {
  10098. fields = append(fields, sopnode.FieldUpdatedAt)
  10099. }
  10100. if m.status != nil {
  10101. fields = append(fields, sopnode.FieldStatus)
  10102. }
  10103. if m.deleted_at != nil {
  10104. fields = append(fields, sopnode.FieldDeletedAt)
  10105. }
  10106. if m.sop_stage != nil {
  10107. fields = append(fields, sopnode.FieldStageID)
  10108. }
  10109. if m.parent_id != nil {
  10110. fields = append(fields, sopnode.FieldParentID)
  10111. }
  10112. if m.name != nil {
  10113. fields = append(fields, sopnode.FieldName)
  10114. }
  10115. if m.condition_type != nil {
  10116. fields = append(fields, sopnode.FieldConditionType)
  10117. }
  10118. if m.condition_list != nil {
  10119. fields = append(fields, sopnode.FieldConditionList)
  10120. }
  10121. if m.no_reply_condition != nil {
  10122. fields = append(fields, sopnode.FieldNoReplyCondition)
  10123. }
  10124. if m.action_message != nil {
  10125. fields = append(fields, sopnode.FieldActionMessage)
  10126. }
  10127. if m.action_label != nil {
  10128. fields = append(fields, sopnode.FieldActionLabel)
  10129. }
  10130. return fields
  10131. }
  10132. // Field returns the value of a field with the given name. The second boolean
  10133. // return value indicates that this field was not set, or was not defined in the
  10134. // schema.
  10135. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  10136. switch name {
  10137. case sopnode.FieldCreatedAt:
  10138. return m.CreatedAt()
  10139. case sopnode.FieldUpdatedAt:
  10140. return m.UpdatedAt()
  10141. case sopnode.FieldStatus:
  10142. return m.Status()
  10143. case sopnode.FieldDeletedAt:
  10144. return m.DeletedAt()
  10145. case sopnode.FieldStageID:
  10146. return m.StageID()
  10147. case sopnode.FieldParentID:
  10148. return m.ParentID()
  10149. case sopnode.FieldName:
  10150. return m.Name()
  10151. case sopnode.FieldConditionType:
  10152. return m.ConditionType()
  10153. case sopnode.FieldConditionList:
  10154. return m.ConditionList()
  10155. case sopnode.FieldNoReplyCondition:
  10156. return m.NoReplyCondition()
  10157. case sopnode.FieldActionMessage:
  10158. return m.ActionMessage()
  10159. case sopnode.FieldActionLabel:
  10160. return m.ActionLabel()
  10161. }
  10162. return nil, false
  10163. }
  10164. // OldField returns the old value of the field from the database. An error is
  10165. // returned if the mutation operation is not UpdateOne, or the query to the
  10166. // database failed.
  10167. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10168. switch name {
  10169. case sopnode.FieldCreatedAt:
  10170. return m.OldCreatedAt(ctx)
  10171. case sopnode.FieldUpdatedAt:
  10172. return m.OldUpdatedAt(ctx)
  10173. case sopnode.FieldStatus:
  10174. return m.OldStatus(ctx)
  10175. case sopnode.FieldDeletedAt:
  10176. return m.OldDeletedAt(ctx)
  10177. case sopnode.FieldStageID:
  10178. return m.OldStageID(ctx)
  10179. case sopnode.FieldParentID:
  10180. return m.OldParentID(ctx)
  10181. case sopnode.FieldName:
  10182. return m.OldName(ctx)
  10183. case sopnode.FieldConditionType:
  10184. return m.OldConditionType(ctx)
  10185. case sopnode.FieldConditionList:
  10186. return m.OldConditionList(ctx)
  10187. case sopnode.FieldNoReplyCondition:
  10188. return m.OldNoReplyCondition(ctx)
  10189. case sopnode.FieldActionMessage:
  10190. return m.OldActionMessage(ctx)
  10191. case sopnode.FieldActionLabel:
  10192. return m.OldActionLabel(ctx)
  10193. }
  10194. return nil, fmt.Errorf("unknown SopNode field %s", name)
  10195. }
  10196. // SetField sets the value of a field with the given name. It returns an error if
  10197. // the field is not defined in the schema, or if the type mismatched the field
  10198. // type.
  10199. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  10200. switch name {
  10201. case sopnode.FieldCreatedAt:
  10202. v, ok := value.(time.Time)
  10203. if !ok {
  10204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10205. }
  10206. m.SetCreatedAt(v)
  10207. return nil
  10208. case sopnode.FieldUpdatedAt:
  10209. v, ok := value.(time.Time)
  10210. if !ok {
  10211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10212. }
  10213. m.SetUpdatedAt(v)
  10214. return nil
  10215. case sopnode.FieldStatus:
  10216. v, ok := value.(uint8)
  10217. if !ok {
  10218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10219. }
  10220. m.SetStatus(v)
  10221. return nil
  10222. case sopnode.FieldDeletedAt:
  10223. v, ok := value.(time.Time)
  10224. if !ok {
  10225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10226. }
  10227. m.SetDeletedAt(v)
  10228. return nil
  10229. case sopnode.FieldStageID:
  10230. v, ok := value.(uint64)
  10231. if !ok {
  10232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10233. }
  10234. m.SetStageID(v)
  10235. return nil
  10236. case sopnode.FieldParentID:
  10237. v, ok := value.(uint64)
  10238. if !ok {
  10239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10240. }
  10241. m.SetParentID(v)
  10242. return nil
  10243. case sopnode.FieldName:
  10244. v, ok := value.(string)
  10245. if !ok {
  10246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10247. }
  10248. m.SetName(v)
  10249. return nil
  10250. case sopnode.FieldConditionType:
  10251. v, ok := value.(int)
  10252. if !ok {
  10253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10254. }
  10255. m.SetConditionType(v)
  10256. return nil
  10257. case sopnode.FieldConditionList:
  10258. v, ok := value.([]string)
  10259. if !ok {
  10260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10261. }
  10262. m.SetConditionList(v)
  10263. return nil
  10264. case sopnode.FieldNoReplyCondition:
  10265. v, ok := value.(uint64)
  10266. if !ok {
  10267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10268. }
  10269. m.SetNoReplyCondition(v)
  10270. return nil
  10271. case sopnode.FieldActionMessage:
  10272. v, ok := value.([]custom_types.Action)
  10273. if !ok {
  10274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10275. }
  10276. m.SetActionMessage(v)
  10277. return nil
  10278. case sopnode.FieldActionLabel:
  10279. v, ok := value.([]uint64)
  10280. if !ok {
  10281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10282. }
  10283. m.SetActionLabel(v)
  10284. return nil
  10285. }
  10286. return fmt.Errorf("unknown SopNode field %s", name)
  10287. }
  10288. // AddedFields returns all numeric fields that were incremented/decremented during
  10289. // this mutation.
  10290. func (m *SopNodeMutation) AddedFields() []string {
  10291. var fields []string
  10292. if m.addstatus != nil {
  10293. fields = append(fields, sopnode.FieldStatus)
  10294. }
  10295. if m.addparent_id != nil {
  10296. fields = append(fields, sopnode.FieldParentID)
  10297. }
  10298. if m.addcondition_type != nil {
  10299. fields = append(fields, sopnode.FieldConditionType)
  10300. }
  10301. if m.addno_reply_condition != nil {
  10302. fields = append(fields, sopnode.FieldNoReplyCondition)
  10303. }
  10304. return fields
  10305. }
  10306. // AddedField returns the numeric value that was incremented/decremented on a field
  10307. // with the given name. The second boolean return value indicates that this field
  10308. // was not set, or was not defined in the schema.
  10309. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  10310. switch name {
  10311. case sopnode.FieldStatus:
  10312. return m.AddedStatus()
  10313. case sopnode.FieldParentID:
  10314. return m.AddedParentID()
  10315. case sopnode.FieldConditionType:
  10316. return m.AddedConditionType()
  10317. case sopnode.FieldNoReplyCondition:
  10318. return m.AddedNoReplyCondition()
  10319. }
  10320. return nil, false
  10321. }
  10322. // AddField adds the value to the field with the given name. It returns an error if
  10323. // the field is not defined in the schema, or if the type mismatched the field
  10324. // type.
  10325. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  10326. switch name {
  10327. case sopnode.FieldStatus:
  10328. v, ok := value.(int8)
  10329. if !ok {
  10330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10331. }
  10332. m.AddStatus(v)
  10333. return nil
  10334. case sopnode.FieldParentID:
  10335. v, ok := value.(int64)
  10336. if !ok {
  10337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10338. }
  10339. m.AddParentID(v)
  10340. return nil
  10341. case sopnode.FieldConditionType:
  10342. v, ok := value.(int)
  10343. if !ok {
  10344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10345. }
  10346. m.AddConditionType(v)
  10347. return nil
  10348. case sopnode.FieldNoReplyCondition:
  10349. v, ok := value.(int64)
  10350. if !ok {
  10351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10352. }
  10353. m.AddNoReplyCondition(v)
  10354. return nil
  10355. }
  10356. return fmt.Errorf("unknown SopNode numeric field %s", name)
  10357. }
  10358. // ClearedFields returns all nullable fields that were cleared during this
  10359. // mutation.
  10360. func (m *SopNodeMutation) ClearedFields() []string {
  10361. var fields []string
  10362. if m.FieldCleared(sopnode.FieldStatus) {
  10363. fields = append(fields, sopnode.FieldStatus)
  10364. }
  10365. if m.FieldCleared(sopnode.FieldDeletedAt) {
  10366. fields = append(fields, sopnode.FieldDeletedAt)
  10367. }
  10368. if m.FieldCleared(sopnode.FieldConditionList) {
  10369. fields = append(fields, sopnode.FieldConditionList)
  10370. }
  10371. if m.FieldCleared(sopnode.FieldActionMessage) {
  10372. fields = append(fields, sopnode.FieldActionMessage)
  10373. }
  10374. if m.FieldCleared(sopnode.FieldActionLabel) {
  10375. fields = append(fields, sopnode.FieldActionLabel)
  10376. }
  10377. return fields
  10378. }
  10379. // FieldCleared returns a boolean indicating if a field with the given name was
  10380. // cleared in this mutation.
  10381. func (m *SopNodeMutation) FieldCleared(name string) bool {
  10382. _, ok := m.clearedFields[name]
  10383. return ok
  10384. }
  10385. // ClearField clears the value of the field with the given name. It returns an
  10386. // error if the field is not defined in the schema.
  10387. func (m *SopNodeMutation) ClearField(name string) error {
  10388. switch name {
  10389. case sopnode.FieldStatus:
  10390. m.ClearStatus()
  10391. return nil
  10392. case sopnode.FieldDeletedAt:
  10393. m.ClearDeletedAt()
  10394. return nil
  10395. case sopnode.FieldConditionList:
  10396. m.ClearConditionList()
  10397. return nil
  10398. case sopnode.FieldActionMessage:
  10399. m.ClearActionMessage()
  10400. return nil
  10401. case sopnode.FieldActionLabel:
  10402. m.ClearActionLabel()
  10403. return nil
  10404. }
  10405. return fmt.Errorf("unknown SopNode nullable field %s", name)
  10406. }
  10407. // ResetField resets all changes in the mutation for the field with the given name.
  10408. // It returns an error if the field is not defined in the schema.
  10409. func (m *SopNodeMutation) ResetField(name string) error {
  10410. switch name {
  10411. case sopnode.FieldCreatedAt:
  10412. m.ResetCreatedAt()
  10413. return nil
  10414. case sopnode.FieldUpdatedAt:
  10415. m.ResetUpdatedAt()
  10416. return nil
  10417. case sopnode.FieldStatus:
  10418. m.ResetStatus()
  10419. return nil
  10420. case sopnode.FieldDeletedAt:
  10421. m.ResetDeletedAt()
  10422. return nil
  10423. case sopnode.FieldStageID:
  10424. m.ResetStageID()
  10425. return nil
  10426. case sopnode.FieldParentID:
  10427. m.ResetParentID()
  10428. return nil
  10429. case sopnode.FieldName:
  10430. m.ResetName()
  10431. return nil
  10432. case sopnode.FieldConditionType:
  10433. m.ResetConditionType()
  10434. return nil
  10435. case sopnode.FieldConditionList:
  10436. m.ResetConditionList()
  10437. return nil
  10438. case sopnode.FieldNoReplyCondition:
  10439. m.ResetNoReplyCondition()
  10440. return nil
  10441. case sopnode.FieldActionMessage:
  10442. m.ResetActionMessage()
  10443. return nil
  10444. case sopnode.FieldActionLabel:
  10445. m.ResetActionLabel()
  10446. return nil
  10447. }
  10448. return fmt.Errorf("unknown SopNode field %s", name)
  10449. }
  10450. // AddedEdges returns all edge names that were set/added in this mutation.
  10451. func (m *SopNodeMutation) AddedEdges() []string {
  10452. edges := make([]string, 0, 2)
  10453. if m.sop_stage != nil {
  10454. edges = append(edges, sopnode.EdgeSopStage)
  10455. }
  10456. if m.node_messages != nil {
  10457. edges = append(edges, sopnode.EdgeNodeMessages)
  10458. }
  10459. return edges
  10460. }
  10461. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10462. // name in this mutation.
  10463. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  10464. switch name {
  10465. case sopnode.EdgeSopStage:
  10466. if id := m.sop_stage; id != nil {
  10467. return []ent.Value{*id}
  10468. }
  10469. case sopnode.EdgeNodeMessages:
  10470. ids := make([]ent.Value, 0, len(m.node_messages))
  10471. for id := range m.node_messages {
  10472. ids = append(ids, id)
  10473. }
  10474. return ids
  10475. }
  10476. return nil
  10477. }
  10478. // RemovedEdges returns all edge names that were removed in this mutation.
  10479. func (m *SopNodeMutation) RemovedEdges() []string {
  10480. edges := make([]string, 0, 2)
  10481. if m.removednode_messages != nil {
  10482. edges = append(edges, sopnode.EdgeNodeMessages)
  10483. }
  10484. return edges
  10485. }
  10486. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10487. // the given name in this mutation.
  10488. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  10489. switch name {
  10490. case sopnode.EdgeNodeMessages:
  10491. ids := make([]ent.Value, 0, len(m.removednode_messages))
  10492. for id := range m.removednode_messages {
  10493. ids = append(ids, id)
  10494. }
  10495. return ids
  10496. }
  10497. return nil
  10498. }
  10499. // ClearedEdges returns all edge names that were cleared in this mutation.
  10500. func (m *SopNodeMutation) ClearedEdges() []string {
  10501. edges := make([]string, 0, 2)
  10502. if m.clearedsop_stage {
  10503. edges = append(edges, sopnode.EdgeSopStage)
  10504. }
  10505. if m.clearednode_messages {
  10506. edges = append(edges, sopnode.EdgeNodeMessages)
  10507. }
  10508. return edges
  10509. }
  10510. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10511. // was cleared in this mutation.
  10512. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  10513. switch name {
  10514. case sopnode.EdgeSopStage:
  10515. return m.clearedsop_stage
  10516. case sopnode.EdgeNodeMessages:
  10517. return m.clearednode_messages
  10518. }
  10519. return false
  10520. }
  10521. // ClearEdge clears the value of the edge with the given name. It returns an error
  10522. // if that edge is not defined in the schema.
  10523. func (m *SopNodeMutation) ClearEdge(name string) error {
  10524. switch name {
  10525. case sopnode.EdgeSopStage:
  10526. m.ClearSopStage()
  10527. return nil
  10528. }
  10529. return fmt.Errorf("unknown SopNode unique edge %s", name)
  10530. }
  10531. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10532. // It returns an error if the edge is not defined in the schema.
  10533. func (m *SopNodeMutation) ResetEdge(name string) error {
  10534. switch name {
  10535. case sopnode.EdgeSopStage:
  10536. m.ResetSopStage()
  10537. return nil
  10538. case sopnode.EdgeNodeMessages:
  10539. m.ResetNodeMessages()
  10540. return nil
  10541. }
  10542. return fmt.Errorf("unknown SopNode edge %s", name)
  10543. }
  10544. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  10545. type SopStageMutation struct {
  10546. config
  10547. op Op
  10548. typ string
  10549. id *uint64
  10550. created_at *time.Time
  10551. updated_at *time.Time
  10552. status *uint8
  10553. addstatus *int8
  10554. deleted_at *time.Time
  10555. name *string
  10556. condition_type *int
  10557. addcondition_type *int
  10558. condition_operator *int
  10559. addcondition_operator *int
  10560. condition_list *[]custom_types.Condition
  10561. appendcondition_list []custom_types.Condition
  10562. action_message *[]custom_types.Action
  10563. appendaction_message []custom_types.Action
  10564. action_label *[]uint64
  10565. appendaction_label []uint64
  10566. index_sort *int
  10567. addindex_sort *int
  10568. clearedFields map[string]struct{}
  10569. sop_task *uint64
  10570. clearedsop_task bool
  10571. stage_nodes map[uint64]struct{}
  10572. removedstage_nodes map[uint64]struct{}
  10573. clearedstage_nodes bool
  10574. stage_messages map[uint64]struct{}
  10575. removedstage_messages map[uint64]struct{}
  10576. clearedstage_messages bool
  10577. done bool
  10578. oldValue func(context.Context) (*SopStage, error)
  10579. predicates []predicate.SopStage
  10580. }
  10581. var _ ent.Mutation = (*SopStageMutation)(nil)
  10582. // sopstageOption allows management of the mutation configuration using functional options.
  10583. type sopstageOption func(*SopStageMutation)
  10584. // newSopStageMutation creates new mutation for the SopStage entity.
  10585. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  10586. m := &SopStageMutation{
  10587. config: c,
  10588. op: op,
  10589. typ: TypeSopStage,
  10590. clearedFields: make(map[string]struct{}),
  10591. }
  10592. for _, opt := range opts {
  10593. opt(m)
  10594. }
  10595. return m
  10596. }
  10597. // withSopStageID sets the ID field of the mutation.
  10598. func withSopStageID(id uint64) sopstageOption {
  10599. return func(m *SopStageMutation) {
  10600. var (
  10601. err error
  10602. once sync.Once
  10603. value *SopStage
  10604. )
  10605. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  10606. once.Do(func() {
  10607. if m.done {
  10608. err = errors.New("querying old values post mutation is not allowed")
  10609. } else {
  10610. value, err = m.Client().SopStage.Get(ctx, id)
  10611. }
  10612. })
  10613. return value, err
  10614. }
  10615. m.id = &id
  10616. }
  10617. }
  10618. // withSopStage sets the old SopStage of the mutation.
  10619. func withSopStage(node *SopStage) sopstageOption {
  10620. return func(m *SopStageMutation) {
  10621. m.oldValue = func(context.Context) (*SopStage, error) {
  10622. return node, nil
  10623. }
  10624. m.id = &node.ID
  10625. }
  10626. }
  10627. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10628. // executed in a transaction (ent.Tx), a transactional client is returned.
  10629. func (m SopStageMutation) Client() *Client {
  10630. client := &Client{config: m.config}
  10631. client.init()
  10632. return client
  10633. }
  10634. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10635. // it returns an error otherwise.
  10636. func (m SopStageMutation) Tx() (*Tx, error) {
  10637. if _, ok := m.driver.(*txDriver); !ok {
  10638. return nil, errors.New("ent: mutation is not running in a transaction")
  10639. }
  10640. tx := &Tx{config: m.config}
  10641. tx.init()
  10642. return tx, nil
  10643. }
  10644. // SetID sets the value of the id field. Note that this
  10645. // operation is only accepted on creation of SopStage entities.
  10646. func (m *SopStageMutation) SetID(id uint64) {
  10647. m.id = &id
  10648. }
  10649. // ID returns the ID value in the mutation. Note that the ID is only available
  10650. // if it was provided to the builder or after it was returned from the database.
  10651. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  10652. if m.id == nil {
  10653. return
  10654. }
  10655. return *m.id, true
  10656. }
  10657. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10658. // That means, if the mutation is applied within a transaction with an isolation level such
  10659. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10660. // or updated by the mutation.
  10661. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  10662. switch {
  10663. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10664. id, exists := m.ID()
  10665. if exists {
  10666. return []uint64{id}, nil
  10667. }
  10668. fallthrough
  10669. case m.op.Is(OpUpdate | OpDelete):
  10670. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  10671. default:
  10672. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10673. }
  10674. }
  10675. // SetCreatedAt sets the "created_at" field.
  10676. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  10677. m.created_at = &t
  10678. }
  10679. // CreatedAt returns the value of the "created_at" field in the mutation.
  10680. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  10681. v := m.created_at
  10682. if v == nil {
  10683. return
  10684. }
  10685. return *v, true
  10686. }
  10687. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  10688. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10690. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10691. if !m.op.Is(OpUpdateOne) {
  10692. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10693. }
  10694. if m.id == nil || m.oldValue == nil {
  10695. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10696. }
  10697. oldValue, err := m.oldValue(ctx)
  10698. if err != nil {
  10699. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10700. }
  10701. return oldValue.CreatedAt, nil
  10702. }
  10703. // ResetCreatedAt resets all changes to the "created_at" field.
  10704. func (m *SopStageMutation) ResetCreatedAt() {
  10705. m.created_at = nil
  10706. }
  10707. // SetUpdatedAt sets the "updated_at" field.
  10708. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  10709. m.updated_at = &t
  10710. }
  10711. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10712. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  10713. v := m.updated_at
  10714. if v == nil {
  10715. return
  10716. }
  10717. return *v, true
  10718. }
  10719. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  10720. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10722. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10723. if !m.op.Is(OpUpdateOne) {
  10724. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10725. }
  10726. if m.id == nil || m.oldValue == nil {
  10727. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10728. }
  10729. oldValue, err := m.oldValue(ctx)
  10730. if err != nil {
  10731. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10732. }
  10733. return oldValue.UpdatedAt, nil
  10734. }
  10735. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10736. func (m *SopStageMutation) ResetUpdatedAt() {
  10737. m.updated_at = nil
  10738. }
  10739. // SetStatus sets the "status" field.
  10740. func (m *SopStageMutation) SetStatus(u uint8) {
  10741. m.status = &u
  10742. m.addstatus = nil
  10743. }
  10744. // Status returns the value of the "status" field in the mutation.
  10745. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  10746. v := m.status
  10747. if v == nil {
  10748. return
  10749. }
  10750. return *v, true
  10751. }
  10752. // OldStatus returns the old "status" field's value of the SopStage entity.
  10753. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10755. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  10756. if !m.op.Is(OpUpdateOne) {
  10757. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10758. }
  10759. if m.id == nil || m.oldValue == nil {
  10760. return v, errors.New("OldStatus requires an ID field in the mutation")
  10761. }
  10762. oldValue, err := m.oldValue(ctx)
  10763. if err != nil {
  10764. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10765. }
  10766. return oldValue.Status, nil
  10767. }
  10768. // AddStatus adds u to the "status" field.
  10769. func (m *SopStageMutation) AddStatus(u int8) {
  10770. if m.addstatus != nil {
  10771. *m.addstatus += u
  10772. } else {
  10773. m.addstatus = &u
  10774. }
  10775. }
  10776. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10777. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  10778. v := m.addstatus
  10779. if v == nil {
  10780. return
  10781. }
  10782. return *v, true
  10783. }
  10784. // ClearStatus clears the value of the "status" field.
  10785. func (m *SopStageMutation) ClearStatus() {
  10786. m.status = nil
  10787. m.addstatus = nil
  10788. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  10789. }
  10790. // StatusCleared returns if the "status" field was cleared in this mutation.
  10791. func (m *SopStageMutation) StatusCleared() bool {
  10792. _, ok := m.clearedFields[sopstage.FieldStatus]
  10793. return ok
  10794. }
  10795. // ResetStatus resets all changes to the "status" field.
  10796. func (m *SopStageMutation) ResetStatus() {
  10797. m.status = nil
  10798. m.addstatus = nil
  10799. delete(m.clearedFields, sopstage.FieldStatus)
  10800. }
  10801. // SetDeletedAt sets the "deleted_at" field.
  10802. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  10803. m.deleted_at = &t
  10804. }
  10805. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10806. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  10807. v := m.deleted_at
  10808. if v == nil {
  10809. return
  10810. }
  10811. return *v, true
  10812. }
  10813. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  10814. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10815. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10816. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10817. if !m.op.Is(OpUpdateOne) {
  10818. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10819. }
  10820. if m.id == nil || m.oldValue == nil {
  10821. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10822. }
  10823. oldValue, err := m.oldValue(ctx)
  10824. if err != nil {
  10825. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10826. }
  10827. return oldValue.DeletedAt, nil
  10828. }
  10829. // ClearDeletedAt clears the value of the "deleted_at" field.
  10830. func (m *SopStageMutation) ClearDeletedAt() {
  10831. m.deleted_at = nil
  10832. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  10833. }
  10834. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10835. func (m *SopStageMutation) DeletedAtCleared() bool {
  10836. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  10837. return ok
  10838. }
  10839. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10840. func (m *SopStageMutation) ResetDeletedAt() {
  10841. m.deleted_at = nil
  10842. delete(m.clearedFields, sopstage.FieldDeletedAt)
  10843. }
  10844. // SetTaskID sets the "task_id" field.
  10845. func (m *SopStageMutation) SetTaskID(u uint64) {
  10846. m.sop_task = &u
  10847. }
  10848. // TaskID returns the value of the "task_id" field in the mutation.
  10849. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  10850. v := m.sop_task
  10851. if v == nil {
  10852. return
  10853. }
  10854. return *v, true
  10855. }
  10856. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  10857. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10859. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  10860. if !m.op.Is(OpUpdateOne) {
  10861. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  10862. }
  10863. if m.id == nil || m.oldValue == nil {
  10864. return v, errors.New("OldTaskID requires an ID field in the mutation")
  10865. }
  10866. oldValue, err := m.oldValue(ctx)
  10867. if err != nil {
  10868. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  10869. }
  10870. return oldValue.TaskID, nil
  10871. }
  10872. // ResetTaskID resets all changes to the "task_id" field.
  10873. func (m *SopStageMutation) ResetTaskID() {
  10874. m.sop_task = nil
  10875. }
  10876. // SetName sets the "name" field.
  10877. func (m *SopStageMutation) SetName(s string) {
  10878. m.name = &s
  10879. }
  10880. // Name returns the value of the "name" field in the mutation.
  10881. func (m *SopStageMutation) Name() (r string, exists bool) {
  10882. v := m.name
  10883. if v == nil {
  10884. return
  10885. }
  10886. return *v, true
  10887. }
  10888. // OldName returns the old "name" field's value of the SopStage entity.
  10889. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10891. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  10892. if !m.op.Is(OpUpdateOne) {
  10893. return v, errors.New("OldName is only allowed on UpdateOne operations")
  10894. }
  10895. if m.id == nil || m.oldValue == nil {
  10896. return v, errors.New("OldName requires an ID field in the mutation")
  10897. }
  10898. oldValue, err := m.oldValue(ctx)
  10899. if err != nil {
  10900. return v, fmt.Errorf("querying old value for OldName: %w", err)
  10901. }
  10902. return oldValue.Name, nil
  10903. }
  10904. // ResetName resets all changes to the "name" field.
  10905. func (m *SopStageMutation) ResetName() {
  10906. m.name = nil
  10907. }
  10908. // SetConditionType sets the "condition_type" field.
  10909. func (m *SopStageMutation) SetConditionType(i int) {
  10910. m.condition_type = &i
  10911. m.addcondition_type = nil
  10912. }
  10913. // ConditionType returns the value of the "condition_type" field in the mutation.
  10914. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  10915. v := m.condition_type
  10916. if v == nil {
  10917. return
  10918. }
  10919. return *v, true
  10920. }
  10921. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  10922. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10924. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  10925. if !m.op.Is(OpUpdateOne) {
  10926. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  10927. }
  10928. if m.id == nil || m.oldValue == nil {
  10929. return v, errors.New("OldConditionType requires an ID field in the mutation")
  10930. }
  10931. oldValue, err := m.oldValue(ctx)
  10932. if err != nil {
  10933. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  10934. }
  10935. return oldValue.ConditionType, nil
  10936. }
  10937. // AddConditionType adds i to the "condition_type" field.
  10938. func (m *SopStageMutation) AddConditionType(i int) {
  10939. if m.addcondition_type != nil {
  10940. *m.addcondition_type += i
  10941. } else {
  10942. m.addcondition_type = &i
  10943. }
  10944. }
  10945. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  10946. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  10947. v := m.addcondition_type
  10948. if v == nil {
  10949. return
  10950. }
  10951. return *v, true
  10952. }
  10953. // ResetConditionType resets all changes to the "condition_type" field.
  10954. func (m *SopStageMutation) ResetConditionType() {
  10955. m.condition_type = nil
  10956. m.addcondition_type = nil
  10957. }
  10958. // SetConditionOperator sets the "condition_operator" field.
  10959. func (m *SopStageMutation) SetConditionOperator(i int) {
  10960. m.condition_operator = &i
  10961. m.addcondition_operator = nil
  10962. }
  10963. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  10964. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  10965. v := m.condition_operator
  10966. if v == nil {
  10967. return
  10968. }
  10969. return *v, true
  10970. }
  10971. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  10972. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10974. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  10975. if !m.op.Is(OpUpdateOne) {
  10976. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  10977. }
  10978. if m.id == nil || m.oldValue == nil {
  10979. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  10980. }
  10981. oldValue, err := m.oldValue(ctx)
  10982. if err != nil {
  10983. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  10984. }
  10985. return oldValue.ConditionOperator, nil
  10986. }
  10987. // AddConditionOperator adds i to the "condition_operator" field.
  10988. func (m *SopStageMutation) AddConditionOperator(i int) {
  10989. if m.addcondition_operator != nil {
  10990. *m.addcondition_operator += i
  10991. } else {
  10992. m.addcondition_operator = &i
  10993. }
  10994. }
  10995. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  10996. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  10997. v := m.addcondition_operator
  10998. if v == nil {
  10999. return
  11000. }
  11001. return *v, true
  11002. }
  11003. // ResetConditionOperator resets all changes to the "condition_operator" field.
  11004. func (m *SopStageMutation) ResetConditionOperator() {
  11005. m.condition_operator = nil
  11006. m.addcondition_operator = nil
  11007. }
  11008. // SetConditionList sets the "condition_list" field.
  11009. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  11010. m.condition_list = &ct
  11011. m.appendcondition_list = nil
  11012. }
  11013. // ConditionList returns the value of the "condition_list" field in the mutation.
  11014. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  11015. v := m.condition_list
  11016. if v == nil {
  11017. return
  11018. }
  11019. return *v, true
  11020. }
  11021. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  11022. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11023. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11024. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  11025. if !m.op.Is(OpUpdateOne) {
  11026. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  11027. }
  11028. if m.id == nil || m.oldValue == nil {
  11029. return v, errors.New("OldConditionList requires an ID field in the mutation")
  11030. }
  11031. oldValue, err := m.oldValue(ctx)
  11032. if err != nil {
  11033. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  11034. }
  11035. return oldValue.ConditionList, nil
  11036. }
  11037. // AppendConditionList adds ct to the "condition_list" field.
  11038. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  11039. m.appendcondition_list = append(m.appendcondition_list, ct...)
  11040. }
  11041. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  11042. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  11043. if len(m.appendcondition_list) == 0 {
  11044. return nil, false
  11045. }
  11046. return m.appendcondition_list, true
  11047. }
  11048. // ResetConditionList resets all changes to the "condition_list" field.
  11049. func (m *SopStageMutation) ResetConditionList() {
  11050. m.condition_list = nil
  11051. m.appendcondition_list = nil
  11052. }
  11053. // SetActionMessage sets the "action_message" field.
  11054. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  11055. m.action_message = &ct
  11056. m.appendaction_message = nil
  11057. }
  11058. // ActionMessage returns the value of the "action_message" field in the mutation.
  11059. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  11060. v := m.action_message
  11061. if v == nil {
  11062. return
  11063. }
  11064. return *v, true
  11065. }
  11066. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  11067. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11069. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  11070. if !m.op.Is(OpUpdateOne) {
  11071. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  11072. }
  11073. if m.id == nil || m.oldValue == nil {
  11074. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  11075. }
  11076. oldValue, err := m.oldValue(ctx)
  11077. if err != nil {
  11078. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  11079. }
  11080. return oldValue.ActionMessage, nil
  11081. }
  11082. // AppendActionMessage adds ct to the "action_message" field.
  11083. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  11084. m.appendaction_message = append(m.appendaction_message, ct...)
  11085. }
  11086. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  11087. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  11088. if len(m.appendaction_message) == 0 {
  11089. return nil, false
  11090. }
  11091. return m.appendaction_message, true
  11092. }
  11093. // ClearActionMessage clears the value of the "action_message" field.
  11094. func (m *SopStageMutation) ClearActionMessage() {
  11095. m.action_message = nil
  11096. m.appendaction_message = nil
  11097. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  11098. }
  11099. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  11100. func (m *SopStageMutation) ActionMessageCleared() bool {
  11101. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  11102. return ok
  11103. }
  11104. // ResetActionMessage resets all changes to the "action_message" field.
  11105. func (m *SopStageMutation) ResetActionMessage() {
  11106. m.action_message = nil
  11107. m.appendaction_message = nil
  11108. delete(m.clearedFields, sopstage.FieldActionMessage)
  11109. }
  11110. // SetActionLabel sets the "action_label" field.
  11111. func (m *SopStageMutation) SetActionLabel(u []uint64) {
  11112. m.action_label = &u
  11113. m.appendaction_label = nil
  11114. }
  11115. // ActionLabel returns the value of the "action_label" field in the mutation.
  11116. func (m *SopStageMutation) ActionLabel() (r []uint64, exists bool) {
  11117. v := m.action_label
  11118. if v == nil {
  11119. return
  11120. }
  11121. return *v, true
  11122. }
  11123. // OldActionLabel returns the old "action_label" 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) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  11127. if !m.op.Is(OpUpdateOne) {
  11128. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  11129. }
  11130. if m.id == nil || m.oldValue == nil {
  11131. return v, errors.New("OldActionLabel 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 OldActionLabel: %w", err)
  11136. }
  11137. return oldValue.ActionLabel, nil
  11138. }
  11139. // AppendActionLabel adds u to the "action_label" field.
  11140. func (m *SopStageMutation) AppendActionLabel(u []uint64) {
  11141. m.appendaction_label = append(m.appendaction_label, u...)
  11142. }
  11143. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  11144. func (m *SopStageMutation) AppendedActionLabel() ([]uint64, bool) {
  11145. if len(m.appendaction_label) == 0 {
  11146. return nil, false
  11147. }
  11148. return m.appendaction_label, true
  11149. }
  11150. // ClearActionLabel clears the value of the "action_label" field.
  11151. func (m *SopStageMutation) ClearActionLabel() {
  11152. m.action_label = nil
  11153. m.appendaction_label = nil
  11154. m.clearedFields[sopstage.FieldActionLabel] = struct{}{}
  11155. }
  11156. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  11157. func (m *SopStageMutation) ActionLabelCleared() bool {
  11158. _, ok := m.clearedFields[sopstage.FieldActionLabel]
  11159. return ok
  11160. }
  11161. // ResetActionLabel resets all changes to the "action_label" field.
  11162. func (m *SopStageMutation) ResetActionLabel() {
  11163. m.action_label = nil
  11164. m.appendaction_label = nil
  11165. delete(m.clearedFields, sopstage.FieldActionLabel)
  11166. }
  11167. // SetIndexSort sets the "index_sort" field.
  11168. func (m *SopStageMutation) SetIndexSort(i int) {
  11169. m.index_sort = &i
  11170. m.addindex_sort = nil
  11171. }
  11172. // IndexSort returns the value of the "index_sort" field in the mutation.
  11173. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  11174. v := m.index_sort
  11175. if v == nil {
  11176. return
  11177. }
  11178. return *v, true
  11179. }
  11180. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  11181. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11183. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  11184. if !m.op.Is(OpUpdateOne) {
  11185. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  11186. }
  11187. if m.id == nil || m.oldValue == nil {
  11188. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  11189. }
  11190. oldValue, err := m.oldValue(ctx)
  11191. if err != nil {
  11192. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  11193. }
  11194. return oldValue.IndexSort, nil
  11195. }
  11196. // AddIndexSort adds i to the "index_sort" field.
  11197. func (m *SopStageMutation) AddIndexSort(i int) {
  11198. if m.addindex_sort != nil {
  11199. *m.addindex_sort += i
  11200. } else {
  11201. m.addindex_sort = &i
  11202. }
  11203. }
  11204. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  11205. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  11206. v := m.addindex_sort
  11207. if v == nil {
  11208. return
  11209. }
  11210. return *v, true
  11211. }
  11212. // ClearIndexSort clears the value of the "index_sort" field.
  11213. func (m *SopStageMutation) ClearIndexSort() {
  11214. m.index_sort = nil
  11215. m.addindex_sort = nil
  11216. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  11217. }
  11218. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  11219. func (m *SopStageMutation) IndexSortCleared() bool {
  11220. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  11221. return ok
  11222. }
  11223. // ResetIndexSort resets all changes to the "index_sort" field.
  11224. func (m *SopStageMutation) ResetIndexSort() {
  11225. m.index_sort = nil
  11226. m.addindex_sort = nil
  11227. delete(m.clearedFields, sopstage.FieldIndexSort)
  11228. }
  11229. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  11230. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  11231. m.sop_task = &id
  11232. }
  11233. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  11234. func (m *SopStageMutation) ClearSopTask() {
  11235. m.clearedsop_task = true
  11236. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  11237. }
  11238. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  11239. func (m *SopStageMutation) SopTaskCleared() bool {
  11240. return m.clearedsop_task
  11241. }
  11242. // SopTaskID returns the "sop_task" edge ID in the mutation.
  11243. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  11244. if m.sop_task != nil {
  11245. return *m.sop_task, true
  11246. }
  11247. return
  11248. }
  11249. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  11250. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  11251. // SopTaskID instead. It exists only for internal usage by the builders.
  11252. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  11253. if id := m.sop_task; id != nil {
  11254. ids = append(ids, *id)
  11255. }
  11256. return
  11257. }
  11258. // ResetSopTask resets all changes to the "sop_task" edge.
  11259. func (m *SopStageMutation) ResetSopTask() {
  11260. m.sop_task = nil
  11261. m.clearedsop_task = false
  11262. }
  11263. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  11264. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  11265. if m.stage_nodes == nil {
  11266. m.stage_nodes = make(map[uint64]struct{})
  11267. }
  11268. for i := range ids {
  11269. m.stage_nodes[ids[i]] = struct{}{}
  11270. }
  11271. }
  11272. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  11273. func (m *SopStageMutation) ClearStageNodes() {
  11274. m.clearedstage_nodes = true
  11275. }
  11276. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  11277. func (m *SopStageMutation) StageNodesCleared() bool {
  11278. return m.clearedstage_nodes
  11279. }
  11280. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  11281. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  11282. if m.removedstage_nodes == nil {
  11283. m.removedstage_nodes = make(map[uint64]struct{})
  11284. }
  11285. for i := range ids {
  11286. delete(m.stage_nodes, ids[i])
  11287. m.removedstage_nodes[ids[i]] = struct{}{}
  11288. }
  11289. }
  11290. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  11291. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  11292. for id := range m.removedstage_nodes {
  11293. ids = append(ids, id)
  11294. }
  11295. return
  11296. }
  11297. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  11298. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  11299. for id := range m.stage_nodes {
  11300. ids = append(ids, id)
  11301. }
  11302. return
  11303. }
  11304. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  11305. func (m *SopStageMutation) ResetStageNodes() {
  11306. m.stage_nodes = nil
  11307. m.clearedstage_nodes = false
  11308. m.removedstage_nodes = nil
  11309. }
  11310. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  11311. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  11312. if m.stage_messages == nil {
  11313. m.stage_messages = make(map[uint64]struct{})
  11314. }
  11315. for i := range ids {
  11316. m.stage_messages[ids[i]] = struct{}{}
  11317. }
  11318. }
  11319. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  11320. func (m *SopStageMutation) ClearStageMessages() {
  11321. m.clearedstage_messages = true
  11322. }
  11323. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  11324. func (m *SopStageMutation) StageMessagesCleared() bool {
  11325. return m.clearedstage_messages
  11326. }
  11327. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  11328. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  11329. if m.removedstage_messages == nil {
  11330. m.removedstage_messages = make(map[uint64]struct{})
  11331. }
  11332. for i := range ids {
  11333. delete(m.stage_messages, ids[i])
  11334. m.removedstage_messages[ids[i]] = struct{}{}
  11335. }
  11336. }
  11337. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  11338. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  11339. for id := range m.removedstage_messages {
  11340. ids = append(ids, id)
  11341. }
  11342. return
  11343. }
  11344. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  11345. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  11346. for id := range m.stage_messages {
  11347. ids = append(ids, id)
  11348. }
  11349. return
  11350. }
  11351. // ResetStageMessages resets all changes to the "stage_messages" edge.
  11352. func (m *SopStageMutation) ResetStageMessages() {
  11353. m.stage_messages = nil
  11354. m.clearedstage_messages = false
  11355. m.removedstage_messages = nil
  11356. }
  11357. // Where appends a list predicates to the SopStageMutation builder.
  11358. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  11359. m.predicates = append(m.predicates, ps...)
  11360. }
  11361. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  11362. // users can use type-assertion to append predicates that do not depend on any generated package.
  11363. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  11364. p := make([]predicate.SopStage, len(ps))
  11365. for i := range ps {
  11366. p[i] = ps[i]
  11367. }
  11368. m.Where(p...)
  11369. }
  11370. // Op returns the operation name.
  11371. func (m *SopStageMutation) Op() Op {
  11372. return m.op
  11373. }
  11374. // SetOp allows setting the mutation operation.
  11375. func (m *SopStageMutation) SetOp(op Op) {
  11376. m.op = op
  11377. }
  11378. // Type returns the node type of this mutation (SopStage).
  11379. func (m *SopStageMutation) Type() string {
  11380. return m.typ
  11381. }
  11382. // Fields returns all fields that were changed during this mutation. Note that in
  11383. // order to get all numeric fields that were incremented/decremented, call
  11384. // AddedFields().
  11385. func (m *SopStageMutation) Fields() []string {
  11386. fields := make([]string, 0, 12)
  11387. if m.created_at != nil {
  11388. fields = append(fields, sopstage.FieldCreatedAt)
  11389. }
  11390. if m.updated_at != nil {
  11391. fields = append(fields, sopstage.FieldUpdatedAt)
  11392. }
  11393. if m.status != nil {
  11394. fields = append(fields, sopstage.FieldStatus)
  11395. }
  11396. if m.deleted_at != nil {
  11397. fields = append(fields, sopstage.FieldDeletedAt)
  11398. }
  11399. if m.sop_task != nil {
  11400. fields = append(fields, sopstage.FieldTaskID)
  11401. }
  11402. if m.name != nil {
  11403. fields = append(fields, sopstage.FieldName)
  11404. }
  11405. if m.condition_type != nil {
  11406. fields = append(fields, sopstage.FieldConditionType)
  11407. }
  11408. if m.condition_operator != nil {
  11409. fields = append(fields, sopstage.FieldConditionOperator)
  11410. }
  11411. if m.condition_list != nil {
  11412. fields = append(fields, sopstage.FieldConditionList)
  11413. }
  11414. if m.action_message != nil {
  11415. fields = append(fields, sopstage.FieldActionMessage)
  11416. }
  11417. if m.action_label != nil {
  11418. fields = append(fields, sopstage.FieldActionLabel)
  11419. }
  11420. if m.index_sort != nil {
  11421. fields = append(fields, sopstage.FieldIndexSort)
  11422. }
  11423. return fields
  11424. }
  11425. // Field returns the value of a field with the given name. The second boolean
  11426. // return value indicates that this field was not set, or was not defined in the
  11427. // schema.
  11428. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  11429. switch name {
  11430. case sopstage.FieldCreatedAt:
  11431. return m.CreatedAt()
  11432. case sopstage.FieldUpdatedAt:
  11433. return m.UpdatedAt()
  11434. case sopstage.FieldStatus:
  11435. return m.Status()
  11436. case sopstage.FieldDeletedAt:
  11437. return m.DeletedAt()
  11438. case sopstage.FieldTaskID:
  11439. return m.TaskID()
  11440. case sopstage.FieldName:
  11441. return m.Name()
  11442. case sopstage.FieldConditionType:
  11443. return m.ConditionType()
  11444. case sopstage.FieldConditionOperator:
  11445. return m.ConditionOperator()
  11446. case sopstage.FieldConditionList:
  11447. return m.ConditionList()
  11448. case sopstage.FieldActionMessage:
  11449. return m.ActionMessage()
  11450. case sopstage.FieldActionLabel:
  11451. return m.ActionLabel()
  11452. case sopstage.FieldIndexSort:
  11453. return m.IndexSort()
  11454. }
  11455. return nil, false
  11456. }
  11457. // OldField returns the old value of the field from the database. An error is
  11458. // returned if the mutation operation is not UpdateOne, or the query to the
  11459. // database failed.
  11460. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11461. switch name {
  11462. case sopstage.FieldCreatedAt:
  11463. return m.OldCreatedAt(ctx)
  11464. case sopstage.FieldUpdatedAt:
  11465. return m.OldUpdatedAt(ctx)
  11466. case sopstage.FieldStatus:
  11467. return m.OldStatus(ctx)
  11468. case sopstage.FieldDeletedAt:
  11469. return m.OldDeletedAt(ctx)
  11470. case sopstage.FieldTaskID:
  11471. return m.OldTaskID(ctx)
  11472. case sopstage.FieldName:
  11473. return m.OldName(ctx)
  11474. case sopstage.FieldConditionType:
  11475. return m.OldConditionType(ctx)
  11476. case sopstage.FieldConditionOperator:
  11477. return m.OldConditionOperator(ctx)
  11478. case sopstage.FieldConditionList:
  11479. return m.OldConditionList(ctx)
  11480. case sopstage.FieldActionMessage:
  11481. return m.OldActionMessage(ctx)
  11482. case sopstage.FieldActionLabel:
  11483. return m.OldActionLabel(ctx)
  11484. case sopstage.FieldIndexSort:
  11485. return m.OldIndexSort(ctx)
  11486. }
  11487. return nil, fmt.Errorf("unknown SopStage field %s", name)
  11488. }
  11489. // SetField sets the value of a field with the given name. It returns an error if
  11490. // the field is not defined in the schema, or if the type mismatched the field
  11491. // type.
  11492. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  11493. switch name {
  11494. case sopstage.FieldCreatedAt:
  11495. v, ok := value.(time.Time)
  11496. if !ok {
  11497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11498. }
  11499. m.SetCreatedAt(v)
  11500. return nil
  11501. case sopstage.FieldUpdatedAt:
  11502. v, ok := value.(time.Time)
  11503. if !ok {
  11504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11505. }
  11506. m.SetUpdatedAt(v)
  11507. return nil
  11508. case sopstage.FieldStatus:
  11509. v, ok := value.(uint8)
  11510. if !ok {
  11511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11512. }
  11513. m.SetStatus(v)
  11514. return nil
  11515. case sopstage.FieldDeletedAt:
  11516. v, ok := value.(time.Time)
  11517. if !ok {
  11518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11519. }
  11520. m.SetDeletedAt(v)
  11521. return nil
  11522. case sopstage.FieldTaskID:
  11523. v, ok := value.(uint64)
  11524. if !ok {
  11525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11526. }
  11527. m.SetTaskID(v)
  11528. return nil
  11529. case sopstage.FieldName:
  11530. v, ok := value.(string)
  11531. if !ok {
  11532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11533. }
  11534. m.SetName(v)
  11535. return nil
  11536. case sopstage.FieldConditionType:
  11537. v, ok := value.(int)
  11538. if !ok {
  11539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11540. }
  11541. m.SetConditionType(v)
  11542. return nil
  11543. case sopstage.FieldConditionOperator:
  11544. v, ok := value.(int)
  11545. if !ok {
  11546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11547. }
  11548. m.SetConditionOperator(v)
  11549. return nil
  11550. case sopstage.FieldConditionList:
  11551. v, ok := value.([]custom_types.Condition)
  11552. if !ok {
  11553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11554. }
  11555. m.SetConditionList(v)
  11556. return nil
  11557. case sopstage.FieldActionMessage:
  11558. v, ok := value.([]custom_types.Action)
  11559. if !ok {
  11560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11561. }
  11562. m.SetActionMessage(v)
  11563. return nil
  11564. case sopstage.FieldActionLabel:
  11565. v, ok := value.([]uint64)
  11566. if !ok {
  11567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11568. }
  11569. m.SetActionLabel(v)
  11570. return nil
  11571. case sopstage.FieldIndexSort:
  11572. v, ok := value.(int)
  11573. if !ok {
  11574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11575. }
  11576. m.SetIndexSort(v)
  11577. return nil
  11578. }
  11579. return fmt.Errorf("unknown SopStage field %s", name)
  11580. }
  11581. // AddedFields returns all numeric fields that were incremented/decremented during
  11582. // this mutation.
  11583. func (m *SopStageMutation) AddedFields() []string {
  11584. var fields []string
  11585. if m.addstatus != nil {
  11586. fields = append(fields, sopstage.FieldStatus)
  11587. }
  11588. if m.addcondition_type != nil {
  11589. fields = append(fields, sopstage.FieldConditionType)
  11590. }
  11591. if m.addcondition_operator != nil {
  11592. fields = append(fields, sopstage.FieldConditionOperator)
  11593. }
  11594. if m.addindex_sort != nil {
  11595. fields = append(fields, sopstage.FieldIndexSort)
  11596. }
  11597. return fields
  11598. }
  11599. // AddedField returns the numeric value that was incremented/decremented on a field
  11600. // with the given name. The second boolean return value indicates that this field
  11601. // was not set, or was not defined in the schema.
  11602. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  11603. switch name {
  11604. case sopstage.FieldStatus:
  11605. return m.AddedStatus()
  11606. case sopstage.FieldConditionType:
  11607. return m.AddedConditionType()
  11608. case sopstage.FieldConditionOperator:
  11609. return m.AddedConditionOperator()
  11610. case sopstage.FieldIndexSort:
  11611. return m.AddedIndexSort()
  11612. }
  11613. return nil, false
  11614. }
  11615. // AddField adds the value to the field with the given name. It returns an error if
  11616. // the field is not defined in the schema, or if the type mismatched the field
  11617. // type.
  11618. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  11619. switch name {
  11620. case sopstage.FieldStatus:
  11621. v, ok := value.(int8)
  11622. if !ok {
  11623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11624. }
  11625. m.AddStatus(v)
  11626. return nil
  11627. case sopstage.FieldConditionType:
  11628. v, ok := value.(int)
  11629. if !ok {
  11630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11631. }
  11632. m.AddConditionType(v)
  11633. return nil
  11634. case sopstage.FieldConditionOperator:
  11635. v, ok := value.(int)
  11636. if !ok {
  11637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11638. }
  11639. m.AddConditionOperator(v)
  11640. return nil
  11641. case sopstage.FieldIndexSort:
  11642. v, ok := value.(int)
  11643. if !ok {
  11644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11645. }
  11646. m.AddIndexSort(v)
  11647. return nil
  11648. }
  11649. return fmt.Errorf("unknown SopStage numeric field %s", name)
  11650. }
  11651. // ClearedFields returns all nullable fields that were cleared during this
  11652. // mutation.
  11653. func (m *SopStageMutation) ClearedFields() []string {
  11654. var fields []string
  11655. if m.FieldCleared(sopstage.FieldStatus) {
  11656. fields = append(fields, sopstage.FieldStatus)
  11657. }
  11658. if m.FieldCleared(sopstage.FieldDeletedAt) {
  11659. fields = append(fields, sopstage.FieldDeletedAt)
  11660. }
  11661. if m.FieldCleared(sopstage.FieldActionMessage) {
  11662. fields = append(fields, sopstage.FieldActionMessage)
  11663. }
  11664. if m.FieldCleared(sopstage.FieldActionLabel) {
  11665. fields = append(fields, sopstage.FieldActionLabel)
  11666. }
  11667. if m.FieldCleared(sopstage.FieldIndexSort) {
  11668. fields = append(fields, sopstage.FieldIndexSort)
  11669. }
  11670. return fields
  11671. }
  11672. // FieldCleared returns a boolean indicating if a field with the given name was
  11673. // cleared in this mutation.
  11674. func (m *SopStageMutation) FieldCleared(name string) bool {
  11675. _, ok := m.clearedFields[name]
  11676. return ok
  11677. }
  11678. // ClearField clears the value of the field with the given name. It returns an
  11679. // error if the field is not defined in the schema.
  11680. func (m *SopStageMutation) ClearField(name string) error {
  11681. switch name {
  11682. case sopstage.FieldStatus:
  11683. m.ClearStatus()
  11684. return nil
  11685. case sopstage.FieldDeletedAt:
  11686. m.ClearDeletedAt()
  11687. return nil
  11688. case sopstage.FieldActionMessage:
  11689. m.ClearActionMessage()
  11690. return nil
  11691. case sopstage.FieldActionLabel:
  11692. m.ClearActionLabel()
  11693. return nil
  11694. case sopstage.FieldIndexSort:
  11695. m.ClearIndexSort()
  11696. return nil
  11697. }
  11698. return fmt.Errorf("unknown SopStage nullable field %s", name)
  11699. }
  11700. // ResetField resets all changes in the mutation for the field with the given name.
  11701. // It returns an error if the field is not defined in the schema.
  11702. func (m *SopStageMutation) ResetField(name string) error {
  11703. switch name {
  11704. case sopstage.FieldCreatedAt:
  11705. m.ResetCreatedAt()
  11706. return nil
  11707. case sopstage.FieldUpdatedAt:
  11708. m.ResetUpdatedAt()
  11709. return nil
  11710. case sopstage.FieldStatus:
  11711. m.ResetStatus()
  11712. return nil
  11713. case sopstage.FieldDeletedAt:
  11714. m.ResetDeletedAt()
  11715. return nil
  11716. case sopstage.FieldTaskID:
  11717. m.ResetTaskID()
  11718. return nil
  11719. case sopstage.FieldName:
  11720. m.ResetName()
  11721. return nil
  11722. case sopstage.FieldConditionType:
  11723. m.ResetConditionType()
  11724. return nil
  11725. case sopstage.FieldConditionOperator:
  11726. m.ResetConditionOperator()
  11727. return nil
  11728. case sopstage.FieldConditionList:
  11729. m.ResetConditionList()
  11730. return nil
  11731. case sopstage.FieldActionMessage:
  11732. m.ResetActionMessage()
  11733. return nil
  11734. case sopstage.FieldActionLabel:
  11735. m.ResetActionLabel()
  11736. return nil
  11737. case sopstage.FieldIndexSort:
  11738. m.ResetIndexSort()
  11739. return nil
  11740. }
  11741. return fmt.Errorf("unknown SopStage field %s", name)
  11742. }
  11743. // AddedEdges returns all edge names that were set/added in this mutation.
  11744. func (m *SopStageMutation) AddedEdges() []string {
  11745. edges := make([]string, 0, 3)
  11746. if m.sop_task != nil {
  11747. edges = append(edges, sopstage.EdgeSopTask)
  11748. }
  11749. if m.stage_nodes != nil {
  11750. edges = append(edges, sopstage.EdgeStageNodes)
  11751. }
  11752. if m.stage_messages != nil {
  11753. edges = append(edges, sopstage.EdgeStageMessages)
  11754. }
  11755. return edges
  11756. }
  11757. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11758. // name in this mutation.
  11759. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  11760. switch name {
  11761. case sopstage.EdgeSopTask:
  11762. if id := m.sop_task; id != nil {
  11763. return []ent.Value{*id}
  11764. }
  11765. case sopstage.EdgeStageNodes:
  11766. ids := make([]ent.Value, 0, len(m.stage_nodes))
  11767. for id := range m.stage_nodes {
  11768. ids = append(ids, id)
  11769. }
  11770. return ids
  11771. case sopstage.EdgeStageMessages:
  11772. ids := make([]ent.Value, 0, len(m.stage_messages))
  11773. for id := range m.stage_messages {
  11774. ids = append(ids, id)
  11775. }
  11776. return ids
  11777. }
  11778. return nil
  11779. }
  11780. // RemovedEdges returns all edge names that were removed in this mutation.
  11781. func (m *SopStageMutation) RemovedEdges() []string {
  11782. edges := make([]string, 0, 3)
  11783. if m.removedstage_nodes != nil {
  11784. edges = append(edges, sopstage.EdgeStageNodes)
  11785. }
  11786. if m.removedstage_messages != nil {
  11787. edges = append(edges, sopstage.EdgeStageMessages)
  11788. }
  11789. return edges
  11790. }
  11791. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11792. // the given name in this mutation.
  11793. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  11794. switch name {
  11795. case sopstage.EdgeStageNodes:
  11796. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  11797. for id := range m.removedstage_nodes {
  11798. ids = append(ids, id)
  11799. }
  11800. return ids
  11801. case sopstage.EdgeStageMessages:
  11802. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  11803. for id := range m.removedstage_messages {
  11804. ids = append(ids, id)
  11805. }
  11806. return ids
  11807. }
  11808. return nil
  11809. }
  11810. // ClearedEdges returns all edge names that were cleared in this mutation.
  11811. func (m *SopStageMutation) ClearedEdges() []string {
  11812. edges := make([]string, 0, 3)
  11813. if m.clearedsop_task {
  11814. edges = append(edges, sopstage.EdgeSopTask)
  11815. }
  11816. if m.clearedstage_nodes {
  11817. edges = append(edges, sopstage.EdgeStageNodes)
  11818. }
  11819. if m.clearedstage_messages {
  11820. edges = append(edges, sopstage.EdgeStageMessages)
  11821. }
  11822. return edges
  11823. }
  11824. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11825. // was cleared in this mutation.
  11826. func (m *SopStageMutation) EdgeCleared(name string) bool {
  11827. switch name {
  11828. case sopstage.EdgeSopTask:
  11829. return m.clearedsop_task
  11830. case sopstage.EdgeStageNodes:
  11831. return m.clearedstage_nodes
  11832. case sopstage.EdgeStageMessages:
  11833. return m.clearedstage_messages
  11834. }
  11835. return false
  11836. }
  11837. // ClearEdge clears the value of the edge with the given name. It returns an error
  11838. // if that edge is not defined in the schema.
  11839. func (m *SopStageMutation) ClearEdge(name string) error {
  11840. switch name {
  11841. case sopstage.EdgeSopTask:
  11842. m.ClearSopTask()
  11843. return nil
  11844. }
  11845. return fmt.Errorf("unknown SopStage unique edge %s", name)
  11846. }
  11847. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11848. // It returns an error if the edge is not defined in the schema.
  11849. func (m *SopStageMutation) ResetEdge(name string) error {
  11850. switch name {
  11851. case sopstage.EdgeSopTask:
  11852. m.ResetSopTask()
  11853. return nil
  11854. case sopstage.EdgeStageNodes:
  11855. m.ResetStageNodes()
  11856. return nil
  11857. case sopstage.EdgeStageMessages:
  11858. m.ResetStageMessages()
  11859. return nil
  11860. }
  11861. return fmt.Errorf("unknown SopStage edge %s", name)
  11862. }
  11863. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  11864. type SopTaskMutation struct {
  11865. config
  11866. op Op
  11867. typ string
  11868. id *uint64
  11869. created_at *time.Time
  11870. updated_at *time.Time
  11871. status *uint8
  11872. addstatus *int8
  11873. deleted_at *time.Time
  11874. name *string
  11875. bot_wxid_list *[]string
  11876. appendbot_wxid_list []string
  11877. _type *int
  11878. add_type *int
  11879. plan_start_time *time.Time
  11880. plan_end_time *time.Time
  11881. creator_id *string
  11882. organization_id *uint64
  11883. addorganization_id *int64
  11884. clearedFields map[string]struct{}
  11885. task_stages map[uint64]struct{}
  11886. removedtask_stages map[uint64]struct{}
  11887. clearedtask_stages bool
  11888. done bool
  11889. oldValue func(context.Context) (*SopTask, error)
  11890. predicates []predicate.SopTask
  11891. }
  11892. var _ ent.Mutation = (*SopTaskMutation)(nil)
  11893. // soptaskOption allows management of the mutation configuration using functional options.
  11894. type soptaskOption func(*SopTaskMutation)
  11895. // newSopTaskMutation creates new mutation for the SopTask entity.
  11896. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  11897. m := &SopTaskMutation{
  11898. config: c,
  11899. op: op,
  11900. typ: TypeSopTask,
  11901. clearedFields: make(map[string]struct{}),
  11902. }
  11903. for _, opt := range opts {
  11904. opt(m)
  11905. }
  11906. return m
  11907. }
  11908. // withSopTaskID sets the ID field of the mutation.
  11909. func withSopTaskID(id uint64) soptaskOption {
  11910. return func(m *SopTaskMutation) {
  11911. var (
  11912. err error
  11913. once sync.Once
  11914. value *SopTask
  11915. )
  11916. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  11917. once.Do(func() {
  11918. if m.done {
  11919. err = errors.New("querying old values post mutation is not allowed")
  11920. } else {
  11921. value, err = m.Client().SopTask.Get(ctx, id)
  11922. }
  11923. })
  11924. return value, err
  11925. }
  11926. m.id = &id
  11927. }
  11928. }
  11929. // withSopTask sets the old SopTask of the mutation.
  11930. func withSopTask(node *SopTask) soptaskOption {
  11931. return func(m *SopTaskMutation) {
  11932. m.oldValue = func(context.Context) (*SopTask, error) {
  11933. return node, nil
  11934. }
  11935. m.id = &node.ID
  11936. }
  11937. }
  11938. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11939. // executed in a transaction (ent.Tx), a transactional client is returned.
  11940. func (m SopTaskMutation) Client() *Client {
  11941. client := &Client{config: m.config}
  11942. client.init()
  11943. return client
  11944. }
  11945. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11946. // it returns an error otherwise.
  11947. func (m SopTaskMutation) Tx() (*Tx, error) {
  11948. if _, ok := m.driver.(*txDriver); !ok {
  11949. return nil, errors.New("ent: mutation is not running in a transaction")
  11950. }
  11951. tx := &Tx{config: m.config}
  11952. tx.init()
  11953. return tx, nil
  11954. }
  11955. // SetID sets the value of the id field. Note that this
  11956. // operation is only accepted on creation of SopTask entities.
  11957. func (m *SopTaskMutation) SetID(id uint64) {
  11958. m.id = &id
  11959. }
  11960. // ID returns the ID value in the mutation. Note that the ID is only available
  11961. // if it was provided to the builder or after it was returned from the database.
  11962. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  11963. if m.id == nil {
  11964. return
  11965. }
  11966. return *m.id, true
  11967. }
  11968. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11969. // That means, if the mutation is applied within a transaction with an isolation level such
  11970. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11971. // or updated by the mutation.
  11972. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  11973. switch {
  11974. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11975. id, exists := m.ID()
  11976. if exists {
  11977. return []uint64{id}, nil
  11978. }
  11979. fallthrough
  11980. case m.op.Is(OpUpdate | OpDelete):
  11981. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  11982. default:
  11983. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11984. }
  11985. }
  11986. // SetCreatedAt sets the "created_at" field.
  11987. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  11988. m.created_at = &t
  11989. }
  11990. // CreatedAt returns the value of the "created_at" field in the mutation.
  11991. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  11992. v := m.created_at
  11993. if v == nil {
  11994. return
  11995. }
  11996. return *v, true
  11997. }
  11998. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  11999. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12001. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12002. if !m.op.Is(OpUpdateOne) {
  12003. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12004. }
  12005. if m.id == nil || m.oldValue == nil {
  12006. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12007. }
  12008. oldValue, err := m.oldValue(ctx)
  12009. if err != nil {
  12010. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12011. }
  12012. return oldValue.CreatedAt, nil
  12013. }
  12014. // ResetCreatedAt resets all changes to the "created_at" field.
  12015. func (m *SopTaskMutation) ResetCreatedAt() {
  12016. m.created_at = nil
  12017. }
  12018. // SetUpdatedAt sets the "updated_at" field.
  12019. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  12020. m.updated_at = &t
  12021. }
  12022. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12023. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  12024. v := m.updated_at
  12025. if v == nil {
  12026. return
  12027. }
  12028. return *v, true
  12029. }
  12030. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  12031. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12032. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12033. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12034. if !m.op.Is(OpUpdateOne) {
  12035. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12036. }
  12037. if m.id == nil || m.oldValue == nil {
  12038. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12039. }
  12040. oldValue, err := m.oldValue(ctx)
  12041. if err != nil {
  12042. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12043. }
  12044. return oldValue.UpdatedAt, nil
  12045. }
  12046. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12047. func (m *SopTaskMutation) ResetUpdatedAt() {
  12048. m.updated_at = nil
  12049. }
  12050. // SetStatus sets the "status" field.
  12051. func (m *SopTaskMutation) SetStatus(u uint8) {
  12052. m.status = &u
  12053. m.addstatus = nil
  12054. }
  12055. // Status returns the value of the "status" field in the mutation.
  12056. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  12057. v := m.status
  12058. if v == nil {
  12059. return
  12060. }
  12061. return *v, true
  12062. }
  12063. // OldStatus returns the old "status" field's value of the SopTask entity.
  12064. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12066. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12067. if !m.op.Is(OpUpdateOne) {
  12068. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12069. }
  12070. if m.id == nil || m.oldValue == nil {
  12071. return v, errors.New("OldStatus requires an ID field in the mutation")
  12072. }
  12073. oldValue, err := m.oldValue(ctx)
  12074. if err != nil {
  12075. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12076. }
  12077. return oldValue.Status, nil
  12078. }
  12079. // AddStatus adds u to the "status" field.
  12080. func (m *SopTaskMutation) AddStatus(u int8) {
  12081. if m.addstatus != nil {
  12082. *m.addstatus += u
  12083. } else {
  12084. m.addstatus = &u
  12085. }
  12086. }
  12087. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12088. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  12089. v := m.addstatus
  12090. if v == nil {
  12091. return
  12092. }
  12093. return *v, true
  12094. }
  12095. // ClearStatus clears the value of the "status" field.
  12096. func (m *SopTaskMutation) ClearStatus() {
  12097. m.status = nil
  12098. m.addstatus = nil
  12099. m.clearedFields[soptask.FieldStatus] = struct{}{}
  12100. }
  12101. // StatusCleared returns if the "status" field was cleared in this mutation.
  12102. func (m *SopTaskMutation) StatusCleared() bool {
  12103. _, ok := m.clearedFields[soptask.FieldStatus]
  12104. return ok
  12105. }
  12106. // ResetStatus resets all changes to the "status" field.
  12107. func (m *SopTaskMutation) ResetStatus() {
  12108. m.status = nil
  12109. m.addstatus = nil
  12110. delete(m.clearedFields, soptask.FieldStatus)
  12111. }
  12112. // SetDeletedAt sets the "deleted_at" field.
  12113. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  12114. m.deleted_at = &t
  12115. }
  12116. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12117. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  12118. v := m.deleted_at
  12119. if v == nil {
  12120. return
  12121. }
  12122. return *v, true
  12123. }
  12124. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  12125. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12127. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12128. if !m.op.Is(OpUpdateOne) {
  12129. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12130. }
  12131. if m.id == nil || m.oldValue == nil {
  12132. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12133. }
  12134. oldValue, err := m.oldValue(ctx)
  12135. if err != nil {
  12136. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12137. }
  12138. return oldValue.DeletedAt, nil
  12139. }
  12140. // ClearDeletedAt clears the value of the "deleted_at" field.
  12141. func (m *SopTaskMutation) ClearDeletedAt() {
  12142. m.deleted_at = nil
  12143. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  12144. }
  12145. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12146. func (m *SopTaskMutation) DeletedAtCleared() bool {
  12147. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  12148. return ok
  12149. }
  12150. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12151. func (m *SopTaskMutation) ResetDeletedAt() {
  12152. m.deleted_at = nil
  12153. delete(m.clearedFields, soptask.FieldDeletedAt)
  12154. }
  12155. // SetName sets the "name" field.
  12156. func (m *SopTaskMutation) SetName(s string) {
  12157. m.name = &s
  12158. }
  12159. // Name returns the value of the "name" field in the mutation.
  12160. func (m *SopTaskMutation) Name() (r string, exists bool) {
  12161. v := m.name
  12162. if v == nil {
  12163. return
  12164. }
  12165. return *v, true
  12166. }
  12167. // OldName returns the old "name" field's value of the SopTask entity.
  12168. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12170. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  12171. if !m.op.Is(OpUpdateOne) {
  12172. return v, errors.New("OldName is only allowed on UpdateOne operations")
  12173. }
  12174. if m.id == nil || m.oldValue == nil {
  12175. return v, errors.New("OldName requires an ID field in the mutation")
  12176. }
  12177. oldValue, err := m.oldValue(ctx)
  12178. if err != nil {
  12179. return v, fmt.Errorf("querying old value for OldName: %w", err)
  12180. }
  12181. return oldValue.Name, nil
  12182. }
  12183. // ResetName resets all changes to the "name" field.
  12184. func (m *SopTaskMutation) ResetName() {
  12185. m.name = nil
  12186. }
  12187. // SetBotWxidList sets the "bot_wxid_list" field.
  12188. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  12189. m.bot_wxid_list = &s
  12190. m.appendbot_wxid_list = nil
  12191. }
  12192. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  12193. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  12194. v := m.bot_wxid_list
  12195. if v == nil {
  12196. return
  12197. }
  12198. return *v, true
  12199. }
  12200. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  12201. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12203. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  12204. if !m.op.Is(OpUpdateOne) {
  12205. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  12206. }
  12207. if m.id == nil || m.oldValue == nil {
  12208. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  12209. }
  12210. oldValue, err := m.oldValue(ctx)
  12211. if err != nil {
  12212. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  12213. }
  12214. return oldValue.BotWxidList, nil
  12215. }
  12216. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  12217. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  12218. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  12219. }
  12220. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  12221. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  12222. if len(m.appendbot_wxid_list) == 0 {
  12223. return nil, false
  12224. }
  12225. return m.appendbot_wxid_list, true
  12226. }
  12227. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  12228. func (m *SopTaskMutation) ClearBotWxidList() {
  12229. m.bot_wxid_list = nil
  12230. m.appendbot_wxid_list = nil
  12231. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  12232. }
  12233. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  12234. func (m *SopTaskMutation) BotWxidListCleared() bool {
  12235. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  12236. return ok
  12237. }
  12238. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  12239. func (m *SopTaskMutation) ResetBotWxidList() {
  12240. m.bot_wxid_list = nil
  12241. m.appendbot_wxid_list = nil
  12242. delete(m.clearedFields, soptask.FieldBotWxidList)
  12243. }
  12244. // SetType sets the "type" field.
  12245. func (m *SopTaskMutation) SetType(i int) {
  12246. m._type = &i
  12247. m.add_type = nil
  12248. }
  12249. // GetType returns the value of the "type" field in the mutation.
  12250. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  12251. v := m._type
  12252. if v == nil {
  12253. return
  12254. }
  12255. return *v, true
  12256. }
  12257. // OldType returns the old "type" field's value of the SopTask entity.
  12258. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12260. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  12261. if !m.op.Is(OpUpdateOne) {
  12262. return v, errors.New("OldType is only allowed on UpdateOne operations")
  12263. }
  12264. if m.id == nil || m.oldValue == nil {
  12265. return v, errors.New("OldType requires an ID field in the mutation")
  12266. }
  12267. oldValue, err := m.oldValue(ctx)
  12268. if err != nil {
  12269. return v, fmt.Errorf("querying old value for OldType: %w", err)
  12270. }
  12271. return oldValue.Type, nil
  12272. }
  12273. // AddType adds i to the "type" field.
  12274. func (m *SopTaskMutation) AddType(i int) {
  12275. if m.add_type != nil {
  12276. *m.add_type += i
  12277. } else {
  12278. m.add_type = &i
  12279. }
  12280. }
  12281. // AddedType returns the value that was added to the "type" field in this mutation.
  12282. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  12283. v := m.add_type
  12284. if v == nil {
  12285. return
  12286. }
  12287. return *v, true
  12288. }
  12289. // ResetType resets all changes to the "type" field.
  12290. func (m *SopTaskMutation) ResetType() {
  12291. m._type = nil
  12292. m.add_type = nil
  12293. }
  12294. // SetPlanStartTime sets the "plan_start_time" field.
  12295. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  12296. m.plan_start_time = &t
  12297. }
  12298. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  12299. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  12300. v := m.plan_start_time
  12301. if v == nil {
  12302. return
  12303. }
  12304. return *v, true
  12305. }
  12306. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  12307. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12309. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  12310. if !m.op.Is(OpUpdateOne) {
  12311. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  12312. }
  12313. if m.id == nil || m.oldValue == nil {
  12314. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  12315. }
  12316. oldValue, err := m.oldValue(ctx)
  12317. if err != nil {
  12318. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  12319. }
  12320. return oldValue.PlanStartTime, nil
  12321. }
  12322. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  12323. func (m *SopTaskMutation) ClearPlanStartTime() {
  12324. m.plan_start_time = nil
  12325. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  12326. }
  12327. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  12328. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  12329. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  12330. return ok
  12331. }
  12332. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  12333. func (m *SopTaskMutation) ResetPlanStartTime() {
  12334. m.plan_start_time = nil
  12335. delete(m.clearedFields, soptask.FieldPlanStartTime)
  12336. }
  12337. // SetPlanEndTime sets the "plan_end_time" field.
  12338. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  12339. m.plan_end_time = &t
  12340. }
  12341. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  12342. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  12343. v := m.plan_end_time
  12344. if v == nil {
  12345. return
  12346. }
  12347. return *v, true
  12348. }
  12349. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  12350. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12352. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  12353. if !m.op.Is(OpUpdateOne) {
  12354. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  12355. }
  12356. if m.id == nil || m.oldValue == nil {
  12357. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  12358. }
  12359. oldValue, err := m.oldValue(ctx)
  12360. if err != nil {
  12361. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  12362. }
  12363. return oldValue.PlanEndTime, nil
  12364. }
  12365. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  12366. func (m *SopTaskMutation) ClearPlanEndTime() {
  12367. m.plan_end_time = nil
  12368. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  12369. }
  12370. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  12371. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  12372. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  12373. return ok
  12374. }
  12375. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  12376. func (m *SopTaskMutation) ResetPlanEndTime() {
  12377. m.plan_end_time = nil
  12378. delete(m.clearedFields, soptask.FieldPlanEndTime)
  12379. }
  12380. // SetCreatorID sets the "creator_id" field.
  12381. func (m *SopTaskMutation) SetCreatorID(s string) {
  12382. m.creator_id = &s
  12383. }
  12384. // CreatorID returns the value of the "creator_id" field in the mutation.
  12385. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  12386. v := m.creator_id
  12387. if v == nil {
  12388. return
  12389. }
  12390. return *v, true
  12391. }
  12392. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  12393. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12395. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  12396. if !m.op.Is(OpUpdateOne) {
  12397. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  12398. }
  12399. if m.id == nil || m.oldValue == nil {
  12400. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  12401. }
  12402. oldValue, err := m.oldValue(ctx)
  12403. if err != nil {
  12404. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  12405. }
  12406. return oldValue.CreatorID, nil
  12407. }
  12408. // ClearCreatorID clears the value of the "creator_id" field.
  12409. func (m *SopTaskMutation) ClearCreatorID() {
  12410. m.creator_id = nil
  12411. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  12412. }
  12413. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  12414. func (m *SopTaskMutation) CreatorIDCleared() bool {
  12415. _, ok := m.clearedFields[soptask.FieldCreatorID]
  12416. return ok
  12417. }
  12418. // ResetCreatorID resets all changes to the "creator_id" field.
  12419. func (m *SopTaskMutation) ResetCreatorID() {
  12420. m.creator_id = nil
  12421. delete(m.clearedFields, soptask.FieldCreatorID)
  12422. }
  12423. // SetOrganizationID sets the "organization_id" field.
  12424. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  12425. m.organization_id = &u
  12426. m.addorganization_id = nil
  12427. }
  12428. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12429. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  12430. v := m.organization_id
  12431. if v == nil {
  12432. return
  12433. }
  12434. return *v, true
  12435. }
  12436. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  12437. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12439. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12440. if !m.op.Is(OpUpdateOne) {
  12441. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12442. }
  12443. if m.id == nil || m.oldValue == nil {
  12444. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12445. }
  12446. oldValue, err := m.oldValue(ctx)
  12447. if err != nil {
  12448. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12449. }
  12450. return oldValue.OrganizationID, nil
  12451. }
  12452. // AddOrganizationID adds u to the "organization_id" field.
  12453. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  12454. if m.addorganization_id != nil {
  12455. *m.addorganization_id += u
  12456. } else {
  12457. m.addorganization_id = &u
  12458. }
  12459. }
  12460. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12461. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  12462. v := m.addorganization_id
  12463. if v == nil {
  12464. return
  12465. }
  12466. return *v, true
  12467. }
  12468. // ClearOrganizationID clears the value of the "organization_id" field.
  12469. func (m *SopTaskMutation) ClearOrganizationID() {
  12470. m.organization_id = nil
  12471. m.addorganization_id = nil
  12472. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  12473. }
  12474. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12475. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  12476. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  12477. return ok
  12478. }
  12479. // ResetOrganizationID resets all changes to the "organization_id" field.
  12480. func (m *SopTaskMutation) ResetOrganizationID() {
  12481. m.organization_id = nil
  12482. m.addorganization_id = nil
  12483. delete(m.clearedFields, soptask.FieldOrganizationID)
  12484. }
  12485. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  12486. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  12487. if m.task_stages == nil {
  12488. m.task_stages = make(map[uint64]struct{})
  12489. }
  12490. for i := range ids {
  12491. m.task_stages[ids[i]] = struct{}{}
  12492. }
  12493. }
  12494. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  12495. func (m *SopTaskMutation) ClearTaskStages() {
  12496. m.clearedtask_stages = true
  12497. }
  12498. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  12499. func (m *SopTaskMutation) TaskStagesCleared() bool {
  12500. return m.clearedtask_stages
  12501. }
  12502. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  12503. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  12504. if m.removedtask_stages == nil {
  12505. m.removedtask_stages = make(map[uint64]struct{})
  12506. }
  12507. for i := range ids {
  12508. delete(m.task_stages, ids[i])
  12509. m.removedtask_stages[ids[i]] = struct{}{}
  12510. }
  12511. }
  12512. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  12513. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  12514. for id := range m.removedtask_stages {
  12515. ids = append(ids, id)
  12516. }
  12517. return
  12518. }
  12519. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  12520. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  12521. for id := range m.task_stages {
  12522. ids = append(ids, id)
  12523. }
  12524. return
  12525. }
  12526. // ResetTaskStages resets all changes to the "task_stages" edge.
  12527. func (m *SopTaskMutation) ResetTaskStages() {
  12528. m.task_stages = nil
  12529. m.clearedtask_stages = false
  12530. m.removedtask_stages = nil
  12531. }
  12532. // Where appends a list predicates to the SopTaskMutation builder.
  12533. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  12534. m.predicates = append(m.predicates, ps...)
  12535. }
  12536. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  12537. // users can use type-assertion to append predicates that do not depend on any generated package.
  12538. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  12539. p := make([]predicate.SopTask, len(ps))
  12540. for i := range ps {
  12541. p[i] = ps[i]
  12542. }
  12543. m.Where(p...)
  12544. }
  12545. // Op returns the operation name.
  12546. func (m *SopTaskMutation) Op() Op {
  12547. return m.op
  12548. }
  12549. // SetOp allows setting the mutation operation.
  12550. func (m *SopTaskMutation) SetOp(op Op) {
  12551. m.op = op
  12552. }
  12553. // Type returns the node type of this mutation (SopTask).
  12554. func (m *SopTaskMutation) Type() string {
  12555. return m.typ
  12556. }
  12557. // Fields returns all fields that were changed during this mutation. Note that in
  12558. // order to get all numeric fields that were incremented/decremented, call
  12559. // AddedFields().
  12560. func (m *SopTaskMutation) Fields() []string {
  12561. fields := make([]string, 0, 11)
  12562. if m.created_at != nil {
  12563. fields = append(fields, soptask.FieldCreatedAt)
  12564. }
  12565. if m.updated_at != nil {
  12566. fields = append(fields, soptask.FieldUpdatedAt)
  12567. }
  12568. if m.status != nil {
  12569. fields = append(fields, soptask.FieldStatus)
  12570. }
  12571. if m.deleted_at != nil {
  12572. fields = append(fields, soptask.FieldDeletedAt)
  12573. }
  12574. if m.name != nil {
  12575. fields = append(fields, soptask.FieldName)
  12576. }
  12577. if m.bot_wxid_list != nil {
  12578. fields = append(fields, soptask.FieldBotWxidList)
  12579. }
  12580. if m._type != nil {
  12581. fields = append(fields, soptask.FieldType)
  12582. }
  12583. if m.plan_start_time != nil {
  12584. fields = append(fields, soptask.FieldPlanStartTime)
  12585. }
  12586. if m.plan_end_time != nil {
  12587. fields = append(fields, soptask.FieldPlanEndTime)
  12588. }
  12589. if m.creator_id != nil {
  12590. fields = append(fields, soptask.FieldCreatorID)
  12591. }
  12592. if m.organization_id != nil {
  12593. fields = append(fields, soptask.FieldOrganizationID)
  12594. }
  12595. return fields
  12596. }
  12597. // Field returns the value of a field with the given name. The second boolean
  12598. // return value indicates that this field was not set, or was not defined in the
  12599. // schema.
  12600. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  12601. switch name {
  12602. case soptask.FieldCreatedAt:
  12603. return m.CreatedAt()
  12604. case soptask.FieldUpdatedAt:
  12605. return m.UpdatedAt()
  12606. case soptask.FieldStatus:
  12607. return m.Status()
  12608. case soptask.FieldDeletedAt:
  12609. return m.DeletedAt()
  12610. case soptask.FieldName:
  12611. return m.Name()
  12612. case soptask.FieldBotWxidList:
  12613. return m.BotWxidList()
  12614. case soptask.FieldType:
  12615. return m.GetType()
  12616. case soptask.FieldPlanStartTime:
  12617. return m.PlanStartTime()
  12618. case soptask.FieldPlanEndTime:
  12619. return m.PlanEndTime()
  12620. case soptask.FieldCreatorID:
  12621. return m.CreatorID()
  12622. case soptask.FieldOrganizationID:
  12623. return m.OrganizationID()
  12624. }
  12625. return nil, false
  12626. }
  12627. // OldField returns the old value of the field from the database. An error is
  12628. // returned if the mutation operation is not UpdateOne, or the query to the
  12629. // database failed.
  12630. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12631. switch name {
  12632. case soptask.FieldCreatedAt:
  12633. return m.OldCreatedAt(ctx)
  12634. case soptask.FieldUpdatedAt:
  12635. return m.OldUpdatedAt(ctx)
  12636. case soptask.FieldStatus:
  12637. return m.OldStatus(ctx)
  12638. case soptask.FieldDeletedAt:
  12639. return m.OldDeletedAt(ctx)
  12640. case soptask.FieldName:
  12641. return m.OldName(ctx)
  12642. case soptask.FieldBotWxidList:
  12643. return m.OldBotWxidList(ctx)
  12644. case soptask.FieldType:
  12645. return m.OldType(ctx)
  12646. case soptask.FieldPlanStartTime:
  12647. return m.OldPlanStartTime(ctx)
  12648. case soptask.FieldPlanEndTime:
  12649. return m.OldPlanEndTime(ctx)
  12650. case soptask.FieldCreatorID:
  12651. return m.OldCreatorID(ctx)
  12652. case soptask.FieldOrganizationID:
  12653. return m.OldOrganizationID(ctx)
  12654. }
  12655. return nil, fmt.Errorf("unknown SopTask field %s", name)
  12656. }
  12657. // SetField sets the value of a field with the given name. It returns an error if
  12658. // the field is not defined in the schema, or if the type mismatched the field
  12659. // type.
  12660. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  12661. switch name {
  12662. case soptask.FieldCreatedAt:
  12663. v, ok := value.(time.Time)
  12664. if !ok {
  12665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12666. }
  12667. m.SetCreatedAt(v)
  12668. return nil
  12669. case soptask.FieldUpdatedAt:
  12670. v, ok := value.(time.Time)
  12671. if !ok {
  12672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12673. }
  12674. m.SetUpdatedAt(v)
  12675. return nil
  12676. case soptask.FieldStatus:
  12677. v, ok := value.(uint8)
  12678. if !ok {
  12679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12680. }
  12681. m.SetStatus(v)
  12682. return nil
  12683. case soptask.FieldDeletedAt:
  12684. v, ok := value.(time.Time)
  12685. if !ok {
  12686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12687. }
  12688. m.SetDeletedAt(v)
  12689. return nil
  12690. case soptask.FieldName:
  12691. v, ok := value.(string)
  12692. if !ok {
  12693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12694. }
  12695. m.SetName(v)
  12696. return nil
  12697. case soptask.FieldBotWxidList:
  12698. v, ok := value.([]string)
  12699. if !ok {
  12700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12701. }
  12702. m.SetBotWxidList(v)
  12703. return nil
  12704. case soptask.FieldType:
  12705. v, ok := value.(int)
  12706. if !ok {
  12707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12708. }
  12709. m.SetType(v)
  12710. return nil
  12711. case soptask.FieldPlanStartTime:
  12712. v, ok := value.(time.Time)
  12713. if !ok {
  12714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12715. }
  12716. m.SetPlanStartTime(v)
  12717. return nil
  12718. case soptask.FieldPlanEndTime:
  12719. v, ok := value.(time.Time)
  12720. if !ok {
  12721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12722. }
  12723. m.SetPlanEndTime(v)
  12724. return nil
  12725. case soptask.FieldCreatorID:
  12726. v, ok := value.(string)
  12727. if !ok {
  12728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12729. }
  12730. m.SetCreatorID(v)
  12731. return nil
  12732. case soptask.FieldOrganizationID:
  12733. v, ok := value.(uint64)
  12734. if !ok {
  12735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12736. }
  12737. m.SetOrganizationID(v)
  12738. return nil
  12739. }
  12740. return fmt.Errorf("unknown SopTask field %s", name)
  12741. }
  12742. // AddedFields returns all numeric fields that were incremented/decremented during
  12743. // this mutation.
  12744. func (m *SopTaskMutation) AddedFields() []string {
  12745. var fields []string
  12746. if m.addstatus != nil {
  12747. fields = append(fields, soptask.FieldStatus)
  12748. }
  12749. if m.add_type != nil {
  12750. fields = append(fields, soptask.FieldType)
  12751. }
  12752. if m.addorganization_id != nil {
  12753. fields = append(fields, soptask.FieldOrganizationID)
  12754. }
  12755. return fields
  12756. }
  12757. // AddedField returns the numeric value that was incremented/decremented on a field
  12758. // with the given name. The second boolean return value indicates that this field
  12759. // was not set, or was not defined in the schema.
  12760. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  12761. switch name {
  12762. case soptask.FieldStatus:
  12763. return m.AddedStatus()
  12764. case soptask.FieldType:
  12765. return m.AddedType()
  12766. case soptask.FieldOrganizationID:
  12767. return m.AddedOrganizationID()
  12768. }
  12769. return nil, false
  12770. }
  12771. // AddField adds the value to the field with the given name. It returns an error if
  12772. // the field is not defined in the schema, or if the type mismatched the field
  12773. // type.
  12774. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  12775. switch name {
  12776. case soptask.FieldStatus:
  12777. v, ok := value.(int8)
  12778. if !ok {
  12779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12780. }
  12781. m.AddStatus(v)
  12782. return nil
  12783. case soptask.FieldType:
  12784. v, ok := value.(int)
  12785. if !ok {
  12786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12787. }
  12788. m.AddType(v)
  12789. return nil
  12790. case soptask.FieldOrganizationID:
  12791. v, ok := value.(int64)
  12792. if !ok {
  12793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12794. }
  12795. m.AddOrganizationID(v)
  12796. return nil
  12797. }
  12798. return fmt.Errorf("unknown SopTask numeric field %s", name)
  12799. }
  12800. // ClearedFields returns all nullable fields that were cleared during this
  12801. // mutation.
  12802. func (m *SopTaskMutation) ClearedFields() []string {
  12803. var fields []string
  12804. if m.FieldCleared(soptask.FieldStatus) {
  12805. fields = append(fields, soptask.FieldStatus)
  12806. }
  12807. if m.FieldCleared(soptask.FieldDeletedAt) {
  12808. fields = append(fields, soptask.FieldDeletedAt)
  12809. }
  12810. if m.FieldCleared(soptask.FieldBotWxidList) {
  12811. fields = append(fields, soptask.FieldBotWxidList)
  12812. }
  12813. if m.FieldCleared(soptask.FieldPlanStartTime) {
  12814. fields = append(fields, soptask.FieldPlanStartTime)
  12815. }
  12816. if m.FieldCleared(soptask.FieldPlanEndTime) {
  12817. fields = append(fields, soptask.FieldPlanEndTime)
  12818. }
  12819. if m.FieldCleared(soptask.FieldCreatorID) {
  12820. fields = append(fields, soptask.FieldCreatorID)
  12821. }
  12822. if m.FieldCleared(soptask.FieldOrganizationID) {
  12823. fields = append(fields, soptask.FieldOrganizationID)
  12824. }
  12825. return fields
  12826. }
  12827. // FieldCleared returns a boolean indicating if a field with the given name was
  12828. // cleared in this mutation.
  12829. func (m *SopTaskMutation) FieldCleared(name string) bool {
  12830. _, ok := m.clearedFields[name]
  12831. return ok
  12832. }
  12833. // ClearField clears the value of the field with the given name. It returns an
  12834. // error if the field is not defined in the schema.
  12835. func (m *SopTaskMutation) ClearField(name string) error {
  12836. switch name {
  12837. case soptask.FieldStatus:
  12838. m.ClearStatus()
  12839. return nil
  12840. case soptask.FieldDeletedAt:
  12841. m.ClearDeletedAt()
  12842. return nil
  12843. case soptask.FieldBotWxidList:
  12844. m.ClearBotWxidList()
  12845. return nil
  12846. case soptask.FieldPlanStartTime:
  12847. m.ClearPlanStartTime()
  12848. return nil
  12849. case soptask.FieldPlanEndTime:
  12850. m.ClearPlanEndTime()
  12851. return nil
  12852. case soptask.FieldCreatorID:
  12853. m.ClearCreatorID()
  12854. return nil
  12855. case soptask.FieldOrganizationID:
  12856. m.ClearOrganizationID()
  12857. return nil
  12858. }
  12859. return fmt.Errorf("unknown SopTask nullable field %s", name)
  12860. }
  12861. // ResetField resets all changes in the mutation for the field with the given name.
  12862. // It returns an error if the field is not defined in the schema.
  12863. func (m *SopTaskMutation) ResetField(name string) error {
  12864. switch name {
  12865. case soptask.FieldCreatedAt:
  12866. m.ResetCreatedAt()
  12867. return nil
  12868. case soptask.FieldUpdatedAt:
  12869. m.ResetUpdatedAt()
  12870. return nil
  12871. case soptask.FieldStatus:
  12872. m.ResetStatus()
  12873. return nil
  12874. case soptask.FieldDeletedAt:
  12875. m.ResetDeletedAt()
  12876. return nil
  12877. case soptask.FieldName:
  12878. m.ResetName()
  12879. return nil
  12880. case soptask.FieldBotWxidList:
  12881. m.ResetBotWxidList()
  12882. return nil
  12883. case soptask.FieldType:
  12884. m.ResetType()
  12885. return nil
  12886. case soptask.FieldPlanStartTime:
  12887. m.ResetPlanStartTime()
  12888. return nil
  12889. case soptask.FieldPlanEndTime:
  12890. m.ResetPlanEndTime()
  12891. return nil
  12892. case soptask.FieldCreatorID:
  12893. m.ResetCreatorID()
  12894. return nil
  12895. case soptask.FieldOrganizationID:
  12896. m.ResetOrganizationID()
  12897. return nil
  12898. }
  12899. return fmt.Errorf("unknown SopTask field %s", name)
  12900. }
  12901. // AddedEdges returns all edge names that were set/added in this mutation.
  12902. func (m *SopTaskMutation) AddedEdges() []string {
  12903. edges := make([]string, 0, 1)
  12904. if m.task_stages != nil {
  12905. edges = append(edges, soptask.EdgeTaskStages)
  12906. }
  12907. return edges
  12908. }
  12909. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12910. // name in this mutation.
  12911. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  12912. switch name {
  12913. case soptask.EdgeTaskStages:
  12914. ids := make([]ent.Value, 0, len(m.task_stages))
  12915. for id := range m.task_stages {
  12916. ids = append(ids, id)
  12917. }
  12918. return ids
  12919. }
  12920. return nil
  12921. }
  12922. // RemovedEdges returns all edge names that were removed in this mutation.
  12923. func (m *SopTaskMutation) RemovedEdges() []string {
  12924. edges := make([]string, 0, 1)
  12925. if m.removedtask_stages != nil {
  12926. edges = append(edges, soptask.EdgeTaskStages)
  12927. }
  12928. return edges
  12929. }
  12930. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12931. // the given name in this mutation.
  12932. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  12933. switch name {
  12934. case soptask.EdgeTaskStages:
  12935. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  12936. for id := range m.removedtask_stages {
  12937. ids = append(ids, id)
  12938. }
  12939. return ids
  12940. }
  12941. return nil
  12942. }
  12943. // ClearedEdges returns all edge names that were cleared in this mutation.
  12944. func (m *SopTaskMutation) ClearedEdges() []string {
  12945. edges := make([]string, 0, 1)
  12946. if m.clearedtask_stages {
  12947. edges = append(edges, soptask.EdgeTaskStages)
  12948. }
  12949. return edges
  12950. }
  12951. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12952. // was cleared in this mutation.
  12953. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  12954. switch name {
  12955. case soptask.EdgeTaskStages:
  12956. return m.clearedtask_stages
  12957. }
  12958. return false
  12959. }
  12960. // ClearEdge clears the value of the edge with the given name. It returns an error
  12961. // if that edge is not defined in the schema.
  12962. func (m *SopTaskMutation) ClearEdge(name string) error {
  12963. switch name {
  12964. }
  12965. return fmt.Errorf("unknown SopTask unique edge %s", name)
  12966. }
  12967. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12968. // It returns an error if the edge is not defined in the schema.
  12969. func (m *SopTaskMutation) ResetEdge(name string) error {
  12970. switch name {
  12971. case soptask.EdgeTaskStages:
  12972. m.ResetTaskStages()
  12973. return nil
  12974. }
  12975. return fmt.Errorf("unknown SopTask edge %s", name)
  12976. }
  12977. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  12978. type WxMutation struct {
  12979. config
  12980. op Op
  12981. typ string
  12982. id *uint64
  12983. created_at *time.Time
  12984. updated_at *time.Time
  12985. status *uint8
  12986. addstatus *int8
  12987. deleted_at *time.Time
  12988. port *string
  12989. process_id *string
  12990. callback *string
  12991. wxid *string
  12992. account *string
  12993. nickname *string
  12994. tel *string
  12995. head_big *string
  12996. organization_id *uint64
  12997. addorganization_id *int64
  12998. clearedFields map[string]struct{}
  12999. server *uint64
  13000. clearedserver bool
  13001. agent *uint64
  13002. clearedagent bool
  13003. done bool
  13004. oldValue func(context.Context) (*Wx, error)
  13005. predicates []predicate.Wx
  13006. }
  13007. var _ ent.Mutation = (*WxMutation)(nil)
  13008. // wxOption allows management of the mutation configuration using functional options.
  13009. type wxOption func(*WxMutation)
  13010. // newWxMutation creates new mutation for the Wx entity.
  13011. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  13012. m := &WxMutation{
  13013. config: c,
  13014. op: op,
  13015. typ: TypeWx,
  13016. clearedFields: make(map[string]struct{}),
  13017. }
  13018. for _, opt := range opts {
  13019. opt(m)
  13020. }
  13021. return m
  13022. }
  13023. // withWxID sets the ID field of the mutation.
  13024. func withWxID(id uint64) wxOption {
  13025. return func(m *WxMutation) {
  13026. var (
  13027. err error
  13028. once sync.Once
  13029. value *Wx
  13030. )
  13031. m.oldValue = func(ctx context.Context) (*Wx, error) {
  13032. once.Do(func() {
  13033. if m.done {
  13034. err = errors.New("querying old values post mutation is not allowed")
  13035. } else {
  13036. value, err = m.Client().Wx.Get(ctx, id)
  13037. }
  13038. })
  13039. return value, err
  13040. }
  13041. m.id = &id
  13042. }
  13043. }
  13044. // withWx sets the old Wx of the mutation.
  13045. func withWx(node *Wx) wxOption {
  13046. return func(m *WxMutation) {
  13047. m.oldValue = func(context.Context) (*Wx, error) {
  13048. return node, nil
  13049. }
  13050. m.id = &node.ID
  13051. }
  13052. }
  13053. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13054. // executed in a transaction (ent.Tx), a transactional client is returned.
  13055. func (m WxMutation) Client() *Client {
  13056. client := &Client{config: m.config}
  13057. client.init()
  13058. return client
  13059. }
  13060. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13061. // it returns an error otherwise.
  13062. func (m WxMutation) Tx() (*Tx, error) {
  13063. if _, ok := m.driver.(*txDriver); !ok {
  13064. return nil, errors.New("ent: mutation is not running in a transaction")
  13065. }
  13066. tx := &Tx{config: m.config}
  13067. tx.init()
  13068. return tx, nil
  13069. }
  13070. // SetID sets the value of the id field. Note that this
  13071. // operation is only accepted on creation of Wx entities.
  13072. func (m *WxMutation) SetID(id uint64) {
  13073. m.id = &id
  13074. }
  13075. // ID returns the ID value in the mutation. Note that the ID is only available
  13076. // if it was provided to the builder or after it was returned from the database.
  13077. func (m *WxMutation) ID() (id uint64, exists bool) {
  13078. if m.id == nil {
  13079. return
  13080. }
  13081. return *m.id, true
  13082. }
  13083. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13084. // That means, if the mutation is applied within a transaction with an isolation level such
  13085. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13086. // or updated by the mutation.
  13087. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  13088. switch {
  13089. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13090. id, exists := m.ID()
  13091. if exists {
  13092. return []uint64{id}, nil
  13093. }
  13094. fallthrough
  13095. case m.op.Is(OpUpdate | OpDelete):
  13096. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  13097. default:
  13098. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13099. }
  13100. }
  13101. // SetCreatedAt sets the "created_at" field.
  13102. func (m *WxMutation) SetCreatedAt(t time.Time) {
  13103. m.created_at = &t
  13104. }
  13105. // CreatedAt returns the value of the "created_at" field in the mutation.
  13106. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  13107. v := m.created_at
  13108. if v == nil {
  13109. return
  13110. }
  13111. return *v, true
  13112. }
  13113. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  13114. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13116. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13117. if !m.op.Is(OpUpdateOne) {
  13118. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13119. }
  13120. if m.id == nil || m.oldValue == nil {
  13121. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13122. }
  13123. oldValue, err := m.oldValue(ctx)
  13124. if err != nil {
  13125. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13126. }
  13127. return oldValue.CreatedAt, nil
  13128. }
  13129. // ResetCreatedAt resets all changes to the "created_at" field.
  13130. func (m *WxMutation) ResetCreatedAt() {
  13131. m.created_at = nil
  13132. }
  13133. // SetUpdatedAt sets the "updated_at" field.
  13134. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  13135. m.updated_at = &t
  13136. }
  13137. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13138. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  13139. v := m.updated_at
  13140. if v == nil {
  13141. return
  13142. }
  13143. return *v, true
  13144. }
  13145. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  13146. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13148. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13149. if !m.op.Is(OpUpdateOne) {
  13150. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13151. }
  13152. if m.id == nil || m.oldValue == nil {
  13153. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13154. }
  13155. oldValue, err := m.oldValue(ctx)
  13156. if err != nil {
  13157. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13158. }
  13159. return oldValue.UpdatedAt, nil
  13160. }
  13161. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13162. func (m *WxMutation) ResetUpdatedAt() {
  13163. m.updated_at = nil
  13164. }
  13165. // SetStatus sets the "status" field.
  13166. func (m *WxMutation) SetStatus(u uint8) {
  13167. m.status = &u
  13168. m.addstatus = nil
  13169. }
  13170. // Status returns the value of the "status" field in the mutation.
  13171. func (m *WxMutation) Status() (r uint8, exists bool) {
  13172. v := m.status
  13173. if v == nil {
  13174. return
  13175. }
  13176. return *v, true
  13177. }
  13178. // OldStatus returns the old "status" field's value of the Wx entity.
  13179. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13181. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13182. if !m.op.Is(OpUpdateOne) {
  13183. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13184. }
  13185. if m.id == nil || m.oldValue == nil {
  13186. return v, errors.New("OldStatus requires an ID field in the mutation")
  13187. }
  13188. oldValue, err := m.oldValue(ctx)
  13189. if err != nil {
  13190. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13191. }
  13192. return oldValue.Status, nil
  13193. }
  13194. // AddStatus adds u to the "status" field.
  13195. func (m *WxMutation) AddStatus(u int8) {
  13196. if m.addstatus != nil {
  13197. *m.addstatus += u
  13198. } else {
  13199. m.addstatus = &u
  13200. }
  13201. }
  13202. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13203. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  13204. v := m.addstatus
  13205. if v == nil {
  13206. return
  13207. }
  13208. return *v, true
  13209. }
  13210. // ClearStatus clears the value of the "status" field.
  13211. func (m *WxMutation) ClearStatus() {
  13212. m.status = nil
  13213. m.addstatus = nil
  13214. m.clearedFields[wx.FieldStatus] = struct{}{}
  13215. }
  13216. // StatusCleared returns if the "status" field was cleared in this mutation.
  13217. func (m *WxMutation) StatusCleared() bool {
  13218. _, ok := m.clearedFields[wx.FieldStatus]
  13219. return ok
  13220. }
  13221. // ResetStatus resets all changes to the "status" field.
  13222. func (m *WxMutation) ResetStatus() {
  13223. m.status = nil
  13224. m.addstatus = nil
  13225. delete(m.clearedFields, wx.FieldStatus)
  13226. }
  13227. // SetDeletedAt sets the "deleted_at" field.
  13228. func (m *WxMutation) SetDeletedAt(t time.Time) {
  13229. m.deleted_at = &t
  13230. }
  13231. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13232. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  13233. v := m.deleted_at
  13234. if v == nil {
  13235. return
  13236. }
  13237. return *v, true
  13238. }
  13239. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  13240. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13242. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13243. if !m.op.Is(OpUpdateOne) {
  13244. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13245. }
  13246. if m.id == nil || m.oldValue == nil {
  13247. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13248. }
  13249. oldValue, err := m.oldValue(ctx)
  13250. if err != nil {
  13251. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13252. }
  13253. return oldValue.DeletedAt, nil
  13254. }
  13255. // ClearDeletedAt clears the value of the "deleted_at" field.
  13256. func (m *WxMutation) ClearDeletedAt() {
  13257. m.deleted_at = nil
  13258. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  13259. }
  13260. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13261. func (m *WxMutation) DeletedAtCleared() bool {
  13262. _, ok := m.clearedFields[wx.FieldDeletedAt]
  13263. return ok
  13264. }
  13265. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13266. func (m *WxMutation) ResetDeletedAt() {
  13267. m.deleted_at = nil
  13268. delete(m.clearedFields, wx.FieldDeletedAt)
  13269. }
  13270. // SetServerID sets the "server_id" field.
  13271. func (m *WxMutation) SetServerID(u uint64) {
  13272. m.server = &u
  13273. }
  13274. // ServerID returns the value of the "server_id" field in the mutation.
  13275. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  13276. v := m.server
  13277. if v == nil {
  13278. return
  13279. }
  13280. return *v, true
  13281. }
  13282. // OldServerID returns the old "server_id" field's value of the Wx entity.
  13283. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13284. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13285. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  13286. if !m.op.Is(OpUpdateOne) {
  13287. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  13288. }
  13289. if m.id == nil || m.oldValue == nil {
  13290. return v, errors.New("OldServerID requires an ID field in the mutation")
  13291. }
  13292. oldValue, err := m.oldValue(ctx)
  13293. if err != nil {
  13294. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  13295. }
  13296. return oldValue.ServerID, nil
  13297. }
  13298. // ClearServerID clears the value of the "server_id" field.
  13299. func (m *WxMutation) ClearServerID() {
  13300. m.server = nil
  13301. m.clearedFields[wx.FieldServerID] = struct{}{}
  13302. }
  13303. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  13304. func (m *WxMutation) ServerIDCleared() bool {
  13305. _, ok := m.clearedFields[wx.FieldServerID]
  13306. return ok
  13307. }
  13308. // ResetServerID resets all changes to the "server_id" field.
  13309. func (m *WxMutation) ResetServerID() {
  13310. m.server = nil
  13311. delete(m.clearedFields, wx.FieldServerID)
  13312. }
  13313. // SetPort sets the "port" field.
  13314. func (m *WxMutation) SetPort(s string) {
  13315. m.port = &s
  13316. }
  13317. // Port returns the value of the "port" field in the mutation.
  13318. func (m *WxMutation) Port() (r string, exists bool) {
  13319. v := m.port
  13320. if v == nil {
  13321. return
  13322. }
  13323. return *v, true
  13324. }
  13325. // OldPort returns the old "port" field's value of the Wx entity.
  13326. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13328. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  13329. if !m.op.Is(OpUpdateOne) {
  13330. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  13331. }
  13332. if m.id == nil || m.oldValue == nil {
  13333. return v, errors.New("OldPort requires an ID field in the mutation")
  13334. }
  13335. oldValue, err := m.oldValue(ctx)
  13336. if err != nil {
  13337. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  13338. }
  13339. return oldValue.Port, nil
  13340. }
  13341. // ResetPort resets all changes to the "port" field.
  13342. func (m *WxMutation) ResetPort() {
  13343. m.port = nil
  13344. }
  13345. // SetProcessID sets the "process_id" field.
  13346. func (m *WxMutation) SetProcessID(s string) {
  13347. m.process_id = &s
  13348. }
  13349. // ProcessID returns the value of the "process_id" field in the mutation.
  13350. func (m *WxMutation) ProcessID() (r string, exists bool) {
  13351. v := m.process_id
  13352. if v == nil {
  13353. return
  13354. }
  13355. return *v, true
  13356. }
  13357. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  13358. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13360. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  13361. if !m.op.Is(OpUpdateOne) {
  13362. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  13363. }
  13364. if m.id == nil || m.oldValue == nil {
  13365. return v, errors.New("OldProcessID requires an ID field in the mutation")
  13366. }
  13367. oldValue, err := m.oldValue(ctx)
  13368. if err != nil {
  13369. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  13370. }
  13371. return oldValue.ProcessID, nil
  13372. }
  13373. // ResetProcessID resets all changes to the "process_id" field.
  13374. func (m *WxMutation) ResetProcessID() {
  13375. m.process_id = nil
  13376. }
  13377. // SetCallback sets the "callback" field.
  13378. func (m *WxMutation) SetCallback(s string) {
  13379. m.callback = &s
  13380. }
  13381. // Callback returns the value of the "callback" field in the mutation.
  13382. func (m *WxMutation) Callback() (r string, exists bool) {
  13383. v := m.callback
  13384. if v == nil {
  13385. return
  13386. }
  13387. return *v, true
  13388. }
  13389. // OldCallback returns the old "callback" field's value of the Wx entity.
  13390. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13392. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  13393. if !m.op.Is(OpUpdateOne) {
  13394. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  13395. }
  13396. if m.id == nil || m.oldValue == nil {
  13397. return v, errors.New("OldCallback requires an ID field in the mutation")
  13398. }
  13399. oldValue, err := m.oldValue(ctx)
  13400. if err != nil {
  13401. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  13402. }
  13403. return oldValue.Callback, nil
  13404. }
  13405. // ResetCallback resets all changes to the "callback" field.
  13406. func (m *WxMutation) ResetCallback() {
  13407. m.callback = nil
  13408. }
  13409. // SetWxid sets the "wxid" field.
  13410. func (m *WxMutation) SetWxid(s string) {
  13411. m.wxid = &s
  13412. }
  13413. // Wxid returns the value of the "wxid" field in the mutation.
  13414. func (m *WxMutation) Wxid() (r string, exists bool) {
  13415. v := m.wxid
  13416. if v == nil {
  13417. return
  13418. }
  13419. return *v, true
  13420. }
  13421. // OldWxid returns the old "wxid" field's value of the Wx entity.
  13422. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13424. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  13425. if !m.op.Is(OpUpdateOne) {
  13426. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  13427. }
  13428. if m.id == nil || m.oldValue == nil {
  13429. return v, errors.New("OldWxid requires an ID field in the mutation")
  13430. }
  13431. oldValue, err := m.oldValue(ctx)
  13432. if err != nil {
  13433. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  13434. }
  13435. return oldValue.Wxid, nil
  13436. }
  13437. // ResetWxid resets all changes to the "wxid" field.
  13438. func (m *WxMutation) ResetWxid() {
  13439. m.wxid = nil
  13440. }
  13441. // SetAccount sets the "account" field.
  13442. func (m *WxMutation) SetAccount(s string) {
  13443. m.account = &s
  13444. }
  13445. // Account returns the value of the "account" field in the mutation.
  13446. func (m *WxMutation) Account() (r string, exists bool) {
  13447. v := m.account
  13448. if v == nil {
  13449. return
  13450. }
  13451. return *v, true
  13452. }
  13453. // OldAccount returns the old "account" field's value of the Wx entity.
  13454. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13456. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  13457. if !m.op.Is(OpUpdateOne) {
  13458. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  13459. }
  13460. if m.id == nil || m.oldValue == nil {
  13461. return v, errors.New("OldAccount requires an ID field in the mutation")
  13462. }
  13463. oldValue, err := m.oldValue(ctx)
  13464. if err != nil {
  13465. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  13466. }
  13467. return oldValue.Account, nil
  13468. }
  13469. // ResetAccount resets all changes to the "account" field.
  13470. func (m *WxMutation) ResetAccount() {
  13471. m.account = nil
  13472. }
  13473. // SetNickname sets the "nickname" field.
  13474. func (m *WxMutation) SetNickname(s string) {
  13475. m.nickname = &s
  13476. }
  13477. // Nickname returns the value of the "nickname" field in the mutation.
  13478. func (m *WxMutation) Nickname() (r string, exists bool) {
  13479. v := m.nickname
  13480. if v == nil {
  13481. return
  13482. }
  13483. return *v, true
  13484. }
  13485. // OldNickname returns the old "nickname" field's value of the Wx entity.
  13486. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13488. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  13489. if !m.op.Is(OpUpdateOne) {
  13490. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  13491. }
  13492. if m.id == nil || m.oldValue == nil {
  13493. return v, errors.New("OldNickname requires an ID field in the mutation")
  13494. }
  13495. oldValue, err := m.oldValue(ctx)
  13496. if err != nil {
  13497. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  13498. }
  13499. return oldValue.Nickname, nil
  13500. }
  13501. // ResetNickname resets all changes to the "nickname" field.
  13502. func (m *WxMutation) ResetNickname() {
  13503. m.nickname = nil
  13504. }
  13505. // SetTel sets the "tel" field.
  13506. func (m *WxMutation) SetTel(s string) {
  13507. m.tel = &s
  13508. }
  13509. // Tel returns the value of the "tel" field in the mutation.
  13510. func (m *WxMutation) Tel() (r string, exists bool) {
  13511. v := m.tel
  13512. if v == nil {
  13513. return
  13514. }
  13515. return *v, true
  13516. }
  13517. // OldTel returns the old "tel" field's value of the Wx entity.
  13518. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13520. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  13521. if !m.op.Is(OpUpdateOne) {
  13522. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  13523. }
  13524. if m.id == nil || m.oldValue == nil {
  13525. return v, errors.New("OldTel requires an ID field in the mutation")
  13526. }
  13527. oldValue, err := m.oldValue(ctx)
  13528. if err != nil {
  13529. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  13530. }
  13531. return oldValue.Tel, nil
  13532. }
  13533. // ResetTel resets all changes to the "tel" field.
  13534. func (m *WxMutation) ResetTel() {
  13535. m.tel = nil
  13536. }
  13537. // SetHeadBig sets the "head_big" field.
  13538. func (m *WxMutation) SetHeadBig(s string) {
  13539. m.head_big = &s
  13540. }
  13541. // HeadBig returns the value of the "head_big" field in the mutation.
  13542. func (m *WxMutation) HeadBig() (r string, exists bool) {
  13543. v := m.head_big
  13544. if v == nil {
  13545. return
  13546. }
  13547. return *v, true
  13548. }
  13549. // OldHeadBig returns the old "head_big" 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) OldHeadBig(ctx context.Context) (v string, err error) {
  13553. if !m.op.Is(OpUpdateOne) {
  13554. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  13555. }
  13556. if m.id == nil || m.oldValue == nil {
  13557. return v, errors.New("OldHeadBig 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 OldHeadBig: %w", err)
  13562. }
  13563. return oldValue.HeadBig, nil
  13564. }
  13565. // ResetHeadBig resets all changes to the "head_big" field.
  13566. func (m *WxMutation) ResetHeadBig() {
  13567. m.head_big = nil
  13568. }
  13569. // SetOrganizationID sets the "organization_id" field.
  13570. func (m *WxMutation) SetOrganizationID(u uint64) {
  13571. m.organization_id = &u
  13572. m.addorganization_id = nil
  13573. }
  13574. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13575. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  13576. v := m.organization_id
  13577. if v == nil {
  13578. return
  13579. }
  13580. return *v, true
  13581. }
  13582. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  13583. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13585. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13586. if !m.op.Is(OpUpdateOne) {
  13587. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13588. }
  13589. if m.id == nil || m.oldValue == nil {
  13590. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13591. }
  13592. oldValue, err := m.oldValue(ctx)
  13593. if err != nil {
  13594. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13595. }
  13596. return oldValue.OrganizationID, nil
  13597. }
  13598. // AddOrganizationID adds u to the "organization_id" field.
  13599. func (m *WxMutation) AddOrganizationID(u int64) {
  13600. if m.addorganization_id != nil {
  13601. *m.addorganization_id += u
  13602. } else {
  13603. m.addorganization_id = &u
  13604. }
  13605. }
  13606. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13607. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  13608. v := m.addorganization_id
  13609. if v == nil {
  13610. return
  13611. }
  13612. return *v, true
  13613. }
  13614. // ClearOrganizationID clears the value of the "organization_id" field.
  13615. func (m *WxMutation) ClearOrganizationID() {
  13616. m.organization_id = nil
  13617. m.addorganization_id = nil
  13618. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  13619. }
  13620. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13621. func (m *WxMutation) OrganizationIDCleared() bool {
  13622. _, ok := m.clearedFields[wx.FieldOrganizationID]
  13623. return ok
  13624. }
  13625. // ResetOrganizationID resets all changes to the "organization_id" field.
  13626. func (m *WxMutation) ResetOrganizationID() {
  13627. m.organization_id = nil
  13628. m.addorganization_id = nil
  13629. delete(m.clearedFields, wx.FieldOrganizationID)
  13630. }
  13631. // SetAgentID sets the "agent_id" field.
  13632. func (m *WxMutation) SetAgentID(u uint64) {
  13633. m.agent = &u
  13634. }
  13635. // AgentID returns the value of the "agent_id" field in the mutation.
  13636. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  13637. v := m.agent
  13638. if v == nil {
  13639. return
  13640. }
  13641. return *v, true
  13642. }
  13643. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  13644. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13646. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  13647. if !m.op.Is(OpUpdateOne) {
  13648. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  13649. }
  13650. if m.id == nil || m.oldValue == nil {
  13651. return v, errors.New("OldAgentID requires an ID field in the mutation")
  13652. }
  13653. oldValue, err := m.oldValue(ctx)
  13654. if err != nil {
  13655. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  13656. }
  13657. return oldValue.AgentID, nil
  13658. }
  13659. // ResetAgentID resets all changes to the "agent_id" field.
  13660. func (m *WxMutation) ResetAgentID() {
  13661. m.agent = nil
  13662. }
  13663. // ClearServer clears the "server" edge to the Server entity.
  13664. func (m *WxMutation) ClearServer() {
  13665. m.clearedserver = true
  13666. m.clearedFields[wx.FieldServerID] = struct{}{}
  13667. }
  13668. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  13669. func (m *WxMutation) ServerCleared() bool {
  13670. return m.ServerIDCleared() || m.clearedserver
  13671. }
  13672. // ServerIDs returns the "server" edge IDs in the mutation.
  13673. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13674. // ServerID instead. It exists only for internal usage by the builders.
  13675. func (m *WxMutation) ServerIDs() (ids []uint64) {
  13676. if id := m.server; id != nil {
  13677. ids = append(ids, *id)
  13678. }
  13679. return
  13680. }
  13681. // ResetServer resets all changes to the "server" edge.
  13682. func (m *WxMutation) ResetServer() {
  13683. m.server = nil
  13684. m.clearedserver = false
  13685. }
  13686. // ClearAgent clears the "agent" edge to the Agent entity.
  13687. func (m *WxMutation) ClearAgent() {
  13688. m.clearedagent = true
  13689. m.clearedFields[wx.FieldAgentID] = struct{}{}
  13690. }
  13691. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  13692. func (m *WxMutation) AgentCleared() bool {
  13693. return m.clearedagent
  13694. }
  13695. // AgentIDs returns the "agent" edge IDs in the mutation.
  13696. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13697. // AgentID instead. It exists only for internal usage by the builders.
  13698. func (m *WxMutation) AgentIDs() (ids []uint64) {
  13699. if id := m.agent; id != nil {
  13700. ids = append(ids, *id)
  13701. }
  13702. return
  13703. }
  13704. // ResetAgent resets all changes to the "agent" edge.
  13705. func (m *WxMutation) ResetAgent() {
  13706. m.agent = nil
  13707. m.clearedagent = false
  13708. }
  13709. // Where appends a list predicates to the WxMutation builder.
  13710. func (m *WxMutation) Where(ps ...predicate.Wx) {
  13711. m.predicates = append(m.predicates, ps...)
  13712. }
  13713. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  13714. // users can use type-assertion to append predicates that do not depend on any generated package.
  13715. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  13716. p := make([]predicate.Wx, len(ps))
  13717. for i := range ps {
  13718. p[i] = ps[i]
  13719. }
  13720. m.Where(p...)
  13721. }
  13722. // Op returns the operation name.
  13723. func (m *WxMutation) Op() Op {
  13724. return m.op
  13725. }
  13726. // SetOp allows setting the mutation operation.
  13727. func (m *WxMutation) SetOp(op Op) {
  13728. m.op = op
  13729. }
  13730. // Type returns the node type of this mutation (Wx).
  13731. func (m *WxMutation) Type() string {
  13732. return m.typ
  13733. }
  13734. // Fields returns all fields that were changed during this mutation. Note that in
  13735. // order to get all numeric fields that were incremented/decremented, call
  13736. // AddedFields().
  13737. func (m *WxMutation) Fields() []string {
  13738. fields := make([]string, 0, 15)
  13739. if m.created_at != nil {
  13740. fields = append(fields, wx.FieldCreatedAt)
  13741. }
  13742. if m.updated_at != nil {
  13743. fields = append(fields, wx.FieldUpdatedAt)
  13744. }
  13745. if m.status != nil {
  13746. fields = append(fields, wx.FieldStatus)
  13747. }
  13748. if m.deleted_at != nil {
  13749. fields = append(fields, wx.FieldDeletedAt)
  13750. }
  13751. if m.server != nil {
  13752. fields = append(fields, wx.FieldServerID)
  13753. }
  13754. if m.port != nil {
  13755. fields = append(fields, wx.FieldPort)
  13756. }
  13757. if m.process_id != nil {
  13758. fields = append(fields, wx.FieldProcessID)
  13759. }
  13760. if m.callback != nil {
  13761. fields = append(fields, wx.FieldCallback)
  13762. }
  13763. if m.wxid != nil {
  13764. fields = append(fields, wx.FieldWxid)
  13765. }
  13766. if m.account != nil {
  13767. fields = append(fields, wx.FieldAccount)
  13768. }
  13769. if m.nickname != nil {
  13770. fields = append(fields, wx.FieldNickname)
  13771. }
  13772. if m.tel != nil {
  13773. fields = append(fields, wx.FieldTel)
  13774. }
  13775. if m.head_big != nil {
  13776. fields = append(fields, wx.FieldHeadBig)
  13777. }
  13778. if m.organization_id != nil {
  13779. fields = append(fields, wx.FieldOrganizationID)
  13780. }
  13781. if m.agent != nil {
  13782. fields = append(fields, wx.FieldAgentID)
  13783. }
  13784. return fields
  13785. }
  13786. // Field returns the value of a field with the given name. The second boolean
  13787. // return value indicates that this field was not set, or was not defined in the
  13788. // schema.
  13789. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  13790. switch name {
  13791. case wx.FieldCreatedAt:
  13792. return m.CreatedAt()
  13793. case wx.FieldUpdatedAt:
  13794. return m.UpdatedAt()
  13795. case wx.FieldStatus:
  13796. return m.Status()
  13797. case wx.FieldDeletedAt:
  13798. return m.DeletedAt()
  13799. case wx.FieldServerID:
  13800. return m.ServerID()
  13801. case wx.FieldPort:
  13802. return m.Port()
  13803. case wx.FieldProcessID:
  13804. return m.ProcessID()
  13805. case wx.FieldCallback:
  13806. return m.Callback()
  13807. case wx.FieldWxid:
  13808. return m.Wxid()
  13809. case wx.FieldAccount:
  13810. return m.Account()
  13811. case wx.FieldNickname:
  13812. return m.Nickname()
  13813. case wx.FieldTel:
  13814. return m.Tel()
  13815. case wx.FieldHeadBig:
  13816. return m.HeadBig()
  13817. case wx.FieldOrganizationID:
  13818. return m.OrganizationID()
  13819. case wx.FieldAgentID:
  13820. return m.AgentID()
  13821. }
  13822. return nil, false
  13823. }
  13824. // OldField returns the old value of the field from the database. An error is
  13825. // returned if the mutation operation is not UpdateOne, or the query to the
  13826. // database failed.
  13827. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13828. switch name {
  13829. case wx.FieldCreatedAt:
  13830. return m.OldCreatedAt(ctx)
  13831. case wx.FieldUpdatedAt:
  13832. return m.OldUpdatedAt(ctx)
  13833. case wx.FieldStatus:
  13834. return m.OldStatus(ctx)
  13835. case wx.FieldDeletedAt:
  13836. return m.OldDeletedAt(ctx)
  13837. case wx.FieldServerID:
  13838. return m.OldServerID(ctx)
  13839. case wx.FieldPort:
  13840. return m.OldPort(ctx)
  13841. case wx.FieldProcessID:
  13842. return m.OldProcessID(ctx)
  13843. case wx.FieldCallback:
  13844. return m.OldCallback(ctx)
  13845. case wx.FieldWxid:
  13846. return m.OldWxid(ctx)
  13847. case wx.FieldAccount:
  13848. return m.OldAccount(ctx)
  13849. case wx.FieldNickname:
  13850. return m.OldNickname(ctx)
  13851. case wx.FieldTel:
  13852. return m.OldTel(ctx)
  13853. case wx.FieldHeadBig:
  13854. return m.OldHeadBig(ctx)
  13855. case wx.FieldOrganizationID:
  13856. return m.OldOrganizationID(ctx)
  13857. case wx.FieldAgentID:
  13858. return m.OldAgentID(ctx)
  13859. }
  13860. return nil, fmt.Errorf("unknown Wx field %s", name)
  13861. }
  13862. // SetField sets the value of a field with the given name. It returns an error if
  13863. // the field is not defined in the schema, or if the type mismatched the field
  13864. // type.
  13865. func (m *WxMutation) SetField(name string, value ent.Value) error {
  13866. switch name {
  13867. case wx.FieldCreatedAt:
  13868. v, ok := value.(time.Time)
  13869. if !ok {
  13870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13871. }
  13872. m.SetCreatedAt(v)
  13873. return nil
  13874. case wx.FieldUpdatedAt:
  13875. v, ok := value.(time.Time)
  13876. if !ok {
  13877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13878. }
  13879. m.SetUpdatedAt(v)
  13880. return nil
  13881. case wx.FieldStatus:
  13882. v, ok := value.(uint8)
  13883. if !ok {
  13884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13885. }
  13886. m.SetStatus(v)
  13887. return nil
  13888. case wx.FieldDeletedAt:
  13889. v, ok := value.(time.Time)
  13890. if !ok {
  13891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13892. }
  13893. m.SetDeletedAt(v)
  13894. return nil
  13895. case wx.FieldServerID:
  13896. v, ok := value.(uint64)
  13897. if !ok {
  13898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13899. }
  13900. m.SetServerID(v)
  13901. return nil
  13902. case wx.FieldPort:
  13903. v, ok := value.(string)
  13904. if !ok {
  13905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13906. }
  13907. m.SetPort(v)
  13908. return nil
  13909. case wx.FieldProcessID:
  13910. v, ok := value.(string)
  13911. if !ok {
  13912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13913. }
  13914. m.SetProcessID(v)
  13915. return nil
  13916. case wx.FieldCallback:
  13917. v, ok := value.(string)
  13918. if !ok {
  13919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13920. }
  13921. m.SetCallback(v)
  13922. return nil
  13923. case wx.FieldWxid:
  13924. v, ok := value.(string)
  13925. if !ok {
  13926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13927. }
  13928. m.SetWxid(v)
  13929. return nil
  13930. case wx.FieldAccount:
  13931. v, ok := value.(string)
  13932. if !ok {
  13933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13934. }
  13935. m.SetAccount(v)
  13936. return nil
  13937. case wx.FieldNickname:
  13938. v, ok := value.(string)
  13939. if !ok {
  13940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13941. }
  13942. m.SetNickname(v)
  13943. return nil
  13944. case wx.FieldTel:
  13945. v, ok := value.(string)
  13946. if !ok {
  13947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13948. }
  13949. m.SetTel(v)
  13950. return nil
  13951. case wx.FieldHeadBig:
  13952. v, ok := value.(string)
  13953. if !ok {
  13954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13955. }
  13956. m.SetHeadBig(v)
  13957. return nil
  13958. case wx.FieldOrganizationID:
  13959. v, ok := value.(uint64)
  13960. if !ok {
  13961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13962. }
  13963. m.SetOrganizationID(v)
  13964. return nil
  13965. case wx.FieldAgentID:
  13966. v, ok := value.(uint64)
  13967. if !ok {
  13968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13969. }
  13970. m.SetAgentID(v)
  13971. return nil
  13972. }
  13973. return fmt.Errorf("unknown Wx field %s", name)
  13974. }
  13975. // AddedFields returns all numeric fields that were incremented/decremented during
  13976. // this mutation.
  13977. func (m *WxMutation) AddedFields() []string {
  13978. var fields []string
  13979. if m.addstatus != nil {
  13980. fields = append(fields, wx.FieldStatus)
  13981. }
  13982. if m.addorganization_id != nil {
  13983. fields = append(fields, wx.FieldOrganizationID)
  13984. }
  13985. return fields
  13986. }
  13987. // AddedField returns the numeric value that was incremented/decremented on a field
  13988. // with the given name. The second boolean return value indicates that this field
  13989. // was not set, or was not defined in the schema.
  13990. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  13991. switch name {
  13992. case wx.FieldStatus:
  13993. return m.AddedStatus()
  13994. case wx.FieldOrganizationID:
  13995. return m.AddedOrganizationID()
  13996. }
  13997. return nil, false
  13998. }
  13999. // AddField adds the value to the field with the given name. It returns an error if
  14000. // the field is not defined in the schema, or if the type mismatched the field
  14001. // type.
  14002. func (m *WxMutation) AddField(name string, value ent.Value) error {
  14003. switch name {
  14004. case wx.FieldStatus:
  14005. v, ok := value.(int8)
  14006. if !ok {
  14007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14008. }
  14009. m.AddStatus(v)
  14010. return nil
  14011. case wx.FieldOrganizationID:
  14012. v, ok := value.(int64)
  14013. if !ok {
  14014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14015. }
  14016. m.AddOrganizationID(v)
  14017. return nil
  14018. }
  14019. return fmt.Errorf("unknown Wx numeric field %s", name)
  14020. }
  14021. // ClearedFields returns all nullable fields that were cleared during this
  14022. // mutation.
  14023. func (m *WxMutation) ClearedFields() []string {
  14024. var fields []string
  14025. if m.FieldCleared(wx.FieldStatus) {
  14026. fields = append(fields, wx.FieldStatus)
  14027. }
  14028. if m.FieldCleared(wx.FieldDeletedAt) {
  14029. fields = append(fields, wx.FieldDeletedAt)
  14030. }
  14031. if m.FieldCleared(wx.FieldServerID) {
  14032. fields = append(fields, wx.FieldServerID)
  14033. }
  14034. if m.FieldCleared(wx.FieldOrganizationID) {
  14035. fields = append(fields, wx.FieldOrganizationID)
  14036. }
  14037. return fields
  14038. }
  14039. // FieldCleared returns a boolean indicating if a field with the given name was
  14040. // cleared in this mutation.
  14041. func (m *WxMutation) FieldCleared(name string) bool {
  14042. _, ok := m.clearedFields[name]
  14043. return ok
  14044. }
  14045. // ClearField clears the value of the field with the given name. It returns an
  14046. // error if the field is not defined in the schema.
  14047. func (m *WxMutation) ClearField(name string) error {
  14048. switch name {
  14049. case wx.FieldStatus:
  14050. m.ClearStatus()
  14051. return nil
  14052. case wx.FieldDeletedAt:
  14053. m.ClearDeletedAt()
  14054. return nil
  14055. case wx.FieldServerID:
  14056. m.ClearServerID()
  14057. return nil
  14058. case wx.FieldOrganizationID:
  14059. m.ClearOrganizationID()
  14060. return nil
  14061. }
  14062. return fmt.Errorf("unknown Wx nullable field %s", name)
  14063. }
  14064. // ResetField resets all changes in the mutation for the field with the given name.
  14065. // It returns an error if the field is not defined in the schema.
  14066. func (m *WxMutation) ResetField(name string) error {
  14067. switch name {
  14068. case wx.FieldCreatedAt:
  14069. m.ResetCreatedAt()
  14070. return nil
  14071. case wx.FieldUpdatedAt:
  14072. m.ResetUpdatedAt()
  14073. return nil
  14074. case wx.FieldStatus:
  14075. m.ResetStatus()
  14076. return nil
  14077. case wx.FieldDeletedAt:
  14078. m.ResetDeletedAt()
  14079. return nil
  14080. case wx.FieldServerID:
  14081. m.ResetServerID()
  14082. return nil
  14083. case wx.FieldPort:
  14084. m.ResetPort()
  14085. return nil
  14086. case wx.FieldProcessID:
  14087. m.ResetProcessID()
  14088. return nil
  14089. case wx.FieldCallback:
  14090. m.ResetCallback()
  14091. return nil
  14092. case wx.FieldWxid:
  14093. m.ResetWxid()
  14094. return nil
  14095. case wx.FieldAccount:
  14096. m.ResetAccount()
  14097. return nil
  14098. case wx.FieldNickname:
  14099. m.ResetNickname()
  14100. return nil
  14101. case wx.FieldTel:
  14102. m.ResetTel()
  14103. return nil
  14104. case wx.FieldHeadBig:
  14105. m.ResetHeadBig()
  14106. return nil
  14107. case wx.FieldOrganizationID:
  14108. m.ResetOrganizationID()
  14109. return nil
  14110. case wx.FieldAgentID:
  14111. m.ResetAgentID()
  14112. return nil
  14113. }
  14114. return fmt.Errorf("unknown Wx field %s", name)
  14115. }
  14116. // AddedEdges returns all edge names that were set/added in this mutation.
  14117. func (m *WxMutation) AddedEdges() []string {
  14118. edges := make([]string, 0, 2)
  14119. if m.server != nil {
  14120. edges = append(edges, wx.EdgeServer)
  14121. }
  14122. if m.agent != nil {
  14123. edges = append(edges, wx.EdgeAgent)
  14124. }
  14125. return edges
  14126. }
  14127. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14128. // name in this mutation.
  14129. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  14130. switch name {
  14131. case wx.EdgeServer:
  14132. if id := m.server; id != nil {
  14133. return []ent.Value{*id}
  14134. }
  14135. case wx.EdgeAgent:
  14136. if id := m.agent; id != nil {
  14137. return []ent.Value{*id}
  14138. }
  14139. }
  14140. return nil
  14141. }
  14142. // RemovedEdges returns all edge names that were removed in this mutation.
  14143. func (m *WxMutation) RemovedEdges() []string {
  14144. edges := make([]string, 0, 2)
  14145. return edges
  14146. }
  14147. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14148. // the given name in this mutation.
  14149. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  14150. return nil
  14151. }
  14152. // ClearedEdges returns all edge names that were cleared in this mutation.
  14153. func (m *WxMutation) ClearedEdges() []string {
  14154. edges := make([]string, 0, 2)
  14155. if m.clearedserver {
  14156. edges = append(edges, wx.EdgeServer)
  14157. }
  14158. if m.clearedagent {
  14159. edges = append(edges, wx.EdgeAgent)
  14160. }
  14161. return edges
  14162. }
  14163. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14164. // was cleared in this mutation.
  14165. func (m *WxMutation) EdgeCleared(name string) bool {
  14166. switch name {
  14167. case wx.EdgeServer:
  14168. return m.clearedserver
  14169. case wx.EdgeAgent:
  14170. return m.clearedagent
  14171. }
  14172. return false
  14173. }
  14174. // ClearEdge clears the value of the edge with the given name. It returns an error
  14175. // if that edge is not defined in the schema.
  14176. func (m *WxMutation) ClearEdge(name string) error {
  14177. switch name {
  14178. case wx.EdgeServer:
  14179. m.ClearServer()
  14180. return nil
  14181. case wx.EdgeAgent:
  14182. m.ClearAgent()
  14183. return nil
  14184. }
  14185. return fmt.Errorf("unknown Wx unique edge %s", name)
  14186. }
  14187. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14188. // It returns an error if the edge is not defined in the schema.
  14189. func (m *WxMutation) ResetEdge(name string) error {
  14190. switch name {
  14191. case wx.EdgeServer:
  14192. m.ResetServer()
  14193. return nil
  14194. case wx.EdgeAgent:
  14195. m.ResetAgent()
  14196. return nil
  14197. }
  14198. return fmt.Errorf("unknown Wx edge %s", name)
  14199. }