mutation.go 455 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/batchmsg"
  11. "wechat-api/ent/contact"
  12. "wechat-api/ent/custom_types"
  13. "wechat-api/ent/label"
  14. "wechat-api/ent/labelrelationship"
  15. "wechat-api/ent/message"
  16. "wechat-api/ent/messagerecords"
  17. "wechat-api/ent/msg"
  18. "wechat-api/ent/predicate"
  19. "wechat-api/ent/server"
  20. "wechat-api/ent/sopnode"
  21. "wechat-api/ent/sopstage"
  22. "wechat-api/ent/soptask"
  23. "wechat-api/ent/wx"
  24. "entgo.io/ent"
  25. "entgo.io/ent/dialect/sql"
  26. )
  27. const (
  28. // Operation types.
  29. OpCreate = ent.OpCreate
  30. OpDelete = ent.OpDelete
  31. OpDeleteOne = ent.OpDeleteOne
  32. OpUpdate = ent.OpUpdate
  33. OpUpdateOne = ent.OpUpdateOne
  34. // Node types.
  35. TypeAgent = "Agent"
  36. TypeBatchMsg = "BatchMsg"
  37. TypeContact = "Contact"
  38. TypeLabel = "Label"
  39. TypeLabelRelationship = "LabelRelationship"
  40. TypeMessage = "Message"
  41. TypeMessageRecords = "MessageRecords"
  42. TypeMsg = "Msg"
  43. TypeServer = "Server"
  44. TypeSopNode = "SopNode"
  45. TypeSopStage = "SopStage"
  46. TypeSopTask = "SopTask"
  47. TypeWx = "Wx"
  48. )
  49. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  50. type AgentMutation struct {
  51. config
  52. op Op
  53. typ string
  54. id *uint64
  55. created_at *time.Time
  56. updated_at *time.Time
  57. deleted_at *time.Time
  58. name *string
  59. role *string
  60. status *int
  61. addstatus *int
  62. background *string
  63. examples *string
  64. organization_id *uint64
  65. addorganization_id *int64
  66. clearedFields map[string]struct{}
  67. wx_agent map[uint64]struct{}
  68. removedwx_agent map[uint64]struct{}
  69. clearedwx_agent bool
  70. done bool
  71. oldValue func(context.Context) (*Agent, error)
  72. predicates []predicate.Agent
  73. }
  74. var _ ent.Mutation = (*AgentMutation)(nil)
  75. // agentOption allows management of the mutation configuration using functional options.
  76. type agentOption func(*AgentMutation)
  77. // newAgentMutation creates new mutation for the Agent entity.
  78. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  79. m := &AgentMutation{
  80. config: c,
  81. op: op,
  82. typ: TypeAgent,
  83. clearedFields: make(map[string]struct{}),
  84. }
  85. for _, opt := range opts {
  86. opt(m)
  87. }
  88. return m
  89. }
  90. // withAgentID sets the ID field of the mutation.
  91. func withAgentID(id uint64) agentOption {
  92. return func(m *AgentMutation) {
  93. var (
  94. err error
  95. once sync.Once
  96. value *Agent
  97. )
  98. m.oldValue = func(ctx context.Context) (*Agent, error) {
  99. once.Do(func() {
  100. if m.done {
  101. err = errors.New("querying old values post mutation is not allowed")
  102. } else {
  103. value, err = m.Client().Agent.Get(ctx, id)
  104. }
  105. })
  106. return value, err
  107. }
  108. m.id = &id
  109. }
  110. }
  111. // withAgent sets the old Agent of the mutation.
  112. func withAgent(node *Agent) agentOption {
  113. return func(m *AgentMutation) {
  114. m.oldValue = func(context.Context) (*Agent, error) {
  115. return node, nil
  116. }
  117. m.id = &node.ID
  118. }
  119. }
  120. // Client returns a new `ent.Client` from the mutation. If the mutation was
  121. // executed in a transaction (ent.Tx), a transactional client is returned.
  122. func (m AgentMutation) Client() *Client {
  123. client := &Client{config: m.config}
  124. client.init()
  125. return client
  126. }
  127. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  128. // it returns an error otherwise.
  129. func (m AgentMutation) Tx() (*Tx, error) {
  130. if _, ok := m.driver.(*txDriver); !ok {
  131. return nil, errors.New("ent: mutation is not running in a transaction")
  132. }
  133. tx := &Tx{config: m.config}
  134. tx.init()
  135. return tx, nil
  136. }
  137. // SetID sets the value of the id field. Note that this
  138. // operation is only accepted on creation of Agent entities.
  139. func (m *AgentMutation) SetID(id uint64) {
  140. m.id = &id
  141. }
  142. // ID returns the ID value in the mutation. Note that the ID is only available
  143. // if it was provided to the builder or after it was returned from the database.
  144. func (m *AgentMutation) ID() (id uint64, exists bool) {
  145. if m.id == nil {
  146. return
  147. }
  148. return *m.id, true
  149. }
  150. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  151. // That means, if the mutation is applied within a transaction with an isolation level such
  152. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  153. // or updated by the mutation.
  154. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  155. switch {
  156. case m.op.Is(OpUpdateOne | OpDeleteOne):
  157. id, exists := m.ID()
  158. if exists {
  159. return []uint64{id}, nil
  160. }
  161. fallthrough
  162. case m.op.Is(OpUpdate | OpDelete):
  163. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  164. default:
  165. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  166. }
  167. }
  168. // SetCreatedAt sets the "created_at" field.
  169. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  170. m.created_at = &t
  171. }
  172. // CreatedAt returns the value of the "created_at" field in the mutation.
  173. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  174. v := m.created_at
  175. if v == nil {
  176. return
  177. }
  178. return *v, true
  179. }
  180. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  181. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  183. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  184. if !m.op.Is(OpUpdateOne) {
  185. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  186. }
  187. if m.id == nil || m.oldValue == nil {
  188. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  189. }
  190. oldValue, err := m.oldValue(ctx)
  191. if err != nil {
  192. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  193. }
  194. return oldValue.CreatedAt, nil
  195. }
  196. // ResetCreatedAt resets all changes to the "created_at" field.
  197. func (m *AgentMutation) ResetCreatedAt() {
  198. m.created_at = nil
  199. }
  200. // SetUpdatedAt sets the "updated_at" field.
  201. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  202. m.updated_at = &t
  203. }
  204. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  205. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  206. v := m.updated_at
  207. if v == nil {
  208. return
  209. }
  210. return *v, true
  211. }
  212. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  213. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  215. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  216. if !m.op.Is(OpUpdateOne) {
  217. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  218. }
  219. if m.id == nil || m.oldValue == nil {
  220. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  221. }
  222. oldValue, err := m.oldValue(ctx)
  223. if err != nil {
  224. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  225. }
  226. return oldValue.UpdatedAt, nil
  227. }
  228. // ResetUpdatedAt resets all changes to the "updated_at" field.
  229. func (m *AgentMutation) ResetUpdatedAt() {
  230. m.updated_at = nil
  231. }
  232. // SetDeletedAt sets the "deleted_at" field.
  233. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  234. m.deleted_at = &t
  235. }
  236. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  237. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  238. v := m.deleted_at
  239. if v == nil {
  240. return
  241. }
  242. return *v, true
  243. }
  244. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  245. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  247. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  248. if !m.op.Is(OpUpdateOne) {
  249. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  250. }
  251. if m.id == nil || m.oldValue == nil {
  252. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  253. }
  254. oldValue, err := m.oldValue(ctx)
  255. if err != nil {
  256. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  257. }
  258. return oldValue.DeletedAt, nil
  259. }
  260. // ClearDeletedAt clears the value of the "deleted_at" field.
  261. func (m *AgentMutation) ClearDeletedAt() {
  262. m.deleted_at = nil
  263. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  264. }
  265. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  266. func (m *AgentMutation) DeletedAtCleared() bool {
  267. _, ok := m.clearedFields[agent.FieldDeletedAt]
  268. return ok
  269. }
  270. // ResetDeletedAt resets all changes to the "deleted_at" field.
  271. func (m *AgentMutation) ResetDeletedAt() {
  272. m.deleted_at = nil
  273. delete(m.clearedFields, agent.FieldDeletedAt)
  274. }
  275. // SetName sets the "name" field.
  276. func (m *AgentMutation) SetName(s string) {
  277. m.name = &s
  278. }
  279. // Name returns the value of the "name" field in the mutation.
  280. func (m *AgentMutation) Name() (r string, exists bool) {
  281. v := m.name
  282. if v == nil {
  283. return
  284. }
  285. return *v, true
  286. }
  287. // OldName returns the old "name" field's value of the Agent entity.
  288. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  290. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  291. if !m.op.Is(OpUpdateOne) {
  292. return v, errors.New("OldName is only allowed on UpdateOne operations")
  293. }
  294. if m.id == nil || m.oldValue == nil {
  295. return v, errors.New("OldName requires an ID field in the mutation")
  296. }
  297. oldValue, err := m.oldValue(ctx)
  298. if err != nil {
  299. return v, fmt.Errorf("querying old value for OldName: %w", err)
  300. }
  301. return oldValue.Name, nil
  302. }
  303. // ResetName resets all changes to the "name" field.
  304. func (m *AgentMutation) ResetName() {
  305. m.name = nil
  306. }
  307. // SetRole sets the "role" field.
  308. func (m *AgentMutation) SetRole(s string) {
  309. m.role = &s
  310. }
  311. // Role returns the value of the "role" field in the mutation.
  312. func (m *AgentMutation) Role() (r string, exists bool) {
  313. v := m.role
  314. if v == nil {
  315. return
  316. }
  317. return *v, true
  318. }
  319. // OldRole returns the old "role" field's value of the Agent entity.
  320. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  322. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  323. if !m.op.Is(OpUpdateOne) {
  324. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  325. }
  326. if m.id == nil || m.oldValue == nil {
  327. return v, errors.New("OldRole requires an ID field in the mutation")
  328. }
  329. oldValue, err := m.oldValue(ctx)
  330. if err != nil {
  331. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  332. }
  333. return oldValue.Role, nil
  334. }
  335. // ResetRole resets all changes to the "role" field.
  336. func (m *AgentMutation) ResetRole() {
  337. m.role = nil
  338. }
  339. // SetStatus sets the "status" field.
  340. func (m *AgentMutation) SetStatus(i int) {
  341. m.status = &i
  342. m.addstatus = nil
  343. }
  344. // Status returns the value of the "status" field in the mutation.
  345. func (m *AgentMutation) Status() (r int, exists bool) {
  346. v := m.status
  347. if v == nil {
  348. return
  349. }
  350. return *v, true
  351. }
  352. // OldStatus returns the old "status" field's value of the Agent entity.
  353. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  355. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  356. if !m.op.Is(OpUpdateOne) {
  357. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  358. }
  359. if m.id == nil || m.oldValue == nil {
  360. return v, errors.New("OldStatus requires an ID field in the mutation")
  361. }
  362. oldValue, err := m.oldValue(ctx)
  363. if err != nil {
  364. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  365. }
  366. return oldValue.Status, nil
  367. }
  368. // AddStatus adds i to the "status" field.
  369. func (m *AgentMutation) AddStatus(i int) {
  370. if m.addstatus != nil {
  371. *m.addstatus += i
  372. } else {
  373. m.addstatus = &i
  374. }
  375. }
  376. // AddedStatus returns the value that was added to the "status" field in this mutation.
  377. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  378. v := m.addstatus
  379. if v == nil {
  380. return
  381. }
  382. return *v, true
  383. }
  384. // ClearStatus clears the value of the "status" field.
  385. func (m *AgentMutation) ClearStatus() {
  386. m.status = nil
  387. m.addstatus = nil
  388. m.clearedFields[agent.FieldStatus] = struct{}{}
  389. }
  390. // StatusCleared returns if the "status" field was cleared in this mutation.
  391. func (m *AgentMutation) StatusCleared() bool {
  392. _, ok := m.clearedFields[agent.FieldStatus]
  393. return ok
  394. }
  395. // ResetStatus resets all changes to the "status" field.
  396. func (m *AgentMutation) ResetStatus() {
  397. m.status = nil
  398. m.addstatus = nil
  399. delete(m.clearedFields, agent.FieldStatus)
  400. }
  401. // SetBackground sets the "background" field.
  402. func (m *AgentMutation) SetBackground(s string) {
  403. m.background = &s
  404. }
  405. // Background returns the value of the "background" field in the mutation.
  406. func (m *AgentMutation) Background() (r string, exists bool) {
  407. v := m.background
  408. if v == nil {
  409. return
  410. }
  411. return *v, true
  412. }
  413. // OldBackground returns the old "background" field's value of the Agent entity.
  414. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  416. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  417. if !m.op.Is(OpUpdateOne) {
  418. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  419. }
  420. if m.id == nil || m.oldValue == nil {
  421. return v, errors.New("OldBackground requires an ID field in the mutation")
  422. }
  423. oldValue, err := m.oldValue(ctx)
  424. if err != nil {
  425. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  426. }
  427. return oldValue.Background, nil
  428. }
  429. // ClearBackground clears the value of the "background" field.
  430. func (m *AgentMutation) ClearBackground() {
  431. m.background = nil
  432. m.clearedFields[agent.FieldBackground] = struct{}{}
  433. }
  434. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  435. func (m *AgentMutation) BackgroundCleared() bool {
  436. _, ok := m.clearedFields[agent.FieldBackground]
  437. return ok
  438. }
  439. // ResetBackground resets all changes to the "background" field.
  440. func (m *AgentMutation) ResetBackground() {
  441. m.background = nil
  442. delete(m.clearedFields, agent.FieldBackground)
  443. }
  444. // SetExamples sets the "examples" field.
  445. func (m *AgentMutation) SetExamples(s string) {
  446. m.examples = &s
  447. }
  448. // Examples returns the value of the "examples" field in the mutation.
  449. func (m *AgentMutation) Examples() (r string, exists bool) {
  450. v := m.examples
  451. if v == nil {
  452. return
  453. }
  454. return *v, true
  455. }
  456. // OldExamples returns the old "examples" field's value of the Agent entity.
  457. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  458. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  459. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  460. if !m.op.Is(OpUpdateOne) {
  461. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  462. }
  463. if m.id == nil || m.oldValue == nil {
  464. return v, errors.New("OldExamples requires an ID field in the mutation")
  465. }
  466. oldValue, err := m.oldValue(ctx)
  467. if err != nil {
  468. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  469. }
  470. return oldValue.Examples, nil
  471. }
  472. // ClearExamples clears the value of the "examples" field.
  473. func (m *AgentMutation) ClearExamples() {
  474. m.examples = nil
  475. m.clearedFields[agent.FieldExamples] = struct{}{}
  476. }
  477. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  478. func (m *AgentMutation) ExamplesCleared() bool {
  479. _, ok := m.clearedFields[agent.FieldExamples]
  480. return ok
  481. }
  482. // ResetExamples resets all changes to the "examples" field.
  483. func (m *AgentMutation) ResetExamples() {
  484. m.examples = nil
  485. delete(m.clearedFields, agent.FieldExamples)
  486. }
  487. // SetOrganizationID sets the "organization_id" field.
  488. func (m *AgentMutation) SetOrganizationID(u uint64) {
  489. m.organization_id = &u
  490. m.addorganization_id = nil
  491. }
  492. // OrganizationID returns the value of the "organization_id" field in the mutation.
  493. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  494. v := m.organization_id
  495. if v == nil {
  496. return
  497. }
  498. return *v, true
  499. }
  500. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  501. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  503. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  504. if !m.op.Is(OpUpdateOne) {
  505. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  506. }
  507. if m.id == nil || m.oldValue == nil {
  508. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  509. }
  510. oldValue, err := m.oldValue(ctx)
  511. if err != nil {
  512. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  513. }
  514. return oldValue.OrganizationID, nil
  515. }
  516. // AddOrganizationID adds u to the "organization_id" field.
  517. func (m *AgentMutation) AddOrganizationID(u int64) {
  518. if m.addorganization_id != nil {
  519. *m.addorganization_id += u
  520. } else {
  521. m.addorganization_id = &u
  522. }
  523. }
  524. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  525. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  526. v := m.addorganization_id
  527. if v == nil {
  528. return
  529. }
  530. return *v, true
  531. }
  532. // ResetOrganizationID resets all changes to the "organization_id" field.
  533. func (m *AgentMutation) ResetOrganizationID() {
  534. m.organization_id = nil
  535. m.addorganization_id = nil
  536. }
  537. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  538. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  539. if m.wx_agent == nil {
  540. m.wx_agent = make(map[uint64]struct{})
  541. }
  542. for i := range ids {
  543. m.wx_agent[ids[i]] = struct{}{}
  544. }
  545. }
  546. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  547. func (m *AgentMutation) ClearWxAgent() {
  548. m.clearedwx_agent = true
  549. }
  550. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  551. func (m *AgentMutation) WxAgentCleared() bool {
  552. return m.clearedwx_agent
  553. }
  554. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  555. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  556. if m.removedwx_agent == nil {
  557. m.removedwx_agent = make(map[uint64]struct{})
  558. }
  559. for i := range ids {
  560. delete(m.wx_agent, ids[i])
  561. m.removedwx_agent[ids[i]] = struct{}{}
  562. }
  563. }
  564. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  565. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  566. for id := range m.removedwx_agent {
  567. ids = append(ids, id)
  568. }
  569. return
  570. }
  571. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  572. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  573. for id := range m.wx_agent {
  574. ids = append(ids, id)
  575. }
  576. return
  577. }
  578. // ResetWxAgent resets all changes to the "wx_agent" edge.
  579. func (m *AgentMutation) ResetWxAgent() {
  580. m.wx_agent = nil
  581. m.clearedwx_agent = false
  582. m.removedwx_agent = nil
  583. }
  584. // Where appends a list predicates to the AgentMutation builder.
  585. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  586. m.predicates = append(m.predicates, ps...)
  587. }
  588. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  589. // users can use type-assertion to append predicates that do not depend on any generated package.
  590. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  591. p := make([]predicate.Agent, len(ps))
  592. for i := range ps {
  593. p[i] = ps[i]
  594. }
  595. m.Where(p...)
  596. }
  597. // Op returns the operation name.
  598. func (m *AgentMutation) Op() Op {
  599. return m.op
  600. }
  601. // SetOp allows setting the mutation operation.
  602. func (m *AgentMutation) SetOp(op Op) {
  603. m.op = op
  604. }
  605. // Type returns the node type of this mutation (Agent).
  606. func (m *AgentMutation) Type() string {
  607. return m.typ
  608. }
  609. // Fields returns all fields that were changed during this mutation. Note that in
  610. // order to get all numeric fields that were incremented/decremented, call
  611. // AddedFields().
  612. func (m *AgentMutation) Fields() []string {
  613. fields := make([]string, 0, 9)
  614. if m.created_at != nil {
  615. fields = append(fields, agent.FieldCreatedAt)
  616. }
  617. if m.updated_at != nil {
  618. fields = append(fields, agent.FieldUpdatedAt)
  619. }
  620. if m.deleted_at != nil {
  621. fields = append(fields, agent.FieldDeletedAt)
  622. }
  623. if m.name != nil {
  624. fields = append(fields, agent.FieldName)
  625. }
  626. if m.role != nil {
  627. fields = append(fields, agent.FieldRole)
  628. }
  629. if m.status != nil {
  630. fields = append(fields, agent.FieldStatus)
  631. }
  632. if m.background != nil {
  633. fields = append(fields, agent.FieldBackground)
  634. }
  635. if m.examples != nil {
  636. fields = append(fields, agent.FieldExamples)
  637. }
  638. if m.organization_id != nil {
  639. fields = append(fields, agent.FieldOrganizationID)
  640. }
  641. return fields
  642. }
  643. // Field returns the value of a field with the given name. The second boolean
  644. // return value indicates that this field was not set, or was not defined in the
  645. // schema.
  646. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  647. switch name {
  648. case agent.FieldCreatedAt:
  649. return m.CreatedAt()
  650. case agent.FieldUpdatedAt:
  651. return m.UpdatedAt()
  652. case agent.FieldDeletedAt:
  653. return m.DeletedAt()
  654. case agent.FieldName:
  655. return m.Name()
  656. case agent.FieldRole:
  657. return m.Role()
  658. case agent.FieldStatus:
  659. return m.Status()
  660. case agent.FieldBackground:
  661. return m.Background()
  662. case agent.FieldExamples:
  663. return m.Examples()
  664. case agent.FieldOrganizationID:
  665. return m.OrganizationID()
  666. }
  667. return nil, false
  668. }
  669. // OldField returns the old value of the field from the database. An error is
  670. // returned if the mutation operation is not UpdateOne, or the query to the
  671. // database failed.
  672. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  673. switch name {
  674. case agent.FieldCreatedAt:
  675. return m.OldCreatedAt(ctx)
  676. case agent.FieldUpdatedAt:
  677. return m.OldUpdatedAt(ctx)
  678. case agent.FieldDeletedAt:
  679. return m.OldDeletedAt(ctx)
  680. case agent.FieldName:
  681. return m.OldName(ctx)
  682. case agent.FieldRole:
  683. return m.OldRole(ctx)
  684. case agent.FieldStatus:
  685. return m.OldStatus(ctx)
  686. case agent.FieldBackground:
  687. return m.OldBackground(ctx)
  688. case agent.FieldExamples:
  689. return m.OldExamples(ctx)
  690. case agent.FieldOrganizationID:
  691. return m.OldOrganizationID(ctx)
  692. }
  693. return nil, fmt.Errorf("unknown Agent field %s", name)
  694. }
  695. // SetField sets the value of a field with the given name. It returns an error if
  696. // the field is not defined in the schema, or if the type mismatched the field
  697. // type.
  698. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  699. switch name {
  700. case agent.FieldCreatedAt:
  701. v, ok := value.(time.Time)
  702. if !ok {
  703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  704. }
  705. m.SetCreatedAt(v)
  706. return nil
  707. case agent.FieldUpdatedAt:
  708. v, ok := value.(time.Time)
  709. if !ok {
  710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  711. }
  712. m.SetUpdatedAt(v)
  713. return nil
  714. case agent.FieldDeletedAt:
  715. v, ok := value.(time.Time)
  716. if !ok {
  717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  718. }
  719. m.SetDeletedAt(v)
  720. return nil
  721. case agent.FieldName:
  722. v, ok := value.(string)
  723. if !ok {
  724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  725. }
  726. m.SetName(v)
  727. return nil
  728. case agent.FieldRole:
  729. v, ok := value.(string)
  730. if !ok {
  731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  732. }
  733. m.SetRole(v)
  734. return nil
  735. case agent.FieldStatus:
  736. v, ok := value.(int)
  737. if !ok {
  738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  739. }
  740. m.SetStatus(v)
  741. return nil
  742. case agent.FieldBackground:
  743. v, ok := value.(string)
  744. if !ok {
  745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  746. }
  747. m.SetBackground(v)
  748. return nil
  749. case agent.FieldExamples:
  750. v, ok := value.(string)
  751. if !ok {
  752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  753. }
  754. m.SetExamples(v)
  755. return nil
  756. case agent.FieldOrganizationID:
  757. v, ok := value.(uint64)
  758. if !ok {
  759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  760. }
  761. m.SetOrganizationID(v)
  762. return nil
  763. }
  764. return fmt.Errorf("unknown Agent field %s", name)
  765. }
  766. // AddedFields returns all numeric fields that were incremented/decremented during
  767. // this mutation.
  768. func (m *AgentMutation) AddedFields() []string {
  769. var fields []string
  770. if m.addstatus != nil {
  771. fields = append(fields, agent.FieldStatus)
  772. }
  773. if m.addorganization_id != nil {
  774. fields = append(fields, agent.FieldOrganizationID)
  775. }
  776. return fields
  777. }
  778. // AddedField returns the numeric value that was incremented/decremented on a field
  779. // with the given name. The second boolean return value indicates that this field
  780. // was not set, or was not defined in the schema.
  781. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  782. switch name {
  783. case agent.FieldStatus:
  784. return m.AddedStatus()
  785. case agent.FieldOrganizationID:
  786. return m.AddedOrganizationID()
  787. }
  788. return nil, false
  789. }
  790. // AddField adds the value to the field with the given name. It returns an error if
  791. // the field is not defined in the schema, or if the type mismatched the field
  792. // type.
  793. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  794. switch name {
  795. case agent.FieldStatus:
  796. v, ok := value.(int)
  797. if !ok {
  798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  799. }
  800. m.AddStatus(v)
  801. return nil
  802. case agent.FieldOrganizationID:
  803. v, ok := value.(int64)
  804. if !ok {
  805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  806. }
  807. m.AddOrganizationID(v)
  808. return nil
  809. }
  810. return fmt.Errorf("unknown Agent numeric field %s", name)
  811. }
  812. // ClearedFields returns all nullable fields that were cleared during this
  813. // mutation.
  814. func (m *AgentMutation) ClearedFields() []string {
  815. var fields []string
  816. if m.FieldCleared(agent.FieldDeletedAt) {
  817. fields = append(fields, agent.FieldDeletedAt)
  818. }
  819. if m.FieldCleared(agent.FieldStatus) {
  820. fields = append(fields, agent.FieldStatus)
  821. }
  822. if m.FieldCleared(agent.FieldBackground) {
  823. fields = append(fields, agent.FieldBackground)
  824. }
  825. if m.FieldCleared(agent.FieldExamples) {
  826. fields = append(fields, agent.FieldExamples)
  827. }
  828. return fields
  829. }
  830. // FieldCleared returns a boolean indicating if a field with the given name was
  831. // cleared in this mutation.
  832. func (m *AgentMutation) FieldCleared(name string) bool {
  833. _, ok := m.clearedFields[name]
  834. return ok
  835. }
  836. // ClearField clears the value of the field with the given name. It returns an
  837. // error if the field is not defined in the schema.
  838. func (m *AgentMutation) ClearField(name string) error {
  839. switch name {
  840. case agent.FieldDeletedAt:
  841. m.ClearDeletedAt()
  842. return nil
  843. case agent.FieldStatus:
  844. m.ClearStatus()
  845. return nil
  846. case agent.FieldBackground:
  847. m.ClearBackground()
  848. return nil
  849. case agent.FieldExamples:
  850. m.ClearExamples()
  851. return nil
  852. }
  853. return fmt.Errorf("unknown Agent nullable field %s", name)
  854. }
  855. // ResetField resets all changes in the mutation for the field with the given name.
  856. // It returns an error if the field is not defined in the schema.
  857. func (m *AgentMutation) ResetField(name string) error {
  858. switch name {
  859. case agent.FieldCreatedAt:
  860. m.ResetCreatedAt()
  861. return nil
  862. case agent.FieldUpdatedAt:
  863. m.ResetUpdatedAt()
  864. return nil
  865. case agent.FieldDeletedAt:
  866. m.ResetDeletedAt()
  867. return nil
  868. case agent.FieldName:
  869. m.ResetName()
  870. return nil
  871. case agent.FieldRole:
  872. m.ResetRole()
  873. return nil
  874. case agent.FieldStatus:
  875. m.ResetStatus()
  876. return nil
  877. case agent.FieldBackground:
  878. m.ResetBackground()
  879. return nil
  880. case agent.FieldExamples:
  881. m.ResetExamples()
  882. return nil
  883. case agent.FieldOrganizationID:
  884. m.ResetOrganizationID()
  885. return nil
  886. }
  887. return fmt.Errorf("unknown Agent field %s", name)
  888. }
  889. // AddedEdges returns all edge names that were set/added in this mutation.
  890. func (m *AgentMutation) AddedEdges() []string {
  891. edges := make([]string, 0, 1)
  892. if m.wx_agent != nil {
  893. edges = append(edges, agent.EdgeWxAgent)
  894. }
  895. return edges
  896. }
  897. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  898. // name in this mutation.
  899. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  900. switch name {
  901. case agent.EdgeWxAgent:
  902. ids := make([]ent.Value, 0, len(m.wx_agent))
  903. for id := range m.wx_agent {
  904. ids = append(ids, id)
  905. }
  906. return ids
  907. }
  908. return nil
  909. }
  910. // RemovedEdges returns all edge names that were removed in this mutation.
  911. func (m *AgentMutation) RemovedEdges() []string {
  912. edges := make([]string, 0, 1)
  913. if m.removedwx_agent != nil {
  914. edges = append(edges, agent.EdgeWxAgent)
  915. }
  916. return edges
  917. }
  918. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  919. // the given name in this mutation.
  920. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  921. switch name {
  922. case agent.EdgeWxAgent:
  923. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  924. for id := range m.removedwx_agent {
  925. ids = append(ids, id)
  926. }
  927. return ids
  928. }
  929. return nil
  930. }
  931. // ClearedEdges returns all edge names that were cleared in this mutation.
  932. func (m *AgentMutation) ClearedEdges() []string {
  933. edges := make([]string, 0, 1)
  934. if m.clearedwx_agent {
  935. edges = append(edges, agent.EdgeWxAgent)
  936. }
  937. return edges
  938. }
  939. // EdgeCleared returns a boolean which indicates if the edge with the given name
  940. // was cleared in this mutation.
  941. func (m *AgentMutation) EdgeCleared(name string) bool {
  942. switch name {
  943. case agent.EdgeWxAgent:
  944. return m.clearedwx_agent
  945. }
  946. return false
  947. }
  948. // ClearEdge clears the value of the edge with the given name. It returns an error
  949. // if that edge is not defined in the schema.
  950. func (m *AgentMutation) ClearEdge(name string) error {
  951. switch name {
  952. }
  953. return fmt.Errorf("unknown Agent unique edge %s", name)
  954. }
  955. // ResetEdge resets all changes to the edge with the given name in this mutation.
  956. // It returns an error if the edge is not defined in the schema.
  957. func (m *AgentMutation) ResetEdge(name string) error {
  958. switch name {
  959. case agent.EdgeWxAgent:
  960. m.ResetWxAgent()
  961. return nil
  962. }
  963. return fmt.Errorf("unknown Agent edge %s", name)
  964. }
  965. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  966. type BatchMsgMutation struct {
  967. config
  968. op Op
  969. typ string
  970. id *uint64
  971. created_at *time.Time
  972. updated_at *time.Time
  973. deleted_at *time.Time
  974. status *uint8
  975. addstatus *int8
  976. batch_no *string
  977. fromwxid *string
  978. msg *string
  979. tag *string
  980. total *int32
  981. addtotal *int32
  982. success *int32
  983. addsuccess *int32
  984. fail *int32
  985. addfail *int32
  986. start_time *time.Time
  987. stop_time *time.Time
  988. clearedFields map[string]struct{}
  989. done bool
  990. oldValue func(context.Context) (*BatchMsg, error)
  991. predicates []predicate.BatchMsg
  992. }
  993. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  994. // batchmsgOption allows management of the mutation configuration using functional options.
  995. type batchmsgOption func(*BatchMsgMutation)
  996. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  997. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  998. m := &BatchMsgMutation{
  999. config: c,
  1000. op: op,
  1001. typ: TypeBatchMsg,
  1002. clearedFields: make(map[string]struct{}),
  1003. }
  1004. for _, opt := range opts {
  1005. opt(m)
  1006. }
  1007. return m
  1008. }
  1009. // withBatchMsgID sets the ID field of the mutation.
  1010. func withBatchMsgID(id uint64) batchmsgOption {
  1011. return func(m *BatchMsgMutation) {
  1012. var (
  1013. err error
  1014. once sync.Once
  1015. value *BatchMsg
  1016. )
  1017. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  1018. once.Do(func() {
  1019. if m.done {
  1020. err = errors.New("querying old values post mutation is not allowed")
  1021. } else {
  1022. value, err = m.Client().BatchMsg.Get(ctx, id)
  1023. }
  1024. })
  1025. return value, err
  1026. }
  1027. m.id = &id
  1028. }
  1029. }
  1030. // withBatchMsg sets the old BatchMsg of the mutation.
  1031. func withBatchMsg(node *BatchMsg) batchmsgOption {
  1032. return func(m *BatchMsgMutation) {
  1033. m.oldValue = func(context.Context) (*BatchMsg, error) {
  1034. return node, nil
  1035. }
  1036. m.id = &node.ID
  1037. }
  1038. }
  1039. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1040. // executed in a transaction (ent.Tx), a transactional client is returned.
  1041. func (m BatchMsgMutation) Client() *Client {
  1042. client := &Client{config: m.config}
  1043. client.init()
  1044. return client
  1045. }
  1046. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1047. // it returns an error otherwise.
  1048. func (m BatchMsgMutation) Tx() (*Tx, error) {
  1049. if _, ok := m.driver.(*txDriver); !ok {
  1050. return nil, errors.New("ent: mutation is not running in a transaction")
  1051. }
  1052. tx := &Tx{config: m.config}
  1053. tx.init()
  1054. return tx, nil
  1055. }
  1056. // SetID sets the value of the id field. Note that this
  1057. // operation is only accepted on creation of BatchMsg entities.
  1058. func (m *BatchMsgMutation) SetID(id uint64) {
  1059. m.id = &id
  1060. }
  1061. // ID returns the ID value in the mutation. Note that the ID is only available
  1062. // if it was provided to the builder or after it was returned from the database.
  1063. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  1064. if m.id == nil {
  1065. return
  1066. }
  1067. return *m.id, true
  1068. }
  1069. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1070. // That means, if the mutation is applied within a transaction with an isolation level such
  1071. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1072. // or updated by the mutation.
  1073. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  1074. switch {
  1075. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1076. id, exists := m.ID()
  1077. if exists {
  1078. return []uint64{id}, nil
  1079. }
  1080. fallthrough
  1081. case m.op.Is(OpUpdate | OpDelete):
  1082. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  1083. default:
  1084. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1085. }
  1086. }
  1087. // SetCreatedAt sets the "created_at" field.
  1088. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  1089. m.created_at = &t
  1090. }
  1091. // CreatedAt returns the value of the "created_at" field in the mutation.
  1092. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  1093. v := m.created_at
  1094. if v == nil {
  1095. return
  1096. }
  1097. return *v, true
  1098. }
  1099. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  1100. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1102. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  1103. if !m.op.Is(OpUpdateOne) {
  1104. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  1105. }
  1106. if m.id == nil || m.oldValue == nil {
  1107. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  1108. }
  1109. oldValue, err := m.oldValue(ctx)
  1110. if err != nil {
  1111. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  1112. }
  1113. return oldValue.CreatedAt, nil
  1114. }
  1115. // ResetCreatedAt resets all changes to the "created_at" field.
  1116. func (m *BatchMsgMutation) ResetCreatedAt() {
  1117. m.created_at = nil
  1118. }
  1119. // SetUpdatedAt sets the "updated_at" field.
  1120. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  1121. m.updated_at = &t
  1122. }
  1123. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  1124. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  1125. v := m.updated_at
  1126. if v == nil {
  1127. return
  1128. }
  1129. return *v, true
  1130. }
  1131. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  1132. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1134. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  1135. if !m.op.Is(OpUpdateOne) {
  1136. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  1137. }
  1138. if m.id == nil || m.oldValue == nil {
  1139. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  1140. }
  1141. oldValue, err := m.oldValue(ctx)
  1142. if err != nil {
  1143. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  1144. }
  1145. return oldValue.UpdatedAt, nil
  1146. }
  1147. // ResetUpdatedAt resets all changes to the "updated_at" field.
  1148. func (m *BatchMsgMutation) ResetUpdatedAt() {
  1149. m.updated_at = nil
  1150. }
  1151. // SetDeletedAt sets the "deleted_at" field.
  1152. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  1153. m.deleted_at = &t
  1154. }
  1155. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  1156. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  1157. v := m.deleted_at
  1158. if v == nil {
  1159. return
  1160. }
  1161. return *v, true
  1162. }
  1163. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  1164. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1166. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  1167. if !m.op.Is(OpUpdateOne) {
  1168. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  1169. }
  1170. if m.id == nil || m.oldValue == nil {
  1171. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  1172. }
  1173. oldValue, err := m.oldValue(ctx)
  1174. if err != nil {
  1175. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  1176. }
  1177. return oldValue.DeletedAt, nil
  1178. }
  1179. // ClearDeletedAt clears the value of the "deleted_at" field.
  1180. func (m *BatchMsgMutation) ClearDeletedAt() {
  1181. m.deleted_at = nil
  1182. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  1183. }
  1184. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  1185. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  1186. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  1187. return ok
  1188. }
  1189. // ResetDeletedAt resets all changes to the "deleted_at" field.
  1190. func (m *BatchMsgMutation) ResetDeletedAt() {
  1191. m.deleted_at = nil
  1192. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  1193. }
  1194. // SetStatus sets the "status" field.
  1195. func (m *BatchMsgMutation) SetStatus(u uint8) {
  1196. m.status = &u
  1197. m.addstatus = nil
  1198. }
  1199. // Status returns the value of the "status" field in the mutation.
  1200. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  1201. v := m.status
  1202. if v == nil {
  1203. return
  1204. }
  1205. return *v, true
  1206. }
  1207. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  1208. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1210. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  1211. if !m.op.Is(OpUpdateOne) {
  1212. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  1213. }
  1214. if m.id == nil || m.oldValue == nil {
  1215. return v, errors.New("OldStatus requires an ID field in the mutation")
  1216. }
  1217. oldValue, err := m.oldValue(ctx)
  1218. if err != nil {
  1219. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  1220. }
  1221. return oldValue.Status, nil
  1222. }
  1223. // AddStatus adds u to the "status" field.
  1224. func (m *BatchMsgMutation) AddStatus(u int8) {
  1225. if m.addstatus != nil {
  1226. *m.addstatus += u
  1227. } else {
  1228. m.addstatus = &u
  1229. }
  1230. }
  1231. // AddedStatus returns the value that was added to the "status" field in this mutation.
  1232. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  1233. v := m.addstatus
  1234. if v == nil {
  1235. return
  1236. }
  1237. return *v, true
  1238. }
  1239. // ClearStatus clears the value of the "status" field.
  1240. func (m *BatchMsgMutation) ClearStatus() {
  1241. m.status = nil
  1242. m.addstatus = nil
  1243. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  1244. }
  1245. // StatusCleared returns if the "status" field was cleared in this mutation.
  1246. func (m *BatchMsgMutation) StatusCleared() bool {
  1247. _, ok := m.clearedFields[batchmsg.FieldStatus]
  1248. return ok
  1249. }
  1250. // ResetStatus resets all changes to the "status" field.
  1251. func (m *BatchMsgMutation) ResetStatus() {
  1252. m.status = nil
  1253. m.addstatus = nil
  1254. delete(m.clearedFields, batchmsg.FieldStatus)
  1255. }
  1256. // SetBatchNo sets the "batch_no" field.
  1257. func (m *BatchMsgMutation) SetBatchNo(s string) {
  1258. m.batch_no = &s
  1259. }
  1260. // BatchNo returns the value of the "batch_no" field in the mutation.
  1261. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  1262. v := m.batch_no
  1263. if v == nil {
  1264. return
  1265. }
  1266. return *v, true
  1267. }
  1268. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  1269. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1271. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  1272. if !m.op.Is(OpUpdateOne) {
  1273. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  1274. }
  1275. if m.id == nil || m.oldValue == nil {
  1276. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  1277. }
  1278. oldValue, err := m.oldValue(ctx)
  1279. if err != nil {
  1280. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  1281. }
  1282. return oldValue.BatchNo, nil
  1283. }
  1284. // ClearBatchNo clears the value of the "batch_no" field.
  1285. func (m *BatchMsgMutation) ClearBatchNo() {
  1286. m.batch_no = nil
  1287. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  1288. }
  1289. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  1290. func (m *BatchMsgMutation) BatchNoCleared() bool {
  1291. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  1292. return ok
  1293. }
  1294. // ResetBatchNo resets all changes to the "batch_no" field.
  1295. func (m *BatchMsgMutation) ResetBatchNo() {
  1296. m.batch_no = nil
  1297. delete(m.clearedFields, batchmsg.FieldBatchNo)
  1298. }
  1299. // SetFromwxid sets the "fromwxid" field.
  1300. func (m *BatchMsgMutation) SetFromwxid(s string) {
  1301. m.fromwxid = &s
  1302. }
  1303. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  1304. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  1305. v := m.fromwxid
  1306. if v == nil {
  1307. return
  1308. }
  1309. return *v, true
  1310. }
  1311. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  1312. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1314. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  1315. if !m.op.Is(OpUpdateOne) {
  1316. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  1317. }
  1318. if m.id == nil || m.oldValue == nil {
  1319. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  1320. }
  1321. oldValue, err := m.oldValue(ctx)
  1322. if err != nil {
  1323. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  1324. }
  1325. return oldValue.Fromwxid, nil
  1326. }
  1327. // ClearFromwxid clears the value of the "fromwxid" field.
  1328. func (m *BatchMsgMutation) ClearFromwxid() {
  1329. m.fromwxid = nil
  1330. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  1331. }
  1332. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  1333. func (m *BatchMsgMutation) FromwxidCleared() bool {
  1334. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  1335. return ok
  1336. }
  1337. // ResetFromwxid resets all changes to the "fromwxid" field.
  1338. func (m *BatchMsgMutation) ResetFromwxid() {
  1339. m.fromwxid = nil
  1340. delete(m.clearedFields, batchmsg.FieldFromwxid)
  1341. }
  1342. // SetMsg sets the "msg" field.
  1343. func (m *BatchMsgMutation) SetMsg(s string) {
  1344. m.msg = &s
  1345. }
  1346. // Msg returns the value of the "msg" field in the mutation.
  1347. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  1348. v := m.msg
  1349. if v == nil {
  1350. return
  1351. }
  1352. return *v, true
  1353. }
  1354. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  1355. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1357. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  1358. if !m.op.Is(OpUpdateOne) {
  1359. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  1360. }
  1361. if m.id == nil || m.oldValue == nil {
  1362. return v, errors.New("OldMsg requires an ID field in the mutation")
  1363. }
  1364. oldValue, err := m.oldValue(ctx)
  1365. if err != nil {
  1366. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  1367. }
  1368. return oldValue.Msg, nil
  1369. }
  1370. // ClearMsg clears the value of the "msg" field.
  1371. func (m *BatchMsgMutation) ClearMsg() {
  1372. m.msg = nil
  1373. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  1374. }
  1375. // MsgCleared returns if the "msg" field was cleared in this mutation.
  1376. func (m *BatchMsgMutation) MsgCleared() bool {
  1377. _, ok := m.clearedFields[batchmsg.FieldMsg]
  1378. return ok
  1379. }
  1380. // ResetMsg resets all changes to the "msg" field.
  1381. func (m *BatchMsgMutation) ResetMsg() {
  1382. m.msg = nil
  1383. delete(m.clearedFields, batchmsg.FieldMsg)
  1384. }
  1385. // SetTag sets the "tag" field.
  1386. func (m *BatchMsgMutation) SetTag(s string) {
  1387. m.tag = &s
  1388. }
  1389. // Tag returns the value of the "tag" field in the mutation.
  1390. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  1391. v := m.tag
  1392. if v == nil {
  1393. return
  1394. }
  1395. return *v, true
  1396. }
  1397. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  1398. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1400. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  1401. if !m.op.Is(OpUpdateOne) {
  1402. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  1403. }
  1404. if m.id == nil || m.oldValue == nil {
  1405. return v, errors.New("OldTag requires an ID field in the mutation")
  1406. }
  1407. oldValue, err := m.oldValue(ctx)
  1408. if err != nil {
  1409. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  1410. }
  1411. return oldValue.Tag, nil
  1412. }
  1413. // ClearTag clears the value of the "tag" field.
  1414. func (m *BatchMsgMutation) ClearTag() {
  1415. m.tag = nil
  1416. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  1417. }
  1418. // TagCleared returns if the "tag" field was cleared in this mutation.
  1419. func (m *BatchMsgMutation) TagCleared() bool {
  1420. _, ok := m.clearedFields[batchmsg.FieldTag]
  1421. return ok
  1422. }
  1423. // ResetTag resets all changes to the "tag" field.
  1424. func (m *BatchMsgMutation) ResetTag() {
  1425. m.tag = nil
  1426. delete(m.clearedFields, batchmsg.FieldTag)
  1427. }
  1428. // SetTotal sets the "total" field.
  1429. func (m *BatchMsgMutation) SetTotal(i int32) {
  1430. m.total = &i
  1431. m.addtotal = nil
  1432. }
  1433. // Total returns the value of the "total" field in the mutation.
  1434. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  1435. v := m.total
  1436. if v == nil {
  1437. return
  1438. }
  1439. return *v, true
  1440. }
  1441. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  1442. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1444. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  1445. if !m.op.Is(OpUpdateOne) {
  1446. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  1447. }
  1448. if m.id == nil || m.oldValue == nil {
  1449. return v, errors.New("OldTotal requires an ID field in the mutation")
  1450. }
  1451. oldValue, err := m.oldValue(ctx)
  1452. if err != nil {
  1453. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  1454. }
  1455. return oldValue.Total, nil
  1456. }
  1457. // AddTotal adds i to the "total" field.
  1458. func (m *BatchMsgMutation) AddTotal(i int32) {
  1459. if m.addtotal != nil {
  1460. *m.addtotal += i
  1461. } else {
  1462. m.addtotal = &i
  1463. }
  1464. }
  1465. // AddedTotal returns the value that was added to the "total" field in this mutation.
  1466. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  1467. v := m.addtotal
  1468. if v == nil {
  1469. return
  1470. }
  1471. return *v, true
  1472. }
  1473. // ClearTotal clears the value of the "total" field.
  1474. func (m *BatchMsgMutation) ClearTotal() {
  1475. m.total = nil
  1476. m.addtotal = nil
  1477. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  1478. }
  1479. // TotalCleared returns if the "total" field was cleared in this mutation.
  1480. func (m *BatchMsgMutation) TotalCleared() bool {
  1481. _, ok := m.clearedFields[batchmsg.FieldTotal]
  1482. return ok
  1483. }
  1484. // ResetTotal resets all changes to the "total" field.
  1485. func (m *BatchMsgMutation) ResetTotal() {
  1486. m.total = nil
  1487. m.addtotal = nil
  1488. delete(m.clearedFields, batchmsg.FieldTotal)
  1489. }
  1490. // SetSuccess sets the "success" field.
  1491. func (m *BatchMsgMutation) SetSuccess(i int32) {
  1492. m.success = &i
  1493. m.addsuccess = nil
  1494. }
  1495. // Success returns the value of the "success" field in the mutation.
  1496. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  1497. v := m.success
  1498. if v == nil {
  1499. return
  1500. }
  1501. return *v, true
  1502. }
  1503. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  1504. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1506. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  1507. if !m.op.Is(OpUpdateOne) {
  1508. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  1509. }
  1510. if m.id == nil || m.oldValue == nil {
  1511. return v, errors.New("OldSuccess requires an ID field in the mutation")
  1512. }
  1513. oldValue, err := m.oldValue(ctx)
  1514. if err != nil {
  1515. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  1516. }
  1517. return oldValue.Success, nil
  1518. }
  1519. // AddSuccess adds i to the "success" field.
  1520. func (m *BatchMsgMutation) AddSuccess(i int32) {
  1521. if m.addsuccess != nil {
  1522. *m.addsuccess += i
  1523. } else {
  1524. m.addsuccess = &i
  1525. }
  1526. }
  1527. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  1528. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  1529. v := m.addsuccess
  1530. if v == nil {
  1531. return
  1532. }
  1533. return *v, true
  1534. }
  1535. // ClearSuccess clears the value of the "success" field.
  1536. func (m *BatchMsgMutation) ClearSuccess() {
  1537. m.success = nil
  1538. m.addsuccess = nil
  1539. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  1540. }
  1541. // SuccessCleared returns if the "success" field was cleared in this mutation.
  1542. func (m *BatchMsgMutation) SuccessCleared() bool {
  1543. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  1544. return ok
  1545. }
  1546. // ResetSuccess resets all changes to the "success" field.
  1547. func (m *BatchMsgMutation) ResetSuccess() {
  1548. m.success = nil
  1549. m.addsuccess = nil
  1550. delete(m.clearedFields, batchmsg.FieldSuccess)
  1551. }
  1552. // SetFail sets the "fail" field.
  1553. func (m *BatchMsgMutation) SetFail(i int32) {
  1554. m.fail = &i
  1555. m.addfail = nil
  1556. }
  1557. // Fail returns the value of the "fail" field in the mutation.
  1558. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  1559. v := m.fail
  1560. if v == nil {
  1561. return
  1562. }
  1563. return *v, true
  1564. }
  1565. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  1566. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1568. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  1569. if !m.op.Is(OpUpdateOne) {
  1570. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  1571. }
  1572. if m.id == nil || m.oldValue == nil {
  1573. return v, errors.New("OldFail requires an ID field in the mutation")
  1574. }
  1575. oldValue, err := m.oldValue(ctx)
  1576. if err != nil {
  1577. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  1578. }
  1579. return oldValue.Fail, nil
  1580. }
  1581. // AddFail adds i to the "fail" field.
  1582. func (m *BatchMsgMutation) AddFail(i int32) {
  1583. if m.addfail != nil {
  1584. *m.addfail += i
  1585. } else {
  1586. m.addfail = &i
  1587. }
  1588. }
  1589. // AddedFail returns the value that was added to the "fail" field in this mutation.
  1590. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  1591. v := m.addfail
  1592. if v == nil {
  1593. return
  1594. }
  1595. return *v, true
  1596. }
  1597. // ClearFail clears the value of the "fail" field.
  1598. func (m *BatchMsgMutation) ClearFail() {
  1599. m.fail = nil
  1600. m.addfail = nil
  1601. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  1602. }
  1603. // FailCleared returns if the "fail" field was cleared in this mutation.
  1604. func (m *BatchMsgMutation) FailCleared() bool {
  1605. _, ok := m.clearedFields[batchmsg.FieldFail]
  1606. return ok
  1607. }
  1608. // ResetFail resets all changes to the "fail" field.
  1609. func (m *BatchMsgMutation) ResetFail() {
  1610. m.fail = nil
  1611. m.addfail = nil
  1612. delete(m.clearedFields, batchmsg.FieldFail)
  1613. }
  1614. // SetStartTime sets the "start_time" field.
  1615. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  1616. m.start_time = &t
  1617. }
  1618. // StartTime returns the value of the "start_time" field in the mutation.
  1619. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  1620. v := m.start_time
  1621. if v == nil {
  1622. return
  1623. }
  1624. return *v, true
  1625. }
  1626. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  1627. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1629. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  1630. if !m.op.Is(OpUpdateOne) {
  1631. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  1632. }
  1633. if m.id == nil || m.oldValue == nil {
  1634. return v, errors.New("OldStartTime requires an ID field in the mutation")
  1635. }
  1636. oldValue, err := m.oldValue(ctx)
  1637. if err != nil {
  1638. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  1639. }
  1640. return oldValue.StartTime, nil
  1641. }
  1642. // ClearStartTime clears the value of the "start_time" field.
  1643. func (m *BatchMsgMutation) ClearStartTime() {
  1644. m.start_time = nil
  1645. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  1646. }
  1647. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  1648. func (m *BatchMsgMutation) StartTimeCleared() bool {
  1649. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  1650. return ok
  1651. }
  1652. // ResetStartTime resets all changes to the "start_time" field.
  1653. func (m *BatchMsgMutation) ResetStartTime() {
  1654. m.start_time = nil
  1655. delete(m.clearedFields, batchmsg.FieldStartTime)
  1656. }
  1657. // SetStopTime sets the "stop_time" field.
  1658. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  1659. m.stop_time = &t
  1660. }
  1661. // StopTime returns the value of the "stop_time" field in the mutation.
  1662. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  1663. v := m.stop_time
  1664. if v == nil {
  1665. return
  1666. }
  1667. return *v, true
  1668. }
  1669. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  1670. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1672. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  1673. if !m.op.Is(OpUpdateOne) {
  1674. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  1675. }
  1676. if m.id == nil || m.oldValue == nil {
  1677. return v, errors.New("OldStopTime requires an ID field in the mutation")
  1678. }
  1679. oldValue, err := m.oldValue(ctx)
  1680. if err != nil {
  1681. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  1682. }
  1683. return oldValue.StopTime, nil
  1684. }
  1685. // ClearStopTime clears the value of the "stop_time" field.
  1686. func (m *BatchMsgMutation) ClearStopTime() {
  1687. m.stop_time = nil
  1688. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  1689. }
  1690. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  1691. func (m *BatchMsgMutation) StopTimeCleared() bool {
  1692. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  1693. return ok
  1694. }
  1695. // ResetStopTime resets all changes to the "stop_time" field.
  1696. func (m *BatchMsgMutation) ResetStopTime() {
  1697. m.stop_time = nil
  1698. delete(m.clearedFields, batchmsg.FieldStopTime)
  1699. }
  1700. // Where appends a list predicates to the BatchMsgMutation builder.
  1701. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  1702. m.predicates = append(m.predicates, ps...)
  1703. }
  1704. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  1705. // users can use type-assertion to append predicates that do not depend on any generated package.
  1706. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  1707. p := make([]predicate.BatchMsg, len(ps))
  1708. for i := range ps {
  1709. p[i] = ps[i]
  1710. }
  1711. m.Where(p...)
  1712. }
  1713. // Op returns the operation name.
  1714. func (m *BatchMsgMutation) Op() Op {
  1715. return m.op
  1716. }
  1717. // SetOp allows setting the mutation operation.
  1718. func (m *BatchMsgMutation) SetOp(op Op) {
  1719. m.op = op
  1720. }
  1721. // Type returns the node type of this mutation (BatchMsg).
  1722. func (m *BatchMsgMutation) Type() string {
  1723. return m.typ
  1724. }
  1725. // Fields returns all fields that were changed during this mutation. Note that in
  1726. // order to get all numeric fields that were incremented/decremented, call
  1727. // AddedFields().
  1728. func (m *BatchMsgMutation) Fields() []string {
  1729. fields := make([]string, 0, 13)
  1730. if m.created_at != nil {
  1731. fields = append(fields, batchmsg.FieldCreatedAt)
  1732. }
  1733. if m.updated_at != nil {
  1734. fields = append(fields, batchmsg.FieldUpdatedAt)
  1735. }
  1736. if m.deleted_at != nil {
  1737. fields = append(fields, batchmsg.FieldDeletedAt)
  1738. }
  1739. if m.status != nil {
  1740. fields = append(fields, batchmsg.FieldStatus)
  1741. }
  1742. if m.batch_no != nil {
  1743. fields = append(fields, batchmsg.FieldBatchNo)
  1744. }
  1745. if m.fromwxid != nil {
  1746. fields = append(fields, batchmsg.FieldFromwxid)
  1747. }
  1748. if m.msg != nil {
  1749. fields = append(fields, batchmsg.FieldMsg)
  1750. }
  1751. if m.tag != nil {
  1752. fields = append(fields, batchmsg.FieldTag)
  1753. }
  1754. if m.total != nil {
  1755. fields = append(fields, batchmsg.FieldTotal)
  1756. }
  1757. if m.success != nil {
  1758. fields = append(fields, batchmsg.FieldSuccess)
  1759. }
  1760. if m.fail != nil {
  1761. fields = append(fields, batchmsg.FieldFail)
  1762. }
  1763. if m.start_time != nil {
  1764. fields = append(fields, batchmsg.FieldStartTime)
  1765. }
  1766. if m.stop_time != nil {
  1767. fields = append(fields, batchmsg.FieldStopTime)
  1768. }
  1769. return fields
  1770. }
  1771. // Field returns the value of a field with the given name. The second boolean
  1772. // return value indicates that this field was not set, or was not defined in the
  1773. // schema.
  1774. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  1775. switch name {
  1776. case batchmsg.FieldCreatedAt:
  1777. return m.CreatedAt()
  1778. case batchmsg.FieldUpdatedAt:
  1779. return m.UpdatedAt()
  1780. case batchmsg.FieldDeletedAt:
  1781. return m.DeletedAt()
  1782. case batchmsg.FieldStatus:
  1783. return m.Status()
  1784. case batchmsg.FieldBatchNo:
  1785. return m.BatchNo()
  1786. case batchmsg.FieldFromwxid:
  1787. return m.Fromwxid()
  1788. case batchmsg.FieldMsg:
  1789. return m.Msg()
  1790. case batchmsg.FieldTag:
  1791. return m.Tag()
  1792. case batchmsg.FieldTotal:
  1793. return m.Total()
  1794. case batchmsg.FieldSuccess:
  1795. return m.Success()
  1796. case batchmsg.FieldFail:
  1797. return m.Fail()
  1798. case batchmsg.FieldStartTime:
  1799. return m.StartTime()
  1800. case batchmsg.FieldStopTime:
  1801. return m.StopTime()
  1802. }
  1803. return nil, false
  1804. }
  1805. // OldField returns the old value of the field from the database. An error is
  1806. // returned if the mutation operation is not UpdateOne, or the query to the
  1807. // database failed.
  1808. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1809. switch name {
  1810. case batchmsg.FieldCreatedAt:
  1811. return m.OldCreatedAt(ctx)
  1812. case batchmsg.FieldUpdatedAt:
  1813. return m.OldUpdatedAt(ctx)
  1814. case batchmsg.FieldDeletedAt:
  1815. return m.OldDeletedAt(ctx)
  1816. case batchmsg.FieldStatus:
  1817. return m.OldStatus(ctx)
  1818. case batchmsg.FieldBatchNo:
  1819. return m.OldBatchNo(ctx)
  1820. case batchmsg.FieldFromwxid:
  1821. return m.OldFromwxid(ctx)
  1822. case batchmsg.FieldMsg:
  1823. return m.OldMsg(ctx)
  1824. case batchmsg.FieldTag:
  1825. return m.OldTag(ctx)
  1826. case batchmsg.FieldTotal:
  1827. return m.OldTotal(ctx)
  1828. case batchmsg.FieldSuccess:
  1829. return m.OldSuccess(ctx)
  1830. case batchmsg.FieldFail:
  1831. return m.OldFail(ctx)
  1832. case batchmsg.FieldStartTime:
  1833. return m.OldStartTime(ctx)
  1834. case batchmsg.FieldStopTime:
  1835. return m.OldStopTime(ctx)
  1836. }
  1837. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  1838. }
  1839. // SetField sets the value of a field with the given name. It returns an error if
  1840. // the field is not defined in the schema, or if the type mismatched the field
  1841. // type.
  1842. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  1843. switch name {
  1844. case batchmsg.FieldCreatedAt:
  1845. v, ok := value.(time.Time)
  1846. if !ok {
  1847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1848. }
  1849. m.SetCreatedAt(v)
  1850. return nil
  1851. case batchmsg.FieldUpdatedAt:
  1852. v, ok := value.(time.Time)
  1853. if !ok {
  1854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1855. }
  1856. m.SetUpdatedAt(v)
  1857. return nil
  1858. case batchmsg.FieldDeletedAt:
  1859. v, ok := value.(time.Time)
  1860. if !ok {
  1861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1862. }
  1863. m.SetDeletedAt(v)
  1864. return nil
  1865. case batchmsg.FieldStatus:
  1866. v, ok := value.(uint8)
  1867. if !ok {
  1868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1869. }
  1870. m.SetStatus(v)
  1871. return nil
  1872. case batchmsg.FieldBatchNo:
  1873. v, ok := value.(string)
  1874. if !ok {
  1875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1876. }
  1877. m.SetBatchNo(v)
  1878. return nil
  1879. case batchmsg.FieldFromwxid:
  1880. v, ok := value.(string)
  1881. if !ok {
  1882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1883. }
  1884. m.SetFromwxid(v)
  1885. return nil
  1886. case batchmsg.FieldMsg:
  1887. v, ok := value.(string)
  1888. if !ok {
  1889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1890. }
  1891. m.SetMsg(v)
  1892. return nil
  1893. case batchmsg.FieldTag:
  1894. v, ok := value.(string)
  1895. if !ok {
  1896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1897. }
  1898. m.SetTag(v)
  1899. return nil
  1900. case batchmsg.FieldTotal:
  1901. v, ok := value.(int32)
  1902. if !ok {
  1903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1904. }
  1905. m.SetTotal(v)
  1906. return nil
  1907. case batchmsg.FieldSuccess:
  1908. v, ok := value.(int32)
  1909. if !ok {
  1910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1911. }
  1912. m.SetSuccess(v)
  1913. return nil
  1914. case batchmsg.FieldFail:
  1915. v, ok := value.(int32)
  1916. if !ok {
  1917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1918. }
  1919. m.SetFail(v)
  1920. return nil
  1921. case batchmsg.FieldStartTime:
  1922. v, ok := value.(time.Time)
  1923. if !ok {
  1924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1925. }
  1926. m.SetStartTime(v)
  1927. return nil
  1928. case batchmsg.FieldStopTime:
  1929. v, ok := value.(time.Time)
  1930. if !ok {
  1931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1932. }
  1933. m.SetStopTime(v)
  1934. return nil
  1935. }
  1936. return fmt.Errorf("unknown BatchMsg field %s", name)
  1937. }
  1938. // AddedFields returns all numeric fields that were incremented/decremented during
  1939. // this mutation.
  1940. func (m *BatchMsgMutation) AddedFields() []string {
  1941. var fields []string
  1942. if m.addstatus != nil {
  1943. fields = append(fields, batchmsg.FieldStatus)
  1944. }
  1945. if m.addtotal != nil {
  1946. fields = append(fields, batchmsg.FieldTotal)
  1947. }
  1948. if m.addsuccess != nil {
  1949. fields = append(fields, batchmsg.FieldSuccess)
  1950. }
  1951. if m.addfail != nil {
  1952. fields = append(fields, batchmsg.FieldFail)
  1953. }
  1954. return fields
  1955. }
  1956. // AddedField returns the numeric value that was incremented/decremented on a field
  1957. // with the given name. The second boolean return value indicates that this field
  1958. // was not set, or was not defined in the schema.
  1959. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  1960. switch name {
  1961. case batchmsg.FieldStatus:
  1962. return m.AddedStatus()
  1963. case batchmsg.FieldTotal:
  1964. return m.AddedTotal()
  1965. case batchmsg.FieldSuccess:
  1966. return m.AddedSuccess()
  1967. case batchmsg.FieldFail:
  1968. return m.AddedFail()
  1969. }
  1970. return nil, false
  1971. }
  1972. // AddField adds the value to the field with the given name. It returns an error if
  1973. // the field is not defined in the schema, or if the type mismatched the field
  1974. // type.
  1975. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  1976. switch name {
  1977. case batchmsg.FieldStatus:
  1978. v, ok := value.(int8)
  1979. if !ok {
  1980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1981. }
  1982. m.AddStatus(v)
  1983. return nil
  1984. case batchmsg.FieldTotal:
  1985. v, ok := value.(int32)
  1986. if !ok {
  1987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1988. }
  1989. m.AddTotal(v)
  1990. return nil
  1991. case batchmsg.FieldSuccess:
  1992. v, ok := value.(int32)
  1993. if !ok {
  1994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1995. }
  1996. m.AddSuccess(v)
  1997. return nil
  1998. case batchmsg.FieldFail:
  1999. v, ok := value.(int32)
  2000. if !ok {
  2001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2002. }
  2003. m.AddFail(v)
  2004. return nil
  2005. }
  2006. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  2007. }
  2008. // ClearedFields returns all nullable fields that were cleared during this
  2009. // mutation.
  2010. func (m *BatchMsgMutation) ClearedFields() []string {
  2011. var fields []string
  2012. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  2013. fields = append(fields, batchmsg.FieldDeletedAt)
  2014. }
  2015. if m.FieldCleared(batchmsg.FieldStatus) {
  2016. fields = append(fields, batchmsg.FieldStatus)
  2017. }
  2018. if m.FieldCleared(batchmsg.FieldBatchNo) {
  2019. fields = append(fields, batchmsg.FieldBatchNo)
  2020. }
  2021. if m.FieldCleared(batchmsg.FieldFromwxid) {
  2022. fields = append(fields, batchmsg.FieldFromwxid)
  2023. }
  2024. if m.FieldCleared(batchmsg.FieldMsg) {
  2025. fields = append(fields, batchmsg.FieldMsg)
  2026. }
  2027. if m.FieldCleared(batchmsg.FieldTag) {
  2028. fields = append(fields, batchmsg.FieldTag)
  2029. }
  2030. if m.FieldCleared(batchmsg.FieldTotal) {
  2031. fields = append(fields, batchmsg.FieldTotal)
  2032. }
  2033. if m.FieldCleared(batchmsg.FieldSuccess) {
  2034. fields = append(fields, batchmsg.FieldSuccess)
  2035. }
  2036. if m.FieldCleared(batchmsg.FieldFail) {
  2037. fields = append(fields, batchmsg.FieldFail)
  2038. }
  2039. if m.FieldCleared(batchmsg.FieldStartTime) {
  2040. fields = append(fields, batchmsg.FieldStartTime)
  2041. }
  2042. if m.FieldCleared(batchmsg.FieldStopTime) {
  2043. fields = append(fields, batchmsg.FieldStopTime)
  2044. }
  2045. return fields
  2046. }
  2047. // FieldCleared returns a boolean indicating if a field with the given name was
  2048. // cleared in this mutation.
  2049. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  2050. _, ok := m.clearedFields[name]
  2051. return ok
  2052. }
  2053. // ClearField clears the value of the field with the given name. It returns an
  2054. // error if the field is not defined in the schema.
  2055. func (m *BatchMsgMutation) ClearField(name string) error {
  2056. switch name {
  2057. case batchmsg.FieldDeletedAt:
  2058. m.ClearDeletedAt()
  2059. return nil
  2060. case batchmsg.FieldStatus:
  2061. m.ClearStatus()
  2062. return nil
  2063. case batchmsg.FieldBatchNo:
  2064. m.ClearBatchNo()
  2065. return nil
  2066. case batchmsg.FieldFromwxid:
  2067. m.ClearFromwxid()
  2068. return nil
  2069. case batchmsg.FieldMsg:
  2070. m.ClearMsg()
  2071. return nil
  2072. case batchmsg.FieldTag:
  2073. m.ClearTag()
  2074. return nil
  2075. case batchmsg.FieldTotal:
  2076. m.ClearTotal()
  2077. return nil
  2078. case batchmsg.FieldSuccess:
  2079. m.ClearSuccess()
  2080. return nil
  2081. case batchmsg.FieldFail:
  2082. m.ClearFail()
  2083. return nil
  2084. case batchmsg.FieldStartTime:
  2085. m.ClearStartTime()
  2086. return nil
  2087. case batchmsg.FieldStopTime:
  2088. m.ClearStopTime()
  2089. return nil
  2090. }
  2091. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  2092. }
  2093. // ResetField resets all changes in the mutation for the field with the given name.
  2094. // It returns an error if the field is not defined in the schema.
  2095. func (m *BatchMsgMutation) ResetField(name string) error {
  2096. switch name {
  2097. case batchmsg.FieldCreatedAt:
  2098. m.ResetCreatedAt()
  2099. return nil
  2100. case batchmsg.FieldUpdatedAt:
  2101. m.ResetUpdatedAt()
  2102. return nil
  2103. case batchmsg.FieldDeletedAt:
  2104. m.ResetDeletedAt()
  2105. return nil
  2106. case batchmsg.FieldStatus:
  2107. m.ResetStatus()
  2108. return nil
  2109. case batchmsg.FieldBatchNo:
  2110. m.ResetBatchNo()
  2111. return nil
  2112. case batchmsg.FieldFromwxid:
  2113. m.ResetFromwxid()
  2114. return nil
  2115. case batchmsg.FieldMsg:
  2116. m.ResetMsg()
  2117. return nil
  2118. case batchmsg.FieldTag:
  2119. m.ResetTag()
  2120. return nil
  2121. case batchmsg.FieldTotal:
  2122. m.ResetTotal()
  2123. return nil
  2124. case batchmsg.FieldSuccess:
  2125. m.ResetSuccess()
  2126. return nil
  2127. case batchmsg.FieldFail:
  2128. m.ResetFail()
  2129. return nil
  2130. case batchmsg.FieldStartTime:
  2131. m.ResetStartTime()
  2132. return nil
  2133. case batchmsg.FieldStopTime:
  2134. m.ResetStopTime()
  2135. return nil
  2136. }
  2137. return fmt.Errorf("unknown BatchMsg field %s", name)
  2138. }
  2139. // AddedEdges returns all edge names that were set/added in this mutation.
  2140. func (m *BatchMsgMutation) AddedEdges() []string {
  2141. edges := make([]string, 0, 0)
  2142. return edges
  2143. }
  2144. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2145. // name in this mutation.
  2146. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  2147. return nil
  2148. }
  2149. // RemovedEdges returns all edge names that were removed in this mutation.
  2150. func (m *BatchMsgMutation) RemovedEdges() []string {
  2151. edges := make([]string, 0, 0)
  2152. return edges
  2153. }
  2154. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2155. // the given name in this mutation.
  2156. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  2157. return nil
  2158. }
  2159. // ClearedEdges returns all edge names that were cleared in this mutation.
  2160. func (m *BatchMsgMutation) ClearedEdges() []string {
  2161. edges := make([]string, 0, 0)
  2162. return edges
  2163. }
  2164. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2165. // was cleared in this mutation.
  2166. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  2167. return false
  2168. }
  2169. // ClearEdge clears the value of the edge with the given name. It returns an error
  2170. // if that edge is not defined in the schema.
  2171. func (m *BatchMsgMutation) ClearEdge(name string) error {
  2172. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  2173. }
  2174. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2175. // It returns an error if the edge is not defined in the schema.
  2176. func (m *BatchMsgMutation) ResetEdge(name string) error {
  2177. return fmt.Errorf("unknown BatchMsg edge %s", name)
  2178. }
  2179. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  2180. type ContactMutation struct {
  2181. config
  2182. op Op
  2183. typ string
  2184. id *uint64
  2185. created_at *time.Time
  2186. updated_at *time.Time
  2187. status *uint8
  2188. addstatus *int8
  2189. deleted_at *time.Time
  2190. wx_wxid *string
  2191. _type *int
  2192. add_type *int
  2193. wxid *string
  2194. account *string
  2195. nickname *string
  2196. markname *string
  2197. headimg *string
  2198. sex *int
  2199. addsex *int
  2200. starrole *string
  2201. dontseeit *int
  2202. adddontseeit *int
  2203. dontseeme *int
  2204. adddontseeme *int
  2205. lag *string
  2206. gid *string
  2207. gname *string
  2208. v3 *string
  2209. organization_id *uint64
  2210. addorganization_id *int64
  2211. clearedFields map[string]struct{}
  2212. contact_relationships map[uint64]struct{}
  2213. removedcontact_relationships map[uint64]struct{}
  2214. clearedcontact_relationships bool
  2215. contact_messages map[uint64]struct{}
  2216. removedcontact_messages map[uint64]struct{}
  2217. clearedcontact_messages bool
  2218. done bool
  2219. oldValue func(context.Context) (*Contact, error)
  2220. predicates []predicate.Contact
  2221. }
  2222. var _ ent.Mutation = (*ContactMutation)(nil)
  2223. // contactOption allows management of the mutation configuration using functional options.
  2224. type contactOption func(*ContactMutation)
  2225. // newContactMutation creates new mutation for the Contact entity.
  2226. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  2227. m := &ContactMutation{
  2228. config: c,
  2229. op: op,
  2230. typ: TypeContact,
  2231. clearedFields: make(map[string]struct{}),
  2232. }
  2233. for _, opt := range opts {
  2234. opt(m)
  2235. }
  2236. return m
  2237. }
  2238. // withContactID sets the ID field of the mutation.
  2239. func withContactID(id uint64) contactOption {
  2240. return func(m *ContactMutation) {
  2241. var (
  2242. err error
  2243. once sync.Once
  2244. value *Contact
  2245. )
  2246. m.oldValue = func(ctx context.Context) (*Contact, error) {
  2247. once.Do(func() {
  2248. if m.done {
  2249. err = errors.New("querying old values post mutation is not allowed")
  2250. } else {
  2251. value, err = m.Client().Contact.Get(ctx, id)
  2252. }
  2253. })
  2254. return value, err
  2255. }
  2256. m.id = &id
  2257. }
  2258. }
  2259. // withContact sets the old Contact of the mutation.
  2260. func withContact(node *Contact) contactOption {
  2261. return func(m *ContactMutation) {
  2262. m.oldValue = func(context.Context) (*Contact, error) {
  2263. return node, nil
  2264. }
  2265. m.id = &node.ID
  2266. }
  2267. }
  2268. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2269. // executed in a transaction (ent.Tx), a transactional client is returned.
  2270. func (m ContactMutation) Client() *Client {
  2271. client := &Client{config: m.config}
  2272. client.init()
  2273. return client
  2274. }
  2275. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2276. // it returns an error otherwise.
  2277. func (m ContactMutation) Tx() (*Tx, error) {
  2278. if _, ok := m.driver.(*txDriver); !ok {
  2279. return nil, errors.New("ent: mutation is not running in a transaction")
  2280. }
  2281. tx := &Tx{config: m.config}
  2282. tx.init()
  2283. return tx, nil
  2284. }
  2285. // SetID sets the value of the id field. Note that this
  2286. // operation is only accepted on creation of Contact entities.
  2287. func (m *ContactMutation) SetID(id uint64) {
  2288. m.id = &id
  2289. }
  2290. // ID returns the ID value in the mutation. Note that the ID is only available
  2291. // if it was provided to the builder or after it was returned from the database.
  2292. func (m *ContactMutation) ID() (id uint64, exists bool) {
  2293. if m.id == nil {
  2294. return
  2295. }
  2296. return *m.id, true
  2297. }
  2298. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2299. // That means, if the mutation is applied within a transaction with an isolation level such
  2300. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2301. // or updated by the mutation.
  2302. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  2303. switch {
  2304. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2305. id, exists := m.ID()
  2306. if exists {
  2307. return []uint64{id}, nil
  2308. }
  2309. fallthrough
  2310. case m.op.Is(OpUpdate | OpDelete):
  2311. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  2312. default:
  2313. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2314. }
  2315. }
  2316. // SetCreatedAt sets the "created_at" field.
  2317. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  2318. m.created_at = &t
  2319. }
  2320. // CreatedAt returns the value of the "created_at" field in the mutation.
  2321. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  2322. v := m.created_at
  2323. if v == nil {
  2324. return
  2325. }
  2326. return *v, true
  2327. }
  2328. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  2329. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2331. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2332. if !m.op.Is(OpUpdateOne) {
  2333. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2334. }
  2335. if m.id == nil || m.oldValue == nil {
  2336. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2337. }
  2338. oldValue, err := m.oldValue(ctx)
  2339. if err != nil {
  2340. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2341. }
  2342. return oldValue.CreatedAt, nil
  2343. }
  2344. // ResetCreatedAt resets all changes to the "created_at" field.
  2345. func (m *ContactMutation) ResetCreatedAt() {
  2346. m.created_at = nil
  2347. }
  2348. // SetUpdatedAt sets the "updated_at" field.
  2349. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  2350. m.updated_at = &t
  2351. }
  2352. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2353. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  2354. v := m.updated_at
  2355. if v == nil {
  2356. return
  2357. }
  2358. return *v, true
  2359. }
  2360. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  2361. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2363. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2364. if !m.op.Is(OpUpdateOne) {
  2365. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2366. }
  2367. if m.id == nil || m.oldValue == nil {
  2368. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2369. }
  2370. oldValue, err := m.oldValue(ctx)
  2371. if err != nil {
  2372. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2373. }
  2374. return oldValue.UpdatedAt, nil
  2375. }
  2376. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2377. func (m *ContactMutation) ResetUpdatedAt() {
  2378. m.updated_at = nil
  2379. }
  2380. // SetStatus sets the "status" field.
  2381. func (m *ContactMutation) SetStatus(u uint8) {
  2382. m.status = &u
  2383. m.addstatus = nil
  2384. }
  2385. // Status returns the value of the "status" field in the mutation.
  2386. func (m *ContactMutation) Status() (r uint8, exists bool) {
  2387. v := m.status
  2388. if v == nil {
  2389. return
  2390. }
  2391. return *v, true
  2392. }
  2393. // OldStatus returns the old "status" field's value of the Contact entity.
  2394. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2396. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  2397. if !m.op.Is(OpUpdateOne) {
  2398. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  2399. }
  2400. if m.id == nil || m.oldValue == nil {
  2401. return v, errors.New("OldStatus requires an ID field in the mutation")
  2402. }
  2403. oldValue, err := m.oldValue(ctx)
  2404. if err != nil {
  2405. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  2406. }
  2407. return oldValue.Status, nil
  2408. }
  2409. // AddStatus adds u to the "status" field.
  2410. func (m *ContactMutation) AddStatus(u int8) {
  2411. if m.addstatus != nil {
  2412. *m.addstatus += u
  2413. } else {
  2414. m.addstatus = &u
  2415. }
  2416. }
  2417. // AddedStatus returns the value that was added to the "status" field in this mutation.
  2418. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  2419. v := m.addstatus
  2420. if v == nil {
  2421. return
  2422. }
  2423. return *v, true
  2424. }
  2425. // ClearStatus clears the value of the "status" field.
  2426. func (m *ContactMutation) ClearStatus() {
  2427. m.status = nil
  2428. m.addstatus = nil
  2429. m.clearedFields[contact.FieldStatus] = struct{}{}
  2430. }
  2431. // StatusCleared returns if the "status" field was cleared in this mutation.
  2432. func (m *ContactMutation) StatusCleared() bool {
  2433. _, ok := m.clearedFields[contact.FieldStatus]
  2434. return ok
  2435. }
  2436. // ResetStatus resets all changes to the "status" field.
  2437. func (m *ContactMutation) ResetStatus() {
  2438. m.status = nil
  2439. m.addstatus = nil
  2440. delete(m.clearedFields, contact.FieldStatus)
  2441. }
  2442. // SetDeletedAt sets the "deleted_at" field.
  2443. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  2444. m.deleted_at = &t
  2445. }
  2446. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2447. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  2448. v := m.deleted_at
  2449. if v == nil {
  2450. return
  2451. }
  2452. return *v, true
  2453. }
  2454. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  2455. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2457. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2458. if !m.op.Is(OpUpdateOne) {
  2459. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2460. }
  2461. if m.id == nil || m.oldValue == nil {
  2462. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2463. }
  2464. oldValue, err := m.oldValue(ctx)
  2465. if err != nil {
  2466. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2467. }
  2468. return oldValue.DeletedAt, nil
  2469. }
  2470. // ClearDeletedAt clears the value of the "deleted_at" field.
  2471. func (m *ContactMutation) ClearDeletedAt() {
  2472. m.deleted_at = nil
  2473. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  2474. }
  2475. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2476. func (m *ContactMutation) DeletedAtCleared() bool {
  2477. _, ok := m.clearedFields[contact.FieldDeletedAt]
  2478. return ok
  2479. }
  2480. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2481. func (m *ContactMutation) ResetDeletedAt() {
  2482. m.deleted_at = nil
  2483. delete(m.clearedFields, contact.FieldDeletedAt)
  2484. }
  2485. // SetWxWxid sets the "wx_wxid" field.
  2486. func (m *ContactMutation) SetWxWxid(s string) {
  2487. m.wx_wxid = &s
  2488. }
  2489. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  2490. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  2491. v := m.wx_wxid
  2492. if v == nil {
  2493. return
  2494. }
  2495. return *v, true
  2496. }
  2497. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  2498. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2499. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2500. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  2501. if !m.op.Is(OpUpdateOne) {
  2502. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  2503. }
  2504. if m.id == nil || m.oldValue == nil {
  2505. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  2506. }
  2507. oldValue, err := m.oldValue(ctx)
  2508. if err != nil {
  2509. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  2510. }
  2511. return oldValue.WxWxid, nil
  2512. }
  2513. // ClearWxWxid clears the value of the "wx_wxid" field.
  2514. func (m *ContactMutation) ClearWxWxid() {
  2515. m.wx_wxid = nil
  2516. m.clearedFields[contact.FieldWxWxid] = struct{}{}
  2517. }
  2518. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  2519. func (m *ContactMutation) WxWxidCleared() bool {
  2520. _, ok := m.clearedFields[contact.FieldWxWxid]
  2521. return ok
  2522. }
  2523. // ResetWxWxid resets all changes to the "wx_wxid" field.
  2524. func (m *ContactMutation) ResetWxWxid() {
  2525. m.wx_wxid = nil
  2526. delete(m.clearedFields, contact.FieldWxWxid)
  2527. }
  2528. // SetType sets the "type" field.
  2529. func (m *ContactMutation) SetType(i int) {
  2530. m._type = &i
  2531. m.add_type = nil
  2532. }
  2533. // GetType returns the value of the "type" field in the mutation.
  2534. func (m *ContactMutation) GetType() (r int, exists bool) {
  2535. v := m._type
  2536. if v == nil {
  2537. return
  2538. }
  2539. return *v, true
  2540. }
  2541. // OldType returns the old "type" field's value of the Contact entity.
  2542. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2544. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  2545. if !m.op.Is(OpUpdateOne) {
  2546. return v, errors.New("OldType is only allowed on UpdateOne operations")
  2547. }
  2548. if m.id == nil || m.oldValue == nil {
  2549. return v, errors.New("OldType requires an ID field in the mutation")
  2550. }
  2551. oldValue, err := m.oldValue(ctx)
  2552. if err != nil {
  2553. return v, fmt.Errorf("querying old value for OldType: %w", err)
  2554. }
  2555. return oldValue.Type, nil
  2556. }
  2557. // AddType adds i to the "type" field.
  2558. func (m *ContactMutation) AddType(i int) {
  2559. if m.add_type != nil {
  2560. *m.add_type += i
  2561. } else {
  2562. m.add_type = &i
  2563. }
  2564. }
  2565. // AddedType returns the value that was added to the "type" field in this mutation.
  2566. func (m *ContactMutation) AddedType() (r int, exists bool) {
  2567. v := m.add_type
  2568. if v == nil {
  2569. return
  2570. }
  2571. return *v, true
  2572. }
  2573. // ClearType clears the value of the "type" field.
  2574. func (m *ContactMutation) ClearType() {
  2575. m._type = nil
  2576. m.add_type = nil
  2577. m.clearedFields[contact.FieldType] = struct{}{}
  2578. }
  2579. // TypeCleared returns if the "type" field was cleared in this mutation.
  2580. func (m *ContactMutation) TypeCleared() bool {
  2581. _, ok := m.clearedFields[contact.FieldType]
  2582. return ok
  2583. }
  2584. // ResetType resets all changes to the "type" field.
  2585. func (m *ContactMutation) ResetType() {
  2586. m._type = nil
  2587. m.add_type = nil
  2588. delete(m.clearedFields, contact.FieldType)
  2589. }
  2590. // SetWxid sets the "wxid" field.
  2591. func (m *ContactMutation) SetWxid(s string) {
  2592. m.wxid = &s
  2593. }
  2594. // Wxid returns the value of the "wxid" field in the mutation.
  2595. func (m *ContactMutation) Wxid() (r string, exists bool) {
  2596. v := m.wxid
  2597. if v == nil {
  2598. return
  2599. }
  2600. return *v, true
  2601. }
  2602. // OldWxid returns the old "wxid" field's value of the Contact entity.
  2603. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2605. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  2606. if !m.op.Is(OpUpdateOne) {
  2607. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  2608. }
  2609. if m.id == nil || m.oldValue == nil {
  2610. return v, errors.New("OldWxid requires an ID field in the mutation")
  2611. }
  2612. oldValue, err := m.oldValue(ctx)
  2613. if err != nil {
  2614. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  2615. }
  2616. return oldValue.Wxid, nil
  2617. }
  2618. // ResetWxid resets all changes to the "wxid" field.
  2619. func (m *ContactMutation) ResetWxid() {
  2620. m.wxid = nil
  2621. }
  2622. // SetAccount sets the "account" field.
  2623. func (m *ContactMutation) SetAccount(s string) {
  2624. m.account = &s
  2625. }
  2626. // Account returns the value of the "account" field in the mutation.
  2627. func (m *ContactMutation) Account() (r string, exists bool) {
  2628. v := m.account
  2629. if v == nil {
  2630. return
  2631. }
  2632. return *v, true
  2633. }
  2634. // OldAccount returns the old "account" field's value of the Contact entity.
  2635. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2637. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  2638. if !m.op.Is(OpUpdateOne) {
  2639. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  2640. }
  2641. if m.id == nil || m.oldValue == nil {
  2642. return v, errors.New("OldAccount requires an ID field in the mutation")
  2643. }
  2644. oldValue, err := m.oldValue(ctx)
  2645. if err != nil {
  2646. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  2647. }
  2648. return oldValue.Account, nil
  2649. }
  2650. // ResetAccount resets all changes to the "account" field.
  2651. func (m *ContactMutation) ResetAccount() {
  2652. m.account = nil
  2653. }
  2654. // SetNickname sets the "nickname" field.
  2655. func (m *ContactMutation) SetNickname(s string) {
  2656. m.nickname = &s
  2657. }
  2658. // Nickname returns the value of the "nickname" field in the mutation.
  2659. func (m *ContactMutation) Nickname() (r string, exists bool) {
  2660. v := m.nickname
  2661. if v == nil {
  2662. return
  2663. }
  2664. return *v, true
  2665. }
  2666. // OldNickname returns the old "nickname" field's value of the Contact entity.
  2667. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2669. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  2670. if !m.op.Is(OpUpdateOne) {
  2671. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  2672. }
  2673. if m.id == nil || m.oldValue == nil {
  2674. return v, errors.New("OldNickname requires an ID field in the mutation")
  2675. }
  2676. oldValue, err := m.oldValue(ctx)
  2677. if err != nil {
  2678. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  2679. }
  2680. return oldValue.Nickname, nil
  2681. }
  2682. // ResetNickname resets all changes to the "nickname" field.
  2683. func (m *ContactMutation) ResetNickname() {
  2684. m.nickname = nil
  2685. }
  2686. // SetMarkname sets the "markname" field.
  2687. func (m *ContactMutation) SetMarkname(s string) {
  2688. m.markname = &s
  2689. }
  2690. // Markname returns the value of the "markname" field in the mutation.
  2691. func (m *ContactMutation) Markname() (r string, exists bool) {
  2692. v := m.markname
  2693. if v == nil {
  2694. return
  2695. }
  2696. return *v, true
  2697. }
  2698. // OldMarkname returns the old "markname" field's value of the Contact entity.
  2699. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2701. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  2702. if !m.op.Is(OpUpdateOne) {
  2703. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  2704. }
  2705. if m.id == nil || m.oldValue == nil {
  2706. return v, errors.New("OldMarkname requires an ID field in the mutation")
  2707. }
  2708. oldValue, err := m.oldValue(ctx)
  2709. if err != nil {
  2710. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  2711. }
  2712. return oldValue.Markname, nil
  2713. }
  2714. // ResetMarkname resets all changes to the "markname" field.
  2715. func (m *ContactMutation) ResetMarkname() {
  2716. m.markname = nil
  2717. }
  2718. // SetHeadimg sets the "headimg" field.
  2719. func (m *ContactMutation) SetHeadimg(s string) {
  2720. m.headimg = &s
  2721. }
  2722. // Headimg returns the value of the "headimg" field in the mutation.
  2723. func (m *ContactMutation) Headimg() (r string, exists bool) {
  2724. v := m.headimg
  2725. if v == nil {
  2726. return
  2727. }
  2728. return *v, true
  2729. }
  2730. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  2731. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2733. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  2734. if !m.op.Is(OpUpdateOne) {
  2735. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  2736. }
  2737. if m.id == nil || m.oldValue == nil {
  2738. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  2739. }
  2740. oldValue, err := m.oldValue(ctx)
  2741. if err != nil {
  2742. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  2743. }
  2744. return oldValue.Headimg, nil
  2745. }
  2746. // ResetHeadimg resets all changes to the "headimg" field.
  2747. func (m *ContactMutation) ResetHeadimg() {
  2748. m.headimg = nil
  2749. }
  2750. // SetSex sets the "sex" field.
  2751. func (m *ContactMutation) SetSex(i int) {
  2752. m.sex = &i
  2753. m.addsex = nil
  2754. }
  2755. // Sex returns the value of the "sex" field in the mutation.
  2756. func (m *ContactMutation) Sex() (r int, exists bool) {
  2757. v := m.sex
  2758. if v == nil {
  2759. return
  2760. }
  2761. return *v, true
  2762. }
  2763. // OldSex returns the old "sex" field's value of the Contact entity.
  2764. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2766. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  2767. if !m.op.Is(OpUpdateOne) {
  2768. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  2769. }
  2770. if m.id == nil || m.oldValue == nil {
  2771. return v, errors.New("OldSex requires an ID field in the mutation")
  2772. }
  2773. oldValue, err := m.oldValue(ctx)
  2774. if err != nil {
  2775. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  2776. }
  2777. return oldValue.Sex, nil
  2778. }
  2779. // AddSex adds i to the "sex" field.
  2780. func (m *ContactMutation) AddSex(i int) {
  2781. if m.addsex != nil {
  2782. *m.addsex += i
  2783. } else {
  2784. m.addsex = &i
  2785. }
  2786. }
  2787. // AddedSex returns the value that was added to the "sex" field in this mutation.
  2788. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  2789. v := m.addsex
  2790. if v == nil {
  2791. return
  2792. }
  2793. return *v, true
  2794. }
  2795. // ResetSex resets all changes to the "sex" field.
  2796. func (m *ContactMutation) ResetSex() {
  2797. m.sex = nil
  2798. m.addsex = nil
  2799. }
  2800. // SetStarrole sets the "starrole" field.
  2801. func (m *ContactMutation) SetStarrole(s string) {
  2802. m.starrole = &s
  2803. }
  2804. // Starrole returns the value of the "starrole" field in the mutation.
  2805. func (m *ContactMutation) Starrole() (r string, exists bool) {
  2806. v := m.starrole
  2807. if v == nil {
  2808. return
  2809. }
  2810. return *v, true
  2811. }
  2812. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  2813. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2815. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  2816. if !m.op.Is(OpUpdateOne) {
  2817. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  2818. }
  2819. if m.id == nil || m.oldValue == nil {
  2820. return v, errors.New("OldStarrole requires an ID field in the mutation")
  2821. }
  2822. oldValue, err := m.oldValue(ctx)
  2823. if err != nil {
  2824. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  2825. }
  2826. return oldValue.Starrole, nil
  2827. }
  2828. // ResetStarrole resets all changes to the "starrole" field.
  2829. func (m *ContactMutation) ResetStarrole() {
  2830. m.starrole = nil
  2831. }
  2832. // SetDontseeit sets the "dontseeit" field.
  2833. func (m *ContactMutation) SetDontseeit(i int) {
  2834. m.dontseeit = &i
  2835. m.adddontseeit = nil
  2836. }
  2837. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  2838. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  2839. v := m.dontseeit
  2840. if v == nil {
  2841. return
  2842. }
  2843. return *v, true
  2844. }
  2845. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  2846. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2847. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2848. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  2849. if !m.op.Is(OpUpdateOne) {
  2850. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  2851. }
  2852. if m.id == nil || m.oldValue == nil {
  2853. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  2854. }
  2855. oldValue, err := m.oldValue(ctx)
  2856. if err != nil {
  2857. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  2858. }
  2859. return oldValue.Dontseeit, nil
  2860. }
  2861. // AddDontseeit adds i to the "dontseeit" field.
  2862. func (m *ContactMutation) AddDontseeit(i int) {
  2863. if m.adddontseeit != nil {
  2864. *m.adddontseeit += i
  2865. } else {
  2866. m.adddontseeit = &i
  2867. }
  2868. }
  2869. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  2870. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  2871. v := m.adddontseeit
  2872. if v == nil {
  2873. return
  2874. }
  2875. return *v, true
  2876. }
  2877. // ResetDontseeit resets all changes to the "dontseeit" field.
  2878. func (m *ContactMutation) ResetDontseeit() {
  2879. m.dontseeit = nil
  2880. m.adddontseeit = nil
  2881. }
  2882. // SetDontseeme sets the "dontseeme" field.
  2883. func (m *ContactMutation) SetDontseeme(i int) {
  2884. m.dontseeme = &i
  2885. m.adddontseeme = nil
  2886. }
  2887. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  2888. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  2889. v := m.dontseeme
  2890. if v == nil {
  2891. return
  2892. }
  2893. return *v, true
  2894. }
  2895. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  2896. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2897. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2898. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  2899. if !m.op.Is(OpUpdateOne) {
  2900. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  2901. }
  2902. if m.id == nil || m.oldValue == nil {
  2903. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  2904. }
  2905. oldValue, err := m.oldValue(ctx)
  2906. if err != nil {
  2907. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  2908. }
  2909. return oldValue.Dontseeme, nil
  2910. }
  2911. // AddDontseeme adds i to the "dontseeme" field.
  2912. func (m *ContactMutation) AddDontseeme(i int) {
  2913. if m.adddontseeme != nil {
  2914. *m.adddontseeme += i
  2915. } else {
  2916. m.adddontseeme = &i
  2917. }
  2918. }
  2919. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  2920. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  2921. v := m.adddontseeme
  2922. if v == nil {
  2923. return
  2924. }
  2925. return *v, true
  2926. }
  2927. // ResetDontseeme resets all changes to the "dontseeme" field.
  2928. func (m *ContactMutation) ResetDontseeme() {
  2929. m.dontseeme = nil
  2930. m.adddontseeme = nil
  2931. }
  2932. // SetLag sets the "lag" field.
  2933. func (m *ContactMutation) SetLag(s string) {
  2934. m.lag = &s
  2935. }
  2936. // Lag returns the value of the "lag" field in the mutation.
  2937. func (m *ContactMutation) Lag() (r string, exists bool) {
  2938. v := m.lag
  2939. if v == nil {
  2940. return
  2941. }
  2942. return *v, true
  2943. }
  2944. // OldLag returns the old "lag" field's value of the Contact entity.
  2945. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2947. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  2948. if !m.op.Is(OpUpdateOne) {
  2949. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  2950. }
  2951. if m.id == nil || m.oldValue == nil {
  2952. return v, errors.New("OldLag requires an ID field in the mutation")
  2953. }
  2954. oldValue, err := m.oldValue(ctx)
  2955. if err != nil {
  2956. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  2957. }
  2958. return oldValue.Lag, nil
  2959. }
  2960. // ResetLag resets all changes to the "lag" field.
  2961. func (m *ContactMutation) ResetLag() {
  2962. m.lag = nil
  2963. }
  2964. // SetGid sets the "gid" field.
  2965. func (m *ContactMutation) SetGid(s string) {
  2966. m.gid = &s
  2967. }
  2968. // Gid returns the value of the "gid" field in the mutation.
  2969. func (m *ContactMutation) Gid() (r string, exists bool) {
  2970. v := m.gid
  2971. if v == nil {
  2972. return
  2973. }
  2974. return *v, true
  2975. }
  2976. // OldGid returns the old "gid" field's value of the Contact entity.
  2977. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2978. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2979. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  2980. if !m.op.Is(OpUpdateOne) {
  2981. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  2982. }
  2983. if m.id == nil || m.oldValue == nil {
  2984. return v, errors.New("OldGid requires an ID field in the mutation")
  2985. }
  2986. oldValue, err := m.oldValue(ctx)
  2987. if err != nil {
  2988. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  2989. }
  2990. return oldValue.Gid, nil
  2991. }
  2992. // ResetGid resets all changes to the "gid" field.
  2993. func (m *ContactMutation) ResetGid() {
  2994. m.gid = nil
  2995. }
  2996. // SetGname sets the "gname" field.
  2997. func (m *ContactMutation) SetGname(s string) {
  2998. m.gname = &s
  2999. }
  3000. // Gname returns the value of the "gname" field in the mutation.
  3001. func (m *ContactMutation) Gname() (r string, exists bool) {
  3002. v := m.gname
  3003. if v == nil {
  3004. return
  3005. }
  3006. return *v, true
  3007. }
  3008. // OldGname returns the old "gname" field's value of the Contact entity.
  3009. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3010. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3011. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  3012. if !m.op.Is(OpUpdateOne) {
  3013. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  3014. }
  3015. if m.id == nil || m.oldValue == nil {
  3016. return v, errors.New("OldGname requires an ID field in the mutation")
  3017. }
  3018. oldValue, err := m.oldValue(ctx)
  3019. if err != nil {
  3020. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  3021. }
  3022. return oldValue.Gname, nil
  3023. }
  3024. // ResetGname resets all changes to the "gname" field.
  3025. func (m *ContactMutation) ResetGname() {
  3026. m.gname = nil
  3027. }
  3028. // SetV3 sets the "v3" field.
  3029. func (m *ContactMutation) SetV3(s string) {
  3030. m.v3 = &s
  3031. }
  3032. // V3 returns the value of the "v3" field in the mutation.
  3033. func (m *ContactMutation) V3() (r string, exists bool) {
  3034. v := m.v3
  3035. if v == nil {
  3036. return
  3037. }
  3038. return *v, true
  3039. }
  3040. // OldV3 returns the old "v3" field's value of the Contact entity.
  3041. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3043. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  3044. if !m.op.Is(OpUpdateOne) {
  3045. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  3046. }
  3047. if m.id == nil || m.oldValue == nil {
  3048. return v, errors.New("OldV3 requires an ID field in the mutation")
  3049. }
  3050. oldValue, err := m.oldValue(ctx)
  3051. if err != nil {
  3052. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  3053. }
  3054. return oldValue.V3, nil
  3055. }
  3056. // ResetV3 resets all changes to the "v3" field.
  3057. func (m *ContactMutation) ResetV3() {
  3058. m.v3 = nil
  3059. }
  3060. // SetOrganizationID sets the "organization_id" field.
  3061. func (m *ContactMutation) SetOrganizationID(u uint64) {
  3062. m.organization_id = &u
  3063. m.addorganization_id = nil
  3064. }
  3065. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3066. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  3067. v := m.organization_id
  3068. if v == nil {
  3069. return
  3070. }
  3071. return *v, true
  3072. }
  3073. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  3074. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3076. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3077. if !m.op.Is(OpUpdateOne) {
  3078. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3079. }
  3080. if m.id == nil || m.oldValue == nil {
  3081. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3082. }
  3083. oldValue, err := m.oldValue(ctx)
  3084. if err != nil {
  3085. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3086. }
  3087. return oldValue.OrganizationID, nil
  3088. }
  3089. // AddOrganizationID adds u to the "organization_id" field.
  3090. func (m *ContactMutation) AddOrganizationID(u int64) {
  3091. if m.addorganization_id != nil {
  3092. *m.addorganization_id += u
  3093. } else {
  3094. m.addorganization_id = &u
  3095. }
  3096. }
  3097. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3098. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  3099. v := m.addorganization_id
  3100. if v == nil {
  3101. return
  3102. }
  3103. return *v, true
  3104. }
  3105. // ClearOrganizationID clears the value of the "organization_id" field.
  3106. func (m *ContactMutation) ClearOrganizationID() {
  3107. m.organization_id = nil
  3108. m.addorganization_id = nil
  3109. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  3110. }
  3111. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3112. func (m *ContactMutation) OrganizationIDCleared() bool {
  3113. _, ok := m.clearedFields[contact.FieldOrganizationID]
  3114. return ok
  3115. }
  3116. // ResetOrganizationID resets all changes to the "organization_id" field.
  3117. func (m *ContactMutation) ResetOrganizationID() {
  3118. m.organization_id = nil
  3119. m.addorganization_id = nil
  3120. delete(m.clearedFields, contact.FieldOrganizationID)
  3121. }
  3122. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  3123. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  3124. if m.contact_relationships == nil {
  3125. m.contact_relationships = make(map[uint64]struct{})
  3126. }
  3127. for i := range ids {
  3128. m.contact_relationships[ids[i]] = struct{}{}
  3129. }
  3130. }
  3131. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  3132. func (m *ContactMutation) ClearContactRelationships() {
  3133. m.clearedcontact_relationships = true
  3134. }
  3135. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  3136. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  3137. return m.clearedcontact_relationships
  3138. }
  3139. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  3140. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  3141. if m.removedcontact_relationships == nil {
  3142. m.removedcontact_relationships = make(map[uint64]struct{})
  3143. }
  3144. for i := range ids {
  3145. delete(m.contact_relationships, ids[i])
  3146. m.removedcontact_relationships[ids[i]] = struct{}{}
  3147. }
  3148. }
  3149. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  3150. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  3151. for id := range m.removedcontact_relationships {
  3152. ids = append(ids, id)
  3153. }
  3154. return
  3155. }
  3156. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  3157. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  3158. for id := range m.contact_relationships {
  3159. ids = append(ids, id)
  3160. }
  3161. return
  3162. }
  3163. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  3164. func (m *ContactMutation) ResetContactRelationships() {
  3165. m.contact_relationships = nil
  3166. m.clearedcontact_relationships = false
  3167. m.removedcontact_relationships = nil
  3168. }
  3169. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  3170. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  3171. if m.contact_messages == nil {
  3172. m.contact_messages = make(map[uint64]struct{})
  3173. }
  3174. for i := range ids {
  3175. m.contact_messages[ids[i]] = struct{}{}
  3176. }
  3177. }
  3178. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  3179. func (m *ContactMutation) ClearContactMessages() {
  3180. m.clearedcontact_messages = true
  3181. }
  3182. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  3183. func (m *ContactMutation) ContactMessagesCleared() bool {
  3184. return m.clearedcontact_messages
  3185. }
  3186. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  3187. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  3188. if m.removedcontact_messages == nil {
  3189. m.removedcontact_messages = make(map[uint64]struct{})
  3190. }
  3191. for i := range ids {
  3192. delete(m.contact_messages, ids[i])
  3193. m.removedcontact_messages[ids[i]] = struct{}{}
  3194. }
  3195. }
  3196. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  3197. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  3198. for id := range m.removedcontact_messages {
  3199. ids = append(ids, id)
  3200. }
  3201. return
  3202. }
  3203. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  3204. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  3205. for id := range m.contact_messages {
  3206. ids = append(ids, id)
  3207. }
  3208. return
  3209. }
  3210. // ResetContactMessages resets all changes to the "contact_messages" edge.
  3211. func (m *ContactMutation) ResetContactMessages() {
  3212. m.contact_messages = nil
  3213. m.clearedcontact_messages = false
  3214. m.removedcontact_messages = nil
  3215. }
  3216. // Where appends a list predicates to the ContactMutation builder.
  3217. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  3218. m.predicates = append(m.predicates, ps...)
  3219. }
  3220. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  3221. // users can use type-assertion to append predicates that do not depend on any generated package.
  3222. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  3223. p := make([]predicate.Contact, len(ps))
  3224. for i := range ps {
  3225. p[i] = ps[i]
  3226. }
  3227. m.Where(p...)
  3228. }
  3229. // Op returns the operation name.
  3230. func (m *ContactMutation) Op() Op {
  3231. return m.op
  3232. }
  3233. // SetOp allows setting the mutation operation.
  3234. func (m *ContactMutation) SetOp(op Op) {
  3235. m.op = op
  3236. }
  3237. // Type returns the node type of this mutation (Contact).
  3238. func (m *ContactMutation) Type() string {
  3239. return m.typ
  3240. }
  3241. // Fields returns all fields that were changed during this mutation. Note that in
  3242. // order to get all numeric fields that were incremented/decremented, call
  3243. // AddedFields().
  3244. func (m *ContactMutation) Fields() []string {
  3245. fields := make([]string, 0, 20)
  3246. if m.created_at != nil {
  3247. fields = append(fields, contact.FieldCreatedAt)
  3248. }
  3249. if m.updated_at != nil {
  3250. fields = append(fields, contact.FieldUpdatedAt)
  3251. }
  3252. if m.status != nil {
  3253. fields = append(fields, contact.FieldStatus)
  3254. }
  3255. if m.deleted_at != nil {
  3256. fields = append(fields, contact.FieldDeletedAt)
  3257. }
  3258. if m.wx_wxid != nil {
  3259. fields = append(fields, contact.FieldWxWxid)
  3260. }
  3261. if m._type != nil {
  3262. fields = append(fields, contact.FieldType)
  3263. }
  3264. if m.wxid != nil {
  3265. fields = append(fields, contact.FieldWxid)
  3266. }
  3267. if m.account != nil {
  3268. fields = append(fields, contact.FieldAccount)
  3269. }
  3270. if m.nickname != nil {
  3271. fields = append(fields, contact.FieldNickname)
  3272. }
  3273. if m.markname != nil {
  3274. fields = append(fields, contact.FieldMarkname)
  3275. }
  3276. if m.headimg != nil {
  3277. fields = append(fields, contact.FieldHeadimg)
  3278. }
  3279. if m.sex != nil {
  3280. fields = append(fields, contact.FieldSex)
  3281. }
  3282. if m.starrole != nil {
  3283. fields = append(fields, contact.FieldStarrole)
  3284. }
  3285. if m.dontseeit != nil {
  3286. fields = append(fields, contact.FieldDontseeit)
  3287. }
  3288. if m.dontseeme != nil {
  3289. fields = append(fields, contact.FieldDontseeme)
  3290. }
  3291. if m.lag != nil {
  3292. fields = append(fields, contact.FieldLag)
  3293. }
  3294. if m.gid != nil {
  3295. fields = append(fields, contact.FieldGid)
  3296. }
  3297. if m.gname != nil {
  3298. fields = append(fields, contact.FieldGname)
  3299. }
  3300. if m.v3 != nil {
  3301. fields = append(fields, contact.FieldV3)
  3302. }
  3303. if m.organization_id != nil {
  3304. fields = append(fields, contact.FieldOrganizationID)
  3305. }
  3306. return fields
  3307. }
  3308. // Field returns the value of a field with the given name. The second boolean
  3309. // return value indicates that this field was not set, or was not defined in the
  3310. // schema.
  3311. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  3312. switch name {
  3313. case contact.FieldCreatedAt:
  3314. return m.CreatedAt()
  3315. case contact.FieldUpdatedAt:
  3316. return m.UpdatedAt()
  3317. case contact.FieldStatus:
  3318. return m.Status()
  3319. case contact.FieldDeletedAt:
  3320. return m.DeletedAt()
  3321. case contact.FieldWxWxid:
  3322. return m.WxWxid()
  3323. case contact.FieldType:
  3324. return m.GetType()
  3325. case contact.FieldWxid:
  3326. return m.Wxid()
  3327. case contact.FieldAccount:
  3328. return m.Account()
  3329. case contact.FieldNickname:
  3330. return m.Nickname()
  3331. case contact.FieldMarkname:
  3332. return m.Markname()
  3333. case contact.FieldHeadimg:
  3334. return m.Headimg()
  3335. case contact.FieldSex:
  3336. return m.Sex()
  3337. case contact.FieldStarrole:
  3338. return m.Starrole()
  3339. case contact.FieldDontseeit:
  3340. return m.Dontseeit()
  3341. case contact.FieldDontseeme:
  3342. return m.Dontseeme()
  3343. case contact.FieldLag:
  3344. return m.Lag()
  3345. case contact.FieldGid:
  3346. return m.Gid()
  3347. case contact.FieldGname:
  3348. return m.Gname()
  3349. case contact.FieldV3:
  3350. return m.V3()
  3351. case contact.FieldOrganizationID:
  3352. return m.OrganizationID()
  3353. }
  3354. return nil, false
  3355. }
  3356. // OldField returns the old value of the field from the database. An error is
  3357. // returned if the mutation operation is not UpdateOne, or the query to the
  3358. // database failed.
  3359. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3360. switch name {
  3361. case contact.FieldCreatedAt:
  3362. return m.OldCreatedAt(ctx)
  3363. case contact.FieldUpdatedAt:
  3364. return m.OldUpdatedAt(ctx)
  3365. case contact.FieldStatus:
  3366. return m.OldStatus(ctx)
  3367. case contact.FieldDeletedAt:
  3368. return m.OldDeletedAt(ctx)
  3369. case contact.FieldWxWxid:
  3370. return m.OldWxWxid(ctx)
  3371. case contact.FieldType:
  3372. return m.OldType(ctx)
  3373. case contact.FieldWxid:
  3374. return m.OldWxid(ctx)
  3375. case contact.FieldAccount:
  3376. return m.OldAccount(ctx)
  3377. case contact.FieldNickname:
  3378. return m.OldNickname(ctx)
  3379. case contact.FieldMarkname:
  3380. return m.OldMarkname(ctx)
  3381. case contact.FieldHeadimg:
  3382. return m.OldHeadimg(ctx)
  3383. case contact.FieldSex:
  3384. return m.OldSex(ctx)
  3385. case contact.FieldStarrole:
  3386. return m.OldStarrole(ctx)
  3387. case contact.FieldDontseeit:
  3388. return m.OldDontseeit(ctx)
  3389. case contact.FieldDontseeme:
  3390. return m.OldDontseeme(ctx)
  3391. case contact.FieldLag:
  3392. return m.OldLag(ctx)
  3393. case contact.FieldGid:
  3394. return m.OldGid(ctx)
  3395. case contact.FieldGname:
  3396. return m.OldGname(ctx)
  3397. case contact.FieldV3:
  3398. return m.OldV3(ctx)
  3399. case contact.FieldOrganizationID:
  3400. return m.OldOrganizationID(ctx)
  3401. }
  3402. return nil, fmt.Errorf("unknown Contact field %s", name)
  3403. }
  3404. // SetField sets the value of a field with the given name. It returns an error if
  3405. // the field is not defined in the schema, or if the type mismatched the field
  3406. // type.
  3407. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  3408. switch name {
  3409. case contact.FieldCreatedAt:
  3410. v, ok := value.(time.Time)
  3411. if !ok {
  3412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3413. }
  3414. m.SetCreatedAt(v)
  3415. return nil
  3416. case contact.FieldUpdatedAt:
  3417. v, ok := value.(time.Time)
  3418. if !ok {
  3419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3420. }
  3421. m.SetUpdatedAt(v)
  3422. return nil
  3423. case contact.FieldStatus:
  3424. v, ok := value.(uint8)
  3425. if !ok {
  3426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3427. }
  3428. m.SetStatus(v)
  3429. return nil
  3430. case contact.FieldDeletedAt:
  3431. v, ok := value.(time.Time)
  3432. if !ok {
  3433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3434. }
  3435. m.SetDeletedAt(v)
  3436. return nil
  3437. case contact.FieldWxWxid:
  3438. v, ok := value.(string)
  3439. if !ok {
  3440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3441. }
  3442. m.SetWxWxid(v)
  3443. return nil
  3444. case contact.FieldType:
  3445. v, ok := value.(int)
  3446. if !ok {
  3447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3448. }
  3449. m.SetType(v)
  3450. return nil
  3451. case contact.FieldWxid:
  3452. v, ok := value.(string)
  3453. if !ok {
  3454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3455. }
  3456. m.SetWxid(v)
  3457. return nil
  3458. case contact.FieldAccount:
  3459. v, ok := value.(string)
  3460. if !ok {
  3461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3462. }
  3463. m.SetAccount(v)
  3464. return nil
  3465. case contact.FieldNickname:
  3466. v, ok := value.(string)
  3467. if !ok {
  3468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3469. }
  3470. m.SetNickname(v)
  3471. return nil
  3472. case contact.FieldMarkname:
  3473. v, ok := value.(string)
  3474. if !ok {
  3475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3476. }
  3477. m.SetMarkname(v)
  3478. return nil
  3479. case contact.FieldHeadimg:
  3480. v, ok := value.(string)
  3481. if !ok {
  3482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3483. }
  3484. m.SetHeadimg(v)
  3485. return nil
  3486. case contact.FieldSex:
  3487. v, ok := value.(int)
  3488. if !ok {
  3489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3490. }
  3491. m.SetSex(v)
  3492. return nil
  3493. case contact.FieldStarrole:
  3494. v, ok := value.(string)
  3495. if !ok {
  3496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3497. }
  3498. m.SetStarrole(v)
  3499. return nil
  3500. case contact.FieldDontseeit:
  3501. v, ok := value.(int)
  3502. if !ok {
  3503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3504. }
  3505. m.SetDontseeit(v)
  3506. return nil
  3507. case contact.FieldDontseeme:
  3508. v, ok := value.(int)
  3509. if !ok {
  3510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3511. }
  3512. m.SetDontseeme(v)
  3513. return nil
  3514. case contact.FieldLag:
  3515. v, ok := value.(string)
  3516. if !ok {
  3517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3518. }
  3519. m.SetLag(v)
  3520. return nil
  3521. case contact.FieldGid:
  3522. v, ok := value.(string)
  3523. if !ok {
  3524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3525. }
  3526. m.SetGid(v)
  3527. return nil
  3528. case contact.FieldGname:
  3529. v, ok := value.(string)
  3530. if !ok {
  3531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3532. }
  3533. m.SetGname(v)
  3534. return nil
  3535. case contact.FieldV3:
  3536. v, ok := value.(string)
  3537. if !ok {
  3538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3539. }
  3540. m.SetV3(v)
  3541. return nil
  3542. case contact.FieldOrganizationID:
  3543. v, ok := value.(uint64)
  3544. if !ok {
  3545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3546. }
  3547. m.SetOrganizationID(v)
  3548. return nil
  3549. }
  3550. return fmt.Errorf("unknown Contact field %s", name)
  3551. }
  3552. // AddedFields returns all numeric fields that were incremented/decremented during
  3553. // this mutation.
  3554. func (m *ContactMutation) AddedFields() []string {
  3555. var fields []string
  3556. if m.addstatus != nil {
  3557. fields = append(fields, contact.FieldStatus)
  3558. }
  3559. if m.add_type != nil {
  3560. fields = append(fields, contact.FieldType)
  3561. }
  3562. if m.addsex != nil {
  3563. fields = append(fields, contact.FieldSex)
  3564. }
  3565. if m.adddontseeit != nil {
  3566. fields = append(fields, contact.FieldDontseeit)
  3567. }
  3568. if m.adddontseeme != nil {
  3569. fields = append(fields, contact.FieldDontseeme)
  3570. }
  3571. if m.addorganization_id != nil {
  3572. fields = append(fields, contact.FieldOrganizationID)
  3573. }
  3574. return fields
  3575. }
  3576. // AddedField returns the numeric value that was incremented/decremented on a field
  3577. // with the given name. The second boolean return value indicates that this field
  3578. // was not set, or was not defined in the schema.
  3579. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  3580. switch name {
  3581. case contact.FieldStatus:
  3582. return m.AddedStatus()
  3583. case contact.FieldType:
  3584. return m.AddedType()
  3585. case contact.FieldSex:
  3586. return m.AddedSex()
  3587. case contact.FieldDontseeit:
  3588. return m.AddedDontseeit()
  3589. case contact.FieldDontseeme:
  3590. return m.AddedDontseeme()
  3591. case contact.FieldOrganizationID:
  3592. return m.AddedOrganizationID()
  3593. }
  3594. return nil, false
  3595. }
  3596. // AddField adds the value to the field with the given name. It returns an error if
  3597. // the field is not defined in the schema, or if the type mismatched the field
  3598. // type.
  3599. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  3600. switch name {
  3601. case contact.FieldStatus:
  3602. v, ok := value.(int8)
  3603. if !ok {
  3604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3605. }
  3606. m.AddStatus(v)
  3607. return nil
  3608. case contact.FieldType:
  3609. v, ok := value.(int)
  3610. if !ok {
  3611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3612. }
  3613. m.AddType(v)
  3614. return nil
  3615. case contact.FieldSex:
  3616. v, ok := value.(int)
  3617. if !ok {
  3618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3619. }
  3620. m.AddSex(v)
  3621. return nil
  3622. case contact.FieldDontseeit:
  3623. v, ok := value.(int)
  3624. if !ok {
  3625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3626. }
  3627. m.AddDontseeit(v)
  3628. return nil
  3629. case contact.FieldDontseeme:
  3630. v, ok := value.(int)
  3631. if !ok {
  3632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3633. }
  3634. m.AddDontseeme(v)
  3635. return nil
  3636. case contact.FieldOrganizationID:
  3637. v, ok := value.(int64)
  3638. if !ok {
  3639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3640. }
  3641. m.AddOrganizationID(v)
  3642. return nil
  3643. }
  3644. return fmt.Errorf("unknown Contact numeric field %s", name)
  3645. }
  3646. // ClearedFields returns all nullable fields that were cleared during this
  3647. // mutation.
  3648. func (m *ContactMutation) ClearedFields() []string {
  3649. var fields []string
  3650. if m.FieldCleared(contact.FieldStatus) {
  3651. fields = append(fields, contact.FieldStatus)
  3652. }
  3653. if m.FieldCleared(contact.FieldDeletedAt) {
  3654. fields = append(fields, contact.FieldDeletedAt)
  3655. }
  3656. if m.FieldCleared(contact.FieldWxWxid) {
  3657. fields = append(fields, contact.FieldWxWxid)
  3658. }
  3659. if m.FieldCleared(contact.FieldType) {
  3660. fields = append(fields, contact.FieldType)
  3661. }
  3662. if m.FieldCleared(contact.FieldOrganizationID) {
  3663. fields = append(fields, contact.FieldOrganizationID)
  3664. }
  3665. return fields
  3666. }
  3667. // FieldCleared returns a boolean indicating if a field with the given name was
  3668. // cleared in this mutation.
  3669. func (m *ContactMutation) FieldCleared(name string) bool {
  3670. _, ok := m.clearedFields[name]
  3671. return ok
  3672. }
  3673. // ClearField clears the value of the field with the given name. It returns an
  3674. // error if the field is not defined in the schema.
  3675. func (m *ContactMutation) ClearField(name string) error {
  3676. switch name {
  3677. case contact.FieldStatus:
  3678. m.ClearStatus()
  3679. return nil
  3680. case contact.FieldDeletedAt:
  3681. m.ClearDeletedAt()
  3682. return nil
  3683. case contact.FieldWxWxid:
  3684. m.ClearWxWxid()
  3685. return nil
  3686. case contact.FieldType:
  3687. m.ClearType()
  3688. return nil
  3689. case contact.FieldOrganizationID:
  3690. m.ClearOrganizationID()
  3691. return nil
  3692. }
  3693. return fmt.Errorf("unknown Contact nullable field %s", name)
  3694. }
  3695. // ResetField resets all changes in the mutation for the field with the given name.
  3696. // It returns an error if the field is not defined in the schema.
  3697. func (m *ContactMutation) ResetField(name string) error {
  3698. switch name {
  3699. case contact.FieldCreatedAt:
  3700. m.ResetCreatedAt()
  3701. return nil
  3702. case contact.FieldUpdatedAt:
  3703. m.ResetUpdatedAt()
  3704. return nil
  3705. case contact.FieldStatus:
  3706. m.ResetStatus()
  3707. return nil
  3708. case contact.FieldDeletedAt:
  3709. m.ResetDeletedAt()
  3710. return nil
  3711. case contact.FieldWxWxid:
  3712. m.ResetWxWxid()
  3713. return nil
  3714. case contact.FieldType:
  3715. m.ResetType()
  3716. return nil
  3717. case contact.FieldWxid:
  3718. m.ResetWxid()
  3719. return nil
  3720. case contact.FieldAccount:
  3721. m.ResetAccount()
  3722. return nil
  3723. case contact.FieldNickname:
  3724. m.ResetNickname()
  3725. return nil
  3726. case contact.FieldMarkname:
  3727. m.ResetMarkname()
  3728. return nil
  3729. case contact.FieldHeadimg:
  3730. m.ResetHeadimg()
  3731. return nil
  3732. case contact.FieldSex:
  3733. m.ResetSex()
  3734. return nil
  3735. case contact.FieldStarrole:
  3736. m.ResetStarrole()
  3737. return nil
  3738. case contact.FieldDontseeit:
  3739. m.ResetDontseeit()
  3740. return nil
  3741. case contact.FieldDontseeme:
  3742. m.ResetDontseeme()
  3743. return nil
  3744. case contact.FieldLag:
  3745. m.ResetLag()
  3746. return nil
  3747. case contact.FieldGid:
  3748. m.ResetGid()
  3749. return nil
  3750. case contact.FieldGname:
  3751. m.ResetGname()
  3752. return nil
  3753. case contact.FieldV3:
  3754. m.ResetV3()
  3755. return nil
  3756. case contact.FieldOrganizationID:
  3757. m.ResetOrganizationID()
  3758. return nil
  3759. }
  3760. return fmt.Errorf("unknown Contact field %s", name)
  3761. }
  3762. // AddedEdges returns all edge names that were set/added in this mutation.
  3763. func (m *ContactMutation) AddedEdges() []string {
  3764. edges := make([]string, 0, 2)
  3765. if m.contact_relationships != nil {
  3766. edges = append(edges, contact.EdgeContactRelationships)
  3767. }
  3768. if m.contact_messages != nil {
  3769. edges = append(edges, contact.EdgeContactMessages)
  3770. }
  3771. return edges
  3772. }
  3773. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3774. // name in this mutation.
  3775. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  3776. switch name {
  3777. case contact.EdgeContactRelationships:
  3778. ids := make([]ent.Value, 0, len(m.contact_relationships))
  3779. for id := range m.contact_relationships {
  3780. ids = append(ids, id)
  3781. }
  3782. return ids
  3783. case contact.EdgeContactMessages:
  3784. ids := make([]ent.Value, 0, len(m.contact_messages))
  3785. for id := range m.contact_messages {
  3786. ids = append(ids, id)
  3787. }
  3788. return ids
  3789. }
  3790. return nil
  3791. }
  3792. // RemovedEdges returns all edge names that were removed in this mutation.
  3793. func (m *ContactMutation) RemovedEdges() []string {
  3794. edges := make([]string, 0, 2)
  3795. if m.removedcontact_relationships != nil {
  3796. edges = append(edges, contact.EdgeContactRelationships)
  3797. }
  3798. if m.removedcontact_messages != nil {
  3799. edges = append(edges, contact.EdgeContactMessages)
  3800. }
  3801. return edges
  3802. }
  3803. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3804. // the given name in this mutation.
  3805. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  3806. switch name {
  3807. case contact.EdgeContactRelationships:
  3808. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  3809. for id := range m.removedcontact_relationships {
  3810. ids = append(ids, id)
  3811. }
  3812. return ids
  3813. case contact.EdgeContactMessages:
  3814. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  3815. for id := range m.removedcontact_messages {
  3816. ids = append(ids, id)
  3817. }
  3818. return ids
  3819. }
  3820. return nil
  3821. }
  3822. // ClearedEdges returns all edge names that were cleared in this mutation.
  3823. func (m *ContactMutation) ClearedEdges() []string {
  3824. edges := make([]string, 0, 2)
  3825. if m.clearedcontact_relationships {
  3826. edges = append(edges, contact.EdgeContactRelationships)
  3827. }
  3828. if m.clearedcontact_messages {
  3829. edges = append(edges, contact.EdgeContactMessages)
  3830. }
  3831. return edges
  3832. }
  3833. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3834. // was cleared in this mutation.
  3835. func (m *ContactMutation) EdgeCleared(name string) bool {
  3836. switch name {
  3837. case contact.EdgeContactRelationships:
  3838. return m.clearedcontact_relationships
  3839. case contact.EdgeContactMessages:
  3840. return m.clearedcontact_messages
  3841. }
  3842. return false
  3843. }
  3844. // ClearEdge clears the value of the edge with the given name. It returns an error
  3845. // if that edge is not defined in the schema.
  3846. func (m *ContactMutation) ClearEdge(name string) error {
  3847. switch name {
  3848. }
  3849. return fmt.Errorf("unknown Contact unique edge %s", name)
  3850. }
  3851. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3852. // It returns an error if the edge is not defined in the schema.
  3853. func (m *ContactMutation) ResetEdge(name string) error {
  3854. switch name {
  3855. case contact.EdgeContactRelationships:
  3856. m.ResetContactRelationships()
  3857. return nil
  3858. case contact.EdgeContactMessages:
  3859. m.ResetContactMessages()
  3860. return nil
  3861. }
  3862. return fmt.Errorf("unknown Contact edge %s", name)
  3863. }
  3864. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  3865. type LabelMutation struct {
  3866. config
  3867. op Op
  3868. typ string
  3869. id *uint64
  3870. created_at *time.Time
  3871. updated_at *time.Time
  3872. status *uint8
  3873. addstatus *int8
  3874. _type *int
  3875. add_type *int
  3876. name *string
  3877. from *int
  3878. addfrom *int
  3879. mode *int
  3880. addmode *int
  3881. conditions *string
  3882. organization_id *uint64
  3883. addorganization_id *int64
  3884. clearedFields map[string]struct{}
  3885. label_relationships map[uint64]struct{}
  3886. removedlabel_relationships map[uint64]struct{}
  3887. clearedlabel_relationships bool
  3888. done bool
  3889. oldValue func(context.Context) (*Label, error)
  3890. predicates []predicate.Label
  3891. }
  3892. var _ ent.Mutation = (*LabelMutation)(nil)
  3893. // labelOption allows management of the mutation configuration using functional options.
  3894. type labelOption func(*LabelMutation)
  3895. // newLabelMutation creates new mutation for the Label entity.
  3896. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  3897. m := &LabelMutation{
  3898. config: c,
  3899. op: op,
  3900. typ: TypeLabel,
  3901. clearedFields: make(map[string]struct{}),
  3902. }
  3903. for _, opt := range opts {
  3904. opt(m)
  3905. }
  3906. return m
  3907. }
  3908. // withLabelID sets the ID field of the mutation.
  3909. func withLabelID(id uint64) labelOption {
  3910. return func(m *LabelMutation) {
  3911. var (
  3912. err error
  3913. once sync.Once
  3914. value *Label
  3915. )
  3916. m.oldValue = func(ctx context.Context) (*Label, error) {
  3917. once.Do(func() {
  3918. if m.done {
  3919. err = errors.New("querying old values post mutation is not allowed")
  3920. } else {
  3921. value, err = m.Client().Label.Get(ctx, id)
  3922. }
  3923. })
  3924. return value, err
  3925. }
  3926. m.id = &id
  3927. }
  3928. }
  3929. // withLabel sets the old Label of the mutation.
  3930. func withLabel(node *Label) labelOption {
  3931. return func(m *LabelMutation) {
  3932. m.oldValue = func(context.Context) (*Label, error) {
  3933. return node, nil
  3934. }
  3935. m.id = &node.ID
  3936. }
  3937. }
  3938. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3939. // executed in a transaction (ent.Tx), a transactional client is returned.
  3940. func (m LabelMutation) Client() *Client {
  3941. client := &Client{config: m.config}
  3942. client.init()
  3943. return client
  3944. }
  3945. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3946. // it returns an error otherwise.
  3947. func (m LabelMutation) Tx() (*Tx, error) {
  3948. if _, ok := m.driver.(*txDriver); !ok {
  3949. return nil, errors.New("ent: mutation is not running in a transaction")
  3950. }
  3951. tx := &Tx{config: m.config}
  3952. tx.init()
  3953. return tx, nil
  3954. }
  3955. // SetID sets the value of the id field. Note that this
  3956. // operation is only accepted on creation of Label entities.
  3957. func (m *LabelMutation) SetID(id uint64) {
  3958. m.id = &id
  3959. }
  3960. // ID returns the ID value in the mutation. Note that the ID is only available
  3961. // if it was provided to the builder or after it was returned from the database.
  3962. func (m *LabelMutation) ID() (id uint64, exists bool) {
  3963. if m.id == nil {
  3964. return
  3965. }
  3966. return *m.id, true
  3967. }
  3968. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3969. // That means, if the mutation is applied within a transaction with an isolation level such
  3970. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3971. // or updated by the mutation.
  3972. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  3973. switch {
  3974. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3975. id, exists := m.ID()
  3976. if exists {
  3977. return []uint64{id}, nil
  3978. }
  3979. fallthrough
  3980. case m.op.Is(OpUpdate | OpDelete):
  3981. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  3982. default:
  3983. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3984. }
  3985. }
  3986. // SetCreatedAt sets the "created_at" field.
  3987. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  3988. m.created_at = &t
  3989. }
  3990. // CreatedAt returns the value of the "created_at" field in the mutation.
  3991. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  3992. v := m.created_at
  3993. if v == nil {
  3994. return
  3995. }
  3996. return *v, true
  3997. }
  3998. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  3999. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4001. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4002. if !m.op.Is(OpUpdateOne) {
  4003. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4004. }
  4005. if m.id == nil || m.oldValue == nil {
  4006. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4007. }
  4008. oldValue, err := m.oldValue(ctx)
  4009. if err != nil {
  4010. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4011. }
  4012. return oldValue.CreatedAt, nil
  4013. }
  4014. // ResetCreatedAt resets all changes to the "created_at" field.
  4015. func (m *LabelMutation) ResetCreatedAt() {
  4016. m.created_at = nil
  4017. }
  4018. // SetUpdatedAt sets the "updated_at" field.
  4019. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  4020. m.updated_at = &t
  4021. }
  4022. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4023. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  4024. v := m.updated_at
  4025. if v == nil {
  4026. return
  4027. }
  4028. return *v, true
  4029. }
  4030. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  4031. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4032. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4033. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4034. if !m.op.Is(OpUpdateOne) {
  4035. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4036. }
  4037. if m.id == nil || m.oldValue == nil {
  4038. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4039. }
  4040. oldValue, err := m.oldValue(ctx)
  4041. if err != nil {
  4042. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4043. }
  4044. return oldValue.UpdatedAt, nil
  4045. }
  4046. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4047. func (m *LabelMutation) ResetUpdatedAt() {
  4048. m.updated_at = nil
  4049. }
  4050. // SetStatus sets the "status" field.
  4051. func (m *LabelMutation) SetStatus(u uint8) {
  4052. m.status = &u
  4053. m.addstatus = nil
  4054. }
  4055. // Status returns the value of the "status" field in the mutation.
  4056. func (m *LabelMutation) Status() (r uint8, exists bool) {
  4057. v := m.status
  4058. if v == nil {
  4059. return
  4060. }
  4061. return *v, true
  4062. }
  4063. // OldStatus returns the old "status" field's value of the Label entity.
  4064. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4066. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4067. if !m.op.Is(OpUpdateOne) {
  4068. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4069. }
  4070. if m.id == nil || m.oldValue == nil {
  4071. return v, errors.New("OldStatus requires an ID field in the mutation")
  4072. }
  4073. oldValue, err := m.oldValue(ctx)
  4074. if err != nil {
  4075. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4076. }
  4077. return oldValue.Status, nil
  4078. }
  4079. // AddStatus adds u to the "status" field.
  4080. func (m *LabelMutation) AddStatus(u int8) {
  4081. if m.addstatus != nil {
  4082. *m.addstatus += u
  4083. } else {
  4084. m.addstatus = &u
  4085. }
  4086. }
  4087. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4088. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  4089. v := m.addstatus
  4090. if v == nil {
  4091. return
  4092. }
  4093. return *v, true
  4094. }
  4095. // ClearStatus clears the value of the "status" field.
  4096. func (m *LabelMutation) ClearStatus() {
  4097. m.status = nil
  4098. m.addstatus = nil
  4099. m.clearedFields[label.FieldStatus] = struct{}{}
  4100. }
  4101. // StatusCleared returns if the "status" field was cleared in this mutation.
  4102. func (m *LabelMutation) StatusCleared() bool {
  4103. _, ok := m.clearedFields[label.FieldStatus]
  4104. return ok
  4105. }
  4106. // ResetStatus resets all changes to the "status" field.
  4107. func (m *LabelMutation) ResetStatus() {
  4108. m.status = nil
  4109. m.addstatus = nil
  4110. delete(m.clearedFields, label.FieldStatus)
  4111. }
  4112. // SetType sets the "type" field.
  4113. func (m *LabelMutation) SetType(i int) {
  4114. m._type = &i
  4115. m.add_type = nil
  4116. }
  4117. // GetType returns the value of the "type" field in the mutation.
  4118. func (m *LabelMutation) GetType() (r int, exists bool) {
  4119. v := m._type
  4120. if v == nil {
  4121. return
  4122. }
  4123. return *v, true
  4124. }
  4125. // OldType returns the old "type" field's value of the Label entity.
  4126. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4128. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  4129. if !m.op.Is(OpUpdateOne) {
  4130. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4131. }
  4132. if m.id == nil || m.oldValue == nil {
  4133. return v, errors.New("OldType requires an ID field in the mutation")
  4134. }
  4135. oldValue, err := m.oldValue(ctx)
  4136. if err != nil {
  4137. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4138. }
  4139. return oldValue.Type, nil
  4140. }
  4141. // AddType adds i to the "type" field.
  4142. func (m *LabelMutation) AddType(i int) {
  4143. if m.add_type != nil {
  4144. *m.add_type += i
  4145. } else {
  4146. m.add_type = &i
  4147. }
  4148. }
  4149. // AddedType returns the value that was added to the "type" field in this mutation.
  4150. func (m *LabelMutation) AddedType() (r int, exists bool) {
  4151. v := m.add_type
  4152. if v == nil {
  4153. return
  4154. }
  4155. return *v, true
  4156. }
  4157. // ResetType resets all changes to the "type" field.
  4158. func (m *LabelMutation) ResetType() {
  4159. m._type = nil
  4160. m.add_type = nil
  4161. }
  4162. // SetName sets the "name" field.
  4163. func (m *LabelMutation) SetName(s string) {
  4164. m.name = &s
  4165. }
  4166. // Name returns the value of the "name" field in the mutation.
  4167. func (m *LabelMutation) Name() (r string, exists bool) {
  4168. v := m.name
  4169. if v == nil {
  4170. return
  4171. }
  4172. return *v, true
  4173. }
  4174. // OldName returns the old "name" field's value of the Label entity.
  4175. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4177. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  4178. if !m.op.Is(OpUpdateOne) {
  4179. return v, errors.New("OldName is only allowed on UpdateOne operations")
  4180. }
  4181. if m.id == nil || m.oldValue == nil {
  4182. return v, errors.New("OldName requires an ID field in the mutation")
  4183. }
  4184. oldValue, err := m.oldValue(ctx)
  4185. if err != nil {
  4186. return v, fmt.Errorf("querying old value for OldName: %w", err)
  4187. }
  4188. return oldValue.Name, nil
  4189. }
  4190. // ResetName resets all changes to the "name" field.
  4191. func (m *LabelMutation) ResetName() {
  4192. m.name = nil
  4193. }
  4194. // SetFrom sets the "from" field.
  4195. func (m *LabelMutation) SetFrom(i int) {
  4196. m.from = &i
  4197. m.addfrom = nil
  4198. }
  4199. // From returns the value of the "from" field in the mutation.
  4200. func (m *LabelMutation) From() (r int, exists bool) {
  4201. v := m.from
  4202. if v == nil {
  4203. return
  4204. }
  4205. return *v, true
  4206. }
  4207. // OldFrom returns the old "from" field's value of the Label entity.
  4208. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4210. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  4211. if !m.op.Is(OpUpdateOne) {
  4212. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  4213. }
  4214. if m.id == nil || m.oldValue == nil {
  4215. return v, errors.New("OldFrom requires an ID field in the mutation")
  4216. }
  4217. oldValue, err := m.oldValue(ctx)
  4218. if err != nil {
  4219. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  4220. }
  4221. return oldValue.From, nil
  4222. }
  4223. // AddFrom adds i to the "from" field.
  4224. func (m *LabelMutation) AddFrom(i int) {
  4225. if m.addfrom != nil {
  4226. *m.addfrom += i
  4227. } else {
  4228. m.addfrom = &i
  4229. }
  4230. }
  4231. // AddedFrom returns the value that was added to the "from" field in this mutation.
  4232. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  4233. v := m.addfrom
  4234. if v == nil {
  4235. return
  4236. }
  4237. return *v, true
  4238. }
  4239. // ResetFrom resets all changes to the "from" field.
  4240. func (m *LabelMutation) ResetFrom() {
  4241. m.from = nil
  4242. m.addfrom = nil
  4243. }
  4244. // SetMode sets the "mode" field.
  4245. func (m *LabelMutation) SetMode(i int) {
  4246. m.mode = &i
  4247. m.addmode = nil
  4248. }
  4249. // Mode returns the value of the "mode" field in the mutation.
  4250. func (m *LabelMutation) Mode() (r int, exists bool) {
  4251. v := m.mode
  4252. if v == nil {
  4253. return
  4254. }
  4255. return *v, true
  4256. }
  4257. // OldMode returns the old "mode" field's value of the Label entity.
  4258. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4260. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  4261. if !m.op.Is(OpUpdateOne) {
  4262. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  4263. }
  4264. if m.id == nil || m.oldValue == nil {
  4265. return v, errors.New("OldMode requires an ID field in the mutation")
  4266. }
  4267. oldValue, err := m.oldValue(ctx)
  4268. if err != nil {
  4269. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  4270. }
  4271. return oldValue.Mode, nil
  4272. }
  4273. // AddMode adds i to the "mode" field.
  4274. func (m *LabelMutation) AddMode(i int) {
  4275. if m.addmode != nil {
  4276. *m.addmode += i
  4277. } else {
  4278. m.addmode = &i
  4279. }
  4280. }
  4281. // AddedMode returns the value that was added to the "mode" field in this mutation.
  4282. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  4283. v := m.addmode
  4284. if v == nil {
  4285. return
  4286. }
  4287. return *v, true
  4288. }
  4289. // ResetMode resets all changes to the "mode" field.
  4290. func (m *LabelMutation) ResetMode() {
  4291. m.mode = nil
  4292. m.addmode = nil
  4293. }
  4294. // SetConditions sets the "conditions" field.
  4295. func (m *LabelMutation) SetConditions(s string) {
  4296. m.conditions = &s
  4297. }
  4298. // Conditions returns the value of the "conditions" field in the mutation.
  4299. func (m *LabelMutation) Conditions() (r string, exists bool) {
  4300. v := m.conditions
  4301. if v == nil {
  4302. return
  4303. }
  4304. return *v, true
  4305. }
  4306. // OldConditions returns the old "conditions" field's value of the Label entity.
  4307. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4309. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  4310. if !m.op.Is(OpUpdateOne) {
  4311. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  4312. }
  4313. if m.id == nil || m.oldValue == nil {
  4314. return v, errors.New("OldConditions requires an ID field in the mutation")
  4315. }
  4316. oldValue, err := m.oldValue(ctx)
  4317. if err != nil {
  4318. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  4319. }
  4320. return oldValue.Conditions, nil
  4321. }
  4322. // ClearConditions clears the value of the "conditions" field.
  4323. func (m *LabelMutation) ClearConditions() {
  4324. m.conditions = nil
  4325. m.clearedFields[label.FieldConditions] = struct{}{}
  4326. }
  4327. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  4328. func (m *LabelMutation) ConditionsCleared() bool {
  4329. _, ok := m.clearedFields[label.FieldConditions]
  4330. return ok
  4331. }
  4332. // ResetConditions resets all changes to the "conditions" field.
  4333. func (m *LabelMutation) ResetConditions() {
  4334. m.conditions = nil
  4335. delete(m.clearedFields, label.FieldConditions)
  4336. }
  4337. // SetOrganizationID sets the "organization_id" field.
  4338. func (m *LabelMutation) SetOrganizationID(u uint64) {
  4339. m.organization_id = &u
  4340. m.addorganization_id = nil
  4341. }
  4342. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4343. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  4344. v := m.organization_id
  4345. if v == nil {
  4346. return
  4347. }
  4348. return *v, true
  4349. }
  4350. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  4351. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4353. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4354. if !m.op.Is(OpUpdateOne) {
  4355. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4356. }
  4357. if m.id == nil || m.oldValue == nil {
  4358. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4359. }
  4360. oldValue, err := m.oldValue(ctx)
  4361. if err != nil {
  4362. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4363. }
  4364. return oldValue.OrganizationID, nil
  4365. }
  4366. // AddOrganizationID adds u to the "organization_id" field.
  4367. func (m *LabelMutation) AddOrganizationID(u int64) {
  4368. if m.addorganization_id != nil {
  4369. *m.addorganization_id += u
  4370. } else {
  4371. m.addorganization_id = &u
  4372. }
  4373. }
  4374. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4375. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  4376. v := m.addorganization_id
  4377. if v == nil {
  4378. return
  4379. }
  4380. return *v, true
  4381. }
  4382. // ClearOrganizationID clears the value of the "organization_id" field.
  4383. func (m *LabelMutation) ClearOrganizationID() {
  4384. m.organization_id = nil
  4385. m.addorganization_id = nil
  4386. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  4387. }
  4388. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  4389. func (m *LabelMutation) OrganizationIDCleared() bool {
  4390. _, ok := m.clearedFields[label.FieldOrganizationID]
  4391. return ok
  4392. }
  4393. // ResetOrganizationID resets all changes to the "organization_id" field.
  4394. func (m *LabelMutation) ResetOrganizationID() {
  4395. m.organization_id = nil
  4396. m.addorganization_id = nil
  4397. delete(m.clearedFields, label.FieldOrganizationID)
  4398. }
  4399. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  4400. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  4401. if m.label_relationships == nil {
  4402. m.label_relationships = make(map[uint64]struct{})
  4403. }
  4404. for i := range ids {
  4405. m.label_relationships[ids[i]] = struct{}{}
  4406. }
  4407. }
  4408. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  4409. func (m *LabelMutation) ClearLabelRelationships() {
  4410. m.clearedlabel_relationships = true
  4411. }
  4412. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  4413. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  4414. return m.clearedlabel_relationships
  4415. }
  4416. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  4417. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  4418. if m.removedlabel_relationships == nil {
  4419. m.removedlabel_relationships = make(map[uint64]struct{})
  4420. }
  4421. for i := range ids {
  4422. delete(m.label_relationships, ids[i])
  4423. m.removedlabel_relationships[ids[i]] = struct{}{}
  4424. }
  4425. }
  4426. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  4427. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  4428. for id := range m.removedlabel_relationships {
  4429. ids = append(ids, id)
  4430. }
  4431. return
  4432. }
  4433. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  4434. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  4435. for id := range m.label_relationships {
  4436. ids = append(ids, id)
  4437. }
  4438. return
  4439. }
  4440. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  4441. func (m *LabelMutation) ResetLabelRelationships() {
  4442. m.label_relationships = nil
  4443. m.clearedlabel_relationships = false
  4444. m.removedlabel_relationships = nil
  4445. }
  4446. // Where appends a list predicates to the LabelMutation builder.
  4447. func (m *LabelMutation) Where(ps ...predicate.Label) {
  4448. m.predicates = append(m.predicates, ps...)
  4449. }
  4450. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  4451. // users can use type-assertion to append predicates that do not depend on any generated package.
  4452. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  4453. p := make([]predicate.Label, len(ps))
  4454. for i := range ps {
  4455. p[i] = ps[i]
  4456. }
  4457. m.Where(p...)
  4458. }
  4459. // Op returns the operation name.
  4460. func (m *LabelMutation) Op() Op {
  4461. return m.op
  4462. }
  4463. // SetOp allows setting the mutation operation.
  4464. func (m *LabelMutation) SetOp(op Op) {
  4465. m.op = op
  4466. }
  4467. // Type returns the node type of this mutation (Label).
  4468. func (m *LabelMutation) Type() string {
  4469. return m.typ
  4470. }
  4471. // Fields returns all fields that were changed during this mutation. Note that in
  4472. // order to get all numeric fields that were incremented/decremented, call
  4473. // AddedFields().
  4474. func (m *LabelMutation) Fields() []string {
  4475. fields := make([]string, 0, 9)
  4476. if m.created_at != nil {
  4477. fields = append(fields, label.FieldCreatedAt)
  4478. }
  4479. if m.updated_at != nil {
  4480. fields = append(fields, label.FieldUpdatedAt)
  4481. }
  4482. if m.status != nil {
  4483. fields = append(fields, label.FieldStatus)
  4484. }
  4485. if m._type != nil {
  4486. fields = append(fields, label.FieldType)
  4487. }
  4488. if m.name != nil {
  4489. fields = append(fields, label.FieldName)
  4490. }
  4491. if m.from != nil {
  4492. fields = append(fields, label.FieldFrom)
  4493. }
  4494. if m.mode != nil {
  4495. fields = append(fields, label.FieldMode)
  4496. }
  4497. if m.conditions != nil {
  4498. fields = append(fields, label.FieldConditions)
  4499. }
  4500. if m.organization_id != nil {
  4501. fields = append(fields, label.FieldOrganizationID)
  4502. }
  4503. return fields
  4504. }
  4505. // Field returns the value of a field with the given name. The second boolean
  4506. // return value indicates that this field was not set, or was not defined in the
  4507. // schema.
  4508. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  4509. switch name {
  4510. case label.FieldCreatedAt:
  4511. return m.CreatedAt()
  4512. case label.FieldUpdatedAt:
  4513. return m.UpdatedAt()
  4514. case label.FieldStatus:
  4515. return m.Status()
  4516. case label.FieldType:
  4517. return m.GetType()
  4518. case label.FieldName:
  4519. return m.Name()
  4520. case label.FieldFrom:
  4521. return m.From()
  4522. case label.FieldMode:
  4523. return m.Mode()
  4524. case label.FieldConditions:
  4525. return m.Conditions()
  4526. case label.FieldOrganizationID:
  4527. return m.OrganizationID()
  4528. }
  4529. return nil, false
  4530. }
  4531. // OldField returns the old value of the field from the database. An error is
  4532. // returned if the mutation operation is not UpdateOne, or the query to the
  4533. // database failed.
  4534. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4535. switch name {
  4536. case label.FieldCreatedAt:
  4537. return m.OldCreatedAt(ctx)
  4538. case label.FieldUpdatedAt:
  4539. return m.OldUpdatedAt(ctx)
  4540. case label.FieldStatus:
  4541. return m.OldStatus(ctx)
  4542. case label.FieldType:
  4543. return m.OldType(ctx)
  4544. case label.FieldName:
  4545. return m.OldName(ctx)
  4546. case label.FieldFrom:
  4547. return m.OldFrom(ctx)
  4548. case label.FieldMode:
  4549. return m.OldMode(ctx)
  4550. case label.FieldConditions:
  4551. return m.OldConditions(ctx)
  4552. case label.FieldOrganizationID:
  4553. return m.OldOrganizationID(ctx)
  4554. }
  4555. return nil, fmt.Errorf("unknown Label field %s", name)
  4556. }
  4557. // SetField sets the value of a field with the given name. It returns an error if
  4558. // the field is not defined in the schema, or if the type mismatched the field
  4559. // type.
  4560. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  4561. switch name {
  4562. case label.FieldCreatedAt:
  4563. v, ok := value.(time.Time)
  4564. if !ok {
  4565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4566. }
  4567. m.SetCreatedAt(v)
  4568. return nil
  4569. case label.FieldUpdatedAt:
  4570. v, ok := value.(time.Time)
  4571. if !ok {
  4572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4573. }
  4574. m.SetUpdatedAt(v)
  4575. return nil
  4576. case label.FieldStatus:
  4577. v, ok := value.(uint8)
  4578. if !ok {
  4579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4580. }
  4581. m.SetStatus(v)
  4582. return nil
  4583. case label.FieldType:
  4584. v, ok := value.(int)
  4585. if !ok {
  4586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4587. }
  4588. m.SetType(v)
  4589. return nil
  4590. case label.FieldName:
  4591. v, ok := value.(string)
  4592. if !ok {
  4593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4594. }
  4595. m.SetName(v)
  4596. return nil
  4597. case label.FieldFrom:
  4598. v, ok := value.(int)
  4599. if !ok {
  4600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4601. }
  4602. m.SetFrom(v)
  4603. return nil
  4604. case label.FieldMode:
  4605. v, ok := value.(int)
  4606. if !ok {
  4607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4608. }
  4609. m.SetMode(v)
  4610. return nil
  4611. case label.FieldConditions:
  4612. v, ok := value.(string)
  4613. if !ok {
  4614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4615. }
  4616. m.SetConditions(v)
  4617. return nil
  4618. case label.FieldOrganizationID:
  4619. v, ok := value.(uint64)
  4620. if !ok {
  4621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4622. }
  4623. m.SetOrganizationID(v)
  4624. return nil
  4625. }
  4626. return fmt.Errorf("unknown Label field %s", name)
  4627. }
  4628. // AddedFields returns all numeric fields that were incremented/decremented during
  4629. // this mutation.
  4630. func (m *LabelMutation) AddedFields() []string {
  4631. var fields []string
  4632. if m.addstatus != nil {
  4633. fields = append(fields, label.FieldStatus)
  4634. }
  4635. if m.add_type != nil {
  4636. fields = append(fields, label.FieldType)
  4637. }
  4638. if m.addfrom != nil {
  4639. fields = append(fields, label.FieldFrom)
  4640. }
  4641. if m.addmode != nil {
  4642. fields = append(fields, label.FieldMode)
  4643. }
  4644. if m.addorganization_id != nil {
  4645. fields = append(fields, label.FieldOrganizationID)
  4646. }
  4647. return fields
  4648. }
  4649. // AddedField returns the numeric value that was incremented/decremented on a field
  4650. // with the given name. The second boolean return value indicates that this field
  4651. // was not set, or was not defined in the schema.
  4652. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  4653. switch name {
  4654. case label.FieldStatus:
  4655. return m.AddedStatus()
  4656. case label.FieldType:
  4657. return m.AddedType()
  4658. case label.FieldFrom:
  4659. return m.AddedFrom()
  4660. case label.FieldMode:
  4661. return m.AddedMode()
  4662. case label.FieldOrganizationID:
  4663. return m.AddedOrganizationID()
  4664. }
  4665. return nil, false
  4666. }
  4667. // AddField adds the value to the field with the given name. It returns an error if
  4668. // the field is not defined in the schema, or if the type mismatched the field
  4669. // type.
  4670. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  4671. switch name {
  4672. case label.FieldStatus:
  4673. v, ok := value.(int8)
  4674. if !ok {
  4675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4676. }
  4677. m.AddStatus(v)
  4678. return nil
  4679. case label.FieldType:
  4680. v, ok := value.(int)
  4681. if !ok {
  4682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4683. }
  4684. m.AddType(v)
  4685. return nil
  4686. case label.FieldFrom:
  4687. v, ok := value.(int)
  4688. if !ok {
  4689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4690. }
  4691. m.AddFrom(v)
  4692. return nil
  4693. case label.FieldMode:
  4694. v, ok := value.(int)
  4695. if !ok {
  4696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4697. }
  4698. m.AddMode(v)
  4699. return nil
  4700. case label.FieldOrganizationID:
  4701. v, ok := value.(int64)
  4702. if !ok {
  4703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4704. }
  4705. m.AddOrganizationID(v)
  4706. return nil
  4707. }
  4708. return fmt.Errorf("unknown Label numeric field %s", name)
  4709. }
  4710. // ClearedFields returns all nullable fields that were cleared during this
  4711. // mutation.
  4712. func (m *LabelMutation) ClearedFields() []string {
  4713. var fields []string
  4714. if m.FieldCleared(label.FieldStatus) {
  4715. fields = append(fields, label.FieldStatus)
  4716. }
  4717. if m.FieldCleared(label.FieldConditions) {
  4718. fields = append(fields, label.FieldConditions)
  4719. }
  4720. if m.FieldCleared(label.FieldOrganizationID) {
  4721. fields = append(fields, label.FieldOrganizationID)
  4722. }
  4723. return fields
  4724. }
  4725. // FieldCleared returns a boolean indicating if a field with the given name was
  4726. // cleared in this mutation.
  4727. func (m *LabelMutation) FieldCleared(name string) bool {
  4728. _, ok := m.clearedFields[name]
  4729. return ok
  4730. }
  4731. // ClearField clears the value of the field with the given name. It returns an
  4732. // error if the field is not defined in the schema.
  4733. func (m *LabelMutation) ClearField(name string) error {
  4734. switch name {
  4735. case label.FieldStatus:
  4736. m.ClearStatus()
  4737. return nil
  4738. case label.FieldConditions:
  4739. m.ClearConditions()
  4740. return nil
  4741. case label.FieldOrganizationID:
  4742. m.ClearOrganizationID()
  4743. return nil
  4744. }
  4745. return fmt.Errorf("unknown Label nullable field %s", name)
  4746. }
  4747. // ResetField resets all changes in the mutation for the field with the given name.
  4748. // It returns an error if the field is not defined in the schema.
  4749. func (m *LabelMutation) ResetField(name string) error {
  4750. switch name {
  4751. case label.FieldCreatedAt:
  4752. m.ResetCreatedAt()
  4753. return nil
  4754. case label.FieldUpdatedAt:
  4755. m.ResetUpdatedAt()
  4756. return nil
  4757. case label.FieldStatus:
  4758. m.ResetStatus()
  4759. return nil
  4760. case label.FieldType:
  4761. m.ResetType()
  4762. return nil
  4763. case label.FieldName:
  4764. m.ResetName()
  4765. return nil
  4766. case label.FieldFrom:
  4767. m.ResetFrom()
  4768. return nil
  4769. case label.FieldMode:
  4770. m.ResetMode()
  4771. return nil
  4772. case label.FieldConditions:
  4773. m.ResetConditions()
  4774. return nil
  4775. case label.FieldOrganizationID:
  4776. m.ResetOrganizationID()
  4777. return nil
  4778. }
  4779. return fmt.Errorf("unknown Label field %s", name)
  4780. }
  4781. // AddedEdges returns all edge names that were set/added in this mutation.
  4782. func (m *LabelMutation) AddedEdges() []string {
  4783. edges := make([]string, 0, 1)
  4784. if m.label_relationships != nil {
  4785. edges = append(edges, label.EdgeLabelRelationships)
  4786. }
  4787. return edges
  4788. }
  4789. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4790. // name in this mutation.
  4791. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  4792. switch name {
  4793. case label.EdgeLabelRelationships:
  4794. ids := make([]ent.Value, 0, len(m.label_relationships))
  4795. for id := range m.label_relationships {
  4796. ids = append(ids, id)
  4797. }
  4798. return ids
  4799. }
  4800. return nil
  4801. }
  4802. // RemovedEdges returns all edge names that were removed in this mutation.
  4803. func (m *LabelMutation) RemovedEdges() []string {
  4804. edges := make([]string, 0, 1)
  4805. if m.removedlabel_relationships != nil {
  4806. edges = append(edges, label.EdgeLabelRelationships)
  4807. }
  4808. return edges
  4809. }
  4810. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4811. // the given name in this mutation.
  4812. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  4813. switch name {
  4814. case label.EdgeLabelRelationships:
  4815. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  4816. for id := range m.removedlabel_relationships {
  4817. ids = append(ids, id)
  4818. }
  4819. return ids
  4820. }
  4821. return nil
  4822. }
  4823. // ClearedEdges returns all edge names that were cleared in this mutation.
  4824. func (m *LabelMutation) ClearedEdges() []string {
  4825. edges := make([]string, 0, 1)
  4826. if m.clearedlabel_relationships {
  4827. edges = append(edges, label.EdgeLabelRelationships)
  4828. }
  4829. return edges
  4830. }
  4831. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4832. // was cleared in this mutation.
  4833. func (m *LabelMutation) EdgeCleared(name string) bool {
  4834. switch name {
  4835. case label.EdgeLabelRelationships:
  4836. return m.clearedlabel_relationships
  4837. }
  4838. return false
  4839. }
  4840. // ClearEdge clears the value of the edge with the given name. It returns an error
  4841. // if that edge is not defined in the schema.
  4842. func (m *LabelMutation) ClearEdge(name string) error {
  4843. switch name {
  4844. }
  4845. return fmt.Errorf("unknown Label unique edge %s", name)
  4846. }
  4847. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4848. // It returns an error if the edge is not defined in the schema.
  4849. func (m *LabelMutation) ResetEdge(name string) error {
  4850. switch name {
  4851. case label.EdgeLabelRelationships:
  4852. m.ResetLabelRelationships()
  4853. return nil
  4854. }
  4855. return fmt.Errorf("unknown Label edge %s", name)
  4856. }
  4857. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  4858. type LabelRelationshipMutation struct {
  4859. config
  4860. op Op
  4861. typ string
  4862. id *uint64
  4863. created_at *time.Time
  4864. updated_at *time.Time
  4865. status *uint8
  4866. addstatus *int8
  4867. deleted_at *time.Time
  4868. organization_id *uint64
  4869. addorganization_id *int64
  4870. clearedFields map[string]struct{}
  4871. contacts *uint64
  4872. clearedcontacts bool
  4873. labels *uint64
  4874. clearedlabels bool
  4875. done bool
  4876. oldValue func(context.Context) (*LabelRelationship, error)
  4877. predicates []predicate.LabelRelationship
  4878. }
  4879. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  4880. // labelrelationshipOption allows management of the mutation configuration using functional options.
  4881. type labelrelationshipOption func(*LabelRelationshipMutation)
  4882. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  4883. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  4884. m := &LabelRelationshipMutation{
  4885. config: c,
  4886. op: op,
  4887. typ: TypeLabelRelationship,
  4888. clearedFields: make(map[string]struct{}),
  4889. }
  4890. for _, opt := range opts {
  4891. opt(m)
  4892. }
  4893. return m
  4894. }
  4895. // withLabelRelationshipID sets the ID field of the mutation.
  4896. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  4897. return func(m *LabelRelationshipMutation) {
  4898. var (
  4899. err error
  4900. once sync.Once
  4901. value *LabelRelationship
  4902. )
  4903. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  4904. once.Do(func() {
  4905. if m.done {
  4906. err = errors.New("querying old values post mutation is not allowed")
  4907. } else {
  4908. value, err = m.Client().LabelRelationship.Get(ctx, id)
  4909. }
  4910. })
  4911. return value, err
  4912. }
  4913. m.id = &id
  4914. }
  4915. }
  4916. // withLabelRelationship sets the old LabelRelationship of the mutation.
  4917. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  4918. return func(m *LabelRelationshipMutation) {
  4919. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  4920. return node, nil
  4921. }
  4922. m.id = &node.ID
  4923. }
  4924. }
  4925. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4926. // executed in a transaction (ent.Tx), a transactional client is returned.
  4927. func (m LabelRelationshipMutation) Client() *Client {
  4928. client := &Client{config: m.config}
  4929. client.init()
  4930. return client
  4931. }
  4932. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4933. // it returns an error otherwise.
  4934. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  4935. if _, ok := m.driver.(*txDriver); !ok {
  4936. return nil, errors.New("ent: mutation is not running in a transaction")
  4937. }
  4938. tx := &Tx{config: m.config}
  4939. tx.init()
  4940. return tx, nil
  4941. }
  4942. // SetID sets the value of the id field. Note that this
  4943. // operation is only accepted on creation of LabelRelationship entities.
  4944. func (m *LabelRelationshipMutation) SetID(id uint64) {
  4945. m.id = &id
  4946. }
  4947. // ID returns the ID value in the mutation. Note that the ID is only available
  4948. // if it was provided to the builder or after it was returned from the database.
  4949. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  4950. if m.id == nil {
  4951. return
  4952. }
  4953. return *m.id, true
  4954. }
  4955. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4956. // That means, if the mutation is applied within a transaction with an isolation level such
  4957. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4958. // or updated by the mutation.
  4959. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  4960. switch {
  4961. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4962. id, exists := m.ID()
  4963. if exists {
  4964. return []uint64{id}, nil
  4965. }
  4966. fallthrough
  4967. case m.op.Is(OpUpdate | OpDelete):
  4968. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  4969. default:
  4970. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4971. }
  4972. }
  4973. // SetCreatedAt sets the "created_at" field.
  4974. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  4975. m.created_at = &t
  4976. }
  4977. // CreatedAt returns the value of the "created_at" field in the mutation.
  4978. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  4979. v := m.created_at
  4980. if v == nil {
  4981. return
  4982. }
  4983. return *v, true
  4984. }
  4985. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  4986. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  4987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4988. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4989. if !m.op.Is(OpUpdateOne) {
  4990. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4991. }
  4992. if m.id == nil || m.oldValue == nil {
  4993. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4994. }
  4995. oldValue, err := m.oldValue(ctx)
  4996. if err != nil {
  4997. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4998. }
  4999. return oldValue.CreatedAt, nil
  5000. }
  5001. // ResetCreatedAt resets all changes to the "created_at" field.
  5002. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  5003. m.created_at = nil
  5004. }
  5005. // SetUpdatedAt sets the "updated_at" field.
  5006. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  5007. m.updated_at = &t
  5008. }
  5009. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5010. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  5011. v := m.updated_at
  5012. if v == nil {
  5013. return
  5014. }
  5015. return *v, true
  5016. }
  5017. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  5018. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5020. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5021. if !m.op.Is(OpUpdateOne) {
  5022. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5023. }
  5024. if m.id == nil || m.oldValue == nil {
  5025. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5026. }
  5027. oldValue, err := m.oldValue(ctx)
  5028. if err != nil {
  5029. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5030. }
  5031. return oldValue.UpdatedAt, nil
  5032. }
  5033. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5034. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  5035. m.updated_at = nil
  5036. }
  5037. // SetStatus sets the "status" field.
  5038. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  5039. m.status = &u
  5040. m.addstatus = nil
  5041. }
  5042. // Status returns the value of the "status" field in the mutation.
  5043. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  5044. v := m.status
  5045. if v == nil {
  5046. return
  5047. }
  5048. return *v, true
  5049. }
  5050. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  5051. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5053. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5054. if !m.op.Is(OpUpdateOne) {
  5055. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5056. }
  5057. if m.id == nil || m.oldValue == nil {
  5058. return v, errors.New("OldStatus requires an ID field in the mutation")
  5059. }
  5060. oldValue, err := m.oldValue(ctx)
  5061. if err != nil {
  5062. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5063. }
  5064. return oldValue.Status, nil
  5065. }
  5066. // AddStatus adds u to the "status" field.
  5067. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  5068. if m.addstatus != nil {
  5069. *m.addstatus += u
  5070. } else {
  5071. m.addstatus = &u
  5072. }
  5073. }
  5074. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5075. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  5076. v := m.addstatus
  5077. if v == nil {
  5078. return
  5079. }
  5080. return *v, true
  5081. }
  5082. // ClearStatus clears the value of the "status" field.
  5083. func (m *LabelRelationshipMutation) ClearStatus() {
  5084. m.status = nil
  5085. m.addstatus = nil
  5086. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  5087. }
  5088. // StatusCleared returns if the "status" field was cleared in this mutation.
  5089. func (m *LabelRelationshipMutation) StatusCleared() bool {
  5090. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  5091. return ok
  5092. }
  5093. // ResetStatus resets all changes to the "status" field.
  5094. func (m *LabelRelationshipMutation) ResetStatus() {
  5095. m.status = nil
  5096. m.addstatus = nil
  5097. delete(m.clearedFields, labelrelationship.FieldStatus)
  5098. }
  5099. // SetDeletedAt sets the "deleted_at" field.
  5100. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  5101. m.deleted_at = &t
  5102. }
  5103. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5104. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  5105. v := m.deleted_at
  5106. if v == nil {
  5107. return
  5108. }
  5109. return *v, true
  5110. }
  5111. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  5112. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5114. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5115. if !m.op.Is(OpUpdateOne) {
  5116. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5117. }
  5118. if m.id == nil || m.oldValue == nil {
  5119. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5120. }
  5121. oldValue, err := m.oldValue(ctx)
  5122. if err != nil {
  5123. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5124. }
  5125. return oldValue.DeletedAt, nil
  5126. }
  5127. // ClearDeletedAt clears the value of the "deleted_at" field.
  5128. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  5129. m.deleted_at = nil
  5130. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  5131. }
  5132. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5133. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  5134. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  5135. return ok
  5136. }
  5137. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5138. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  5139. m.deleted_at = nil
  5140. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  5141. }
  5142. // SetLabelID sets the "label_id" field.
  5143. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  5144. m.labels = &u
  5145. }
  5146. // LabelID returns the value of the "label_id" field in the mutation.
  5147. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  5148. v := m.labels
  5149. if v == nil {
  5150. return
  5151. }
  5152. return *v, true
  5153. }
  5154. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  5155. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5157. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  5158. if !m.op.Is(OpUpdateOne) {
  5159. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  5160. }
  5161. if m.id == nil || m.oldValue == nil {
  5162. return v, errors.New("OldLabelID requires an ID field in the mutation")
  5163. }
  5164. oldValue, err := m.oldValue(ctx)
  5165. if err != nil {
  5166. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  5167. }
  5168. return oldValue.LabelID, nil
  5169. }
  5170. // ResetLabelID resets all changes to the "label_id" field.
  5171. func (m *LabelRelationshipMutation) ResetLabelID() {
  5172. m.labels = nil
  5173. }
  5174. // SetContactID sets the "contact_id" field.
  5175. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  5176. m.contacts = &u
  5177. }
  5178. // ContactID returns the value of the "contact_id" field in the mutation.
  5179. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  5180. v := m.contacts
  5181. if v == nil {
  5182. return
  5183. }
  5184. return *v, true
  5185. }
  5186. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  5187. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5189. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  5190. if !m.op.Is(OpUpdateOne) {
  5191. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  5192. }
  5193. if m.id == nil || m.oldValue == nil {
  5194. return v, errors.New("OldContactID requires an ID field in the mutation")
  5195. }
  5196. oldValue, err := m.oldValue(ctx)
  5197. if err != nil {
  5198. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  5199. }
  5200. return oldValue.ContactID, nil
  5201. }
  5202. // ResetContactID resets all changes to the "contact_id" field.
  5203. func (m *LabelRelationshipMutation) ResetContactID() {
  5204. m.contacts = nil
  5205. }
  5206. // SetOrganizationID sets the "organization_id" field.
  5207. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  5208. m.organization_id = &u
  5209. m.addorganization_id = nil
  5210. }
  5211. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5212. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  5213. v := m.organization_id
  5214. if v == nil {
  5215. return
  5216. }
  5217. return *v, true
  5218. }
  5219. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  5220. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5222. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5223. if !m.op.Is(OpUpdateOne) {
  5224. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5225. }
  5226. if m.id == nil || m.oldValue == nil {
  5227. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5228. }
  5229. oldValue, err := m.oldValue(ctx)
  5230. if err != nil {
  5231. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5232. }
  5233. return oldValue.OrganizationID, nil
  5234. }
  5235. // AddOrganizationID adds u to the "organization_id" field.
  5236. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  5237. if m.addorganization_id != nil {
  5238. *m.addorganization_id += u
  5239. } else {
  5240. m.addorganization_id = &u
  5241. }
  5242. }
  5243. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5244. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  5245. v := m.addorganization_id
  5246. if v == nil {
  5247. return
  5248. }
  5249. return *v, true
  5250. }
  5251. // ClearOrganizationID clears the value of the "organization_id" field.
  5252. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  5253. m.organization_id = nil
  5254. m.addorganization_id = nil
  5255. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  5256. }
  5257. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  5258. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  5259. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  5260. return ok
  5261. }
  5262. // ResetOrganizationID resets all changes to the "organization_id" field.
  5263. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  5264. m.organization_id = nil
  5265. m.addorganization_id = nil
  5266. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  5267. }
  5268. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  5269. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  5270. m.contacts = &id
  5271. }
  5272. // ClearContacts clears the "contacts" edge to the Contact entity.
  5273. func (m *LabelRelationshipMutation) ClearContacts() {
  5274. m.clearedcontacts = true
  5275. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  5276. }
  5277. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  5278. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  5279. return m.clearedcontacts
  5280. }
  5281. // ContactsID returns the "contacts" edge ID in the mutation.
  5282. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  5283. if m.contacts != nil {
  5284. return *m.contacts, true
  5285. }
  5286. return
  5287. }
  5288. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  5289. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  5290. // ContactsID instead. It exists only for internal usage by the builders.
  5291. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  5292. if id := m.contacts; id != nil {
  5293. ids = append(ids, *id)
  5294. }
  5295. return
  5296. }
  5297. // ResetContacts resets all changes to the "contacts" edge.
  5298. func (m *LabelRelationshipMutation) ResetContacts() {
  5299. m.contacts = nil
  5300. m.clearedcontacts = false
  5301. }
  5302. // SetLabelsID sets the "labels" edge to the Label entity by id.
  5303. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  5304. m.labels = &id
  5305. }
  5306. // ClearLabels clears the "labels" edge to the Label entity.
  5307. func (m *LabelRelationshipMutation) ClearLabels() {
  5308. m.clearedlabels = true
  5309. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  5310. }
  5311. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  5312. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  5313. return m.clearedlabels
  5314. }
  5315. // LabelsID returns the "labels" edge ID in the mutation.
  5316. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  5317. if m.labels != nil {
  5318. return *m.labels, true
  5319. }
  5320. return
  5321. }
  5322. // LabelsIDs returns the "labels" edge IDs in the mutation.
  5323. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  5324. // LabelsID instead. It exists only for internal usage by the builders.
  5325. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  5326. if id := m.labels; id != nil {
  5327. ids = append(ids, *id)
  5328. }
  5329. return
  5330. }
  5331. // ResetLabels resets all changes to the "labels" edge.
  5332. func (m *LabelRelationshipMutation) ResetLabels() {
  5333. m.labels = nil
  5334. m.clearedlabels = false
  5335. }
  5336. // Where appends a list predicates to the LabelRelationshipMutation builder.
  5337. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  5338. m.predicates = append(m.predicates, ps...)
  5339. }
  5340. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  5341. // users can use type-assertion to append predicates that do not depend on any generated package.
  5342. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  5343. p := make([]predicate.LabelRelationship, len(ps))
  5344. for i := range ps {
  5345. p[i] = ps[i]
  5346. }
  5347. m.Where(p...)
  5348. }
  5349. // Op returns the operation name.
  5350. func (m *LabelRelationshipMutation) Op() Op {
  5351. return m.op
  5352. }
  5353. // SetOp allows setting the mutation operation.
  5354. func (m *LabelRelationshipMutation) SetOp(op Op) {
  5355. m.op = op
  5356. }
  5357. // Type returns the node type of this mutation (LabelRelationship).
  5358. func (m *LabelRelationshipMutation) Type() string {
  5359. return m.typ
  5360. }
  5361. // Fields returns all fields that were changed during this mutation. Note that in
  5362. // order to get all numeric fields that were incremented/decremented, call
  5363. // AddedFields().
  5364. func (m *LabelRelationshipMutation) Fields() []string {
  5365. fields := make([]string, 0, 7)
  5366. if m.created_at != nil {
  5367. fields = append(fields, labelrelationship.FieldCreatedAt)
  5368. }
  5369. if m.updated_at != nil {
  5370. fields = append(fields, labelrelationship.FieldUpdatedAt)
  5371. }
  5372. if m.status != nil {
  5373. fields = append(fields, labelrelationship.FieldStatus)
  5374. }
  5375. if m.deleted_at != nil {
  5376. fields = append(fields, labelrelationship.FieldDeletedAt)
  5377. }
  5378. if m.labels != nil {
  5379. fields = append(fields, labelrelationship.FieldLabelID)
  5380. }
  5381. if m.contacts != nil {
  5382. fields = append(fields, labelrelationship.FieldContactID)
  5383. }
  5384. if m.organization_id != nil {
  5385. fields = append(fields, labelrelationship.FieldOrganizationID)
  5386. }
  5387. return fields
  5388. }
  5389. // Field returns the value of a field with the given name. The second boolean
  5390. // return value indicates that this field was not set, or was not defined in the
  5391. // schema.
  5392. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  5393. switch name {
  5394. case labelrelationship.FieldCreatedAt:
  5395. return m.CreatedAt()
  5396. case labelrelationship.FieldUpdatedAt:
  5397. return m.UpdatedAt()
  5398. case labelrelationship.FieldStatus:
  5399. return m.Status()
  5400. case labelrelationship.FieldDeletedAt:
  5401. return m.DeletedAt()
  5402. case labelrelationship.FieldLabelID:
  5403. return m.LabelID()
  5404. case labelrelationship.FieldContactID:
  5405. return m.ContactID()
  5406. case labelrelationship.FieldOrganizationID:
  5407. return m.OrganizationID()
  5408. }
  5409. return nil, false
  5410. }
  5411. // OldField returns the old value of the field from the database. An error is
  5412. // returned if the mutation operation is not UpdateOne, or the query to the
  5413. // database failed.
  5414. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5415. switch name {
  5416. case labelrelationship.FieldCreatedAt:
  5417. return m.OldCreatedAt(ctx)
  5418. case labelrelationship.FieldUpdatedAt:
  5419. return m.OldUpdatedAt(ctx)
  5420. case labelrelationship.FieldStatus:
  5421. return m.OldStatus(ctx)
  5422. case labelrelationship.FieldDeletedAt:
  5423. return m.OldDeletedAt(ctx)
  5424. case labelrelationship.FieldLabelID:
  5425. return m.OldLabelID(ctx)
  5426. case labelrelationship.FieldContactID:
  5427. return m.OldContactID(ctx)
  5428. case labelrelationship.FieldOrganizationID:
  5429. return m.OldOrganizationID(ctx)
  5430. }
  5431. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  5432. }
  5433. // SetField sets the value of a field with the given name. It returns an error if
  5434. // the field is not defined in the schema, or if the type mismatched the field
  5435. // type.
  5436. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  5437. switch name {
  5438. case labelrelationship.FieldCreatedAt:
  5439. v, ok := value.(time.Time)
  5440. if !ok {
  5441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5442. }
  5443. m.SetCreatedAt(v)
  5444. return nil
  5445. case labelrelationship.FieldUpdatedAt:
  5446. v, ok := value.(time.Time)
  5447. if !ok {
  5448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5449. }
  5450. m.SetUpdatedAt(v)
  5451. return nil
  5452. case labelrelationship.FieldStatus:
  5453. v, ok := value.(uint8)
  5454. if !ok {
  5455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5456. }
  5457. m.SetStatus(v)
  5458. return nil
  5459. case labelrelationship.FieldDeletedAt:
  5460. v, ok := value.(time.Time)
  5461. if !ok {
  5462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5463. }
  5464. m.SetDeletedAt(v)
  5465. return nil
  5466. case labelrelationship.FieldLabelID:
  5467. v, ok := value.(uint64)
  5468. if !ok {
  5469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5470. }
  5471. m.SetLabelID(v)
  5472. return nil
  5473. case labelrelationship.FieldContactID:
  5474. v, ok := value.(uint64)
  5475. if !ok {
  5476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5477. }
  5478. m.SetContactID(v)
  5479. return nil
  5480. case labelrelationship.FieldOrganizationID:
  5481. v, ok := value.(uint64)
  5482. if !ok {
  5483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5484. }
  5485. m.SetOrganizationID(v)
  5486. return nil
  5487. }
  5488. return fmt.Errorf("unknown LabelRelationship field %s", name)
  5489. }
  5490. // AddedFields returns all numeric fields that were incremented/decremented during
  5491. // this mutation.
  5492. func (m *LabelRelationshipMutation) AddedFields() []string {
  5493. var fields []string
  5494. if m.addstatus != nil {
  5495. fields = append(fields, labelrelationship.FieldStatus)
  5496. }
  5497. if m.addorganization_id != nil {
  5498. fields = append(fields, labelrelationship.FieldOrganizationID)
  5499. }
  5500. return fields
  5501. }
  5502. // AddedField returns the numeric value that was incremented/decremented on a field
  5503. // with the given name. The second boolean return value indicates that this field
  5504. // was not set, or was not defined in the schema.
  5505. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  5506. switch name {
  5507. case labelrelationship.FieldStatus:
  5508. return m.AddedStatus()
  5509. case labelrelationship.FieldOrganizationID:
  5510. return m.AddedOrganizationID()
  5511. }
  5512. return nil, false
  5513. }
  5514. // AddField adds the value to the field with the given name. It returns an error if
  5515. // the field is not defined in the schema, or if the type mismatched the field
  5516. // type.
  5517. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  5518. switch name {
  5519. case labelrelationship.FieldStatus:
  5520. v, ok := value.(int8)
  5521. if !ok {
  5522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5523. }
  5524. m.AddStatus(v)
  5525. return nil
  5526. case labelrelationship.FieldOrganizationID:
  5527. v, ok := value.(int64)
  5528. if !ok {
  5529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5530. }
  5531. m.AddOrganizationID(v)
  5532. return nil
  5533. }
  5534. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  5535. }
  5536. // ClearedFields returns all nullable fields that were cleared during this
  5537. // mutation.
  5538. func (m *LabelRelationshipMutation) ClearedFields() []string {
  5539. var fields []string
  5540. if m.FieldCleared(labelrelationship.FieldStatus) {
  5541. fields = append(fields, labelrelationship.FieldStatus)
  5542. }
  5543. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  5544. fields = append(fields, labelrelationship.FieldDeletedAt)
  5545. }
  5546. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  5547. fields = append(fields, labelrelationship.FieldOrganizationID)
  5548. }
  5549. return fields
  5550. }
  5551. // FieldCleared returns a boolean indicating if a field with the given name was
  5552. // cleared in this mutation.
  5553. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  5554. _, ok := m.clearedFields[name]
  5555. return ok
  5556. }
  5557. // ClearField clears the value of the field with the given name. It returns an
  5558. // error if the field is not defined in the schema.
  5559. func (m *LabelRelationshipMutation) ClearField(name string) error {
  5560. switch name {
  5561. case labelrelationship.FieldStatus:
  5562. m.ClearStatus()
  5563. return nil
  5564. case labelrelationship.FieldDeletedAt:
  5565. m.ClearDeletedAt()
  5566. return nil
  5567. case labelrelationship.FieldOrganizationID:
  5568. m.ClearOrganizationID()
  5569. return nil
  5570. }
  5571. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  5572. }
  5573. // ResetField resets all changes in the mutation for the field with the given name.
  5574. // It returns an error if the field is not defined in the schema.
  5575. func (m *LabelRelationshipMutation) ResetField(name string) error {
  5576. switch name {
  5577. case labelrelationship.FieldCreatedAt:
  5578. m.ResetCreatedAt()
  5579. return nil
  5580. case labelrelationship.FieldUpdatedAt:
  5581. m.ResetUpdatedAt()
  5582. return nil
  5583. case labelrelationship.FieldStatus:
  5584. m.ResetStatus()
  5585. return nil
  5586. case labelrelationship.FieldDeletedAt:
  5587. m.ResetDeletedAt()
  5588. return nil
  5589. case labelrelationship.FieldLabelID:
  5590. m.ResetLabelID()
  5591. return nil
  5592. case labelrelationship.FieldContactID:
  5593. m.ResetContactID()
  5594. return nil
  5595. case labelrelationship.FieldOrganizationID:
  5596. m.ResetOrganizationID()
  5597. return nil
  5598. }
  5599. return fmt.Errorf("unknown LabelRelationship field %s", name)
  5600. }
  5601. // AddedEdges returns all edge names that were set/added in this mutation.
  5602. func (m *LabelRelationshipMutation) AddedEdges() []string {
  5603. edges := make([]string, 0, 2)
  5604. if m.contacts != nil {
  5605. edges = append(edges, labelrelationship.EdgeContacts)
  5606. }
  5607. if m.labels != nil {
  5608. edges = append(edges, labelrelationship.EdgeLabels)
  5609. }
  5610. return edges
  5611. }
  5612. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5613. // name in this mutation.
  5614. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  5615. switch name {
  5616. case labelrelationship.EdgeContacts:
  5617. if id := m.contacts; id != nil {
  5618. return []ent.Value{*id}
  5619. }
  5620. case labelrelationship.EdgeLabels:
  5621. if id := m.labels; id != nil {
  5622. return []ent.Value{*id}
  5623. }
  5624. }
  5625. return nil
  5626. }
  5627. // RemovedEdges returns all edge names that were removed in this mutation.
  5628. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  5629. edges := make([]string, 0, 2)
  5630. return edges
  5631. }
  5632. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5633. // the given name in this mutation.
  5634. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  5635. return nil
  5636. }
  5637. // ClearedEdges returns all edge names that were cleared in this mutation.
  5638. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  5639. edges := make([]string, 0, 2)
  5640. if m.clearedcontacts {
  5641. edges = append(edges, labelrelationship.EdgeContacts)
  5642. }
  5643. if m.clearedlabels {
  5644. edges = append(edges, labelrelationship.EdgeLabels)
  5645. }
  5646. return edges
  5647. }
  5648. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5649. // was cleared in this mutation.
  5650. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  5651. switch name {
  5652. case labelrelationship.EdgeContacts:
  5653. return m.clearedcontacts
  5654. case labelrelationship.EdgeLabels:
  5655. return m.clearedlabels
  5656. }
  5657. return false
  5658. }
  5659. // ClearEdge clears the value of the edge with the given name. It returns an error
  5660. // if that edge is not defined in the schema.
  5661. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  5662. switch name {
  5663. case labelrelationship.EdgeContacts:
  5664. m.ClearContacts()
  5665. return nil
  5666. case labelrelationship.EdgeLabels:
  5667. m.ClearLabels()
  5668. return nil
  5669. }
  5670. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  5671. }
  5672. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5673. // It returns an error if the edge is not defined in the schema.
  5674. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  5675. switch name {
  5676. case labelrelationship.EdgeContacts:
  5677. m.ResetContacts()
  5678. return nil
  5679. case labelrelationship.EdgeLabels:
  5680. m.ResetLabels()
  5681. return nil
  5682. }
  5683. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  5684. }
  5685. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  5686. type MessageMutation struct {
  5687. config
  5688. op Op
  5689. typ string
  5690. id *int
  5691. wx_wxid *string
  5692. wxid *string
  5693. content *string
  5694. clearedFields map[string]struct{}
  5695. done bool
  5696. oldValue func(context.Context) (*Message, error)
  5697. predicates []predicate.Message
  5698. }
  5699. var _ ent.Mutation = (*MessageMutation)(nil)
  5700. // messageOption allows management of the mutation configuration using functional options.
  5701. type messageOption func(*MessageMutation)
  5702. // newMessageMutation creates new mutation for the Message entity.
  5703. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  5704. m := &MessageMutation{
  5705. config: c,
  5706. op: op,
  5707. typ: TypeMessage,
  5708. clearedFields: make(map[string]struct{}),
  5709. }
  5710. for _, opt := range opts {
  5711. opt(m)
  5712. }
  5713. return m
  5714. }
  5715. // withMessageID sets the ID field of the mutation.
  5716. func withMessageID(id int) messageOption {
  5717. return func(m *MessageMutation) {
  5718. var (
  5719. err error
  5720. once sync.Once
  5721. value *Message
  5722. )
  5723. m.oldValue = func(ctx context.Context) (*Message, error) {
  5724. once.Do(func() {
  5725. if m.done {
  5726. err = errors.New("querying old values post mutation is not allowed")
  5727. } else {
  5728. value, err = m.Client().Message.Get(ctx, id)
  5729. }
  5730. })
  5731. return value, err
  5732. }
  5733. m.id = &id
  5734. }
  5735. }
  5736. // withMessage sets the old Message of the mutation.
  5737. func withMessage(node *Message) messageOption {
  5738. return func(m *MessageMutation) {
  5739. m.oldValue = func(context.Context) (*Message, error) {
  5740. return node, nil
  5741. }
  5742. m.id = &node.ID
  5743. }
  5744. }
  5745. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5746. // executed in a transaction (ent.Tx), a transactional client is returned.
  5747. func (m MessageMutation) Client() *Client {
  5748. client := &Client{config: m.config}
  5749. client.init()
  5750. return client
  5751. }
  5752. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5753. // it returns an error otherwise.
  5754. func (m MessageMutation) Tx() (*Tx, error) {
  5755. if _, ok := m.driver.(*txDriver); !ok {
  5756. return nil, errors.New("ent: mutation is not running in a transaction")
  5757. }
  5758. tx := &Tx{config: m.config}
  5759. tx.init()
  5760. return tx, nil
  5761. }
  5762. // ID returns the ID value in the mutation. Note that the ID is only available
  5763. // if it was provided to the builder or after it was returned from the database.
  5764. func (m *MessageMutation) ID() (id int, exists bool) {
  5765. if m.id == nil {
  5766. return
  5767. }
  5768. return *m.id, true
  5769. }
  5770. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5771. // That means, if the mutation is applied within a transaction with an isolation level such
  5772. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5773. // or updated by the mutation.
  5774. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  5775. switch {
  5776. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5777. id, exists := m.ID()
  5778. if exists {
  5779. return []int{id}, nil
  5780. }
  5781. fallthrough
  5782. case m.op.Is(OpUpdate | OpDelete):
  5783. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  5784. default:
  5785. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5786. }
  5787. }
  5788. // SetWxWxid sets the "wx_wxid" field.
  5789. func (m *MessageMutation) SetWxWxid(s string) {
  5790. m.wx_wxid = &s
  5791. }
  5792. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  5793. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  5794. v := m.wx_wxid
  5795. if v == nil {
  5796. return
  5797. }
  5798. return *v, true
  5799. }
  5800. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  5801. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  5802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5803. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  5804. if !m.op.Is(OpUpdateOne) {
  5805. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  5806. }
  5807. if m.id == nil || m.oldValue == nil {
  5808. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  5809. }
  5810. oldValue, err := m.oldValue(ctx)
  5811. if err != nil {
  5812. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  5813. }
  5814. return oldValue.WxWxid, nil
  5815. }
  5816. // ClearWxWxid clears the value of the "wx_wxid" field.
  5817. func (m *MessageMutation) ClearWxWxid() {
  5818. m.wx_wxid = nil
  5819. m.clearedFields[message.FieldWxWxid] = struct{}{}
  5820. }
  5821. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  5822. func (m *MessageMutation) WxWxidCleared() bool {
  5823. _, ok := m.clearedFields[message.FieldWxWxid]
  5824. return ok
  5825. }
  5826. // ResetWxWxid resets all changes to the "wx_wxid" field.
  5827. func (m *MessageMutation) ResetWxWxid() {
  5828. m.wx_wxid = nil
  5829. delete(m.clearedFields, message.FieldWxWxid)
  5830. }
  5831. // SetWxid sets the "wxid" field.
  5832. func (m *MessageMutation) SetWxid(s string) {
  5833. m.wxid = &s
  5834. }
  5835. // Wxid returns the value of the "wxid" field in the mutation.
  5836. func (m *MessageMutation) Wxid() (r string, exists bool) {
  5837. v := m.wxid
  5838. if v == nil {
  5839. return
  5840. }
  5841. return *v, true
  5842. }
  5843. // OldWxid returns the old "wxid" field's value of the Message entity.
  5844. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  5845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5846. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  5847. if !m.op.Is(OpUpdateOne) {
  5848. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  5849. }
  5850. if m.id == nil || m.oldValue == nil {
  5851. return v, errors.New("OldWxid requires an ID field in the mutation")
  5852. }
  5853. oldValue, err := m.oldValue(ctx)
  5854. if err != nil {
  5855. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  5856. }
  5857. return oldValue.Wxid, nil
  5858. }
  5859. // ResetWxid resets all changes to the "wxid" field.
  5860. func (m *MessageMutation) ResetWxid() {
  5861. m.wxid = nil
  5862. }
  5863. // SetContent sets the "content" field.
  5864. func (m *MessageMutation) SetContent(s string) {
  5865. m.content = &s
  5866. }
  5867. // Content returns the value of the "content" field in the mutation.
  5868. func (m *MessageMutation) Content() (r string, exists bool) {
  5869. v := m.content
  5870. if v == nil {
  5871. return
  5872. }
  5873. return *v, true
  5874. }
  5875. // OldContent returns the old "content" field's value of the Message entity.
  5876. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  5877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5878. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  5879. if !m.op.Is(OpUpdateOne) {
  5880. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  5881. }
  5882. if m.id == nil || m.oldValue == nil {
  5883. return v, errors.New("OldContent requires an ID field in the mutation")
  5884. }
  5885. oldValue, err := m.oldValue(ctx)
  5886. if err != nil {
  5887. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  5888. }
  5889. return oldValue.Content, nil
  5890. }
  5891. // ResetContent resets all changes to the "content" field.
  5892. func (m *MessageMutation) ResetContent() {
  5893. m.content = nil
  5894. }
  5895. // Where appends a list predicates to the MessageMutation builder.
  5896. func (m *MessageMutation) Where(ps ...predicate.Message) {
  5897. m.predicates = append(m.predicates, ps...)
  5898. }
  5899. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  5900. // users can use type-assertion to append predicates that do not depend on any generated package.
  5901. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  5902. p := make([]predicate.Message, len(ps))
  5903. for i := range ps {
  5904. p[i] = ps[i]
  5905. }
  5906. m.Where(p...)
  5907. }
  5908. // Op returns the operation name.
  5909. func (m *MessageMutation) Op() Op {
  5910. return m.op
  5911. }
  5912. // SetOp allows setting the mutation operation.
  5913. func (m *MessageMutation) SetOp(op Op) {
  5914. m.op = op
  5915. }
  5916. // Type returns the node type of this mutation (Message).
  5917. func (m *MessageMutation) Type() string {
  5918. return m.typ
  5919. }
  5920. // Fields returns all fields that were changed during this mutation. Note that in
  5921. // order to get all numeric fields that were incremented/decremented, call
  5922. // AddedFields().
  5923. func (m *MessageMutation) Fields() []string {
  5924. fields := make([]string, 0, 3)
  5925. if m.wx_wxid != nil {
  5926. fields = append(fields, message.FieldWxWxid)
  5927. }
  5928. if m.wxid != nil {
  5929. fields = append(fields, message.FieldWxid)
  5930. }
  5931. if m.content != nil {
  5932. fields = append(fields, message.FieldContent)
  5933. }
  5934. return fields
  5935. }
  5936. // Field returns the value of a field with the given name. The second boolean
  5937. // return value indicates that this field was not set, or was not defined in the
  5938. // schema.
  5939. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  5940. switch name {
  5941. case message.FieldWxWxid:
  5942. return m.WxWxid()
  5943. case message.FieldWxid:
  5944. return m.Wxid()
  5945. case message.FieldContent:
  5946. return m.Content()
  5947. }
  5948. return nil, false
  5949. }
  5950. // OldField returns the old value of the field from the database. An error is
  5951. // returned if the mutation operation is not UpdateOne, or the query to the
  5952. // database failed.
  5953. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5954. switch name {
  5955. case message.FieldWxWxid:
  5956. return m.OldWxWxid(ctx)
  5957. case message.FieldWxid:
  5958. return m.OldWxid(ctx)
  5959. case message.FieldContent:
  5960. return m.OldContent(ctx)
  5961. }
  5962. return nil, fmt.Errorf("unknown Message field %s", name)
  5963. }
  5964. // SetField sets the value of a field with the given name. It returns an error if
  5965. // the field is not defined in the schema, or if the type mismatched the field
  5966. // type.
  5967. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  5968. switch name {
  5969. case message.FieldWxWxid:
  5970. v, ok := value.(string)
  5971. if !ok {
  5972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5973. }
  5974. m.SetWxWxid(v)
  5975. return nil
  5976. case message.FieldWxid:
  5977. v, ok := value.(string)
  5978. if !ok {
  5979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5980. }
  5981. m.SetWxid(v)
  5982. return nil
  5983. case message.FieldContent:
  5984. v, ok := value.(string)
  5985. if !ok {
  5986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5987. }
  5988. m.SetContent(v)
  5989. return nil
  5990. }
  5991. return fmt.Errorf("unknown Message field %s", name)
  5992. }
  5993. // AddedFields returns all numeric fields that were incremented/decremented during
  5994. // this mutation.
  5995. func (m *MessageMutation) AddedFields() []string {
  5996. return nil
  5997. }
  5998. // AddedField returns the numeric value that was incremented/decremented on a field
  5999. // with the given name. The second boolean return value indicates that this field
  6000. // was not set, or was not defined in the schema.
  6001. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  6002. return nil, false
  6003. }
  6004. // AddField adds the value to the field with the given name. It returns an error if
  6005. // the field is not defined in the schema, or if the type mismatched the field
  6006. // type.
  6007. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  6008. switch name {
  6009. }
  6010. return fmt.Errorf("unknown Message numeric field %s", name)
  6011. }
  6012. // ClearedFields returns all nullable fields that were cleared during this
  6013. // mutation.
  6014. func (m *MessageMutation) ClearedFields() []string {
  6015. var fields []string
  6016. if m.FieldCleared(message.FieldWxWxid) {
  6017. fields = append(fields, message.FieldWxWxid)
  6018. }
  6019. return fields
  6020. }
  6021. // FieldCleared returns a boolean indicating if a field with the given name was
  6022. // cleared in this mutation.
  6023. func (m *MessageMutation) FieldCleared(name string) bool {
  6024. _, ok := m.clearedFields[name]
  6025. return ok
  6026. }
  6027. // ClearField clears the value of the field with the given name. It returns an
  6028. // error if the field is not defined in the schema.
  6029. func (m *MessageMutation) ClearField(name string) error {
  6030. switch name {
  6031. case message.FieldWxWxid:
  6032. m.ClearWxWxid()
  6033. return nil
  6034. }
  6035. return fmt.Errorf("unknown Message nullable field %s", name)
  6036. }
  6037. // ResetField resets all changes in the mutation for the field with the given name.
  6038. // It returns an error if the field is not defined in the schema.
  6039. func (m *MessageMutation) ResetField(name string) error {
  6040. switch name {
  6041. case message.FieldWxWxid:
  6042. m.ResetWxWxid()
  6043. return nil
  6044. case message.FieldWxid:
  6045. m.ResetWxid()
  6046. return nil
  6047. case message.FieldContent:
  6048. m.ResetContent()
  6049. return nil
  6050. }
  6051. return fmt.Errorf("unknown Message field %s", name)
  6052. }
  6053. // AddedEdges returns all edge names that were set/added in this mutation.
  6054. func (m *MessageMutation) AddedEdges() []string {
  6055. edges := make([]string, 0, 0)
  6056. return edges
  6057. }
  6058. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6059. // name in this mutation.
  6060. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  6061. return nil
  6062. }
  6063. // RemovedEdges returns all edge names that were removed in this mutation.
  6064. func (m *MessageMutation) RemovedEdges() []string {
  6065. edges := make([]string, 0, 0)
  6066. return edges
  6067. }
  6068. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6069. // the given name in this mutation.
  6070. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  6071. return nil
  6072. }
  6073. // ClearedEdges returns all edge names that were cleared in this mutation.
  6074. func (m *MessageMutation) ClearedEdges() []string {
  6075. edges := make([]string, 0, 0)
  6076. return edges
  6077. }
  6078. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6079. // was cleared in this mutation.
  6080. func (m *MessageMutation) EdgeCleared(name string) bool {
  6081. return false
  6082. }
  6083. // ClearEdge clears the value of the edge with the given name. It returns an error
  6084. // if that edge is not defined in the schema.
  6085. func (m *MessageMutation) ClearEdge(name string) error {
  6086. return fmt.Errorf("unknown Message unique edge %s", name)
  6087. }
  6088. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6089. // It returns an error if the edge is not defined in the schema.
  6090. func (m *MessageMutation) ResetEdge(name string) error {
  6091. return fmt.Errorf("unknown Message edge %s", name)
  6092. }
  6093. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  6094. type MessageRecordsMutation struct {
  6095. config
  6096. op Op
  6097. typ string
  6098. id *uint64
  6099. created_at *time.Time
  6100. updated_at *time.Time
  6101. status *uint8
  6102. addstatus *int8
  6103. deleted_at *time.Time
  6104. bot_wxid *string
  6105. contact_type *int
  6106. addcontact_type *int
  6107. contact_wxid *string
  6108. content_type *int
  6109. addcontent_type *int
  6110. content *string
  6111. meta *custom_types.Meta
  6112. error_detail *string
  6113. send_time *time.Time
  6114. source_type *int
  6115. addsource_type *int
  6116. organization_id *uint64
  6117. addorganization_id *int64
  6118. clearedFields map[string]struct{}
  6119. sop_stage *uint64
  6120. clearedsop_stage bool
  6121. sop_node *uint64
  6122. clearedsop_node bool
  6123. message_contact *uint64
  6124. clearedmessage_contact bool
  6125. done bool
  6126. oldValue func(context.Context) (*MessageRecords, error)
  6127. predicates []predicate.MessageRecords
  6128. }
  6129. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  6130. // messagerecordsOption allows management of the mutation configuration using functional options.
  6131. type messagerecordsOption func(*MessageRecordsMutation)
  6132. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  6133. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  6134. m := &MessageRecordsMutation{
  6135. config: c,
  6136. op: op,
  6137. typ: TypeMessageRecords,
  6138. clearedFields: make(map[string]struct{}),
  6139. }
  6140. for _, opt := range opts {
  6141. opt(m)
  6142. }
  6143. return m
  6144. }
  6145. // withMessageRecordsID sets the ID field of the mutation.
  6146. func withMessageRecordsID(id uint64) messagerecordsOption {
  6147. return func(m *MessageRecordsMutation) {
  6148. var (
  6149. err error
  6150. once sync.Once
  6151. value *MessageRecords
  6152. )
  6153. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  6154. once.Do(func() {
  6155. if m.done {
  6156. err = errors.New("querying old values post mutation is not allowed")
  6157. } else {
  6158. value, err = m.Client().MessageRecords.Get(ctx, id)
  6159. }
  6160. })
  6161. return value, err
  6162. }
  6163. m.id = &id
  6164. }
  6165. }
  6166. // withMessageRecords sets the old MessageRecords of the mutation.
  6167. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  6168. return func(m *MessageRecordsMutation) {
  6169. m.oldValue = func(context.Context) (*MessageRecords, error) {
  6170. return node, nil
  6171. }
  6172. m.id = &node.ID
  6173. }
  6174. }
  6175. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6176. // executed in a transaction (ent.Tx), a transactional client is returned.
  6177. func (m MessageRecordsMutation) Client() *Client {
  6178. client := &Client{config: m.config}
  6179. client.init()
  6180. return client
  6181. }
  6182. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6183. // it returns an error otherwise.
  6184. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  6185. if _, ok := m.driver.(*txDriver); !ok {
  6186. return nil, errors.New("ent: mutation is not running in a transaction")
  6187. }
  6188. tx := &Tx{config: m.config}
  6189. tx.init()
  6190. return tx, nil
  6191. }
  6192. // SetID sets the value of the id field. Note that this
  6193. // operation is only accepted on creation of MessageRecords entities.
  6194. func (m *MessageRecordsMutation) SetID(id uint64) {
  6195. m.id = &id
  6196. }
  6197. // ID returns the ID value in the mutation. Note that the ID is only available
  6198. // if it was provided to the builder or after it was returned from the database.
  6199. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  6200. if m.id == nil {
  6201. return
  6202. }
  6203. return *m.id, true
  6204. }
  6205. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6206. // That means, if the mutation is applied within a transaction with an isolation level such
  6207. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6208. // or updated by the mutation.
  6209. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  6210. switch {
  6211. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6212. id, exists := m.ID()
  6213. if exists {
  6214. return []uint64{id}, nil
  6215. }
  6216. fallthrough
  6217. case m.op.Is(OpUpdate | OpDelete):
  6218. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  6219. default:
  6220. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6221. }
  6222. }
  6223. // SetCreatedAt sets the "created_at" field.
  6224. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  6225. m.created_at = &t
  6226. }
  6227. // CreatedAt returns the value of the "created_at" field in the mutation.
  6228. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  6229. v := m.created_at
  6230. if v == nil {
  6231. return
  6232. }
  6233. return *v, true
  6234. }
  6235. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  6236. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6238. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6239. if !m.op.Is(OpUpdateOne) {
  6240. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6241. }
  6242. if m.id == nil || m.oldValue == nil {
  6243. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6244. }
  6245. oldValue, err := m.oldValue(ctx)
  6246. if err != nil {
  6247. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6248. }
  6249. return oldValue.CreatedAt, nil
  6250. }
  6251. // ResetCreatedAt resets all changes to the "created_at" field.
  6252. func (m *MessageRecordsMutation) ResetCreatedAt() {
  6253. m.created_at = nil
  6254. }
  6255. // SetUpdatedAt sets the "updated_at" field.
  6256. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  6257. m.updated_at = &t
  6258. }
  6259. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6260. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  6261. v := m.updated_at
  6262. if v == nil {
  6263. return
  6264. }
  6265. return *v, true
  6266. }
  6267. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  6268. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6270. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6271. if !m.op.Is(OpUpdateOne) {
  6272. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6273. }
  6274. if m.id == nil || m.oldValue == nil {
  6275. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6276. }
  6277. oldValue, err := m.oldValue(ctx)
  6278. if err != nil {
  6279. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6280. }
  6281. return oldValue.UpdatedAt, nil
  6282. }
  6283. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6284. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  6285. m.updated_at = nil
  6286. }
  6287. // SetStatus sets the "status" field.
  6288. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  6289. m.status = &u
  6290. m.addstatus = nil
  6291. }
  6292. // Status returns the value of the "status" field in the mutation.
  6293. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  6294. v := m.status
  6295. if v == nil {
  6296. return
  6297. }
  6298. return *v, true
  6299. }
  6300. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  6301. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6303. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  6304. if !m.op.Is(OpUpdateOne) {
  6305. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  6306. }
  6307. if m.id == nil || m.oldValue == nil {
  6308. return v, errors.New("OldStatus requires an ID field in the mutation")
  6309. }
  6310. oldValue, err := m.oldValue(ctx)
  6311. if err != nil {
  6312. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  6313. }
  6314. return oldValue.Status, nil
  6315. }
  6316. // AddStatus adds u to the "status" field.
  6317. func (m *MessageRecordsMutation) AddStatus(u int8) {
  6318. if m.addstatus != nil {
  6319. *m.addstatus += u
  6320. } else {
  6321. m.addstatus = &u
  6322. }
  6323. }
  6324. // AddedStatus returns the value that was added to the "status" field in this mutation.
  6325. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  6326. v := m.addstatus
  6327. if v == nil {
  6328. return
  6329. }
  6330. return *v, true
  6331. }
  6332. // ClearStatus clears the value of the "status" field.
  6333. func (m *MessageRecordsMutation) ClearStatus() {
  6334. m.status = nil
  6335. m.addstatus = nil
  6336. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  6337. }
  6338. // StatusCleared returns if the "status" field was cleared in this mutation.
  6339. func (m *MessageRecordsMutation) StatusCleared() bool {
  6340. _, ok := m.clearedFields[messagerecords.FieldStatus]
  6341. return ok
  6342. }
  6343. // ResetStatus resets all changes to the "status" field.
  6344. func (m *MessageRecordsMutation) ResetStatus() {
  6345. m.status = nil
  6346. m.addstatus = nil
  6347. delete(m.clearedFields, messagerecords.FieldStatus)
  6348. }
  6349. // SetDeletedAt sets the "deleted_at" field.
  6350. func (m *MessageRecordsMutation) SetDeletedAt(t time.Time) {
  6351. m.deleted_at = &t
  6352. }
  6353. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6354. func (m *MessageRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  6355. v := m.deleted_at
  6356. if v == nil {
  6357. return
  6358. }
  6359. return *v, true
  6360. }
  6361. // OldDeletedAt returns the old "deleted_at" field's value of the MessageRecords entity.
  6362. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6364. func (m *MessageRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6365. if !m.op.Is(OpUpdateOne) {
  6366. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6367. }
  6368. if m.id == nil || m.oldValue == nil {
  6369. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6370. }
  6371. oldValue, err := m.oldValue(ctx)
  6372. if err != nil {
  6373. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6374. }
  6375. return oldValue.DeletedAt, nil
  6376. }
  6377. // ClearDeletedAt clears the value of the "deleted_at" field.
  6378. func (m *MessageRecordsMutation) ClearDeletedAt() {
  6379. m.deleted_at = nil
  6380. m.clearedFields[messagerecords.FieldDeletedAt] = struct{}{}
  6381. }
  6382. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6383. func (m *MessageRecordsMutation) DeletedAtCleared() bool {
  6384. _, ok := m.clearedFields[messagerecords.FieldDeletedAt]
  6385. return ok
  6386. }
  6387. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6388. func (m *MessageRecordsMutation) ResetDeletedAt() {
  6389. m.deleted_at = nil
  6390. delete(m.clearedFields, messagerecords.FieldDeletedAt)
  6391. }
  6392. // SetBotWxid sets the "bot_wxid" field.
  6393. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  6394. m.bot_wxid = &s
  6395. }
  6396. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  6397. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  6398. v := m.bot_wxid
  6399. if v == nil {
  6400. return
  6401. }
  6402. return *v, true
  6403. }
  6404. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  6405. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6407. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  6408. if !m.op.Is(OpUpdateOne) {
  6409. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  6410. }
  6411. if m.id == nil || m.oldValue == nil {
  6412. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  6413. }
  6414. oldValue, err := m.oldValue(ctx)
  6415. if err != nil {
  6416. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  6417. }
  6418. return oldValue.BotWxid, nil
  6419. }
  6420. // ResetBotWxid resets all changes to the "bot_wxid" field.
  6421. func (m *MessageRecordsMutation) ResetBotWxid() {
  6422. m.bot_wxid = nil
  6423. }
  6424. // SetContactID sets the "contact_id" field.
  6425. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  6426. m.message_contact = &u
  6427. }
  6428. // ContactID returns the value of the "contact_id" field in the mutation.
  6429. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  6430. v := m.message_contact
  6431. if v == nil {
  6432. return
  6433. }
  6434. return *v, true
  6435. }
  6436. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  6437. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6439. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  6440. if !m.op.Is(OpUpdateOne) {
  6441. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  6442. }
  6443. if m.id == nil || m.oldValue == nil {
  6444. return v, errors.New("OldContactID requires an ID field in the mutation")
  6445. }
  6446. oldValue, err := m.oldValue(ctx)
  6447. if err != nil {
  6448. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  6449. }
  6450. return oldValue.ContactID, nil
  6451. }
  6452. // ClearContactID clears the value of the "contact_id" field.
  6453. func (m *MessageRecordsMutation) ClearContactID() {
  6454. m.message_contact = nil
  6455. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  6456. }
  6457. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  6458. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  6459. _, ok := m.clearedFields[messagerecords.FieldContactID]
  6460. return ok
  6461. }
  6462. // ResetContactID resets all changes to the "contact_id" field.
  6463. func (m *MessageRecordsMutation) ResetContactID() {
  6464. m.message_contact = nil
  6465. delete(m.clearedFields, messagerecords.FieldContactID)
  6466. }
  6467. // SetContactType sets the "contact_type" field.
  6468. func (m *MessageRecordsMutation) SetContactType(i int) {
  6469. m.contact_type = &i
  6470. m.addcontact_type = nil
  6471. }
  6472. // ContactType returns the value of the "contact_type" field in the mutation.
  6473. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  6474. v := m.contact_type
  6475. if v == nil {
  6476. return
  6477. }
  6478. return *v, true
  6479. }
  6480. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  6481. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6482. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6483. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  6484. if !m.op.Is(OpUpdateOne) {
  6485. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  6486. }
  6487. if m.id == nil || m.oldValue == nil {
  6488. return v, errors.New("OldContactType requires an ID field in the mutation")
  6489. }
  6490. oldValue, err := m.oldValue(ctx)
  6491. if err != nil {
  6492. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  6493. }
  6494. return oldValue.ContactType, nil
  6495. }
  6496. // AddContactType adds i to the "contact_type" field.
  6497. func (m *MessageRecordsMutation) AddContactType(i int) {
  6498. if m.addcontact_type != nil {
  6499. *m.addcontact_type += i
  6500. } else {
  6501. m.addcontact_type = &i
  6502. }
  6503. }
  6504. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  6505. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  6506. v := m.addcontact_type
  6507. if v == nil {
  6508. return
  6509. }
  6510. return *v, true
  6511. }
  6512. // ResetContactType resets all changes to the "contact_type" field.
  6513. func (m *MessageRecordsMutation) ResetContactType() {
  6514. m.contact_type = nil
  6515. m.addcontact_type = nil
  6516. }
  6517. // SetContactWxid sets the "contact_wxid" field.
  6518. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  6519. m.contact_wxid = &s
  6520. }
  6521. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  6522. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  6523. v := m.contact_wxid
  6524. if v == nil {
  6525. return
  6526. }
  6527. return *v, true
  6528. }
  6529. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  6530. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6532. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  6533. if !m.op.Is(OpUpdateOne) {
  6534. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  6535. }
  6536. if m.id == nil || m.oldValue == nil {
  6537. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  6538. }
  6539. oldValue, err := m.oldValue(ctx)
  6540. if err != nil {
  6541. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  6542. }
  6543. return oldValue.ContactWxid, nil
  6544. }
  6545. // ResetContactWxid resets all changes to the "contact_wxid" field.
  6546. func (m *MessageRecordsMutation) ResetContactWxid() {
  6547. m.contact_wxid = nil
  6548. }
  6549. // SetContentType sets the "content_type" field.
  6550. func (m *MessageRecordsMutation) SetContentType(i int) {
  6551. m.content_type = &i
  6552. m.addcontent_type = nil
  6553. }
  6554. // ContentType returns the value of the "content_type" field in the mutation.
  6555. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  6556. v := m.content_type
  6557. if v == nil {
  6558. return
  6559. }
  6560. return *v, true
  6561. }
  6562. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  6563. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6565. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  6566. if !m.op.Is(OpUpdateOne) {
  6567. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  6568. }
  6569. if m.id == nil || m.oldValue == nil {
  6570. return v, errors.New("OldContentType requires an ID field in the mutation")
  6571. }
  6572. oldValue, err := m.oldValue(ctx)
  6573. if err != nil {
  6574. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  6575. }
  6576. return oldValue.ContentType, nil
  6577. }
  6578. // AddContentType adds i to the "content_type" field.
  6579. func (m *MessageRecordsMutation) AddContentType(i int) {
  6580. if m.addcontent_type != nil {
  6581. *m.addcontent_type += i
  6582. } else {
  6583. m.addcontent_type = &i
  6584. }
  6585. }
  6586. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  6587. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  6588. v := m.addcontent_type
  6589. if v == nil {
  6590. return
  6591. }
  6592. return *v, true
  6593. }
  6594. // ResetContentType resets all changes to the "content_type" field.
  6595. func (m *MessageRecordsMutation) ResetContentType() {
  6596. m.content_type = nil
  6597. m.addcontent_type = nil
  6598. }
  6599. // SetContent sets the "content" field.
  6600. func (m *MessageRecordsMutation) SetContent(s string) {
  6601. m.content = &s
  6602. }
  6603. // Content returns the value of the "content" field in the mutation.
  6604. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  6605. v := m.content
  6606. if v == nil {
  6607. return
  6608. }
  6609. return *v, true
  6610. }
  6611. // OldContent returns the old "content" field's value of the MessageRecords entity.
  6612. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6614. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  6615. if !m.op.Is(OpUpdateOne) {
  6616. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6617. }
  6618. if m.id == nil || m.oldValue == nil {
  6619. return v, errors.New("OldContent requires an ID field in the mutation")
  6620. }
  6621. oldValue, err := m.oldValue(ctx)
  6622. if err != nil {
  6623. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  6624. }
  6625. return oldValue.Content, nil
  6626. }
  6627. // ResetContent resets all changes to the "content" field.
  6628. func (m *MessageRecordsMutation) ResetContent() {
  6629. m.content = nil
  6630. }
  6631. // SetMeta sets the "meta" field.
  6632. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  6633. m.meta = &ct
  6634. }
  6635. // Meta returns the value of the "meta" field in the mutation.
  6636. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  6637. v := m.meta
  6638. if v == nil {
  6639. return
  6640. }
  6641. return *v, true
  6642. }
  6643. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  6644. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6646. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  6647. if !m.op.Is(OpUpdateOne) {
  6648. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  6649. }
  6650. if m.id == nil || m.oldValue == nil {
  6651. return v, errors.New("OldMeta requires an ID field in the mutation")
  6652. }
  6653. oldValue, err := m.oldValue(ctx)
  6654. if err != nil {
  6655. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  6656. }
  6657. return oldValue.Meta, nil
  6658. }
  6659. // ClearMeta clears the value of the "meta" field.
  6660. func (m *MessageRecordsMutation) ClearMeta() {
  6661. m.meta = nil
  6662. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  6663. }
  6664. // MetaCleared returns if the "meta" field was cleared in this mutation.
  6665. func (m *MessageRecordsMutation) MetaCleared() bool {
  6666. _, ok := m.clearedFields[messagerecords.FieldMeta]
  6667. return ok
  6668. }
  6669. // ResetMeta resets all changes to the "meta" field.
  6670. func (m *MessageRecordsMutation) ResetMeta() {
  6671. m.meta = nil
  6672. delete(m.clearedFields, messagerecords.FieldMeta)
  6673. }
  6674. // SetErrorDetail sets the "error_detail" field.
  6675. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  6676. m.error_detail = &s
  6677. }
  6678. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  6679. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  6680. v := m.error_detail
  6681. if v == nil {
  6682. return
  6683. }
  6684. return *v, true
  6685. }
  6686. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  6687. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6689. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  6690. if !m.op.Is(OpUpdateOne) {
  6691. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  6692. }
  6693. if m.id == nil || m.oldValue == nil {
  6694. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  6695. }
  6696. oldValue, err := m.oldValue(ctx)
  6697. if err != nil {
  6698. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  6699. }
  6700. return oldValue.ErrorDetail, nil
  6701. }
  6702. // ResetErrorDetail resets all changes to the "error_detail" field.
  6703. func (m *MessageRecordsMutation) ResetErrorDetail() {
  6704. m.error_detail = nil
  6705. }
  6706. // SetSendTime sets the "send_time" field.
  6707. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  6708. m.send_time = &t
  6709. }
  6710. // SendTime returns the value of the "send_time" field in the mutation.
  6711. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  6712. v := m.send_time
  6713. if v == nil {
  6714. return
  6715. }
  6716. return *v, true
  6717. }
  6718. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  6719. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6721. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  6722. if !m.op.Is(OpUpdateOne) {
  6723. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  6724. }
  6725. if m.id == nil || m.oldValue == nil {
  6726. return v, errors.New("OldSendTime requires an ID field in the mutation")
  6727. }
  6728. oldValue, err := m.oldValue(ctx)
  6729. if err != nil {
  6730. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  6731. }
  6732. return oldValue.SendTime, nil
  6733. }
  6734. // ClearSendTime clears the value of the "send_time" field.
  6735. func (m *MessageRecordsMutation) ClearSendTime() {
  6736. m.send_time = nil
  6737. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  6738. }
  6739. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  6740. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  6741. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  6742. return ok
  6743. }
  6744. // ResetSendTime resets all changes to the "send_time" field.
  6745. func (m *MessageRecordsMutation) ResetSendTime() {
  6746. m.send_time = nil
  6747. delete(m.clearedFields, messagerecords.FieldSendTime)
  6748. }
  6749. // SetSourceType sets the "source_type" field.
  6750. func (m *MessageRecordsMutation) SetSourceType(i int) {
  6751. m.source_type = &i
  6752. m.addsource_type = nil
  6753. }
  6754. // SourceType returns the value of the "source_type" field in the mutation.
  6755. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  6756. v := m.source_type
  6757. if v == nil {
  6758. return
  6759. }
  6760. return *v, true
  6761. }
  6762. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  6763. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6765. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  6766. if !m.op.Is(OpUpdateOne) {
  6767. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  6768. }
  6769. if m.id == nil || m.oldValue == nil {
  6770. return v, errors.New("OldSourceType requires an ID field in the mutation")
  6771. }
  6772. oldValue, err := m.oldValue(ctx)
  6773. if err != nil {
  6774. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  6775. }
  6776. return oldValue.SourceType, nil
  6777. }
  6778. // AddSourceType adds i to the "source_type" field.
  6779. func (m *MessageRecordsMutation) AddSourceType(i int) {
  6780. if m.addsource_type != nil {
  6781. *m.addsource_type += i
  6782. } else {
  6783. m.addsource_type = &i
  6784. }
  6785. }
  6786. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  6787. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  6788. v := m.addsource_type
  6789. if v == nil {
  6790. return
  6791. }
  6792. return *v, true
  6793. }
  6794. // ResetSourceType resets all changes to the "source_type" field.
  6795. func (m *MessageRecordsMutation) ResetSourceType() {
  6796. m.source_type = nil
  6797. m.addsource_type = nil
  6798. }
  6799. // SetSourceID sets the "source_id" field.
  6800. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  6801. m.sop_stage = &u
  6802. }
  6803. // SourceID returns the value of the "source_id" field in the mutation.
  6804. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  6805. v := m.sop_stage
  6806. if v == nil {
  6807. return
  6808. }
  6809. return *v, true
  6810. }
  6811. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  6812. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6814. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  6815. if !m.op.Is(OpUpdateOne) {
  6816. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  6817. }
  6818. if m.id == nil || m.oldValue == nil {
  6819. return v, errors.New("OldSourceID requires an ID field in the mutation")
  6820. }
  6821. oldValue, err := m.oldValue(ctx)
  6822. if err != nil {
  6823. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  6824. }
  6825. return oldValue.SourceID, nil
  6826. }
  6827. // ClearSourceID clears the value of the "source_id" field.
  6828. func (m *MessageRecordsMutation) ClearSourceID() {
  6829. m.sop_stage = nil
  6830. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  6831. }
  6832. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  6833. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  6834. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  6835. return ok
  6836. }
  6837. // ResetSourceID resets all changes to the "source_id" field.
  6838. func (m *MessageRecordsMutation) ResetSourceID() {
  6839. m.sop_stage = nil
  6840. delete(m.clearedFields, messagerecords.FieldSourceID)
  6841. }
  6842. // SetSubSourceID sets the "sub_source_id" field.
  6843. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  6844. m.sop_node = &u
  6845. }
  6846. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  6847. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  6848. v := m.sop_node
  6849. if v == nil {
  6850. return
  6851. }
  6852. return *v, true
  6853. }
  6854. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  6855. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6857. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  6858. if !m.op.Is(OpUpdateOne) {
  6859. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  6860. }
  6861. if m.id == nil || m.oldValue == nil {
  6862. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  6863. }
  6864. oldValue, err := m.oldValue(ctx)
  6865. if err != nil {
  6866. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  6867. }
  6868. return oldValue.SubSourceID, nil
  6869. }
  6870. // ClearSubSourceID clears the value of the "sub_source_id" field.
  6871. func (m *MessageRecordsMutation) ClearSubSourceID() {
  6872. m.sop_node = nil
  6873. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  6874. }
  6875. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  6876. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  6877. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  6878. return ok
  6879. }
  6880. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  6881. func (m *MessageRecordsMutation) ResetSubSourceID() {
  6882. m.sop_node = nil
  6883. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  6884. }
  6885. // SetOrganizationID sets the "organization_id" field.
  6886. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  6887. m.organization_id = &u
  6888. m.addorganization_id = nil
  6889. }
  6890. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6891. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  6892. v := m.organization_id
  6893. if v == nil {
  6894. return
  6895. }
  6896. return *v, true
  6897. }
  6898. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  6899. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6901. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6902. if !m.op.Is(OpUpdateOne) {
  6903. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6904. }
  6905. if m.id == nil || m.oldValue == nil {
  6906. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6907. }
  6908. oldValue, err := m.oldValue(ctx)
  6909. if err != nil {
  6910. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6911. }
  6912. return oldValue.OrganizationID, nil
  6913. }
  6914. // AddOrganizationID adds u to the "organization_id" field.
  6915. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  6916. if m.addorganization_id != nil {
  6917. *m.addorganization_id += u
  6918. } else {
  6919. m.addorganization_id = &u
  6920. }
  6921. }
  6922. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6923. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  6924. v := m.addorganization_id
  6925. if v == nil {
  6926. return
  6927. }
  6928. return *v, true
  6929. }
  6930. // ClearOrganizationID clears the value of the "organization_id" field.
  6931. func (m *MessageRecordsMutation) ClearOrganizationID() {
  6932. m.organization_id = nil
  6933. m.addorganization_id = nil
  6934. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  6935. }
  6936. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  6937. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  6938. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  6939. return ok
  6940. }
  6941. // ResetOrganizationID resets all changes to the "organization_id" field.
  6942. func (m *MessageRecordsMutation) ResetOrganizationID() {
  6943. m.organization_id = nil
  6944. m.addorganization_id = nil
  6945. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  6946. }
  6947. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  6948. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  6949. m.sop_stage = &id
  6950. }
  6951. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  6952. func (m *MessageRecordsMutation) ClearSopStage() {
  6953. m.clearedsop_stage = true
  6954. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  6955. }
  6956. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  6957. func (m *MessageRecordsMutation) SopStageCleared() bool {
  6958. return m.SourceIDCleared() || m.clearedsop_stage
  6959. }
  6960. // SopStageID returns the "sop_stage" edge ID in the mutation.
  6961. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  6962. if m.sop_stage != nil {
  6963. return *m.sop_stage, true
  6964. }
  6965. return
  6966. }
  6967. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  6968. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  6969. // SopStageID instead. It exists only for internal usage by the builders.
  6970. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  6971. if id := m.sop_stage; id != nil {
  6972. ids = append(ids, *id)
  6973. }
  6974. return
  6975. }
  6976. // ResetSopStage resets all changes to the "sop_stage" edge.
  6977. func (m *MessageRecordsMutation) ResetSopStage() {
  6978. m.sop_stage = nil
  6979. m.clearedsop_stage = false
  6980. }
  6981. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  6982. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  6983. m.sop_node = &id
  6984. }
  6985. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  6986. func (m *MessageRecordsMutation) ClearSopNode() {
  6987. m.clearedsop_node = true
  6988. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  6989. }
  6990. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  6991. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  6992. return m.SubSourceIDCleared() || m.clearedsop_node
  6993. }
  6994. // SopNodeID returns the "sop_node" edge ID in the mutation.
  6995. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  6996. if m.sop_node != nil {
  6997. return *m.sop_node, true
  6998. }
  6999. return
  7000. }
  7001. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  7002. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  7003. // SopNodeID instead. It exists only for internal usage by the builders.
  7004. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  7005. if id := m.sop_node; id != nil {
  7006. ids = append(ids, *id)
  7007. }
  7008. return
  7009. }
  7010. // ResetSopNode resets all changes to the "sop_node" edge.
  7011. func (m *MessageRecordsMutation) ResetSopNode() {
  7012. m.sop_node = nil
  7013. m.clearedsop_node = false
  7014. }
  7015. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  7016. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  7017. m.message_contact = &id
  7018. }
  7019. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  7020. func (m *MessageRecordsMutation) ClearMessageContact() {
  7021. m.clearedmessage_contact = true
  7022. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  7023. }
  7024. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  7025. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  7026. return m.ContactIDCleared() || m.clearedmessage_contact
  7027. }
  7028. // MessageContactID returns the "message_contact" edge ID in the mutation.
  7029. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  7030. if m.message_contact != nil {
  7031. return *m.message_contact, true
  7032. }
  7033. return
  7034. }
  7035. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  7036. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  7037. // MessageContactID instead. It exists only for internal usage by the builders.
  7038. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  7039. if id := m.message_contact; id != nil {
  7040. ids = append(ids, *id)
  7041. }
  7042. return
  7043. }
  7044. // ResetMessageContact resets all changes to the "message_contact" edge.
  7045. func (m *MessageRecordsMutation) ResetMessageContact() {
  7046. m.message_contact = nil
  7047. m.clearedmessage_contact = false
  7048. }
  7049. // Where appends a list predicates to the MessageRecordsMutation builder.
  7050. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  7051. m.predicates = append(m.predicates, ps...)
  7052. }
  7053. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  7054. // users can use type-assertion to append predicates that do not depend on any generated package.
  7055. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  7056. p := make([]predicate.MessageRecords, len(ps))
  7057. for i := range ps {
  7058. p[i] = ps[i]
  7059. }
  7060. m.Where(p...)
  7061. }
  7062. // Op returns the operation name.
  7063. func (m *MessageRecordsMutation) Op() Op {
  7064. return m.op
  7065. }
  7066. // SetOp allows setting the mutation operation.
  7067. func (m *MessageRecordsMutation) SetOp(op Op) {
  7068. m.op = op
  7069. }
  7070. // Type returns the node type of this mutation (MessageRecords).
  7071. func (m *MessageRecordsMutation) Type() string {
  7072. return m.typ
  7073. }
  7074. // Fields returns all fields that were changed during this mutation. Note that in
  7075. // order to get all numeric fields that were incremented/decremented, call
  7076. // AddedFields().
  7077. func (m *MessageRecordsMutation) Fields() []string {
  7078. fields := make([]string, 0, 17)
  7079. if m.created_at != nil {
  7080. fields = append(fields, messagerecords.FieldCreatedAt)
  7081. }
  7082. if m.updated_at != nil {
  7083. fields = append(fields, messagerecords.FieldUpdatedAt)
  7084. }
  7085. if m.status != nil {
  7086. fields = append(fields, messagerecords.FieldStatus)
  7087. }
  7088. if m.deleted_at != nil {
  7089. fields = append(fields, messagerecords.FieldDeletedAt)
  7090. }
  7091. if m.bot_wxid != nil {
  7092. fields = append(fields, messagerecords.FieldBotWxid)
  7093. }
  7094. if m.message_contact != nil {
  7095. fields = append(fields, messagerecords.FieldContactID)
  7096. }
  7097. if m.contact_type != nil {
  7098. fields = append(fields, messagerecords.FieldContactType)
  7099. }
  7100. if m.contact_wxid != nil {
  7101. fields = append(fields, messagerecords.FieldContactWxid)
  7102. }
  7103. if m.content_type != nil {
  7104. fields = append(fields, messagerecords.FieldContentType)
  7105. }
  7106. if m.content != nil {
  7107. fields = append(fields, messagerecords.FieldContent)
  7108. }
  7109. if m.meta != nil {
  7110. fields = append(fields, messagerecords.FieldMeta)
  7111. }
  7112. if m.error_detail != nil {
  7113. fields = append(fields, messagerecords.FieldErrorDetail)
  7114. }
  7115. if m.send_time != nil {
  7116. fields = append(fields, messagerecords.FieldSendTime)
  7117. }
  7118. if m.source_type != nil {
  7119. fields = append(fields, messagerecords.FieldSourceType)
  7120. }
  7121. if m.sop_stage != nil {
  7122. fields = append(fields, messagerecords.FieldSourceID)
  7123. }
  7124. if m.sop_node != nil {
  7125. fields = append(fields, messagerecords.FieldSubSourceID)
  7126. }
  7127. if m.organization_id != nil {
  7128. fields = append(fields, messagerecords.FieldOrganizationID)
  7129. }
  7130. return fields
  7131. }
  7132. // Field returns the value of a field with the given name. The second boolean
  7133. // return value indicates that this field was not set, or was not defined in the
  7134. // schema.
  7135. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  7136. switch name {
  7137. case messagerecords.FieldCreatedAt:
  7138. return m.CreatedAt()
  7139. case messagerecords.FieldUpdatedAt:
  7140. return m.UpdatedAt()
  7141. case messagerecords.FieldStatus:
  7142. return m.Status()
  7143. case messagerecords.FieldDeletedAt:
  7144. return m.DeletedAt()
  7145. case messagerecords.FieldBotWxid:
  7146. return m.BotWxid()
  7147. case messagerecords.FieldContactID:
  7148. return m.ContactID()
  7149. case messagerecords.FieldContactType:
  7150. return m.ContactType()
  7151. case messagerecords.FieldContactWxid:
  7152. return m.ContactWxid()
  7153. case messagerecords.FieldContentType:
  7154. return m.ContentType()
  7155. case messagerecords.FieldContent:
  7156. return m.Content()
  7157. case messagerecords.FieldMeta:
  7158. return m.Meta()
  7159. case messagerecords.FieldErrorDetail:
  7160. return m.ErrorDetail()
  7161. case messagerecords.FieldSendTime:
  7162. return m.SendTime()
  7163. case messagerecords.FieldSourceType:
  7164. return m.SourceType()
  7165. case messagerecords.FieldSourceID:
  7166. return m.SourceID()
  7167. case messagerecords.FieldSubSourceID:
  7168. return m.SubSourceID()
  7169. case messagerecords.FieldOrganizationID:
  7170. return m.OrganizationID()
  7171. }
  7172. return nil, false
  7173. }
  7174. // OldField returns the old value of the field from the database. An error is
  7175. // returned if the mutation operation is not UpdateOne, or the query to the
  7176. // database failed.
  7177. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7178. switch name {
  7179. case messagerecords.FieldCreatedAt:
  7180. return m.OldCreatedAt(ctx)
  7181. case messagerecords.FieldUpdatedAt:
  7182. return m.OldUpdatedAt(ctx)
  7183. case messagerecords.FieldStatus:
  7184. return m.OldStatus(ctx)
  7185. case messagerecords.FieldDeletedAt:
  7186. return m.OldDeletedAt(ctx)
  7187. case messagerecords.FieldBotWxid:
  7188. return m.OldBotWxid(ctx)
  7189. case messagerecords.FieldContactID:
  7190. return m.OldContactID(ctx)
  7191. case messagerecords.FieldContactType:
  7192. return m.OldContactType(ctx)
  7193. case messagerecords.FieldContactWxid:
  7194. return m.OldContactWxid(ctx)
  7195. case messagerecords.FieldContentType:
  7196. return m.OldContentType(ctx)
  7197. case messagerecords.FieldContent:
  7198. return m.OldContent(ctx)
  7199. case messagerecords.FieldMeta:
  7200. return m.OldMeta(ctx)
  7201. case messagerecords.FieldErrorDetail:
  7202. return m.OldErrorDetail(ctx)
  7203. case messagerecords.FieldSendTime:
  7204. return m.OldSendTime(ctx)
  7205. case messagerecords.FieldSourceType:
  7206. return m.OldSourceType(ctx)
  7207. case messagerecords.FieldSourceID:
  7208. return m.OldSourceID(ctx)
  7209. case messagerecords.FieldSubSourceID:
  7210. return m.OldSubSourceID(ctx)
  7211. case messagerecords.FieldOrganizationID:
  7212. return m.OldOrganizationID(ctx)
  7213. }
  7214. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  7215. }
  7216. // SetField sets the value of a field with the given name. It returns an error if
  7217. // the field is not defined in the schema, or if the type mismatched the field
  7218. // type.
  7219. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  7220. switch name {
  7221. case messagerecords.FieldCreatedAt:
  7222. v, ok := value.(time.Time)
  7223. if !ok {
  7224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7225. }
  7226. m.SetCreatedAt(v)
  7227. return nil
  7228. case messagerecords.FieldUpdatedAt:
  7229. v, ok := value.(time.Time)
  7230. if !ok {
  7231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7232. }
  7233. m.SetUpdatedAt(v)
  7234. return nil
  7235. case messagerecords.FieldStatus:
  7236. v, ok := value.(uint8)
  7237. if !ok {
  7238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7239. }
  7240. m.SetStatus(v)
  7241. return nil
  7242. case messagerecords.FieldDeletedAt:
  7243. v, ok := value.(time.Time)
  7244. if !ok {
  7245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7246. }
  7247. m.SetDeletedAt(v)
  7248. return nil
  7249. case messagerecords.FieldBotWxid:
  7250. v, ok := value.(string)
  7251. if !ok {
  7252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7253. }
  7254. m.SetBotWxid(v)
  7255. return nil
  7256. case messagerecords.FieldContactID:
  7257. v, ok := value.(uint64)
  7258. if !ok {
  7259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7260. }
  7261. m.SetContactID(v)
  7262. return nil
  7263. case messagerecords.FieldContactType:
  7264. v, ok := value.(int)
  7265. if !ok {
  7266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7267. }
  7268. m.SetContactType(v)
  7269. return nil
  7270. case messagerecords.FieldContactWxid:
  7271. v, ok := value.(string)
  7272. if !ok {
  7273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7274. }
  7275. m.SetContactWxid(v)
  7276. return nil
  7277. case messagerecords.FieldContentType:
  7278. v, ok := value.(int)
  7279. if !ok {
  7280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7281. }
  7282. m.SetContentType(v)
  7283. return nil
  7284. case messagerecords.FieldContent:
  7285. v, ok := value.(string)
  7286. if !ok {
  7287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7288. }
  7289. m.SetContent(v)
  7290. return nil
  7291. case messagerecords.FieldMeta:
  7292. v, ok := value.(custom_types.Meta)
  7293. if !ok {
  7294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7295. }
  7296. m.SetMeta(v)
  7297. return nil
  7298. case messagerecords.FieldErrorDetail:
  7299. v, ok := value.(string)
  7300. if !ok {
  7301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7302. }
  7303. m.SetErrorDetail(v)
  7304. return nil
  7305. case messagerecords.FieldSendTime:
  7306. v, ok := value.(time.Time)
  7307. if !ok {
  7308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7309. }
  7310. m.SetSendTime(v)
  7311. return nil
  7312. case messagerecords.FieldSourceType:
  7313. v, ok := value.(int)
  7314. if !ok {
  7315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7316. }
  7317. m.SetSourceType(v)
  7318. return nil
  7319. case messagerecords.FieldSourceID:
  7320. v, ok := value.(uint64)
  7321. if !ok {
  7322. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7323. }
  7324. m.SetSourceID(v)
  7325. return nil
  7326. case messagerecords.FieldSubSourceID:
  7327. v, ok := value.(uint64)
  7328. if !ok {
  7329. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7330. }
  7331. m.SetSubSourceID(v)
  7332. return nil
  7333. case messagerecords.FieldOrganizationID:
  7334. v, ok := value.(uint64)
  7335. if !ok {
  7336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7337. }
  7338. m.SetOrganizationID(v)
  7339. return nil
  7340. }
  7341. return fmt.Errorf("unknown MessageRecords field %s", name)
  7342. }
  7343. // AddedFields returns all numeric fields that were incremented/decremented during
  7344. // this mutation.
  7345. func (m *MessageRecordsMutation) AddedFields() []string {
  7346. var fields []string
  7347. if m.addstatus != nil {
  7348. fields = append(fields, messagerecords.FieldStatus)
  7349. }
  7350. if m.addcontact_type != nil {
  7351. fields = append(fields, messagerecords.FieldContactType)
  7352. }
  7353. if m.addcontent_type != nil {
  7354. fields = append(fields, messagerecords.FieldContentType)
  7355. }
  7356. if m.addsource_type != nil {
  7357. fields = append(fields, messagerecords.FieldSourceType)
  7358. }
  7359. if m.addorganization_id != nil {
  7360. fields = append(fields, messagerecords.FieldOrganizationID)
  7361. }
  7362. return fields
  7363. }
  7364. // AddedField returns the numeric value that was incremented/decremented on a field
  7365. // with the given name. The second boolean return value indicates that this field
  7366. // was not set, or was not defined in the schema.
  7367. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  7368. switch name {
  7369. case messagerecords.FieldStatus:
  7370. return m.AddedStatus()
  7371. case messagerecords.FieldContactType:
  7372. return m.AddedContactType()
  7373. case messagerecords.FieldContentType:
  7374. return m.AddedContentType()
  7375. case messagerecords.FieldSourceType:
  7376. return m.AddedSourceType()
  7377. case messagerecords.FieldOrganizationID:
  7378. return m.AddedOrganizationID()
  7379. }
  7380. return nil, false
  7381. }
  7382. // AddField adds the value to the field with the given name. It returns an error if
  7383. // the field is not defined in the schema, or if the type mismatched the field
  7384. // type.
  7385. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  7386. switch name {
  7387. case messagerecords.FieldStatus:
  7388. v, ok := value.(int8)
  7389. if !ok {
  7390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7391. }
  7392. m.AddStatus(v)
  7393. return nil
  7394. case messagerecords.FieldContactType:
  7395. v, ok := value.(int)
  7396. if !ok {
  7397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7398. }
  7399. m.AddContactType(v)
  7400. return nil
  7401. case messagerecords.FieldContentType:
  7402. v, ok := value.(int)
  7403. if !ok {
  7404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7405. }
  7406. m.AddContentType(v)
  7407. return nil
  7408. case messagerecords.FieldSourceType:
  7409. v, ok := value.(int)
  7410. if !ok {
  7411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7412. }
  7413. m.AddSourceType(v)
  7414. return nil
  7415. case messagerecords.FieldOrganizationID:
  7416. v, ok := value.(int64)
  7417. if !ok {
  7418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7419. }
  7420. m.AddOrganizationID(v)
  7421. return nil
  7422. }
  7423. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  7424. }
  7425. // ClearedFields returns all nullable fields that were cleared during this
  7426. // mutation.
  7427. func (m *MessageRecordsMutation) ClearedFields() []string {
  7428. var fields []string
  7429. if m.FieldCleared(messagerecords.FieldStatus) {
  7430. fields = append(fields, messagerecords.FieldStatus)
  7431. }
  7432. if m.FieldCleared(messagerecords.FieldDeletedAt) {
  7433. fields = append(fields, messagerecords.FieldDeletedAt)
  7434. }
  7435. if m.FieldCleared(messagerecords.FieldContactID) {
  7436. fields = append(fields, messagerecords.FieldContactID)
  7437. }
  7438. if m.FieldCleared(messagerecords.FieldMeta) {
  7439. fields = append(fields, messagerecords.FieldMeta)
  7440. }
  7441. if m.FieldCleared(messagerecords.FieldSendTime) {
  7442. fields = append(fields, messagerecords.FieldSendTime)
  7443. }
  7444. if m.FieldCleared(messagerecords.FieldSourceID) {
  7445. fields = append(fields, messagerecords.FieldSourceID)
  7446. }
  7447. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  7448. fields = append(fields, messagerecords.FieldSubSourceID)
  7449. }
  7450. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  7451. fields = append(fields, messagerecords.FieldOrganizationID)
  7452. }
  7453. return fields
  7454. }
  7455. // FieldCleared returns a boolean indicating if a field with the given name was
  7456. // cleared in this mutation.
  7457. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  7458. _, ok := m.clearedFields[name]
  7459. return ok
  7460. }
  7461. // ClearField clears the value of the field with the given name. It returns an
  7462. // error if the field is not defined in the schema.
  7463. func (m *MessageRecordsMutation) ClearField(name string) error {
  7464. switch name {
  7465. case messagerecords.FieldStatus:
  7466. m.ClearStatus()
  7467. return nil
  7468. case messagerecords.FieldDeletedAt:
  7469. m.ClearDeletedAt()
  7470. return nil
  7471. case messagerecords.FieldContactID:
  7472. m.ClearContactID()
  7473. return nil
  7474. case messagerecords.FieldMeta:
  7475. m.ClearMeta()
  7476. return nil
  7477. case messagerecords.FieldSendTime:
  7478. m.ClearSendTime()
  7479. return nil
  7480. case messagerecords.FieldSourceID:
  7481. m.ClearSourceID()
  7482. return nil
  7483. case messagerecords.FieldSubSourceID:
  7484. m.ClearSubSourceID()
  7485. return nil
  7486. case messagerecords.FieldOrganizationID:
  7487. m.ClearOrganizationID()
  7488. return nil
  7489. }
  7490. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  7491. }
  7492. // ResetField resets all changes in the mutation for the field with the given name.
  7493. // It returns an error if the field is not defined in the schema.
  7494. func (m *MessageRecordsMutation) ResetField(name string) error {
  7495. switch name {
  7496. case messagerecords.FieldCreatedAt:
  7497. m.ResetCreatedAt()
  7498. return nil
  7499. case messagerecords.FieldUpdatedAt:
  7500. m.ResetUpdatedAt()
  7501. return nil
  7502. case messagerecords.FieldStatus:
  7503. m.ResetStatus()
  7504. return nil
  7505. case messagerecords.FieldDeletedAt:
  7506. m.ResetDeletedAt()
  7507. return nil
  7508. case messagerecords.FieldBotWxid:
  7509. m.ResetBotWxid()
  7510. return nil
  7511. case messagerecords.FieldContactID:
  7512. m.ResetContactID()
  7513. return nil
  7514. case messagerecords.FieldContactType:
  7515. m.ResetContactType()
  7516. return nil
  7517. case messagerecords.FieldContactWxid:
  7518. m.ResetContactWxid()
  7519. return nil
  7520. case messagerecords.FieldContentType:
  7521. m.ResetContentType()
  7522. return nil
  7523. case messagerecords.FieldContent:
  7524. m.ResetContent()
  7525. return nil
  7526. case messagerecords.FieldMeta:
  7527. m.ResetMeta()
  7528. return nil
  7529. case messagerecords.FieldErrorDetail:
  7530. m.ResetErrorDetail()
  7531. return nil
  7532. case messagerecords.FieldSendTime:
  7533. m.ResetSendTime()
  7534. return nil
  7535. case messagerecords.FieldSourceType:
  7536. m.ResetSourceType()
  7537. return nil
  7538. case messagerecords.FieldSourceID:
  7539. m.ResetSourceID()
  7540. return nil
  7541. case messagerecords.FieldSubSourceID:
  7542. m.ResetSubSourceID()
  7543. return nil
  7544. case messagerecords.FieldOrganizationID:
  7545. m.ResetOrganizationID()
  7546. return nil
  7547. }
  7548. return fmt.Errorf("unknown MessageRecords field %s", name)
  7549. }
  7550. // AddedEdges returns all edge names that were set/added in this mutation.
  7551. func (m *MessageRecordsMutation) AddedEdges() []string {
  7552. edges := make([]string, 0, 3)
  7553. if m.sop_stage != nil {
  7554. edges = append(edges, messagerecords.EdgeSopStage)
  7555. }
  7556. if m.sop_node != nil {
  7557. edges = append(edges, messagerecords.EdgeSopNode)
  7558. }
  7559. if m.message_contact != nil {
  7560. edges = append(edges, messagerecords.EdgeMessageContact)
  7561. }
  7562. return edges
  7563. }
  7564. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7565. // name in this mutation.
  7566. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  7567. switch name {
  7568. case messagerecords.EdgeSopStage:
  7569. if id := m.sop_stage; id != nil {
  7570. return []ent.Value{*id}
  7571. }
  7572. case messagerecords.EdgeSopNode:
  7573. if id := m.sop_node; id != nil {
  7574. return []ent.Value{*id}
  7575. }
  7576. case messagerecords.EdgeMessageContact:
  7577. if id := m.message_contact; id != nil {
  7578. return []ent.Value{*id}
  7579. }
  7580. }
  7581. return nil
  7582. }
  7583. // RemovedEdges returns all edge names that were removed in this mutation.
  7584. func (m *MessageRecordsMutation) RemovedEdges() []string {
  7585. edges := make([]string, 0, 3)
  7586. return edges
  7587. }
  7588. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7589. // the given name in this mutation.
  7590. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  7591. return nil
  7592. }
  7593. // ClearedEdges returns all edge names that were cleared in this mutation.
  7594. func (m *MessageRecordsMutation) ClearedEdges() []string {
  7595. edges := make([]string, 0, 3)
  7596. if m.clearedsop_stage {
  7597. edges = append(edges, messagerecords.EdgeSopStage)
  7598. }
  7599. if m.clearedsop_node {
  7600. edges = append(edges, messagerecords.EdgeSopNode)
  7601. }
  7602. if m.clearedmessage_contact {
  7603. edges = append(edges, messagerecords.EdgeMessageContact)
  7604. }
  7605. return edges
  7606. }
  7607. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7608. // was cleared in this mutation.
  7609. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  7610. switch name {
  7611. case messagerecords.EdgeSopStage:
  7612. return m.clearedsop_stage
  7613. case messagerecords.EdgeSopNode:
  7614. return m.clearedsop_node
  7615. case messagerecords.EdgeMessageContact:
  7616. return m.clearedmessage_contact
  7617. }
  7618. return false
  7619. }
  7620. // ClearEdge clears the value of the edge with the given name. It returns an error
  7621. // if that edge is not defined in the schema.
  7622. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  7623. switch name {
  7624. case messagerecords.EdgeSopStage:
  7625. m.ClearSopStage()
  7626. return nil
  7627. case messagerecords.EdgeSopNode:
  7628. m.ClearSopNode()
  7629. return nil
  7630. case messagerecords.EdgeMessageContact:
  7631. m.ClearMessageContact()
  7632. return nil
  7633. }
  7634. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  7635. }
  7636. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7637. // It returns an error if the edge is not defined in the schema.
  7638. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  7639. switch name {
  7640. case messagerecords.EdgeSopStage:
  7641. m.ResetSopStage()
  7642. return nil
  7643. case messagerecords.EdgeSopNode:
  7644. m.ResetSopNode()
  7645. return nil
  7646. case messagerecords.EdgeMessageContact:
  7647. m.ResetMessageContact()
  7648. return nil
  7649. }
  7650. return fmt.Errorf("unknown MessageRecords edge %s", name)
  7651. }
  7652. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  7653. type MsgMutation struct {
  7654. config
  7655. op Op
  7656. typ string
  7657. id *uint64
  7658. created_at *time.Time
  7659. updated_at *time.Time
  7660. deleted_at *time.Time
  7661. status *uint8
  7662. addstatus *int8
  7663. fromwxid *string
  7664. toid *string
  7665. msgtype *int32
  7666. addmsgtype *int32
  7667. msg *string
  7668. batch_no *string
  7669. clearedFields map[string]struct{}
  7670. done bool
  7671. oldValue func(context.Context) (*Msg, error)
  7672. predicates []predicate.Msg
  7673. }
  7674. var _ ent.Mutation = (*MsgMutation)(nil)
  7675. // msgOption allows management of the mutation configuration using functional options.
  7676. type msgOption func(*MsgMutation)
  7677. // newMsgMutation creates new mutation for the Msg entity.
  7678. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  7679. m := &MsgMutation{
  7680. config: c,
  7681. op: op,
  7682. typ: TypeMsg,
  7683. clearedFields: make(map[string]struct{}),
  7684. }
  7685. for _, opt := range opts {
  7686. opt(m)
  7687. }
  7688. return m
  7689. }
  7690. // withMsgID sets the ID field of the mutation.
  7691. func withMsgID(id uint64) msgOption {
  7692. return func(m *MsgMutation) {
  7693. var (
  7694. err error
  7695. once sync.Once
  7696. value *Msg
  7697. )
  7698. m.oldValue = func(ctx context.Context) (*Msg, error) {
  7699. once.Do(func() {
  7700. if m.done {
  7701. err = errors.New("querying old values post mutation is not allowed")
  7702. } else {
  7703. value, err = m.Client().Msg.Get(ctx, id)
  7704. }
  7705. })
  7706. return value, err
  7707. }
  7708. m.id = &id
  7709. }
  7710. }
  7711. // withMsg sets the old Msg of the mutation.
  7712. func withMsg(node *Msg) msgOption {
  7713. return func(m *MsgMutation) {
  7714. m.oldValue = func(context.Context) (*Msg, error) {
  7715. return node, nil
  7716. }
  7717. m.id = &node.ID
  7718. }
  7719. }
  7720. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7721. // executed in a transaction (ent.Tx), a transactional client is returned.
  7722. func (m MsgMutation) Client() *Client {
  7723. client := &Client{config: m.config}
  7724. client.init()
  7725. return client
  7726. }
  7727. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7728. // it returns an error otherwise.
  7729. func (m MsgMutation) Tx() (*Tx, error) {
  7730. if _, ok := m.driver.(*txDriver); !ok {
  7731. return nil, errors.New("ent: mutation is not running in a transaction")
  7732. }
  7733. tx := &Tx{config: m.config}
  7734. tx.init()
  7735. return tx, nil
  7736. }
  7737. // SetID sets the value of the id field. Note that this
  7738. // operation is only accepted on creation of Msg entities.
  7739. func (m *MsgMutation) SetID(id uint64) {
  7740. m.id = &id
  7741. }
  7742. // ID returns the ID value in the mutation. Note that the ID is only available
  7743. // if it was provided to the builder or after it was returned from the database.
  7744. func (m *MsgMutation) ID() (id uint64, exists bool) {
  7745. if m.id == nil {
  7746. return
  7747. }
  7748. return *m.id, true
  7749. }
  7750. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7751. // That means, if the mutation is applied within a transaction with an isolation level such
  7752. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7753. // or updated by the mutation.
  7754. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  7755. switch {
  7756. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7757. id, exists := m.ID()
  7758. if exists {
  7759. return []uint64{id}, nil
  7760. }
  7761. fallthrough
  7762. case m.op.Is(OpUpdate | OpDelete):
  7763. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  7764. default:
  7765. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7766. }
  7767. }
  7768. // SetCreatedAt sets the "created_at" field.
  7769. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  7770. m.created_at = &t
  7771. }
  7772. // CreatedAt returns the value of the "created_at" field in the mutation.
  7773. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  7774. v := m.created_at
  7775. if v == nil {
  7776. return
  7777. }
  7778. return *v, true
  7779. }
  7780. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  7781. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7783. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7784. if !m.op.Is(OpUpdateOne) {
  7785. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7786. }
  7787. if m.id == nil || m.oldValue == nil {
  7788. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7789. }
  7790. oldValue, err := m.oldValue(ctx)
  7791. if err != nil {
  7792. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7793. }
  7794. return oldValue.CreatedAt, nil
  7795. }
  7796. // ResetCreatedAt resets all changes to the "created_at" field.
  7797. func (m *MsgMutation) ResetCreatedAt() {
  7798. m.created_at = nil
  7799. }
  7800. // SetUpdatedAt sets the "updated_at" field.
  7801. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  7802. m.updated_at = &t
  7803. }
  7804. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7805. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  7806. v := m.updated_at
  7807. if v == nil {
  7808. return
  7809. }
  7810. return *v, true
  7811. }
  7812. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  7813. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7815. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7816. if !m.op.Is(OpUpdateOne) {
  7817. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7818. }
  7819. if m.id == nil || m.oldValue == nil {
  7820. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7821. }
  7822. oldValue, err := m.oldValue(ctx)
  7823. if err != nil {
  7824. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7825. }
  7826. return oldValue.UpdatedAt, nil
  7827. }
  7828. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7829. func (m *MsgMutation) ResetUpdatedAt() {
  7830. m.updated_at = nil
  7831. }
  7832. // SetDeletedAt sets the "deleted_at" field.
  7833. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  7834. m.deleted_at = &t
  7835. }
  7836. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7837. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  7838. v := m.deleted_at
  7839. if v == nil {
  7840. return
  7841. }
  7842. return *v, true
  7843. }
  7844. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  7845. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7847. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7848. if !m.op.Is(OpUpdateOne) {
  7849. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7850. }
  7851. if m.id == nil || m.oldValue == nil {
  7852. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7853. }
  7854. oldValue, err := m.oldValue(ctx)
  7855. if err != nil {
  7856. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7857. }
  7858. return oldValue.DeletedAt, nil
  7859. }
  7860. // ClearDeletedAt clears the value of the "deleted_at" field.
  7861. func (m *MsgMutation) ClearDeletedAt() {
  7862. m.deleted_at = nil
  7863. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  7864. }
  7865. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7866. func (m *MsgMutation) DeletedAtCleared() bool {
  7867. _, ok := m.clearedFields[msg.FieldDeletedAt]
  7868. return ok
  7869. }
  7870. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7871. func (m *MsgMutation) ResetDeletedAt() {
  7872. m.deleted_at = nil
  7873. delete(m.clearedFields, msg.FieldDeletedAt)
  7874. }
  7875. // SetStatus sets the "status" field.
  7876. func (m *MsgMutation) SetStatus(u uint8) {
  7877. m.status = &u
  7878. m.addstatus = nil
  7879. }
  7880. // Status returns the value of the "status" field in the mutation.
  7881. func (m *MsgMutation) Status() (r uint8, exists bool) {
  7882. v := m.status
  7883. if v == nil {
  7884. return
  7885. }
  7886. return *v, true
  7887. }
  7888. // OldStatus returns the old "status" field's value of the Msg entity.
  7889. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7891. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7892. if !m.op.Is(OpUpdateOne) {
  7893. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7894. }
  7895. if m.id == nil || m.oldValue == nil {
  7896. return v, errors.New("OldStatus requires an ID field in the mutation")
  7897. }
  7898. oldValue, err := m.oldValue(ctx)
  7899. if err != nil {
  7900. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7901. }
  7902. return oldValue.Status, nil
  7903. }
  7904. // AddStatus adds u to the "status" field.
  7905. func (m *MsgMutation) AddStatus(u int8) {
  7906. if m.addstatus != nil {
  7907. *m.addstatus += u
  7908. } else {
  7909. m.addstatus = &u
  7910. }
  7911. }
  7912. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7913. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  7914. v := m.addstatus
  7915. if v == nil {
  7916. return
  7917. }
  7918. return *v, true
  7919. }
  7920. // ClearStatus clears the value of the "status" field.
  7921. func (m *MsgMutation) ClearStatus() {
  7922. m.status = nil
  7923. m.addstatus = nil
  7924. m.clearedFields[msg.FieldStatus] = struct{}{}
  7925. }
  7926. // StatusCleared returns if the "status" field was cleared in this mutation.
  7927. func (m *MsgMutation) StatusCleared() bool {
  7928. _, ok := m.clearedFields[msg.FieldStatus]
  7929. return ok
  7930. }
  7931. // ResetStatus resets all changes to the "status" field.
  7932. func (m *MsgMutation) ResetStatus() {
  7933. m.status = nil
  7934. m.addstatus = nil
  7935. delete(m.clearedFields, msg.FieldStatus)
  7936. }
  7937. // SetFromwxid sets the "fromwxid" field.
  7938. func (m *MsgMutation) SetFromwxid(s string) {
  7939. m.fromwxid = &s
  7940. }
  7941. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  7942. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  7943. v := m.fromwxid
  7944. if v == nil {
  7945. return
  7946. }
  7947. return *v, true
  7948. }
  7949. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  7950. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7951. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7952. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  7953. if !m.op.Is(OpUpdateOne) {
  7954. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  7955. }
  7956. if m.id == nil || m.oldValue == nil {
  7957. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  7958. }
  7959. oldValue, err := m.oldValue(ctx)
  7960. if err != nil {
  7961. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  7962. }
  7963. return oldValue.Fromwxid, nil
  7964. }
  7965. // ClearFromwxid clears the value of the "fromwxid" field.
  7966. func (m *MsgMutation) ClearFromwxid() {
  7967. m.fromwxid = nil
  7968. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  7969. }
  7970. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  7971. func (m *MsgMutation) FromwxidCleared() bool {
  7972. _, ok := m.clearedFields[msg.FieldFromwxid]
  7973. return ok
  7974. }
  7975. // ResetFromwxid resets all changes to the "fromwxid" field.
  7976. func (m *MsgMutation) ResetFromwxid() {
  7977. m.fromwxid = nil
  7978. delete(m.clearedFields, msg.FieldFromwxid)
  7979. }
  7980. // SetToid sets the "toid" field.
  7981. func (m *MsgMutation) SetToid(s string) {
  7982. m.toid = &s
  7983. }
  7984. // Toid returns the value of the "toid" field in the mutation.
  7985. func (m *MsgMutation) Toid() (r string, exists bool) {
  7986. v := m.toid
  7987. if v == nil {
  7988. return
  7989. }
  7990. return *v, true
  7991. }
  7992. // OldToid returns the old "toid" field's value of the Msg entity.
  7993. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7995. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  7996. if !m.op.Is(OpUpdateOne) {
  7997. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  7998. }
  7999. if m.id == nil || m.oldValue == nil {
  8000. return v, errors.New("OldToid requires an ID field in the mutation")
  8001. }
  8002. oldValue, err := m.oldValue(ctx)
  8003. if err != nil {
  8004. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  8005. }
  8006. return oldValue.Toid, nil
  8007. }
  8008. // ClearToid clears the value of the "toid" field.
  8009. func (m *MsgMutation) ClearToid() {
  8010. m.toid = nil
  8011. m.clearedFields[msg.FieldToid] = struct{}{}
  8012. }
  8013. // ToidCleared returns if the "toid" field was cleared in this mutation.
  8014. func (m *MsgMutation) ToidCleared() bool {
  8015. _, ok := m.clearedFields[msg.FieldToid]
  8016. return ok
  8017. }
  8018. // ResetToid resets all changes to the "toid" field.
  8019. func (m *MsgMutation) ResetToid() {
  8020. m.toid = nil
  8021. delete(m.clearedFields, msg.FieldToid)
  8022. }
  8023. // SetMsgtype sets the "msgtype" field.
  8024. func (m *MsgMutation) SetMsgtype(i int32) {
  8025. m.msgtype = &i
  8026. m.addmsgtype = nil
  8027. }
  8028. // Msgtype returns the value of the "msgtype" field in the mutation.
  8029. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  8030. v := m.msgtype
  8031. if v == nil {
  8032. return
  8033. }
  8034. return *v, true
  8035. }
  8036. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  8037. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  8038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8039. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  8040. if !m.op.Is(OpUpdateOne) {
  8041. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  8042. }
  8043. if m.id == nil || m.oldValue == nil {
  8044. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  8045. }
  8046. oldValue, err := m.oldValue(ctx)
  8047. if err != nil {
  8048. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  8049. }
  8050. return oldValue.Msgtype, nil
  8051. }
  8052. // AddMsgtype adds i to the "msgtype" field.
  8053. func (m *MsgMutation) AddMsgtype(i int32) {
  8054. if m.addmsgtype != nil {
  8055. *m.addmsgtype += i
  8056. } else {
  8057. m.addmsgtype = &i
  8058. }
  8059. }
  8060. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  8061. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  8062. v := m.addmsgtype
  8063. if v == nil {
  8064. return
  8065. }
  8066. return *v, true
  8067. }
  8068. // ClearMsgtype clears the value of the "msgtype" field.
  8069. func (m *MsgMutation) ClearMsgtype() {
  8070. m.msgtype = nil
  8071. m.addmsgtype = nil
  8072. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  8073. }
  8074. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  8075. func (m *MsgMutation) MsgtypeCleared() bool {
  8076. _, ok := m.clearedFields[msg.FieldMsgtype]
  8077. return ok
  8078. }
  8079. // ResetMsgtype resets all changes to the "msgtype" field.
  8080. func (m *MsgMutation) ResetMsgtype() {
  8081. m.msgtype = nil
  8082. m.addmsgtype = nil
  8083. delete(m.clearedFields, msg.FieldMsgtype)
  8084. }
  8085. // SetMsg sets the "msg" field.
  8086. func (m *MsgMutation) SetMsg(s string) {
  8087. m.msg = &s
  8088. }
  8089. // Msg returns the value of the "msg" field in the mutation.
  8090. func (m *MsgMutation) Msg() (r string, exists bool) {
  8091. v := m.msg
  8092. if v == nil {
  8093. return
  8094. }
  8095. return *v, true
  8096. }
  8097. // OldMsg returns the old "msg" field's value of the Msg entity.
  8098. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  8099. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8100. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  8101. if !m.op.Is(OpUpdateOne) {
  8102. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  8103. }
  8104. if m.id == nil || m.oldValue == nil {
  8105. return v, errors.New("OldMsg requires an ID field in the mutation")
  8106. }
  8107. oldValue, err := m.oldValue(ctx)
  8108. if err != nil {
  8109. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  8110. }
  8111. return oldValue.Msg, nil
  8112. }
  8113. // ClearMsg clears the value of the "msg" field.
  8114. func (m *MsgMutation) ClearMsg() {
  8115. m.msg = nil
  8116. m.clearedFields[msg.FieldMsg] = struct{}{}
  8117. }
  8118. // MsgCleared returns if the "msg" field was cleared in this mutation.
  8119. func (m *MsgMutation) MsgCleared() bool {
  8120. _, ok := m.clearedFields[msg.FieldMsg]
  8121. return ok
  8122. }
  8123. // ResetMsg resets all changes to the "msg" field.
  8124. func (m *MsgMutation) ResetMsg() {
  8125. m.msg = nil
  8126. delete(m.clearedFields, msg.FieldMsg)
  8127. }
  8128. // SetBatchNo sets the "batch_no" field.
  8129. func (m *MsgMutation) SetBatchNo(s string) {
  8130. m.batch_no = &s
  8131. }
  8132. // BatchNo returns the value of the "batch_no" field in the mutation.
  8133. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  8134. v := m.batch_no
  8135. if v == nil {
  8136. return
  8137. }
  8138. return *v, true
  8139. }
  8140. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  8141. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  8142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8143. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  8144. if !m.op.Is(OpUpdateOne) {
  8145. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  8146. }
  8147. if m.id == nil || m.oldValue == nil {
  8148. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  8149. }
  8150. oldValue, err := m.oldValue(ctx)
  8151. if err != nil {
  8152. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  8153. }
  8154. return oldValue.BatchNo, nil
  8155. }
  8156. // ClearBatchNo clears the value of the "batch_no" field.
  8157. func (m *MsgMutation) ClearBatchNo() {
  8158. m.batch_no = nil
  8159. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  8160. }
  8161. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  8162. func (m *MsgMutation) BatchNoCleared() bool {
  8163. _, ok := m.clearedFields[msg.FieldBatchNo]
  8164. return ok
  8165. }
  8166. // ResetBatchNo resets all changes to the "batch_no" field.
  8167. func (m *MsgMutation) ResetBatchNo() {
  8168. m.batch_no = nil
  8169. delete(m.clearedFields, msg.FieldBatchNo)
  8170. }
  8171. // Where appends a list predicates to the MsgMutation builder.
  8172. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  8173. m.predicates = append(m.predicates, ps...)
  8174. }
  8175. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  8176. // users can use type-assertion to append predicates that do not depend on any generated package.
  8177. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  8178. p := make([]predicate.Msg, len(ps))
  8179. for i := range ps {
  8180. p[i] = ps[i]
  8181. }
  8182. m.Where(p...)
  8183. }
  8184. // Op returns the operation name.
  8185. func (m *MsgMutation) Op() Op {
  8186. return m.op
  8187. }
  8188. // SetOp allows setting the mutation operation.
  8189. func (m *MsgMutation) SetOp(op Op) {
  8190. m.op = op
  8191. }
  8192. // Type returns the node type of this mutation (Msg).
  8193. func (m *MsgMutation) Type() string {
  8194. return m.typ
  8195. }
  8196. // Fields returns all fields that were changed during this mutation. Note that in
  8197. // order to get all numeric fields that were incremented/decremented, call
  8198. // AddedFields().
  8199. func (m *MsgMutation) Fields() []string {
  8200. fields := make([]string, 0, 9)
  8201. if m.created_at != nil {
  8202. fields = append(fields, msg.FieldCreatedAt)
  8203. }
  8204. if m.updated_at != nil {
  8205. fields = append(fields, msg.FieldUpdatedAt)
  8206. }
  8207. if m.deleted_at != nil {
  8208. fields = append(fields, msg.FieldDeletedAt)
  8209. }
  8210. if m.status != nil {
  8211. fields = append(fields, msg.FieldStatus)
  8212. }
  8213. if m.fromwxid != nil {
  8214. fields = append(fields, msg.FieldFromwxid)
  8215. }
  8216. if m.toid != nil {
  8217. fields = append(fields, msg.FieldToid)
  8218. }
  8219. if m.msgtype != nil {
  8220. fields = append(fields, msg.FieldMsgtype)
  8221. }
  8222. if m.msg != nil {
  8223. fields = append(fields, msg.FieldMsg)
  8224. }
  8225. if m.batch_no != nil {
  8226. fields = append(fields, msg.FieldBatchNo)
  8227. }
  8228. return fields
  8229. }
  8230. // Field returns the value of a field with the given name. The second boolean
  8231. // return value indicates that this field was not set, or was not defined in the
  8232. // schema.
  8233. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  8234. switch name {
  8235. case msg.FieldCreatedAt:
  8236. return m.CreatedAt()
  8237. case msg.FieldUpdatedAt:
  8238. return m.UpdatedAt()
  8239. case msg.FieldDeletedAt:
  8240. return m.DeletedAt()
  8241. case msg.FieldStatus:
  8242. return m.Status()
  8243. case msg.FieldFromwxid:
  8244. return m.Fromwxid()
  8245. case msg.FieldToid:
  8246. return m.Toid()
  8247. case msg.FieldMsgtype:
  8248. return m.Msgtype()
  8249. case msg.FieldMsg:
  8250. return m.Msg()
  8251. case msg.FieldBatchNo:
  8252. return m.BatchNo()
  8253. }
  8254. return nil, false
  8255. }
  8256. // OldField returns the old value of the field from the database. An error is
  8257. // returned if the mutation operation is not UpdateOne, or the query to the
  8258. // database failed.
  8259. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8260. switch name {
  8261. case msg.FieldCreatedAt:
  8262. return m.OldCreatedAt(ctx)
  8263. case msg.FieldUpdatedAt:
  8264. return m.OldUpdatedAt(ctx)
  8265. case msg.FieldDeletedAt:
  8266. return m.OldDeletedAt(ctx)
  8267. case msg.FieldStatus:
  8268. return m.OldStatus(ctx)
  8269. case msg.FieldFromwxid:
  8270. return m.OldFromwxid(ctx)
  8271. case msg.FieldToid:
  8272. return m.OldToid(ctx)
  8273. case msg.FieldMsgtype:
  8274. return m.OldMsgtype(ctx)
  8275. case msg.FieldMsg:
  8276. return m.OldMsg(ctx)
  8277. case msg.FieldBatchNo:
  8278. return m.OldBatchNo(ctx)
  8279. }
  8280. return nil, fmt.Errorf("unknown Msg field %s", name)
  8281. }
  8282. // SetField sets the value of a field with the given name. It returns an error if
  8283. // the field is not defined in the schema, or if the type mismatched the field
  8284. // type.
  8285. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  8286. switch name {
  8287. case msg.FieldCreatedAt:
  8288. v, ok := value.(time.Time)
  8289. if !ok {
  8290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8291. }
  8292. m.SetCreatedAt(v)
  8293. return nil
  8294. case msg.FieldUpdatedAt:
  8295. v, ok := value.(time.Time)
  8296. if !ok {
  8297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8298. }
  8299. m.SetUpdatedAt(v)
  8300. return nil
  8301. case msg.FieldDeletedAt:
  8302. v, ok := value.(time.Time)
  8303. if !ok {
  8304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8305. }
  8306. m.SetDeletedAt(v)
  8307. return nil
  8308. case msg.FieldStatus:
  8309. v, ok := value.(uint8)
  8310. if !ok {
  8311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8312. }
  8313. m.SetStatus(v)
  8314. return nil
  8315. case msg.FieldFromwxid:
  8316. v, ok := value.(string)
  8317. if !ok {
  8318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8319. }
  8320. m.SetFromwxid(v)
  8321. return nil
  8322. case msg.FieldToid:
  8323. v, ok := value.(string)
  8324. if !ok {
  8325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8326. }
  8327. m.SetToid(v)
  8328. return nil
  8329. case msg.FieldMsgtype:
  8330. v, ok := value.(int32)
  8331. if !ok {
  8332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8333. }
  8334. m.SetMsgtype(v)
  8335. return nil
  8336. case msg.FieldMsg:
  8337. v, ok := value.(string)
  8338. if !ok {
  8339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8340. }
  8341. m.SetMsg(v)
  8342. return nil
  8343. case msg.FieldBatchNo:
  8344. v, ok := value.(string)
  8345. if !ok {
  8346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8347. }
  8348. m.SetBatchNo(v)
  8349. return nil
  8350. }
  8351. return fmt.Errorf("unknown Msg field %s", name)
  8352. }
  8353. // AddedFields returns all numeric fields that were incremented/decremented during
  8354. // this mutation.
  8355. func (m *MsgMutation) AddedFields() []string {
  8356. var fields []string
  8357. if m.addstatus != nil {
  8358. fields = append(fields, msg.FieldStatus)
  8359. }
  8360. if m.addmsgtype != nil {
  8361. fields = append(fields, msg.FieldMsgtype)
  8362. }
  8363. return fields
  8364. }
  8365. // AddedField returns the numeric value that was incremented/decremented on a field
  8366. // with the given name. The second boolean return value indicates that this field
  8367. // was not set, or was not defined in the schema.
  8368. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  8369. switch name {
  8370. case msg.FieldStatus:
  8371. return m.AddedStatus()
  8372. case msg.FieldMsgtype:
  8373. return m.AddedMsgtype()
  8374. }
  8375. return nil, false
  8376. }
  8377. // AddField adds the value to the field with the given name. It returns an error if
  8378. // the field is not defined in the schema, or if the type mismatched the field
  8379. // type.
  8380. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  8381. switch name {
  8382. case msg.FieldStatus:
  8383. v, ok := value.(int8)
  8384. if !ok {
  8385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8386. }
  8387. m.AddStatus(v)
  8388. return nil
  8389. case msg.FieldMsgtype:
  8390. v, ok := value.(int32)
  8391. if !ok {
  8392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8393. }
  8394. m.AddMsgtype(v)
  8395. return nil
  8396. }
  8397. return fmt.Errorf("unknown Msg numeric field %s", name)
  8398. }
  8399. // ClearedFields returns all nullable fields that were cleared during this
  8400. // mutation.
  8401. func (m *MsgMutation) ClearedFields() []string {
  8402. var fields []string
  8403. if m.FieldCleared(msg.FieldDeletedAt) {
  8404. fields = append(fields, msg.FieldDeletedAt)
  8405. }
  8406. if m.FieldCleared(msg.FieldStatus) {
  8407. fields = append(fields, msg.FieldStatus)
  8408. }
  8409. if m.FieldCleared(msg.FieldFromwxid) {
  8410. fields = append(fields, msg.FieldFromwxid)
  8411. }
  8412. if m.FieldCleared(msg.FieldToid) {
  8413. fields = append(fields, msg.FieldToid)
  8414. }
  8415. if m.FieldCleared(msg.FieldMsgtype) {
  8416. fields = append(fields, msg.FieldMsgtype)
  8417. }
  8418. if m.FieldCleared(msg.FieldMsg) {
  8419. fields = append(fields, msg.FieldMsg)
  8420. }
  8421. if m.FieldCleared(msg.FieldBatchNo) {
  8422. fields = append(fields, msg.FieldBatchNo)
  8423. }
  8424. return fields
  8425. }
  8426. // FieldCleared returns a boolean indicating if a field with the given name was
  8427. // cleared in this mutation.
  8428. func (m *MsgMutation) FieldCleared(name string) bool {
  8429. _, ok := m.clearedFields[name]
  8430. return ok
  8431. }
  8432. // ClearField clears the value of the field with the given name. It returns an
  8433. // error if the field is not defined in the schema.
  8434. func (m *MsgMutation) ClearField(name string) error {
  8435. switch name {
  8436. case msg.FieldDeletedAt:
  8437. m.ClearDeletedAt()
  8438. return nil
  8439. case msg.FieldStatus:
  8440. m.ClearStatus()
  8441. return nil
  8442. case msg.FieldFromwxid:
  8443. m.ClearFromwxid()
  8444. return nil
  8445. case msg.FieldToid:
  8446. m.ClearToid()
  8447. return nil
  8448. case msg.FieldMsgtype:
  8449. m.ClearMsgtype()
  8450. return nil
  8451. case msg.FieldMsg:
  8452. m.ClearMsg()
  8453. return nil
  8454. case msg.FieldBatchNo:
  8455. m.ClearBatchNo()
  8456. return nil
  8457. }
  8458. return fmt.Errorf("unknown Msg nullable field %s", name)
  8459. }
  8460. // ResetField resets all changes in the mutation for the field with the given name.
  8461. // It returns an error if the field is not defined in the schema.
  8462. func (m *MsgMutation) ResetField(name string) error {
  8463. switch name {
  8464. case msg.FieldCreatedAt:
  8465. m.ResetCreatedAt()
  8466. return nil
  8467. case msg.FieldUpdatedAt:
  8468. m.ResetUpdatedAt()
  8469. return nil
  8470. case msg.FieldDeletedAt:
  8471. m.ResetDeletedAt()
  8472. return nil
  8473. case msg.FieldStatus:
  8474. m.ResetStatus()
  8475. return nil
  8476. case msg.FieldFromwxid:
  8477. m.ResetFromwxid()
  8478. return nil
  8479. case msg.FieldToid:
  8480. m.ResetToid()
  8481. return nil
  8482. case msg.FieldMsgtype:
  8483. m.ResetMsgtype()
  8484. return nil
  8485. case msg.FieldMsg:
  8486. m.ResetMsg()
  8487. return nil
  8488. case msg.FieldBatchNo:
  8489. m.ResetBatchNo()
  8490. return nil
  8491. }
  8492. return fmt.Errorf("unknown Msg field %s", name)
  8493. }
  8494. // AddedEdges returns all edge names that were set/added in this mutation.
  8495. func (m *MsgMutation) AddedEdges() []string {
  8496. edges := make([]string, 0, 0)
  8497. return edges
  8498. }
  8499. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8500. // name in this mutation.
  8501. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  8502. return nil
  8503. }
  8504. // RemovedEdges returns all edge names that were removed in this mutation.
  8505. func (m *MsgMutation) RemovedEdges() []string {
  8506. edges := make([]string, 0, 0)
  8507. return edges
  8508. }
  8509. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8510. // the given name in this mutation.
  8511. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  8512. return nil
  8513. }
  8514. // ClearedEdges returns all edge names that were cleared in this mutation.
  8515. func (m *MsgMutation) ClearedEdges() []string {
  8516. edges := make([]string, 0, 0)
  8517. return edges
  8518. }
  8519. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8520. // was cleared in this mutation.
  8521. func (m *MsgMutation) EdgeCleared(name string) bool {
  8522. return false
  8523. }
  8524. // ClearEdge clears the value of the edge with the given name. It returns an error
  8525. // if that edge is not defined in the schema.
  8526. func (m *MsgMutation) ClearEdge(name string) error {
  8527. return fmt.Errorf("unknown Msg unique edge %s", name)
  8528. }
  8529. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8530. // It returns an error if the edge is not defined in the schema.
  8531. func (m *MsgMutation) ResetEdge(name string) error {
  8532. return fmt.Errorf("unknown Msg edge %s", name)
  8533. }
  8534. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  8535. type ServerMutation struct {
  8536. config
  8537. op Op
  8538. typ string
  8539. id *uint64
  8540. created_at *time.Time
  8541. updated_at *time.Time
  8542. status *uint8
  8543. addstatus *int8
  8544. deleted_at *time.Time
  8545. name *string
  8546. public_ip *string
  8547. private_ip *string
  8548. admin_port *string
  8549. clearedFields map[string]struct{}
  8550. wxs map[uint64]struct{}
  8551. removedwxs map[uint64]struct{}
  8552. clearedwxs bool
  8553. done bool
  8554. oldValue func(context.Context) (*Server, error)
  8555. predicates []predicate.Server
  8556. }
  8557. var _ ent.Mutation = (*ServerMutation)(nil)
  8558. // serverOption allows management of the mutation configuration using functional options.
  8559. type serverOption func(*ServerMutation)
  8560. // newServerMutation creates new mutation for the Server entity.
  8561. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  8562. m := &ServerMutation{
  8563. config: c,
  8564. op: op,
  8565. typ: TypeServer,
  8566. clearedFields: make(map[string]struct{}),
  8567. }
  8568. for _, opt := range opts {
  8569. opt(m)
  8570. }
  8571. return m
  8572. }
  8573. // withServerID sets the ID field of the mutation.
  8574. func withServerID(id uint64) serverOption {
  8575. return func(m *ServerMutation) {
  8576. var (
  8577. err error
  8578. once sync.Once
  8579. value *Server
  8580. )
  8581. m.oldValue = func(ctx context.Context) (*Server, error) {
  8582. once.Do(func() {
  8583. if m.done {
  8584. err = errors.New("querying old values post mutation is not allowed")
  8585. } else {
  8586. value, err = m.Client().Server.Get(ctx, id)
  8587. }
  8588. })
  8589. return value, err
  8590. }
  8591. m.id = &id
  8592. }
  8593. }
  8594. // withServer sets the old Server of the mutation.
  8595. func withServer(node *Server) serverOption {
  8596. return func(m *ServerMutation) {
  8597. m.oldValue = func(context.Context) (*Server, error) {
  8598. return node, nil
  8599. }
  8600. m.id = &node.ID
  8601. }
  8602. }
  8603. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8604. // executed in a transaction (ent.Tx), a transactional client is returned.
  8605. func (m ServerMutation) Client() *Client {
  8606. client := &Client{config: m.config}
  8607. client.init()
  8608. return client
  8609. }
  8610. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8611. // it returns an error otherwise.
  8612. func (m ServerMutation) Tx() (*Tx, error) {
  8613. if _, ok := m.driver.(*txDriver); !ok {
  8614. return nil, errors.New("ent: mutation is not running in a transaction")
  8615. }
  8616. tx := &Tx{config: m.config}
  8617. tx.init()
  8618. return tx, nil
  8619. }
  8620. // SetID sets the value of the id field. Note that this
  8621. // operation is only accepted on creation of Server entities.
  8622. func (m *ServerMutation) SetID(id uint64) {
  8623. m.id = &id
  8624. }
  8625. // ID returns the ID value in the mutation. Note that the ID is only available
  8626. // if it was provided to the builder or after it was returned from the database.
  8627. func (m *ServerMutation) ID() (id uint64, exists bool) {
  8628. if m.id == nil {
  8629. return
  8630. }
  8631. return *m.id, true
  8632. }
  8633. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8634. // That means, if the mutation is applied within a transaction with an isolation level such
  8635. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8636. // or updated by the mutation.
  8637. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  8638. switch {
  8639. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8640. id, exists := m.ID()
  8641. if exists {
  8642. return []uint64{id}, nil
  8643. }
  8644. fallthrough
  8645. case m.op.Is(OpUpdate | OpDelete):
  8646. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  8647. default:
  8648. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8649. }
  8650. }
  8651. // SetCreatedAt sets the "created_at" field.
  8652. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  8653. m.created_at = &t
  8654. }
  8655. // CreatedAt returns the value of the "created_at" field in the mutation.
  8656. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  8657. v := m.created_at
  8658. if v == nil {
  8659. return
  8660. }
  8661. return *v, true
  8662. }
  8663. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  8664. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8666. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8667. if !m.op.Is(OpUpdateOne) {
  8668. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8669. }
  8670. if m.id == nil || m.oldValue == nil {
  8671. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8672. }
  8673. oldValue, err := m.oldValue(ctx)
  8674. if err != nil {
  8675. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8676. }
  8677. return oldValue.CreatedAt, nil
  8678. }
  8679. // ResetCreatedAt resets all changes to the "created_at" field.
  8680. func (m *ServerMutation) ResetCreatedAt() {
  8681. m.created_at = nil
  8682. }
  8683. // SetUpdatedAt sets the "updated_at" field.
  8684. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  8685. m.updated_at = &t
  8686. }
  8687. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8688. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  8689. v := m.updated_at
  8690. if v == nil {
  8691. return
  8692. }
  8693. return *v, true
  8694. }
  8695. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  8696. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8698. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8699. if !m.op.Is(OpUpdateOne) {
  8700. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8701. }
  8702. if m.id == nil || m.oldValue == nil {
  8703. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8704. }
  8705. oldValue, err := m.oldValue(ctx)
  8706. if err != nil {
  8707. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8708. }
  8709. return oldValue.UpdatedAt, nil
  8710. }
  8711. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8712. func (m *ServerMutation) ResetUpdatedAt() {
  8713. m.updated_at = nil
  8714. }
  8715. // SetStatus sets the "status" field.
  8716. func (m *ServerMutation) SetStatus(u uint8) {
  8717. m.status = &u
  8718. m.addstatus = nil
  8719. }
  8720. // Status returns the value of the "status" field in the mutation.
  8721. func (m *ServerMutation) Status() (r uint8, exists bool) {
  8722. v := m.status
  8723. if v == nil {
  8724. return
  8725. }
  8726. return *v, true
  8727. }
  8728. // OldStatus returns the old "status" field's value of the Server entity.
  8729. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8731. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  8732. if !m.op.Is(OpUpdateOne) {
  8733. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  8734. }
  8735. if m.id == nil || m.oldValue == nil {
  8736. return v, errors.New("OldStatus requires an ID field in the mutation")
  8737. }
  8738. oldValue, err := m.oldValue(ctx)
  8739. if err != nil {
  8740. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  8741. }
  8742. return oldValue.Status, nil
  8743. }
  8744. // AddStatus adds u to the "status" field.
  8745. func (m *ServerMutation) AddStatus(u int8) {
  8746. if m.addstatus != nil {
  8747. *m.addstatus += u
  8748. } else {
  8749. m.addstatus = &u
  8750. }
  8751. }
  8752. // AddedStatus returns the value that was added to the "status" field in this mutation.
  8753. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  8754. v := m.addstatus
  8755. if v == nil {
  8756. return
  8757. }
  8758. return *v, true
  8759. }
  8760. // ClearStatus clears the value of the "status" field.
  8761. func (m *ServerMutation) ClearStatus() {
  8762. m.status = nil
  8763. m.addstatus = nil
  8764. m.clearedFields[server.FieldStatus] = struct{}{}
  8765. }
  8766. // StatusCleared returns if the "status" field was cleared in this mutation.
  8767. func (m *ServerMutation) StatusCleared() bool {
  8768. _, ok := m.clearedFields[server.FieldStatus]
  8769. return ok
  8770. }
  8771. // ResetStatus resets all changes to the "status" field.
  8772. func (m *ServerMutation) ResetStatus() {
  8773. m.status = nil
  8774. m.addstatus = nil
  8775. delete(m.clearedFields, server.FieldStatus)
  8776. }
  8777. // SetDeletedAt sets the "deleted_at" field.
  8778. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  8779. m.deleted_at = &t
  8780. }
  8781. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8782. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  8783. v := m.deleted_at
  8784. if v == nil {
  8785. return
  8786. }
  8787. return *v, true
  8788. }
  8789. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  8790. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8791. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8792. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8793. if !m.op.Is(OpUpdateOne) {
  8794. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8795. }
  8796. if m.id == nil || m.oldValue == nil {
  8797. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8798. }
  8799. oldValue, err := m.oldValue(ctx)
  8800. if err != nil {
  8801. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8802. }
  8803. return oldValue.DeletedAt, nil
  8804. }
  8805. // ClearDeletedAt clears the value of the "deleted_at" field.
  8806. func (m *ServerMutation) ClearDeletedAt() {
  8807. m.deleted_at = nil
  8808. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  8809. }
  8810. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8811. func (m *ServerMutation) DeletedAtCleared() bool {
  8812. _, ok := m.clearedFields[server.FieldDeletedAt]
  8813. return ok
  8814. }
  8815. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8816. func (m *ServerMutation) ResetDeletedAt() {
  8817. m.deleted_at = nil
  8818. delete(m.clearedFields, server.FieldDeletedAt)
  8819. }
  8820. // SetName sets the "name" field.
  8821. func (m *ServerMutation) SetName(s string) {
  8822. m.name = &s
  8823. }
  8824. // Name returns the value of the "name" field in the mutation.
  8825. func (m *ServerMutation) Name() (r string, exists bool) {
  8826. v := m.name
  8827. if v == nil {
  8828. return
  8829. }
  8830. return *v, true
  8831. }
  8832. // OldName returns the old "name" field's value of the Server entity.
  8833. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8835. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  8836. if !m.op.Is(OpUpdateOne) {
  8837. return v, errors.New("OldName is only allowed on UpdateOne operations")
  8838. }
  8839. if m.id == nil || m.oldValue == nil {
  8840. return v, errors.New("OldName requires an ID field in the mutation")
  8841. }
  8842. oldValue, err := m.oldValue(ctx)
  8843. if err != nil {
  8844. return v, fmt.Errorf("querying old value for OldName: %w", err)
  8845. }
  8846. return oldValue.Name, nil
  8847. }
  8848. // ResetName resets all changes to the "name" field.
  8849. func (m *ServerMutation) ResetName() {
  8850. m.name = nil
  8851. }
  8852. // SetPublicIP sets the "public_ip" field.
  8853. func (m *ServerMutation) SetPublicIP(s string) {
  8854. m.public_ip = &s
  8855. }
  8856. // PublicIP returns the value of the "public_ip" field in the mutation.
  8857. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  8858. v := m.public_ip
  8859. if v == nil {
  8860. return
  8861. }
  8862. return *v, true
  8863. }
  8864. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  8865. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8867. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  8868. if !m.op.Is(OpUpdateOne) {
  8869. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  8870. }
  8871. if m.id == nil || m.oldValue == nil {
  8872. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  8873. }
  8874. oldValue, err := m.oldValue(ctx)
  8875. if err != nil {
  8876. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  8877. }
  8878. return oldValue.PublicIP, nil
  8879. }
  8880. // ResetPublicIP resets all changes to the "public_ip" field.
  8881. func (m *ServerMutation) ResetPublicIP() {
  8882. m.public_ip = nil
  8883. }
  8884. // SetPrivateIP sets the "private_ip" field.
  8885. func (m *ServerMutation) SetPrivateIP(s string) {
  8886. m.private_ip = &s
  8887. }
  8888. // PrivateIP returns the value of the "private_ip" field in the mutation.
  8889. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  8890. v := m.private_ip
  8891. if v == nil {
  8892. return
  8893. }
  8894. return *v, true
  8895. }
  8896. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  8897. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8898. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8899. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  8900. if !m.op.Is(OpUpdateOne) {
  8901. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  8902. }
  8903. if m.id == nil || m.oldValue == nil {
  8904. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  8905. }
  8906. oldValue, err := m.oldValue(ctx)
  8907. if err != nil {
  8908. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  8909. }
  8910. return oldValue.PrivateIP, nil
  8911. }
  8912. // ResetPrivateIP resets all changes to the "private_ip" field.
  8913. func (m *ServerMutation) ResetPrivateIP() {
  8914. m.private_ip = nil
  8915. }
  8916. // SetAdminPort sets the "admin_port" field.
  8917. func (m *ServerMutation) SetAdminPort(s string) {
  8918. m.admin_port = &s
  8919. }
  8920. // AdminPort returns the value of the "admin_port" field in the mutation.
  8921. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  8922. v := m.admin_port
  8923. if v == nil {
  8924. return
  8925. }
  8926. return *v, true
  8927. }
  8928. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  8929. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8931. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  8932. if !m.op.Is(OpUpdateOne) {
  8933. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  8934. }
  8935. if m.id == nil || m.oldValue == nil {
  8936. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  8937. }
  8938. oldValue, err := m.oldValue(ctx)
  8939. if err != nil {
  8940. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  8941. }
  8942. return oldValue.AdminPort, nil
  8943. }
  8944. // ResetAdminPort resets all changes to the "admin_port" field.
  8945. func (m *ServerMutation) ResetAdminPort() {
  8946. m.admin_port = nil
  8947. }
  8948. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  8949. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  8950. if m.wxs == nil {
  8951. m.wxs = make(map[uint64]struct{})
  8952. }
  8953. for i := range ids {
  8954. m.wxs[ids[i]] = struct{}{}
  8955. }
  8956. }
  8957. // ClearWxs clears the "wxs" edge to the Wx entity.
  8958. func (m *ServerMutation) ClearWxs() {
  8959. m.clearedwxs = true
  8960. }
  8961. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  8962. func (m *ServerMutation) WxsCleared() bool {
  8963. return m.clearedwxs
  8964. }
  8965. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  8966. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  8967. if m.removedwxs == nil {
  8968. m.removedwxs = make(map[uint64]struct{})
  8969. }
  8970. for i := range ids {
  8971. delete(m.wxs, ids[i])
  8972. m.removedwxs[ids[i]] = struct{}{}
  8973. }
  8974. }
  8975. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  8976. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  8977. for id := range m.removedwxs {
  8978. ids = append(ids, id)
  8979. }
  8980. return
  8981. }
  8982. // WxsIDs returns the "wxs" edge IDs in the mutation.
  8983. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  8984. for id := range m.wxs {
  8985. ids = append(ids, id)
  8986. }
  8987. return
  8988. }
  8989. // ResetWxs resets all changes to the "wxs" edge.
  8990. func (m *ServerMutation) ResetWxs() {
  8991. m.wxs = nil
  8992. m.clearedwxs = false
  8993. m.removedwxs = nil
  8994. }
  8995. // Where appends a list predicates to the ServerMutation builder.
  8996. func (m *ServerMutation) Where(ps ...predicate.Server) {
  8997. m.predicates = append(m.predicates, ps...)
  8998. }
  8999. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  9000. // users can use type-assertion to append predicates that do not depend on any generated package.
  9001. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  9002. p := make([]predicate.Server, len(ps))
  9003. for i := range ps {
  9004. p[i] = ps[i]
  9005. }
  9006. m.Where(p...)
  9007. }
  9008. // Op returns the operation name.
  9009. func (m *ServerMutation) Op() Op {
  9010. return m.op
  9011. }
  9012. // SetOp allows setting the mutation operation.
  9013. func (m *ServerMutation) SetOp(op Op) {
  9014. m.op = op
  9015. }
  9016. // Type returns the node type of this mutation (Server).
  9017. func (m *ServerMutation) Type() string {
  9018. return m.typ
  9019. }
  9020. // Fields returns all fields that were changed during this mutation. Note that in
  9021. // order to get all numeric fields that were incremented/decremented, call
  9022. // AddedFields().
  9023. func (m *ServerMutation) Fields() []string {
  9024. fields := make([]string, 0, 8)
  9025. if m.created_at != nil {
  9026. fields = append(fields, server.FieldCreatedAt)
  9027. }
  9028. if m.updated_at != nil {
  9029. fields = append(fields, server.FieldUpdatedAt)
  9030. }
  9031. if m.status != nil {
  9032. fields = append(fields, server.FieldStatus)
  9033. }
  9034. if m.deleted_at != nil {
  9035. fields = append(fields, server.FieldDeletedAt)
  9036. }
  9037. if m.name != nil {
  9038. fields = append(fields, server.FieldName)
  9039. }
  9040. if m.public_ip != nil {
  9041. fields = append(fields, server.FieldPublicIP)
  9042. }
  9043. if m.private_ip != nil {
  9044. fields = append(fields, server.FieldPrivateIP)
  9045. }
  9046. if m.admin_port != nil {
  9047. fields = append(fields, server.FieldAdminPort)
  9048. }
  9049. return fields
  9050. }
  9051. // Field returns the value of a field with the given name. The second boolean
  9052. // return value indicates that this field was not set, or was not defined in the
  9053. // schema.
  9054. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  9055. switch name {
  9056. case server.FieldCreatedAt:
  9057. return m.CreatedAt()
  9058. case server.FieldUpdatedAt:
  9059. return m.UpdatedAt()
  9060. case server.FieldStatus:
  9061. return m.Status()
  9062. case server.FieldDeletedAt:
  9063. return m.DeletedAt()
  9064. case server.FieldName:
  9065. return m.Name()
  9066. case server.FieldPublicIP:
  9067. return m.PublicIP()
  9068. case server.FieldPrivateIP:
  9069. return m.PrivateIP()
  9070. case server.FieldAdminPort:
  9071. return m.AdminPort()
  9072. }
  9073. return nil, false
  9074. }
  9075. // OldField returns the old value of the field from the database. An error is
  9076. // returned if the mutation operation is not UpdateOne, or the query to the
  9077. // database failed.
  9078. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9079. switch name {
  9080. case server.FieldCreatedAt:
  9081. return m.OldCreatedAt(ctx)
  9082. case server.FieldUpdatedAt:
  9083. return m.OldUpdatedAt(ctx)
  9084. case server.FieldStatus:
  9085. return m.OldStatus(ctx)
  9086. case server.FieldDeletedAt:
  9087. return m.OldDeletedAt(ctx)
  9088. case server.FieldName:
  9089. return m.OldName(ctx)
  9090. case server.FieldPublicIP:
  9091. return m.OldPublicIP(ctx)
  9092. case server.FieldPrivateIP:
  9093. return m.OldPrivateIP(ctx)
  9094. case server.FieldAdminPort:
  9095. return m.OldAdminPort(ctx)
  9096. }
  9097. return nil, fmt.Errorf("unknown Server field %s", name)
  9098. }
  9099. // SetField sets the value of a field with the given name. It returns an error if
  9100. // the field is not defined in the schema, or if the type mismatched the field
  9101. // type.
  9102. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  9103. switch name {
  9104. case server.FieldCreatedAt:
  9105. v, ok := value.(time.Time)
  9106. if !ok {
  9107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9108. }
  9109. m.SetCreatedAt(v)
  9110. return nil
  9111. case server.FieldUpdatedAt:
  9112. v, ok := value.(time.Time)
  9113. if !ok {
  9114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9115. }
  9116. m.SetUpdatedAt(v)
  9117. return nil
  9118. case server.FieldStatus:
  9119. v, ok := value.(uint8)
  9120. if !ok {
  9121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9122. }
  9123. m.SetStatus(v)
  9124. return nil
  9125. case server.FieldDeletedAt:
  9126. v, ok := value.(time.Time)
  9127. if !ok {
  9128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9129. }
  9130. m.SetDeletedAt(v)
  9131. return nil
  9132. case server.FieldName:
  9133. v, ok := value.(string)
  9134. if !ok {
  9135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9136. }
  9137. m.SetName(v)
  9138. return nil
  9139. case server.FieldPublicIP:
  9140. v, ok := value.(string)
  9141. if !ok {
  9142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9143. }
  9144. m.SetPublicIP(v)
  9145. return nil
  9146. case server.FieldPrivateIP:
  9147. v, ok := value.(string)
  9148. if !ok {
  9149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9150. }
  9151. m.SetPrivateIP(v)
  9152. return nil
  9153. case server.FieldAdminPort:
  9154. v, ok := value.(string)
  9155. if !ok {
  9156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9157. }
  9158. m.SetAdminPort(v)
  9159. return nil
  9160. }
  9161. return fmt.Errorf("unknown Server field %s", name)
  9162. }
  9163. // AddedFields returns all numeric fields that were incremented/decremented during
  9164. // this mutation.
  9165. func (m *ServerMutation) AddedFields() []string {
  9166. var fields []string
  9167. if m.addstatus != nil {
  9168. fields = append(fields, server.FieldStatus)
  9169. }
  9170. return fields
  9171. }
  9172. // AddedField returns the numeric value that was incremented/decremented on a field
  9173. // with the given name. The second boolean return value indicates that this field
  9174. // was not set, or was not defined in the schema.
  9175. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  9176. switch name {
  9177. case server.FieldStatus:
  9178. return m.AddedStatus()
  9179. }
  9180. return nil, false
  9181. }
  9182. // AddField adds the value to the field with the given name. It returns an error if
  9183. // the field is not defined in the schema, or if the type mismatched the field
  9184. // type.
  9185. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  9186. switch name {
  9187. case server.FieldStatus:
  9188. v, ok := value.(int8)
  9189. if !ok {
  9190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9191. }
  9192. m.AddStatus(v)
  9193. return nil
  9194. }
  9195. return fmt.Errorf("unknown Server numeric field %s", name)
  9196. }
  9197. // ClearedFields returns all nullable fields that were cleared during this
  9198. // mutation.
  9199. func (m *ServerMutation) ClearedFields() []string {
  9200. var fields []string
  9201. if m.FieldCleared(server.FieldStatus) {
  9202. fields = append(fields, server.FieldStatus)
  9203. }
  9204. if m.FieldCleared(server.FieldDeletedAt) {
  9205. fields = append(fields, server.FieldDeletedAt)
  9206. }
  9207. return fields
  9208. }
  9209. // FieldCleared returns a boolean indicating if a field with the given name was
  9210. // cleared in this mutation.
  9211. func (m *ServerMutation) FieldCleared(name string) bool {
  9212. _, ok := m.clearedFields[name]
  9213. return ok
  9214. }
  9215. // ClearField clears the value of the field with the given name. It returns an
  9216. // error if the field is not defined in the schema.
  9217. func (m *ServerMutation) ClearField(name string) error {
  9218. switch name {
  9219. case server.FieldStatus:
  9220. m.ClearStatus()
  9221. return nil
  9222. case server.FieldDeletedAt:
  9223. m.ClearDeletedAt()
  9224. return nil
  9225. }
  9226. return fmt.Errorf("unknown Server nullable field %s", name)
  9227. }
  9228. // ResetField resets all changes in the mutation for the field with the given name.
  9229. // It returns an error if the field is not defined in the schema.
  9230. func (m *ServerMutation) ResetField(name string) error {
  9231. switch name {
  9232. case server.FieldCreatedAt:
  9233. m.ResetCreatedAt()
  9234. return nil
  9235. case server.FieldUpdatedAt:
  9236. m.ResetUpdatedAt()
  9237. return nil
  9238. case server.FieldStatus:
  9239. m.ResetStatus()
  9240. return nil
  9241. case server.FieldDeletedAt:
  9242. m.ResetDeletedAt()
  9243. return nil
  9244. case server.FieldName:
  9245. m.ResetName()
  9246. return nil
  9247. case server.FieldPublicIP:
  9248. m.ResetPublicIP()
  9249. return nil
  9250. case server.FieldPrivateIP:
  9251. m.ResetPrivateIP()
  9252. return nil
  9253. case server.FieldAdminPort:
  9254. m.ResetAdminPort()
  9255. return nil
  9256. }
  9257. return fmt.Errorf("unknown Server field %s", name)
  9258. }
  9259. // AddedEdges returns all edge names that were set/added in this mutation.
  9260. func (m *ServerMutation) AddedEdges() []string {
  9261. edges := make([]string, 0, 1)
  9262. if m.wxs != nil {
  9263. edges = append(edges, server.EdgeWxs)
  9264. }
  9265. return edges
  9266. }
  9267. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9268. // name in this mutation.
  9269. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  9270. switch name {
  9271. case server.EdgeWxs:
  9272. ids := make([]ent.Value, 0, len(m.wxs))
  9273. for id := range m.wxs {
  9274. ids = append(ids, id)
  9275. }
  9276. return ids
  9277. }
  9278. return nil
  9279. }
  9280. // RemovedEdges returns all edge names that were removed in this mutation.
  9281. func (m *ServerMutation) RemovedEdges() []string {
  9282. edges := make([]string, 0, 1)
  9283. if m.removedwxs != nil {
  9284. edges = append(edges, server.EdgeWxs)
  9285. }
  9286. return edges
  9287. }
  9288. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9289. // the given name in this mutation.
  9290. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  9291. switch name {
  9292. case server.EdgeWxs:
  9293. ids := make([]ent.Value, 0, len(m.removedwxs))
  9294. for id := range m.removedwxs {
  9295. ids = append(ids, id)
  9296. }
  9297. return ids
  9298. }
  9299. return nil
  9300. }
  9301. // ClearedEdges returns all edge names that were cleared in this mutation.
  9302. func (m *ServerMutation) ClearedEdges() []string {
  9303. edges := make([]string, 0, 1)
  9304. if m.clearedwxs {
  9305. edges = append(edges, server.EdgeWxs)
  9306. }
  9307. return edges
  9308. }
  9309. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9310. // was cleared in this mutation.
  9311. func (m *ServerMutation) EdgeCleared(name string) bool {
  9312. switch name {
  9313. case server.EdgeWxs:
  9314. return m.clearedwxs
  9315. }
  9316. return false
  9317. }
  9318. // ClearEdge clears the value of the edge with the given name. It returns an error
  9319. // if that edge is not defined in the schema.
  9320. func (m *ServerMutation) ClearEdge(name string) error {
  9321. switch name {
  9322. }
  9323. return fmt.Errorf("unknown Server unique edge %s", name)
  9324. }
  9325. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9326. // It returns an error if the edge is not defined in the schema.
  9327. func (m *ServerMutation) ResetEdge(name string) error {
  9328. switch name {
  9329. case server.EdgeWxs:
  9330. m.ResetWxs()
  9331. return nil
  9332. }
  9333. return fmt.Errorf("unknown Server edge %s", name)
  9334. }
  9335. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  9336. type SopNodeMutation struct {
  9337. config
  9338. op Op
  9339. typ string
  9340. id *uint64
  9341. created_at *time.Time
  9342. updated_at *time.Time
  9343. status *uint8
  9344. addstatus *int8
  9345. deleted_at *time.Time
  9346. parent_id *uint64
  9347. addparent_id *int64
  9348. name *string
  9349. condition_type *int
  9350. addcondition_type *int
  9351. condition_list *[]string
  9352. appendcondition_list []string
  9353. no_reply_condition *uint64
  9354. addno_reply_condition *int64
  9355. action_message *[]custom_types.Action
  9356. appendaction_message []custom_types.Action
  9357. action_label *[]uint64
  9358. appendaction_label []uint64
  9359. clearedFields map[string]struct{}
  9360. sop_stage *uint64
  9361. clearedsop_stage bool
  9362. node_messages map[uint64]struct{}
  9363. removednode_messages map[uint64]struct{}
  9364. clearednode_messages bool
  9365. done bool
  9366. oldValue func(context.Context) (*SopNode, error)
  9367. predicates []predicate.SopNode
  9368. }
  9369. var _ ent.Mutation = (*SopNodeMutation)(nil)
  9370. // sopnodeOption allows management of the mutation configuration using functional options.
  9371. type sopnodeOption func(*SopNodeMutation)
  9372. // newSopNodeMutation creates new mutation for the SopNode entity.
  9373. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  9374. m := &SopNodeMutation{
  9375. config: c,
  9376. op: op,
  9377. typ: TypeSopNode,
  9378. clearedFields: make(map[string]struct{}),
  9379. }
  9380. for _, opt := range opts {
  9381. opt(m)
  9382. }
  9383. return m
  9384. }
  9385. // withSopNodeID sets the ID field of the mutation.
  9386. func withSopNodeID(id uint64) sopnodeOption {
  9387. return func(m *SopNodeMutation) {
  9388. var (
  9389. err error
  9390. once sync.Once
  9391. value *SopNode
  9392. )
  9393. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  9394. once.Do(func() {
  9395. if m.done {
  9396. err = errors.New("querying old values post mutation is not allowed")
  9397. } else {
  9398. value, err = m.Client().SopNode.Get(ctx, id)
  9399. }
  9400. })
  9401. return value, err
  9402. }
  9403. m.id = &id
  9404. }
  9405. }
  9406. // withSopNode sets the old SopNode of the mutation.
  9407. func withSopNode(node *SopNode) sopnodeOption {
  9408. return func(m *SopNodeMutation) {
  9409. m.oldValue = func(context.Context) (*SopNode, error) {
  9410. return node, nil
  9411. }
  9412. m.id = &node.ID
  9413. }
  9414. }
  9415. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9416. // executed in a transaction (ent.Tx), a transactional client is returned.
  9417. func (m SopNodeMutation) Client() *Client {
  9418. client := &Client{config: m.config}
  9419. client.init()
  9420. return client
  9421. }
  9422. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9423. // it returns an error otherwise.
  9424. func (m SopNodeMutation) Tx() (*Tx, error) {
  9425. if _, ok := m.driver.(*txDriver); !ok {
  9426. return nil, errors.New("ent: mutation is not running in a transaction")
  9427. }
  9428. tx := &Tx{config: m.config}
  9429. tx.init()
  9430. return tx, nil
  9431. }
  9432. // SetID sets the value of the id field. Note that this
  9433. // operation is only accepted on creation of SopNode entities.
  9434. func (m *SopNodeMutation) SetID(id uint64) {
  9435. m.id = &id
  9436. }
  9437. // ID returns the ID value in the mutation. Note that the ID is only available
  9438. // if it was provided to the builder or after it was returned from the database.
  9439. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  9440. if m.id == nil {
  9441. return
  9442. }
  9443. return *m.id, true
  9444. }
  9445. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9446. // That means, if the mutation is applied within a transaction with an isolation level such
  9447. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9448. // or updated by the mutation.
  9449. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  9450. switch {
  9451. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9452. id, exists := m.ID()
  9453. if exists {
  9454. return []uint64{id}, nil
  9455. }
  9456. fallthrough
  9457. case m.op.Is(OpUpdate | OpDelete):
  9458. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  9459. default:
  9460. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9461. }
  9462. }
  9463. // SetCreatedAt sets the "created_at" field.
  9464. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  9465. m.created_at = &t
  9466. }
  9467. // CreatedAt returns the value of the "created_at" field in the mutation.
  9468. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  9469. v := m.created_at
  9470. if v == nil {
  9471. return
  9472. }
  9473. return *v, true
  9474. }
  9475. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  9476. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9478. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9479. if !m.op.Is(OpUpdateOne) {
  9480. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9481. }
  9482. if m.id == nil || m.oldValue == nil {
  9483. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9484. }
  9485. oldValue, err := m.oldValue(ctx)
  9486. if err != nil {
  9487. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9488. }
  9489. return oldValue.CreatedAt, nil
  9490. }
  9491. // ResetCreatedAt resets all changes to the "created_at" field.
  9492. func (m *SopNodeMutation) ResetCreatedAt() {
  9493. m.created_at = nil
  9494. }
  9495. // SetUpdatedAt sets the "updated_at" field.
  9496. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  9497. m.updated_at = &t
  9498. }
  9499. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9500. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  9501. v := m.updated_at
  9502. if v == nil {
  9503. return
  9504. }
  9505. return *v, true
  9506. }
  9507. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  9508. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9510. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9511. if !m.op.Is(OpUpdateOne) {
  9512. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9513. }
  9514. if m.id == nil || m.oldValue == nil {
  9515. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9516. }
  9517. oldValue, err := m.oldValue(ctx)
  9518. if err != nil {
  9519. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9520. }
  9521. return oldValue.UpdatedAt, nil
  9522. }
  9523. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9524. func (m *SopNodeMutation) ResetUpdatedAt() {
  9525. m.updated_at = nil
  9526. }
  9527. // SetStatus sets the "status" field.
  9528. func (m *SopNodeMutation) SetStatus(u uint8) {
  9529. m.status = &u
  9530. m.addstatus = nil
  9531. }
  9532. // Status returns the value of the "status" field in the mutation.
  9533. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  9534. v := m.status
  9535. if v == nil {
  9536. return
  9537. }
  9538. return *v, true
  9539. }
  9540. // OldStatus returns the old "status" field's value of the SopNode entity.
  9541. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9543. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9544. if !m.op.Is(OpUpdateOne) {
  9545. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9546. }
  9547. if m.id == nil || m.oldValue == nil {
  9548. return v, errors.New("OldStatus requires an ID field in the mutation")
  9549. }
  9550. oldValue, err := m.oldValue(ctx)
  9551. if err != nil {
  9552. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9553. }
  9554. return oldValue.Status, nil
  9555. }
  9556. // AddStatus adds u to the "status" field.
  9557. func (m *SopNodeMutation) AddStatus(u int8) {
  9558. if m.addstatus != nil {
  9559. *m.addstatus += u
  9560. } else {
  9561. m.addstatus = &u
  9562. }
  9563. }
  9564. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9565. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  9566. v := m.addstatus
  9567. if v == nil {
  9568. return
  9569. }
  9570. return *v, true
  9571. }
  9572. // ClearStatus clears the value of the "status" field.
  9573. func (m *SopNodeMutation) ClearStatus() {
  9574. m.status = nil
  9575. m.addstatus = nil
  9576. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  9577. }
  9578. // StatusCleared returns if the "status" field was cleared in this mutation.
  9579. func (m *SopNodeMutation) StatusCleared() bool {
  9580. _, ok := m.clearedFields[sopnode.FieldStatus]
  9581. return ok
  9582. }
  9583. // ResetStatus resets all changes to the "status" field.
  9584. func (m *SopNodeMutation) ResetStatus() {
  9585. m.status = nil
  9586. m.addstatus = nil
  9587. delete(m.clearedFields, sopnode.FieldStatus)
  9588. }
  9589. // SetDeletedAt sets the "deleted_at" field.
  9590. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  9591. m.deleted_at = &t
  9592. }
  9593. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9594. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  9595. v := m.deleted_at
  9596. if v == nil {
  9597. return
  9598. }
  9599. return *v, true
  9600. }
  9601. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  9602. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9604. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9605. if !m.op.Is(OpUpdateOne) {
  9606. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9607. }
  9608. if m.id == nil || m.oldValue == nil {
  9609. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9610. }
  9611. oldValue, err := m.oldValue(ctx)
  9612. if err != nil {
  9613. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9614. }
  9615. return oldValue.DeletedAt, nil
  9616. }
  9617. // ClearDeletedAt clears the value of the "deleted_at" field.
  9618. func (m *SopNodeMutation) ClearDeletedAt() {
  9619. m.deleted_at = nil
  9620. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  9621. }
  9622. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9623. func (m *SopNodeMutation) DeletedAtCleared() bool {
  9624. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  9625. return ok
  9626. }
  9627. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9628. func (m *SopNodeMutation) ResetDeletedAt() {
  9629. m.deleted_at = nil
  9630. delete(m.clearedFields, sopnode.FieldDeletedAt)
  9631. }
  9632. // SetStageID sets the "stage_id" field.
  9633. func (m *SopNodeMutation) SetStageID(u uint64) {
  9634. m.sop_stage = &u
  9635. }
  9636. // StageID returns the value of the "stage_id" field in the mutation.
  9637. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  9638. v := m.sop_stage
  9639. if v == nil {
  9640. return
  9641. }
  9642. return *v, true
  9643. }
  9644. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  9645. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9647. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  9648. if !m.op.Is(OpUpdateOne) {
  9649. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  9650. }
  9651. if m.id == nil || m.oldValue == nil {
  9652. return v, errors.New("OldStageID requires an ID field in the mutation")
  9653. }
  9654. oldValue, err := m.oldValue(ctx)
  9655. if err != nil {
  9656. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  9657. }
  9658. return oldValue.StageID, nil
  9659. }
  9660. // ResetStageID resets all changes to the "stage_id" field.
  9661. func (m *SopNodeMutation) ResetStageID() {
  9662. m.sop_stage = nil
  9663. }
  9664. // SetParentID sets the "parent_id" field.
  9665. func (m *SopNodeMutation) SetParentID(u uint64) {
  9666. m.parent_id = &u
  9667. m.addparent_id = nil
  9668. }
  9669. // ParentID returns the value of the "parent_id" field in the mutation.
  9670. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  9671. v := m.parent_id
  9672. if v == nil {
  9673. return
  9674. }
  9675. return *v, true
  9676. }
  9677. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  9678. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9680. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  9681. if !m.op.Is(OpUpdateOne) {
  9682. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  9683. }
  9684. if m.id == nil || m.oldValue == nil {
  9685. return v, errors.New("OldParentID requires an ID field in the mutation")
  9686. }
  9687. oldValue, err := m.oldValue(ctx)
  9688. if err != nil {
  9689. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  9690. }
  9691. return oldValue.ParentID, nil
  9692. }
  9693. // AddParentID adds u to the "parent_id" field.
  9694. func (m *SopNodeMutation) AddParentID(u int64) {
  9695. if m.addparent_id != nil {
  9696. *m.addparent_id += u
  9697. } else {
  9698. m.addparent_id = &u
  9699. }
  9700. }
  9701. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  9702. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  9703. v := m.addparent_id
  9704. if v == nil {
  9705. return
  9706. }
  9707. return *v, true
  9708. }
  9709. // ResetParentID resets all changes to the "parent_id" field.
  9710. func (m *SopNodeMutation) ResetParentID() {
  9711. m.parent_id = nil
  9712. m.addparent_id = nil
  9713. }
  9714. // SetName sets the "name" field.
  9715. func (m *SopNodeMutation) SetName(s string) {
  9716. m.name = &s
  9717. }
  9718. // Name returns the value of the "name" field in the mutation.
  9719. func (m *SopNodeMutation) Name() (r string, exists bool) {
  9720. v := m.name
  9721. if v == nil {
  9722. return
  9723. }
  9724. return *v, true
  9725. }
  9726. // OldName returns the old "name" field's value of the SopNode entity.
  9727. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9729. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  9730. if !m.op.Is(OpUpdateOne) {
  9731. return v, errors.New("OldName is only allowed on UpdateOne operations")
  9732. }
  9733. if m.id == nil || m.oldValue == nil {
  9734. return v, errors.New("OldName requires an ID field in the mutation")
  9735. }
  9736. oldValue, err := m.oldValue(ctx)
  9737. if err != nil {
  9738. return v, fmt.Errorf("querying old value for OldName: %w", err)
  9739. }
  9740. return oldValue.Name, nil
  9741. }
  9742. // ResetName resets all changes to the "name" field.
  9743. func (m *SopNodeMutation) ResetName() {
  9744. m.name = nil
  9745. }
  9746. // SetConditionType sets the "condition_type" field.
  9747. func (m *SopNodeMutation) SetConditionType(i int) {
  9748. m.condition_type = &i
  9749. m.addcondition_type = nil
  9750. }
  9751. // ConditionType returns the value of the "condition_type" field in the mutation.
  9752. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  9753. v := m.condition_type
  9754. if v == nil {
  9755. return
  9756. }
  9757. return *v, true
  9758. }
  9759. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  9760. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9762. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  9763. if !m.op.Is(OpUpdateOne) {
  9764. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  9765. }
  9766. if m.id == nil || m.oldValue == nil {
  9767. return v, errors.New("OldConditionType requires an ID field in the mutation")
  9768. }
  9769. oldValue, err := m.oldValue(ctx)
  9770. if err != nil {
  9771. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  9772. }
  9773. return oldValue.ConditionType, nil
  9774. }
  9775. // AddConditionType adds i to the "condition_type" field.
  9776. func (m *SopNodeMutation) AddConditionType(i int) {
  9777. if m.addcondition_type != nil {
  9778. *m.addcondition_type += i
  9779. } else {
  9780. m.addcondition_type = &i
  9781. }
  9782. }
  9783. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  9784. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  9785. v := m.addcondition_type
  9786. if v == nil {
  9787. return
  9788. }
  9789. return *v, true
  9790. }
  9791. // ResetConditionType resets all changes to the "condition_type" field.
  9792. func (m *SopNodeMutation) ResetConditionType() {
  9793. m.condition_type = nil
  9794. m.addcondition_type = nil
  9795. }
  9796. // SetConditionList sets the "condition_list" field.
  9797. func (m *SopNodeMutation) SetConditionList(s []string) {
  9798. m.condition_list = &s
  9799. m.appendcondition_list = nil
  9800. }
  9801. // ConditionList returns the value of the "condition_list" field in the mutation.
  9802. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  9803. v := m.condition_list
  9804. if v == nil {
  9805. return
  9806. }
  9807. return *v, true
  9808. }
  9809. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  9810. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9812. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  9813. if !m.op.Is(OpUpdateOne) {
  9814. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  9815. }
  9816. if m.id == nil || m.oldValue == nil {
  9817. return v, errors.New("OldConditionList requires an ID field in the mutation")
  9818. }
  9819. oldValue, err := m.oldValue(ctx)
  9820. if err != nil {
  9821. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  9822. }
  9823. return oldValue.ConditionList, nil
  9824. }
  9825. // AppendConditionList adds s to the "condition_list" field.
  9826. func (m *SopNodeMutation) AppendConditionList(s []string) {
  9827. m.appendcondition_list = append(m.appendcondition_list, s...)
  9828. }
  9829. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  9830. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  9831. if len(m.appendcondition_list) == 0 {
  9832. return nil, false
  9833. }
  9834. return m.appendcondition_list, true
  9835. }
  9836. // ClearConditionList clears the value of the "condition_list" field.
  9837. func (m *SopNodeMutation) ClearConditionList() {
  9838. m.condition_list = nil
  9839. m.appendcondition_list = nil
  9840. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  9841. }
  9842. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  9843. func (m *SopNodeMutation) ConditionListCleared() bool {
  9844. _, ok := m.clearedFields[sopnode.FieldConditionList]
  9845. return ok
  9846. }
  9847. // ResetConditionList resets all changes to the "condition_list" field.
  9848. func (m *SopNodeMutation) ResetConditionList() {
  9849. m.condition_list = nil
  9850. m.appendcondition_list = nil
  9851. delete(m.clearedFields, sopnode.FieldConditionList)
  9852. }
  9853. // SetNoReplyCondition sets the "no_reply_condition" field.
  9854. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  9855. m.no_reply_condition = &u
  9856. m.addno_reply_condition = nil
  9857. }
  9858. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  9859. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  9860. v := m.no_reply_condition
  9861. if v == nil {
  9862. return
  9863. }
  9864. return *v, true
  9865. }
  9866. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  9867. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9869. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  9870. if !m.op.Is(OpUpdateOne) {
  9871. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  9872. }
  9873. if m.id == nil || m.oldValue == nil {
  9874. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  9875. }
  9876. oldValue, err := m.oldValue(ctx)
  9877. if err != nil {
  9878. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  9879. }
  9880. return oldValue.NoReplyCondition, nil
  9881. }
  9882. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  9883. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  9884. if m.addno_reply_condition != nil {
  9885. *m.addno_reply_condition += u
  9886. } else {
  9887. m.addno_reply_condition = &u
  9888. }
  9889. }
  9890. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  9891. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  9892. v := m.addno_reply_condition
  9893. if v == nil {
  9894. return
  9895. }
  9896. return *v, true
  9897. }
  9898. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  9899. func (m *SopNodeMutation) ResetNoReplyCondition() {
  9900. m.no_reply_condition = nil
  9901. m.addno_reply_condition = nil
  9902. }
  9903. // SetActionMessage sets the "action_message" field.
  9904. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  9905. m.action_message = &ct
  9906. m.appendaction_message = nil
  9907. }
  9908. // ActionMessage returns the value of the "action_message" field in the mutation.
  9909. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  9910. v := m.action_message
  9911. if v == nil {
  9912. return
  9913. }
  9914. return *v, true
  9915. }
  9916. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  9917. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9919. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  9920. if !m.op.Is(OpUpdateOne) {
  9921. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  9922. }
  9923. if m.id == nil || m.oldValue == nil {
  9924. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  9925. }
  9926. oldValue, err := m.oldValue(ctx)
  9927. if err != nil {
  9928. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  9929. }
  9930. return oldValue.ActionMessage, nil
  9931. }
  9932. // AppendActionMessage adds ct to the "action_message" field.
  9933. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  9934. m.appendaction_message = append(m.appendaction_message, ct...)
  9935. }
  9936. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  9937. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  9938. if len(m.appendaction_message) == 0 {
  9939. return nil, false
  9940. }
  9941. return m.appendaction_message, true
  9942. }
  9943. // ClearActionMessage clears the value of the "action_message" field.
  9944. func (m *SopNodeMutation) ClearActionMessage() {
  9945. m.action_message = nil
  9946. m.appendaction_message = nil
  9947. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  9948. }
  9949. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  9950. func (m *SopNodeMutation) ActionMessageCleared() bool {
  9951. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  9952. return ok
  9953. }
  9954. // ResetActionMessage resets all changes to the "action_message" field.
  9955. func (m *SopNodeMutation) ResetActionMessage() {
  9956. m.action_message = nil
  9957. m.appendaction_message = nil
  9958. delete(m.clearedFields, sopnode.FieldActionMessage)
  9959. }
  9960. // SetActionLabel sets the "action_label" field.
  9961. func (m *SopNodeMutation) SetActionLabel(u []uint64) {
  9962. m.action_label = &u
  9963. m.appendaction_label = nil
  9964. }
  9965. // ActionLabel returns the value of the "action_label" field in the mutation.
  9966. func (m *SopNodeMutation) ActionLabel() (r []uint64, exists bool) {
  9967. v := m.action_label
  9968. if v == nil {
  9969. return
  9970. }
  9971. return *v, true
  9972. }
  9973. // OldActionLabel returns the old "action_label" field's value of the SopNode entity.
  9974. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9976. func (m *SopNodeMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  9977. if !m.op.Is(OpUpdateOne) {
  9978. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  9979. }
  9980. if m.id == nil || m.oldValue == nil {
  9981. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  9982. }
  9983. oldValue, err := m.oldValue(ctx)
  9984. if err != nil {
  9985. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  9986. }
  9987. return oldValue.ActionLabel, nil
  9988. }
  9989. // AppendActionLabel adds u to the "action_label" field.
  9990. func (m *SopNodeMutation) AppendActionLabel(u []uint64) {
  9991. m.appendaction_label = append(m.appendaction_label, u...)
  9992. }
  9993. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  9994. func (m *SopNodeMutation) AppendedActionLabel() ([]uint64, bool) {
  9995. if len(m.appendaction_label) == 0 {
  9996. return nil, false
  9997. }
  9998. return m.appendaction_label, true
  9999. }
  10000. // ClearActionLabel clears the value of the "action_label" field.
  10001. func (m *SopNodeMutation) ClearActionLabel() {
  10002. m.action_label = nil
  10003. m.appendaction_label = nil
  10004. m.clearedFields[sopnode.FieldActionLabel] = struct{}{}
  10005. }
  10006. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  10007. func (m *SopNodeMutation) ActionLabelCleared() bool {
  10008. _, ok := m.clearedFields[sopnode.FieldActionLabel]
  10009. return ok
  10010. }
  10011. // ResetActionLabel resets all changes to the "action_label" field.
  10012. func (m *SopNodeMutation) ResetActionLabel() {
  10013. m.action_label = nil
  10014. m.appendaction_label = nil
  10015. delete(m.clearedFields, sopnode.FieldActionLabel)
  10016. }
  10017. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  10018. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  10019. m.sop_stage = &id
  10020. }
  10021. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  10022. func (m *SopNodeMutation) ClearSopStage() {
  10023. m.clearedsop_stage = true
  10024. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  10025. }
  10026. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  10027. func (m *SopNodeMutation) SopStageCleared() bool {
  10028. return m.clearedsop_stage
  10029. }
  10030. // SopStageID returns the "sop_stage" edge ID in the mutation.
  10031. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  10032. if m.sop_stage != nil {
  10033. return *m.sop_stage, true
  10034. }
  10035. return
  10036. }
  10037. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  10038. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  10039. // SopStageID instead. It exists only for internal usage by the builders.
  10040. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  10041. if id := m.sop_stage; id != nil {
  10042. ids = append(ids, *id)
  10043. }
  10044. return
  10045. }
  10046. // ResetSopStage resets all changes to the "sop_stage" edge.
  10047. func (m *SopNodeMutation) ResetSopStage() {
  10048. m.sop_stage = nil
  10049. m.clearedsop_stage = false
  10050. }
  10051. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  10052. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  10053. if m.node_messages == nil {
  10054. m.node_messages = make(map[uint64]struct{})
  10055. }
  10056. for i := range ids {
  10057. m.node_messages[ids[i]] = struct{}{}
  10058. }
  10059. }
  10060. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  10061. func (m *SopNodeMutation) ClearNodeMessages() {
  10062. m.clearednode_messages = true
  10063. }
  10064. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  10065. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  10066. return m.clearednode_messages
  10067. }
  10068. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  10069. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  10070. if m.removednode_messages == nil {
  10071. m.removednode_messages = make(map[uint64]struct{})
  10072. }
  10073. for i := range ids {
  10074. delete(m.node_messages, ids[i])
  10075. m.removednode_messages[ids[i]] = struct{}{}
  10076. }
  10077. }
  10078. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  10079. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  10080. for id := range m.removednode_messages {
  10081. ids = append(ids, id)
  10082. }
  10083. return
  10084. }
  10085. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  10086. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  10087. for id := range m.node_messages {
  10088. ids = append(ids, id)
  10089. }
  10090. return
  10091. }
  10092. // ResetNodeMessages resets all changes to the "node_messages" edge.
  10093. func (m *SopNodeMutation) ResetNodeMessages() {
  10094. m.node_messages = nil
  10095. m.clearednode_messages = false
  10096. m.removednode_messages = nil
  10097. }
  10098. // Where appends a list predicates to the SopNodeMutation builder.
  10099. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  10100. m.predicates = append(m.predicates, ps...)
  10101. }
  10102. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  10103. // users can use type-assertion to append predicates that do not depend on any generated package.
  10104. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  10105. p := make([]predicate.SopNode, len(ps))
  10106. for i := range ps {
  10107. p[i] = ps[i]
  10108. }
  10109. m.Where(p...)
  10110. }
  10111. // Op returns the operation name.
  10112. func (m *SopNodeMutation) Op() Op {
  10113. return m.op
  10114. }
  10115. // SetOp allows setting the mutation operation.
  10116. func (m *SopNodeMutation) SetOp(op Op) {
  10117. m.op = op
  10118. }
  10119. // Type returns the node type of this mutation (SopNode).
  10120. func (m *SopNodeMutation) Type() string {
  10121. return m.typ
  10122. }
  10123. // Fields returns all fields that were changed during this mutation. Note that in
  10124. // order to get all numeric fields that were incremented/decremented, call
  10125. // AddedFields().
  10126. func (m *SopNodeMutation) Fields() []string {
  10127. fields := make([]string, 0, 12)
  10128. if m.created_at != nil {
  10129. fields = append(fields, sopnode.FieldCreatedAt)
  10130. }
  10131. if m.updated_at != nil {
  10132. fields = append(fields, sopnode.FieldUpdatedAt)
  10133. }
  10134. if m.status != nil {
  10135. fields = append(fields, sopnode.FieldStatus)
  10136. }
  10137. if m.deleted_at != nil {
  10138. fields = append(fields, sopnode.FieldDeletedAt)
  10139. }
  10140. if m.sop_stage != nil {
  10141. fields = append(fields, sopnode.FieldStageID)
  10142. }
  10143. if m.parent_id != nil {
  10144. fields = append(fields, sopnode.FieldParentID)
  10145. }
  10146. if m.name != nil {
  10147. fields = append(fields, sopnode.FieldName)
  10148. }
  10149. if m.condition_type != nil {
  10150. fields = append(fields, sopnode.FieldConditionType)
  10151. }
  10152. if m.condition_list != nil {
  10153. fields = append(fields, sopnode.FieldConditionList)
  10154. }
  10155. if m.no_reply_condition != nil {
  10156. fields = append(fields, sopnode.FieldNoReplyCondition)
  10157. }
  10158. if m.action_message != nil {
  10159. fields = append(fields, sopnode.FieldActionMessage)
  10160. }
  10161. if m.action_label != nil {
  10162. fields = append(fields, sopnode.FieldActionLabel)
  10163. }
  10164. return fields
  10165. }
  10166. // Field returns the value of a field with the given name. The second boolean
  10167. // return value indicates that this field was not set, or was not defined in the
  10168. // schema.
  10169. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  10170. switch name {
  10171. case sopnode.FieldCreatedAt:
  10172. return m.CreatedAt()
  10173. case sopnode.FieldUpdatedAt:
  10174. return m.UpdatedAt()
  10175. case sopnode.FieldStatus:
  10176. return m.Status()
  10177. case sopnode.FieldDeletedAt:
  10178. return m.DeletedAt()
  10179. case sopnode.FieldStageID:
  10180. return m.StageID()
  10181. case sopnode.FieldParentID:
  10182. return m.ParentID()
  10183. case sopnode.FieldName:
  10184. return m.Name()
  10185. case sopnode.FieldConditionType:
  10186. return m.ConditionType()
  10187. case sopnode.FieldConditionList:
  10188. return m.ConditionList()
  10189. case sopnode.FieldNoReplyCondition:
  10190. return m.NoReplyCondition()
  10191. case sopnode.FieldActionMessage:
  10192. return m.ActionMessage()
  10193. case sopnode.FieldActionLabel:
  10194. return m.ActionLabel()
  10195. }
  10196. return nil, false
  10197. }
  10198. // OldField returns the old value of the field from the database. An error is
  10199. // returned if the mutation operation is not UpdateOne, or the query to the
  10200. // database failed.
  10201. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10202. switch name {
  10203. case sopnode.FieldCreatedAt:
  10204. return m.OldCreatedAt(ctx)
  10205. case sopnode.FieldUpdatedAt:
  10206. return m.OldUpdatedAt(ctx)
  10207. case sopnode.FieldStatus:
  10208. return m.OldStatus(ctx)
  10209. case sopnode.FieldDeletedAt:
  10210. return m.OldDeletedAt(ctx)
  10211. case sopnode.FieldStageID:
  10212. return m.OldStageID(ctx)
  10213. case sopnode.FieldParentID:
  10214. return m.OldParentID(ctx)
  10215. case sopnode.FieldName:
  10216. return m.OldName(ctx)
  10217. case sopnode.FieldConditionType:
  10218. return m.OldConditionType(ctx)
  10219. case sopnode.FieldConditionList:
  10220. return m.OldConditionList(ctx)
  10221. case sopnode.FieldNoReplyCondition:
  10222. return m.OldNoReplyCondition(ctx)
  10223. case sopnode.FieldActionMessage:
  10224. return m.OldActionMessage(ctx)
  10225. case sopnode.FieldActionLabel:
  10226. return m.OldActionLabel(ctx)
  10227. }
  10228. return nil, fmt.Errorf("unknown SopNode field %s", name)
  10229. }
  10230. // SetField sets the value of a field with the given name. It returns an error if
  10231. // the field is not defined in the schema, or if the type mismatched the field
  10232. // type.
  10233. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  10234. switch name {
  10235. case sopnode.FieldCreatedAt:
  10236. v, ok := value.(time.Time)
  10237. if !ok {
  10238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10239. }
  10240. m.SetCreatedAt(v)
  10241. return nil
  10242. case sopnode.FieldUpdatedAt:
  10243. v, ok := value.(time.Time)
  10244. if !ok {
  10245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10246. }
  10247. m.SetUpdatedAt(v)
  10248. return nil
  10249. case sopnode.FieldStatus:
  10250. v, ok := value.(uint8)
  10251. if !ok {
  10252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10253. }
  10254. m.SetStatus(v)
  10255. return nil
  10256. case sopnode.FieldDeletedAt:
  10257. v, ok := value.(time.Time)
  10258. if !ok {
  10259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10260. }
  10261. m.SetDeletedAt(v)
  10262. return nil
  10263. case sopnode.FieldStageID:
  10264. v, ok := value.(uint64)
  10265. if !ok {
  10266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10267. }
  10268. m.SetStageID(v)
  10269. return nil
  10270. case sopnode.FieldParentID:
  10271. v, ok := value.(uint64)
  10272. if !ok {
  10273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10274. }
  10275. m.SetParentID(v)
  10276. return nil
  10277. case sopnode.FieldName:
  10278. v, ok := value.(string)
  10279. if !ok {
  10280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10281. }
  10282. m.SetName(v)
  10283. return nil
  10284. case sopnode.FieldConditionType:
  10285. v, ok := value.(int)
  10286. if !ok {
  10287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10288. }
  10289. m.SetConditionType(v)
  10290. return nil
  10291. case sopnode.FieldConditionList:
  10292. v, ok := value.([]string)
  10293. if !ok {
  10294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10295. }
  10296. m.SetConditionList(v)
  10297. return nil
  10298. case sopnode.FieldNoReplyCondition:
  10299. v, ok := value.(uint64)
  10300. if !ok {
  10301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10302. }
  10303. m.SetNoReplyCondition(v)
  10304. return nil
  10305. case sopnode.FieldActionMessage:
  10306. v, ok := value.([]custom_types.Action)
  10307. if !ok {
  10308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10309. }
  10310. m.SetActionMessage(v)
  10311. return nil
  10312. case sopnode.FieldActionLabel:
  10313. v, ok := value.([]uint64)
  10314. if !ok {
  10315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10316. }
  10317. m.SetActionLabel(v)
  10318. return nil
  10319. }
  10320. return fmt.Errorf("unknown SopNode field %s", name)
  10321. }
  10322. // AddedFields returns all numeric fields that were incremented/decremented during
  10323. // this mutation.
  10324. func (m *SopNodeMutation) AddedFields() []string {
  10325. var fields []string
  10326. if m.addstatus != nil {
  10327. fields = append(fields, sopnode.FieldStatus)
  10328. }
  10329. if m.addparent_id != nil {
  10330. fields = append(fields, sopnode.FieldParentID)
  10331. }
  10332. if m.addcondition_type != nil {
  10333. fields = append(fields, sopnode.FieldConditionType)
  10334. }
  10335. if m.addno_reply_condition != nil {
  10336. fields = append(fields, sopnode.FieldNoReplyCondition)
  10337. }
  10338. return fields
  10339. }
  10340. // AddedField returns the numeric value that was incremented/decremented on a field
  10341. // with the given name. The second boolean return value indicates that this field
  10342. // was not set, or was not defined in the schema.
  10343. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  10344. switch name {
  10345. case sopnode.FieldStatus:
  10346. return m.AddedStatus()
  10347. case sopnode.FieldParentID:
  10348. return m.AddedParentID()
  10349. case sopnode.FieldConditionType:
  10350. return m.AddedConditionType()
  10351. case sopnode.FieldNoReplyCondition:
  10352. return m.AddedNoReplyCondition()
  10353. }
  10354. return nil, false
  10355. }
  10356. // AddField adds the value to the field with the given name. It returns an error if
  10357. // the field is not defined in the schema, or if the type mismatched the field
  10358. // type.
  10359. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  10360. switch name {
  10361. case sopnode.FieldStatus:
  10362. v, ok := value.(int8)
  10363. if !ok {
  10364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10365. }
  10366. m.AddStatus(v)
  10367. return nil
  10368. case sopnode.FieldParentID:
  10369. v, ok := value.(int64)
  10370. if !ok {
  10371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10372. }
  10373. m.AddParentID(v)
  10374. return nil
  10375. case sopnode.FieldConditionType:
  10376. v, ok := value.(int)
  10377. if !ok {
  10378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10379. }
  10380. m.AddConditionType(v)
  10381. return nil
  10382. case sopnode.FieldNoReplyCondition:
  10383. v, ok := value.(int64)
  10384. if !ok {
  10385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10386. }
  10387. m.AddNoReplyCondition(v)
  10388. return nil
  10389. }
  10390. return fmt.Errorf("unknown SopNode numeric field %s", name)
  10391. }
  10392. // ClearedFields returns all nullable fields that were cleared during this
  10393. // mutation.
  10394. func (m *SopNodeMutation) ClearedFields() []string {
  10395. var fields []string
  10396. if m.FieldCleared(sopnode.FieldStatus) {
  10397. fields = append(fields, sopnode.FieldStatus)
  10398. }
  10399. if m.FieldCleared(sopnode.FieldDeletedAt) {
  10400. fields = append(fields, sopnode.FieldDeletedAt)
  10401. }
  10402. if m.FieldCleared(sopnode.FieldConditionList) {
  10403. fields = append(fields, sopnode.FieldConditionList)
  10404. }
  10405. if m.FieldCleared(sopnode.FieldActionMessage) {
  10406. fields = append(fields, sopnode.FieldActionMessage)
  10407. }
  10408. if m.FieldCleared(sopnode.FieldActionLabel) {
  10409. fields = append(fields, sopnode.FieldActionLabel)
  10410. }
  10411. return fields
  10412. }
  10413. // FieldCleared returns a boolean indicating if a field with the given name was
  10414. // cleared in this mutation.
  10415. func (m *SopNodeMutation) FieldCleared(name string) bool {
  10416. _, ok := m.clearedFields[name]
  10417. return ok
  10418. }
  10419. // ClearField clears the value of the field with the given name. It returns an
  10420. // error if the field is not defined in the schema.
  10421. func (m *SopNodeMutation) ClearField(name string) error {
  10422. switch name {
  10423. case sopnode.FieldStatus:
  10424. m.ClearStatus()
  10425. return nil
  10426. case sopnode.FieldDeletedAt:
  10427. m.ClearDeletedAt()
  10428. return nil
  10429. case sopnode.FieldConditionList:
  10430. m.ClearConditionList()
  10431. return nil
  10432. case sopnode.FieldActionMessage:
  10433. m.ClearActionMessage()
  10434. return nil
  10435. case sopnode.FieldActionLabel:
  10436. m.ClearActionLabel()
  10437. return nil
  10438. }
  10439. return fmt.Errorf("unknown SopNode nullable field %s", name)
  10440. }
  10441. // ResetField resets all changes in the mutation for the field with the given name.
  10442. // It returns an error if the field is not defined in the schema.
  10443. func (m *SopNodeMutation) ResetField(name string) error {
  10444. switch name {
  10445. case sopnode.FieldCreatedAt:
  10446. m.ResetCreatedAt()
  10447. return nil
  10448. case sopnode.FieldUpdatedAt:
  10449. m.ResetUpdatedAt()
  10450. return nil
  10451. case sopnode.FieldStatus:
  10452. m.ResetStatus()
  10453. return nil
  10454. case sopnode.FieldDeletedAt:
  10455. m.ResetDeletedAt()
  10456. return nil
  10457. case sopnode.FieldStageID:
  10458. m.ResetStageID()
  10459. return nil
  10460. case sopnode.FieldParentID:
  10461. m.ResetParentID()
  10462. return nil
  10463. case sopnode.FieldName:
  10464. m.ResetName()
  10465. return nil
  10466. case sopnode.FieldConditionType:
  10467. m.ResetConditionType()
  10468. return nil
  10469. case sopnode.FieldConditionList:
  10470. m.ResetConditionList()
  10471. return nil
  10472. case sopnode.FieldNoReplyCondition:
  10473. m.ResetNoReplyCondition()
  10474. return nil
  10475. case sopnode.FieldActionMessage:
  10476. m.ResetActionMessage()
  10477. return nil
  10478. case sopnode.FieldActionLabel:
  10479. m.ResetActionLabel()
  10480. return nil
  10481. }
  10482. return fmt.Errorf("unknown SopNode field %s", name)
  10483. }
  10484. // AddedEdges returns all edge names that were set/added in this mutation.
  10485. func (m *SopNodeMutation) AddedEdges() []string {
  10486. edges := make([]string, 0, 2)
  10487. if m.sop_stage != nil {
  10488. edges = append(edges, sopnode.EdgeSopStage)
  10489. }
  10490. if m.node_messages != nil {
  10491. edges = append(edges, sopnode.EdgeNodeMessages)
  10492. }
  10493. return edges
  10494. }
  10495. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10496. // name in this mutation.
  10497. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  10498. switch name {
  10499. case sopnode.EdgeSopStage:
  10500. if id := m.sop_stage; id != nil {
  10501. return []ent.Value{*id}
  10502. }
  10503. case sopnode.EdgeNodeMessages:
  10504. ids := make([]ent.Value, 0, len(m.node_messages))
  10505. for id := range m.node_messages {
  10506. ids = append(ids, id)
  10507. }
  10508. return ids
  10509. }
  10510. return nil
  10511. }
  10512. // RemovedEdges returns all edge names that were removed in this mutation.
  10513. func (m *SopNodeMutation) RemovedEdges() []string {
  10514. edges := make([]string, 0, 2)
  10515. if m.removednode_messages != nil {
  10516. edges = append(edges, sopnode.EdgeNodeMessages)
  10517. }
  10518. return edges
  10519. }
  10520. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10521. // the given name in this mutation.
  10522. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  10523. switch name {
  10524. case sopnode.EdgeNodeMessages:
  10525. ids := make([]ent.Value, 0, len(m.removednode_messages))
  10526. for id := range m.removednode_messages {
  10527. ids = append(ids, id)
  10528. }
  10529. return ids
  10530. }
  10531. return nil
  10532. }
  10533. // ClearedEdges returns all edge names that were cleared in this mutation.
  10534. func (m *SopNodeMutation) ClearedEdges() []string {
  10535. edges := make([]string, 0, 2)
  10536. if m.clearedsop_stage {
  10537. edges = append(edges, sopnode.EdgeSopStage)
  10538. }
  10539. if m.clearednode_messages {
  10540. edges = append(edges, sopnode.EdgeNodeMessages)
  10541. }
  10542. return edges
  10543. }
  10544. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10545. // was cleared in this mutation.
  10546. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  10547. switch name {
  10548. case sopnode.EdgeSopStage:
  10549. return m.clearedsop_stage
  10550. case sopnode.EdgeNodeMessages:
  10551. return m.clearednode_messages
  10552. }
  10553. return false
  10554. }
  10555. // ClearEdge clears the value of the edge with the given name. It returns an error
  10556. // if that edge is not defined in the schema.
  10557. func (m *SopNodeMutation) ClearEdge(name string) error {
  10558. switch name {
  10559. case sopnode.EdgeSopStage:
  10560. m.ClearSopStage()
  10561. return nil
  10562. }
  10563. return fmt.Errorf("unknown SopNode unique edge %s", name)
  10564. }
  10565. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10566. // It returns an error if the edge is not defined in the schema.
  10567. func (m *SopNodeMutation) ResetEdge(name string) error {
  10568. switch name {
  10569. case sopnode.EdgeSopStage:
  10570. m.ResetSopStage()
  10571. return nil
  10572. case sopnode.EdgeNodeMessages:
  10573. m.ResetNodeMessages()
  10574. return nil
  10575. }
  10576. return fmt.Errorf("unknown SopNode edge %s", name)
  10577. }
  10578. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  10579. type SopStageMutation struct {
  10580. config
  10581. op Op
  10582. typ string
  10583. id *uint64
  10584. created_at *time.Time
  10585. updated_at *time.Time
  10586. status *uint8
  10587. addstatus *int8
  10588. deleted_at *time.Time
  10589. name *string
  10590. condition_type *int
  10591. addcondition_type *int
  10592. condition_operator *int
  10593. addcondition_operator *int
  10594. condition_list *[]custom_types.Condition
  10595. appendcondition_list []custom_types.Condition
  10596. action_message *[]custom_types.Action
  10597. appendaction_message []custom_types.Action
  10598. action_label *[]uint64
  10599. appendaction_label []uint64
  10600. index_sort *int
  10601. addindex_sort *int
  10602. clearedFields map[string]struct{}
  10603. sop_task *uint64
  10604. clearedsop_task bool
  10605. stage_nodes map[uint64]struct{}
  10606. removedstage_nodes map[uint64]struct{}
  10607. clearedstage_nodes bool
  10608. stage_messages map[uint64]struct{}
  10609. removedstage_messages map[uint64]struct{}
  10610. clearedstage_messages bool
  10611. done bool
  10612. oldValue func(context.Context) (*SopStage, error)
  10613. predicates []predicate.SopStage
  10614. }
  10615. var _ ent.Mutation = (*SopStageMutation)(nil)
  10616. // sopstageOption allows management of the mutation configuration using functional options.
  10617. type sopstageOption func(*SopStageMutation)
  10618. // newSopStageMutation creates new mutation for the SopStage entity.
  10619. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  10620. m := &SopStageMutation{
  10621. config: c,
  10622. op: op,
  10623. typ: TypeSopStage,
  10624. clearedFields: make(map[string]struct{}),
  10625. }
  10626. for _, opt := range opts {
  10627. opt(m)
  10628. }
  10629. return m
  10630. }
  10631. // withSopStageID sets the ID field of the mutation.
  10632. func withSopStageID(id uint64) sopstageOption {
  10633. return func(m *SopStageMutation) {
  10634. var (
  10635. err error
  10636. once sync.Once
  10637. value *SopStage
  10638. )
  10639. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  10640. once.Do(func() {
  10641. if m.done {
  10642. err = errors.New("querying old values post mutation is not allowed")
  10643. } else {
  10644. value, err = m.Client().SopStage.Get(ctx, id)
  10645. }
  10646. })
  10647. return value, err
  10648. }
  10649. m.id = &id
  10650. }
  10651. }
  10652. // withSopStage sets the old SopStage of the mutation.
  10653. func withSopStage(node *SopStage) sopstageOption {
  10654. return func(m *SopStageMutation) {
  10655. m.oldValue = func(context.Context) (*SopStage, error) {
  10656. return node, nil
  10657. }
  10658. m.id = &node.ID
  10659. }
  10660. }
  10661. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10662. // executed in a transaction (ent.Tx), a transactional client is returned.
  10663. func (m SopStageMutation) Client() *Client {
  10664. client := &Client{config: m.config}
  10665. client.init()
  10666. return client
  10667. }
  10668. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10669. // it returns an error otherwise.
  10670. func (m SopStageMutation) Tx() (*Tx, error) {
  10671. if _, ok := m.driver.(*txDriver); !ok {
  10672. return nil, errors.New("ent: mutation is not running in a transaction")
  10673. }
  10674. tx := &Tx{config: m.config}
  10675. tx.init()
  10676. return tx, nil
  10677. }
  10678. // SetID sets the value of the id field. Note that this
  10679. // operation is only accepted on creation of SopStage entities.
  10680. func (m *SopStageMutation) SetID(id uint64) {
  10681. m.id = &id
  10682. }
  10683. // ID returns the ID value in the mutation. Note that the ID is only available
  10684. // if it was provided to the builder or after it was returned from the database.
  10685. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  10686. if m.id == nil {
  10687. return
  10688. }
  10689. return *m.id, true
  10690. }
  10691. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10692. // That means, if the mutation is applied within a transaction with an isolation level such
  10693. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10694. // or updated by the mutation.
  10695. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  10696. switch {
  10697. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10698. id, exists := m.ID()
  10699. if exists {
  10700. return []uint64{id}, nil
  10701. }
  10702. fallthrough
  10703. case m.op.Is(OpUpdate | OpDelete):
  10704. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  10705. default:
  10706. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10707. }
  10708. }
  10709. // SetCreatedAt sets the "created_at" field.
  10710. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  10711. m.created_at = &t
  10712. }
  10713. // CreatedAt returns the value of the "created_at" field in the mutation.
  10714. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  10715. v := m.created_at
  10716. if v == nil {
  10717. return
  10718. }
  10719. return *v, true
  10720. }
  10721. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  10722. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10724. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10725. if !m.op.Is(OpUpdateOne) {
  10726. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10727. }
  10728. if m.id == nil || m.oldValue == nil {
  10729. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10730. }
  10731. oldValue, err := m.oldValue(ctx)
  10732. if err != nil {
  10733. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10734. }
  10735. return oldValue.CreatedAt, nil
  10736. }
  10737. // ResetCreatedAt resets all changes to the "created_at" field.
  10738. func (m *SopStageMutation) ResetCreatedAt() {
  10739. m.created_at = nil
  10740. }
  10741. // SetUpdatedAt sets the "updated_at" field.
  10742. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  10743. m.updated_at = &t
  10744. }
  10745. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10746. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  10747. v := m.updated_at
  10748. if v == nil {
  10749. return
  10750. }
  10751. return *v, true
  10752. }
  10753. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  10754. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10756. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10757. if !m.op.Is(OpUpdateOne) {
  10758. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10759. }
  10760. if m.id == nil || m.oldValue == nil {
  10761. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10762. }
  10763. oldValue, err := m.oldValue(ctx)
  10764. if err != nil {
  10765. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10766. }
  10767. return oldValue.UpdatedAt, nil
  10768. }
  10769. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10770. func (m *SopStageMutation) ResetUpdatedAt() {
  10771. m.updated_at = nil
  10772. }
  10773. // SetStatus sets the "status" field.
  10774. func (m *SopStageMutation) SetStatus(u uint8) {
  10775. m.status = &u
  10776. m.addstatus = nil
  10777. }
  10778. // Status returns the value of the "status" field in the mutation.
  10779. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  10780. v := m.status
  10781. if v == nil {
  10782. return
  10783. }
  10784. return *v, true
  10785. }
  10786. // OldStatus returns the old "status" field's value of the SopStage entity.
  10787. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10789. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  10790. if !m.op.Is(OpUpdateOne) {
  10791. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10792. }
  10793. if m.id == nil || m.oldValue == nil {
  10794. return v, errors.New("OldStatus requires an ID field in the mutation")
  10795. }
  10796. oldValue, err := m.oldValue(ctx)
  10797. if err != nil {
  10798. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10799. }
  10800. return oldValue.Status, nil
  10801. }
  10802. // AddStatus adds u to the "status" field.
  10803. func (m *SopStageMutation) AddStatus(u int8) {
  10804. if m.addstatus != nil {
  10805. *m.addstatus += u
  10806. } else {
  10807. m.addstatus = &u
  10808. }
  10809. }
  10810. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10811. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  10812. v := m.addstatus
  10813. if v == nil {
  10814. return
  10815. }
  10816. return *v, true
  10817. }
  10818. // ClearStatus clears the value of the "status" field.
  10819. func (m *SopStageMutation) ClearStatus() {
  10820. m.status = nil
  10821. m.addstatus = nil
  10822. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  10823. }
  10824. // StatusCleared returns if the "status" field was cleared in this mutation.
  10825. func (m *SopStageMutation) StatusCleared() bool {
  10826. _, ok := m.clearedFields[sopstage.FieldStatus]
  10827. return ok
  10828. }
  10829. // ResetStatus resets all changes to the "status" field.
  10830. func (m *SopStageMutation) ResetStatus() {
  10831. m.status = nil
  10832. m.addstatus = nil
  10833. delete(m.clearedFields, sopstage.FieldStatus)
  10834. }
  10835. // SetDeletedAt sets the "deleted_at" field.
  10836. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  10837. m.deleted_at = &t
  10838. }
  10839. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10840. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  10841. v := m.deleted_at
  10842. if v == nil {
  10843. return
  10844. }
  10845. return *v, true
  10846. }
  10847. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  10848. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10849. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10850. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10851. if !m.op.Is(OpUpdateOne) {
  10852. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10853. }
  10854. if m.id == nil || m.oldValue == nil {
  10855. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10856. }
  10857. oldValue, err := m.oldValue(ctx)
  10858. if err != nil {
  10859. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10860. }
  10861. return oldValue.DeletedAt, nil
  10862. }
  10863. // ClearDeletedAt clears the value of the "deleted_at" field.
  10864. func (m *SopStageMutation) ClearDeletedAt() {
  10865. m.deleted_at = nil
  10866. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  10867. }
  10868. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10869. func (m *SopStageMutation) DeletedAtCleared() bool {
  10870. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  10871. return ok
  10872. }
  10873. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10874. func (m *SopStageMutation) ResetDeletedAt() {
  10875. m.deleted_at = nil
  10876. delete(m.clearedFields, sopstage.FieldDeletedAt)
  10877. }
  10878. // SetTaskID sets the "task_id" field.
  10879. func (m *SopStageMutation) SetTaskID(u uint64) {
  10880. m.sop_task = &u
  10881. }
  10882. // TaskID returns the value of the "task_id" field in the mutation.
  10883. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  10884. v := m.sop_task
  10885. if v == nil {
  10886. return
  10887. }
  10888. return *v, true
  10889. }
  10890. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  10891. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10892. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10893. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  10894. if !m.op.Is(OpUpdateOne) {
  10895. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  10896. }
  10897. if m.id == nil || m.oldValue == nil {
  10898. return v, errors.New("OldTaskID requires an ID field in the mutation")
  10899. }
  10900. oldValue, err := m.oldValue(ctx)
  10901. if err != nil {
  10902. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  10903. }
  10904. return oldValue.TaskID, nil
  10905. }
  10906. // ResetTaskID resets all changes to the "task_id" field.
  10907. func (m *SopStageMutation) ResetTaskID() {
  10908. m.sop_task = nil
  10909. }
  10910. // SetName sets the "name" field.
  10911. func (m *SopStageMutation) SetName(s string) {
  10912. m.name = &s
  10913. }
  10914. // Name returns the value of the "name" field in the mutation.
  10915. func (m *SopStageMutation) Name() (r string, exists bool) {
  10916. v := m.name
  10917. if v == nil {
  10918. return
  10919. }
  10920. return *v, true
  10921. }
  10922. // OldName returns the old "name" field's value of the SopStage entity.
  10923. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10924. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10925. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  10926. if !m.op.Is(OpUpdateOne) {
  10927. return v, errors.New("OldName is only allowed on UpdateOne operations")
  10928. }
  10929. if m.id == nil || m.oldValue == nil {
  10930. return v, errors.New("OldName requires an ID field in the mutation")
  10931. }
  10932. oldValue, err := m.oldValue(ctx)
  10933. if err != nil {
  10934. return v, fmt.Errorf("querying old value for OldName: %w", err)
  10935. }
  10936. return oldValue.Name, nil
  10937. }
  10938. // ResetName resets all changes to the "name" field.
  10939. func (m *SopStageMutation) ResetName() {
  10940. m.name = nil
  10941. }
  10942. // SetConditionType sets the "condition_type" field.
  10943. func (m *SopStageMutation) SetConditionType(i int) {
  10944. m.condition_type = &i
  10945. m.addcondition_type = nil
  10946. }
  10947. // ConditionType returns the value of the "condition_type" field in the mutation.
  10948. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  10949. v := m.condition_type
  10950. if v == nil {
  10951. return
  10952. }
  10953. return *v, true
  10954. }
  10955. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  10956. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10958. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  10959. if !m.op.Is(OpUpdateOne) {
  10960. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  10961. }
  10962. if m.id == nil || m.oldValue == nil {
  10963. return v, errors.New("OldConditionType requires an ID field in the mutation")
  10964. }
  10965. oldValue, err := m.oldValue(ctx)
  10966. if err != nil {
  10967. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  10968. }
  10969. return oldValue.ConditionType, nil
  10970. }
  10971. // AddConditionType adds i to the "condition_type" field.
  10972. func (m *SopStageMutation) AddConditionType(i int) {
  10973. if m.addcondition_type != nil {
  10974. *m.addcondition_type += i
  10975. } else {
  10976. m.addcondition_type = &i
  10977. }
  10978. }
  10979. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  10980. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  10981. v := m.addcondition_type
  10982. if v == nil {
  10983. return
  10984. }
  10985. return *v, true
  10986. }
  10987. // ResetConditionType resets all changes to the "condition_type" field.
  10988. func (m *SopStageMutation) ResetConditionType() {
  10989. m.condition_type = nil
  10990. m.addcondition_type = nil
  10991. }
  10992. // SetConditionOperator sets the "condition_operator" field.
  10993. func (m *SopStageMutation) SetConditionOperator(i int) {
  10994. m.condition_operator = &i
  10995. m.addcondition_operator = nil
  10996. }
  10997. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  10998. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  10999. v := m.condition_operator
  11000. if v == nil {
  11001. return
  11002. }
  11003. return *v, true
  11004. }
  11005. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  11006. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11007. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11008. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  11009. if !m.op.Is(OpUpdateOne) {
  11010. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  11011. }
  11012. if m.id == nil || m.oldValue == nil {
  11013. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  11014. }
  11015. oldValue, err := m.oldValue(ctx)
  11016. if err != nil {
  11017. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  11018. }
  11019. return oldValue.ConditionOperator, nil
  11020. }
  11021. // AddConditionOperator adds i to the "condition_operator" field.
  11022. func (m *SopStageMutation) AddConditionOperator(i int) {
  11023. if m.addcondition_operator != nil {
  11024. *m.addcondition_operator += i
  11025. } else {
  11026. m.addcondition_operator = &i
  11027. }
  11028. }
  11029. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  11030. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  11031. v := m.addcondition_operator
  11032. if v == nil {
  11033. return
  11034. }
  11035. return *v, true
  11036. }
  11037. // ResetConditionOperator resets all changes to the "condition_operator" field.
  11038. func (m *SopStageMutation) ResetConditionOperator() {
  11039. m.condition_operator = nil
  11040. m.addcondition_operator = nil
  11041. }
  11042. // SetConditionList sets the "condition_list" field.
  11043. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  11044. m.condition_list = &ct
  11045. m.appendcondition_list = nil
  11046. }
  11047. // ConditionList returns the value of the "condition_list" field in the mutation.
  11048. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  11049. v := m.condition_list
  11050. if v == nil {
  11051. return
  11052. }
  11053. return *v, true
  11054. }
  11055. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  11056. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11058. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  11059. if !m.op.Is(OpUpdateOne) {
  11060. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  11061. }
  11062. if m.id == nil || m.oldValue == nil {
  11063. return v, errors.New("OldConditionList requires an ID field in the mutation")
  11064. }
  11065. oldValue, err := m.oldValue(ctx)
  11066. if err != nil {
  11067. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  11068. }
  11069. return oldValue.ConditionList, nil
  11070. }
  11071. // AppendConditionList adds ct to the "condition_list" field.
  11072. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  11073. m.appendcondition_list = append(m.appendcondition_list, ct...)
  11074. }
  11075. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  11076. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  11077. if len(m.appendcondition_list) == 0 {
  11078. return nil, false
  11079. }
  11080. return m.appendcondition_list, true
  11081. }
  11082. // ResetConditionList resets all changes to the "condition_list" field.
  11083. func (m *SopStageMutation) ResetConditionList() {
  11084. m.condition_list = nil
  11085. m.appendcondition_list = nil
  11086. }
  11087. // SetActionMessage sets the "action_message" field.
  11088. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  11089. m.action_message = &ct
  11090. m.appendaction_message = nil
  11091. }
  11092. // ActionMessage returns the value of the "action_message" field in the mutation.
  11093. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  11094. v := m.action_message
  11095. if v == nil {
  11096. return
  11097. }
  11098. return *v, true
  11099. }
  11100. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  11101. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11103. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  11104. if !m.op.Is(OpUpdateOne) {
  11105. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  11106. }
  11107. if m.id == nil || m.oldValue == nil {
  11108. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  11109. }
  11110. oldValue, err := m.oldValue(ctx)
  11111. if err != nil {
  11112. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  11113. }
  11114. return oldValue.ActionMessage, nil
  11115. }
  11116. // AppendActionMessage adds ct to the "action_message" field.
  11117. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  11118. m.appendaction_message = append(m.appendaction_message, ct...)
  11119. }
  11120. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  11121. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  11122. if len(m.appendaction_message) == 0 {
  11123. return nil, false
  11124. }
  11125. return m.appendaction_message, true
  11126. }
  11127. // ClearActionMessage clears the value of the "action_message" field.
  11128. func (m *SopStageMutation) ClearActionMessage() {
  11129. m.action_message = nil
  11130. m.appendaction_message = nil
  11131. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  11132. }
  11133. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  11134. func (m *SopStageMutation) ActionMessageCleared() bool {
  11135. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  11136. return ok
  11137. }
  11138. // ResetActionMessage resets all changes to the "action_message" field.
  11139. func (m *SopStageMutation) ResetActionMessage() {
  11140. m.action_message = nil
  11141. m.appendaction_message = nil
  11142. delete(m.clearedFields, sopstage.FieldActionMessage)
  11143. }
  11144. // SetActionLabel sets the "action_label" field.
  11145. func (m *SopStageMutation) SetActionLabel(u []uint64) {
  11146. m.action_label = &u
  11147. m.appendaction_label = nil
  11148. }
  11149. // ActionLabel returns the value of the "action_label" field in the mutation.
  11150. func (m *SopStageMutation) ActionLabel() (r []uint64, exists bool) {
  11151. v := m.action_label
  11152. if v == nil {
  11153. return
  11154. }
  11155. return *v, true
  11156. }
  11157. // OldActionLabel returns the old "action_label" field's value of the SopStage entity.
  11158. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11160. func (m *SopStageMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  11161. if !m.op.Is(OpUpdateOne) {
  11162. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  11163. }
  11164. if m.id == nil || m.oldValue == nil {
  11165. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  11166. }
  11167. oldValue, err := m.oldValue(ctx)
  11168. if err != nil {
  11169. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  11170. }
  11171. return oldValue.ActionLabel, nil
  11172. }
  11173. // AppendActionLabel adds u to the "action_label" field.
  11174. func (m *SopStageMutation) AppendActionLabel(u []uint64) {
  11175. m.appendaction_label = append(m.appendaction_label, u...)
  11176. }
  11177. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  11178. func (m *SopStageMutation) AppendedActionLabel() ([]uint64, bool) {
  11179. if len(m.appendaction_label) == 0 {
  11180. return nil, false
  11181. }
  11182. return m.appendaction_label, true
  11183. }
  11184. // ClearActionLabel clears the value of the "action_label" field.
  11185. func (m *SopStageMutation) ClearActionLabel() {
  11186. m.action_label = nil
  11187. m.appendaction_label = nil
  11188. m.clearedFields[sopstage.FieldActionLabel] = struct{}{}
  11189. }
  11190. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  11191. func (m *SopStageMutation) ActionLabelCleared() bool {
  11192. _, ok := m.clearedFields[sopstage.FieldActionLabel]
  11193. return ok
  11194. }
  11195. // ResetActionLabel resets all changes to the "action_label" field.
  11196. func (m *SopStageMutation) ResetActionLabel() {
  11197. m.action_label = nil
  11198. m.appendaction_label = nil
  11199. delete(m.clearedFields, sopstage.FieldActionLabel)
  11200. }
  11201. // SetIndexSort sets the "index_sort" field.
  11202. func (m *SopStageMutation) SetIndexSort(i int) {
  11203. m.index_sort = &i
  11204. m.addindex_sort = nil
  11205. }
  11206. // IndexSort returns the value of the "index_sort" field in the mutation.
  11207. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  11208. v := m.index_sort
  11209. if v == nil {
  11210. return
  11211. }
  11212. return *v, true
  11213. }
  11214. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  11215. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11216. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11217. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  11218. if !m.op.Is(OpUpdateOne) {
  11219. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  11220. }
  11221. if m.id == nil || m.oldValue == nil {
  11222. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  11223. }
  11224. oldValue, err := m.oldValue(ctx)
  11225. if err != nil {
  11226. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  11227. }
  11228. return oldValue.IndexSort, nil
  11229. }
  11230. // AddIndexSort adds i to the "index_sort" field.
  11231. func (m *SopStageMutation) AddIndexSort(i int) {
  11232. if m.addindex_sort != nil {
  11233. *m.addindex_sort += i
  11234. } else {
  11235. m.addindex_sort = &i
  11236. }
  11237. }
  11238. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  11239. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  11240. v := m.addindex_sort
  11241. if v == nil {
  11242. return
  11243. }
  11244. return *v, true
  11245. }
  11246. // ClearIndexSort clears the value of the "index_sort" field.
  11247. func (m *SopStageMutation) ClearIndexSort() {
  11248. m.index_sort = nil
  11249. m.addindex_sort = nil
  11250. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  11251. }
  11252. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  11253. func (m *SopStageMutation) IndexSortCleared() bool {
  11254. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  11255. return ok
  11256. }
  11257. // ResetIndexSort resets all changes to the "index_sort" field.
  11258. func (m *SopStageMutation) ResetIndexSort() {
  11259. m.index_sort = nil
  11260. m.addindex_sort = nil
  11261. delete(m.clearedFields, sopstage.FieldIndexSort)
  11262. }
  11263. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  11264. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  11265. m.sop_task = &id
  11266. }
  11267. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  11268. func (m *SopStageMutation) ClearSopTask() {
  11269. m.clearedsop_task = true
  11270. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  11271. }
  11272. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  11273. func (m *SopStageMutation) SopTaskCleared() bool {
  11274. return m.clearedsop_task
  11275. }
  11276. // SopTaskID returns the "sop_task" edge ID in the mutation.
  11277. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  11278. if m.sop_task != nil {
  11279. return *m.sop_task, true
  11280. }
  11281. return
  11282. }
  11283. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  11284. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  11285. // SopTaskID instead. It exists only for internal usage by the builders.
  11286. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  11287. if id := m.sop_task; id != nil {
  11288. ids = append(ids, *id)
  11289. }
  11290. return
  11291. }
  11292. // ResetSopTask resets all changes to the "sop_task" edge.
  11293. func (m *SopStageMutation) ResetSopTask() {
  11294. m.sop_task = nil
  11295. m.clearedsop_task = false
  11296. }
  11297. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  11298. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  11299. if m.stage_nodes == nil {
  11300. m.stage_nodes = make(map[uint64]struct{})
  11301. }
  11302. for i := range ids {
  11303. m.stage_nodes[ids[i]] = struct{}{}
  11304. }
  11305. }
  11306. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  11307. func (m *SopStageMutation) ClearStageNodes() {
  11308. m.clearedstage_nodes = true
  11309. }
  11310. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  11311. func (m *SopStageMutation) StageNodesCleared() bool {
  11312. return m.clearedstage_nodes
  11313. }
  11314. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  11315. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  11316. if m.removedstage_nodes == nil {
  11317. m.removedstage_nodes = make(map[uint64]struct{})
  11318. }
  11319. for i := range ids {
  11320. delete(m.stage_nodes, ids[i])
  11321. m.removedstage_nodes[ids[i]] = struct{}{}
  11322. }
  11323. }
  11324. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  11325. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  11326. for id := range m.removedstage_nodes {
  11327. ids = append(ids, id)
  11328. }
  11329. return
  11330. }
  11331. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  11332. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  11333. for id := range m.stage_nodes {
  11334. ids = append(ids, id)
  11335. }
  11336. return
  11337. }
  11338. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  11339. func (m *SopStageMutation) ResetStageNodes() {
  11340. m.stage_nodes = nil
  11341. m.clearedstage_nodes = false
  11342. m.removedstage_nodes = nil
  11343. }
  11344. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  11345. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  11346. if m.stage_messages == nil {
  11347. m.stage_messages = make(map[uint64]struct{})
  11348. }
  11349. for i := range ids {
  11350. m.stage_messages[ids[i]] = struct{}{}
  11351. }
  11352. }
  11353. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  11354. func (m *SopStageMutation) ClearStageMessages() {
  11355. m.clearedstage_messages = true
  11356. }
  11357. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  11358. func (m *SopStageMutation) StageMessagesCleared() bool {
  11359. return m.clearedstage_messages
  11360. }
  11361. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  11362. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  11363. if m.removedstage_messages == nil {
  11364. m.removedstage_messages = make(map[uint64]struct{})
  11365. }
  11366. for i := range ids {
  11367. delete(m.stage_messages, ids[i])
  11368. m.removedstage_messages[ids[i]] = struct{}{}
  11369. }
  11370. }
  11371. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  11372. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  11373. for id := range m.removedstage_messages {
  11374. ids = append(ids, id)
  11375. }
  11376. return
  11377. }
  11378. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  11379. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  11380. for id := range m.stage_messages {
  11381. ids = append(ids, id)
  11382. }
  11383. return
  11384. }
  11385. // ResetStageMessages resets all changes to the "stage_messages" edge.
  11386. func (m *SopStageMutation) ResetStageMessages() {
  11387. m.stage_messages = nil
  11388. m.clearedstage_messages = false
  11389. m.removedstage_messages = nil
  11390. }
  11391. // Where appends a list predicates to the SopStageMutation builder.
  11392. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  11393. m.predicates = append(m.predicates, ps...)
  11394. }
  11395. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  11396. // users can use type-assertion to append predicates that do not depend on any generated package.
  11397. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  11398. p := make([]predicate.SopStage, len(ps))
  11399. for i := range ps {
  11400. p[i] = ps[i]
  11401. }
  11402. m.Where(p...)
  11403. }
  11404. // Op returns the operation name.
  11405. func (m *SopStageMutation) Op() Op {
  11406. return m.op
  11407. }
  11408. // SetOp allows setting the mutation operation.
  11409. func (m *SopStageMutation) SetOp(op Op) {
  11410. m.op = op
  11411. }
  11412. // Type returns the node type of this mutation (SopStage).
  11413. func (m *SopStageMutation) Type() string {
  11414. return m.typ
  11415. }
  11416. // Fields returns all fields that were changed during this mutation. Note that in
  11417. // order to get all numeric fields that were incremented/decremented, call
  11418. // AddedFields().
  11419. func (m *SopStageMutation) Fields() []string {
  11420. fields := make([]string, 0, 12)
  11421. if m.created_at != nil {
  11422. fields = append(fields, sopstage.FieldCreatedAt)
  11423. }
  11424. if m.updated_at != nil {
  11425. fields = append(fields, sopstage.FieldUpdatedAt)
  11426. }
  11427. if m.status != nil {
  11428. fields = append(fields, sopstage.FieldStatus)
  11429. }
  11430. if m.deleted_at != nil {
  11431. fields = append(fields, sopstage.FieldDeletedAt)
  11432. }
  11433. if m.sop_task != nil {
  11434. fields = append(fields, sopstage.FieldTaskID)
  11435. }
  11436. if m.name != nil {
  11437. fields = append(fields, sopstage.FieldName)
  11438. }
  11439. if m.condition_type != nil {
  11440. fields = append(fields, sopstage.FieldConditionType)
  11441. }
  11442. if m.condition_operator != nil {
  11443. fields = append(fields, sopstage.FieldConditionOperator)
  11444. }
  11445. if m.condition_list != nil {
  11446. fields = append(fields, sopstage.FieldConditionList)
  11447. }
  11448. if m.action_message != nil {
  11449. fields = append(fields, sopstage.FieldActionMessage)
  11450. }
  11451. if m.action_label != nil {
  11452. fields = append(fields, sopstage.FieldActionLabel)
  11453. }
  11454. if m.index_sort != nil {
  11455. fields = append(fields, sopstage.FieldIndexSort)
  11456. }
  11457. return fields
  11458. }
  11459. // Field returns the value of a field with the given name. The second boolean
  11460. // return value indicates that this field was not set, or was not defined in the
  11461. // schema.
  11462. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  11463. switch name {
  11464. case sopstage.FieldCreatedAt:
  11465. return m.CreatedAt()
  11466. case sopstage.FieldUpdatedAt:
  11467. return m.UpdatedAt()
  11468. case sopstage.FieldStatus:
  11469. return m.Status()
  11470. case sopstage.FieldDeletedAt:
  11471. return m.DeletedAt()
  11472. case sopstage.FieldTaskID:
  11473. return m.TaskID()
  11474. case sopstage.FieldName:
  11475. return m.Name()
  11476. case sopstage.FieldConditionType:
  11477. return m.ConditionType()
  11478. case sopstage.FieldConditionOperator:
  11479. return m.ConditionOperator()
  11480. case sopstage.FieldConditionList:
  11481. return m.ConditionList()
  11482. case sopstage.FieldActionMessage:
  11483. return m.ActionMessage()
  11484. case sopstage.FieldActionLabel:
  11485. return m.ActionLabel()
  11486. case sopstage.FieldIndexSort:
  11487. return m.IndexSort()
  11488. }
  11489. return nil, false
  11490. }
  11491. // OldField returns the old value of the field from the database. An error is
  11492. // returned if the mutation operation is not UpdateOne, or the query to the
  11493. // database failed.
  11494. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11495. switch name {
  11496. case sopstage.FieldCreatedAt:
  11497. return m.OldCreatedAt(ctx)
  11498. case sopstage.FieldUpdatedAt:
  11499. return m.OldUpdatedAt(ctx)
  11500. case sopstage.FieldStatus:
  11501. return m.OldStatus(ctx)
  11502. case sopstage.FieldDeletedAt:
  11503. return m.OldDeletedAt(ctx)
  11504. case sopstage.FieldTaskID:
  11505. return m.OldTaskID(ctx)
  11506. case sopstage.FieldName:
  11507. return m.OldName(ctx)
  11508. case sopstage.FieldConditionType:
  11509. return m.OldConditionType(ctx)
  11510. case sopstage.FieldConditionOperator:
  11511. return m.OldConditionOperator(ctx)
  11512. case sopstage.FieldConditionList:
  11513. return m.OldConditionList(ctx)
  11514. case sopstage.FieldActionMessage:
  11515. return m.OldActionMessage(ctx)
  11516. case sopstage.FieldActionLabel:
  11517. return m.OldActionLabel(ctx)
  11518. case sopstage.FieldIndexSort:
  11519. return m.OldIndexSort(ctx)
  11520. }
  11521. return nil, fmt.Errorf("unknown SopStage field %s", name)
  11522. }
  11523. // SetField sets the value of a field with the given name. It returns an error if
  11524. // the field is not defined in the schema, or if the type mismatched the field
  11525. // type.
  11526. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  11527. switch name {
  11528. case sopstage.FieldCreatedAt:
  11529. v, ok := value.(time.Time)
  11530. if !ok {
  11531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11532. }
  11533. m.SetCreatedAt(v)
  11534. return nil
  11535. case sopstage.FieldUpdatedAt:
  11536. v, ok := value.(time.Time)
  11537. if !ok {
  11538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11539. }
  11540. m.SetUpdatedAt(v)
  11541. return nil
  11542. case sopstage.FieldStatus:
  11543. v, ok := value.(uint8)
  11544. if !ok {
  11545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11546. }
  11547. m.SetStatus(v)
  11548. return nil
  11549. case sopstage.FieldDeletedAt:
  11550. v, ok := value.(time.Time)
  11551. if !ok {
  11552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11553. }
  11554. m.SetDeletedAt(v)
  11555. return nil
  11556. case sopstage.FieldTaskID:
  11557. v, ok := value.(uint64)
  11558. if !ok {
  11559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11560. }
  11561. m.SetTaskID(v)
  11562. return nil
  11563. case sopstage.FieldName:
  11564. v, ok := value.(string)
  11565. if !ok {
  11566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11567. }
  11568. m.SetName(v)
  11569. return nil
  11570. case sopstage.FieldConditionType:
  11571. v, ok := value.(int)
  11572. if !ok {
  11573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11574. }
  11575. m.SetConditionType(v)
  11576. return nil
  11577. case sopstage.FieldConditionOperator:
  11578. v, ok := value.(int)
  11579. if !ok {
  11580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11581. }
  11582. m.SetConditionOperator(v)
  11583. return nil
  11584. case sopstage.FieldConditionList:
  11585. v, ok := value.([]custom_types.Condition)
  11586. if !ok {
  11587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11588. }
  11589. m.SetConditionList(v)
  11590. return nil
  11591. case sopstage.FieldActionMessage:
  11592. v, ok := value.([]custom_types.Action)
  11593. if !ok {
  11594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11595. }
  11596. m.SetActionMessage(v)
  11597. return nil
  11598. case sopstage.FieldActionLabel:
  11599. v, ok := value.([]uint64)
  11600. if !ok {
  11601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11602. }
  11603. m.SetActionLabel(v)
  11604. return nil
  11605. case sopstage.FieldIndexSort:
  11606. v, ok := value.(int)
  11607. if !ok {
  11608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11609. }
  11610. m.SetIndexSort(v)
  11611. return nil
  11612. }
  11613. return fmt.Errorf("unknown SopStage field %s", name)
  11614. }
  11615. // AddedFields returns all numeric fields that were incremented/decremented during
  11616. // this mutation.
  11617. func (m *SopStageMutation) AddedFields() []string {
  11618. var fields []string
  11619. if m.addstatus != nil {
  11620. fields = append(fields, sopstage.FieldStatus)
  11621. }
  11622. if m.addcondition_type != nil {
  11623. fields = append(fields, sopstage.FieldConditionType)
  11624. }
  11625. if m.addcondition_operator != nil {
  11626. fields = append(fields, sopstage.FieldConditionOperator)
  11627. }
  11628. if m.addindex_sort != nil {
  11629. fields = append(fields, sopstage.FieldIndexSort)
  11630. }
  11631. return fields
  11632. }
  11633. // AddedField returns the numeric value that was incremented/decremented on a field
  11634. // with the given name. The second boolean return value indicates that this field
  11635. // was not set, or was not defined in the schema.
  11636. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  11637. switch name {
  11638. case sopstage.FieldStatus:
  11639. return m.AddedStatus()
  11640. case sopstage.FieldConditionType:
  11641. return m.AddedConditionType()
  11642. case sopstage.FieldConditionOperator:
  11643. return m.AddedConditionOperator()
  11644. case sopstage.FieldIndexSort:
  11645. return m.AddedIndexSort()
  11646. }
  11647. return nil, false
  11648. }
  11649. // AddField adds the value to the field with the given name. It returns an error if
  11650. // the field is not defined in the schema, or if the type mismatched the field
  11651. // type.
  11652. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  11653. switch name {
  11654. case sopstage.FieldStatus:
  11655. v, ok := value.(int8)
  11656. if !ok {
  11657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11658. }
  11659. m.AddStatus(v)
  11660. return nil
  11661. case sopstage.FieldConditionType:
  11662. v, ok := value.(int)
  11663. if !ok {
  11664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11665. }
  11666. m.AddConditionType(v)
  11667. return nil
  11668. case sopstage.FieldConditionOperator:
  11669. v, ok := value.(int)
  11670. if !ok {
  11671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11672. }
  11673. m.AddConditionOperator(v)
  11674. return nil
  11675. case sopstage.FieldIndexSort:
  11676. v, ok := value.(int)
  11677. if !ok {
  11678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11679. }
  11680. m.AddIndexSort(v)
  11681. return nil
  11682. }
  11683. return fmt.Errorf("unknown SopStage numeric field %s", name)
  11684. }
  11685. // ClearedFields returns all nullable fields that were cleared during this
  11686. // mutation.
  11687. func (m *SopStageMutation) ClearedFields() []string {
  11688. var fields []string
  11689. if m.FieldCleared(sopstage.FieldStatus) {
  11690. fields = append(fields, sopstage.FieldStatus)
  11691. }
  11692. if m.FieldCleared(sopstage.FieldDeletedAt) {
  11693. fields = append(fields, sopstage.FieldDeletedAt)
  11694. }
  11695. if m.FieldCleared(sopstage.FieldActionMessage) {
  11696. fields = append(fields, sopstage.FieldActionMessage)
  11697. }
  11698. if m.FieldCleared(sopstage.FieldActionLabel) {
  11699. fields = append(fields, sopstage.FieldActionLabel)
  11700. }
  11701. if m.FieldCleared(sopstage.FieldIndexSort) {
  11702. fields = append(fields, sopstage.FieldIndexSort)
  11703. }
  11704. return fields
  11705. }
  11706. // FieldCleared returns a boolean indicating if a field with the given name was
  11707. // cleared in this mutation.
  11708. func (m *SopStageMutation) FieldCleared(name string) bool {
  11709. _, ok := m.clearedFields[name]
  11710. return ok
  11711. }
  11712. // ClearField clears the value of the field with the given name. It returns an
  11713. // error if the field is not defined in the schema.
  11714. func (m *SopStageMutation) ClearField(name string) error {
  11715. switch name {
  11716. case sopstage.FieldStatus:
  11717. m.ClearStatus()
  11718. return nil
  11719. case sopstage.FieldDeletedAt:
  11720. m.ClearDeletedAt()
  11721. return nil
  11722. case sopstage.FieldActionMessage:
  11723. m.ClearActionMessage()
  11724. return nil
  11725. case sopstage.FieldActionLabel:
  11726. m.ClearActionLabel()
  11727. return nil
  11728. case sopstage.FieldIndexSort:
  11729. m.ClearIndexSort()
  11730. return nil
  11731. }
  11732. return fmt.Errorf("unknown SopStage nullable field %s", name)
  11733. }
  11734. // ResetField resets all changes in the mutation for the field with the given name.
  11735. // It returns an error if the field is not defined in the schema.
  11736. func (m *SopStageMutation) ResetField(name string) error {
  11737. switch name {
  11738. case sopstage.FieldCreatedAt:
  11739. m.ResetCreatedAt()
  11740. return nil
  11741. case sopstage.FieldUpdatedAt:
  11742. m.ResetUpdatedAt()
  11743. return nil
  11744. case sopstage.FieldStatus:
  11745. m.ResetStatus()
  11746. return nil
  11747. case sopstage.FieldDeletedAt:
  11748. m.ResetDeletedAt()
  11749. return nil
  11750. case sopstage.FieldTaskID:
  11751. m.ResetTaskID()
  11752. return nil
  11753. case sopstage.FieldName:
  11754. m.ResetName()
  11755. return nil
  11756. case sopstage.FieldConditionType:
  11757. m.ResetConditionType()
  11758. return nil
  11759. case sopstage.FieldConditionOperator:
  11760. m.ResetConditionOperator()
  11761. return nil
  11762. case sopstage.FieldConditionList:
  11763. m.ResetConditionList()
  11764. return nil
  11765. case sopstage.FieldActionMessage:
  11766. m.ResetActionMessage()
  11767. return nil
  11768. case sopstage.FieldActionLabel:
  11769. m.ResetActionLabel()
  11770. return nil
  11771. case sopstage.FieldIndexSort:
  11772. m.ResetIndexSort()
  11773. return nil
  11774. }
  11775. return fmt.Errorf("unknown SopStage field %s", name)
  11776. }
  11777. // AddedEdges returns all edge names that were set/added in this mutation.
  11778. func (m *SopStageMutation) AddedEdges() []string {
  11779. edges := make([]string, 0, 3)
  11780. if m.sop_task != nil {
  11781. edges = append(edges, sopstage.EdgeSopTask)
  11782. }
  11783. if m.stage_nodes != nil {
  11784. edges = append(edges, sopstage.EdgeStageNodes)
  11785. }
  11786. if m.stage_messages != nil {
  11787. edges = append(edges, sopstage.EdgeStageMessages)
  11788. }
  11789. return edges
  11790. }
  11791. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11792. // name in this mutation.
  11793. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  11794. switch name {
  11795. case sopstage.EdgeSopTask:
  11796. if id := m.sop_task; id != nil {
  11797. return []ent.Value{*id}
  11798. }
  11799. case sopstage.EdgeStageNodes:
  11800. ids := make([]ent.Value, 0, len(m.stage_nodes))
  11801. for id := range m.stage_nodes {
  11802. ids = append(ids, id)
  11803. }
  11804. return ids
  11805. case sopstage.EdgeStageMessages:
  11806. ids := make([]ent.Value, 0, len(m.stage_messages))
  11807. for id := range m.stage_messages {
  11808. ids = append(ids, id)
  11809. }
  11810. return ids
  11811. }
  11812. return nil
  11813. }
  11814. // RemovedEdges returns all edge names that were removed in this mutation.
  11815. func (m *SopStageMutation) RemovedEdges() []string {
  11816. edges := make([]string, 0, 3)
  11817. if m.removedstage_nodes != nil {
  11818. edges = append(edges, sopstage.EdgeStageNodes)
  11819. }
  11820. if m.removedstage_messages != nil {
  11821. edges = append(edges, sopstage.EdgeStageMessages)
  11822. }
  11823. return edges
  11824. }
  11825. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11826. // the given name in this mutation.
  11827. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  11828. switch name {
  11829. case sopstage.EdgeStageNodes:
  11830. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  11831. for id := range m.removedstage_nodes {
  11832. ids = append(ids, id)
  11833. }
  11834. return ids
  11835. case sopstage.EdgeStageMessages:
  11836. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  11837. for id := range m.removedstage_messages {
  11838. ids = append(ids, id)
  11839. }
  11840. return ids
  11841. }
  11842. return nil
  11843. }
  11844. // ClearedEdges returns all edge names that were cleared in this mutation.
  11845. func (m *SopStageMutation) ClearedEdges() []string {
  11846. edges := make([]string, 0, 3)
  11847. if m.clearedsop_task {
  11848. edges = append(edges, sopstage.EdgeSopTask)
  11849. }
  11850. if m.clearedstage_nodes {
  11851. edges = append(edges, sopstage.EdgeStageNodes)
  11852. }
  11853. if m.clearedstage_messages {
  11854. edges = append(edges, sopstage.EdgeStageMessages)
  11855. }
  11856. return edges
  11857. }
  11858. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11859. // was cleared in this mutation.
  11860. func (m *SopStageMutation) EdgeCleared(name string) bool {
  11861. switch name {
  11862. case sopstage.EdgeSopTask:
  11863. return m.clearedsop_task
  11864. case sopstage.EdgeStageNodes:
  11865. return m.clearedstage_nodes
  11866. case sopstage.EdgeStageMessages:
  11867. return m.clearedstage_messages
  11868. }
  11869. return false
  11870. }
  11871. // ClearEdge clears the value of the edge with the given name. It returns an error
  11872. // if that edge is not defined in the schema.
  11873. func (m *SopStageMutation) ClearEdge(name string) error {
  11874. switch name {
  11875. case sopstage.EdgeSopTask:
  11876. m.ClearSopTask()
  11877. return nil
  11878. }
  11879. return fmt.Errorf("unknown SopStage unique edge %s", name)
  11880. }
  11881. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11882. // It returns an error if the edge is not defined in the schema.
  11883. func (m *SopStageMutation) ResetEdge(name string) error {
  11884. switch name {
  11885. case sopstage.EdgeSopTask:
  11886. m.ResetSopTask()
  11887. return nil
  11888. case sopstage.EdgeStageNodes:
  11889. m.ResetStageNodes()
  11890. return nil
  11891. case sopstage.EdgeStageMessages:
  11892. m.ResetStageMessages()
  11893. return nil
  11894. }
  11895. return fmt.Errorf("unknown SopStage edge %s", name)
  11896. }
  11897. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  11898. type SopTaskMutation struct {
  11899. config
  11900. op Op
  11901. typ string
  11902. id *uint64
  11903. created_at *time.Time
  11904. updated_at *time.Time
  11905. status *uint8
  11906. addstatus *int8
  11907. deleted_at *time.Time
  11908. name *string
  11909. bot_wxid_list *[]string
  11910. appendbot_wxid_list []string
  11911. _type *int
  11912. add_type *int
  11913. plan_start_time *time.Time
  11914. plan_end_time *time.Time
  11915. creator_id *string
  11916. organization_id *uint64
  11917. addorganization_id *int64
  11918. clearedFields map[string]struct{}
  11919. task_stages map[uint64]struct{}
  11920. removedtask_stages map[uint64]struct{}
  11921. clearedtask_stages bool
  11922. done bool
  11923. oldValue func(context.Context) (*SopTask, error)
  11924. predicates []predicate.SopTask
  11925. }
  11926. var _ ent.Mutation = (*SopTaskMutation)(nil)
  11927. // soptaskOption allows management of the mutation configuration using functional options.
  11928. type soptaskOption func(*SopTaskMutation)
  11929. // newSopTaskMutation creates new mutation for the SopTask entity.
  11930. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  11931. m := &SopTaskMutation{
  11932. config: c,
  11933. op: op,
  11934. typ: TypeSopTask,
  11935. clearedFields: make(map[string]struct{}),
  11936. }
  11937. for _, opt := range opts {
  11938. opt(m)
  11939. }
  11940. return m
  11941. }
  11942. // withSopTaskID sets the ID field of the mutation.
  11943. func withSopTaskID(id uint64) soptaskOption {
  11944. return func(m *SopTaskMutation) {
  11945. var (
  11946. err error
  11947. once sync.Once
  11948. value *SopTask
  11949. )
  11950. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  11951. once.Do(func() {
  11952. if m.done {
  11953. err = errors.New("querying old values post mutation is not allowed")
  11954. } else {
  11955. value, err = m.Client().SopTask.Get(ctx, id)
  11956. }
  11957. })
  11958. return value, err
  11959. }
  11960. m.id = &id
  11961. }
  11962. }
  11963. // withSopTask sets the old SopTask of the mutation.
  11964. func withSopTask(node *SopTask) soptaskOption {
  11965. return func(m *SopTaskMutation) {
  11966. m.oldValue = func(context.Context) (*SopTask, error) {
  11967. return node, nil
  11968. }
  11969. m.id = &node.ID
  11970. }
  11971. }
  11972. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11973. // executed in a transaction (ent.Tx), a transactional client is returned.
  11974. func (m SopTaskMutation) Client() *Client {
  11975. client := &Client{config: m.config}
  11976. client.init()
  11977. return client
  11978. }
  11979. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11980. // it returns an error otherwise.
  11981. func (m SopTaskMutation) Tx() (*Tx, error) {
  11982. if _, ok := m.driver.(*txDriver); !ok {
  11983. return nil, errors.New("ent: mutation is not running in a transaction")
  11984. }
  11985. tx := &Tx{config: m.config}
  11986. tx.init()
  11987. return tx, nil
  11988. }
  11989. // SetID sets the value of the id field. Note that this
  11990. // operation is only accepted on creation of SopTask entities.
  11991. func (m *SopTaskMutation) SetID(id uint64) {
  11992. m.id = &id
  11993. }
  11994. // ID returns the ID value in the mutation. Note that the ID is only available
  11995. // if it was provided to the builder or after it was returned from the database.
  11996. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  11997. if m.id == nil {
  11998. return
  11999. }
  12000. return *m.id, true
  12001. }
  12002. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12003. // That means, if the mutation is applied within a transaction with an isolation level such
  12004. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12005. // or updated by the mutation.
  12006. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  12007. switch {
  12008. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12009. id, exists := m.ID()
  12010. if exists {
  12011. return []uint64{id}, nil
  12012. }
  12013. fallthrough
  12014. case m.op.Is(OpUpdate | OpDelete):
  12015. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  12016. default:
  12017. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12018. }
  12019. }
  12020. // SetCreatedAt sets the "created_at" field.
  12021. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  12022. m.created_at = &t
  12023. }
  12024. // CreatedAt returns the value of the "created_at" field in the mutation.
  12025. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  12026. v := m.created_at
  12027. if v == nil {
  12028. return
  12029. }
  12030. return *v, true
  12031. }
  12032. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  12033. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12035. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12036. if !m.op.Is(OpUpdateOne) {
  12037. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12038. }
  12039. if m.id == nil || m.oldValue == nil {
  12040. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12041. }
  12042. oldValue, err := m.oldValue(ctx)
  12043. if err != nil {
  12044. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12045. }
  12046. return oldValue.CreatedAt, nil
  12047. }
  12048. // ResetCreatedAt resets all changes to the "created_at" field.
  12049. func (m *SopTaskMutation) ResetCreatedAt() {
  12050. m.created_at = nil
  12051. }
  12052. // SetUpdatedAt sets the "updated_at" field.
  12053. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  12054. m.updated_at = &t
  12055. }
  12056. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12057. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  12058. v := m.updated_at
  12059. if v == nil {
  12060. return
  12061. }
  12062. return *v, true
  12063. }
  12064. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  12065. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12066. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12067. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12068. if !m.op.Is(OpUpdateOne) {
  12069. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12070. }
  12071. if m.id == nil || m.oldValue == nil {
  12072. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12073. }
  12074. oldValue, err := m.oldValue(ctx)
  12075. if err != nil {
  12076. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12077. }
  12078. return oldValue.UpdatedAt, nil
  12079. }
  12080. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12081. func (m *SopTaskMutation) ResetUpdatedAt() {
  12082. m.updated_at = nil
  12083. }
  12084. // SetStatus sets the "status" field.
  12085. func (m *SopTaskMutation) SetStatus(u uint8) {
  12086. m.status = &u
  12087. m.addstatus = nil
  12088. }
  12089. // Status returns the value of the "status" field in the mutation.
  12090. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  12091. v := m.status
  12092. if v == nil {
  12093. return
  12094. }
  12095. return *v, true
  12096. }
  12097. // OldStatus returns the old "status" field's value of the SopTask entity.
  12098. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12099. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12100. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12101. if !m.op.Is(OpUpdateOne) {
  12102. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12103. }
  12104. if m.id == nil || m.oldValue == nil {
  12105. return v, errors.New("OldStatus requires an ID field in the mutation")
  12106. }
  12107. oldValue, err := m.oldValue(ctx)
  12108. if err != nil {
  12109. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12110. }
  12111. return oldValue.Status, nil
  12112. }
  12113. // AddStatus adds u to the "status" field.
  12114. func (m *SopTaskMutation) AddStatus(u int8) {
  12115. if m.addstatus != nil {
  12116. *m.addstatus += u
  12117. } else {
  12118. m.addstatus = &u
  12119. }
  12120. }
  12121. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12122. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  12123. v := m.addstatus
  12124. if v == nil {
  12125. return
  12126. }
  12127. return *v, true
  12128. }
  12129. // ClearStatus clears the value of the "status" field.
  12130. func (m *SopTaskMutation) ClearStatus() {
  12131. m.status = nil
  12132. m.addstatus = nil
  12133. m.clearedFields[soptask.FieldStatus] = struct{}{}
  12134. }
  12135. // StatusCleared returns if the "status" field was cleared in this mutation.
  12136. func (m *SopTaskMutation) StatusCleared() bool {
  12137. _, ok := m.clearedFields[soptask.FieldStatus]
  12138. return ok
  12139. }
  12140. // ResetStatus resets all changes to the "status" field.
  12141. func (m *SopTaskMutation) ResetStatus() {
  12142. m.status = nil
  12143. m.addstatus = nil
  12144. delete(m.clearedFields, soptask.FieldStatus)
  12145. }
  12146. // SetDeletedAt sets the "deleted_at" field.
  12147. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  12148. m.deleted_at = &t
  12149. }
  12150. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12151. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  12152. v := m.deleted_at
  12153. if v == nil {
  12154. return
  12155. }
  12156. return *v, true
  12157. }
  12158. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  12159. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12160. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12161. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12162. if !m.op.Is(OpUpdateOne) {
  12163. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12164. }
  12165. if m.id == nil || m.oldValue == nil {
  12166. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12167. }
  12168. oldValue, err := m.oldValue(ctx)
  12169. if err != nil {
  12170. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12171. }
  12172. return oldValue.DeletedAt, nil
  12173. }
  12174. // ClearDeletedAt clears the value of the "deleted_at" field.
  12175. func (m *SopTaskMutation) ClearDeletedAt() {
  12176. m.deleted_at = nil
  12177. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  12178. }
  12179. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12180. func (m *SopTaskMutation) DeletedAtCleared() bool {
  12181. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  12182. return ok
  12183. }
  12184. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12185. func (m *SopTaskMutation) ResetDeletedAt() {
  12186. m.deleted_at = nil
  12187. delete(m.clearedFields, soptask.FieldDeletedAt)
  12188. }
  12189. // SetName sets the "name" field.
  12190. func (m *SopTaskMutation) SetName(s string) {
  12191. m.name = &s
  12192. }
  12193. // Name returns the value of the "name" field in the mutation.
  12194. func (m *SopTaskMutation) Name() (r string, exists bool) {
  12195. v := m.name
  12196. if v == nil {
  12197. return
  12198. }
  12199. return *v, true
  12200. }
  12201. // OldName returns the old "name" field's value of the SopTask entity.
  12202. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12204. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  12205. if !m.op.Is(OpUpdateOne) {
  12206. return v, errors.New("OldName is only allowed on UpdateOne operations")
  12207. }
  12208. if m.id == nil || m.oldValue == nil {
  12209. return v, errors.New("OldName requires an ID field in the mutation")
  12210. }
  12211. oldValue, err := m.oldValue(ctx)
  12212. if err != nil {
  12213. return v, fmt.Errorf("querying old value for OldName: %w", err)
  12214. }
  12215. return oldValue.Name, nil
  12216. }
  12217. // ResetName resets all changes to the "name" field.
  12218. func (m *SopTaskMutation) ResetName() {
  12219. m.name = nil
  12220. }
  12221. // SetBotWxidList sets the "bot_wxid_list" field.
  12222. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  12223. m.bot_wxid_list = &s
  12224. m.appendbot_wxid_list = nil
  12225. }
  12226. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  12227. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  12228. v := m.bot_wxid_list
  12229. if v == nil {
  12230. return
  12231. }
  12232. return *v, true
  12233. }
  12234. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  12235. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12237. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  12238. if !m.op.Is(OpUpdateOne) {
  12239. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  12240. }
  12241. if m.id == nil || m.oldValue == nil {
  12242. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  12243. }
  12244. oldValue, err := m.oldValue(ctx)
  12245. if err != nil {
  12246. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  12247. }
  12248. return oldValue.BotWxidList, nil
  12249. }
  12250. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  12251. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  12252. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  12253. }
  12254. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  12255. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  12256. if len(m.appendbot_wxid_list) == 0 {
  12257. return nil, false
  12258. }
  12259. return m.appendbot_wxid_list, true
  12260. }
  12261. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  12262. func (m *SopTaskMutation) ClearBotWxidList() {
  12263. m.bot_wxid_list = nil
  12264. m.appendbot_wxid_list = nil
  12265. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  12266. }
  12267. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  12268. func (m *SopTaskMutation) BotWxidListCleared() bool {
  12269. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  12270. return ok
  12271. }
  12272. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  12273. func (m *SopTaskMutation) ResetBotWxidList() {
  12274. m.bot_wxid_list = nil
  12275. m.appendbot_wxid_list = nil
  12276. delete(m.clearedFields, soptask.FieldBotWxidList)
  12277. }
  12278. // SetType sets the "type" field.
  12279. func (m *SopTaskMutation) SetType(i int) {
  12280. m._type = &i
  12281. m.add_type = nil
  12282. }
  12283. // GetType returns the value of the "type" field in the mutation.
  12284. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  12285. v := m._type
  12286. if v == nil {
  12287. return
  12288. }
  12289. return *v, true
  12290. }
  12291. // OldType returns the old "type" field's value of the SopTask entity.
  12292. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12294. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  12295. if !m.op.Is(OpUpdateOne) {
  12296. return v, errors.New("OldType is only allowed on UpdateOne operations")
  12297. }
  12298. if m.id == nil || m.oldValue == nil {
  12299. return v, errors.New("OldType requires an ID field in the mutation")
  12300. }
  12301. oldValue, err := m.oldValue(ctx)
  12302. if err != nil {
  12303. return v, fmt.Errorf("querying old value for OldType: %w", err)
  12304. }
  12305. return oldValue.Type, nil
  12306. }
  12307. // AddType adds i to the "type" field.
  12308. func (m *SopTaskMutation) AddType(i int) {
  12309. if m.add_type != nil {
  12310. *m.add_type += i
  12311. } else {
  12312. m.add_type = &i
  12313. }
  12314. }
  12315. // AddedType returns the value that was added to the "type" field in this mutation.
  12316. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  12317. v := m.add_type
  12318. if v == nil {
  12319. return
  12320. }
  12321. return *v, true
  12322. }
  12323. // ResetType resets all changes to the "type" field.
  12324. func (m *SopTaskMutation) ResetType() {
  12325. m._type = nil
  12326. m.add_type = nil
  12327. }
  12328. // SetPlanStartTime sets the "plan_start_time" field.
  12329. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  12330. m.plan_start_time = &t
  12331. }
  12332. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  12333. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  12334. v := m.plan_start_time
  12335. if v == nil {
  12336. return
  12337. }
  12338. return *v, true
  12339. }
  12340. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  12341. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12342. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12343. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  12344. if !m.op.Is(OpUpdateOne) {
  12345. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  12346. }
  12347. if m.id == nil || m.oldValue == nil {
  12348. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  12349. }
  12350. oldValue, err := m.oldValue(ctx)
  12351. if err != nil {
  12352. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  12353. }
  12354. return oldValue.PlanStartTime, nil
  12355. }
  12356. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  12357. func (m *SopTaskMutation) ClearPlanStartTime() {
  12358. m.plan_start_time = nil
  12359. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  12360. }
  12361. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  12362. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  12363. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  12364. return ok
  12365. }
  12366. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  12367. func (m *SopTaskMutation) ResetPlanStartTime() {
  12368. m.plan_start_time = nil
  12369. delete(m.clearedFields, soptask.FieldPlanStartTime)
  12370. }
  12371. // SetPlanEndTime sets the "plan_end_time" field.
  12372. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  12373. m.plan_end_time = &t
  12374. }
  12375. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  12376. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  12377. v := m.plan_end_time
  12378. if v == nil {
  12379. return
  12380. }
  12381. return *v, true
  12382. }
  12383. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  12384. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12386. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  12387. if !m.op.Is(OpUpdateOne) {
  12388. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  12389. }
  12390. if m.id == nil || m.oldValue == nil {
  12391. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  12392. }
  12393. oldValue, err := m.oldValue(ctx)
  12394. if err != nil {
  12395. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  12396. }
  12397. return oldValue.PlanEndTime, nil
  12398. }
  12399. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  12400. func (m *SopTaskMutation) ClearPlanEndTime() {
  12401. m.plan_end_time = nil
  12402. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  12403. }
  12404. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  12405. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  12406. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  12407. return ok
  12408. }
  12409. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  12410. func (m *SopTaskMutation) ResetPlanEndTime() {
  12411. m.plan_end_time = nil
  12412. delete(m.clearedFields, soptask.FieldPlanEndTime)
  12413. }
  12414. // SetCreatorID sets the "creator_id" field.
  12415. func (m *SopTaskMutation) SetCreatorID(s string) {
  12416. m.creator_id = &s
  12417. }
  12418. // CreatorID returns the value of the "creator_id" field in the mutation.
  12419. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  12420. v := m.creator_id
  12421. if v == nil {
  12422. return
  12423. }
  12424. return *v, true
  12425. }
  12426. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  12427. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12429. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  12430. if !m.op.Is(OpUpdateOne) {
  12431. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  12432. }
  12433. if m.id == nil || m.oldValue == nil {
  12434. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  12435. }
  12436. oldValue, err := m.oldValue(ctx)
  12437. if err != nil {
  12438. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  12439. }
  12440. return oldValue.CreatorID, nil
  12441. }
  12442. // ClearCreatorID clears the value of the "creator_id" field.
  12443. func (m *SopTaskMutation) ClearCreatorID() {
  12444. m.creator_id = nil
  12445. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  12446. }
  12447. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  12448. func (m *SopTaskMutation) CreatorIDCleared() bool {
  12449. _, ok := m.clearedFields[soptask.FieldCreatorID]
  12450. return ok
  12451. }
  12452. // ResetCreatorID resets all changes to the "creator_id" field.
  12453. func (m *SopTaskMutation) ResetCreatorID() {
  12454. m.creator_id = nil
  12455. delete(m.clearedFields, soptask.FieldCreatorID)
  12456. }
  12457. // SetOrganizationID sets the "organization_id" field.
  12458. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  12459. m.organization_id = &u
  12460. m.addorganization_id = nil
  12461. }
  12462. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12463. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  12464. v := m.organization_id
  12465. if v == nil {
  12466. return
  12467. }
  12468. return *v, true
  12469. }
  12470. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  12471. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12473. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12474. if !m.op.Is(OpUpdateOne) {
  12475. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12476. }
  12477. if m.id == nil || m.oldValue == nil {
  12478. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12479. }
  12480. oldValue, err := m.oldValue(ctx)
  12481. if err != nil {
  12482. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12483. }
  12484. return oldValue.OrganizationID, nil
  12485. }
  12486. // AddOrganizationID adds u to the "organization_id" field.
  12487. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  12488. if m.addorganization_id != nil {
  12489. *m.addorganization_id += u
  12490. } else {
  12491. m.addorganization_id = &u
  12492. }
  12493. }
  12494. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12495. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  12496. v := m.addorganization_id
  12497. if v == nil {
  12498. return
  12499. }
  12500. return *v, true
  12501. }
  12502. // ClearOrganizationID clears the value of the "organization_id" field.
  12503. func (m *SopTaskMutation) ClearOrganizationID() {
  12504. m.organization_id = nil
  12505. m.addorganization_id = nil
  12506. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  12507. }
  12508. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12509. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  12510. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  12511. return ok
  12512. }
  12513. // ResetOrganizationID resets all changes to the "organization_id" field.
  12514. func (m *SopTaskMutation) ResetOrganizationID() {
  12515. m.organization_id = nil
  12516. m.addorganization_id = nil
  12517. delete(m.clearedFields, soptask.FieldOrganizationID)
  12518. }
  12519. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  12520. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  12521. if m.task_stages == nil {
  12522. m.task_stages = make(map[uint64]struct{})
  12523. }
  12524. for i := range ids {
  12525. m.task_stages[ids[i]] = struct{}{}
  12526. }
  12527. }
  12528. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  12529. func (m *SopTaskMutation) ClearTaskStages() {
  12530. m.clearedtask_stages = true
  12531. }
  12532. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  12533. func (m *SopTaskMutation) TaskStagesCleared() bool {
  12534. return m.clearedtask_stages
  12535. }
  12536. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  12537. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  12538. if m.removedtask_stages == nil {
  12539. m.removedtask_stages = make(map[uint64]struct{})
  12540. }
  12541. for i := range ids {
  12542. delete(m.task_stages, ids[i])
  12543. m.removedtask_stages[ids[i]] = struct{}{}
  12544. }
  12545. }
  12546. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  12547. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  12548. for id := range m.removedtask_stages {
  12549. ids = append(ids, id)
  12550. }
  12551. return
  12552. }
  12553. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  12554. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  12555. for id := range m.task_stages {
  12556. ids = append(ids, id)
  12557. }
  12558. return
  12559. }
  12560. // ResetTaskStages resets all changes to the "task_stages" edge.
  12561. func (m *SopTaskMutation) ResetTaskStages() {
  12562. m.task_stages = nil
  12563. m.clearedtask_stages = false
  12564. m.removedtask_stages = nil
  12565. }
  12566. // Where appends a list predicates to the SopTaskMutation builder.
  12567. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  12568. m.predicates = append(m.predicates, ps...)
  12569. }
  12570. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  12571. // users can use type-assertion to append predicates that do not depend on any generated package.
  12572. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  12573. p := make([]predicate.SopTask, len(ps))
  12574. for i := range ps {
  12575. p[i] = ps[i]
  12576. }
  12577. m.Where(p...)
  12578. }
  12579. // Op returns the operation name.
  12580. func (m *SopTaskMutation) Op() Op {
  12581. return m.op
  12582. }
  12583. // SetOp allows setting the mutation operation.
  12584. func (m *SopTaskMutation) SetOp(op Op) {
  12585. m.op = op
  12586. }
  12587. // Type returns the node type of this mutation (SopTask).
  12588. func (m *SopTaskMutation) Type() string {
  12589. return m.typ
  12590. }
  12591. // Fields returns all fields that were changed during this mutation. Note that in
  12592. // order to get all numeric fields that were incremented/decremented, call
  12593. // AddedFields().
  12594. func (m *SopTaskMutation) Fields() []string {
  12595. fields := make([]string, 0, 11)
  12596. if m.created_at != nil {
  12597. fields = append(fields, soptask.FieldCreatedAt)
  12598. }
  12599. if m.updated_at != nil {
  12600. fields = append(fields, soptask.FieldUpdatedAt)
  12601. }
  12602. if m.status != nil {
  12603. fields = append(fields, soptask.FieldStatus)
  12604. }
  12605. if m.deleted_at != nil {
  12606. fields = append(fields, soptask.FieldDeletedAt)
  12607. }
  12608. if m.name != nil {
  12609. fields = append(fields, soptask.FieldName)
  12610. }
  12611. if m.bot_wxid_list != nil {
  12612. fields = append(fields, soptask.FieldBotWxidList)
  12613. }
  12614. if m._type != nil {
  12615. fields = append(fields, soptask.FieldType)
  12616. }
  12617. if m.plan_start_time != nil {
  12618. fields = append(fields, soptask.FieldPlanStartTime)
  12619. }
  12620. if m.plan_end_time != nil {
  12621. fields = append(fields, soptask.FieldPlanEndTime)
  12622. }
  12623. if m.creator_id != nil {
  12624. fields = append(fields, soptask.FieldCreatorID)
  12625. }
  12626. if m.organization_id != nil {
  12627. fields = append(fields, soptask.FieldOrganizationID)
  12628. }
  12629. return fields
  12630. }
  12631. // Field returns the value of a field with the given name. The second boolean
  12632. // return value indicates that this field was not set, or was not defined in the
  12633. // schema.
  12634. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  12635. switch name {
  12636. case soptask.FieldCreatedAt:
  12637. return m.CreatedAt()
  12638. case soptask.FieldUpdatedAt:
  12639. return m.UpdatedAt()
  12640. case soptask.FieldStatus:
  12641. return m.Status()
  12642. case soptask.FieldDeletedAt:
  12643. return m.DeletedAt()
  12644. case soptask.FieldName:
  12645. return m.Name()
  12646. case soptask.FieldBotWxidList:
  12647. return m.BotWxidList()
  12648. case soptask.FieldType:
  12649. return m.GetType()
  12650. case soptask.FieldPlanStartTime:
  12651. return m.PlanStartTime()
  12652. case soptask.FieldPlanEndTime:
  12653. return m.PlanEndTime()
  12654. case soptask.FieldCreatorID:
  12655. return m.CreatorID()
  12656. case soptask.FieldOrganizationID:
  12657. return m.OrganizationID()
  12658. }
  12659. return nil, false
  12660. }
  12661. // OldField returns the old value of the field from the database. An error is
  12662. // returned if the mutation operation is not UpdateOne, or the query to the
  12663. // database failed.
  12664. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12665. switch name {
  12666. case soptask.FieldCreatedAt:
  12667. return m.OldCreatedAt(ctx)
  12668. case soptask.FieldUpdatedAt:
  12669. return m.OldUpdatedAt(ctx)
  12670. case soptask.FieldStatus:
  12671. return m.OldStatus(ctx)
  12672. case soptask.FieldDeletedAt:
  12673. return m.OldDeletedAt(ctx)
  12674. case soptask.FieldName:
  12675. return m.OldName(ctx)
  12676. case soptask.FieldBotWxidList:
  12677. return m.OldBotWxidList(ctx)
  12678. case soptask.FieldType:
  12679. return m.OldType(ctx)
  12680. case soptask.FieldPlanStartTime:
  12681. return m.OldPlanStartTime(ctx)
  12682. case soptask.FieldPlanEndTime:
  12683. return m.OldPlanEndTime(ctx)
  12684. case soptask.FieldCreatorID:
  12685. return m.OldCreatorID(ctx)
  12686. case soptask.FieldOrganizationID:
  12687. return m.OldOrganizationID(ctx)
  12688. }
  12689. return nil, fmt.Errorf("unknown SopTask field %s", name)
  12690. }
  12691. // SetField sets the value of a field with the given name. It returns an error if
  12692. // the field is not defined in the schema, or if the type mismatched the field
  12693. // type.
  12694. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  12695. switch name {
  12696. case soptask.FieldCreatedAt:
  12697. v, ok := value.(time.Time)
  12698. if !ok {
  12699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12700. }
  12701. m.SetCreatedAt(v)
  12702. return nil
  12703. case soptask.FieldUpdatedAt:
  12704. v, ok := value.(time.Time)
  12705. if !ok {
  12706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12707. }
  12708. m.SetUpdatedAt(v)
  12709. return nil
  12710. case soptask.FieldStatus:
  12711. v, ok := value.(uint8)
  12712. if !ok {
  12713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12714. }
  12715. m.SetStatus(v)
  12716. return nil
  12717. case soptask.FieldDeletedAt:
  12718. v, ok := value.(time.Time)
  12719. if !ok {
  12720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12721. }
  12722. m.SetDeletedAt(v)
  12723. return nil
  12724. case soptask.FieldName:
  12725. v, ok := value.(string)
  12726. if !ok {
  12727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12728. }
  12729. m.SetName(v)
  12730. return nil
  12731. case soptask.FieldBotWxidList:
  12732. v, ok := value.([]string)
  12733. if !ok {
  12734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12735. }
  12736. m.SetBotWxidList(v)
  12737. return nil
  12738. case soptask.FieldType:
  12739. v, ok := value.(int)
  12740. if !ok {
  12741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12742. }
  12743. m.SetType(v)
  12744. return nil
  12745. case soptask.FieldPlanStartTime:
  12746. v, ok := value.(time.Time)
  12747. if !ok {
  12748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12749. }
  12750. m.SetPlanStartTime(v)
  12751. return nil
  12752. case soptask.FieldPlanEndTime:
  12753. v, ok := value.(time.Time)
  12754. if !ok {
  12755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12756. }
  12757. m.SetPlanEndTime(v)
  12758. return nil
  12759. case soptask.FieldCreatorID:
  12760. v, ok := value.(string)
  12761. if !ok {
  12762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12763. }
  12764. m.SetCreatorID(v)
  12765. return nil
  12766. case soptask.FieldOrganizationID:
  12767. v, ok := value.(uint64)
  12768. if !ok {
  12769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12770. }
  12771. m.SetOrganizationID(v)
  12772. return nil
  12773. }
  12774. return fmt.Errorf("unknown SopTask field %s", name)
  12775. }
  12776. // AddedFields returns all numeric fields that were incremented/decremented during
  12777. // this mutation.
  12778. func (m *SopTaskMutation) AddedFields() []string {
  12779. var fields []string
  12780. if m.addstatus != nil {
  12781. fields = append(fields, soptask.FieldStatus)
  12782. }
  12783. if m.add_type != nil {
  12784. fields = append(fields, soptask.FieldType)
  12785. }
  12786. if m.addorganization_id != nil {
  12787. fields = append(fields, soptask.FieldOrganizationID)
  12788. }
  12789. return fields
  12790. }
  12791. // AddedField returns the numeric value that was incremented/decremented on a field
  12792. // with the given name. The second boolean return value indicates that this field
  12793. // was not set, or was not defined in the schema.
  12794. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  12795. switch name {
  12796. case soptask.FieldStatus:
  12797. return m.AddedStatus()
  12798. case soptask.FieldType:
  12799. return m.AddedType()
  12800. case soptask.FieldOrganizationID:
  12801. return m.AddedOrganizationID()
  12802. }
  12803. return nil, false
  12804. }
  12805. // AddField adds the value to the field with the given name. It returns an error if
  12806. // the field is not defined in the schema, or if the type mismatched the field
  12807. // type.
  12808. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  12809. switch name {
  12810. case soptask.FieldStatus:
  12811. v, ok := value.(int8)
  12812. if !ok {
  12813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12814. }
  12815. m.AddStatus(v)
  12816. return nil
  12817. case soptask.FieldType:
  12818. v, ok := value.(int)
  12819. if !ok {
  12820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12821. }
  12822. m.AddType(v)
  12823. return nil
  12824. case soptask.FieldOrganizationID:
  12825. v, ok := value.(int64)
  12826. if !ok {
  12827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12828. }
  12829. m.AddOrganizationID(v)
  12830. return nil
  12831. }
  12832. return fmt.Errorf("unknown SopTask numeric field %s", name)
  12833. }
  12834. // ClearedFields returns all nullable fields that were cleared during this
  12835. // mutation.
  12836. func (m *SopTaskMutation) ClearedFields() []string {
  12837. var fields []string
  12838. if m.FieldCleared(soptask.FieldStatus) {
  12839. fields = append(fields, soptask.FieldStatus)
  12840. }
  12841. if m.FieldCleared(soptask.FieldDeletedAt) {
  12842. fields = append(fields, soptask.FieldDeletedAt)
  12843. }
  12844. if m.FieldCleared(soptask.FieldBotWxidList) {
  12845. fields = append(fields, soptask.FieldBotWxidList)
  12846. }
  12847. if m.FieldCleared(soptask.FieldPlanStartTime) {
  12848. fields = append(fields, soptask.FieldPlanStartTime)
  12849. }
  12850. if m.FieldCleared(soptask.FieldPlanEndTime) {
  12851. fields = append(fields, soptask.FieldPlanEndTime)
  12852. }
  12853. if m.FieldCleared(soptask.FieldCreatorID) {
  12854. fields = append(fields, soptask.FieldCreatorID)
  12855. }
  12856. if m.FieldCleared(soptask.FieldOrganizationID) {
  12857. fields = append(fields, soptask.FieldOrganizationID)
  12858. }
  12859. return fields
  12860. }
  12861. // FieldCleared returns a boolean indicating if a field with the given name was
  12862. // cleared in this mutation.
  12863. func (m *SopTaskMutation) FieldCleared(name string) bool {
  12864. _, ok := m.clearedFields[name]
  12865. return ok
  12866. }
  12867. // ClearField clears the value of the field with the given name. It returns an
  12868. // error if the field is not defined in the schema.
  12869. func (m *SopTaskMutation) ClearField(name string) error {
  12870. switch name {
  12871. case soptask.FieldStatus:
  12872. m.ClearStatus()
  12873. return nil
  12874. case soptask.FieldDeletedAt:
  12875. m.ClearDeletedAt()
  12876. return nil
  12877. case soptask.FieldBotWxidList:
  12878. m.ClearBotWxidList()
  12879. return nil
  12880. case soptask.FieldPlanStartTime:
  12881. m.ClearPlanStartTime()
  12882. return nil
  12883. case soptask.FieldPlanEndTime:
  12884. m.ClearPlanEndTime()
  12885. return nil
  12886. case soptask.FieldCreatorID:
  12887. m.ClearCreatorID()
  12888. return nil
  12889. case soptask.FieldOrganizationID:
  12890. m.ClearOrganizationID()
  12891. return nil
  12892. }
  12893. return fmt.Errorf("unknown SopTask nullable field %s", name)
  12894. }
  12895. // ResetField resets all changes in the mutation for the field with the given name.
  12896. // It returns an error if the field is not defined in the schema.
  12897. func (m *SopTaskMutation) ResetField(name string) error {
  12898. switch name {
  12899. case soptask.FieldCreatedAt:
  12900. m.ResetCreatedAt()
  12901. return nil
  12902. case soptask.FieldUpdatedAt:
  12903. m.ResetUpdatedAt()
  12904. return nil
  12905. case soptask.FieldStatus:
  12906. m.ResetStatus()
  12907. return nil
  12908. case soptask.FieldDeletedAt:
  12909. m.ResetDeletedAt()
  12910. return nil
  12911. case soptask.FieldName:
  12912. m.ResetName()
  12913. return nil
  12914. case soptask.FieldBotWxidList:
  12915. m.ResetBotWxidList()
  12916. return nil
  12917. case soptask.FieldType:
  12918. m.ResetType()
  12919. return nil
  12920. case soptask.FieldPlanStartTime:
  12921. m.ResetPlanStartTime()
  12922. return nil
  12923. case soptask.FieldPlanEndTime:
  12924. m.ResetPlanEndTime()
  12925. return nil
  12926. case soptask.FieldCreatorID:
  12927. m.ResetCreatorID()
  12928. return nil
  12929. case soptask.FieldOrganizationID:
  12930. m.ResetOrganizationID()
  12931. return nil
  12932. }
  12933. return fmt.Errorf("unknown SopTask field %s", name)
  12934. }
  12935. // AddedEdges returns all edge names that were set/added in this mutation.
  12936. func (m *SopTaskMutation) AddedEdges() []string {
  12937. edges := make([]string, 0, 1)
  12938. if m.task_stages != nil {
  12939. edges = append(edges, soptask.EdgeTaskStages)
  12940. }
  12941. return edges
  12942. }
  12943. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12944. // name in this mutation.
  12945. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  12946. switch name {
  12947. case soptask.EdgeTaskStages:
  12948. ids := make([]ent.Value, 0, len(m.task_stages))
  12949. for id := range m.task_stages {
  12950. ids = append(ids, id)
  12951. }
  12952. return ids
  12953. }
  12954. return nil
  12955. }
  12956. // RemovedEdges returns all edge names that were removed in this mutation.
  12957. func (m *SopTaskMutation) RemovedEdges() []string {
  12958. edges := make([]string, 0, 1)
  12959. if m.removedtask_stages != nil {
  12960. edges = append(edges, soptask.EdgeTaskStages)
  12961. }
  12962. return edges
  12963. }
  12964. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12965. // the given name in this mutation.
  12966. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  12967. switch name {
  12968. case soptask.EdgeTaskStages:
  12969. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  12970. for id := range m.removedtask_stages {
  12971. ids = append(ids, id)
  12972. }
  12973. return ids
  12974. }
  12975. return nil
  12976. }
  12977. // ClearedEdges returns all edge names that were cleared in this mutation.
  12978. func (m *SopTaskMutation) ClearedEdges() []string {
  12979. edges := make([]string, 0, 1)
  12980. if m.clearedtask_stages {
  12981. edges = append(edges, soptask.EdgeTaskStages)
  12982. }
  12983. return edges
  12984. }
  12985. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12986. // was cleared in this mutation.
  12987. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  12988. switch name {
  12989. case soptask.EdgeTaskStages:
  12990. return m.clearedtask_stages
  12991. }
  12992. return false
  12993. }
  12994. // ClearEdge clears the value of the edge with the given name. It returns an error
  12995. // if that edge is not defined in the schema.
  12996. func (m *SopTaskMutation) ClearEdge(name string) error {
  12997. switch name {
  12998. }
  12999. return fmt.Errorf("unknown SopTask unique edge %s", name)
  13000. }
  13001. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13002. // It returns an error if the edge is not defined in the schema.
  13003. func (m *SopTaskMutation) ResetEdge(name string) error {
  13004. switch name {
  13005. case soptask.EdgeTaskStages:
  13006. m.ResetTaskStages()
  13007. return nil
  13008. }
  13009. return fmt.Errorf("unknown SopTask edge %s", name)
  13010. }
  13011. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  13012. type WxMutation struct {
  13013. config
  13014. op Op
  13015. typ string
  13016. id *uint64
  13017. created_at *time.Time
  13018. updated_at *time.Time
  13019. status *uint8
  13020. addstatus *int8
  13021. deleted_at *time.Time
  13022. port *string
  13023. process_id *string
  13024. callback *string
  13025. wxid *string
  13026. account *string
  13027. nickname *string
  13028. tel *string
  13029. head_big *string
  13030. organization_id *uint64
  13031. addorganization_id *int64
  13032. clearedFields map[string]struct{}
  13033. server *uint64
  13034. clearedserver bool
  13035. agent *uint64
  13036. clearedagent bool
  13037. done bool
  13038. oldValue func(context.Context) (*Wx, error)
  13039. predicates []predicate.Wx
  13040. }
  13041. var _ ent.Mutation = (*WxMutation)(nil)
  13042. // wxOption allows management of the mutation configuration using functional options.
  13043. type wxOption func(*WxMutation)
  13044. // newWxMutation creates new mutation for the Wx entity.
  13045. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  13046. m := &WxMutation{
  13047. config: c,
  13048. op: op,
  13049. typ: TypeWx,
  13050. clearedFields: make(map[string]struct{}),
  13051. }
  13052. for _, opt := range opts {
  13053. opt(m)
  13054. }
  13055. return m
  13056. }
  13057. // withWxID sets the ID field of the mutation.
  13058. func withWxID(id uint64) wxOption {
  13059. return func(m *WxMutation) {
  13060. var (
  13061. err error
  13062. once sync.Once
  13063. value *Wx
  13064. )
  13065. m.oldValue = func(ctx context.Context) (*Wx, error) {
  13066. once.Do(func() {
  13067. if m.done {
  13068. err = errors.New("querying old values post mutation is not allowed")
  13069. } else {
  13070. value, err = m.Client().Wx.Get(ctx, id)
  13071. }
  13072. })
  13073. return value, err
  13074. }
  13075. m.id = &id
  13076. }
  13077. }
  13078. // withWx sets the old Wx of the mutation.
  13079. func withWx(node *Wx) wxOption {
  13080. return func(m *WxMutation) {
  13081. m.oldValue = func(context.Context) (*Wx, error) {
  13082. return node, nil
  13083. }
  13084. m.id = &node.ID
  13085. }
  13086. }
  13087. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13088. // executed in a transaction (ent.Tx), a transactional client is returned.
  13089. func (m WxMutation) Client() *Client {
  13090. client := &Client{config: m.config}
  13091. client.init()
  13092. return client
  13093. }
  13094. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13095. // it returns an error otherwise.
  13096. func (m WxMutation) Tx() (*Tx, error) {
  13097. if _, ok := m.driver.(*txDriver); !ok {
  13098. return nil, errors.New("ent: mutation is not running in a transaction")
  13099. }
  13100. tx := &Tx{config: m.config}
  13101. tx.init()
  13102. return tx, nil
  13103. }
  13104. // SetID sets the value of the id field. Note that this
  13105. // operation is only accepted on creation of Wx entities.
  13106. func (m *WxMutation) SetID(id uint64) {
  13107. m.id = &id
  13108. }
  13109. // ID returns the ID value in the mutation. Note that the ID is only available
  13110. // if it was provided to the builder or after it was returned from the database.
  13111. func (m *WxMutation) ID() (id uint64, exists bool) {
  13112. if m.id == nil {
  13113. return
  13114. }
  13115. return *m.id, true
  13116. }
  13117. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13118. // That means, if the mutation is applied within a transaction with an isolation level such
  13119. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13120. // or updated by the mutation.
  13121. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  13122. switch {
  13123. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13124. id, exists := m.ID()
  13125. if exists {
  13126. return []uint64{id}, nil
  13127. }
  13128. fallthrough
  13129. case m.op.Is(OpUpdate | OpDelete):
  13130. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  13131. default:
  13132. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13133. }
  13134. }
  13135. // SetCreatedAt sets the "created_at" field.
  13136. func (m *WxMutation) SetCreatedAt(t time.Time) {
  13137. m.created_at = &t
  13138. }
  13139. // CreatedAt returns the value of the "created_at" field in the mutation.
  13140. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  13141. v := m.created_at
  13142. if v == nil {
  13143. return
  13144. }
  13145. return *v, true
  13146. }
  13147. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  13148. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13149. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13150. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13151. if !m.op.Is(OpUpdateOne) {
  13152. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13153. }
  13154. if m.id == nil || m.oldValue == nil {
  13155. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13156. }
  13157. oldValue, err := m.oldValue(ctx)
  13158. if err != nil {
  13159. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13160. }
  13161. return oldValue.CreatedAt, nil
  13162. }
  13163. // ResetCreatedAt resets all changes to the "created_at" field.
  13164. func (m *WxMutation) ResetCreatedAt() {
  13165. m.created_at = nil
  13166. }
  13167. // SetUpdatedAt sets the "updated_at" field.
  13168. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  13169. m.updated_at = &t
  13170. }
  13171. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13172. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  13173. v := m.updated_at
  13174. if v == nil {
  13175. return
  13176. }
  13177. return *v, true
  13178. }
  13179. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  13180. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13182. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13183. if !m.op.Is(OpUpdateOne) {
  13184. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13185. }
  13186. if m.id == nil || m.oldValue == nil {
  13187. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13188. }
  13189. oldValue, err := m.oldValue(ctx)
  13190. if err != nil {
  13191. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13192. }
  13193. return oldValue.UpdatedAt, nil
  13194. }
  13195. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13196. func (m *WxMutation) ResetUpdatedAt() {
  13197. m.updated_at = nil
  13198. }
  13199. // SetStatus sets the "status" field.
  13200. func (m *WxMutation) SetStatus(u uint8) {
  13201. m.status = &u
  13202. m.addstatus = nil
  13203. }
  13204. // Status returns the value of the "status" field in the mutation.
  13205. func (m *WxMutation) Status() (r uint8, exists bool) {
  13206. v := m.status
  13207. if v == nil {
  13208. return
  13209. }
  13210. return *v, true
  13211. }
  13212. // OldStatus returns the old "status" field's value of the Wx entity.
  13213. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13215. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13216. if !m.op.Is(OpUpdateOne) {
  13217. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13218. }
  13219. if m.id == nil || m.oldValue == nil {
  13220. return v, errors.New("OldStatus requires an ID field in the mutation")
  13221. }
  13222. oldValue, err := m.oldValue(ctx)
  13223. if err != nil {
  13224. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13225. }
  13226. return oldValue.Status, nil
  13227. }
  13228. // AddStatus adds u to the "status" field.
  13229. func (m *WxMutation) AddStatus(u int8) {
  13230. if m.addstatus != nil {
  13231. *m.addstatus += u
  13232. } else {
  13233. m.addstatus = &u
  13234. }
  13235. }
  13236. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13237. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  13238. v := m.addstatus
  13239. if v == nil {
  13240. return
  13241. }
  13242. return *v, true
  13243. }
  13244. // ClearStatus clears the value of the "status" field.
  13245. func (m *WxMutation) ClearStatus() {
  13246. m.status = nil
  13247. m.addstatus = nil
  13248. m.clearedFields[wx.FieldStatus] = struct{}{}
  13249. }
  13250. // StatusCleared returns if the "status" field was cleared in this mutation.
  13251. func (m *WxMutation) StatusCleared() bool {
  13252. _, ok := m.clearedFields[wx.FieldStatus]
  13253. return ok
  13254. }
  13255. // ResetStatus resets all changes to the "status" field.
  13256. func (m *WxMutation) ResetStatus() {
  13257. m.status = nil
  13258. m.addstatus = nil
  13259. delete(m.clearedFields, wx.FieldStatus)
  13260. }
  13261. // SetDeletedAt sets the "deleted_at" field.
  13262. func (m *WxMutation) SetDeletedAt(t time.Time) {
  13263. m.deleted_at = &t
  13264. }
  13265. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13266. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  13267. v := m.deleted_at
  13268. if v == nil {
  13269. return
  13270. }
  13271. return *v, true
  13272. }
  13273. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  13274. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13276. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13277. if !m.op.Is(OpUpdateOne) {
  13278. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13279. }
  13280. if m.id == nil || m.oldValue == nil {
  13281. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13282. }
  13283. oldValue, err := m.oldValue(ctx)
  13284. if err != nil {
  13285. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13286. }
  13287. return oldValue.DeletedAt, nil
  13288. }
  13289. // ClearDeletedAt clears the value of the "deleted_at" field.
  13290. func (m *WxMutation) ClearDeletedAt() {
  13291. m.deleted_at = nil
  13292. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  13293. }
  13294. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13295. func (m *WxMutation) DeletedAtCleared() bool {
  13296. _, ok := m.clearedFields[wx.FieldDeletedAt]
  13297. return ok
  13298. }
  13299. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13300. func (m *WxMutation) ResetDeletedAt() {
  13301. m.deleted_at = nil
  13302. delete(m.clearedFields, wx.FieldDeletedAt)
  13303. }
  13304. // SetServerID sets the "server_id" field.
  13305. func (m *WxMutation) SetServerID(u uint64) {
  13306. m.server = &u
  13307. }
  13308. // ServerID returns the value of the "server_id" field in the mutation.
  13309. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  13310. v := m.server
  13311. if v == nil {
  13312. return
  13313. }
  13314. return *v, true
  13315. }
  13316. // OldServerID returns the old "server_id" field's value of the Wx entity.
  13317. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13319. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  13320. if !m.op.Is(OpUpdateOne) {
  13321. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  13322. }
  13323. if m.id == nil || m.oldValue == nil {
  13324. return v, errors.New("OldServerID requires an ID field in the mutation")
  13325. }
  13326. oldValue, err := m.oldValue(ctx)
  13327. if err != nil {
  13328. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  13329. }
  13330. return oldValue.ServerID, nil
  13331. }
  13332. // ClearServerID clears the value of the "server_id" field.
  13333. func (m *WxMutation) ClearServerID() {
  13334. m.server = nil
  13335. m.clearedFields[wx.FieldServerID] = struct{}{}
  13336. }
  13337. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  13338. func (m *WxMutation) ServerIDCleared() bool {
  13339. _, ok := m.clearedFields[wx.FieldServerID]
  13340. return ok
  13341. }
  13342. // ResetServerID resets all changes to the "server_id" field.
  13343. func (m *WxMutation) ResetServerID() {
  13344. m.server = nil
  13345. delete(m.clearedFields, wx.FieldServerID)
  13346. }
  13347. // SetPort sets the "port" field.
  13348. func (m *WxMutation) SetPort(s string) {
  13349. m.port = &s
  13350. }
  13351. // Port returns the value of the "port" field in the mutation.
  13352. func (m *WxMutation) Port() (r string, exists bool) {
  13353. v := m.port
  13354. if v == nil {
  13355. return
  13356. }
  13357. return *v, true
  13358. }
  13359. // OldPort returns the old "port" field's value of the Wx entity.
  13360. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13362. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  13363. if !m.op.Is(OpUpdateOne) {
  13364. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  13365. }
  13366. if m.id == nil || m.oldValue == nil {
  13367. return v, errors.New("OldPort requires an ID field in the mutation")
  13368. }
  13369. oldValue, err := m.oldValue(ctx)
  13370. if err != nil {
  13371. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  13372. }
  13373. return oldValue.Port, nil
  13374. }
  13375. // ResetPort resets all changes to the "port" field.
  13376. func (m *WxMutation) ResetPort() {
  13377. m.port = nil
  13378. }
  13379. // SetProcessID sets the "process_id" field.
  13380. func (m *WxMutation) SetProcessID(s string) {
  13381. m.process_id = &s
  13382. }
  13383. // ProcessID returns the value of the "process_id" field in the mutation.
  13384. func (m *WxMutation) ProcessID() (r string, exists bool) {
  13385. v := m.process_id
  13386. if v == nil {
  13387. return
  13388. }
  13389. return *v, true
  13390. }
  13391. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  13392. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13394. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  13395. if !m.op.Is(OpUpdateOne) {
  13396. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  13397. }
  13398. if m.id == nil || m.oldValue == nil {
  13399. return v, errors.New("OldProcessID requires an ID field in the mutation")
  13400. }
  13401. oldValue, err := m.oldValue(ctx)
  13402. if err != nil {
  13403. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  13404. }
  13405. return oldValue.ProcessID, nil
  13406. }
  13407. // ResetProcessID resets all changes to the "process_id" field.
  13408. func (m *WxMutation) ResetProcessID() {
  13409. m.process_id = nil
  13410. }
  13411. // SetCallback sets the "callback" field.
  13412. func (m *WxMutation) SetCallback(s string) {
  13413. m.callback = &s
  13414. }
  13415. // Callback returns the value of the "callback" field in the mutation.
  13416. func (m *WxMutation) Callback() (r string, exists bool) {
  13417. v := m.callback
  13418. if v == nil {
  13419. return
  13420. }
  13421. return *v, true
  13422. }
  13423. // OldCallback returns the old "callback" field's value of the Wx entity.
  13424. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13426. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  13427. if !m.op.Is(OpUpdateOne) {
  13428. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  13429. }
  13430. if m.id == nil || m.oldValue == nil {
  13431. return v, errors.New("OldCallback requires an ID field in the mutation")
  13432. }
  13433. oldValue, err := m.oldValue(ctx)
  13434. if err != nil {
  13435. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  13436. }
  13437. return oldValue.Callback, nil
  13438. }
  13439. // ResetCallback resets all changes to the "callback" field.
  13440. func (m *WxMutation) ResetCallback() {
  13441. m.callback = nil
  13442. }
  13443. // SetWxid sets the "wxid" field.
  13444. func (m *WxMutation) SetWxid(s string) {
  13445. m.wxid = &s
  13446. }
  13447. // Wxid returns the value of the "wxid" field in the mutation.
  13448. func (m *WxMutation) Wxid() (r string, exists bool) {
  13449. v := m.wxid
  13450. if v == nil {
  13451. return
  13452. }
  13453. return *v, true
  13454. }
  13455. // OldWxid returns the old "wxid" field's value of the Wx entity.
  13456. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13458. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  13459. if !m.op.Is(OpUpdateOne) {
  13460. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  13461. }
  13462. if m.id == nil || m.oldValue == nil {
  13463. return v, errors.New("OldWxid requires an ID field in the mutation")
  13464. }
  13465. oldValue, err := m.oldValue(ctx)
  13466. if err != nil {
  13467. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  13468. }
  13469. return oldValue.Wxid, nil
  13470. }
  13471. // ResetWxid resets all changes to the "wxid" field.
  13472. func (m *WxMutation) ResetWxid() {
  13473. m.wxid = nil
  13474. }
  13475. // SetAccount sets the "account" field.
  13476. func (m *WxMutation) SetAccount(s string) {
  13477. m.account = &s
  13478. }
  13479. // Account returns the value of the "account" field in the mutation.
  13480. func (m *WxMutation) Account() (r string, exists bool) {
  13481. v := m.account
  13482. if v == nil {
  13483. return
  13484. }
  13485. return *v, true
  13486. }
  13487. // OldAccount returns the old "account" field's value of the Wx entity.
  13488. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13490. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  13491. if !m.op.Is(OpUpdateOne) {
  13492. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  13493. }
  13494. if m.id == nil || m.oldValue == nil {
  13495. return v, errors.New("OldAccount requires an ID field in the mutation")
  13496. }
  13497. oldValue, err := m.oldValue(ctx)
  13498. if err != nil {
  13499. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  13500. }
  13501. return oldValue.Account, nil
  13502. }
  13503. // ResetAccount resets all changes to the "account" field.
  13504. func (m *WxMutation) ResetAccount() {
  13505. m.account = nil
  13506. }
  13507. // SetNickname sets the "nickname" field.
  13508. func (m *WxMutation) SetNickname(s string) {
  13509. m.nickname = &s
  13510. }
  13511. // Nickname returns the value of the "nickname" field in the mutation.
  13512. func (m *WxMutation) Nickname() (r string, exists bool) {
  13513. v := m.nickname
  13514. if v == nil {
  13515. return
  13516. }
  13517. return *v, true
  13518. }
  13519. // OldNickname returns the old "nickname" field's value of the Wx entity.
  13520. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13522. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  13523. if !m.op.Is(OpUpdateOne) {
  13524. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  13525. }
  13526. if m.id == nil || m.oldValue == nil {
  13527. return v, errors.New("OldNickname requires an ID field in the mutation")
  13528. }
  13529. oldValue, err := m.oldValue(ctx)
  13530. if err != nil {
  13531. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  13532. }
  13533. return oldValue.Nickname, nil
  13534. }
  13535. // ResetNickname resets all changes to the "nickname" field.
  13536. func (m *WxMutation) ResetNickname() {
  13537. m.nickname = nil
  13538. }
  13539. // SetTel sets the "tel" field.
  13540. func (m *WxMutation) SetTel(s string) {
  13541. m.tel = &s
  13542. }
  13543. // Tel returns the value of the "tel" field in the mutation.
  13544. func (m *WxMutation) Tel() (r string, exists bool) {
  13545. v := m.tel
  13546. if v == nil {
  13547. return
  13548. }
  13549. return *v, true
  13550. }
  13551. // OldTel returns the old "tel" field's value of the Wx entity.
  13552. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13554. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  13555. if !m.op.Is(OpUpdateOne) {
  13556. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  13557. }
  13558. if m.id == nil || m.oldValue == nil {
  13559. return v, errors.New("OldTel requires an ID field in the mutation")
  13560. }
  13561. oldValue, err := m.oldValue(ctx)
  13562. if err != nil {
  13563. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  13564. }
  13565. return oldValue.Tel, nil
  13566. }
  13567. // ResetTel resets all changes to the "tel" field.
  13568. func (m *WxMutation) ResetTel() {
  13569. m.tel = nil
  13570. }
  13571. // SetHeadBig sets the "head_big" field.
  13572. func (m *WxMutation) SetHeadBig(s string) {
  13573. m.head_big = &s
  13574. }
  13575. // HeadBig returns the value of the "head_big" field in the mutation.
  13576. func (m *WxMutation) HeadBig() (r string, exists bool) {
  13577. v := m.head_big
  13578. if v == nil {
  13579. return
  13580. }
  13581. return *v, true
  13582. }
  13583. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  13584. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13586. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  13587. if !m.op.Is(OpUpdateOne) {
  13588. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  13589. }
  13590. if m.id == nil || m.oldValue == nil {
  13591. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  13592. }
  13593. oldValue, err := m.oldValue(ctx)
  13594. if err != nil {
  13595. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  13596. }
  13597. return oldValue.HeadBig, nil
  13598. }
  13599. // ResetHeadBig resets all changes to the "head_big" field.
  13600. func (m *WxMutation) ResetHeadBig() {
  13601. m.head_big = nil
  13602. }
  13603. // SetOrganizationID sets the "organization_id" field.
  13604. func (m *WxMutation) SetOrganizationID(u uint64) {
  13605. m.organization_id = &u
  13606. m.addorganization_id = nil
  13607. }
  13608. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13609. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  13610. v := m.organization_id
  13611. if v == nil {
  13612. return
  13613. }
  13614. return *v, true
  13615. }
  13616. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  13617. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13619. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13620. if !m.op.Is(OpUpdateOne) {
  13621. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13622. }
  13623. if m.id == nil || m.oldValue == nil {
  13624. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13625. }
  13626. oldValue, err := m.oldValue(ctx)
  13627. if err != nil {
  13628. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13629. }
  13630. return oldValue.OrganizationID, nil
  13631. }
  13632. // AddOrganizationID adds u to the "organization_id" field.
  13633. func (m *WxMutation) AddOrganizationID(u int64) {
  13634. if m.addorganization_id != nil {
  13635. *m.addorganization_id += u
  13636. } else {
  13637. m.addorganization_id = &u
  13638. }
  13639. }
  13640. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13641. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  13642. v := m.addorganization_id
  13643. if v == nil {
  13644. return
  13645. }
  13646. return *v, true
  13647. }
  13648. // ClearOrganizationID clears the value of the "organization_id" field.
  13649. func (m *WxMutation) ClearOrganizationID() {
  13650. m.organization_id = nil
  13651. m.addorganization_id = nil
  13652. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  13653. }
  13654. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13655. func (m *WxMutation) OrganizationIDCleared() bool {
  13656. _, ok := m.clearedFields[wx.FieldOrganizationID]
  13657. return ok
  13658. }
  13659. // ResetOrganizationID resets all changes to the "organization_id" field.
  13660. func (m *WxMutation) ResetOrganizationID() {
  13661. m.organization_id = nil
  13662. m.addorganization_id = nil
  13663. delete(m.clearedFields, wx.FieldOrganizationID)
  13664. }
  13665. // SetAgentID sets the "agent_id" field.
  13666. func (m *WxMutation) SetAgentID(u uint64) {
  13667. m.agent = &u
  13668. }
  13669. // AgentID returns the value of the "agent_id" field in the mutation.
  13670. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  13671. v := m.agent
  13672. if v == nil {
  13673. return
  13674. }
  13675. return *v, true
  13676. }
  13677. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  13678. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13680. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  13681. if !m.op.Is(OpUpdateOne) {
  13682. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  13683. }
  13684. if m.id == nil || m.oldValue == nil {
  13685. return v, errors.New("OldAgentID requires an ID field in the mutation")
  13686. }
  13687. oldValue, err := m.oldValue(ctx)
  13688. if err != nil {
  13689. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  13690. }
  13691. return oldValue.AgentID, nil
  13692. }
  13693. // ResetAgentID resets all changes to the "agent_id" field.
  13694. func (m *WxMutation) ResetAgentID() {
  13695. m.agent = nil
  13696. }
  13697. // ClearServer clears the "server" edge to the Server entity.
  13698. func (m *WxMutation) ClearServer() {
  13699. m.clearedserver = true
  13700. m.clearedFields[wx.FieldServerID] = struct{}{}
  13701. }
  13702. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  13703. func (m *WxMutation) ServerCleared() bool {
  13704. return m.ServerIDCleared() || m.clearedserver
  13705. }
  13706. // ServerIDs returns the "server" edge IDs in the mutation.
  13707. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13708. // ServerID instead. It exists only for internal usage by the builders.
  13709. func (m *WxMutation) ServerIDs() (ids []uint64) {
  13710. if id := m.server; id != nil {
  13711. ids = append(ids, *id)
  13712. }
  13713. return
  13714. }
  13715. // ResetServer resets all changes to the "server" edge.
  13716. func (m *WxMutation) ResetServer() {
  13717. m.server = nil
  13718. m.clearedserver = false
  13719. }
  13720. // ClearAgent clears the "agent" edge to the Agent entity.
  13721. func (m *WxMutation) ClearAgent() {
  13722. m.clearedagent = true
  13723. m.clearedFields[wx.FieldAgentID] = struct{}{}
  13724. }
  13725. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  13726. func (m *WxMutation) AgentCleared() bool {
  13727. return m.clearedagent
  13728. }
  13729. // AgentIDs returns the "agent" edge IDs in the mutation.
  13730. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13731. // AgentID instead. It exists only for internal usage by the builders.
  13732. func (m *WxMutation) AgentIDs() (ids []uint64) {
  13733. if id := m.agent; id != nil {
  13734. ids = append(ids, *id)
  13735. }
  13736. return
  13737. }
  13738. // ResetAgent resets all changes to the "agent" edge.
  13739. func (m *WxMutation) ResetAgent() {
  13740. m.agent = nil
  13741. m.clearedagent = false
  13742. }
  13743. // Where appends a list predicates to the WxMutation builder.
  13744. func (m *WxMutation) Where(ps ...predicate.Wx) {
  13745. m.predicates = append(m.predicates, ps...)
  13746. }
  13747. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  13748. // users can use type-assertion to append predicates that do not depend on any generated package.
  13749. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  13750. p := make([]predicate.Wx, len(ps))
  13751. for i := range ps {
  13752. p[i] = ps[i]
  13753. }
  13754. m.Where(p...)
  13755. }
  13756. // Op returns the operation name.
  13757. func (m *WxMutation) Op() Op {
  13758. return m.op
  13759. }
  13760. // SetOp allows setting the mutation operation.
  13761. func (m *WxMutation) SetOp(op Op) {
  13762. m.op = op
  13763. }
  13764. // Type returns the node type of this mutation (Wx).
  13765. func (m *WxMutation) Type() string {
  13766. return m.typ
  13767. }
  13768. // Fields returns all fields that were changed during this mutation. Note that in
  13769. // order to get all numeric fields that were incremented/decremented, call
  13770. // AddedFields().
  13771. func (m *WxMutation) Fields() []string {
  13772. fields := make([]string, 0, 15)
  13773. if m.created_at != nil {
  13774. fields = append(fields, wx.FieldCreatedAt)
  13775. }
  13776. if m.updated_at != nil {
  13777. fields = append(fields, wx.FieldUpdatedAt)
  13778. }
  13779. if m.status != nil {
  13780. fields = append(fields, wx.FieldStatus)
  13781. }
  13782. if m.deleted_at != nil {
  13783. fields = append(fields, wx.FieldDeletedAt)
  13784. }
  13785. if m.server != nil {
  13786. fields = append(fields, wx.FieldServerID)
  13787. }
  13788. if m.port != nil {
  13789. fields = append(fields, wx.FieldPort)
  13790. }
  13791. if m.process_id != nil {
  13792. fields = append(fields, wx.FieldProcessID)
  13793. }
  13794. if m.callback != nil {
  13795. fields = append(fields, wx.FieldCallback)
  13796. }
  13797. if m.wxid != nil {
  13798. fields = append(fields, wx.FieldWxid)
  13799. }
  13800. if m.account != nil {
  13801. fields = append(fields, wx.FieldAccount)
  13802. }
  13803. if m.nickname != nil {
  13804. fields = append(fields, wx.FieldNickname)
  13805. }
  13806. if m.tel != nil {
  13807. fields = append(fields, wx.FieldTel)
  13808. }
  13809. if m.head_big != nil {
  13810. fields = append(fields, wx.FieldHeadBig)
  13811. }
  13812. if m.organization_id != nil {
  13813. fields = append(fields, wx.FieldOrganizationID)
  13814. }
  13815. if m.agent != nil {
  13816. fields = append(fields, wx.FieldAgentID)
  13817. }
  13818. return fields
  13819. }
  13820. // Field returns the value of a field with the given name. The second boolean
  13821. // return value indicates that this field was not set, or was not defined in the
  13822. // schema.
  13823. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  13824. switch name {
  13825. case wx.FieldCreatedAt:
  13826. return m.CreatedAt()
  13827. case wx.FieldUpdatedAt:
  13828. return m.UpdatedAt()
  13829. case wx.FieldStatus:
  13830. return m.Status()
  13831. case wx.FieldDeletedAt:
  13832. return m.DeletedAt()
  13833. case wx.FieldServerID:
  13834. return m.ServerID()
  13835. case wx.FieldPort:
  13836. return m.Port()
  13837. case wx.FieldProcessID:
  13838. return m.ProcessID()
  13839. case wx.FieldCallback:
  13840. return m.Callback()
  13841. case wx.FieldWxid:
  13842. return m.Wxid()
  13843. case wx.FieldAccount:
  13844. return m.Account()
  13845. case wx.FieldNickname:
  13846. return m.Nickname()
  13847. case wx.FieldTel:
  13848. return m.Tel()
  13849. case wx.FieldHeadBig:
  13850. return m.HeadBig()
  13851. case wx.FieldOrganizationID:
  13852. return m.OrganizationID()
  13853. case wx.FieldAgentID:
  13854. return m.AgentID()
  13855. }
  13856. return nil, false
  13857. }
  13858. // OldField returns the old value of the field from the database. An error is
  13859. // returned if the mutation operation is not UpdateOne, or the query to the
  13860. // database failed.
  13861. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13862. switch name {
  13863. case wx.FieldCreatedAt:
  13864. return m.OldCreatedAt(ctx)
  13865. case wx.FieldUpdatedAt:
  13866. return m.OldUpdatedAt(ctx)
  13867. case wx.FieldStatus:
  13868. return m.OldStatus(ctx)
  13869. case wx.FieldDeletedAt:
  13870. return m.OldDeletedAt(ctx)
  13871. case wx.FieldServerID:
  13872. return m.OldServerID(ctx)
  13873. case wx.FieldPort:
  13874. return m.OldPort(ctx)
  13875. case wx.FieldProcessID:
  13876. return m.OldProcessID(ctx)
  13877. case wx.FieldCallback:
  13878. return m.OldCallback(ctx)
  13879. case wx.FieldWxid:
  13880. return m.OldWxid(ctx)
  13881. case wx.FieldAccount:
  13882. return m.OldAccount(ctx)
  13883. case wx.FieldNickname:
  13884. return m.OldNickname(ctx)
  13885. case wx.FieldTel:
  13886. return m.OldTel(ctx)
  13887. case wx.FieldHeadBig:
  13888. return m.OldHeadBig(ctx)
  13889. case wx.FieldOrganizationID:
  13890. return m.OldOrganizationID(ctx)
  13891. case wx.FieldAgentID:
  13892. return m.OldAgentID(ctx)
  13893. }
  13894. return nil, fmt.Errorf("unknown Wx field %s", name)
  13895. }
  13896. // SetField sets the value of a field with the given name. It returns an error if
  13897. // the field is not defined in the schema, or if the type mismatched the field
  13898. // type.
  13899. func (m *WxMutation) SetField(name string, value ent.Value) error {
  13900. switch name {
  13901. case wx.FieldCreatedAt:
  13902. v, ok := value.(time.Time)
  13903. if !ok {
  13904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13905. }
  13906. m.SetCreatedAt(v)
  13907. return nil
  13908. case wx.FieldUpdatedAt:
  13909. v, ok := value.(time.Time)
  13910. if !ok {
  13911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13912. }
  13913. m.SetUpdatedAt(v)
  13914. return nil
  13915. case wx.FieldStatus:
  13916. v, ok := value.(uint8)
  13917. if !ok {
  13918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13919. }
  13920. m.SetStatus(v)
  13921. return nil
  13922. case wx.FieldDeletedAt:
  13923. v, ok := value.(time.Time)
  13924. if !ok {
  13925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13926. }
  13927. m.SetDeletedAt(v)
  13928. return nil
  13929. case wx.FieldServerID:
  13930. v, ok := value.(uint64)
  13931. if !ok {
  13932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13933. }
  13934. m.SetServerID(v)
  13935. return nil
  13936. case wx.FieldPort:
  13937. v, ok := value.(string)
  13938. if !ok {
  13939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13940. }
  13941. m.SetPort(v)
  13942. return nil
  13943. case wx.FieldProcessID:
  13944. v, ok := value.(string)
  13945. if !ok {
  13946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13947. }
  13948. m.SetProcessID(v)
  13949. return nil
  13950. case wx.FieldCallback:
  13951. v, ok := value.(string)
  13952. if !ok {
  13953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13954. }
  13955. m.SetCallback(v)
  13956. return nil
  13957. case wx.FieldWxid:
  13958. v, ok := value.(string)
  13959. if !ok {
  13960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13961. }
  13962. m.SetWxid(v)
  13963. return nil
  13964. case wx.FieldAccount:
  13965. v, ok := value.(string)
  13966. if !ok {
  13967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13968. }
  13969. m.SetAccount(v)
  13970. return nil
  13971. case wx.FieldNickname:
  13972. v, ok := value.(string)
  13973. if !ok {
  13974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13975. }
  13976. m.SetNickname(v)
  13977. return nil
  13978. case wx.FieldTel:
  13979. v, ok := value.(string)
  13980. if !ok {
  13981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13982. }
  13983. m.SetTel(v)
  13984. return nil
  13985. case wx.FieldHeadBig:
  13986. v, ok := value.(string)
  13987. if !ok {
  13988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13989. }
  13990. m.SetHeadBig(v)
  13991. return nil
  13992. case wx.FieldOrganizationID:
  13993. v, ok := value.(uint64)
  13994. if !ok {
  13995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13996. }
  13997. m.SetOrganizationID(v)
  13998. return nil
  13999. case wx.FieldAgentID:
  14000. v, ok := value.(uint64)
  14001. if !ok {
  14002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14003. }
  14004. m.SetAgentID(v)
  14005. return nil
  14006. }
  14007. return fmt.Errorf("unknown Wx field %s", name)
  14008. }
  14009. // AddedFields returns all numeric fields that were incremented/decremented during
  14010. // this mutation.
  14011. func (m *WxMutation) AddedFields() []string {
  14012. var fields []string
  14013. if m.addstatus != nil {
  14014. fields = append(fields, wx.FieldStatus)
  14015. }
  14016. if m.addorganization_id != nil {
  14017. fields = append(fields, wx.FieldOrganizationID)
  14018. }
  14019. return fields
  14020. }
  14021. // AddedField returns the numeric value that was incremented/decremented on a field
  14022. // with the given name. The second boolean return value indicates that this field
  14023. // was not set, or was not defined in the schema.
  14024. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  14025. switch name {
  14026. case wx.FieldStatus:
  14027. return m.AddedStatus()
  14028. case wx.FieldOrganizationID:
  14029. return m.AddedOrganizationID()
  14030. }
  14031. return nil, false
  14032. }
  14033. // AddField adds the value to the field with the given name. It returns an error if
  14034. // the field is not defined in the schema, or if the type mismatched the field
  14035. // type.
  14036. func (m *WxMutation) AddField(name string, value ent.Value) error {
  14037. switch name {
  14038. case wx.FieldStatus:
  14039. v, ok := value.(int8)
  14040. if !ok {
  14041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14042. }
  14043. m.AddStatus(v)
  14044. return nil
  14045. case wx.FieldOrganizationID:
  14046. v, ok := value.(int64)
  14047. if !ok {
  14048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14049. }
  14050. m.AddOrganizationID(v)
  14051. return nil
  14052. }
  14053. return fmt.Errorf("unknown Wx numeric field %s", name)
  14054. }
  14055. // ClearedFields returns all nullable fields that were cleared during this
  14056. // mutation.
  14057. func (m *WxMutation) ClearedFields() []string {
  14058. var fields []string
  14059. if m.FieldCleared(wx.FieldStatus) {
  14060. fields = append(fields, wx.FieldStatus)
  14061. }
  14062. if m.FieldCleared(wx.FieldDeletedAt) {
  14063. fields = append(fields, wx.FieldDeletedAt)
  14064. }
  14065. if m.FieldCleared(wx.FieldServerID) {
  14066. fields = append(fields, wx.FieldServerID)
  14067. }
  14068. if m.FieldCleared(wx.FieldOrganizationID) {
  14069. fields = append(fields, wx.FieldOrganizationID)
  14070. }
  14071. return fields
  14072. }
  14073. // FieldCleared returns a boolean indicating if a field with the given name was
  14074. // cleared in this mutation.
  14075. func (m *WxMutation) FieldCleared(name string) bool {
  14076. _, ok := m.clearedFields[name]
  14077. return ok
  14078. }
  14079. // ClearField clears the value of the field with the given name. It returns an
  14080. // error if the field is not defined in the schema.
  14081. func (m *WxMutation) ClearField(name string) error {
  14082. switch name {
  14083. case wx.FieldStatus:
  14084. m.ClearStatus()
  14085. return nil
  14086. case wx.FieldDeletedAt:
  14087. m.ClearDeletedAt()
  14088. return nil
  14089. case wx.FieldServerID:
  14090. m.ClearServerID()
  14091. return nil
  14092. case wx.FieldOrganizationID:
  14093. m.ClearOrganizationID()
  14094. return nil
  14095. }
  14096. return fmt.Errorf("unknown Wx nullable field %s", name)
  14097. }
  14098. // ResetField resets all changes in the mutation for the field with the given name.
  14099. // It returns an error if the field is not defined in the schema.
  14100. func (m *WxMutation) ResetField(name string) error {
  14101. switch name {
  14102. case wx.FieldCreatedAt:
  14103. m.ResetCreatedAt()
  14104. return nil
  14105. case wx.FieldUpdatedAt:
  14106. m.ResetUpdatedAt()
  14107. return nil
  14108. case wx.FieldStatus:
  14109. m.ResetStatus()
  14110. return nil
  14111. case wx.FieldDeletedAt:
  14112. m.ResetDeletedAt()
  14113. return nil
  14114. case wx.FieldServerID:
  14115. m.ResetServerID()
  14116. return nil
  14117. case wx.FieldPort:
  14118. m.ResetPort()
  14119. return nil
  14120. case wx.FieldProcessID:
  14121. m.ResetProcessID()
  14122. return nil
  14123. case wx.FieldCallback:
  14124. m.ResetCallback()
  14125. return nil
  14126. case wx.FieldWxid:
  14127. m.ResetWxid()
  14128. return nil
  14129. case wx.FieldAccount:
  14130. m.ResetAccount()
  14131. return nil
  14132. case wx.FieldNickname:
  14133. m.ResetNickname()
  14134. return nil
  14135. case wx.FieldTel:
  14136. m.ResetTel()
  14137. return nil
  14138. case wx.FieldHeadBig:
  14139. m.ResetHeadBig()
  14140. return nil
  14141. case wx.FieldOrganizationID:
  14142. m.ResetOrganizationID()
  14143. return nil
  14144. case wx.FieldAgentID:
  14145. m.ResetAgentID()
  14146. return nil
  14147. }
  14148. return fmt.Errorf("unknown Wx field %s", name)
  14149. }
  14150. // AddedEdges returns all edge names that were set/added in this mutation.
  14151. func (m *WxMutation) AddedEdges() []string {
  14152. edges := make([]string, 0, 2)
  14153. if m.server != nil {
  14154. edges = append(edges, wx.EdgeServer)
  14155. }
  14156. if m.agent != nil {
  14157. edges = append(edges, wx.EdgeAgent)
  14158. }
  14159. return edges
  14160. }
  14161. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14162. // name in this mutation.
  14163. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  14164. switch name {
  14165. case wx.EdgeServer:
  14166. if id := m.server; id != nil {
  14167. return []ent.Value{*id}
  14168. }
  14169. case wx.EdgeAgent:
  14170. if id := m.agent; id != nil {
  14171. return []ent.Value{*id}
  14172. }
  14173. }
  14174. return nil
  14175. }
  14176. // RemovedEdges returns all edge names that were removed in this mutation.
  14177. func (m *WxMutation) RemovedEdges() []string {
  14178. edges := make([]string, 0, 2)
  14179. return edges
  14180. }
  14181. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14182. // the given name in this mutation.
  14183. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  14184. return nil
  14185. }
  14186. // ClearedEdges returns all edge names that were cleared in this mutation.
  14187. func (m *WxMutation) ClearedEdges() []string {
  14188. edges := make([]string, 0, 2)
  14189. if m.clearedserver {
  14190. edges = append(edges, wx.EdgeServer)
  14191. }
  14192. if m.clearedagent {
  14193. edges = append(edges, wx.EdgeAgent)
  14194. }
  14195. return edges
  14196. }
  14197. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14198. // was cleared in this mutation.
  14199. func (m *WxMutation) EdgeCleared(name string) bool {
  14200. switch name {
  14201. case wx.EdgeServer:
  14202. return m.clearedserver
  14203. case wx.EdgeAgent:
  14204. return m.clearedagent
  14205. }
  14206. return false
  14207. }
  14208. // ClearEdge clears the value of the edge with the given name. It returns an error
  14209. // if that edge is not defined in the schema.
  14210. func (m *WxMutation) ClearEdge(name string) error {
  14211. switch name {
  14212. case wx.EdgeServer:
  14213. m.ClearServer()
  14214. return nil
  14215. case wx.EdgeAgent:
  14216. m.ClearAgent()
  14217. return nil
  14218. }
  14219. return fmt.Errorf("unknown Wx unique edge %s", name)
  14220. }
  14221. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14222. // It returns an error if the edge is not defined in the schema.
  14223. func (m *WxMutation) ResetEdge(name string) error {
  14224. switch name {
  14225. case wx.EdgeServer:
  14226. m.ResetServer()
  14227. return nil
  14228. case wx.EdgeAgent:
  14229. m.ResetAgent()
  14230. return nil
  14231. }
  14232. return fmt.Errorf("unknown Wx edge %s", name)
  14233. }