mutation.go 629 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383
  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/category"
  12. "wechat-api/ent/contact"
  13. "wechat-api/ent/custom_types"
  14. "wechat-api/ent/employee"
  15. "wechat-api/ent/employeeconfig"
  16. "wechat-api/ent/label"
  17. "wechat-api/ent/labelrelationship"
  18. "wechat-api/ent/message"
  19. "wechat-api/ent/messagerecords"
  20. "wechat-api/ent/msg"
  21. "wechat-api/ent/predicate"
  22. "wechat-api/ent/server"
  23. "wechat-api/ent/sopnode"
  24. "wechat-api/ent/sopstage"
  25. "wechat-api/ent/soptask"
  26. "wechat-api/ent/token"
  27. "wechat-api/ent/tutorial"
  28. "wechat-api/ent/workexperience"
  29. "wechat-api/ent/wx"
  30. "entgo.io/ent"
  31. "entgo.io/ent/dialect/sql"
  32. )
  33. const (
  34. // Operation types.
  35. OpCreate = ent.OpCreate
  36. OpDelete = ent.OpDelete
  37. OpDeleteOne = ent.OpDeleteOne
  38. OpUpdate = ent.OpUpdate
  39. OpUpdateOne = ent.OpUpdateOne
  40. // Node types.
  41. TypeAgent = "Agent"
  42. TypeBatchMsg = "BatchMsg"
  43. TypeCategory = "Category"
  44. TypeContact = "Contact"
  45. TypeEmployee = "Employee"
  46. TypeEmployeeConfig = "EmployeeConfig"
  47. TypeLabel = "Label"
  48. TypeLabelRelationship = "LabelRelationship"
  49. TypeMessage = "Message"
  50. TypeMessageRecords = "MessageRecords"
  51. TypeMsg = "Msg"
  52. TypeServer = "Server"
  53. TypeSopNode = "SopNode"
  54. TypeSopStage = "SopStage"
  55. TypeSopTask = "SopTask"
  56. TypeToken = "Token"
  57. TypeTutorial = "Tutorial"
  58. TypeWorkExperience = "WorkExperience"
  59. TypeWx = "Wx"
  60. )
  61. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  62. type AgentMutation struct {
  63. config
  64. op Op
  65. typ string
  66. id *uint64
  67. created_at *time.Time
  68. updated_at *time.Time
  69. deleted_at *time.Time
  70. name *string
  71. role *string
  72. status *int
  73. addstatus *int
  74. background *string
  75. examples *string
  76. organization_id *uint64
  77. addorganization_id *int64
  78. clearedFields map[string]struct{}
  79. wx_agent map[uint64]struct{}
  80. removedwx_agent map[uint64]struct{}
  81. clearedwx_agent bool
  82. done bool
  83. oldValue func(context.Context) (*Agent, error)
  84. predicates []predicate.Agent
  85. }
  86. var _ ent.Mutation = (*AgentMutation)(nil)
  87. // agentOption allows management of the mutation configuration using functional options.
  88. type agentOption func(*AgentMutation)
  89. // newAgentMutation creates new mutation for the Agent entity.
  90. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  91. m := &AgentMutation{
  92. config: c,
  93. op: op,
  94. typ: TypeAgent,
  95. clearedFields: make(map[string]struct{}),
  96. }
  97. for _, opt := range opts {
  98. opt(m)
  99. }
  100. return m
  101. }
  102. // withAgentID sets the ID field of the mutation.
  103. func withAgentID(id uint64) agentOption {
  104. return func(m *AgentMutation) {
  105. var (
  106. err error
  107. once sync.Once
  108. value *Agent
  109. )
  110. m.oldValue = func(ctx context.Context) (*Agent, error) {
  111. once.Do(func() {
  112. if m.done {
  113. err = errors.New("querying old values post mutation is not allowed")
  114. } else {
  115. value, err = m.Client().Agent.Get(ctx, id)
  116. }
  117. })
  118. return value, err
  119. }
  120. m.id = &id
  121. }
  122. }
  123. // withAgent sets the old Agent of the mutation.
  124. func withAgent(node *Agent) agentOption {
  125. return func(m *AgentMutation) {
  126. m.oldValue = func(context.Context) (*Agent, error) {
  127. return node, nil
  128. }
  129. m.id = &node.ID
  130. }
  131. }
  132. // Client returns a new `ent.Client` from the mutation. If the mutation was
  133. // executed in a transaction (ent.Tx), a transactional client is returned.
  134. func (m AgentMutation) Client() *Client {
  135. client := &Client{config: m.config}
  136. client.init()
  137. return client
  138. }
  139. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  140. // it returns an error otherwise.
  141. func (m AgentMutation) Tx() (*Tx, error) {
  142. if _, ok := m.driver.(*txDriver); !ok {
  143. return nil, errors.New("ent: mutation is not running in a transaction")
  144. }
  145. tx := &Tx{config: m.config}
  146. tx.init()
  147. return tx, nil
  148. }
  149. // SetID sets the value of the id field. Note that this
  150. // operation is only accepted on creation of Agent entities.
  151. func (m *AgentMutation) SetID(id uint64) {
  152. m.id = &id
  153. }
  154. // ID returns the ID value in the mutation. Note that the ID is only available
  155. // if it was provided to the builder or after it was returned from the database.
  156. func (m *AgentMutation) ID() (id uint64, exists bool) {
  157. if m.id == nil {
  158. return
  159. }
  160. return *m.id, true
  161. }
  162. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  163. // That means, if the mutation is applied within a transaction with an isolation level such
  164. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  165. // or updated by the mutation.
  166. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  167. switch {
  168. case m.op.Is(OpUpdateOne | OpDeleteOne):
  169. id, exists := m.ID()
  170. if exists {
  171. return []uint64{id}, nil
  172. }
  173. fallthrough
  174. case m.op.Is(OpUpdate | OpDelete):
  175. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  176. default:
  177. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  178. }
  179. }
  180. // SetCreatedAt sets the "created_at" field.
  181. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  182. m.created_at = &t
  183. }
  184. // CreatedAt returns the value of the "created_at" field in the mutation.
  185. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  186. v := m.created_at
  187. if v == nil {
  188. return
  189. }
  190. return *v, true
  191. }
  192. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  193. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  194. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  195. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  196. if !m.op.Is(OpUpdateOne) {
  197. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  198. }
  199. if m.id == nil || m.oldValue == nil {
  200. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  201. }
  202. oldValue, err := m.oldValue(ctx)
  203. if err != nil {
  204. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  205. }
  206. return oldValue.CreatedAt, nil
  207. }
  208. // ResetCreatedAt resets all changes to the "created_at" field.
  209. func (m *AgentMutation) ResetCreatedAt() {
  210. m.created_at = nil
  211. }
  212. // SetUpdatedAt sets the "updated_at" field.
  213. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  214. m.updated_at = &t
  215. }
  216. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  217. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  218. v := m.updated_at
  219. if v == nil {
  220. return
  221. }
  222. return *v, true
  223. }
  224. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  225. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  227. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  228. if !m.op.Is(OpUpdateOne) {
  229. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  230. }
  231. if m.id == nil || m.oldValue == nil {
  232. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  233. }
  234. oldValue, err := m.oldValue(ctx)
  235. if err != nil {
  236. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  237. }
  238. return oldValue.UpdatedAt, nil
  239. }
  240. // ResetUpdatedAt resets all changes to the "updated_at" field.
  241. func (m *AgentMutation) ResetUpdatedAt() {
  242. m.updated_at = nil
  243. }
  244. // SetDeletedAt sets the "deleted_at" field.
  245. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  246. m.deleted_at = &t
  247. }
  248. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  249. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  250. v := m.deleted_at
  251. if v == nil {
  252. return
  253. }
  254. return *v, true
  255. }
  256. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  257. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  259. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  260. if !m.op.Is(OpUpdateOne) {
  261. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  262. }
  263. if m.id == nil || m.oldValue == nil {
  264. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  265. }
  266. oldValue, err := m.oldValue(ctx)
  267. if err != nil {
  268. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  269. }
  270. return oldValue.DeletedAt, nil
  271. }
  272. // ClearDeletedAt clears the value of the "deleted_at" field.
  273. func (m *AgentMutation) ClearDeletedAt() {
  274. m.deleted_at = nil
  275. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  276. }
  277. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  278. func (m *AgentMutation) DeletedAtCleared() bool {
  279. _, ok := m.clearedFields[agent.FieldDeletedAt]
  280. return ok
  281. }
  282. // ResetDeletedAt resets all changes to the "deleted_at" field.
  283. func (m *AgentMutation) ResetDeletedAt() {
  284. m.deleted_at = nil
  285. delete(m.clearedFields, agent.FieldDeletedAt)
  286. }
  287. // SetName sets the "name" field.
  288. func (m *AgentMutation) SetName(s string) {
  289. m.name = &s
  290. }
  291. // Name returns the value of the "name" field in the mutation.
  292. func (m *AgentMutation) Name() (r string, exists bool) {
  293. v := m.name
  294. if v == nil {
  295. return
  296. }
  297. return *v, true
  298. }
  299. // OldName returns the old "name" field's value of the Agent entity.
  300. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  302. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  303. if !m.op.Is(OpUpdateOne) {
  304. return v, errors.New("OldName is only allowed on UpdateOne operations")
  305. }
  306. if m.id == nil || m.oldValue == nil {
  307. return v, errors.New("OldName requires an ID field in the mutation")
  308. }
  309. oldValue, err := m.oldValue(ctx)
  310. if err != nil {
  311. return v, fmt.Errorf("querying old value for OldName: %w", err)
  312. }
  313. return oldValue.Name, nil
  314. }
  315. // ResetName resets all changes to the "name" field.
  316. func (m *AgentMutation) ResetName() {
  317. m.name = nil
  318. }
  319. // SetRole sets the "role" field.
  320. func (m *AgentMutation) SetRole(s string) {
  321. m.role = &s
  322. }
  323. // Role returns the value of the "role" field in the mutation.
  324. func (m *AgentMutation) Role() (r string, exists bool) {
  325. v := m.role
  326. if v == nil {
  327. return
  328. }
  329. return *v, true
  330. }
  331. // OldRole returns the old "role" field's value of the Agent entity.
  332. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  334. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  335. if !m.op.Is(OpUpdateOne) {
  336. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  337. }
  338. if m.id == nil || m.oldValue == nil {
  339. return v, errors.New("OldRole requires an ID field in the mutation")
  340. }
  341. oldValue, err := m.oldValue(ctx)
  342. if err != nil {
  343. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  344. }
  345. return oldValue.Role, nil
  346. }
  347. // ResetRole resets all changes to the "role" field.
  348. func (m *AgentMutation) ResetRole() {
  349. m.role = nil
  350. }
  351. // SetStatus sets the "status" field.
  352. func (m *AgentMutation) SetStatus(i int) {
  353. m.status = &i
  354. m.addstatus = nil
  355. }
  356. // Status returns the value of the "status" field in the mutation.
  357. func (m *AgentMutation) Status() (r int, exists bool) {
  358. v := m.status
  359. if v == nil {
  360. return
  361. }
  362. return *v, true
  363. }
  364. // OldStatus returns the old "status" field's value of the Agent entity.
  365. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  367. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  368. if !m.op.Is(OpUpdateOne) {
  369. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  370. }
  371. if m.id == nil || m.oldValue == nil {
  372. return v, errors.New("OldStatus requires an ID field in the mutation")
  373. }
  374. oldValue, err := m.oldValue(ctx)
  375. if err != nil {
  376. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  377. }
  378. return oldValue.Status, nil
  379. }
  380. // AddStatus adds i to the "status" field.
  381. func (m *AgentMutation) AddStatus(i int) {
  382. if m.addstatus != nil {
  383. *m.addstatus += i
  384. } else {
  385. m.addstatus = &i
  386. }
  387. }
  388. // AddedStatus returns the value that was added to the "status" field in this mutation.
  389. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  390. v := m.addstatus
  391. if v == nil {
  392. return
  393. }
  394. return *v, true
  395. }
  396. // ClearStatus clears the value of the "status" field.
  397. func (m *AgentMutation) ClearStatus() {
  398. m.status = nil
  399. m.addstatus = nil
  400. m.clearedFields[agent.FieldStatus] = struct{}{}
  401. }
  402. // StatusCleared returns if the "status" field was cleared in this mutation.
  403. func (m *AgentMutation) StatusCleared() bool {
  404. _, ok := m.clearedFields[agent.FieldStatus]
  405. return ok
  406. }
  407. // ResetStatus resets all changes to the "status" field.
  408. func (m *AgentMutation) ResetStatus() {
  409. m.status = nil
  410. m.addstatus = nil
  411. delete(m.clearedFields, agent.FieldStatus)
  412. }
  413. // SetBackground sets the "background" field.
  414. func (m *AgentMutation) SetBackground(s string) {
  415. m.background = &s
  416. }
  417. // Background returns the value of the "background" field in the mutation.
  418. func (m *AgentMutation) Background() (r string, exists bool) {
  419. v := m.background
  420. if v == nil {
  421. return
  422. }
  423. return *v, true
  424. }
  425. // OldBackground returns the old "background" field's value of the Agent entity.
  426. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  428. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  429. if !m.op.Is(OpUpdateOne) {
  430. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  431. }
  432. if m.id == nil || m.oldValue == nil {
  433. return v, errors.New("OldBackground requires an ID field in the mutation")
  434. }
  435. oldValue, err := m.oldValue(ctx)
  436. if err != nil {
  437. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  438. }
  439. return oldValue.Background, nil
  440. }
  441. // ClearBackground clears the value of the "background" field.
  442. func (m *AgentMutation) ClearBackground() {
  443. m.background = nil
  444. m.clearedFields[agent.FieldBackground] = struct{}{}
  445. }
  446. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  447. func (m *AgentMutation) BackgroundCleared() bool {
  448. _, ok := m.clearedFields[agent.FieldBackground]
  449. return ok
  450. }
  451. // ResetBackground resets all changes to the "background" field.
  452. func (m *AgentMutation) ResetBackground() {
  453. m.background = nil
  454. delete(m.clearedFields, agent.FieldBackground)
  455. }
  456. // SetExamples sets the "examples" field.
  457. func (m *AgentMutation) SetExamples(s string) {
  458. m.examples = &s
  459. }
  460. // Examples returns the value of the "examples" field in the mutation.
  461. func (m *AgentMutation) Examples() (r string, exists bool) {
  462. v := m.examples
  463. if v == nil {
  464. return
  465. }
  466. return *v, true
  467. }
  468. // OldExamples returns the old "examples" field's value of the Agent entity.
  469. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  470. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  471. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  472. if !m.op.Is(OpUpdateOne) {
  473. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  474. }
  475. if m.id == nil || m.oldValue == nil {
  476. return v, errors.New("OldExamples requires an ID field in the mutation")
  477. }
  478. oldValue, err := m.oldValue(ctx)
  479. if err != nil {
  480. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  481. }
  482. return oldValue.Examples, nil
  483. }
  484. // ClearExamples clears the value of the "examples" field.
  485. func (m *AgentMutation) ClearExamples() {
  486. m.examples = nil
  487. m.clearedFields[agent.FieldExamples] = struct{}{}
  488. }
  489. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  490. func (m *AgentMutation) ExamplesCleared() bool {
  491. _, ok := m.clearedFields[agent.FieldExamples]
  492. return ok
  493. }
  494. // ResetExamples resets all changes to the "examples" field.
  495. func (m *AgentMutation) ResetExamples() {
  496. m.examples = nil
  497. delete(m.clearedFields, agent.FieldExamples)
  498. }
  499. // SetOrganizationID sets the "organization_id" field.
  500. func (m *AgentMutation) SetOrganizationID(u uint64) {
  501. m.organization_id = &u
  502. m.addorganization_id = nil
  503. }
  504. // OrganizationID returns the value of the "organization_id" field in the mutation.
  505. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  506. v := m.organization_id
  507. if v == nil {
  508. return
  509. }
  510. return *v, true
  511. }
  512. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  513. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  515. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  516. if !m.op.Is(OpUpdateOne) {
  517. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  518. }
  519. if m.id == nil || m.oldValue == nil {
  520. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  521. }
  522. oldValue, err := m.oldValue(ctx)
  523. if err != nil {
  524. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  525. }
  526. return oldValue.OrganizationID, nil
  527. }
  528. // AddOrganizationID adds u to the "organization_id" field.
  529. func (m *AgentMutation) AddOrganizationID(u int64) {
  530. if m.addorganization_id != nil {
  531. *m.addorganization_id += u
  532. } else {
  533. m.addorganization_id = &u
  534. }
  535. }
  536. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  537. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  538. v := m.addorganization_id
  539. if v == nil {
  540. return
  541. }
  542. return *v, true
  543. }
  544. // ResetOrganizationID resets all changes to the "organization_id" field.
  545. func (m *AgentMutation) ResetOrganizationID() {
  546. m.organization_id = nil
  547. m.addorganization_id = nil
  548. }
  549. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  550. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  551. if m.wx_agent == nil {
  552. m.wx_agent = make(map[uint64]struct{})
  553. }
  554. for i := range ids {
  555. m.wx_agent[ids[i]] = struct{}{}
  556. }
  557. }
  558. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  559. func (m *AgentMutation) ClearWxAgent() {
  560. m.clearedwx_agent = true
  561. }
  562. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  563. func (m *AgentMutation) WxAgentCleared() bool {
  564. return m.clearedwx_agent
  565. }
  566. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  567. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  568. if m.removedwx_agent == nil {
  569. m.removedwx_agent = make(map[uint64]struct{})
  570. }
  571. for i := range ids {
  572. delete(m.wx_agent, ids[i])
  573. m.removedwx_agent[ids[i]] = struct{}{}
  574. }
  575. }
  576. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  577. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  578. for id := range m.removedwx_agent {
  579. ids = append(ids, id)
  580. }
  581. return
  582. }
  583. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  584. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  585. for id := range m.wx_agent {
  586. ids = append(ids, id)
  587. }
  588. return
  589. }
  590. // ResetWxAgent resets all changes to the "wx_agent" edge.
  591. func (m *AgentMutation) ResetWxAgent() {
  592. m.wx_agent = nil
  593. m.clearedwx_agent = false
  594. m.removedwx_agent = nil
  595. }
  596. // Where appends a list predicates to the AgentMutation builder.
  597. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  598. m.predicates = append(m.predicates, ps...)
  599. }
  600. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  601. // users can use type-assertion to append predicates that do not depend on any generated package.
  602. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  603. p := make([]predicate.Agent, len(ps))
  604. for i := range ps {
  605. p[i] = ps[i]
  606. }
  607. m.Where(p...)
  608. }
  609. // Op returns the operation name.
  610. func (m *AgentMutation) Op() Op {
  611. return m.op
  612. }
  613. // SetOp allows setting the mutation operation.
  614. func (m *AgentMutation) SetOp(op Op) {
  615. m.op = op
  616. }
  617. // Type returns the node type of this mutation (Agent).
  618. func (m *AgentMutation) Type() string {
  619. return m.typ
  620. }
  621. // Fields returns all fields that were changed during this mutation. Note that in
  622. // order to get all numeric fields that were incremented/decremented, call
  623. // AddedFields().
  624. func (m *AgentMutation) Fields() []string {
  625. fields := make([]string, 0, 9)
  626. if m.created_at != nil {
  627. fields = append(fields, agent.FieldCreatedAt)
  628. }
  629. if m.updated_at != nil {
  630. fields = append(fields, agent.FieldUpdatedAt)
  631. }
  632. if m.deleted_at != nil {
  633. fields = append(fields, agent.FieldDeletedAt)
  634. }
  635. if m.name != nil {
  636. fields = append(fields, agent.FieldName)
  637. }
  638. if m.role != nil {
  639. fields = append(fields, agent.FieldRole)
  640. }
  641. if m.status != nil {
  642. fields = append(fields, agent.FieldStatus)
  643. }
  644. if m.background != nil {
  645. fields = append(fields, agent.FieldBackground)
  646. }
  647. if m.examples != nil {
  648. fields = append(fields, agent.FieldExamples)
  649. }
  650. if m.organization_id != nil {
  651. fields = append(fields, agent.FieldOrganizationID)
  652. }
  653. return fields
  654. }
  655. // Field returns the value of a field with the given name. The second boolean
  656. // return value indicates that this field was not set, or was not defined in the
  657. // schema.
  658. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  659. switch name {
  660. case agent.FieldCreatedAt:
  661. return m.CreatedAt()
  662. case agent.FieldUpdatedAt:
  663. return m.UpdatedAt()
  664. case agent.FieldDeletedAt:
  665. return m.DeletedAt()
  666. case agent.FieldName:
  667. return m.Name()
  668. case agent.FieldRole:
  669. return m.Role()
  670. case agent.FieldStatus:
  671. return m.Status()
  672. case agent.FieldBackground:
  673. return m.Background()
  674. case agent.FieldExamples:
  675. return m.Examples()
  676. case agent.FieldOrganizationID:
  677. return m.OrganizationID()
  678. }
  679. return nil, false
  680. }
  681. // OldField returns the old value of the field from the database. An error is
  682. // returned if the mutation operation is not UpdateOne, or the query to the
  683. // database failed.
  684. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  685. switch name {
  686. case agent.FieldCreatedAt:
  687. return m.OldCreatedAt(ctx)
  688. case agent.FieldUpdatedAt:
  689. return m.OldUpdatedAt(ctx)
  690. case agent.FieldDeletedAt:
  691. return m.OldDeletedAt(ctx)
  692. case agent.FieldName:
  693. return m.OldName(ctx)
  694. case agent.FieldRole:
  695. return m.OldRole(ctx)
  696. case agent.FieldStatus:
  697. return m.OldStatus(ctx)
  698. case agent.FieldBackground:
  699. return m.OldBackground(ctx)
  700. case agent.FieldExamples:
  701. return m.OldExamples(ctx)
  702. case agent.FieldOrganizationID:
  703. return m.OldOrganizationID(ctx)
  704. }
  705. return nil, fmt.Errorf("unknown Agent field %s", name)
  706. }
  707. // SetField sets the value of a field with the given name. It returns an error if
  708. // the field is not defined in the schema, or if the type mismatched the field
  709. // type.
  710. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  711. switch name {
  712. case agent.FieldCreatedAt:
  713. v, ok := value.(time.Time)
  714. if !ok {
  715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  716. }
  717. m.SetCreatedAt(v)
  718. return nil
  719. case agent.FieldUpdatedAt:
  720. v, ok := value.(time.Time)
  721. if !ok {
  722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  723. }
  724. m.SetUpdatedAt(v)
  725. return nil
  726. case agent.FieldDeletedAt:
  727. v, ok := value.(time.Time)
  728. if !ok {
  729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  730. }
  731. m.SetDeletedAt(v)
  732. return nil
  733. case agent.FieldName:
  734. v, ok := value.(string)
  735. if !ok {
  736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  737. }
  738. m.SetName(v)
  739. return nil
  740. case agent.FieldRole:
  741. v, ok := value.(string)
  742. if !ok {
  743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  744. }
  745. m.SetRole(v)
  746. return nil
  747. case agent.FieldStatus:
  748. v, ok := value.(int)
  749. if !ok {
  750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  751. }
  752. m.SetStatus(v)
  753. return nil
  754. case agent.FieldBackground:
  755. v, ok := value.(string)
  756. if !ok {
  757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  758. }
  759. m.SetBackground(v)
  760. return nil
  761. case agent.FieldExamples:
  762. v, ok := value.(string)
  763. if !ok {
  764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  765. }
  766. m.SetExamples(v)
  767. return nil
  768. case agent.FieldOrganizationID:
  769. v, ok := value.(uint64)
  770. if !ok {
  771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  772. }
  773. m.SetOrganizationID(v)
  774. return nil
  775. }
  776. return fmt.Errorf("unknown Agent field %s", name)
  777. }
  778. // AddedFields returns all numeric fields that were incremented/decremented during
  779. // this mutation.
  780. func (m *AgentMutation) AddedFields() []string {
  781. var fields []string
  782. if m.addstatus != nil {
  783. fields = append(fields, agent.FieldStatus)
  784. }
  785. if m.addorganization_id != nil {
  786. fields = append(fields, agent.FieldOrganizationID)
  787. }
  788. return fields
  789. }
  790. // AddedField returns the numeric value that was incremented/decremented on a field
  791. // with the given name. The second boolean return value indicates that this field
  792. // was not set, or was not defined in the schema.
  793. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  794. switch name {
  795. case agent.FieldStatus:
  796. return m.AddedStatus()
  797. case agent.FieldOrganizationID:
  798. return m.AddedOrganizationID()
  799. }
  800. return nil, false
  801. }
  802. // AddField adds the value to the field with the given name. It returns an error if
  803. // the field is not defined in the schema, or if the type mismatched the field
  804. // type.
  805. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  806. switch name {
  807. case agent.FieldStatus:
  808. v, ok := value.(int)
  809. if !ok {
  810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  811. }
  812. m.AddStatus(v)
  813. return nil
  814. case agent.FieldOrganizationID:
  815. v, ok := value.(int64)
  816. if !ok {
  817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  818. }
  819. m.AddOrganizationID(v)
  820. return nil
  821. }
  822. return fmt.Errorf("unknown Agent numeric field %s", name)
  823. }
  824. // ClearedFields returns all nullable fields that were cleared during this
  825. // mutation.
  826. func (m *AgentMutation) ClearedFields() []string {
  827. var fields []string
  828. if m.FieldCleared(agent.FieldDeletedAt) {
  829. fields = append(fields, agent.FieldDeletedAt)
  830. }
  831. if m.FieldCleared(agent.FieldStatus) {
  832. fields = append(fields, agent.FieldStatus)
  833. }
  834. if m.FieldCleared(agent.FieldBackground) {
  835. fields = append(fields, agent.FieldBackground)
  836. }
  837. if m.FieldCleared(agent.FieldExamples) {
  838. fields = append(fields, agent.FieldExamples)
  839. }
  840. return fields
  841. }
  842. // FieldCleared returns a boolean indicating if a field with the given name was
  843. // cleared in this mutation.
  844. func (m *AgentMutation) FieldCleared(name string) bool {
  845. _, ok := m.clearedFields[name]
  846. return ok
  847. }
  848. // ClearField clears the value of the field with the given name. It returns an
  849. // error if the field is not defined in the schema.
  850. func (m *AgentMutation) ClearField(name string) error {
  851. switch name {
  852. case agent.FieldDeletedAt:
  853. m.ClearDeletedAt()
  854. return nil
  855. case agent.FieldStatus:
  856. m.ClearStatus()
  857. return nil
  858. case agent.FieldBackground:
  859. m.ClearBackground()
  860. return nil
  861. case agent.FieldExamples:
  862. m.ClearExamples()
  863. return nil
  864. }
  865. return fmt.Errorf("unknown Agent nullable field %s", name)
  866. }
  867. // ResetField resets all changes in the mutation for the field with the given name.
  868. // It returns an error if the field is not defined in the schema.
  869. func (m *AgentMutation) ResetField(name string) error {
  870. switch name {
  871. case agent.FieldCreatedAt:
  872. m.ResetCreatedAt()
  873. return nil
  874. case agent.FieldUpdatedAt:
  875. m.ResetUpdatedAt()
  876. return nil
  877. case agent.FieldDeletedAt:
  878. m.ResetDeletedAt()
  879. return nil
  880. case agent.FieldName:
  881. m.ResetName()
  882. return nil
  883. case agent.FieldRole:
  884. m.ResetRole()
  885. return nil
  886. case agent.FieldStatus:
  887. m.ResetStatus()
  888. return nil
  889. case agent.FieldBackground:
  890. m.ResetBackground()
  891. return nil
  892. case agent.FieldExamples:
  893. m.ResetExamples()
  894. return nil
  895. case agent.FieldOrganizationID:
  896. m.ResetOrganizationID()
  897. return nil
  898. }
  899. return fmt.Errorf("unknown Agent field %s", name)
  900. }
  901. // AddedEdges returns all edge names that were set/added in this mutation.
  902. func (m *AgentMutation) AddedEdges() []string {
  903. edges := make([]string, 0, 1)
  904. if m.wx_agent != nil {
  905. edges = append(edges, agent.EdgeWxAgent)
  906. }
  907. return edges
  908. }
  909. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  910. // name in this mutation.
  911. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  912. switch name {
  913. case agent.EdgeWxAgent:
  914. ids := make([]ent.Value, 0, len(m.wx_agent))
  915. for id := range m.wx_agent {
  916. ids = append(ids, id)
  917. }
  918. return ids
  919. }
  920. return nil
  921. }
  922. // RemovedEdges returns all edge names that were removed in this mutation.
  923. func (m *AgentMutation) RemovedEdges() []string {
  924. edges := make([]string, 0, 1)
  925. if m.removedwx_agent != nil {
  926. edges = append(edges, agent.EdgeWxAgent)
  927. }
  928. return edges
  929. }
  930. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  931. // the given name in this mutation.
  932. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  933. switch name {
  934. case agent.EdgeWxAgent:
  935. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  936. for id := range m.removedwx_agent {
  937. ids = append(ids, id)
  938. }
  939. return ids
  940. }
  941. return nil
  942. }
  943. // ClearedEdges returns all edge names that were cleared in this mutation.
  944. func (m *AgentMutation) ClearedEdges() []string {
  945. edges := make([]string, 0, 1)
  946. if m.clearedwx_agent {
  947. edges = append(edges, agent.EdgeWxAgent)
  948. }
  949. return edges
  950. }
  951. // EdgeCleared returns a boolean which indicates if the edge with the given name
  952. // was cleared in this mutation.
  953. func (m *AgentMutation) EdgeCleared(name string) bool {
  954. switch name {
  955. case agent.EdgeWxAgent:
  956. return m.clearedwx_agent
  957. }
  958. return false
  959. }
  960. // ClearEdge clears the value of the edge with the given name. It returns an error
  961. // if that edge is not defined in the schema.
  962. func (m *AgentMutation) ClearEdge(name string) error {
  963. switch name {
  964. }
  965. return fmt.Errorf("unknown Agent unique edge %s", name)
  966. }
  967. // ResetEdge resets all changes to the edge with the given name in this mutation.
  968. // It returns an error if the edge is not defined in the schema.
  969. func (m *AgentMutation) ResetEdge(name string) error {
  970. switch name {
  971. case agent.EdgeWxAgent:
  972. m.ResetWxAgent()
  973. return nil
  974. }
  975. return fmt.Errorf("unknown Agent edge %s", name)
  976. }
  977. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  978. type BatchMsgMutation struct {
  979. config
  980. op Op
  981. typ string
  982. id *uint64
  983. created_at *time.Time
  984. updated_at *time.Time
  985. deleted_at *time.Time
  986. status *uint8
  987. addstatus *int8
  988. batch_no *string
  989. task_name *string
  990. fromwxid *string
  991. msg *string
  992. tag *string
  993. total *int32
  994. addtotal *int32
  995. success *int32
  996. addsuccess *int32
  997. fail *int32
  998. addfail *int32
  999. start_time *time.Time
  1000. stop_time *time.Time
  1001. _type *int32
  1002. add_type *int32
  1003. organization_id *uint64
  1004. addorganization_id *int64
  1005. clearedFields map[string]struct{}
  1006. done bool
  1007. oldValue func(context.Context) (*BatchMsg, error)
  1008. predicates []predicate.BatchMsg
  1009. }
  1010. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  1011. // batchmsgOption allows management of the mutation configuration using functional options.
  1012. type batchmsgOption func(*BatchMsgMutation)
  1013. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  1014. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  1015. m := &BatchMsgMutation{
  1016. config: c,
  1017. op: op,
  1018. typ: TypeBatchMsg,
  1019. clearedFields: make(map[string]struct{}),
  1020. }
  1021. for _, opt := range opts {
  1022. opt(m)
  1023. }
  1024. return m
  1025. }
  1026. // withBatchMsgID sets the ID field of the mutation.
  1027. func withBatchMsgID(id uint64) batchmsgOption {
  1028. return func(m *BatchMsgMutation) {
  1029. var (
  1030. err error
  1031. once sync.Once
  1032. value *BatchMsg
  1033. )
  1034. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  1035. once.Do(func() {
  1036. if m.done {
  1037. err = errors.New("querying old values post mutation is not allowed")
  1038. } else {
  1039. value, err = m.Client().BatchMsg.Get(ctx, id)
  1040. }
  1041. })
  1042. return value, err
  1043. }
  1044. m.id = &id
  1045. }
  1046. }
  1047. // withBatchMsg sets the old BatchMsg of the mutation.
  1048. func withBatchMsg(node *BatchMsg) batchmsgOption {
  1049. return func(m *BatchMsgMutation) {
  1050. m.oldValue = func(context.Context) (*BatchMsg, error) {
  1051. return node, nil
  1052. }
  1053. m.id = &node.ID
  1054. }
  1055. }
  1056. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1057. // executed in a transaction (ent.Tx), a transactional client is returned.
  1058. func (m BatchMsgMutation) Client() *Client {
  1059. client := &Client{config: m.config}
  1060. client.init()
  1061. return client
  1062. }
  1063. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1064. // it returns an error otherwise.
  1065. func (m BatchMsgMutation) Tx() (*Tx, error) {
  1066. if _, ok := m.driver.(*txDriver); !ok {
  1067. return nil, errors.New("ent: mutation is not running in a transaction")
  1068. }
  1069. tx := &Tx{config: m.config}
  1070. tx.init()
  1071. return tx, nil
  1072. }
  1073. // SetID sets the value of the id field. Note that this
  1074. // operation is only accepted on creation of BatchMsg entities.
  1075. func (m *BatchMsgMutation) SetID(id uint64) {
  1076. m.id = &id
  1077. }
  1078. // ID returns the ID value in the mutation. Note that the ID is only available
  1079. // if it was provided to the builder or after it was returned from the database.
  1080. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  1081. if m.id == nil {
  1082. return
  1083. }
  1084. return *m.id, true
  1085. }
  1086. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1087. // That means, if the mutation is applied within a transaction with an isolation level such
  1088. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1089. // or updated by the mutation.
  1090. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  1091. switch {
  1092. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1093. id, exists := m.ID()
  1094. if exists {
  1095. return []uint64{id}, nil
  1096. }
  1097. fallthrough
  1098. case m.op.Is(OpUpdate | OpDelete):
  1099. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  1100. default:
  1101. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1102. }
  1103. }
  1104. // SetCreatedAt sets the "created_at" field.
  1105. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  1106. m.created_at = &t
  1107. }
  1108. // CreatedAt returns the value of the "created_at" field in the mutation.
  1109. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  1110. v := m.created_at
  1111. if v == nil {
  1112. return
  1113. }
  1114. return *v, true
  1115. }
  1116. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  1117. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1119. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  1120. if !m.op.Is(OpUpdateOne) {
  1121. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  1122. }
  1123. if m.id == nil || m.oldValue == nil {
  1124. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  1125. }
  1126. oldValue, err := m.oldValue(ctx)
  1127. if err != nil {
  1128. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  1129. }
  1130. return oldValue.CreatedAt, nil
  1131. }
  1132. // ResetCreatedAt resets all changes to the "created_at" field.
  1133. func (m *BatchMsgMutation) ResetCreatedAt() {
  1134. m.created_at = nil
  1135. }
  1136. // SetUpdatedAt sets the "updated_at" field.
  1137. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  1138. m.updated_at = &t
  1139. }
  1140. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  1141. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  1142. v := m.updated_at
  1143. if v == nil {
  1144. return
  1145. }
  1146. return *v, true
  1147. }
  1148. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  1149. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1151. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  1152. if !m.op.Is(OpUpdateOne) {
  1153. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  1154. }
  1155. if m.id == nil || m.oldValue == nil {
  1156. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  1157. }
  1158. oldValue, err := m.oldValue(ctx)
  1159. if err != nil {
  1160. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  1161. }
  1162. return oldValue.UpdatedAt, nil
  1163. }
  1164. // ResetUpdatedAt resets all changes to the "updated_at" field.
  1165. func (m *BatchMsgMutation) ResetUpdatedAt() {
  1166. m.updated_at = nil
  1167. }
  1168. // SetDeletedAt sets the "deleted_at" field.
  1169. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  1170. m.deleted_at = &t
  1171. }
  1172. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  1173. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  1174. v := m.deleted_at
  1175. if v == nil {
  1176. return
  1177. }
  1178. return *v, true
  1179. }
  1180. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  1181. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1183. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  1184. if !m.op.Is(OpUpdateOne) {
  1185. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  1186. }
  1187. if m.id == nil || m.oldValue == nil {
  1188. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  1189. }
  1190. oldValue, err := m.oldValue(ctx)
  1191. if err != nil {
  1192. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  1193. }
  1194. return oldValue.DeletedAt, nil
  1195. }
  1196. // ClearDeletedAt clears the value of the "deleted_at" field.
  1197. func (m *BatchMsgMutation) ClearDeletedAt() {
  1198. m.deleted_at = nil
  1199. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  1200. }
  1201. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  1202. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  1203. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  1204. return ok
  1205. }
  1206. // ResetDeletedAt resets all changes to the "deleted_at" field.
  1207. func (m *BatchMsgMutation) ResetDeletedAt() {
  1208. m.deleted_at = nil
  1209. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  1210. }
  1211. // SetStatus sets the "status" field.
  1212. func (m *BatchMsgMutation) SetStatus(u uint8) {
  1213. m.status = &u
  1214. m.addstatus = nil
  1215. }
  1216. // Status returns the value of the "status" field in the mutation.
  1217. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  1218. v := m.status
  1219. if v == nil {
  1220. return
  1221. }
  1222. return *v, true
  1223. }
  1224. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  1225. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1227. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  1228. if !m.op.Is(OpUpdateOne) {
  1229. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  1230. }
  1231. if m.id == nil || m.oldValue == nil {
  1232. return v, errors.New("OldStatus requires an ID field in the mutation")
  1233. }
  1234. oldValue, err := m.oldValue(ctx)
  1235. if err != nil {
  1236. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  1237. }
  1238. return oldValue.Status, nil
  1239. }
  1240. // AddStatus adds u to the "status" field.
  1241. func (m *BatchMsgMutation) AddStatus(u int8) {
  1242. if m.addstatus != nil {
  1243. *m.addstatus += u
  1244. } else {
  1245. m.addstatus = &u
  1246. }
  1247. }
  1248. // AddedStatus returns the value that was added to the "status" field in this mutation.
  1249. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  1250. v := m.addstatus
  1251. if v == nil {
  1252. return
  1253. }
  1254. return *v, true
  1255. }
  1256. // ClearStatus clears the value of the "status" field.
  1257. func (m *BatchMsgMutation) ClearStatus() {
  1258. m.status = nil
  1259. m.addstatus = nil
  1260. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  1261. }
  1262. // StatusCleared returns if the "status" field was cleared in this mutation.
  1263. func (m *BatchMsgMutation) StatusCleared() bool {
  1264. _, ok := m.clearedFields[batchmsg.FieldStatus]
  1265. return ok
  1266. }
  1267. // ResetStatus resets all changes to the "status" field.
  1268. func (m *BatchMsgMutation) ResetStatus() {
  1269. m.status = nil
  1270. m.addstatus = nil
  1271. delete(m.clearedFields, batchmsg.FieldStatus)
  1272. }
  1273. // SetBatchNo sets the "batch_no" field.
  1274. func (m *BatchMsgMutation) SetBatchNo(s string) {
  1275. m.batch_no = &s
  1276. }
  1277. // BatchNo returns the value of the "batch_no" field in the mutation.
  1278. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  1279. v := m.batch_no
  1280. if v == nil {
  1281. return
  1282. }
  1283. return *v, true
  1284. }
  1285. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  1286. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1288. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  1289. if !m.op.Is(OpUpdateOne) {
  1290. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  1291. }
  1292. if m.id == nil || m.oldValue == nil {
  1293. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  1294. }
  1295. oldValue, err := m.oldValue(ctx)
  1296. if err != nil {
  1297. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  1298. }
  1299. return oldValue.BatchNo, nil
  1300. }
  1301. // ClearBatchNo clears the value of the "batch_no" field.
  1302. func (m *BatchMsgMutation) ClearBatchNo() {
  1303. m.batch_no = nil
  1304. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  1305. }
  1306. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  1307. func (m *BatchMsgMutation) BatchNoCleared() bool {
  1308. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  1309. return ok
  1310. }
  1311. // ResetBatchNo resets all changes to the "batch_no" field.
  1312. func (m *BatchMsgMutation) ResetBatchNo() {
  1313. m.batch_no = nil
  1314. delete(m.clearedFields, batchmsg.FieldBatchNo)
  1315. }
  1316. // SetTaskName sets the "task_name" field.
  1317. func (m *BatchMsgMutation) SetTaskName(s string) {
  1318. m.task_name = &s
  1319. }
  1320. // TaskName returns the value of the "task_name" field in the mutation.
  1321. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  1322. v := m.task_name
  1323. if v == nil {
  1324. return
  1325. }
  1326. return *v, true
  1327. }
  1328. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  1329. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1331. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  1332. if !m.op.Is(OpUpdateOne) {
  1333. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  1334. }
  1335. if m.id == nil || m.oldValue == nil {
  1336. return v, errors.New("OldTaskName requires an ID field in the mutation")
  1337. }
  1338. oldValue, err := m.oldValue(ctx)
  1339. if err != nil {
  1340. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  1341. }
  1342. return oldValue.TaskName, nil
  1343. }
  1344. // ClearTaskName clears the value of the "task_name" field.
  1345. func (m *BatchMsgMutation) ClearTaskName() {
  1346. m.task_name = nil
  1347. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  1348. }
  1349. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  1350. func (m *BatchMsgMutation) TaskNameCleared() bool {
  1351. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  1352. return ok
  1353. }
  1354. // ResetTaskName resets all changes to the "task_name" field.
  1355. func (m *BatchMsgMutation) ResetTaskName() {
  1356. m.task_name = nil
  1357. delete(m.clearedFields, batchmsg.FieldTaskName)
  1358. }
  1359. // SetFromwxid sets the "fromwxid" field.
  1360. func (m *BatchMsgMutation) SetFromwxid(s string) {
  1361. m.fromwxid = &s
  1362. }
  1363. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  1364. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  1365. v := m.fromwxid
  1366. if v == nil {
  1367. return
  1368. }
  1369. return *v, true
  1370. }
  1371. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  1372. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1374. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  1375. if !m.op.Is(OpUpdateOne) {
  1376. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  1377. }
  1378. if m.id == nil || m.oldValue == nil {
  1379. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  1380. }
  1381. oldValue, err := m.oldValue(ctx)
  1382. if err != nil {
  1383. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  1384. }
  1385. return oldValue.Fromwxid, nil
  1386. }
  1387. // ClearFromwxid clears the value of the "fromwxid" field.
  1388. func (m *BatchMsgMutation) ClearFromwxid() {
  1389. m.fromwxid = nil
  1390. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  1391. }
  1392. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  1393. func (m *BatchMsgMutation) FromwxidCleared() bool {
  1394. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  1395. return ok
  1396. }
  1397. // ResetFromwxid resets all changes to the "fromwxid" field.
  1398. func (m *BatchMsgMutation) ResetFromwxid() {
  1399. m.fromwxid = nil
  1400. delete(m.clearedFields, batchmsg.FieldFromwxid)
  1401. }
  1402. // SetMsg sets the "msg" field.
  1403. func (m *BatchMsgMutation) SetMsg(s string) {
  1404. m.msg = &s
  1405. }
  1406. // Msg returns the value of the "msg" field in the mutation.
  1407. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  1408. v := m.msg
  1409. if v == nil {
  1410. return
  1411. }
  1412. return *v, true
  1413. }
  1414. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  1415. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1417. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  1418. if !m.op.Is(OpUpdateOne) {
  1419. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  1420. }
  1421. if m.id == nil || m.oldValue == nil {
  1422. return v, errors.New("OldMsg requires an ID field in the mutation")
  1423. }
  1424. oldValue, err := m.oldValue(ctx)
  1425. if err != nil {
  1426. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  1427. }
  1428. return oldValue.Msg, nil
  1429. }
  1430. // ClearMsg clears the value of the "msg" field.
  1431. func (m *BatchMsgMutation) ClearMsg() {
  1432. m.msg = nil
  1433. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  1434. }
  1435. // MsgCleared returns if the "msg" field was cleared in this mutation.
  1436. func (m *BatchMsgMutation) MsgCleared() bool {
  1437. _, ok := m.clearedFields[batchmsg.FieldMsg]
  1438. return ok
  1439. }
  1440. // ResetMsg resets all changes to the "msg" field.
  1441. func (m *BatchMsgMutation) ResetMsg() {
  1442. m.msg = nil
  1443. delete(m.clearedFields, batchmsg.FieldMsg)
  1444. }
  1445. // SetTag sets the "tag" field.
  1446. func (m *BatchMsgMutation) SetTag(s string) {
  1447. m.tag = &s
  1448. }
  1449. // Tag returns the value of the "tag" field in the mutation.
  1450. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  1451. v := m.tag
  1452. if v == nil {
  1453. return
  1454. }
  1455. return *v, true
  1456. }
  1457. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  1458. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1460. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  1461. if !m.op.Is(OpUpdateOne) {
  1462. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  1463. }
  1464. if m.id == nil || m.oldValue == nil {
  1465. return v, errors.New("OldTag requires an ID field in the mutation")
  1466. }
  1467. oldValue, err := m.oldValue(ctx)
  1468. if err != nil {
  1469. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  1470. }
  1471. return oldValue.Tag, nil
  1472. }
  1473. // ClearTag clears the value of the "tag" field.
  1474. func (m *BatchMsgMutation) ClearTag() {
  1475. m.tag = nil
  1476. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  1477. }
  1478. // TagCleared returns if the "tag" field was cleared in this mutation.
  1479. func (m *BatchMsgMutation) TagCleared() bool {
  1480. _, ok := m.clearedFields[batchmsg.FieldTag]
  1481. return ok
  1482. }
  1483. // ResetTag resets all changes to the "tag" field.
  1484. func (m *BatchMsgMutation) ResetTag() {
  1485. m.tag = nil
  1486. delete(m.clearedFields, batchmsg.FieldTag)
  1487. }
  1488. // SetTotal sets the "total" field.
  1489. func (m *BatchMsgMutation) SetTotal(i int32) {
  1490. m.total = &i
  1491. m.addtotal = nil
  1492. }
  1493. // Total returns the value of the "total" field in the mutation.
  1494. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  1495. v := m.total
  1496. if v == nil {
  1497. return
  1498. }
  1499. return *v, true
  1500. }
  1501. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  1502. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1504. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  1505. if !m.op.Is(OpUpdateOne) {
  1506. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  1507. }
  1508. if m.id == nil || m.oldValue == nil {
  1509. return v, errors.New("OldTotal requires an ID field in the mutation")
  1510. }
  1511. oldValue, err := m.oldValue(ctx)
  1512. if err != nil {
  1513. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  1514. }
  1515. return oldValue.Total, nil
  1516. }
  1517. // AddTotal adds i to the "total" field.
  1518. func (m *BatchMsgMutation) AddTotal(i int32) {
  1519. if m.addtotal != nil {
  1520. *m.addtotal += i
  1521. } else {
  1522. m.addtotal = &i
  1523. }
  1524. }
  1525. // AddedTotal returns the value that was added to the "total" field in this mutation.
  1526. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  1527. v := m.addtotal
  1528. if v == nil {
  1529. return
  1530. }
  1531. return *v, true
  1532. }
  1533. // ClearTotal clears the value of the "total" field.
  1534. func (m *BatchMsgMutation) ClearTotal() {
  1535. m.total = nil
  1536. m.addtotal = nil
  1537. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  1538. }
  1539. // TotalCleared returns if the "total" field was cleared in this mutation.
  1540. func (m *BatchMsgMutation) TotalCleared() bool {
  1541. _, ok := m.clearedFields[batchmsg.FieldTotal]
  1542. return ok
  1543. }
  1544. // ResetTotal resets all changes to the "total" field.
  1545. func (m *BatchMsgMutation) ResetTotal() {
  1546. m.total = nil
  1547. m.addtotal = nil
  1548. delete(m.clearedFields, batchmsg.FieldTotal)
  1549. }
  1550. // SetSuccess sets the "success" field.
  1551. func (m *BatchMsgMutation) SetSuccess(i int32) {
  1552. m.success = &i
  1553. m.addsuccess = nil
  1554. }
  1555. // Success returns the value of the "success" field in the mutation.
  1556. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  1557. v := m.success
  1558. if v == nil {
  1559. return
  1560. }
  1561. return *v, true
  1562. }
  1563. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  1564. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1566. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  1567. if !m.op.Is(OpUpdateOne) {
  1568. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  1569. }
  1570. if m.id == nil || m.oldValue == nil {
  1571. return v, errors.New("OldSuccess requires an ID field in the mutation")
  1572. }
  1573. oldValue, err := m.oldValue(ctx)
  1574. if err != nil {
  1575. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  1576. }
  1577. return oldValue.Success, nil
  1578. }
  1579. // AddSuccess adds i to the "success" field.
  1580. func (m *BatchMsgMutation) AddSuccess(i int32) {
  1581. if m.addsuccess != nil {
  1582. *m.addsuccess += i
  1583. } else {
  1584. m.addsuccess = &i
  1585. }
  1586. }
  1587. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  1588. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  1589. v := m.addsuccess
  1590. if v == nil {
  1591. return
  1592. }
  1593. return *v, true
  1594. }
  1595. // ClearSuccess clears the value of the "success" field.
  1596. func (m *BatchMsgMutation) ClearSuccess() {
  1597. m.success = nil
  1598. m.addsuccess = nil
  1599. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  1600. }
  1601. // SuccessCleared returns if the "success" field was cleared in this mutation.
  1602. func (m *BatchMsgMutation) SuccessCleared() bool {
  1603. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  1604. return ok
  1605. }
  1606. // ResetSuccess resets all changes to the "success" field.
  1607. func (m *BatchMsgMutation) ResetSuccess() {
  1608. m.success = nil
  1609. m.addsuccess = nil
  1610. delete(m.clearedFields, batchmsg.FieldSuccess)
  1611. }
  1612. // SetFail sets the "fail" field.
  1613. func (m *BatchMsgMutation) SetFail(i int32) {
  1614. m.fail = &i
  1615. m.addfail = nil
  1616. }
  1617. // Fail returns the value of the "fail" field in the mutation.
  1618. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  1619. v := m.fail
  1620. if v == nil {
  1621. return
  1622. }
  1623. return *v, true
  1624. }
  1625. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  1626. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1628. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  1629. if !m.op.Is(OpUpdateOne) {
  1630. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  1631. }
  1632. if m.id == nil || m.oldValue == nil {
  1633. return v, errors.New("OldFail requires an ID field in the mutation")
  1634. }
  1635. oldValue, err := m.oldValue(ctx)
  1636. if err != nil {
  1637. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  1638. }
  1639. return oldValue.Fail, nil
  1640. }
  1641. // AddFail adds i to the "fail" field.
  1642. func (m *BatchMsgMutation) AddFail(i int32) {
  1643. if m.addfail != nil {
  1644. *m.addfail += i
  1645. } else {
  1646. m.addfail = &i
  1647. }
  1648. }
  1649. // AddedFail returns the value that was added to the "fail" field in this mutation.
  1650. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  1651. v := m.addfail
  1652. if v == nil {
  1653. return
  1654. }
  1655. return *v, true
  1656. }
  1657. // ClearFail clears the value of the "fail" field.
  1658. func (m *BatchMsgMutation) ClearFail() {
  1659. m.fail = nil
  1660. m.addfail = nil
  1661. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  1662. }
  1663. // FailCleared returns if the "fail" field was cleared in this mutation.
  1664. func (m *BatchMsgMutation) FailCleared() bool {
  1665. _, ok := m.clearedFields[batchmsg.FieldFail]
  1666. return ok
  1667. }
  1668. // ResetFail resets all changes to the "fail" field.
  1669. func (m *BatchMsgMutation) ResetFail() {
  1670. m.fail = nil
  1671. m.addfail = nil
  1672. delete(m.clearedFields, batchmsg.FieldFail)
  1673. }
  1674. // SetStartTime sets the "start_time" field.
  1675. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  1676. m.start_time = &t
  1677. }
  1678. // StartTime returns the value of the "start_time" field in the mutation.
  1679. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  1680. v := m.start_time
  1681. if v == nil {
  1682. return
  1683. }
  1684. return *v, true
  1685. }
  1686. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  1687. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1689. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  1690. if !m.op.Is(OpUpdateOne) {
  1691. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  1692. }
  1693. if m.id == nil || m.oldValue == nil {
  1694. return v, errors.New("OldStartTime requires an ID field in the mutation")
  1695. }
  1696. oldValue, err := m.oldValue(ctx)
  1697. if err != nil {
  1698. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  1699. }
  1700. return oldValue.StartTime, nil
  1701. }
  1702. // ClearStartTime clears the value of the "start_time" field.
  1703. func (m *BatchMsgMutation) ClearStartTime() {
  1704. m.start_time = nil
  1705. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  1706. }
  1707. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  1708. func (m *BatchMsgMutation) StartTimeCleared() bool {
  1709. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  1710. return ok
  1711. }
  1712. // ResetStartTime resets all changes to the "start_time" field.
  1713. func (m *BatchMsgMutation) ResetStartTime() {
  1714. m.start_time = nil
  1715. delete(m.clearedFields, batchmsg.FieldStartTime)
  1716. }
  1717. // SetStopTime sets the "stop_time" field.
  1718. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  1719. m.stop_time = &t
  1720. }
  1721. // StopTime returns the value of the "stop_time" field in the mutation.
  1722. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  1723. v := m.stop_time
  1724. if v == nil {
  1725. return
  1726. }
  1727. return *v, true
  1728. }
  1729. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  1730. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1732. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  1733. if !m.op.Is(OpUpdateOne) {
  1734. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  1735. }
  1736. if m.id == nil || m.oldValue == nil {
  1737. return v, errors.New("OldStopTime requires an ID field in the mutation")
  1738. }
  1739. oldValue, err := m.oldValue(ctx)
  1740. if err != nil {
  1741. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  1742. }
  1743. return oldValue.StopTime, nil
  1744. }
  1745. // ClearStopTime clears the value of the "stop_time" field.
  1746. func (m *BatchMsgMutation) ClearStopTime() {
  1747. m.stop_time = nil
  1748. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  1749. }
  1750. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  1751. func (m *BatchMsgMutation) StopTimeCleared() bool {
  1752. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  1753. return ok
  1754. }
  1755. // ResetStopTime resets all changes to the "stop_time" field.
  1756. func (m *BatchMsgMutation) ResetStopTime() {
  1757. m.stop_time = nil
  1758. delete(m.clearedFields, batchmsg.FieldStopTime)
  1759. }
  1760. // SetType sets the "type" field.
  1761. func (m *BatchMsgMutation) SetType(i int32) {
  1762. m._type = &i
  1763. m.add_type = nil
  1764. }
  1765. // GetType returns the value of the "type" field in the mutation.
  1766. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  1767. v := m._type
  1768. if v == nil {
  1769. return
  1770. }
  1771. return *v, true
  1772. }
  1773. // OldType returns the old "type" field's value of the BatchMsg entity.
  1774. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1776. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  1777. if !m.op.Is(OpUpdateOne) {
  1778. return v, errors.New("OldType is only allowed on UpdateOne operations")
  1779. }
  1780. if m.id == nil || m.oldValue == nil {
  1781. return v, errors.New("OldType requires an ID field in the mutation")
  1782. }
  1783. oldValue, err := m.oldValue(ctx)
  1784. if err != nil {
  1785. return v, fmt.Errorf("querying old value for OldType: %w", err)
  1786. }
  1787. return oldValue.Type, nil
  1788. }
  1789. // AddType adds i to the "type" field.
  1790. func (m *BatchMsgMutation) AddType(i int32) {
  1791. if m.add_type != nil {
  1792. *m.add_type += i
  1793. } else {
  1794. m.add_type = &i
  1795. }
  1796. }
  1797. // AddedType returns the value that was added to the "type" field in this mutation.
  1798. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  1799. v := m.add_type
  1800. if v == nil {
  1801. return
  1802. }
  1803. return *v, true
  1804. }
  1805. // ClearType clears the value of the "type" field.
  1806. func (m *BatchMsgMutation) ClearType() {
  1807. m._type = nil
  1808. m.add_type = nil
  1809. m.clearedFields[batchmsg.FieldType] = struct{}{}
  1810. }
  1811. // TypeCleared returns if the "type" field was cleared in this mutation.
  1812. func (m *BatchMsgMutation) TypeCleared() bool {
  1813. _, ok := m.clearedFields[batchmsg.FieldType]
  1814. return ok
  1815. }
  1816. // ResetType resets all changes to the "type" field.
  1817. func (m *BatchMsgMutation) ResetType() {
  1818. m._type = nil
  1819. m.add_type = nil
  1820. delete(m.clearedFields, batchmsg.FieldType)
  1821. }
  1822. // SetOrganizationID sets the "organization_id" field.
  1823. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  1824. m.organization_id = &u
  1825. m.addorganization_id = nil
  1826. }
  1827. // OrganizationID returns the value of the "organization_id" field in the mutation.
  1828. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  1829. v := m.organization_id
  1830. if v == nil {
  1831. return
  1832. }
  1833. return *v, true
  1834. }
  1835. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  1836. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1838. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  1839. if !m.op.Is(OpUpdateOne) {
  1840. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  1841. }
  1842. if m.id == nil || m.oldValue == nil {
  1843. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  1844. }
  1845. oldValue, err := m.oldValue(ctx)
  1846. if err != nil {
  1847. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  1848. }
  1849. return oldValue.OrganizationID, nil
  1850. }
  1851. // AddOrganizationID adds u to the "organization_id" field.
  1852. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  1853. if m.addorganization_id != nil {
  1854. *m.addorganization_id += u
  1855. } else {
  1856. m.addorganization_id = &u
  1857. }
  1858. }
  1859. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  1860. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  1861. v := m.addorganization_id
  1862. if v == nil {
  1863. return
  1864. }
  1865. return *v, true
  1866. }
  1867. // ResetOrganizationID resets all changes to the "organization_id" field.
  1868. func (m *BatchMsgMutation) ResetOrganizationID() {
  1869. m.organization_id = nil
  1870. m.addorganization_id = nil
  1871. }
  1872. // Where appends a list predicates to the BatchMsgMutation builder.
  1873. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  1874. m.predicates = append(m.predicates, ps...)
  1875. }
  1876. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  1877. // users can use type-assertion to append predicates that do not depend on any generated package.
  1878. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  1879. p := make([]predicate.BatchMsg, len(ps))
  1880. for i := range ps {
  1881. p[i] = ps[i]
  1882. }
  1883. m.Where(p...)
  1884. }
  1885. // Op returns the operation name.
  1886. func (m *BatchMsgMutation) Op() Op {
  1887. return m.op
  1888. }
  1889. // SetOp allows setting the mutation operation.
  1890. func (m *BatchMsgMutation) SetOp(op Op) {
  1891. m.op = op
  1892. }
  1893. // Type returns the node type of this mutation (BatchMsg).
  1894. func (m *BatchMsgMutation) Type() string {
  1895. return m.typ
  1896. }
  1897. // Fields returns all fields that were changed during this mutation. Note that in
  1898. // order to get all numeric fields that were incremented/decremented, call
  1899. // AddedFields().
  1900. func (m *BatchMsgMutation) Fields() []string {
  1901. fields := make([]string, 0, 16)
  1902. if m.created_at != nil {
  1903. fields = append(fields, batchmsg.FieldCreatedAt)
  1904. }
  1905. if m.updated_at != nil {
  1906. fields = append(fields, batchmsg.FieldUpdatedAt)
  1907. }
  1908. if m.deleted_at != nil {
  1909. fields = append(fields, batchmsg.FieldDeletedAt)
  1910. }
  1911. if m.status != nil {
  1912. fields = append(fields, batchmsg.FieldStatus)
  1913. }
  1914. if m.batch_no != nil {
  1915. fields = append(fields, batchmsg.FieldBatchNo)
  1916. }
  1917. if m.task_name != nil {
  1918. fields = append(fields, batchmsg.FieldTaskName)
  1919. }
  1920. if m.fromwxid != nil {
  1921. fields = append(fields, batchmsg.FieldFromwxid)
  1922. }
  1923. if m.msg != nil {
  1924. fields = append(fields, batchmsg.FieldMsg)
  1925. }
  1926. if m.tag != nil {
  1927. fields = append(fields, batchmsg.FieldTag)
  1928. }
  1929. if m.total != nil {
  1930. fields = append(fields, batchmsg.FieldTotal)
  1931. }
  1932. if m.success != nil {
  1933. fields = append(fields, batchmsg.FieldSuccess)
  1934. }
  1935. if m.fail != nil {
  1936. fields = append(fields, batchmsg.FieldFail)
  1937. }
  1938. if m.start_time != nil {
  1939. fields = append(fields, batchmsg.FieldStartTime)
  1940. }
  1941. if m.stop_time != nil {
  1942. fields = append(fields, batchmsg.FieldStopTime)
  1943. }
  1944. if m._type != nil {
  1945. fields = append(fields, batchmsg.FieldType)
  1946. }
  1947. if m.organization_id != nil {
  1948. fields = append(fields, batchmsg.FieldOrganizationID)
  1949. }
  1950. return fields
  1951. }
  1952. // Field returns the value of a field with the given name. The second boolean
  1953. // return value indicates that this field was not set, or was not defined in the
  1954. // schema.
  1955. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  1956. switch name {
  1957. case batchmsg.FieldCreatedAt:
  1958. return m.CreatedAt()
  1959. case batchmsg.FieldUpdatedAt:
  1960. return m.UpdatedAt()
  1961. case batchmsg.FieldDeletedAt:
  1962. return m.DeletedAt()
  1963. case batchmsg.FieldStatus:
  1964. return m.Status()
  1965. case batchmsg.FieldBatchNo:
  1966. return m.BatchNo()
  1967. case batchmsg.FieldTaskName:
  1968. return m.TaskName()
  1969. case batchmsg.FieldFromwxid:
  1970. return m.Fromwxid()
  1971. case batchmsg.FieldMsg:
  1972. return m.Msg()
  1973. case batchmsg.FieldTag:
  1974. return m.Tag()
  1975. case batchmsg.FieldTotal:
  1976. return m.Total()
  1977. case batchmsg.FieldSuccess:
  1978. return m.Success()
  1979. case batchmsg.FieldFail:
  1980. return m.Fail()
  1981. case batchmsg.FieldStartTime:
  1982. return m.StartTime()
  1983. case batchmsg.FieldStopTime:
  1984. return m.StopTime()
  1985. case batchmsg.FieldType:
  1986. return m.GetType()
  1987. case batchmsg.FieldOrganizationID:
  1988. return m.OrganizationID()
  1989. }
  1990. return nil, false
  1991. }
  1992. // OldField returns the old value of the field from the database. An error is
  1993. // returned if the mutation operation is not UpdateOne, or the query to the
  1994. // database failed.
  1995. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1996. switch name {
  1997. case batchmsg.FieldCreatedAt:
  1998. return m.OldCreatedAt(ctx)
  1999. case batchmsg.FieldUpdatedAt:
  2000. return m.OldUpdatedAt(ctx)
  2001. case batchmsg.FieldDeletedAt:
  2002. return m.OldDeletedAt(ctx)
  2003. case batchmsg.FieldStatus:
  2004. return m.OldStatus(ctx)
  2005. case batchmsg.FieldBatchNo:
  2006. return m.OldBatchNo(ctx)
  2007. case batchmsg.FieldTaskName:
  2008. return m.OldTaskName(ctx)
  2009. case batchmsg.FieldFromwxid:
  2010. return m.OldFromwxid(ctx)
  2011. case batchmsg.FieldMsg:
  2012. return m.OldMsg(ctx)
  2013. case batchmsg.FieldTag:
  2014. return m.OldTag(ctx)
  2015. case batchmsg.FieldTotal:
  2016. return m.OldTotal(ctx)
  2017. case batchmsg.FieldSuccess:
  2018. return m.OldSuccess(ctx)
  2019. case batchmsg.FieldFail:
  2020. return m.OldFail(ctx)
  2021. case batchmsg.FieldStartTime:
  2022. return m.OldStartTime(ctx)
  2023. case batchmsg.FieldStopTime:
  2024. return m.OldStopTime(ctx)
  2025. case batchmsg.FieldType:
  2026. return m.OldType(ctx)
  2027. case batchmsg.FieldOrganizationID:
  2028. return m.OldOrganizationID(ctx)
  2029. }
  2030. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  2031. }
  2032. // SetField sets the value of a field with the given name. It returns an error if
  2033. // the field is not defined in the schema, or if the type mismatched the field
  2034. // type.
  2035. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  2036. switch name {
  2037. case batchmsg.FieldCreatedAt:
  2038. v, ok := value.(time.Time)
  2039. if !ok {
  2040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2041. }
  2042. m.SetCreatedAt(v)
  2043. return nil
  2044. case batchmsg.FieldUpdatedAt:
  2045. v, ok := value.(time.Time)
  2046. if !ok {
  2047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2048. }
  2049. m.SetUpdatedAt(v)
  2050. return nil
  2051. case batchmsg.FieldDeletedAt:
  2052. v, ok := value.(time.Time)
  2053. if !ok {
  2054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2055. }
  2056. m.SetDeletedAt(v)
  2057. return nil
  2058. case batchmsg.FieldStatus:
  2059. v, ok := value.(uint8)
  2060. if !ok {
  2061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2062. }
  2063. m.SetStatus(v)
  2064. return nil
  2065. case batchmsg.FieldBatchNo:
  2066. v, ok := value.(string)
  2067. if !ok {
  2068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2069. }
  2070. m.SetBatchNo(v)
  2071. return nil
  2072. case batchmsg.FieldTaskName:
  2073. v, ok := value.(string)
  2074. if !ok {
  2075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2076. }
  2077. m.SetTaskName(v)
  2078. return nil
  2079. case batchmsg.FieldFromwxid:
  2080. v, ok := value.(string)
  2081. if !ok {
  2082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2083. }
  2084. m.SetFromwxid(v)
  2085. return nil
  2086. case batchmsg.FieldMsg:
  2087. v, ok := value.(string)
  2088. if !ok {
  2089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2090. }
  2091. m.SetMsg(v)
  2092. return nil
  2093. case batchmsg.FieldTag:
  2094. v, ok := value.(string)
  2095. if !ok {
  2096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2097. }
  2098. m.SetTag(v)
  2099. return nil
  2100. case batchmsg.FieldTotal:
  2101. v, ok := value.(int32)
  2102. if !ok {
  2103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2104. }
  2105. m.SetTotal(v)
  2106. return nil
  2107. case batchmsg.FieldSuccess:
  2108. v, ok := value.(int32)
  2109. if !ok {
  2110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2111. }
  2112. m.SetSuccess(v)
  2113. return nil
  2114. case batchmsg.FieldFail:
  2115. v, ok := value.(int32)
  2116. if !ok {
  2117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2118. }
  2119. m.SetFail(v)
  2120. return nil
  2121. case batchmsg.FieldStartTime:
  2122. v, ok := value.(time.Time)
  2123. if !ok {
  2124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2125. }
  2126. m.SetStartTime(v)
  2127. return nil
  2128. case batchmsg.FieldStopTime:
  2129. v, ok := value.(time.Time)
  2130. if !ok {
  2131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2132. }
  2133. m.SetStopTime(v)
  2134. return nil
  2135. case batchmsg.FieldType:
  2136. v, ok := value.(int32)
  2137. if !ok {
  2138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2139. }
  2140. m.SetType(v)
  2141. return nil
  2142. case batchmsg.FieldOrganizationID:
  2143. v, ok := value.(uint64)
  2144. if !ok {
  2145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2146. }
  2147. m.SetOrganizationID(v)
  2148. return nil
  2149. }
  2150. return fmt.Errorf("unknown BatchMsg field %s", name)
  2151. }
  2152. // AddedFields returns all numeric fields that were incremented/decremented during
  2153. // this mutation.
  2154. func (m *BatchMsgMutation) AddedFields() []string {
  2155. var fields []string
  2156. if m.addstatus != nil {
  2157. fields = append(fields, batchmsg.FieldStatus)
  2158. }
  2159. if m.addtotal != nil {
  2160. fields = append(fields, batchmsg.FieldTotal)
  2161. }
  2162. if m.addsuccess != nil {
  2163. fields = append(fields, batchmsg.FieldSuccess)
  2164. }
  2165. if m.addfail != nil {
  2166. fields = append(fields, batchmsg.FieldFail)
  2167. }
  2168. if m.add_type != nil {
  2169. fields = append(fields, batchmsg.FieldType)
  2170. }
  2171. if m.addorganization_id != nil {
  2172. fields = append(fields, batchmsg.FieldOrganizationID)
  2173. }
  2174. return fields
  2175. }
  2176. // AddedField returns the numeric value that was incremented/decremented on a field
  2177. // with the given name. The second boolean return value indicates that this field
  2178. // was not set, or was not defined in the schema.
  2179. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  2180. switch name {
  2181. case batchmsg.FieldStatus:
  2182. return m.AddedStatus()
  2183. case batchmsg.FieldTotal:
  2184. return m.AddedTotal()
  2185. case batchmsg.FieldSuccess:
  2186. return m.AddedSuccess()
  2187. case batchmsg.FieldFail:
  2188. return m.AddedFail()
  2189. case batchmsg.FieldType:
  2190. return m.AddedType()
  2191. case batchmsg.FieldOrganizationID:
  2192. return m.AddedOrganizationID()
  2193. }
  2194. return nil, false
  2195. }
  2196. // AddField adds the value to the field with the given name. It returns an error if
  2197. // the field is not defined in the schema, or if the type mismatched the field
  2198. // type.
  2199. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  2200. switch name {
  2201. case batchmsg.FieldStatus:
  2202. v, ok := value.(int8)
  2203. if !ok {
  2204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2205. }
  2206. m.AddStatus(v)
  2207. return nil
  2208. case batchmsg.FieldTotal:
  2209. v, ok := value.(int32)
  2210. if !ok {
  2211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2212. }
  2213. m.AddTotal(v)
  2214. return nil
  2215. case batchmsg.FieldSuccess:
  2216. v, ok := value.(int32)
  2217. if !ok {
  2218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2219. }
  2220. m.AddSuccess(v)
  2221. return nil
  2222. case batchmsg.FieldFail:
  2223. v, ok := value.(int32)
  2224. if !ok {
  2225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2226. }
  2227. m.AddFail(v)
  2228. return nil
  2229. case batchmsg.FieldType:
  2230. v, ok := value.(int32)
  2231. if !ok {
  2232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2233. }
  2234. m.AddType(v)
  2235. return nil
  2236. case batchmsg.FieldOrganizationID:
  2237. v, ok := value.(int64)
  2238. if !ok {
  2239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2240. }
  2241. m.AddOrganizationID(v)
  2242. return nil
  2243. }
  2244. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  2245. }
  2246. // ClearedFields returns all nullable fields that were cleared during this
  2247. // mutation.
  2248. func (m *BatchMsgMutation) ClearedFields() []string {
  2249. var fields []string
  2250. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  2251. fields = append(fields, batchmsg.FieldDeletedAt)
  2252. }
  2253. if m.FieldCleared(batchmsg.FieldStatus) {
  2254. fields = append(fields, batchmsg.FieldStatus)
  2255. }
  2256. if m.FieldCleared(batchmsg.FieldBatchNo) {
  2257. fields = append(fields, batchmsg.FieldBatchNo)
  2258. }
  2259. if m.FieldCleared(batchmsg.FieldTaskName) {
  2260. fields = append(fields, batchmsg.FieldTaskName)
  2261. }
  2262. if m.FieldCleared(batchmsg.FieldFromwxid) {
  2263. fields = append(fields, batchmsg.FieldFromwxid)
  2264. }
  2265. if m.FieldCleared(batchmsg.FieldMsg) {
  2266. fields = append(fields, batchmsg.FieldMsg)
  2267. }
  2268. if m.FieldCleared(batchmsg.FieldTag) {
  2269. fields = append(fields, batchmsg.FieldTag)
  2270. }
  2271. if m.FieldCleared(batchmsg.FieldTotal) {
  2272. fields = append(fields, batchmsg.FieldTotal)
  2273. }
  2274. if m.FieldCleared(batchmsg.FieldSuccess) {
  2275. fields = append(fields, batchmsg.FieldSuccess)
  2276. }
  2277. if m.FieldCleared(batchmsg.FieldFail) {
  2278. fields = append(fields, batchmsg.FieldFail)
  2279. }
  2280. if m.FieldCleared(batchmsg.FieldStartTime) {
  2281. fields = append(fields, batchmsg.FieldStartTime)
  2282. }
  2283. if m.FieldCleared(batchmsg.FieldStopTime) {
  2284. fields = append(fields, batchmsg.FieldStopTime)
  2285. }
  2286. if m.FieldCleared(batchmsg.FieldType) {
  2287. fields = append(fields, batchmsg.FieldType)
  2288. }
  2289. return fields
  2290. }
  2291. // FieldCleared returns a boolean indicating if a field with the given name was
  2292. // cleared in this mutation.
  2293. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  2294. _, ok := m.clearedFields[name]
  2295. return ok
  2296. }
  2297. // ClearField clears the value of the field with the given name. It returns an
  2298. // error if the field is not defined in the schema.
  2299. func (m *BatchMsgMutation) ClearField(name string) error {
  2300. switch name {
  2301. case batchmsg.FieldDeletedAt:
  2302. m.ClearDeletedAt()
  2303. return nil
  2304. case batchmsg.FieldStatus:
  2305. m.ClearStatus()
  2306. return nil
  2307. case batchmsg.FieldBatchNo:
  2308. m.ClearBatchNo()
  2309. return nil
  2310. case batchmsg.FieldTaskName:
  2311. m.ClearTaskName()
  2312. return nil
  2313. case batchmsg.FieldFromwxid:
  2314. m.ClearFromwxid()
  2315. return nil
  2316. case batchmsg.FieldMsg:
  2317. m.ClearMsg()
  2318. return nil
  2319. case batchmsg.FieldTag:
  2320. m.ClearTag()
  2321. return nil
  2322. case batchmsg.FieldTotal:
  2323. m.ClearTotal()
  2324. return nil
  2325. case batchmsg.FieldSuccess:
  2326. m.ClearSuccess()
  2327. return nil
  2328. case batchmsg.FieldFail:
  2329. m.ClearFail()
  2330. return nil
  2331. case batchmsg.FieldStartTime:
  2332. m.ClearStartTime()
  2333. return nil
  2334. case batchmsg.FieldStopTime:
  2335. m.ClearStopTime()
  2336. return nil
  2337. case batchmsg.FieldType:
  2338. m.ClearType()
  2339. return nil
  2340. }
  2341. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  2342. }
  2343. // ResetField resets all changes in the mutation for the field with the given name.
  2344. // It returns an error if the field is not defined in the schema.
  2345. func (m *BatchMsgMutation) ResetField(name string) error {
  2346. switch name {
  2347. case batchmsg.FieldCreatedAt:
  2348. m.ResetCreatedAt()
  2349. return nil
  2350. case batchmsg.FieldUpdatedAt:
  2351. m.ResetUpdatedAt()
  2352. return nil
  2353. case batchmsg.FieldDeletedAt:
  2354. m.ResetDeletedAt()
  2355. return nil
  2356. case batchmsg.FieldStatus:
  2357. m.ResetStatus()
  2358. return nil
  2359. case batchmsg.FieldBatchNo:
  2360. m.ResetBatchNo()
  2361. return nil
  2362. case batchmsg.FieldTaskName:
  2363. m.ResetTaskName()
  2364. return nil
  2365. case batchmsg.FieldFromwxid:
  2366. m.ResetFromwxid()
  2367. return nil
  2368. case batchmsg.FieldMsg:
  2369. m.ResetMsg()
  2370. return nil
  2371. case batchmsg.FieldTag:
  2372. m.ResetTag()
  2373. return nil
  2374. case batchmsg.FieldTotal:
  2375. m.ResetTotal()
  2376. return nil
  2377. case batchmsg.FieldSuccess:
  2378. m.ResetSuccess()
  2379. return nil
  2380. case batchmsg.FieldFail:
  2381. m.ResetFail()
  2382. return nil
  2383. case batchmsg.FieldStartTime:
  2384. m.ResetStartTime()
  2385. return nil
  2386. case batchmsg.FieldStopTime:
  2387. m.ResetStopTime()
  2388. return nil
  2389. case batchmsg.FieldType:
  2390. m.ResetType()
  2391. return nil
  2392. case batchmsg.FieldOrganizationID:
  2393. m.ResetOrganizationID()
  2394. return nil
  2395. }
  2396. return fmt.Errorf("unknown BatchMsg field %s", name)
  2397. }
  2398. // AddedEdges returns all edge names that were set/added in this mutation.
  2399. func (m *BatchMsgMutation) AddedEdges() []string {
  2400. edges := make([]string, 0, 0)
  2401. return edges
  2402. }
  2403. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2404. // name in this mutation.
  2405. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  2406. return nil
  2407. }
  2408. // RemovedEdges returns all edge names that were removed in this mutation.
  2409. func (m *BatchMsgMutation) RemovedEdges() []string {
  2410. edges := make([]string, 0, 0)
  2411. return edges
  2412. }
  2413. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2414. // the given name in this mutation.
  2415. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  2416. return nil
  2417. }
  2418. // ClearedEdges returns all edge names that were cleared in this mutation.
  2419. func (m *BatchMsgMutation) ClearedEdges() []string {
  2420. edges := make([]string, 0, 0)
  2421. return edges
  2422. }
  2423. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2424. // was cleared in this mutation.
  2425. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  2426. return false
  2427. }
  2428. // ClearEdge clears the value of the edge with the given name. It returns an error
  2429. // if that edge is not defined in the schema.
  2430. func (m *BatchMsgMutation) ClearEdge(name string) error {
  2431. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  2432. }
  2433. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2434. // It returns an error if the edge is not defined in the schema.
  2435. func (m *BatchMsgMutation) ResetEdge(name string) error {
  2436. return fmt.Errorf("unknown BatchMsg edge %s", name)
  2437. }
  2438. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  2439. type CategoryMutation struct {
  2440. config
  2441. op Op
  2442. typ string
  2443. id *uint64
  2444. created_at *time.Time
  2445. updated_at *time.Time
  2446. deleted_at *time.Time
  2447. name *string
  2448. organization_id *uint64
  2449. addorganization_id *int64
  2450. clearedFields map[string]struct{}
  2451. done bool
  2452. oldValue func(context.Context) (*Category, error)
  2453. predicates []predicate.Category
  2454. }
  2455. var _ ent.Mutation = (*CategoryMutation)(nil)
  2456. // categoryOption allows management of the mutation configuration using functional options.
  2457. type categoryOption func(*CategoryMutation)
  2458. // newCategoryMutation creates new mutation for the Category entity.
  2459. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  2460. m := &CategoryMutation{
  2461. config: c,
  2462. op: op,
  2463. typ: TypeCategory,
  2464. clearedFields: make(map[string]struct{}),
  2465. }
  2466. for _, opt := range opts {
  2467. opt(m)
  2468. }
  2469. return m
  2470. }
  2471. // withCategoryID sets the ID field of the mutation.
  2472. func withCategoryID(id uint64) categoryOption {
  2473. return func(m *CategoryMutation) {
  2474. var (
  2475. err error
  2476. once sync.Once
  2477. value *Category
  2478. )
  2479. m.oldValue = func(ctx context.Context) (*Category, error) {
  2480. once.Do(func() {
  2481. if m.done {
  2482. err = errors.New("querying old values post mutation is not allowed")
  2483. } else {
  2484. value, err = m.Client().Category.Get(ctx, id)
  2485. }
  2486. })
  2487. return value, err
  2488. }
  2489. m.id = &id
  2490. }
  2491. }
  2492. // withCategory sets the old Category of the mutation.
  2493. func withCategory(node *Category) categoryOption {
  2494. return func(m *CategoryMutation) {
  2495. m.oldValue = func(context.Context) (*Category, error) {
  2496. return node, nil
  2497. }
  2498. m.id = &node.ID
  2499. }
  2500. }
  2501. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2502. // executed in a transaction (ent.Tx), a transactional client is returned.
  2503. func (m CategoryMutation) Client() *Client {
  2504. client := &Client{config: m.config}
  2505. client.init()
  2506. return client
  2507. }
  2508. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2509. // it returns an error otherwise.
  2510. func (m CategoryMutation) Tx() (*Tx, error) {
  2511. if _, ok := m.driver.(*txDriver); !ok {
  2512. return nil, errors.New("ent: mutation is not running in a transaction")
  2513. }
  2514. tx := &Tx{config: m.config}
  2515. tx.init()
  2516. return tx, nil
  2517. }
  2518. // SetID sets the value of the id field. Note that this
  2519. // operation is only accepted on creation of Category entities.
  2520. func (m *CategoryMutation) SetID(id uint64) {
  2521. m.id = &id
  2522. }
  2523. // ID returns the ID value in the mutation. Note that the ID is only available
  2524. // if it was provided to the builder or after it was returned from the database.
  2525. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  2526. if m.id == nil {
  2527. return
  2528. }
  2529. return *m.id, true
  2530. }
  2531. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2532. // That means, if the mutation is applied within a transaction with an isolation level such
  2533. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2534. // or updated by the mutation.
  2535. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  2536. switch {
  2537. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2538. id, exists := m.ID()
  2539. if exists {
  2540. return []uint64{id}, nil
  2541. }
  2542. fallthrough
  2543. case m.op.Is(OpUpdate | OpDelete):
  2544. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  2545. default:
  2546. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2547. }
  2548. }
  2549. // SetCreatedAt sets the "created_at" field.
  2550. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  2551. m.created_at = &t
  2552. }
  2553. // CreatedAt returns the value of the "created_at" field in the mutation.
  2554. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  2555. v := m.created_at
  2556. if v == nil {
  2557. return
  2558. }
  2559. return *v, true
  2560. }
  2561. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  2562. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  2563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2564. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2565. if !m.op.Is(OpUpdateOne) {
  2566. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2567. }
  2568. if m.id == nil || m.oldValue == nil {
  2569. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2570. }
  2571. oldValue, err := m.oldValue(ctx)
  2572. if err != nil {
  2573. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2574. }
  2575. return oldValue.CreatedAt, nil
  2576. }
  2577. // ResetCreatedAt resets all changes to the "created_at" field.
  2578. func (m *CategoryMutation) ResetCreatedAt() {
  2579. m.created_at = nil
  2580. }
  2581. // SetUpdatedAt sets the "updated_at" field.
  2582. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  2583. m.updated_at = &t
  2584. }
  2585. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2586. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  2587. v := m.updated_at
  2588. if v == nil {
  2589. return
  2590. }
  2591. return *v, true
  2592. }
  2593. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  2594. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  2595. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2596. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2597. if !m.op.Is(OpUpdateOne) {
  2598. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2599. }
  2600. if m.id == nil || m.oldValue == nil {
  2601. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2602. }
  2603. oldValue, err := m.oldValue(ctx)
  2604. if err != nil {
  2605. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2606. }
  2607. return oldValue.UpdatedAt, nil
  2608. }
  2609. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2610. func (m *CategoryMutation) ResetUpdatedAt() {
  2611. m.updated_at = nil
  2612. }
  2613. // SetDeletedAt sets the "deleted_at" field.
  2614. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  2615. m.deleted_at = &t
  2616. }
  2617. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2618. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  2619. v := m.deleted_at
  2620. if v == nil {
  2621. return
  2622. }
  2623. return *v, true
  2624. }
  2625. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  2626. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  2627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2628. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2629. if !m.op.Is(OpUpdateOne) {
  2630. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2631. }
  2632. if m.id == nil || m.oldValue == nil {
  2633. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2634. }
  2635. oldValue, err := m.oldValue(ctx)
  2636. if err != nil {
  2637. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2638. }
  2639. return oldValue.DeletedAt, nil
  2640. }
  2641. // ClearDeletedAt clears the value of the "deleted_at" field.
  2642. func (m *CategoryMutation) ClearDeletedAt() {
  2643. m.deleted_at = nil
  2644. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  2645. }
  2646. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2647. func (m *CategoryMutation) DeletedAtCleared() bool {
  2648. _, ok := m.clearedFields[category.FieldDeletedAt]
  2649. return ok
  2650. }
  2651. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2652. func (m *CategoryMutation) ResetDeletedAt() {
  2653. m.deleted_at = nil
  2654. delete(m.clearedFields, category.FieldDeletedAt)
  2655. }
  2656. // SetName sets the "name" field.
  2657. func (m *CategoryMutation) SetName(s string) {
  2658. m.name = &s
  2659. }
  2660. // Name returns the value of the "name" field in the mutation.
  2661. func (m *CategoryMutation) Name() (r string, exists bool) {
  2662. v := m.name
  2663. if v == nil {
  2664. return
  2665. }
  2666. return *v, true
  2667. }
  2668. // OldName returns the old "name" field's value of the Category entity.
  2669. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  2670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2671. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  2672. if !m.op.Is(OpUpdateOne) {
  2673. return v, errors.New("OldName is only allowed on UpdateOne operations")
  2674. }
  2675. if m.id == nil || m.oldValue == nil {
  2676. return v, errors.New("OldName requires an ID field in the mutation")
  2677. }
  2678. oldValue, err := m.oldValue(ctx)
  2679. if err != nil {
  2680. return v, fmt.Errorf("querying old value for OldName: %w", err)
  2681. }
  2682. return oldValue.Name, nil
  2683. }
  2684. // ResetName resets all changes to the "name" field.
  2685. func (m *CategoryMutation) ResetName() {
  2686. m.name = nil
  2687. }
  2688. // SetOrganizationID sets the "organization_id" field.
  2689. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  2690. m.organization_id = &u
  2691. m.addorganization_id = nil
  2692. }
  2693. // OrganizationID returns the value of the "organization_id" field in the mutation.
  2694. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  2695. v := m.organization_id
  2696. if v == nil {
  2697. return
  2698. }
  2699. return *v, true
  2700. }
  2701. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  2702. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  2703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2704. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  2705. if !m.op.Is(OpUpdateOne) {
  2706. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  2707. }
  2708. if m.id == nil || m.oldValue == nil {
  2709. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  2710. }
  2711. oldValue, err := m.oldValue(ctx)
  2712. if err != nil {
  2713. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  2714. }
  2715. return oldValue.OrganizationID, nil
  2716. }
  2717. // AddOrganizationID adds u to the "organization_id" field.
  2718. func (m *CategoryMutation) AddOrganizationID(u int64) {
  2719. if m.addorganization_id != nil {
  2720. *m.addorganization_id += u
  2721. } else {
  2722. m.addorganization_id = &u
  2723. }
  2724. }
  2725. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  2726. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  2727. v := m.addorganization_id
  2728. if v == nil {
  2729. return
  2730. }
  2731. return *v, true
  2732. }
  2733. // ResetOrganizationID resets all changes to the "organization_id" field.
  2734. func (m *CategoryMutation) ResetOrganizationID() {
  2735. m.organization_id = nil
  2736. m.addorganization_id = nil
  2737. }
  2738. // Where appends a list predicates to the CategoryMutation builder.
  2739. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  2740. m.predicates = append(m.predicates, ps...)
  2741. }
  2742. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  2743. // users can use type-assertion to append predicates that do not depend on any generated package.
  2744. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  2745. p := make([]predicate.Category, len(ps))
  2746. for i := range ps {
  2747. p[i] = ps[i]
  2748. }
  2749. m.Where(p...)
  2750. }
  2751. // Op returns the operation name.
  2752. func (m *CategoryMutation) Op() Op {
  2753. return m.op
  2754. }
  2755. // SetOp allows setting the mutation operation.
  2756. func (m *CategoryMutation) SetOp(op Op) {
  2757. m.op = op
  2758. }
  2759. // Type returns the node type of this mutation (Category).
  2760. func (m *CategoryMutation) Type() string {
  2761. return m.typ
  2762. }
  2763. // Fields returns all fields that were changed during this mutation. Note that in
  2764. // order to get all numeric fields that were incremented/decremented, call
  2765. // AddedFields().
  2766. func (m *CategoryMutation) Fields() []string {
  2767. fields := make([]string, 0, 5)
  2768. if m.created_at != nil {
  2769. fields = append(fields, category.FieldCreatedAt)
  2770. }
  2771. if m.updated_at != nil {
  2772. fields = append(fields, category.FieldUpdatedAt)
  2773. }
  2774. if m.deleted_at != nil {
  2775. fields = append(fields, category.FieldDeletedAt)
  2776. }
  2777. if m.name != nil {
  2778. fields = append(fields, category.FieldName)
  2779. }
  2780. if m.organization_id != nil {
  2781. fields = append(fields, category.FieldOrganizationID)
  2782. }
  2783. return fields
  2784. }
  2785. // Field returns the value of a field with the given name. The second boolean
  2786. // return value indicates that this field was not set, or was not defined in the
  2787. // schema.
  2788. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  2789. switch name {
  2790. case category.FieldCreatedAt:
  2791. return m.CreatedAt()
  2792. case category.FieldUpdatedAt:
  2793. return m.UpdatedAt()
  2794. case category.FieldDeletedAt:
  2795. return m.DeletedAt()
  2796. case category.FieldName:
  2797. return m.Name()
  2798. case category.FieldOrganizationID:
  2799. return m.OrganizationID()
  2800. }
  2801. return nil, false
  2802. }
  2803. // OldField returns the old value of the field from the database. An error is
  2804. // returned if the mutation operation is not UpdateOne, or the query to the
  2805. // database failed.
  2806. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2807. switch name {
  2808. case category.FieldCreatedAt:
  2809. return m.OldCreatedAt(ctx)
  2810. case category.FieldUpdatedAt:
  2811. return m.OldUpdatedAt(ctx)
  2812. case category.FieldDeletedAt:
  2813. return m.OldDeletedAt(ctx)
  2814. case category.FieldName:
  2815. return m.OldName(ctx)
  2816. case category.FieldOrganizationID:
  2817. return m.OldOrganizationID(ctx)
  2818. }
  2819. return nil, fmt.Errorf("unknown Category field %s", name)
  2820. }
  2821. // SetField sets the value of a field with the given name. It returns an error if
  2822. // the field is not defined in the schema, or if the type mismatched the field
  2823. // type.
  2824. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  2825. switch name {
  2826. case category.FieldCreatedAt:
  2827. v, ok := value.(time.Time)
  2828. if !ok {
  2829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2830. }
  2831. m.SetCreatedAt(v)
  2832. return nil
  2833. case category.FieldUpdatedAt:
  2834. v, ok := value.(time.Time)
  2835. if !ok {
  2836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2837. }
  2838. m.SetUpdatedAt(v)
  2839. return nil
  2840. case category.FieldDeletedAt:
  2841. v, ok := value.(time.Time)
  2842. if !ok {
  2843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2844. }
  2845. m.SetDeletedAt(v)
  2846. return nil
  2847. case category.FieldName:
  2848. v, ok := value.(string)
  2849. if !ok {
  2850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2851. }
  2852. m.SetName(v)
  2853. return nil
  2854. case category.FieldOrganizationID:
  2855. v, ok := value.(uint64)
  2856. if !ok {
  2857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2858. }
  2859. m.SetOrganizationID(v)
  2860. return nil
  2861. }
  2862. return fmt.Errorf("unknown Category field %s", name)
  2863. }
  2864. // AddedFields returns all numeric fields that were incremented/decremented during
  2865. // this mutation.
  2866. func (m *CategoryMutation) AddedFields() []string {
  2867. var fields []string
  2868. if m.addorganization_id != nil {
  2869. fields = append(fields, category.FieldOrganizationID)
  2870. }
  2871. return fields
  2872. }
  2873. // AddedField returns the numeric value that was incremented/decremented on a field
  2874. // with the given name. The second boolean return value indicates that this field
  2875. // was not set, or was not defined in the schema.
  2876. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  2877. switch name {
  2878. case category.FieldOrganizationID:
  2879. return m.AddedOrganizationID()
  2880. }
  2881. return nil, false
  2882. }
  2883. // AddField adds the value to the field with the given name. It returns an error if
  2884. // the field is not defined in the schema, or if the type mismatched the field
  2885. // type.
  2886. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  2887. switch name {
  2888. case category.FieldOrganizationID:
  2889. v, ok := value.(int64)
  2890. if !ok {
  2891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2892. }
  2893. m.AddOrganizationID(v)
  2894. return nil
  2895. }
  2896. return fmt.Errorf("unknown Category numeric field %s", name)
  2897. }
  2898. // ClearedFields returns all nullable fields that were cleared during this
  2899. // mutation.
  2900. func (m *CategoryMutation) ClearedFields() []string {
  2901. var fields []string
  2902. if m.FieldCleared(category.FieldDeletedAt) {
  2903. fields = append(fields, category.FieldDeletedAt)
  2904. }
  2905. return fields
  2906. }
  2907. // FieldCleared returns a boolean indicating if a field with the given name was
  2908. // cleared in this mutation.
  2909. func (m *CategoryMutation) FieldCleared(name string) bool {
  2910. _, ok := m.clearedFields[name]
  2911. return ok
  2912. }
  2913. // ClearField clears the value of the field with the given name. It returns an
  2914. // error if the field is not defined in the schema.
  2915. func (m *CategoryMutation) ClearField(name string) error {
  2916. switch name {
  2917. case category.FieldDeletedAt:
  2918. m.ClearDeletedAt()
  2919. return nil
  2920. }
  2921. return fmt.Errorf("unknown Category nullable field %s", name)
  2922. }
  2923. // ResetField resets all changes in the mutation for the field with the given name.
  2924. // It returns an error if the field is not defined in the schema.
  2925. func (m *CategoryMutation) ResetField(name string) error {
  2926. switch name {
  2927. case category.FieldCreatedAt:
  2928. m.ResetCreatedAt()
  2929. return nil
  2930. case category.FieldUpdatedAt:
  2931. m.ResetUpdatedAt()
  2932. return nil
  2933. case category.FieldDeletedAt:
  2934. m.ResetDeletedAt()
  2935. return nil
  2936. case category.FieldName:
  2937. m.ResetName()
  2938. return nil
  2939. case category.FieldOrganizationID:
  2940. m.ResetOrganizationID()
  2941. return nil
  2942. }
  2943. return fmt.Errorf("unknown Category field %s", name)
  2944. }
  2945. // AddedEdges returns all edge names that were set/added in this mutation.
  2946. func (m *CategoryMutation) AddedEdges() []string {
  2947. edges := make([]string, 0, 0)
  2948. return edges
  2949. }
  2950. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2951. // name in this mutation.
  2952. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  2953. return nil
  2954. }
  2955. // RemovedEdges returns all edge names that were removed in this mutation.
  2956. func (m *CategoryMutation) RemovedEdges() []string {
  2957. edges := make([]string, 0, 0)
  2958. return edges
  2959. }
  2960. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2961. // the given name in this mutation.
  2962. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  2963. return nil
  2964. }
  2965. // ClearedEdges returns all edge names that were cleared in this mutation.
  2966. func (m *CategoryMutation) ClearedEdges() []string {
  2967. edges := make([]string, 0, 0)
  2968. return edges
  2969. }
  2970. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2971. // was cleared in this mutation.
  2972. func (m *CategoryMutation) EdgeCleared(name string) bool {
  2973. return false
  2974. }
  2975. // ClearEdge clears the value of the edge with the given name. It returns an error
  2976. // if that edge is not defined in the schema.
  2977. func (m *CategoryMutation) ClearEdge(name string) error {
  2978. return fmt.Errorf("unknown Category unique edge %s", name)
  2979. }
  2980. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2981. // It returns an error if the edge is not defined in the schema.
  2982. func (m *CategoryMutation) ResetEdge(name string) error {
  2983. return fmt.Errorf("unknown Category edge %s", name)
  2984. }
  2985. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  2986. type ContactMutation struct {
  2987. config
  2988. op Op
  2989. typ string
  2990. id *uint64
  2991. created_at *time.Time
  2992. updated_at *time.Time
  2993. status *uint8
  2994. addstatus *int8
  2995. deleted_at *time.Time
  2996. wx_wxid *string
  2997. _type *int
  2998. add_type *int
  2999. wxid *string
  3000. account *string
  3001. nickname *string
  3002. markname *string
  3003. headimg *string
  3004. sex *int
  3005. addsex *int
  3006. starrole *string
  3007. dontseeit *int
  3008. adddontseeit *int
  3009. dontseeme *int
  3010. adddontseeme *int
  3011. lag *string
  3012. gid *string
  3013. gname *string
  3014. v3 *string
  3015. organization_id *uint64
  3016. addorganization_id *int64
  3017. clearedFields map[string]struct{}
  3018. contact_relationships map[uint64]struct{}
  3019. removedcontact_relationships map[uint64]struct{}
  3020. clearedcontact_relationships bool
  3021. contact_messages map[uint64]struct{}
  3022. removedcontact_messages map[uint64]struct{}
  3023. clearedcontact_messages bool
  3024. done bool
  3025. oldValue func(context.Context) (*Contact, error)
  3026. predicates []predicate.Contact
  3027. }
  3028. var _ ent.Mutation = (*ContactMutation)(nil)
  3029. // contactOption allows management of the mutation configuration using functional options.
  3030. type contactOption func(*ContactMutation)
  3031. // newContactMutation creates new mutation for the Contact entity.
  3032. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  3033. m := &ContactMutation{
  3034. config: c,
  3035. op: op,
  3036. typ: TypeContact,
  3037. clearedFields: make(map[string]struct{}),
  3038. }
  3039. for _, opt := range opts {
  3040. opt(m)
  3041. }
  3042. return m
  3043. }
  3044. // withContactID sets the ID field of the mutation.
  3045. func withContactID(id uint64) contactOption {
  3046. return func(m *ContactMutation) {
  3047. var (
  3048. err error
  3049. once sync.Once
  3050. value *Contact
  3051. )
  3052. m.oldValue = func(ctx context.Context) (*Contact, error) {
  3053. once.Do(func() {
  3054. if m.done {
  3055. err = errors.New("querying old values post mutation is not allowed")
  3056. } else {
  3057. value, err = m.Client().Contact.Get(ctx, id)
  3058. }
  3059. })
  3060. return value, err
  3061. }
  3062. m.id = &id
  3063. }
  3064. }
  3065. // withContact sets the old Contact of the mutation.
  3066. func withContact(node *Contact) contactOption {
  3067. return func(m *ContactMutation) {
  3068. m.oldValue = func(context.Context) (*Contact, error) {
  3069. return node, nil
  3070. }
  3071. m.id = &node.ID
  3072. }
  3073. }
  3074. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3075. // executed in a transaction (ent.Tx), a transactional client is returned.
  3076. func (m ContactMutation) Client() *Client {
  3077. client := &Client{config: m.config}
  3078. client.init()
  3079. return client
  3080. }
  3081. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3082. // it returns an error otherwise.
  3083. func (m ContactMutation) Tx() (*Tx, error) {
  3084. if _, ok := m.driver.(*txDriver); !ok {
  3085. return nil, errors.New("ent: mutation is not running in a transaction")
  3086. }
  3087. tx := &Tx{config: m.config}
  3088. tx.init()
  3089. return tx, nil
  3090. }
  3091. // SetID sets the value of the id field. Note that this
  3092. // operation is only accepted on creation of Contact entities.
  3093. func (m *ContactMutation) SetID(id uint64) {
  3094. m.id = &id
  3095. }
  3096. // ID returns the ID value in the mutation. Note that the ID is only available
  3097. // if it was provided to the builder or after it was returned from the database.
  3098. func (m *ContactMutation) ID() (id uint64, exists bool) {
  3099. if m.id == nil {
  3100. return
  3101. }
  3102. return *m.id, true
  3103. }
  3104. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3105. // That means, if the mutation is applied within a transaction with an isolation level such
  3106. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3107. // or updated by the mutation.
  3108. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  3109. switch {
  3110. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3111. id, exists := m.ID()
  3112. if exists {
  3113. return []uint64{id}, nil
  3114. }
  3115. fallthrough
  3116. case m.op.Is(OpUpdate | OpDelete):
  3117. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  3118. default:
  3119. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3120. }
  3121. }
  3122. // SetCreatedAt sets the "created_at" field.
  3123. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  3124. m.created_at = &t
  3125. }
  3126. // CreatedAt returns the value of the "created_at" field in the mutation.
  3127. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  3128. v := m.created_at
  3129. if v == nil {
  3130. return
  3131. }
  3132. return *v, true
  3133. }
  3134. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  3135. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3137. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3138. if !m.op.Is(OpUpdateOne) {
  3139. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3140. }
  3141. if m.id == nil || m.oldValue == nil {
  3142. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3143. }
  3144. oldValue, err := m.oldValue(ctx)
  3145. if err != nil {
  3146. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3147. }
  3148. return oldValue.CreatedAt, nil
  3149. }
  3150. // ResetCreatedAt resets all changes to the "created_at" field.
  3151. func (m *ContactMutation) ResetCreatedAt() {
  3152. m.created_at = nil
  3153. }
  3154. // SetUpdatedAt sets the "updated_at" field.
  3155. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  3156. m.updated_at = &t
  3157. }
  3158. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3159. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  3160. v := m.updated_at
  3161. if v == nil {
  3162. return
  3163. }
  3164. return *v, true
  3165. }
  3166. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  3167. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3168. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3169. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3170. if !m.op.Is(OpUpdateOne) {
  3171. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3172. }
  3173. if m.id == nil || m.oldValue == nil {
  3174. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3175. }
  3176. oldValue, err := m.oldValue(ctx)
  3177. if err != nil {
  3178. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3179. }
  3180. return oldValue.UpdatedAt, nil
  3181. }
  3182. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3183. func (m *ContactMutation) ResetUpdatedAt() {
  3184. m.updated_at = nil
  3185. }
  3186. // SetStatus sets the "status" field.
  3187. func (m *ContactMutation) SetStatus(u uint8) {
  3188. m.status = &u
  3189. m.addstatus = nil
  3190. }
  3191. // Status returns the value of the "status" field in the mutation.
  3192. func (m *ContactMutation) Status() (r uint8, exists bool) {
  3193. v := m.status
  3194. if v == nil {
  3195. return
  3196. }
  3197. return *v, true
  3198. }
  3199. // OldStatus returns the old "status" field's value of the Contact entity.
  3200. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3202. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  3203. if !m.op.Is(OpUpdateOne) {
  3204. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3205. }
  3206. if m.id == nil || m.oldValue == nil {
  3207. return v, errors.New("OldStatus requires an ID field in the mutation")
  3208. }
  3209. oldValue, err := m.oldValue(ctx)
  3210. if err != nil {
  3211. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3212. }
  3213. return oldValue.Status, nil
  3214. }
  3215. // AddStatus adds u to the "status" field.
  3216. func (m *ContactMutation) AddStatus(u int8) {
  3217. if m.addstatus != nil {
  3218. *m.addstatus += u
  3219. } else {
  3220. m.addstatus = &u
  3221. }
  3222. }
  3223. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3224. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  3225. v := m.addstatus
  3226. if v == nil {
  3227. return
  3228. }
  3229. return *v, true
  3230. }
  3231. // ClearStatus clears the value of the "status" field.
  3232. func (m *ContactMutation) ClearStatus() {
  3233. m.status = nil
  3234. m.addstatus = nil
  3235. m.clearedFields[contact.FieldStatus] = struct{}{}
  3236. }
  3237. // StatusCleared returns if the "status" field was cleared in this mutation.
  3238. func (m *ContactMutation) StatusCleared() bool {
  3239. _, ok := m.clearedFields[contact.FieldStatus]
  3240. return ok
  3241. }
  3242. // ResetStatus resets all changes to the "status" field.
  3243. func (m *ContactMutation) ResetStatus() {
  3244. m.status = nil
  3245. m.addstatus = nil
  3246. delete(m.clearedFields, contact.FieldStatus)
  3247. }
  3248. // SetDeletedAt sets the "deleted_at" field.
  3249. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  3250. m.deleted_at = &t
  3251. }
  3252. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3253. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  3254. v := m.deleted_at
  3255. if v == nil {
  3256. return
  3257. }
  3258. return *v, true
  3259. }
  3260. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  3261. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3263. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3264. if !m.op.Is(OpUpdateOne) {
  3265. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3266. }
  3267. if m.id == nil || m.oldValue == nil {
  3268. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3269. }
  3270. oldValue, err := m.oldValue(ctx)
  3271. if err != nil {
  3272. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3273. }
  3274. return oldValue.DeletedAt, nil
  3275. }
  3276. // ClearDeletedAt clears the value of the "deleted_at" field.
  3277. func (m *ContactMutation) ClearDeletedAt() {
  3278. m.deleted_at = nil
  3279. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  3280. }
  3281. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3282. func (m *ContactMutation) DeletedAtCleared() bool {
  3283. _, ok := m.clearedFields[contact.FieldDeletedAt]
  3284. return ok
  3285. }
  3286. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3287. func (m *ContactMutation) ResetDeletedAt() {
  3288. m.deleted_at = nil
  3289. delete(m.clearedFields, contact.FieldDeletedAt)
  3290. }
  3291. // SetWxWxid sets the "wx_wxid" field.
  3292. func (m *ContactMutation) SetWxWxid(s string) {
  3293. m.wx_wxid = &s
  3294. }
  3295. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  3296. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  3297. v := m.wx_wxid
  3298. if v == nil {
  3299. return
  3300. }
  3301. return *v, true
  3302. }
  3303. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  3304. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3306. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  3307. if !m.op.Is(OpUpdateOne) {
  3308. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  3309. }
  3310. if m.id == nil || m.oldValue == nil {
  3311. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  3312. }
  3313. oldValue, err := m.oldValue(ctx)
  3314. if err != nil {
  3315. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  3316. }
  3317. return oldValue.WxWxid, nil
  3318. }
  3319. // ClearWxWxid clears the value of the "wx_wxid" field.
  3320. func (m *ContactMutation) ClearWxWxid() {
  3321. m.wx_wxid = nil
  3322. m.clearedFields[contact.FieldWxWxid] = struct{}{}
  3323. }
  3324. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  3325. func (m *ContactMutation) WxWxidCleared() bool {
  3326. _, ok := m.clearedFields[contact.FieldWxWxid]
  3327. return ok
  3328. }
  3329. // ResetWxWxid resets all changes to the "wx_wxid" field.
  3330. func (m *ContactMutation) ResetWxWxid() {
  3331. m.wx_wxid = nil
  3332. delete(m.clearedFields, contact.FieldWxWxid)
  3333. }
  3334. // SetType sets the "type" field.
  3335. func (m *ContactMutation) SetType(i int) {
  3336. m._type = &i
  3337. m.add_type = nil
  3338. }
  3339. // GetType returns the value of the "type" field in the mutation.
  3340. func (m *ContactMutation) GetType() (r int, exists bool) {
  3341. v := m._type
  3342. if v == nil {
  3343. return
  3344. }
  3345. return *v, true
  3346. }
  3347. // OldType returns the old "type" field's value of the Contact entity.
  3348. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3350. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  3351. if !m.op.Is(OpUpdateOne) {
  3352. return v, errors.New("OldType is only allowed on UpdateOne operations")
  3353. }
  3354. if m.id == nil || m.oldValue == nil {
  3355. return v, errors.New("OldType requires an ID field in the mutation")
  3356. }
  3357. oldValue, err := m.oldValue(ctx)
  3358. if err != nil {
  3359. return v, fmt.Errorf("querying old value for OldType: %w", err)
  3360. }
  3361. return oldValue.Type, nil
  3362. }
  3363. // AddType adds i to the "type" field.
  3364. func (m *ContactMutation) AddType(i int) {
  3365. if m.add_type != nil {
  3366. *m.add_type += i
  3367. } else {
  3368. m.add_type = &i
  3369. }
  3370. }
  3371. // AddedType returns the value that was added to the "type" field in this mutation.
  3372. func (m *ContactMutation) AddedType() (r int, exists bool) {
  3373. v := m.add_type
  3374. if v == nil {
  3375. return
  3376. }
  3377. return *v, true
  3378. }
  3379. // ClearType clears the value of the "type" field.
  3380. func (m *ContactMutation) ClearType() {
  3381. m._type = nil
  3382. m.add_type = nil
  3383. m.clearedFields[contact.FieldType] = struct{}{}
  3384. }
  3385. // TypeCleared returns if the "type" field was cleared in this mutation.
  3386. func (m *ContactMutation) TypeCleared() bool {
  3387. _, ok := m.clearedFields[contact.FieldType]
  3388. return ok
  3389. }
  3390. // ResetType resets all changes to the "type" field.
  3391. func (m *ContactMutation) ResetType() {
  3392. m._type = nil
  3393. m.add_type = nil
  3394. delete(m.clearedFields, contact.FieldType)
  3395. }
  3396. // SetWxid sets the "wxid" field.
  3397. func (m *ContactMutation) SetWxid(s string) {
  3398. m.wxid = &s
  3399. }
  3400. // Wxid returns the value of the "wxid" field in the mutation.
  3401. func (m *ContactMutation) Wxid() (r string, exists bool) {
  3402. v := m.wxid
  3403. if v == nil {
  3404. return
  3405. }
  3406. return *v, true
  3407. }
  3408. // OldWxid returns the old "wxid" field's value of the Contact entity.
  3409. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3410. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3411. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  3412. if !m.op.Is(OpUpdateOne) {
  3413. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  3414. }
  3415. if m.id == nil || m.oldValue == nil {
  3416. return v, errors.New("OldWxid requires an ID field in the mutation")
  3417. }
  3418. oldValue, err := m.oldValue(ctx)
  3419. if err != nil {
  3420. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  3421. }
  3422. return oldValue.Wxid, nil
  3423. }
  3424. // ResetWxid resets all changes to the "wxid" field.
  3425. func (m *ContactMutation) ResetWxid() {
  3426. m.wxid = nil
  3427. }
  3428. // SetAccount sets the "account" field.
  3429. func (m *ContactMutation) SetAccount(s string) {
  3430. m.account = &s
  3431. }
  3432. // Account returns the value of the "account" field in the mutation.
  3433. func (m *ContactMutation) Account() (r string, exists bool) {
  3434. v := m.account
  3435. if v == nil {
  3436. return
  3437. }
  3438. return *v, true
  3439. }
  3440. // OldAccount returns the old "account" field's value of the Contact entity.
  3441. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3443. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  3444. if !m.op.Is(OpUpdateOne) {
  3445. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  3446. }
  3447. if m.id == nil || m.oldValue == nil {
  3448. return v, errors.New("OldAccount requires an ID field in the mutation")
  3449. }
  3450. oldValue, err := m.oldValue(ctx)
  3451. if err != nil {
  3452. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  3453. }
  3454. return oldValue.Account, nil
  3455. }
  3456. // ResetAccount resets all changes to the "account" field.
  3457. func (m *ContactMutation) ResetAccount() {
  3458. m.account = nil
  3459. }
  3460. // SetNickname sets the "nickname" field.
  3461. func (m *ContactMutation) SetNickname(s string) {
  3462. m.nickname = &s
  3463. }
  3464. // Nickname returns the value of the "nickname" field in the mutation.
  3465. func (m *ContactMutation) Nickname() (r string, exists bool) {
  3466. v := m.nickname
  3467. if v == nil {
  3468. return
  3469. }
  3470. return *v, true
  3471. }
  3472. // OldNickname returns the old "nickname" field's value of the Contact entity.
  3473. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3475. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  3476. if !m.op.Is(OpUpdateOne) {
  3477. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  3478. }
  3479. if m.id == nil || m.oldValue == nil {
  3480. return v, errors.New("OldNickname requires an ID field in the mutation")
  3481. }
  3482. oldValue, err := m.oldValue(ctx)
  3483. if err != nil {
  3484. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  3485. }
  3486. return oldValue.Nickname, nil
  3487. }
  3488. // ResetNickname resets all changes to the "nickname" field.
  3489. func (m *ContactMutation) ResetNickname() {
  3490. m.nickname = nil
  3491. }
  3492. // SetMarkname sets the "markname" field.
  3493. func (m *ContactMutation) SetMarkname(s string) {
  3494. m.markname = &s
  3495. }
  3496. // Markname returns the value of the "markname" field in the mutation.
  3497. func (m *ContactMutation) Markname() (r string, exists bool) {
  3498. v := m.markname
  3499. if v == nil {
  3500. return
  3501. }
  3502. return *v, true
  3503. }
  3504. // OldMarkname returns the old "markname" field's value of the Contact entity.
  3505. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3507. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  3508. if !m.op.Is(OpUpdateOne) {
  3509. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  3510. }
  3511. if m.id == nil || m.oldValue == nil {
  3512. return v, errors.New("OldMarkname requires an ID field in the mutation")
  3513. }
  3514. oldValue, err := m.oldValue(ctx)
  3515. if err != nil {
  3516. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  3517. }
  3518. return oldValue.Markname, nil
  3519. }
  3520. // ResetMarkname resets all changes to the "markname" field.
  3521. func (m *ContactMutation) ResetMarkname() {
  3522. m.markname = nil
  3523. }
  3524. // SetHeadimg sets the "headimg" field.
  3525. func (m *ContactMutation) SetHeadimg(s string) {
  3526. m.headimg = &s
  3527. }
  3528. // Headimg returns the value of the "headimg" field in the mutation.
  3529. func (m *ContactMutation) Headimg() (r string, exists bool) {
  3530. v := m.headimg
  3531. if v == nil {
  3532. return
  3533. }
  3534. return *v, true
  3535. }
  3536. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  3537. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3539. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  3540. if !m.op.Is(OpUpdateOne) {
  3541. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  3542. }
  3543. if m.id == nil || m.oldValue == nil {
  3544. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  3545. }
  3546. oldValue, err := m.oldValue(ctx)
  3547. if err != nil {
  3548. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  3549. }
  3550. return oldValue.Headimg, nil
  3551. }
  3552. // ResetHeadimg resets all changes to the "headimg" field.
  3553. func (m *ContactMutation) ResetHeadimg() {
  3554. m.headimg = nil
  3555. }
  3556. // SetSex sets the "sex" field.
  3557. func (m *ContactMutation) SetSex(i int) {
  3558. m.sex = &i
  3559. m.addsex = nil
  3560. }
  3561. // Sex returns the value of the "sex" field in the mutation.
  3562. func (m *ContactMutation) Sex() (r int, exists bool) {
  3563. v := m.sex
  3564. if v == nil {
  3565. return
  3566. }
  3567. return *v, true
  3568. }
  3569. // OldSex returns the old "sex" field's value of the Contact entity.
  3570. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3572. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  3573. if !m.op.Is(OpUpdateOne) {
  3574. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  3575. }
  3576. if m.id == nil || m.oldValue == nil {
  3577. return v, errors.New("OldSex requires an ID field in the mutation")
  3578. }
  3579. oldValue, err := m.oldValue(ctx)
  3580. if err != nil {
  3581. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  3582. }
  3583. return oldValue.Sex, nil
  3584. }
  3585. // AddSex adds i to the "sex" field.
  3586. func (m *ContactMutation) AddSex(i int) {
  3587. if m.addsex != nil {
  3588. *m.addsex += i
  3589. } else {
  3590. m.addsex = &i
  3591. }
  3592. }
  3593. // AddedSex returns the value that was added to the "sex" field in this mutation.
  3594. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  3595. v := m.addsex
  3596. if v == nil {
  3597. return
  3598. }
  3599. return *v, true
  3600. }
  3601. // ResetSex resets all changes to the "sex" field.
  3602. func (m *ContactMutation) ResetSex() {
  3603. m.sex = nil
  3604. m.addsex = nil
  3605. }
  3606. // SetStarrole sets the "starrole" field.
  3607. func (m *ContactMutation) SetStarrole(s string) {
  3608. m.starrole = &s
  3609. }
  3610. // Starrole returns the value of the "starrole" field in the mutation.
  3611. func (m *ContactMutation) Starrole() (r string, exists bool) {
  3612. v := m.starrole
  3613. if v == nil {
  3614. return
  3615. }
  3616. return *v, true
  3617. }
  3618. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  3619. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3621. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  3622. if !m.op.Is(OpUpdateOne) {
  3623. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  3624. }
  3625. if m.id == nil || m.oldValue == nil {
  3626. return v, errors.New("OldStarrole requires an ID field in the mutation")
  3627. }
  3628. oldValue, err := m.oldValue(ctx)
  3629. if err != nil {
  3630. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  3631. }
  3632. return oldValue.Starrole, nil
  3633. }
  3634. // ResetStarrole resets all changes to the "starrole" field.
  3635. func (m *ContactMutation) ResetStarrole() {
  3636. m.starrole = nil
  3637. }
  3638. // SetDontseeit sets the "dontseeit" field.
  3639. func (m *ContactMutation) SetDontseeit(i int) {
  3640. m.dontseeit = &i
  3641. m.adddontseeit = nil
  3642. }
  3643. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  3644. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  3645. v := m.dontseeit
  3646. if v == nil {
  3647. return
  3648. }
  3649. return *v, true
  3650. }
  3651. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  3652. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3654. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  3655. if !m.op.Is(OpUpdateOne) {
  3656. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  3657. }
  3658. if m.id == nil || m.oldValue == nil {
  3659. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  3660. }
  3661. oldValue, err := m.oldValue(ctx)
  3662. if err != nil {
  3663. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  3664. }
  3665. return oldValue.Dontseeit, nil
  3666. }
  3667. // AddDontseeit adds i to the "dontseeit" field.
  3668. func (m *ContactMutation) AddDontseeit(i int) {
  3669. if m.adddontseeit != nil {
  3670. *m.adddontseeit += i
  3671. } else {
  3672. m.adddontseeit = &i
  3673. }
  3674. }
  3675. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  3676. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  3677. v := m.adddontseeit
  3678. if v == nil {
  3679. return
  3680. }
  3681. return *v, true
  3682. }
  3683. // ResetDontseeit resets all changes to the "dontseeit" field.
  3684. func (m *ContactMutation) ResetDontseeit() {
  3685. m.dontseeit = nil
  3686. m.adddontseeit = nil
  3687. }
  3688. // SetDontseeme sets the "dontseeme" field.
  3689. func (m *ContactMutation) SetDontseeme(i int) {
  3690. m.dontseeme = &i
  3691. m.adddontseeme = nil
  3692. }
  3693. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  3694. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  3695. v := m.dontseeme
  3696. if v == nil {
  3697. return
  3698. }
  3699. return *v, true
  3700. }
  3701. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  3702. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3704. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  3705. if !m.op.Is(OpUpdateOne) {
  3706. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  3707. }
  3708. if m.id == nil || m.oldValue == nil {
  3709. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  3710. }
  3711. oldValue, err := m.oldValue(ctx)
  3712. if err != nil {
  3713. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  3714. }
  3715. return oldValue.Dontseeme, nil
  3716. }
  3717. // AddDontseeme adds i to the "dontseeme" field.
  3718. func (m *ContactMutation) AddDontseeme(i int) {
  3719. if m.adddontseeme != nil {
  3720. *m.adddontseeme += i
  3721. } else {
  3722. m.adddontseeme = &i
  3723. }
  3724. }
  3725. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  3726. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  3727. v := m.adddontseeme
  3728. if v == nil {
  3729. return
  3730. }
  3731. return *v, true
  3732. }
  3733. // ResetDontseeme resets all changes to the "dontseeme" field.
  3734. func (m *ContactMutation) ResetDontseeme() {
  3735. m.dontseeme = nil
  3736. m.adddontseeme = nil
  3737. }
  3738. // SetLag sets the "lag" field.
  3739. func (m *ContactMutation) SetLag(s string) {
  3740. m.lag = &s
  3741. }
  3742. // Lag returns the value of the "lag" field in the mutation.
  3743. func (m *ContactMutation) Lag() (r string, exists bool) {
  3744. v := m.lag
  3745. if v == nil {
  3746. return
  3747. }
  3748. return *v, true
  3749. }
  3750. // OldLag returns the old "lag" field's value of the Contact entity.
  3751. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3753. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  3754. if !m.op.Is(OpUpdateOne) {
  3755. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  3756. }
  3757. if m.id == nil || m.oldValue == nil {
  3758. return v, errors.New("OldLag requires an ID field in the mutation")
  3759. }
  3760. oldValue, err := m.oldValue(ctx)
  3761. if err != nil {
  3762. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  3763. }
  3764. return oldValue.Lag, nil
  3765. }
  3766. // ResetLag resets all changes to the "lag" field.
  3767. func (m *ContactMutation) ResetLag() {
  3768. m.lag = nil
  3769. }
  3770. // SetGid sets the "gid" field.
  3771. func (m *ContactMutation) SetGid(s string) {
  3772. m.gid = &s
  3773. }
  3774. // Gid returns the value of the "gid" field in the mutation.
  3775. func (m *ContactMutation) Gid() (r string, exists bool) {
  3776. v := m.gid
  3777. if v == nil {
  3778. return
  3779. }
  3780. return *v, true
  3781. }
  3782. // OldGid returns the old "gid" field's value of the Contact entity.
  3783. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3785. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  3786. if !m.op.Is(OpUpdateOne) {
  3787. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  3788. }
  3789. if m.id == nil || m.oldValue == nil {
  3790. return v, errors.New("OldGid requires an ID field in the mutation")
  3791. }
  3792. oldValue, err := m.oldValue(ctx)
  3793. if err != nil {
  3794. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  3795. }
  3796. return oldValue.Gid, nil
  3797. }
  3798. // ResetGid resets all changes to the "gid" field.
  3799. func (m *ContactMutation) ResetGid() {
  3800. m.gid = nil
  3801. }
  3802. // SetGname sets the "gname" field.
  3803. func (m *ContactMutation) SetGname(s string) {
  3804. m.gname = &s
  3805. }
  3806. // Gname returns the value of the "gname" field in the mutation.
  3807. func (m *ContactMutation) Gname() (r string, exists bool) {
  3808. v := m.gname
  3809. if v == nil {
  3810. return
  3811. }
  3812. return *v, true
  3813. }
  3814. // OldGname returns the old "gname" field's value of the Contact entity.
  3815. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3817. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  3818. if !m.op.Is(OpUpdateOne) {
  3819. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  3820. }
  3821. if m.id == nil || m.oldValue == nil {
  3822. return v, errors.New("OldGname requires an ID field in the mutation")
  3823. }
  3824. oldValue, err := m.oldValue(ctx)
  3825. if err != nil {
  3826. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  3827. }
  3828. return oldValue.Gname, nil
  3829. }
  3830. // ResetGname resets all changes to the "gname" field.
  3831. func (m *ContactMutation) ResetGname() {
  3832. m.gname = nil
  3833. }
  3834. // SetV3 sets the "v3" field.
  3835. func (m *ContactMutation) SetV3(s string) {
  3836. m.v3 = &s
  3837. }
  3838. // V3 returns the value of the "v3" field in the mutation.
  3839. func (m *ContactMutation) V3() (r string, exists bool) {
  3840. v := m.v3
  3841. if v == nil {
  3842. return
  3843. }
  3844. return *v, true
  3845. }
  3846. // OldV3 returns the old "v3" field's value of the Contact entity.
  3847. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3849. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  3850. if !m.op.Is(OpUpdateOne) {
  3851. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  3852. }
  3853. if m.id == nil || m.oldValue == nil {
  3854. return v, errors.New("OldV3 requires an ID field in the mutation")
  3855. }
  3856. oldValue, err := m.oldValue(ctx)
  3857. if err != nil {
  3858. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  3859. }
  3860. return oldValue.V3, nil
  3861. }
  3862. // ResetV3 resets all changes to the "v3" field.
  3863. func (m *ContactMutation) ResetV3() {
  3864. m.v3 = nil
  3865. }
  3866. // SetOrganizationID sets the "organization_id" field.
  3867. func (m *ContactMutation) SetOrganizationID(u uint64) {
  3868. m.organization_id = &u
  3869. m.addorganization_id = nil
  3870. }
  3871. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3872. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  3873. v := m.organization_id
  3874. if v == nil {
  3875. return
  3876. }
  3877. return *v, true
  3878. }
  3879. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  3880. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3882. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3883. if !m.op.Is(OpUpdateOne) {
  3884. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3885. }
  3886. if m.id == nil || m.oldValue == nil {
  3887. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3888. }
  3889. oldValue, err := m.oldValue(ctx)
  3890. if err != nil {
  3891. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3892. }
  3893. return oldValue.OrganizationID, nil
  3894. }
  3895. // AddOrganizationID adds u to the "organization_id" field.
  3896. func (m *ContactMutation) AddOrganizationID(u int64) {
  3897. if m.addorganization_id != nil {
  3898. *m.addorganization_id += u
  3899. } else {
  3900. m.addorganization_id = &u
  3901. }
  3902. }
  3903. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3904. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  3905. v := m.addorganization_id
  3906. if v == nil {
  3907. return
  3908. }
  3909. return *v, true
  3910. }
  3911. // ClearOrganizationID clears the value of the "organization_id" field.
  3912. func (m *ContactMutation) ClearOrganizationID() {
  3913. m.organization_id = nil
  3914. m.addorganization_id = nil
  3915. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  3916. }
  3917. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3918. func (m *ContactMutation) OrganizationIDCleared() bool {
  3919. _, ok := m.clearedFields[contact.FieldOrganizationID]
  3920. return ok
  3921. }
  3922. // ResetOrganizationID resets all changes to the "organization_id" field.
  3923. func (m *ContactMutation) ResetOrganizationID() {
  3924. m.organization_id = nil
  3925. m.addorganization_id = nil
  3926. delete(m.clearedFields, contact.FieldOrganizationID)
  3927. }
  3928. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  3929. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  3930. if m.contact_relationships == nil {
  3931. m.contact_relationships = make(map[uint64]struct{})
  3932. }
  3933. for i := range ids {
  3934. m.contact_relationships[ids[i]] = struct{}{}
  3935. }
  3936. }
  3937. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  3938. func (m *ContactMutation) ClearContactRelationships() {
  3939. m.clearedcontact_relationships = true
  3940. }
  3941. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  3942. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  3943. return m.clearedcontact_relationships
  3944. }
  3945. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  3946. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  3947. if m.removedcontact_relationships == nil {
  3948. m.removedcontact_relationships = make(map[uint64]struct{})
  3949. }
  3950. for i := range ids {
  3951. delete(m.contact_relationships, ids[i])
  3952. m.removedcontact_relationships[ids[i]] = struct{}{}
  3953. }
  3954. }
  3955. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  3956. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  3957. for id := range m.removedcontact_relationships {
  3958. ids = append(ids, id)
  3959. }
  3960. return
  3961. }
  3962. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  3963. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  3964. for id := range m.contact_relationships {
  3965. ids = append(ids, id)
  3966. }
  3967. return
  3968. }
  3969. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  3970. func (m *ContactMutation) ResetContactRelationships() {
  3971. m.contact_relationships = nil
  3972. m.clearedcontact_relationships = false
  3973. m.removedcontact_relationships = nil
  3974. }
  3975. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  3976. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  3977. if m.contact_messages == nil {
  3978. m.contact_messages = make(map[uint64]struct{})
  3979. }
  3980. for i := range ids {
  3981. m.contact_messages[ids[i]] = struct{}{}
  3982. }
  3983. }
  3984. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  3985. func (m *ContactMutation) ClearContactMessages() {
  3986. m.clearedcontact_messages = true
  3987. }
  3988. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  3989. func (m *ContactMutation) ContactMessagesCleared() bool {
  3990. return m.clearedcontact_messages
  3991. }
  3992. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  3993. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  3994. if m.removedcontact_messages == nil {
  3995. m.removedcontact_messages = make(map[uint64]struct{})
  3996. }
  3997. for i := range ids {
  3998. delete(m.contact_messages, ids[i])
  3999. m.removedcontact_messages[ids[i]] = struct{}{}
  4000. }
  4001. }
  4002. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  4003. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  4004. for id := range m.removedcontact_messages {
  4005. ids = append(ids, id)
  4006. }
  4007. return
  4008. }
  4009. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  4010. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  4011. for id := range m.contact_messages {
  4012. ids = append(ids, id)
  4013. }
  4014. return
  4015. }
  4016. // ResetContactMessages resets all changes to the "contact_messages" edge.
  4017. func (m *ContactMutation) ResetContactMessages() {
  4018. m.contact_messages = nil
  4019. m.clearedcontact_messages = false
  4020. m.removedcontact_messages = nil
  4021. }
  4022. // Where appends a list predicates to the ContactMutation builder.
  4023. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  4024. m.predicates = append(m.predicates, ps...)
  4025. }
  4026. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  4027. // users can use type-assertion to append predicates that do not depend on any generated package.
  4028. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  4029. p := make([]predicate.Contact, len(ps))
  4030. for i := range ps {
  4031. p[i] = ps[i]
  4032. }
  4033. m.Where(p...)
  4034. }
  4035. // Op returns the operation name.
  4036. func (m *ContactMutation) Op() Op {
  4037. return m.op
  4038. }
  4039. // SetOp allows setting the mutation operation.
  4040. func (m *ContactMutation) SetOp(op Op) {
  4041. m.op = op
  4042. }
  4043. // Type returns the node type of this mutation (Contact).
  4044. func (m *ContactMutation) Type() string {
  4045. return m.typ
  4046. }
  4047. // Fields returns all fields that were changed during this mutation. Note that in
  4048. // order to get all numeric fields that were incremented/decremented, call
  4049. // AddedFields().
  4050. func (m *ContactMutation) Fields() []string {
  4051. fields := make([]string, 0, 20)
  4052. if m.created_at != nil {
  4053. fields = append(fields, contact.FieldCreatedAt)
  4054. }
  4055. if m.updated_at != nil {
  4056. fields = append(fields, contact.FieldUpdatedAt)
  4057. }
  4058. if m.status != nil {
  4059. fields = append(fields, contact.FieldStatus)
  4060. }
  4061. if m.deleted_at != nil {
  4062. fields = append(fields, contact.FieldDeletedAt)
  4063. }
  4064. if m.wx_wxid != nil {
  4065. fields = append(fields, contact.FieldWxWxid)
  4066. }
  4067. if m._type != nil {
  4068. fields = append(fields, contact.FieldType)
  4069. }
  4070. if m.wxid != nil {
  4071. fields = append(fields, contact.FieldWxid)
  4072. }
  4073. if m.account != nil {
  4074. fields = append(fields, contact.FieldAccount)
  4075. }
  4076. if m.nickname != nil {
  4077. fields = append(fields, contact.FieldNickname)
  4078. }
  4079. if m.markname != nil {
  4080. fields = append(fields, contact.FieldMarkname)
  4081. }
  4082. if m.headimg != nil {
  4083. fields = append(fields, contact.FieldHeadimg)
  4084. }
  4085. if m.sex != nil {
  4086. fields = append(fields, contact.FieldSex)
  4087. }
  4088. if m.starrole != nil {
  4089. fields = append(fields, contact.FieldStarrole)
  4090. }
  4091. if m.dontseeit != nil {
  4092. fields = append(fields, contact.FieldDontseeit)
  4093. }
  4094. if m.dontseeme != nil {
  4095. fields = append(fields, contact.FieldDontseeme)
  4096. }
  4097. if m.lag != nil {
  4098. fields = append(fields, contact.FieldLag)
  4099. }
  4100. if m.gid != nil {
  4101. fields = append(fields, contact.FieldGid)
  4102. }
  4103. if m.gname != nil {
  4104. fields = append(fields, contact.FieldGname)
  4105. }
  4106. if m.v3 != nil {
  4107. fields = append(fields, contact.FieldV3)
  4108. }
  4109. if m.organization_id != nil {
  4110. fields = append(fields, contact.FieldOrganizationID)
  4111. }
  4112. return fields
  4113. }
  4114. // Field returns the value of a field with the given name. The second boolean
  4115. // return value indicates that this field was not set, or was not defined in the
  4116. // schema.
  4117. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  4118. switch name {
  4119. case contact.FieldCreatedAt:
  4120. return m.CreatedAt()
  4121. case contact.FieldUpdatedAt:
  4122. return m.UpdatedAt()
  4123. case contact.FieldStatus:
  4124. return m.Status()
  4125. case contact.FieldDeletedAt:
  4126. return m.DeletedAt()
  4127. case contact.FieldWxWxid:
  4128. return m.WxWxid()
  4129. case contact.FieldType:
  4130. return m.GetType()
  4131. case contact.FieldWxid:
  4132. return m.Wxid()
  4133. case contact.FieldAccount:
  4134. return m.Account()
  4135. case contact.FieldNickname:
  4136. return m.Nickname()
  4137. case contact.FieldMarkname:
  4138. return m.Markname()
  4139. case contact.FieldHeadimg:
  4140. return m.Headimg()
  4141. case contact.FieldSex:
  4142. return m.Sex()
  4143. case contact.FieldStarrole:
  4144. return m.Starrole()
  4145. case contact.FieldDontseeit:
  4146. return m.Dontseeit()
  4147. case contact.FieldDontseeme:
  4148. return m.Dontseeme()
  4149. case contact.FieldLag:
  4150. return m.Lag()
  4151. case contact.FieldGid:
  4152. return m.Gid()
  4153. case contact.FieldGname:
  4154. return m.Gname()
  4155. case contact.FieldV3:
  4156. return m.V3()
  4157. case contact.FieldOrganizationID:
  4158. return m.OrganizationID()
  4159. }
  4160. return nil, false
  4161. }
  4162. // OldField returns the old value of the field from the database. An error is
  4163. // returned if the mutation operation is not UpdateOne, or the query to the
  4164. // database failed.
  4165. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4166. switch name {
  4167. case contact.FieldCreatedAt:
  4168. return m.OldCreatedAt(ctx)
  4169. case contact.FieldUpdatedAt:
  4170. return m.OldUpdatedAt(ctx)
  4171. case contact.FieldStatus:
  4172. return m.OldStatus(ctx)
  4173. case contact.FieldDeletedAt:
  4174. return m.OldDeletedAt(ctx)
  4175. case contact.FieldWxWxid:
  4176. return m.OldWxWxid(ctx)
  4177. case contact.FieldType:
  4178. return m.OldType(ctx)
  4179. case contact.FieldWxid:
  4180. return m.OldWxid(ctx)
  4181. case contact.FieldAccount:
  4182. return m.OldAccount(ctx)
  4183. case contact.FieldNickname:
  4184. return m.OldNickname(ctx)
  4185. case contact.FieldMarkname:
  4186. return m.OldMarkname(ctx)
  4187. case contact.FieldHeadimg:
  4188. return m.OldHeadimg(ctx)
  4189. case contact.FieldSex:
  4190. return m.OldSex(ctx)
  4191. case contact.FieldStarrole:
  4192. return m.OldStarrole(ctx)
  4193. case contact.FieldDontseeit:
  4194. return m.OldDontseeit(ctx)
  4195. case contact.FieldDontseeme:
  4196. return m.OldDontseeme(ctx)
  4197. case contact.FieldLag:
  4198. return m.OldLag(ctx)
  4199. case contact.FieldGid:
  4200. return m.OldGid(ctx)
  4201. case contact.FieldGname:
  4202. return m.OldGname(ctx)
  4203. case contact.FieldV3:
  4204. return m.OldV3(ctx)
  4205. case contact.FieldOrganizationID:
  4206. return m.OldOrganizationID(ctx)
  4207. }
  4208. return nil, fmt.Errorf("unknown Contact field %s", name)
  4209. }
  4210. // SetField sets the value of a field with the given name. It returns an error if
  4211. // the field is not defined in the schema, or if the type mismatched the field
  4212. // type.
  4213. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  4214. switch name {
  4215. case contact.FieldCreatedAt:
  4216. v, ok := value.(time.Time)
  4217. if !ok {
  4218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4219. }
  4220. m.SetCreatedAt(v)
  4221. return nil
  4222. case contact.FieldUpdatedAt:
  4223. v, ok := value.(time.Time)
  4224. if !ok {
  4225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4226. }
  4227. m.SetUpdatedAt(v)
  4228. return nil
  4229. case contact.FieldStatus:
  4230. v, ok := value.(uint8)
  4231. if !ok {
  4232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4233. }
  4234. m.SetStatus(v)
  4235. return nil
  4236. case contact.FieldDeletedAt:
  4237. v, ok := value.(time.Time)
  4238. if !ok {
  4239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4240. }
  4241. m.SetDeletedAt(v)
  4242. return nil
  4243. case contact.FieldWxWxid:
  4244. v, ok := value.(string)
  4245. if !ok {
  4246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4247. }
  4248. m.SetWxWxid(v)
  4249. return nil
  4250. case contact.FieldType:
  4251. v, ok := value.(int)
  4252. if !ok {
  4253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4254. }
  4255. m.SetType(v)
  4256. return nil
  4257. case contact.FieldWxid:
  4258. v, ok := value.(string)
  4259. if !ok {
  4260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4261. }
  4262. m.SetWxid(v)
  4263. return nil
  4264. case contact.FieldAccount:
  4265. v, ok := value.(string)
  4266. if !ok {
  4267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4268. }
  4269. m.SetAccount(v)
  4270. return nil
  4271. case contact.FieldNickname:
  4272. v, ok := value.(string)
  4273. if !ok {
  4274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4275. }
  4276. m.SetNickname(v)
  4277. return nil
  4278. case contact.FieldMarkname:
  4279. v, ok := value.(string)
  4280. if !ok {
  4281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4282. }
  4283. m.SetMarkname(v)
  4284. return nil
  4285. case contact.FieldHeadimg:
  4286. v, ok := value.(string)
  4287. if !ok {
  4288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4289. }
  4290. m.SetHeadimg(v)
  4291. return nil
  4292. case contact.FieldSex:
  4293. v, ok := value.(int)
  4294. if !ok {
  4295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4296. }
  4297. m.SetSex(v)
  4298. return nil
  4299. case contact.FieldStarrole:
  4300. v, ok := value.(string)
  4301. if !ok {
  4302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4303. }
  4304. m.SetStarrole(v)
  4305. return nil
  4306. case contact.FieldDontseeit:
  4307. v, ok := value.(int)
  4308. if !ok {
  4309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4310. }
  4311. m.SetDontseeit(v)
  4312. return nil
  4313. case contact.FieldDontseeme:
  4314. v, ok := value.(int)
  4315. if !ok {
  4316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4317. }
  4318. m.SetDontseeme(v)
  4319. return nil
  4320. case contact.FieldLag:
  4321. v, ok := value.(string)
  4322. if !ok {
  4323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4324. }
  4325. m.SetLag(v)
  4326. return nil
  4327. case contact.FieldGid:
  4328. v, ok := value.(string)
  4329. if !ok {
  4330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4331. }
  4332. m.SetGid(v)
  4333. return nil
  4334. case contact.FieldGname:
  4335. v, ok := value.(string)
  4336. if !ok {
  4337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4338. }
  4339. m.SetGname(v)
  4340. return nil
  4341. case contact.FieldV3:
  4342. v, ok := value.(string)
  4343. if !ok {
  4344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4345. }
  4346. m.SetV3(v)
  4347. return nil
  4348. case contact.FieldOrganizationID:
  4349. v, ok := value.(uint64)
  4350. if !ok {
  4351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4352. }
  4353. m.SetOrganizationID(v)
  4354. return nil
  4355. }
  4356. return fmt.Errorf("unknown Contact field %s", name)
  4357. }
  4358. // AddedFields returns all numeric fields that were incremented/decremented during
  4359. // this mutation.
  4360. func (m *ContactMutation) AddedFields() []string {
  4361. var fields []string
  4362. if m.addstatus != nil {
  4363. fields = append(fields, contact.FieldStatus)
  4364. }
  4365. if m.add_type != nil {
  4366. fields = append(fields, contact.FieldType)
  4367. }
  4368. if m.addsex != nil {
  4369. fields = append(fields, contact.FieldSex)
  4370. }
  4371. if m.adddontseeit != nil {
  4372. fields = append(fields, contact.FieldDontseeit)
  4373. }
  4374. if m.adddontseeme != nil {
  4375. fields = append(fields, contact.FieldDontseeme)
  4376. }
  4377. if m.addorganization_id != nil {
  4378. fields = append(fields, contact.FieldOrganizationID)
  4379. }
  4380. return fields
  4381. }
  4382. // AddedField returns the numeric value that was incremented/decremented on a field
  4383. // with the given name. The second boolean return value indicates that this field
  4384. // was not set, or was not defined in the schema.
  4385. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  4386. switch name {
  4387. case contact.FieldStatus:
  4388. return m.AddedStatus()
  4389. case contact.FieldType:
  4390. return m.AddedType()
  4391. case contact.FieldSex:
  4392. return m.AddedSex()
  4393. case contact.FieldDontseeit:
  4394. return m.AddedDontseeit()
  4395. case contact.FieldDontseeme:
  4396. return m.AddedDontseeme()
  4397. case contact.FieldOrganizationID:
  4398. return m.AddedOrganizationID()
  4399. }
  4400. return nil, false
  4401. }
  4402. // AddField adds the value to the field with the given name. It returns an error if
  4403. // the field is not defined in the schema, or if the type mismatched the field
  4404. // type.
  4405. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  4406. switch name {
  4407. case contact.FieldStatus:
  4408. v, ok := value.(int8)
  4409. if !ok {
  4410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4411. }
  4412. m.AddStatus(v)
  4413. return nil
  4414. case contact.FieldType:
  4415. v, ok := value.(int)
  4416. if !ok {
  4417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4418. }
  4419. m.AddType(v)
  4420. return nil
  4421. case contact.FieldSex:
  4422. v, ok := value.(int)
  4423. if !ok {
  4424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4425. }
  4426. m.AddSex(v)
  4427. return nil
  4428. case contact.FieldDontseeit:
  4429. v, ok := value.(int)
  4430. if !ok {
  4431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4432. }
  4433. m.AddDontseeit(v)
  4434. return nil
  4435. case contact.FieldDontseeme:
  4436. v, ok := value.(int)
  4437. if !ok {
  4438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4439. }
  4440. m.AddDontseeme(v)
  4441. return nil
  4442. case contact.FieldOrganizationID:
  4443. v, ok := value.(int64)
  4444. if !ok {
  4445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4446. }
  4447. m.AddOrganizationID(v)
  4448. return nil
  4449. }
  4450. return fmt.Errorf("unknown Contact numeric field %s", name)
  4451. }
  4452. // ClearedFields returns all nullable fields that were cleared during this
  4453. // mutation.
  4454. func (m *ContactMutation) ClearedFields() []string {
  4455. var fields []string
  4456. if m.FieldCleared(contact.FieldStatus) {
  4457. fields = append(fields, contact.FieldStatus)
  4458. }
  4459. if m.FieldCleared(contact.FieldDeletedAt) {
  4460. fields = append(fields, contact.FieldDeletedAt)
  4461. }
  4462. if m.FieldCleared(contact.FieldWxWxid) {
  4463. fields = append(fields, contact.FieldWxWxid)
  4464. }
  4465. if m.FieldCleared(contact.FieldType) {
  4466. fields = append(fields, contact.FieldType)
  4467. }
  4468. if m.FieldCleared(contact.FieldOrganizationID) {
  4469. fields = append(fields, contact.FieldOrganizationID)
  4470. }
  4471. return fields
  4472. }
  4473. // FieldCleared returns a boolean indicating if a field with the given name was
  4474. // cleared in this mutation.
  4475. func (m *ContactMutation) FieldCleared(name string) bool {
  4476. _, ok := m.clearedFields[name]
  4477. return ok
  4478. }
  4479. // ClearField clears the value of the field with the given name. It returns an
  4480. // error if the field is not defined in the schema.
  4481. func (m *ContactMutation) ClearField(name string) error {
  4482. switch name {
  4483. case contact.FieldStatus:
  4484. m.ClearStatus()
  4485. return nil
  4486. case contact.FieldDeletedAt:
  4487. m.ClearDeletedAt()
  4488. return nil
  4489. case contact.FieldWxWxid:
  4490. m.ClearWxWxid()
  4491. return nil
  4492. case contact.FieldType:
  4493. m.ClearType()
  4494. return nil
  4495. case contact.FieldOrganizationID:
  4496. m.ClearOrganizationID()
  4497. return nil
  4498. }
  4499. return fmt.Errorf("unknown Contact nullable field %s", name)
  4500. }
  4501. // ResetField resets all changes in the mutation for the field with the given name.
  4502. // It returns an error if the field is not defined in the schema.
  4503. func (m *ContactMutation) ResetField(name string) error {
  4504. switch name {
  4505. case contact.FieldCreatedAt:
  4506. m.ResetCreatedAt()
  4507. return nil
  4508. case contact.FieldUpdatedAt:
  4509. m.ResetUpdatedAt()
  4510. return nil
  4511. case contact.FieldStatus:
  4512. m.ResetStatus()
  4513. return nil
  4514. case contact.FieldDeletedAt:
  4515. m.ResetDeletedAt()
  4516. return nil
  4517. case contact.FieldWxWxid:
  4518. m.ResetWxWxid()
  4519. return nil
  4520. case contact.FieldType:
  4521. m.ResetType()
  4522. return nil
  4523. case contact.FieldWxid:
  4524. m.ResetWxid()
  4525. return nil
  4526. case contact.FieldAccount:
  4527. m.ResetAccount()
  4528. return nil
  4529. case contact.FieldNickname:
  4530. m.ResetNickname()
  4531. return nil
  4532. case contact.FieldMarkname:
  4533. m.ResetMarkname()
  4534. return nil
  4535. case contact.FieldHeadimg:
  4536. m.ResetHeadimg()
  4537. return nil
  4538. case contact.FieldSex:
  4539. m.ResetSex()
  4540. return nil
  4541. case contact.FieldStarrole:
  4542. m.ResetStarrole()
  4543. return nil
  4544. case contact.FieldDontseeit:
  4545. m.ResetDontseeit()
  4546. return nil
  4547. case contact.FieldDontseeme:
  4548. m.ResetDontseeme()
  4549. return nil
  4550. case contact.FieldLag:
  4551. m.ResetLag()
  4552. return nil
  4553. case contact.FieldGid:
  4554. m.ResetGid()
  4555. return nil
  4556. case contact.FieldGname:
  4557. m.ResetGname()
  4558. return nil
  4559. case contact.FieldV3:
  4560. m.ResetV3()
  4561. return nil
  4562. case contact.FieldOrganizationID:
  4563. m.ResetOrganizationID()
  4564. return nil
  4565. }
  4566. return fmt.Errorf("unknown Contact field %s", name)
  4567. }
  4568. // AddedEdges returns all edge names that were set/added in this mutation.
  4569. func (m *ContactMutation) AddedEdges() []string {
  4570. edges := make([]string, 0, 2)
  4571. if m.contact_relationships != nil {
  4572. edges = append(edges, contact.EdgeContactRelationships)
  4573. }
  4574. if m.contact_messages != nil {
  4575. edges = append(edges, contact.EdgeContactMessages)
  4576. }
  4577. return edges
  4578. }
  4579. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4580. // name in this mutation.
  4581. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  4582. switch name {
  4583. case contact.EdgeContactRelationships:
  4584. ids := make([]ent.Value, 0, len(m.contact_relationships))
  4585. for id := range m.contact_relationships {
  4586. ids = append(ids, id)
  4587. }
  4588. return ids
  4589. case contact.EdgeContactMessages:
  4590. ids := make([]ent.Value, 0, len(m.contact_messages))
  4591. for id := range m.contact_messages {
  4592. ids = append(ids, id)
  4593. }
  4594. return ids
  4595. }
  4596. return nil
  4597. }
  4598. // RemovedEdges returns all edge names that were removed in this mutation.
  4599. func (m *ContactMutation) RemovedEdges() []string {
  4600. edges := make([]string, 0, 2)
  4601. if m.removedcontact_relationships != nil {
  4602. edges = append(edges, contact.EdgeContactRelationships)
  4603. }
  4604. if m.removedcontact_messages != nil {
  4605. edges = append(edges, contact.EdgeContactMessages)
  4606. }
  4607. return edges
  4608. }
  4609. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4610. // the given name in this mutation.
  4611. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  4612. switch name {
  4613. case contact.EdgeContactRelationships:
  4614. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  4615. for id := range m.removedcontact_relationships {
  4616. ids = append(ids, id)
  4617. }
  4618. return ids
  4619. case contact.EdgeContactMessages:
  4620. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  4621. for id := range m.removedcontact_messages {
  4622. ids = append(ids, id)
  4623. }
  4624. return ids
  4625. }
  4626. return nil
  4627. }
  4628. // ClearedEdges returns all edge names that were cleared in this mutation.
  4629. func (m *ContactMutation) ClearedEdges() []string {
  4630. edges := make([]string, 0, 2)
  4631. if m.clearedcontact_relationships {
  4632. edges = append(edges, contact.EdgeContactRelationships)
  4633. }
  4634. if m.clearedcontact_messages {
  4635. edges = append(edges, contact.EdgeContactMessages)
  4636. }
  4637. return edges
  4638. }
  4639. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4640. // was cleared in this mutation.
  4641. func (m *ContactMutation) EdgeCleared(name string) bool {
  4642. switch name {
  4643. case contact.EdgeContactRelationships:
  4644. return m.clearedcontact_relationships
  4645. case contact.EdgeContactMessages:
  4646. return m.clearedcontact_messages
  4647. }
  4648. return false
  4649. }
  4650. // ClearEdge clears the value of the edge with the given name. It returns an error
  4651. // if that edge is not defined in the schema.
  4652. func (m *ContactMutation) ClearEdge(name string) error {
  4653. switch name {
  4654. }
  4655. return fmt.Errorf("unknown Contact unique edge %s", name)
  4656. }
  4657. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4658. // It returns an error if the edge is not defined in the schema.
  4659. func (m *ContactMutation) ResetEdge(name string) error {
  4660. switch name {
  4661. case contact.EdgeContactRelationships:
  4662. m.ResetContactRelationships()
  4663. return nil
  4664. case contact.EdgeContactMessages:
  4665. m.ResetContactMessages()
  4666. return nil
  4667. }
  4668. return fmt.Errorf("unknown Contact edge %s", name)
  4669. }
  4670. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  4671. type EmployeeMutation struct {
  4672. config
  4673. op Op
  4674. typ string
  4675. id *uint64
  4676. created_at *time.Time
  4677. updated_at *time.Time
  4678. deleted_at *time.Time
  4679. title *string
  4680. avatar *string
  4681. tags *string
  4682. hire_count *int
  4683. addhire_count *int
  4684. service_count *int
  4685. addservice_count *int
  4686. achievement_count *int
  4687. addachievement_count *int
  4688. intro *string
  4689. estimate *string
  4690. skill *string
  4691. ability_type *string
  4692. scene *string
  4693. switch_in *string
  4694. video_url *string
  4695. organization_id *uint64
  4696. addorganization_id *int64
  4697. category_id *uint64
  4698. addcategory_id *int64
  4699. clearedFields map[string]struct{}
  4700. em_work_experiences map[uint64]struct{}
  4701. removedem_work_experiences map[uint64]struct{}
  4702. clearedem_work_experiences bool
  4703. em_tutorial map[uint64]struct{}
  4704. removedem_tutorial map[uint64]struct{}
  4705. clearedem_tutorial bool
  4706. done bool
  4707. oldValue func(context.Context) (*Employee, error)
  4708. predicates []predicate.Employee
  4709. }
  4710. var _ ent.Mutation = (*EmployeeMutation)(nil)
  4711. // employeeOption allows management of the mutation configuration using functional options.
  4712. type employeeOption func(*EmployeeMutation)
  4713. // newEmployeeMutation creates new mutation for the Employee entity.
  4714. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  4715. m := &EmployeeMutation{
  4716. config: c,
  4717. op: op,
  4718. typ: TypeEmployee,
  4719. clearedFields: make(map[string]struct{}),
  4720. }
  4721. for _, opt := range opts {
  4722. opt(m)
  4723. }
  4724. return m
  4725. }
  4726. // withEmployeeID sets the ID field of the mutation.
  4727. func withEmployeeID(id uint64) employeeOption {
  4728. return func(m *EmployeeMutation) {
  4729. var (
  4730. err error
  4731. once sync.Once
  4732. value *Employee
  4733. )
  4734. m.oldValue = func(ctx context.Context) (*Employee, error) {
  4735. once.Do(func() {
  4736. if m.done {
  4737. err = errors.New("querying old values post mutation is not allowed")
  4738. } else {
  4739. value, err = m.Client().Employee.Get(ctx, id)
  4740. }
  4741. })
  4742. return value, err
  4743. }
  4744. m.id = &id
  4745. }
  4746. }
  4747. // withEmployee sets the old Employee of the mutation.
  4748. func withEmployee(node *Employee) employeeOption {
  4749. return func(m *EmployeeMutation) {
  4750. m.oldValue = func(context.Context) (*Employee, error) {
  4751. return node, nil
  4752. }
  4753. m.id = &node.ID
  4754. }
  4755. }
  4756. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4757. // executed in a transaction (ent.Tx), a transactional client is returned.
  4758. func (m EmployeeMutation) Client() *Client {
  4759. client := &Client{config: m.config}
  4760. client.init()
  4761. return client
  4762. }
  4763. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4764. // it returns an error otherwise.
  4765. func (m EmployeeMutation) Tx() (*Tx, error) {
  4766. if _, ok := m.driver.(*txDriver); !ok {
  4767. return nil, errors.New("ent: mutation is not running in a transaction")
  4768. }
  4769. tx := &Tx{config: m.config}
  4770. tx.init()
  4771. return tx, nil
  4772. }
  4773. // SetID sets the value of the id field. Note that this
  4774. // operation is only accepted on creation of Employee entities.
  4775. func (m *EmployeeMutation) SetID(id uint64) {
  4776. m.id = &id
  4777. }
  4778. // ID returns the ID value in the mutation. Note that the ID is only available
  4779. // if it was provided to the builder or after it was returned from the database.
  4780. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  4781. if m.id == nil {
  4782. return
  4783. }
  4784. return *m.id, true
  4785. }
  4786. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4787. // That means, if the mutation is applied within a transaction with an isolation level such
  4788. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4789. // or updated by the mutation.
  4790. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  4791. switch {
  4792. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4793. id, exists := m.ID()
  4794. if exists {
  4795. return []uint64{id}, nil
  4796. }
  4797. fallthrough
  4798. case m.op.Is(OpUpdate | OpDelete):
  4799. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  4800. default:
  4801. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4802. }
  4803. }
  4804. // SetCreatedAt sets the "created_at" field.
  4805. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  4806. m.created_at = &t
  4807. }
  4808. // CreatedAt returns the value of the "created_at" field in the mutation.
  4809. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  4810. v := m.created_at
  4811. if v == nil {
  4812. return
  4813. }
  4814. return *v, true
  4815. }
  4816. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  4817. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4819. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4820. if !m.op.Is(OpUpdateOne) {
  4821. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4822. }
  4823. if m.id == nil || m.oldValue == nil {
  4824. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4825. }
  4826. oldValue, err := m.oldValue(ctx)
  4827. if err != nil {
  4828. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4829. }
  4830. return oldValue.CreatedAt, nil
  4831. }
  4832. // ResetCreatedAt resets all changes to the "created_at" field.
  4833. func (m *EmployeeMutation) ResetCreatedAt() {
  4834. m.created_at = nil
  4835. }
  4836. // SetUpdatedAt sets the "updated_at" field.
  4837. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  4838. m.updated_at = &t
  4839. }
  4840. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4841. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  4842. v := m.updated_at
  4843. if v == nil {
  4844. return
  4845. }
  4846. return *v, true
  4847. }
  4848. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  4849. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4851. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4852. if !m.op.Is(OpUpdateOne) {
  4853. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4854. }
  4855. if m.id == nil || m.oldValue == nil {
  4856. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4857. }
  4858. oldValue, err := m.oldValue(ctx)
  4859. if err != nil {
  4860. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4861. }
  4862. return oldValue.UpdatedAt, nil
  4863. }
  4864. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4865. func (m *EmployeeMutation) ResetUpdatedAt() {
  4866. m.updated_at = nil
  4867. }
  4868. // SetDeletedAt sets the "deleted_at" field.
  4869. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  4870. m.deleted_at = &t
  4871. }
  4872. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4873. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  4874. v := m.deleted_at
  4875. if v == nil {
  4876. return
  4877. }
  4878. return *v, true
  4879. }
  4880. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  4881. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4882. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4883. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4884. if !m.op.Is(OpUpdateOne) {
  4885. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4886. }
  4887. if m.id == nil || m.oldValue == nil {
  4888. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4889. }
  4890. oldValue, err := m.oldValue(ctx)
  4891. if err != nil {
  4892. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4893. }
  4894. return oldValue.DeletedAt, nil
  4895. }
  4896. // ClearDeletedAt clears the value of the "deleted_at" field.
  4897. func (m *EmployeeMutation) ClearDeletedAt() {
  4898. m.deleted_at = nil
  4899. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  4900. }
  4901. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4902. func (m *EmployeeMutation) DeletedAtCleared() bool {
  4903. _, ok := m.clearedFields[employee.FieldDeletedAt]
  4904. return ok
  4905. }
  4906. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4907. func (m *EmployeeMutation) ResetDeletedAt() {
  4908. m.deleted_at = nil
  4909. delete(m.clearedFields, employee.FieldDeletedAt)
  4910. }
  4911. // SetTitle sets the "title" field.
  4912. func (m *EmployeeMutation) SetTitle(s string) {
  4913. m.title = &s
  4914. }
  4915. // Title returns the value of the "title" field in the mutation.
  4916. func (m *EmployeeMutation) Title() (r string, exists bool) {
  4917. v := m.title
  4918. if v == nil {
  4919. return
  4920. }
  4921. return *v, true
  4922. }
  4923. // OldTitle returns the old "title" field's value of the Employee entity.
  4924. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4925. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4926. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  4927. if !m.op.Is(OpUpdateOne) {
  4928. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4929. }
  4930. if m.id == nil || m.oldValue == nil {
  4931. return v, errors.New("OldTitle requires an ID field in the mutation")
  4932. }
  4933. oldValue, err := m.oldValue(ctx)
  4934. if err != nil {
  4935. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4936. }
  4937. return oldValue.Title, nil
  4938. }
  4939. // ResetTitle resets all changes to the "title" field.
  4940. func (m *EmployeeMutation) ResetTitle() {
  4941. m.title = nil
  4942. }
  4943. // SetAvatar sets the "avatar" field.
  4944. func (m *EmployeeMutation) SetAvatar(s string) {
  4945. m.avatar = &s
  4946. }
  4947. // Avatar returns the value of the "avatar" field in the mutation.
  4948. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  4949. v := m.avatar
  4950. if v == nil {
  4951. return
  4952. }
  4953. return *v, true
  4954. }
  4955. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  4956. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4958. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  4959. if !m.op.Is(OpUpdateOne) {
  4960. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  4961. }
  4962. if m.id == nil || m.oldValue == nil {
  4963. return v, errors.New("OldAvatar requires an ID field in the mutation")
  4964. }
  4965. oldValue, err := m.oldValue(ctx)
  4966. if err != nil {
  4967. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  4968. }
  4969. return oldValue.Avatar, nil
  4970. }
  4971. // ResetAvatar resets all changes to the "avatar" field.
  4972. func (m *EmployeeMutation) ResetAvatar() {
  4973. m.avatar = nil
  4974. }
  4975. // SetTags sets the "tags" field.
  4976. func (m *EmployeeMutation) SetTags(s string) {
  4977. m.tags = &s
  4978. }
  4979. // Tags returns the value of the "tags" field in the mutation.
  4980. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  4981. v := m.tags
  4982. if v == nil {
  4983. return
  4984. }
  4985. return *v, true
  4986. }
  4987. // OldTags returns the old "tags" field's value of the Employee entity.
  4988. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4990. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  4991. if !m.op.Is(OpUpdateOne) {
  4992. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  4993. }
  4994. if m.id == nil || m.oldValue == nil {
  4995. return v, errors.New("OldTags requires an ID field in the mutation")
  4996. }
  4997. oldValue, err := m.oldValue(ctx)
  4998. if err != nil {
  4999. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  5000. }
  5001. return oldValue.Tags, nil
  5002. }
  5003. // ResetTags resets all changes to the "tags" field.
  5004. func (m *EmployeeMutation) ResetTags() {
  5005. m.tags = nil
  5006. }
  5007. // SetHireCount sets the "hire_count" field.
  5008. func (m *EmployeeMutation) SetHireCount(i int) {
  5009. m.hire_count = &i
  5010. m.addhire_count = nil
  5011. }
  5012. // HireCount returns the value of the "hire_count" field in the mutation.
  5013. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  5014. v := m.hire_count
  5015. if v == nil {
  5016. return
  5017. }
  5018. return *v, true
  5019. }
  5020. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  5021. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5023. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  5024. if !m.op.Is(OpUpdateOne) {
  5025. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  5026. }
  5027. if m.id == nil || m.oldValue == nil {
  5028. return v, errors.New("OldHireCount requires an ID field in the mutation")
  5029. }
  5030. oldValue, err := m.oldValue(ctx)
  5031. if err != nil {
  5032. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  5033. }
  5034. return oldValue.HireCount, nil
  5035. }
  5036. // AddHireCount adds i to the "hire_count" field.
  5037. func (m *EmployeeMutation) AddHireCount(i int) {
  5038. if m.addhire_count != nil {
  5039. *m.addhire_count += i
  5040. } else {
  5041. m.addhire_count = &i
  5042. }
  5043. }
  5044. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  5045. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  5046. v := m.addhire_count
  5047. if v == nil {
  5048. return
  5049. }
  5050. return *v, true
  5051. }
  5052. // ResetHireCount resets all changes to the "hire_count" field.
  5053. func (m *EmployeeMutation) ResetHireCount() {
  5054. m.hire_count = nil
  5055. m.addhire_count = nil
  5056. }
  5057. // SetServiceCount sets the "service_count" field.
  5058. func (m *EmployeeMutation) SetServiceCount(i int) {
  5059. m.service_count = &i
  5060. m.addservice_count = nil
  5061. }
  5062. // ServiceCount returns the value of the "service_count" field in the mutation.
  5063. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  5064. v := m.service_count
  5065. if v == nil {
  5066. return
  5067. }
  5068. return *v, true
  5069. }
  5070. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  5071. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5073. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  5074. if !m.op.Is(OpUpdateOne) {
  5075. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  5076. }
  5077. if m.id == nil || m.oldValue == nil {
  5078. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  5079. }
  5080. oldValue, err := m.oldValue(ctx)
  5081. if err != nil {
  5082. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  5083. }
  5084. return oldValue.ServiceCount, nil
  5085. }
  5086. // AddServiceCount adds i to the "service_count" field.
  5087. func (m *EmployeeMutation) AddServiceCount(i int) {
  5088. if m.addservice_count != nil {
  5089. *m.addservice_count += i
  5090. } else {
  5091. m.addservice_count = &i
  5092. }
  5093. }
  5094. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  5095. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  5096. v := m.addservice_count
  5097. if v == nil {
  5098. return
  5099. }
  5100. return *v, true
  5101. }
  5102. // ResetServiceCount resets all changes to the "service_count" field.
  5103. func (m *EmployeeMutation) ResetServiceCount() {
  5104. m.service_count = nil
  5105. m.addservice_count = nil
  5106. }
  5107. // SetAchievementCount sets the "achievement_count" field.
  5108. func (m *EmployeeMutation) SetAchievementCount(i int) {
  5109. m.achievement_count = &i
  5110. m.addachievement_count = nil
  5111. }
  5112. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  5113. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  5114. v := m.achievement_count
  5115. if v == nil {
  5116. return
  5117. }
  5118. return *v, true
  5119. }
  5120. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  5121. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5122. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5123. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  5124. if !m.op.Is(OpUpdateOne) {
  5125. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  5126. }
  5127. if m.id == nil || m.oldValue == nil {
  5128. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  5129. }
  5130. oldValue, err := m.oldValue(ctx)
  5131. if err != nil {
  5132. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  5133. }
  5134. return oldValue.AchievementCount, nil
  5135. }
  5136. // AddAchievementCount adds i to the "achievement_count" field.
  5137. func (m *EmployeeMutation) AddAchievementCount(i int) {
  5138. if m.addachievement_count != nil {
  5139. *m.addachievement_count += i
  5140. } else {
  5141. m.addachievement_count = &i
  5142. }
  5143. }
  5144. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  5145. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  5146. v := m.addachievement_count
  5147. if v == nil {
  5148. return
  5149. }
  5150. return *v, true
  5151. }
  5152. // ResetAchievementCount resets all changes to the "achievement_count" field.
  5153. func (m *EmployeeMutation) ResetAchievementCount() {
  5154. m.achievement_count = nil
  5155. m.addachievement_count = nil
  5156. }
  5157. // SetIntro sets the "intro" field.
  5158. func (m *EmployeeMutation) SetIntro(s string) {
  5159. m.intro = &s
  5160. }
  5161. // Intro returns the value of the "intro" field in the mutation.
  5162. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  5163. v := m.intro
  5164. if v == nil {
  5165. return
  5166. }
  5167. return *v, true
  5168. }
  5169. // OldIntro returns the old "intro" field's value of the Employee entity.
  5170. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5172. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  5173. if !m.op.Is(OpUpdateOne) {
  5174. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  5175. }
  5176. if m.id == nil || m.oldValue == nil {
  5177. return v, errors.New("OldIntro requires an ID field in the mutation")
  5178. }
  5179. oldValue, err := m.oldValue(ctx)
  5180. if err != nil {
  5181. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  5182. }
  5183. return oldValue.Intro, nil
  5184. }
  5185. // ResetIntro resets all changes to the "intro" field.
  5186. func (m *EmployeeMutation) ResetIntro() {
  5187. m.intro = nil
  5188. }
  5189. // SetEstimate sets the "estimate" field.
  5190. func (m *EmployeeMutation) SetEstimate(s string) {
  5191. m.estimate = &s
  5192. }
  5193. // Estimate returns the value of the "estimate" field in the mutation.
  5194. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  5195. v := m.estimate
  5196. if v == nil {
  5197. return
  5198. }
  5199. return *v, true
  5200. }
  5201. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  5202. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5204. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  5205. if !m.op.Is(OpUpdateOne) {
  5206. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  5207. }
  5208. if m.id == nil || m.oldValue == nil {
  5209. return v, errors.New("OldEstimate requires an ID field in the mutation")
  5210. }
  5211. oldValue, err := m.oldValue(ctx)
  5212. if err != nil {
  5213. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  5214. }
  5215. return oldValue.Estimate, nil
  5216. }
  5217. // ResetEstimate resets all changes to the "estimate" field.
  5218. func (m *EmployeeMutation) ResetEstimate() {
  5219. m.estimate = nil
  5220. }
  5221. // SetSkill sets the "skill" field.
  5222. func (m *EmployeeMutation) SetSkill(s string) {
  5223. m.skill = &s
  5224. }
  5225. // Skill returns the value of the "skill" field in the mutation.
  5226. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  5227. v := m.skill
  5228. if v == nil {
  5229. return
  5230. }
  5231. return *v, true
  5232. }
  5233. // OldSkill returns the old "skill" field's value of the Employee entity.
  5234. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5236. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  5237. if !m.op.Is(OpUpdateOne) {
  5238. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  5239. }
  5240. if m.id == nil || m.oldValue == nil {
  5241. return v, errors.New("OldSkill requires an ID field in the mutation")
  5242. }
  5243. oldValue, err := m.oldValue(ctx)
  5244. if err != nil {
  5245. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  5246. }
  5247. return oldValue.Skill, nil
  5248. }
  5249. // ResetSkill resets all changes to the "skill" field.
  5250. func (m *EmployeeMutation) ResetSkill() {
  5251. m.skill = nil
  5252. }
  5253. // SetAbilityType sets the "ability_type" field.
  5254. func (m *EmployeeMutation) SetAbilityType(s string) {
  5255. m.ability_type = &s
  5256. }
  5257. // AbilityType returns the value of the "ability_type" field in the mutation.
  5258. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  5259. v := m.ability_type
  5260. if v == nil {
  5261. return
  5262. }
  5263. return *v, true
  5264. }
  5265. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  5266. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5268. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  5269. if !m.op.Is(OpUpdateOne) {
  5270. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  5271. }
  5272. if m.id == nil || m.oldValue == nil {
  5273. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  5274. }
  5275. oldValue, err := m.oldValue(ctx)
  5276. if err != nil {
  5277. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  5278. }
  5279. return oldValue.AbilityType, nil
  5280. }
  5281. // ResetAbilityType resets all changes to the "ability_type" field.
  5282. func (m *EmployeeMutation) ResetAbilityType() {
  5283. m.ability_type = nil
  5284. }
  5285. // SetScene sets the "scene" field.
  5286. func (m *EmployeeMutation) SetScene(s string) {
  5287. m.scene = &s
  5288. }
  5289. // Scene returns the value of the "scene" field in the mutation.
  5290. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  5291. v := m.scene
  5292. if v == nil {
  5293. return
  5294. }
  5295. return *v, true
  5296. }
  5297. // OldScene returns the old "scene" field's value of the Employee entity.
  5298. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5300. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  5301. if !m.op.Is(OpUpdateOne) {
  5302. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  5303. }
  5304. if m.id == nil || m.oldValue == nil {
  5305. return v, errors.New("OldScene requires an ID field in the mutation")
  5306. }
  5307. oldValue, err := m.oldValue(ctx)
  5308. if err != nil {
  5309. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  5310. }
  5311. return oldValue.Scene, nil
  5312. }
  5313. // ResetScene resets all changes to the "scene" field.
  5314. func (m *EmployeeMutation) ResetScene() {
  5315. m.scene = nil
  5316. }
  5317. // SetSwitchIn sets the "switch_in" field.
  5318. func (m *EmployeeMutation) SetSwitchIn(s string) {
  5319. m.switch_in = &s
  5320. }
  5321. // SwitchIn returns the value of the "switch_in" field in the mutation.
  5322. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  5323. v := m.switch_in
  5324. if v == nil {
  5325. return
  5326. }
  5327. return *v, true
  5328. }
  5329. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  5330. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5332. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  5333. if !m.op.Is(OpUpdateOne) {
  5334. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  5335. }
  5336. if m.id == nil || m.oldValue == nil {
  5337. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  5338. }
  5339. oldValue, err := m.oldValue(ctx)
  5340. if err != nil {
  5341. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  5342. }
  5343. return oldValue.SwitchIn, nil
  5344. }
  5345. // ResetSwitchIn resets all changes to the "switch_in" field.
  5346. func (m *EmployeeMutation) ResetSwitchIn() {
  5347. m.switch_in = nil
  5348. }
  5349. // SetVideoURL sets the "video_url" field.
  5350. func (m *EmployeeMutation) SetVideoURL(s string) {
  5351. m.video_url = &s
  5352. }
  5353. // VideoURL returns the value of the "video_url" field in the mutation.
  5354. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  5355. v := m.video_url
  5356. if v == nil {
  5357. return
  5358. }
  5359. return *v, true
  5360. }
  5361. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  5362. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5364. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  5365. if !m.op.Is(OpUpdateOne) {
  5366. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  5367. }
  5368. if m.id == nil || m.oldValue == nil {
  5369. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  5370. }
  5371. oldValue, err := m.oldValue(ctx)
  5372. if err != nil {
  5373. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  5374. }
  5375. return oldValue.VideoURL, nil
  5376. }
  5377. // ResetVideoURL resets all changes to the "video_url" field.
  5378. func (m *EmployeeMutation) ResetVideoURL() {
  5379. m.video_url = nil
  5380. }
  5381. // SetOrganizationID sets the "organization_id" field.
  5382. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  5383. m.organization_id = &u
  5384. m.addorganization_id = nil
  5385. }
  5386. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5387. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  5388. v := m.organization_id
  5389. if v == nil {
  5390. return
  5391. }
  5392. return *v, true
  5393. }
  5394. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  5395. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5397. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5398. if !m.op.Is(OpUpdateOne) {
  5399. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5400. }
  5401. if m.id == nil || m.oldValue == nil {
  5402. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5403. }
  5404. oldValue, err := m.oldValue(ctx)
  5405. if err != nil {
  5406. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5407. }
  5408. return oldValue.OrganizationID, nil
  5409. }
  5410. // AddOrganizationID adds u to the "organization_id" field.
  5411. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  5412. if m.addorganization_id != nil {
  5413. *m.addorganization_id += u
  5414. } else {
  5415. m.addorganization_id = &u
  5416. }
  5417. }
  5418. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5419. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  5420. v := m.addorganization_id
  5421. if v == nil {
  5422. return
  5423. }
  5424. return *v, true
  5425. }
  5426. // ResetOrganizationID resets all changes to the "organization_id" field.
  5427. func (m *EmployeeMutation) ResetOrganizationID() {
  5428. m.organization_id = nil
  5429. m.addorganization_id = nil
  5430. }
  5431. // SetCategoryID sets the "category_id" field.
  5432. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  5433. m.category_id = &u
  5434. m.addcategory_id = nil
  5435. }
  5436. // CategoryID returns the value of the "category_id" field in the mutation.
  5437. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  5438. v := m.category_id
  5439. if v == nil {
  5440. return
  5441. }
  5442. return *v, true
  5443. }
  5444. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  5445. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5447. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  5448. if !m.op.Is(OpUpdateOne) {
  5449. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  5450. }
  5451. if m.id == nil || m.oldValue == nil {
  5452. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  5453. }
  5454. oldValue, err := m.oldValue(ctx)
  5455. if err != nil {
  5456. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  5457. }
  5458. return oldValue.CategoryID, nil
  5459. }
  5460. // AddCategoryID adds u to the "category_id" field.
  5461. func (m *EmployeeMutation) AddCategoryID(u int64) {
  5462. if m.addcategory_id != nil {
  5463. *m.addcategory_id += u
  5464. } else {
  5465. m.addcategory_id = &u
  5466. }
  5467. }
  5468. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  5469. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  5470. v := m.addcategory_id
  5471. if v == nil {
  5472. return
  5473. }
  5474. return *v, true
  5475. }
  5476. // ResetCategoryID resets all changes to the "category_id" field.
  5477. func (m *EmployeeMutation) ResetCategoryID() {
  5478. m.category_id = nil
  5479. m.addcategory_id = nil
  5480. }
  5481. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  5482. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  5483. if m.em_work_experiences == nil {
  5484. m.em_work_experiences = make(map[uint64]struct{})
  5485. }
  5486. for i := range ids {
  5487. m.em_work_experiences[ids[i]] = struct{}{}
  5488. }
  5489. }
  5490. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  5491. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  5492. m.clearedem_work_experiences = true
  5493. }
  5494. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  5495. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  5496. return m.clearedem_work_experiences
  5497. }
  5498. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  5499. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  5500. if m.removedem_work_experiences == nil {
  5501. m.removedem_work_experiences = make(map[uint64]struct{})
  5502. }
  5503. for i := range ids {
  5504. delete(m.em_work_experiences, ids[i])
  5505. m.removedem_work_experiences[ids[i]] = struct{}{}
  5506. }
  5507. }
  5508. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  5509. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  5510. for id := range m.removedem_work_experiences {
  5511. ids = append(ids, id)
  5512. }
  5513. return
  5514. }
  5515. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  5516. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  5517. for id := range m.em_work_experiences {
  5518. ids = append(ids, id)
  5519. }
  5520. return
  5521. }
  5522. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  5523. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  5524. m.em_work_experiences = nil
  5525. m.clearedem_work_experiences = false
  5526. m.removedem_work_experiences = nil
  5527. }
  5528. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  5529. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  5530. if m.em_tutorial == nil {
  5531. m.em_tutorial = make(map[uint64]struct{})
  5532. }
  5533. for i := range ids {
  5534. m.em_tutorial[ids[i]] = struct{}{}
  5535. }
  5536. }
  5537. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  5538. func (m *EmployeeMutation) ClearEmTutorial() {
  5539. m.clearedem_tutorial = true
  5540. }
  5541. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  5542. func (m *EmployeeMutation) EmTutorialCleared() bool {
  5543. return m.clearedem_tutorial
  5544. }
  5545. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  5546. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  5547. if m.removedem_tutorial == nil {
  5548. m.removedem_tutorial = make(map[uint64]struct{})
  5549. }
  5550. for i := range ids {
  5551. delete(m.em_tutorial, ids[i])
  5552. m.removedem_tutorial[ids[i]] = struct{}{}
  5553. }
  5554. }
  5555. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  5556. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  5557. for id := range m.removedem_tutorial {
  5558. ids = append(ids, id)
  5559. }
  5560. return
  5561. }
  5562. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  5563. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  5564. for id := range m.em_tutorial {
  5565. ids = append(ids, id)
  5566. }
  5567. return
  5568. }
  5569. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  5570. func (m *EmployeeMutation) ResetEmTutorial() {
  5571. m.em_tutorial = nil
  5572. m.clearedem_tutorial = false
  5573. m.removedem_tutorial = nil
  5574. }
  5575. // Where appends a list predicates to the EmployeeMutation builder.
  5576. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  5577. m.predicates = append(m.predicates, ps...)
  5578. }
  5579. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  5580. // users can use type-assertion to append predicates that do not depend on any generated package.
  5581. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  5582. p := make([]predicate.Employee, len(ps))
  5583. for i := range ps {
  5584. p[i] = ps[i]
  5585. }
  5586. m.Where(p...)
  5587. }
  5588. // Op returns the operation name.
  5589. func (m *EmployeeMutation) Op() Op {
  5590. return m.op
  5591. }
  5592. // SetOp allows setting the mutation operation.
  5593. func (m *EmployeeMutation) SetOp(op Op) {
  5594. m.op = op
  5595. }
  5596. // Type returns the node type of this mutation (Employee).
  5597. func (m *EmployeeMutation) Type() string {
  5598. return m.typ
  5599. }
  5600. // Fields returns all fields that were changed during this mutation. Note that in
  5601. // order to get all numeric fields that were incremented/decremented, call
  5602. // AddedFields().
  5603. func (m *EmployeeMutation) Fields() []string {
  5604. fields := make([]string, 0, 18)
  5605. if m.created_at != nil {
  5606. fields = append(fields, employee.FieldCreatedAt)
  5607. }
  5608. if m.updated_at != nil {
  5609. fields = append(fields, employee.FieldUpdatedAt)
  5610. }
  5611. if m.deleted_at != nil {
  5612. fields = append(fields, employee.FieldDeletedAt)
  5613. }
  5614. if m.title != nil {
  5615. fields = append(fields, employee.FieldTitle)
  5616. }
  5617. if m.avatar != nil {
  5618. fields = append(fields, employee.FieldAvatar)
  5619. }
  5620. if m.tags != nil {
  5621. fields = append(fields, employee.FieldTags)
  5622. }
  5623. if m.hire_count != nil {
  5624. fields = append(fields, employee.FieldHireCount)
  5625. }
  5626. if m.service_count != nil {
  5627. fields = append(fields, employee.FieldServiceCount)
  5628. }
  5629. if m.achievement_count != nil {
  5630. fields = append(fields, employee.FieldAchievementCount)
  5631. }
  5632. if m.intro != nil {
  5633. fields = append(fields, employee.FieldIntro)
  5634. }
  5635. if m.estimate != nil {
  5636. fields = append(fields, employee.FieldEstimate)
  5637. }
  5638. if m.skill != nil {
  5639. fields = append(fields, employee.FieldSkill)
  5640. }
  5641. if m.ability_type != nil {
  5642. fields = append(fields, employee.FieldAbilityType)
  5643. }
  5644. if m.scene != nil {
  5645. fields = append(fields, employee.FieldScene)
  5646. }
  5647. if m.switch_in != nil {
  5648. fields = append(fields, employee.FieldSwitchIn)
  5649. }
  5650. if m.video_url != nil {
  5651. fields = append(fields, employee.FieldVideoURL)
  5652. }
  5653. if m.organization_id != nil {
  5654. fields = append(fields, employee.FieldOrganizationID)
  5655. }
  5656. if m.category_id != nil {
  5657. fields = append(fields, employee.FieldCategoryID)
  5658. }
  5659. return fields
  5660. }
  5661. // Field returns the value of a field with the given name. The second boolean
  5662. // return value indicates that this field was not set, or was not defined in the
  5663. // schema.
  5664. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  5665. switch name {
  5666. case employee.FieldCreatedAt:
  5667. return m.CreatedAt()
  5668. case employee.FieldUpdatedAt:
  5669. return m.UpdatedAt()
  5670. case employee.FieldDeletedAt:
  5671. return m.DeletedAt()
  5672. case employee.FieldTitle:
  5673. return m.Title()
  5674. case employee.FieldAvatar:
  5675. return m.Avatar()
  5676. case employee.FieldTags:
  5677. return m.Tags()
  5678. case employee.FieldHireCount:
  5679. return m.HireCount()
  5680. case employee.FieldServiceCount:
  5681. return m.ServiceCount()
  5682. case employee.FieldAchievementCount:
  5683. return m.AchievementCount()
  5684. case employee.FieldIntro:
  5685. return m.Intro()
  5686. case employee.FieldEstimate:
  5687. return m.Estimate()
  5688. case employee.FieldSkill:
  5689. return m.Skill()
  5690. case employee.FieldAbilityType:
  5691. return m.AbilityType()
  5692. case employee.FieldScene:
  5693. return m.Scene()
  5694. case employee.FieldSwitchIn:
  5695. return m.SwitchIn()
  5696. case employee.FieldVideoURL:
  5697. return m.VideoURL()
  5698. case employee.FieldOrganizationID:
  5699. return m.OrganizationID()
  5700. case employee.FieldCategoryID:
  5701. return m.CategoryID()
  5702. }
  5703. return nil, false
  5704. }
  5705. // OldField returns the old value of the field from the database. An error is
  5706. // returned if the mutation operation is not UpdateOne, or the query to the
  5707. // database failed.
  5708. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5709. switch name {
  5710. case employee.FieldCreatedAt:
  5711. return m.OldCreatedAt(ctx)
  5712. case employee.FieldUpdatedAt:
  5713. return m.OldUpdatedAt(ctx)
  5714. case employee.FieldDeletedAt:
  5715. return m.OldDeletedAt(ctx)
  5716. case employee.FieldTitle:
  5717. return m.OldTitle(ctx)
  5718. case employee.FieldAvatar:
  5719. return m.OldAvatar(ctx)
  5720. case employee.FieldTags:
  5721. return m.OldTags(ctx)
  5722. case employee.FieldHireCount:
  5723. return m.OldHireCount(ctx)
  5724. case employee.FieldServiceCount:
  5725. return m.OldServiceCount(ctx)
  5726. case employee.FieldAchievementCount:
  5727. return m.OldAchievementCount(ctx)
  5728. case employee.FieldIntro:
  5729. return m.OldIntro(ctx)
  5730. case employee.FieldEstimate:
  5731. return m.OldEstimate(ctx)
  5732. case employee.FieldSkill:
  5733. return m.OldSkill(ctx)
  5734. case employee.FieldAbilityType:
  5735. return m.OldAbilityType(ctx)
  5736. case employee.FieldScene:
  5737. return m.OldScene(ctx)
  5738. case employee.FieldSwitchIn:
  5739. return m.OldSwitchIn(ctx)
  5740. case employee.FieldVideoURL:
  5741. return m.OldVideoURL(ctx)
  5742. case employee.FieldOrganizationID:
  5743. return m.OldOrganizationID(ctx)
  5744. case employee.FieldCategoryID:
  5745. return m.OldCategoryID(ctx)
  5746. }
  5747. return nil, fmt.Errorf("unknown Employee field %s", name)
  5748. }
  5749. // SetField sets the value of a field with the given name. It returns an error if
  5750. // the field is not defined in the schema, or if the type mismatched the field
  5751. // type.
  5752. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  5753. switch name {
  5754. case employee.FieldCreatedAt:
  5755. v, ok := value.(time.Time)
  5756. if !ok {
  5757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5758. }
  5759. m.SetCreatedAt(v)
  5760. return nil
  5761. case employee.FieldUpdatedAt:
  5762. v, ok := value.(time.Time)
  5763. if !ok {
  5764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5765. }
  5766. m.SetUpdatedAt(v)
  5767. return nil
  5768. case employee.FieldDeletedAt:
  5769. v, ok := value.(time.Time)
  5770. if !ok {
  5771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5772. }
  5773. m.SetDeletedAt(v)
  5774. return nil
  5775. case employee.FieldTitle:
  5776. v, ok := value.(string)
  5777. if !ok {
  5778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5779. }
  5780. m.SetTitle(v)
  5781. return nil
  5782. case employee.FieldAvatar:
  5783. v, ok := value.(string)
  5784. if !ok {
  5785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5786. }
  5787. m.SetAvatar(v)
  5788. return nil
  5789. case employee.FieldTags:
  5790. v, ok := value.(string)
  5791. if !ok {
  5792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5793. }
  5794. m.SetTags(v)
  5795. return nil
  5796. case employee.FieldHireCount:
  5797. v, ok := value.(int)
  5798. if !ok {
  5799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5800. }
  5801. m.SetHireCount(v)
  5802. return nil
  5803. case employee.FieldServiceCount:
  5804. v, ok := value.(int)
  5805. if !ok {
  5806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5807. }
  5808. m.SetServiceCount(v)
  5809. return nil
  5810. case employee.FieldAchievementCount:
  5811. v, ok := value.(int)
  5812. if !ok {
  5813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5814. }
  5815. m.SetAchievementCount(v)
  5816. return nil
  5817. case employee.FieldIntro:
  5818. v, ok := value.(string)
  5819. if !ok {
  5820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5821. }
  5822. m.SetIntro(v)
  5823. return nil
  5824. case employee.FieldEstimate:
  5825. v, ok := value.(string)
  5826. if !ok {
  5827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5828. }
  5829. m.SetEstimate(v)
  5830. return nil
  5831. case employee.FieldSkill:
  5832. v, ok := value.(string)
  5833. if !ok {
  5834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5835. }
  5836. m.SetSkill(v)
  5837. return nil
  5838. case employee.FieldAbilityType:
  5839. v, ok := value.(string)
  5840. if !ok {
  5841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5842. }
  5843. m.SetAbilityType(v)
  5844. return nil
  5845. case employee.FieldScene:
  5846. v, ok := value.(string)
  5847. if !ok {
  5848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5849. }
  5850. m.SetScene(v)
  5851. return nil
  5852. case employee.FieldSwitchIn:
  5853. v, ok := value.(string)
  5854. if !ok {
  5855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5856. }
  5857. m.SetSwitchIn(v)
  5858. return nil
  5859. case employee.FieldVideoURL:
  5860. v, ok := value.(string)
  5861. if !ok {
  5862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5863. }
  5864. m.SetVideoURL(v)
  5865. return nil
  5866. case employee.FieldOrganizationID:
  5867. v, ok := value.(uint64)
  5868. if !ok {
  5869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5870. }
  5871. m.SetOrganizationID(v)
  5872. return nil
  5873. case employee.FieldCategoryID:
  5874. v, ok := value.(uint64)
  5875. if !ok {
  5876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5877. }
  5878. m.SetCategoryID(v)
  5879. return nil
  5880. }
  5881. return fmt.Errorf("unknown Employee field %s", name)
  5882. }
  5883. // AddedFields returns all numeric fields that were incremented/decremented during
  5884. // this mutation.
  5885. func (m *EmployeeMutation) AddedFields() []string {
  5886. var fields []string
  5887. if m.addhire_count != nil {
  5888. fields = append(fields, employee.FieldHireCount)
  5889. }
  5890. if m.addservice_count != nil {
  5891. fields = append(fields, employee.FieldServiceCount)
  5892. }
  5893. if m.addachievement_count != nil {
  5894. fields = append(fields, employee.FieldAchievementCount)
  5895. }
  5896. if m.addorganization_id != nil {
  5897. fields = append(fields, employee.FieldOrganizationID)
  5898. }
  5899. if m.addcategory_id != nil {
  5900. fields = append(fields, employee.FieldCategoryID)
  5901. }
  5902. return fields
  5903. }
  5904. // AddedField returns the numeric value that was incremented/decremented on a field
  5905. // with the given name. The second boolean return value indicates that this field
  5906. // was not set, or was not defined in the schema.
  5907. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  5908. switch name {
  5909. case employee.FieldHireCount:
  5910. return m.AddedHireCount()
  5911. case employee.FieldServiceCount:
  5912. return m.AddedServiceCount()
  5913. case employee.FieldAchievementCount:
  5914. return m.AddedAchievementCount()
  5915. case employee.FieldOrganizationID:
  5916. return m.AddedOrganizationID()
  5917. case employee.FieldCategoryID:
  5918. return m.AddedCategoryID()
  5919. }
  5920. return nil, false
  5921. }
  5922. // AddField adds the value to the field with the given name. It returns an error if
  5923. // the field is not defined in the schema, or if the type mismatched the field
  5924. // type.
  5925. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  5926. switch name {
  5927. case employee.FieldHireCount:
  5928. v, ok := value.(int)
  5929. if !ok {
  5930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5931. }
  5932. m.AddHireCount(v)
  5933. return nil
  5934. case employee.FieldServiceCount:
  5935. v, ok := value.(int)
  5936. if !ok {
  5937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5938. }
  5939. m.AddServiceCount(v)
  5940. return nil
  5941. case employee.FieldAchievementCount:
  5942. v, ok := value.(int)
  5943. if !ok {
  5944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5945. }
  5946. m.AddAchievementCount(v)
  5947. return nil
  5948. case employee.FieldOrganizationID:
  5949. v, ok := value.(int64)
  5950. if !ok {
  5951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5952. }
  5953. m.AddOrganizationID(v)
  5954. return nil
  5955. case employee.FieldCategoryID:
  5956. v, ok := value.(int64)
  5957. if !ok {
  5958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5959. }
  5960. m.AddCategoryID(v)
  5961. return nil
  5962. }
  5963. return fmt.Errorf("unknown Employee numeric field %s", name)
  5964. }
  5965. // ClearedFields returns all nullable fields that were cleared during this
  5966. // mutation.
  5967. func (m *EmployeeMutation) ClearedFields() []string {
  5968. var fields []string
  5969. if m.FieldCleared(employee.FieldDeletedAt) {
  5970. fields = append(fields, employee.FieldDeletedAt)
  5971. }
  5972. return fields
  5973. }
  5974. // FieldCleared returns a boolean indicating if a field with the given name was
  5975. // cleared in this mutation.
  5976. func (m *EmployeeMutation) FieldCleared(name string) bool {
  5977. _, ok := m.clearedFields[name]
  5978. return ok
  5979. }
  5980. // ClearField clears the value of the field with the given name. It returns an
  5981. // error if the field is not defined in the schema.
  5982. func (m *EmployeeMutation) ClearField(name string) error {
  5983. switch name {
  5984. case employee.FieldDeletedAt:
  5985. m.ClearDeletedAt()
  5986. return nil
  5987. }
  5988. return fmt.Errorf("unknown Employee nullable field %s", name)
  5989. }
  5990. // ResetField resets all changes in the mutation for the field with the given name.
  5991. // It returns an error if the field is not defined in the schema.
  5992. func (m *EmployeeMutation) ResetField(name string) error {
  5993. switch name {
  5994. case employee.FieldCreatedAt:
  5995. m.ResetCreatedAt()
  5996. return nil
  5997. case employee.FieldUpdatedAt:
  5998. m.ResetUpdatedAt()
  5999. return nil
  6000. case employee.FieldDeletedAt:
  6001. m.ResetDeletedAt()
  6002. return nil
  6003. case employee.FieldTitle:
  6004. m.ResetTitle()
  6005. return nil
  6006. case employee.FieldAvatar:
  6007. m.ResetAvatar()
  6008. return nil
  6009. case employee.FieldTags:
  6010. m.ResetTags()
  6011. return nil
  6012. case employee.FieldHireCount:
  6013. m.ResetHireCount()
  6014. return nil
  6015. case employee.FieldServiceCount:
  6016. m.ResetServiceCount()
  6017. return nil
  6018. case employee.FieldAchievementCount:
  6019. m.ResetAchievementCount()
  6020. return nil
  6021. case employee.FieldIntro:
  6022. m.ResetIntro()
  6023. return nil
  6024. case employee.FieldEstimate:
  6025. m.ResetEstimate()
  6026. return nil
  6027. case employee.FieldSkill:
  6028. m.ResetSkill()
  6029. return nil
  6030. case employee.FieldAbilityType:
  6031. m.ResetAbilityType()
  6032. return nil
  6033. case employee.FieldScene:
  6034. m.ResetScene()
  6035. return nil
  6036. case employee.FieldSwitchIn:
  6037. m.ResetSwitchIn()
  6038. return nil
  6039. case employee.FieldVideoURL:
  6040. m.ResetVideoURL()
  6041. return nil
  6042. case employee.FieldOrganizationID:
  6043. m.ResetOrganizationID()
  6044. return nil
  6045. case employee.FieldCategoryID:
  6046. m.ResetCategoryID()
  6047. return nil
  6048. }
  6049. return fmt.Errorf("unknown Employee field %s", name)
  6050. }
  6051. // AddedEdges returns all edge names that were set/added in this mutation.
  6052. func (m *EmployeeMutation) AddedEdges() []string {
  6053. edges := make([]string, 0, 2)
  6054. if m.em_work_experiences != nil {
  6055. edges = append(edges, employee.EdgeEmWorkExperiences)
  6056. }
  6057. if m.em_tutorial != nil {
  6058. edges = append(edges, employee.EdgeEmTutorial)
  6059. }
  6060. return edges
  6061. }
  6062. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6063. // name in this mutation.
  6064. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  6065. switch name {
  6066. case employee.EdgeEmWorkExperiences:
  6067. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  6068. for id := range m.em_work_experiences {
  6069. ids = append(ids, id)
  6070. }
  6071. return ids
  6072. case employee.EdgeEmTutorial:
  6073. ids := make([]ent.Value, 0, len(m.em_tutorial))
  6074. for id := range m.em_tutorial {
  6075. ids = append(ids, id)
  6076. }
  6077. return ids
  6078. }
  6079. return nil
  6080. }
  6081. // RemovedEdges returns all edge names that were removed in this mutation.
  6082. func (m *EmployeeMutation) RemovedEdges() []string {
  6083. edges := make([]string, 0, 2)
  6084. if m.removedem_work_experiences != nil {
  6085. edges = append(edges, employee.EdgeEmWorkExperiences)
  6086. }
  6087. if m.removedem_tutorial != nil {
  6088. edges = append(edges, employee.EdgeEmTutorial)
  6089. }
  6090. return edges
  6091. }
  6092. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6093. // the given name in this mutation.
  6094. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  6095. switch name {
  6096. case employee.EdgeEmWorkExperiences:
  6097. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  6098. for id := range m.removedem_work_experiences {
  6099. ids = append(ids, id)
  6100. }
  6101. return ids
  6102. case employee.EdgeEmTutorial:
  6103. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  6104. for id := range m.removedem_tutorial {
  6105. ids = append(ids, id)
  6106. }
  6107. return ids
  6108. }
  6109. return nil
  6110. }
  6111. // ClearedEdges returns all edge names that were cleared in this mutation.
  6112. func (m *EmployeeMutation) ClearedEdges() []string {
  6113. edges := make([]string, 0, 2)
  6114. if m.clearedem_work_experiences {
  6115. edges = append(edges, employee.EdgeEmWorkExperiences)
  6116. }
  6117. if m.clearedem_tutorial {
  6118. edges = append(edges, employee.EdgeEmTutorial)
  6119. }
  6120. return edges
  6121. }
  6122. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6123. // was cleared in this mutation.
  6124. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  6125. switch name {
  6126. case employee.EdgeEmWorkExperiences:
  6127. return m.clearedem_work_experiences
  6128. case employee.EdgeEmTutorial:
  6129. return m.clearedem_tutorial
  6130. }
  6131. return false
  6132. }
  6133. // ClearEdge clears the value of the edge with the given name. It returns an error
  6134. // if that edge is not defined in the schema.
  6135. func (m *EmployeeMutation) ClearEdge(name string) error {
  6136. switch name {
  6137. }
  6138. return fmt.Errorf("unknown Employee unique edge %s", name)
  6139. }
  6140. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6141. // It returns an error if the edge is not defined in the schema.
  6142. func (m *EmployeeMutation) ResetEdge(name string) error {
  6143. switch name {
  6144. case employee.EdgeEmWorkExperiences:
  6145. m.ResetEmWorkExperiences()
  6146. return nil
  6147. case employee.EdgeEmTutorial:
  6148. m.ResetEmTutorial()
  6149. return nil
  6150. }
  6151. return fmt.Errorf("unknown Employee edge %s", name)
  6152. }
  6153. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  6154. type EmployeeConfigMutation struct {
  6155. config
  6156. op Op
  6157. typ string
  6158. id *uint64
  6159. created_at *time.Time
  6160. updated_at *time.Time
  6161. deleted_at *time.Time
  6162. stype *string
  6163. title *string
  6164. photo *string
  6165. organization_id *uint64
  6166. addorganization_id *int64
  6167. clearedFields map[string]struct{}
  6168. done bool
  6169. oldValue func(context.Context) (*EmployeeConfig, error)
  6170. predicates []predicate.EmployeeConfig
  6171. }
  6172. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  6173. // employeeconfigOption allows management of the mutation configuration using functional options.
  6174. type employeeconfigOption func(*EmployeeConfigMutation)
  6175. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  6176. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  6177. m := &EmployeeConfigMutation{
  6178. config: c,
  6179. op: op,
  6180. typ: TypeEmployeeConfig,
  6181. clearedFields: make(map[string]struct{}),
  6182. }
  6183. for _, opt := range opts {
  6184. opt(m)
  6185. }
  6186. return m
  6187. }
  6188. // withEmployeeConfigID sets the ID field of the mutation.
  6189. func withEmployeeConfigID(id uint64) employeeconfigOption {
  6190. return func(m *EmployeeConfigMutation) {
  6191. var (
  6192. err error
  6193. once sync.Once
  6194. value *EmployeeConfig
  6195. )
  6196. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  6197. once.Do(func() {
  6198. if m.done {
  6199. err = errors.New("querying old values post mutation is not allowed")
  6200. } else {
  6201. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  6202. }
  6203. })
  6204. return value, err
  6205. }
  6206. m.id = &id
  6207. }
  6208. }
  6209. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  6210. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  6211. return func(m *EmployeeConfigMutation) {
  6212. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  6213. return node, nil
  6214. }
  6215. m.id = &node.ID
  6216. }
  6217. }
  6218. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6219. // executed in a transaction (ent.Tx), a transactional client is returned.
  6220. func (m EmployeeConfigMutation) Client() *Client {
  6221. client := &Client{config: m.config}
  6222. client.init()
  6223. return client
  6224. }
  6225. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6226. // it returns an error otherwise.
  6227. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  6228. if _, ok := m.driver.(*txDriver); !ok {
  6229. return nil, errors.New("ent: mutation is not running in a transaction")
  6230. }
  6231. tx := &Tx{config: m.config}
  6232. tx.init()
  6233. return tx, nil
  6234. }
  6235. // SetID sets the value of the id field. Note that this
  6236. // operation is only accepted on creation of EmployeeConfig entities.
  6237. func (m *EmployeeConfigMutation) SetID(id uint64) {
  6238. m.id = &id
  6239. }
  6240. // ID returns the ID value in the mutation. Note that the ID is only available
  6241. // if it was provided to the builder or after it was returned from the database.
  6242. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  6243. if m.id == nil {
  6244. return
  6245. }
  6246. return *m.id, true
  6247. }
  6248. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6249. // That means, if the mutation is applied within a transaction with an isolation level such
  6250. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6251. // or updated by the mutation.
  6252. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  6253. switch {
  6254. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6255. id, exists := m.ID()
  6256. if exists {
  6257. return []uint64{id}, nil
  6258. }
  6259. fallthrough
  6260. case m.op.Is(OpUpdate | OpDelete):
  6261. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  6262. default:
  6263. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6264. }
  6265. }
  6266. // SetCreatedAt sets the "created_at" field.
  6267. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  6268. m.created_at = &t
  6269. }
  6270. // CreatedAt returns the value of the "created_at" field in the mutation.
  6271. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  6272. v := m.created_at
  6273. if v == nil {
  6274. return
  6275. }
  6276. return *v, true
  6277. }
  6278. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  6279. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6281. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6282. if !m.op.Is(OpUpdateOne) {
  6283. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6284. }
  6285. if m.id == nil || m.oldValue == nil {
  6286. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6287. }
  6288. oldValue, err := m.oldValue(ctx)
  6289. if err != nil {
  6290. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6291. }
  6292. return oldValue.CreatedAt, nil
  6293. }
  6294. // ResetCreatedAt resets all changes to the "created_at" field.
  6295. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  6296. m.created_at = nil
  6297. }
  6298. // SetUpdatedAt sets the "updated_at" field.
  6299. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  6300. m.updated_at = &t
  6301. }
  6302. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6303. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  6304. v := m.updated_at
  6305. if v == nil {
  6306. return
  6307. }
  6308. return *v, true
  6309. }
  6310. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  6311. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6313. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6314. if !m.op.Is(OpUpdateOne) {
  6315. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6316. }
  6317. if m.id == nil || m.oldValue == nil {
  6318. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6319. }
  6320. oldValue, err := m.oldValue(ctx)
  6321. if err != nil {
  6322. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6323. }
  6324. return oldValue.UpdatedAt, nil
  6325. }
  6326. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6327. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  6328. m.updated_at = nil
  6329. }
  6330. // SetDeletedAt sets the "deleted_at" field.
  6331. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  6332. m.deleted_at = &t
  6333. }
  6334. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6335. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  6336. v := m.deleted_at
  6337. if v == nil {
  6338. return
  6339. }
  6340. return *v, true
  6341. }
  6342. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  6343. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6345. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6346. if !m.op.Is(OpUpdateOne) {
  6347. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6348. }
  6349. if m.id == nil || m.oldValue == nil {
  6350. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6351. }
  6352. oldValue, err := m.oldValue(ctx)
  6353. if err != nil {
  6354. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6355. }
  6356. return oldValue.DeletedAt, nil
  6357. }
  6358. // ClearDeletedAt clears the value of the "deleted_at" field.
  6359. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  6360. m.deleted_at = nil
  6361. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  6362. }
  6363. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6364. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  6365. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  6366. return ok
  6367. }
  6368. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6369. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  6370. m.deleted_at = nil
  6371. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  6372. }
  6373. // SetStype sets the "stype" field.
  6374. func (m *EmployeeConfigMutation) SetStype(s string) {
  6375. m.stype = &s
  6376. }
  6377. // Stype returns the value of the "stype" field in the mutation.
  6378. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  6379. v := m.stype
  6380. if v == nil {
  6381. return
  6382. }
  6383. return *v, true
  6384. }
  6385. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  6386. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6388. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  6389. if !m.op.Is(OpUpdateOne) {
  6390. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  6391. }
  6392. if m.id == nil || m.oldValue == nil {
  6393. return v, errors.New("OldStype requires an ID field in the mutation")
  6394. }
  6395. oldValue, err := m.oldValue(ctx)
  6396. if err != nil {
  6397. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  6398. }
  6399. return oldValue.Stype, nil
  6400. }
  6401. // ResetStype resets all changes to the "stype" field.
  6402. func (m *EmployeeConfigMutation) ResetStype() {
  6403. m.stype = nil
  6404. }
  6405. // SetTitle sets the "title" field.
  6406. func (m *EmployeeConfigMutation) SetTitle(s string) {
  6407. m.title = &s
  6408. }
  6409. // Title returns the value of the "title" field in the mutation.
  6410. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  6411. v := m.title
  6412. if v == nil {
  6413. return
  6414. }
  6415. return *v, true
  6416. }
  6417. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  6418. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6420. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  6421. if !m.op.Is(OpUpdateOne) {
  6422. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  6423. }
  6424. if m.id == nil || m.oldValue == nil {
  6425. return v, errors.New("OldTitle requires an ID field in the mutation")
  6426. }
  6427. oldValue, err := m.oldValue(ctx)
  6428. if err != nil {
  6429. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  6430. }
  6431. return oldValue.Title, nil
  6432. }
  6433. // ResetTitle resets all changes to the "title" field.
  6434. func (m *EmployeeConfigMutation) ResetTitle() {
  6435. m.title = nil
  6436. }
  6437. // SetPhoto sets the "photo" field.
  6438. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  6439. m.photo = &s
  6440. }
  6441. // Photo returns the value of the "photo" field in the mutation.
  6442. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  6443. v := m.photo
  6444. if v == nil {
  6445. return
  6446. }
  6447. return *v, true
  6448. }
  6449. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  6450. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6452. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  6453. if !m.op.Is(OpUpdateOne) {
  6454. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  6455. }
  6456. if m.id == nil || m.oldValue == nil {
  6457. return v, errors.New("OldPhoto requires an ID field in the mutation")
  6458. }
  6459. oldValue, err := m.oldValue(ctx)
  6460. if err != nil {
  6461. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  6462. }
  6463. return oldValue.Photo, nil
  6464. }
  6465. // ResetPhoto resets all changes to the "photo" field.
  6466. func (m *EmployeeConfigMutation) ResetPhoto() {
  6467. m.photo = nil
  6468. }
  6469. // SetOrganizationID sets the "organization_id" field.
  6470. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  6471. m.organization_id = &u
  6472. m.addorganization_id = nil
  6473. }
  6474. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6475. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  6476. v := m.organization_id
  6477. if v == nil {
  6478. return
  6479. }
  6480. return *v, true
  6481. }
  6482. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  6483. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6485. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6486. if !m.op.Is(OpUpdateOne) {
  6487. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6488. }
  6489. if m.id == nil || m.oldValue == nil {
  6490. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6491. }
  6492. oldValue, err := m.oldValue(ctx)
  6493. if err != nil {
  6494. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6495. }
  6496. return oldValue.OrganizationID, nil
  6497. }
  6498. // AddOrganizationID adds u to the "organization_id" field.
  6499. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  6500. if m.addorganization_id != nil {
  6501. *m.addorganization_id += u
  6502. } else {
  6503. m.addorganization_id = &u
  6504. }
  6505. }
  6506. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6507. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  6508. v := m.addorganization_id
  6509. if v == nil {
  6510. return
  6511. }
  6512. return *v, true
  6513. }
  6514. // ClearOrganizationID clears the value of the "organization_id" field.
  6515. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  6516. m.organization_id = nil
  6517. m.addorganization_id = nil
  6518. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  6519. }
  6520. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  6521. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  6522. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  6523. return ok
  6524. }
  6525. // ResetOrganizationID resets all changes to the "organization_id" field.
  6526. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  6527. m.organization_id = nil
  6528. m.addorganization_id = nil
  6529. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  6530. }
  6531. // Where appends a list predicates to the EmployeeConfigMutation builder.
  6532. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  6533. m.predicates = append(m.predicates, ps...)
  6534. }
  6535. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  6536. // users can use type-assertion to append predicates that do not depend on any generated package.
  6537. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  6538. p := make([]predicate.EmployeeConfig, len(ps))
  6539. for i := range ps {
  6540. p[i] = ps[i]
  6541. }
  6542. m.Where(p...)
  6543. }
  6544. // Op returns the operation name.
  6545. func (m *EmployeeConfigMutation) Op() Op {
  6546. return m.op
  6547. }
  6548. // SetOp allows setting the mutation operation.
  6549. func (m *EmployeeConfigMutation) SetOp(op Op) {
  6550. m.op = op
  6551. }
  6552. // Type returns the node type of this mutation (EmployeeConfig).
  6553. func (m *EmployeeConfigMutation) Type() string {
  6554. return m.typ
  6555. }
  6556. // Fields returns all fields that were changed during this mutation. Note that in
  6557. // order to get all numeric fields that were incremented/decremented, call
  6558. // AddedFields().
  6559. func (m *EmployeeConfigMutation) Fields() []string {
  6560. fields := make([]string, 0, 7)
  6561. if m.created_at != nil {
  6562. fields = append(fields, employeeconfig.FieldCreatedAt)
  6563. }
  6564. if m.updated_at != nil {
  6565. fields = append(fields, employeeconfig.FieldUpdatedAt)
  6566. }
  6567. if m.deleted_at != nil {
  6568. fields = append(fields, employeeconfig.FieldDeletedAt)
  6569. }
  6570. if m.stype != nil {
  6571. fields = append(fields, employeeconfig.FieldStype)
  6572. }
  6573. if m.title != nil {
  6574. fields = append(fields, employeeconfig.FieldTitle)
  6575. }
  6576. if m.photo != nil {
  6577. fields = append(fields, employeeconfig.FieldPhoto)
  6578. }
  6579. if m.organization_id != nil {
  6580. fields = append(fields, employeeconfig.FieldOrganizationID)
  6581. }
  6582. return fields
  6583. }
  6584. // Field returns the value of a field with the given name. The second boolean
  6585. // return value indicates that this field was not set, or was not defined in the
  6586. // schema.
  6587. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  6588. switch name {
  6589. case employeeconfig.FieldCreatedAt:
  6590. return m.CreatedAt()
  6591. case employeeconfig.FieldUpdatedAt:
  6592. return m.UpdatedAt()
  6593. case employeeconfig.FieldDeletedAt:
  6594. return m.DeletedAt()
  6595. case employeeconfig.FieldStype:
  6596. return m.Stype()
  6597. case employeeconfig.FieldTitle:
  6598. return m.Title()
  6599. case employeeconfig.FieldPhoto:
  6600. return m.Photo()
  6601. case employeeconfig.FieldOrganizationID:
  6602. return m.OrganizationID()
  6603. }
  6604. return nil, false
  6605. }
  6606. // OldField returns the old value of the field from the database. An error is
  6607. // returned if the mutation operation is not UpdateOne, or the query to the
  6608. // database failed.
  6609. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6610. switch name {
  6611. case employeeconfig.FieldCreatedAt:
  6612. return m.OldCreatedAt(ctx)
  6613. case employeeconfig.FieldUpdatedAt:
  6614. return m.OldUpdatedAt(ctx)
  6615. case employeeconfig.FieldDeletedAt:
  6616. return m.OldDeletedAt(ctx)
  6617. case employeeconfig.FieldStype:
  6618. return m.OldStype(ctx)
  6619. case employeeconfig.FieldTitle:
  6620. return m.OldTitle(ctx)
  6621. case employeeconfig.FieldPhoto:
  6622. return m.OldPhoto(ctx)
  6623. case employeeconfig.FieldOrganizationID:
  6624. return m.OldOrganizationID(ctx)
  6625. }
  6626. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  6627. }
  6628. // SetField sets the value of a field with the given name. It returns an error if
  6629. // the field is not defined in the schema, or if the type mismatched the field
  6630. // type.
  6631. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  6632. switch name {
  6633. case employeeconfig.FieldCreatedAt:
  6634. v, ok := value.(time.Time)
  6635. if !ok {
  6636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6637. }
  6638. m.SetCreatedAt(v)
  6639. return nil
  6640. case employeeconfig.FieldUpdatedAt:
  6641. v, ok := value.(time.Time)
  6642. if !ok {
  6643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6644. }
  6645. m.SetUpdatedAt(v)
  6646. return nil
  6647. case employeeconfig.FieldDeletedAt:
  6648. v, ok := value.(time.Time)
  6649. if !ok {
  6650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6651. }
  6652. m.SetDeletedAt(v)
  6653. return nil
  6654. case employeeconfig.FieldStype:
  6655. v, ok := value.(string)
  6656. if !ok {
  6657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6658. }
  6659. m.SetStype(v)
  6660. return nil
  6661. case employeeconfig.FieldTitle:
  6662. v, ok := value.(string)
  6663. if !ok {
  6664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6665. }
  6666. m.SetTitle(v)
  6667. return nil
  6668. case employeeconfig.FieldPhoto:
  6669. v, ok := value.(string)
  6670. if !ok {
  6671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6672. }
  6673. m.SetPhoto(v)
  6674. return nil
  6675. case employeeconfig.FieldOrganizationID:
  6676. v, ok := value.(uint64)
  6677. if !ok {
  6678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6679. }
  6680. m.SetOrganizationID(v)
  6681. return nil
  6682. }
  6683. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  6684. }
  6685. // AddedFields returns all numeric fields that were incremented/decremented during
  6686. // this mutation.
  6687. func (m *EmployeeConfigMutation) AddedFields() []string {
  6688. var fields []string
  6689. if m.addorganization_id != nil {
  6690. fields = append(fields, employeeconfig.FieldOrganizationID)
  6691. }
  6692. return fields
  6693. }
  6694. // AddedField returns the numeric value that was incremented/decremented on a field
  6695. // with the given name. The second boolean return value indicates that this field
  6696. // was not set, or was not defined in the schema.
  6697. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  6698. switch name {
  6699. case employeeconfig.FieldOrganizationID:
  6700. return m.AddedOrganizationID()
  6701. }
  6702. return nil, false
  6703. }
  6704. // AddField adds the value to the field with the given name. It returns an error if
  6705. // the field is not defined in the schema, or if the type mismatched the field
  6706. // type.
  6707. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  6708. switch name {
  6709. case employeeconfig.FieldOrganizationID:
  6710. v, ok := value.(int64)
  6711. if !ok {
  6712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6713. }
  6714. m.AddOrganizationID(v)
  6715. return nil
  6716. }
  6717. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  6718. }
  6719. // ClearedFields returns all nullable fields that were cleared during this
  6720. // mutation.
  6721. func (m *EmployeeConfigMutation) ClearedFields() []string {
  6722. var fields []string
  6723. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  6724. fields = append(fields, employeeconfig.FieldDeletedAt)
  6725. }
  6726. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  6727. fields = append(fields, employeeconfig.FieldOrganizationID)
  6728. }
  6729. return fields
  6730. }
  6731. // FieldCleared returns a boolean indicating if a field with the given name was
  6732. // cleared in this mutation.
  6733. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  6734. _, ok := m.clearedFields[name]
  6735. return ok
  6736. }
  6737. // ClearField clears the value of the field with the given name. It returns an
  6738. // error if the field is not defined in the schema.
  6739. func (m *EmployeeConfigMutation) ClearField(name string) error {
  6740. switch name {
  6741. case employeeconfig.FieldDeletedAt:
  6742. m.ClearDeletedAt()
  6743. return nil
  6744. case employeeconfig.FieldOrganizationID:
  6745. m.ClearOrganizationID()
  6746. return nil
  6747. }
  6748. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  6749. }
  6750. // ResetField resets all changes in the mutation for the field with the given name.
  6751. // It returns an error if the field is not defined in the schema.
  6752. func (m *EmployeeConfigMutation) ResetField(name string) error {
  6753. switch name {
  6754. case employeeconfig.FieldCreatedAt:
  6755. m.ResetCreatedAt()
  6756. return nil
  6757. case employeeconfig.FieldUpdatedAt:
  6758. m.ResetUpdatedAt()
  6759. return nil
  6760. case employeeconfig.FieldDeletedAt:
  6761. m.ResetDeletedAt()
  6762. return nil
  6763. case employeeconfig.FieldStype:
  6764. m.ResetStype()
  6765. return nil
  6766. case employeeconfig.FieldTitle:
  6767. m.ResetTitle()
  6768. return nil
  6769. case employeeconfig.FieldPhoto:
  6770. m.ResetPhoto()
  6771. return nil
  6772. case employeeconfig.FieldOrganizationID:
  6773. m.ResetOrganizationID()
  6774. return nil
  6775. }
  6776. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  6777. }
  6778. // AddedEdges returns all edge names that were set/added in this mutation.
  6779. func (m *EmployeeConfigMutation) AddedEdges() []string {
  6780. edges := make([]string, 0, 0)
  6781. return edges
  6782. }
  6783. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6784. // name in this mutation.
  6785. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  6786. return nil
  6787. }
  6788. // RemovedEdges returns all edge names that were removed in this mutation.
  6789. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  6790. edges := make([]string, 0, 0)
  6791. return edges
  6792. }
  6793. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6794. // the given name in this mutation.
  6795. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  6796. return nil
  6797. }
  6798. // ClearedEdges returns all edge names that were cleared in this mutation.
  6799. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  6800. edges := make([]string, 0, 0)
  6801. return edges
  6802. }
  6803. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6804. // was cleared in this mutation.
  6805. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  6806. return false
  6807. }
  6808. // ClearEdge clears the value of the edge with the given name. It returns an error
  6809. // if that edge is not defined in the schema.
  6810. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  6811. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  6812. }
  6813. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6814. // It returns an error if the edge is not defined in the schema.
  6815. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  6816. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  6817. }
  6818. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  6819. type LabelMutation struct {
  6820. config
  6821. op Op
  6822. typ string
  6823. id *uint64
  6824. created_at *time.Time
  6825. updated_at *time.Time
  6826. status *uint8
  6827. addstatus *int8
  6828. _type *int
  6829. add_type *int
  6830. name *string
  6831. from *int
  6832. addfrom *int
  6833. mode *int
  6834. addmode *int
  6835. conditions *string
  6836. organization_id *uint64
  6837. addorganization_id *int64
  6838. clearedFields map[string]struct{}
  6839. label_relationships map[uint64]struct{}
  6840. removedlabel_relationships map[uint64]struct{}
  6841. clearedlabel_relationships bool
  6842. done bool
  6843. oldValue func(context.Context) (*Label, error)
  6844. predicates []predicate.Label
  6845. }
  6846. var _ ent.Mutation = (*LabelMutation)(nil)
  6847. // labelOption allows management of the mutation configuration using functional options.
  6848. type labelOption func(*LabelMutation)
  6849. // newLabelMutation creates new mutation for the Label entity.
  6850. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  6851. m := &LabelMutation{
  6852. config: c,
  6853. op: op,
  6854. typ: TypeLabel,
  6855. clearedFields: make(map[string]struct{}),
  6856. }
  6857. for _, opt := range opts {
  6858. opt(m)
  6859. }
  6860. return m
  6861. }
  6862. // withLabelID sets the ID field of the mutation.
  6863. func withLabelID(id uint64) labelOption {
  6864. return func(m *LabelMutation) {
  6865. var (
  6866. err error
  6867. once sync.Once
  6868. value *Label
  6869. )
  6870. m.oldValue = func(ctx context.Context) (*Label, error) {
  6871. once.Do(func() {
  6872. if m.done {
  6873. err = errors.New("querying old values post mutation is not allowed")
  6874. } else {
  6875. value, err = m.Client().Label.Get(ctx, id)
  6876. }
  6877. })
  6878. return value, err
  6879. }
  6880. m.id = &id
  6881. }
  6882. }
  6883. // withLabel sets the old Label of the mutation.
  6884. func withLabel(node *Label) labelOption {
  6885. return func(m *LabelMutation) {
  6886. m.oldValue = func(context.Context) (*Label, error) {
  6887. return node, nil
  6888. }
  6889. m.id = &node.ID
  6890. }
  6891. }
  6892. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6893. // executed in a transaction (ent.Tx), a transactional client is returned.
  6894. func (m LabelMutation) Client() *Client {
  6895. client := &Client{config: m.config}
  6896. client.init()
  6897. return client
  6898. }
  6899. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6900. // it returns an error otherwise.
  6901. func (m LabelMutation) Tx() (*Tx, error) {
  6902. if _, ok := m.driver.(*txDriver); !ok {
  6903. return nil, errors.New("ent: mutation is not running in a transaction")
  6904. }
  6905. tx := &Tx{config: m.config}
  6906. tx.init()
  6907. return tx, nil
  6908. }
  6909. // SetID sets the value of the id field. Note that this
  6910. // operation is only accepted on creation of Label entities.
  6911. func (m *LabelMutation) SetID(id uint64) {
  6912. m.id = &id
  6913. }
  6914. // ID returns the ID value in the mutation. Note that the ID is only available
  6915. // if it was provided to the builder or after it was returned from the database.
  6916. func (m *LabelMutation) ID() (id uint64, exists bool) {
  6917. if m.id == nil {
  6918. return
  6919. }
  6920. return *m.id, true
  6921. }
  6922. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6923. // That means, if the mutation is applied within a transaction with an isolation level such
  6924. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6925. // or updated by the mutation.
  6926. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  6927. switch {
  6928. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6929. id, exists := m.ID()
  6930. if exists {
  6931. return []uint64{id}, nil
  6932. }
  6933. fallthrough
  6934. case m.op.Is(OpUpdate | OpDelete):
  6935. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  6936. default:
  6937. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6938. }
  6939. }
  6940. // SetCreatedAt sets the "created_at" field.
  6941. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  6942. m.created_at = &t
  6943. }
  6944. // CreatedAt returns the value of the "created_at" field in the mutation.
  6945. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  6946. v := m.created_at
  6947. if v == nil {
  6948. return
  6949. }
  6950. return *v, true
  6951. }
  6952. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  6953. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  6954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6955. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6956. if !m.op.Is(OpUpdateOne) {
  6957. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6958. }
  6959. if m.id == nil || m.oldValue == nil {
  6960. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6961. }
  6962. oldValue, err := m.oldValue(ctx)
  6963. if err != nil {
  6964. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6965. }
  6966. return oldValue.CreatedAt, nil
  6967. }
  6968. // ResetCreatedAt resets all changes to the "created_at" field.
  6969. func (m *LabelMutation) ResetCreatedAt() {
  6970. m.created_at = nil
  6971. }
  6972. // SetUpdatedAt sets the "updated_at" field.
  6973. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  6974. m.updated_at = &t
  6975. }
  6976. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6977. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  6978. v := m.updated_at
  6979. if v == nil {
  6980. return
  6981. }
  6982. return *v, true
  6983. }
  6984. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  6985. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  6986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6987. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6988. if !m.op.Is(OpUpdateOne) {
  6989. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6990. }
  6991. if m.id == nil || m.oldValue == nil {
  6992. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6993. }
  6994. oldValue, err := m.oldValue(ctx)
  6995. if err != nil {
  6996. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6997. }
  6998. return oldValue.UpdatedAt, nil
  6999. }
  7000. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7001. func (m *LabelMutation) ResetUpdatedAt() {
  7002. m.updated_at = nil
  7003. }
  7004. // SetStatus sets the "status" field.
  7005. func (m *LabelMutation) SetStatus(u uint8) {
  7006. m.status = &u
  7007. m.addstatus = nil
  7008. }
  7009. // Status returns the value of the "status" field in the mutation.
  7010. func (m *LabelMutation) Status() (r uint8, exists bool) {
  7011. v := m.status
  7012. if v == nil {
  7013. return
  7014. }
  7015. return *v, true
  7016. }
  7017. // OldStatus returns the old "status" field's value of the Label entity.
  7018. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7020. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7021. if !m.op.Is(OpUpdateOne) {
  7022. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7023. }
  7024. if m.id == nil || m.oldValue == nil {
  7025. return v, errors.New("OldStatus requires an ID field in the mutation")
  7026. }
  7027. oldValue, err := m.oldValue(ctx)
  7028. if err != nil {
  7029. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7030. }
  7031. return oldValue.Status, nil
  7032. }
  7033. // AddStatus adds u to the "status" field.
  7034. func (m *LabelMutation) AddStatus(u int8) {
  7035. if m.addstatus != nil {
  7036. *m.addstatus += u
  7037. } else {
  7038. m.addstatus = &u
  7039. }
  7040. }
  7041. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7042. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  7043. v := m.addstatus
  7044. if v == nil {
  7045. return
  7046. }
  7047. return *v, true
  7048. }
  7049. // ClearStatus clears the value of the "status" field.
  7050. func (m *LabelMutation) ClearStatus() {
  7051. m.status = nil
  7052. m.addstatus = nil
  7053. m.clearedFields[label.FieldStatus] = struct{}{}
  7054. }
  7055. // StatusCleared returns if the "status" field was cleared in this mutation.
  7056. func (m *LabelMutation) StatusCleared() bool {
  7057. _, ok := m.clearedFields[label.FieldStatus]
  7058. return ok
  7059. }
  7060. // ResetStatus resets all changes to the "status" field.
  7061. func (m *LabelMutation) ResetStatus() {
  7062. m.status = nil
  7063. m.addstatus = nil
  7064. delete(m.clearedFields, label.FieldStatus)
  7065. }
  7066. // SetType sets the "type" field.
  7067. func (m *LabelMutation) SetType(i int) {
  7068. m._type = &i
  7069. m.add_type = nil
  7070. }
  7071. // GetType returns the value of the "type" field in the mutation.
  7072. func (m *LabelMutation) GetType() (r int, exists bool) {
  7073. v := m._type
  7074. if v == nil {
  7075. return
  7076. }
  7077. return *v, true
  7078. }
  7079. // OldType returns the old "type" field's value of the Label entity.
  7080. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7082. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  7083. if !m.op.Is(OpUpdateOne) {
  7084. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7085. }
  7086. if m.id == nil || m.oldValue == nil {
  7087. return v, errors.New("OldType requires an ID field in the mutation")
  7088. }
  7089. oldValue, err := m.oldValue(ctx)
  7090. if err != nil {
  7091. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7092. }
  7093. return oldValue.Type, nil
  7094. }
  7095. // AddType adds i to the "type" field.
  7096. func (m *LabelMutation) AddType(i int) {
  7097. if m.add_type != nil {
  7098. *m.add_type += i
  7099. } else {
  7100. m.add_type = &i
  7101. }
  7102. }
  7103. // AddedType returns the value that was added to the "type" field in this mutation.
  7104. func (m *LabelMutation) AddedType() (r int, exists bool) {
  7105. v := m.add_type
  7106. if v == nil {
  7107. return
  7108. }
  7109. return *v, true
  7110. }
  7111. // ResetType resets all changes to the "type" field.
  7112. func (m *LabelMutation) ResetType() {
  7113. m._type = nil
  7114. m.add_type = nil
  7115. }
  7116. // SetName sets the "name" field.
  7117. func (m *LabelMutation) SetName(s string) {
  7118. m.name = &s
  7119. }
  7120. // Name returns the value of the "name" field in the mutation.
  7121. func (m *LabelMutation) Name() (r string, exists bool) {
  7122. v := m.name
  7123. if v == nil {
  7124. return
  7125. }
  7126. return *v, true
  7127. }
  7128. // OldName returns the old "name" field's value of the Label entity.
  7129. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7130. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7131. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  7132. if !m.op.Is(OpUpdateOne) {
  7133. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7134. }
  7135. if m.id == nil || m.oldValue == nil {
  7136. return v, errors.New("OldName requires an ID field in the mutation")
  7137. }
  7138. oldValue, err := m.oldValue(ctx)
  7139. if err != nil {
  7140. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7141. }
  7142. return oldValue.Name, nil
  7143. }
  7144. // ResetName resets all changes to the "name" field.
  7145. func (m *LabelMutation) ResetName() {
  7146. m.name = nil
  7147. }
  7148. // SetFrom sets the "from" field.
  7149. func (m *LabelMutation) SetFrom(i int) {
  7150. m.from = &i
  7151. m.addfrom = nil
  7152. }
  7153. // From returns the value of the "from" field in the mutation.
  7154. func (m *LabelMutation) From() (r int, exists bool) {
  7155. v := m.from
  7156. if v == nil {
  7157. return
  7158. }
  7159. return *v, true
  7160. }
  7161. // OldFrom returns the old "from" field's value of the Label entity.
  7162. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7163. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7164. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  7165. if !m.op.Is(OpUpdateOne) {
  7166. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  7167. }
  7168. if m.id == nil || m.oldValue == nil {
  7169. return v, errors.New("OldFrom requires an ID field in the mutation")
  7170. }
  7171. oldValue, err := m.oldValue(ctx)
  7172. if err != nil {
  7173. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  7174. }
  7175. return oldValue.From, nil
  7176. }
  7177. // AddFrom adds i to the "from" field.
  7178. func (m *LabelMutation) AddFrom(i int) {
  7179. if m.addfrom != nil {
  7180. *m.addfrom += i
  7181. } else {
  7182. m.addfrom = &i
  7183. }
  7184. }
  7185. // AddedFrom returns the value that was added to the "from" field in this mutation.
  7186. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  7187. v := m.addfrom
  7188. if v == nil {
  7189. return
  7190. }
  7191. return *v, true
  7192. }
  7193. // ResetFrom resets all changes to the "from" field.
  7194. func (m *LabelMutation) ResetFrom() {
  7195. m.from = nil
  7196. m.addfrom = nil
  7197. }
  7198. // SetMode sets the "mode" field.
  7199. func (m *LabelMutation) SetMode(i int) {
  7200. m.mode = &i
  7201. m.addmode = nil
  7202. }
  7203. // Mode returns the value of the "mode" field in the mutation.
  7204. func (m *LabelMutation) Mode() (r int, exists bool) {
  7205. v := m.mode
  7206. if v == nil {
  7207. return
  7208. }
  7209. return *v, true
  7210. }
  7211. // OldMode returns the old "mode" field's value of the Label entity.
  7212. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7214. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  7215. if !m.op.Is(OpUpdateOne) {
  7216. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  7217. }
  7218. if m.id == nil || m.oldValue == nil {
  7219. return v, errors.New("OldMode requires an ID field in the mutation")
  7220. }
  7221. oldValue, err := m.oldValue(ctx)
  7222. if err != nil {
  7223. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  7224. }
  7225. return oldValue.Mode, nil
  7226. }
  7227. // AddMode adds i to the "mode" field.
  7228. func (m *LabelMutation) AddMode(i int) {
  7229. if m.addmode != nil {
  7230. *m.addmode += i
  7231. } else {
  7232. m.addmode = &i
  7233. }
  7234. }
  7235. // AddedMode returns the value that was added to the "mode" field in this mutation.
  7236. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  7237. v := m.addmode
  7238. if v == nil {
  7239. return
  7240. }
  7241. return *v, true
  7242. }
  7243. // ResetMode resets all changes to the "mode" field.
  7244. func (m *LabelMutation) ResetMode() {
  7245. m.mode = nil
  7246. m.addmode = nil
  7247. }
  7248. // SetConditions sets the "conditions" field.
  7249. func (m *LabelMutation) SetConditions(s string) {
  7250. m.conditions = &s
  7251. }
  7252. // Conditions returns the value of the "conditions" field in the mutation.
  7253. func (m *LabelMutation) Conditions() (r string, exists bool) {
  7254. v := m.conditions
  7255. if v == nil {
  7256. return
  7257. }
  7258. return *v, true
  7259. }
  7260. // OldConditions returns the old "conditions" field's value of the Label entity.
  7261. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7263. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  7264. if !m.op.Is(OpUpdateOne) {
  7265. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  7266. }
  7267. if m.id == nil || m.oldValue == nil {
  7268. return v, errors.New("OldConditions requires an ID field in the mutation")
  7269. }
  7270. oldValue, err := m.oldValue(ctx)
  7271. if err != nil {
  7272. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  7273. }
  7274. return oldValue.Conditions, nil
  7275. }
  7276. // ClearConditions clears the value of the "conditions" field.
  7277. func (m *LabelMutation) ClearConditions() {
  7278. m.conditions = nil
  7279. m.clearedFields[label.FieldConditions] = struct{}{}
  7280. }
  7281. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  7282. func (m *LabelMutation) ConditionsCleared() bool {
  7283. _, ok := m.clearedFields[label.FieldConditions]
  7284. return ok
  7285. }
  7286. // ResetConditions resets all changes to the "conditions" field.
  7287. func (m *LabelMutation) ResetConditions() {
  7288. m.conditions = nil
  7289. delete(m.clearedFields, label.FieldConditions)
  7290. }
  7291. // SetOrganizationID sets the "organization_id" field.
  7292. func (m *LabelMutation) SetOrganizationID(u uint64) {
  7293. m.organization_id = &u
  7294. m.addorganization_id = nil
  7295. }
  7296. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7297. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  7298. v := m.organization_id
  7299. if v == nil {
  7300. return
  7301. }
  7302. return *v, true
  7303. }
  7304. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  7305. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7307. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7308. if !m.op.Is(OpUpdateOne) {
  7309. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7310. }
  7311. if m.id == nil || m.oldValue == nil {
  7312. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7313. }
  7314. oldValue, err := m.oldValue(ctx)
  7315. if err != nil {
  7316. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7317. }
  7318. return oldValue.OrganizationID, nil
  7319. }
  7320. // AddOrganizationID adds u to the "organization_id" field.
  7321. func (m *LabelMutation) AddOrganizationID(u int64) {
  7322. if m.addorganization_id != nil {
  7323. *m.addorganization_id += u
  7324. } else {
  7325. m.addorganization_id = &u
  7326. }
  7327. }
  7328. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7329. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  7330. v := m.addorganization_id
  7331. if v == nil {
  7332. return
  7333. }
  7334. return *v, true
  7335. }
  7336. // ClearOrganizationID clears the value of the "organization_id" field.
  7337. func (m *LabelMutation) ClearOrganizationID() {
  7338. m.organization_id = nil
  7339. m.addorganization_id = nil
  7340. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  7341. }
  7342. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  7343. func (m *LabelMutation) OrganizationIDCleared() bool {
  7344. _, ok := m.clearedFields[label.FieldOrganizationID]
  7345. return ok
  7346. }
  7347. // ResetOrganizationID resets all changes to the "organization_id" field.
  7348. func (m *LabelMutation) ResetOrganizationID() {
  7349. m.organization_id = nil
  7350. m.addorganization_id = nil
  7351. delete(m.clearedFields, label.FieldOrganizationID)
  7352. }
  7353. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  7354. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  7355. if m.label_relationships == nil {
  7356. m.label_relationships = make(map[uint64]struct{})
  7357. }
  7358. for i := range ids {
  7359. m.label_relationships[ids[i]] = struct{}{}
  7360. }
  7361. }
  7362. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  7363. func (m *LabelMutation) ClearLabelRelationships() {
  7364. m.clearedlabel_relationships = true
  7365. }
  7366. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  7367. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  7368. return m.clearedlabel_relationships
  7369. }
  7370. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  7371. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  7372. if m.removedlabel_relationships == nil {
  7373. m.removedlabel_relationships = make(map[uint64]struct{})
  7374. }
  7375. for i := range ids {
  7376. delete(m.label_relationships, ids[i])
  7377. m.removedlabel_relationships[ids[i]] = struct{}{}
  7378. }
  7379. }
  7380. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  7381. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  7382. for id := range m.removedlabel_relationships {
  7383. ids = append(ids, id)
  7384. }
  7385. return
  7386. }
  7387. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  7388. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  7389. for id := range m.label_relationships {
  7390. ids = append(ids, id)
  7391. }
  7392. return
  7393. }
  7394. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  7395. func (m *LabelMutation) ResetLabelRelationships() {
  7396. m.label_relationships = nil
  7397. m.clearedlabel_relationships = false
  7398. m.removedlabel_relationships = nil
  7399. }
  7400. // Where appends a list predicates to the LabelMutation builder.
  7401. func (m *LabelMutation) Where(ps ...predicate.Label) {
  7402. m.predicates = append(m.predicates, ps...)
  7403. }
  7404. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  7405. // users can use type-assertion to append predicates that do not depend on any generated package.
  7406. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  7407. p := make([]predicate.Label, len(ps))
  7408. for i := range ps {
  7409. p[i] = ps[i]
  7410. }
  7411. m.Where(p...)
  7412. }
  7413. // Op returns the operation name.
  7414. func (m *LabelMutation) Op() Op {
  7415. return m.op
  7416. }
  7417. // SetOp allows setting the mutation operation.
  7418. func (m *LabelMutation) SetOp(op Op) {
  7419. m.op = op
  7420. }
  7421. // Type returns the node type of this mutation (Label).
  7422. func (m *LabelMutation) Type() string {
  7423. return m.typ
  7424. }
  7425. // Fields returns all fields that were changed during this mutation. Note that in
  7426. // order to get all numeric fields that were incremented/decremented, call
  7427. // AddedFields().
  7428. func (m *LabelMutation) Fields() []string {
  7429. fields := make([]string, 0, 9)
  7430. if m.created_at != nil {
  7431. fields = append(fields, label.FieldCreatedAt)
  7432. }
  7433. if m.updated_at != nil {
  7434. fields = append(fields, label.FieldUpdatedAt)
  7435. }
  7436. if m.status != nil {
  7437. fields = append(fields, label.FieldStatus)
  7438. }
  7439. if m._type != nil {
  7440. fields = append(fields, label.FieldType)
  7441. }
  7442. if m.name != nil {
  7443. fields = append(fields, label.FieldName)
  7444. }
  7445. if m.from != nil {
  7446. fields = append(fields, label.FieldFrom)
  7447. }
  7448. if m.mode != nil {
  7449. fields = append(fields, label.FieldMode)
  7450. }
  7451. if m.conditions != nil {
  7452. fields = append(fields, label.FieldConditions)
  7453. }
  7454. if m.organization_id != nil {
  7455. fields = append(fields, label.FieldOrganizationID)
  7456. }
  7457. return fields
  7458. }
  7459. // Field returns the value of a field with the given name. The second boolean
  7460. // return value indicates that this field was not set, or was not defined in the
  7461. // schema.
  7462. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  7463. switch name {
  7464. case label.FieldCreatedAt:
  7465. return m.CreatedAt()
  7466. case label.FieldUpdatedAt:
  7467. return m.UpdatedAt()
  7468. case label.FieldStatus:
  7469. return m.Status()
  7470. case label.FieldType:
  7471. return m.GetType()
  7472. case label.FieldName:
  7473. return m.Name()
  7474. case label.FieldFrom:
  7475. return m.From()
  7476. case label.FieldMode:
  7477. return m.Mode()
  7478. case label.FieldConditions:
  7479. return m.Conditions()
  7480. case label.FieldOrganizationID:
  7481. return m.OrganizationID()
  7482. }
  7483. return nil, false
  7484. }
  7485. // OldField returns the old value of the field from the database. An error is
  7486. // returned if the mutation operation is not UpdateOne, or the query to the
  7487. // database failed.
  7488. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7489. switch name {
  7490. case label.FieldCreatedAt:
  7491. return m.OldCreatedAt(ctx)
  7492. case label.FieldUpdatedAt:
  7493. return m.OldUpdatedAt(ctx)
  7494. case label.FieldStatus:
  7495. return m.OldStatus(ctx)
  7496. case label.FieldType:
  7497. return m.OldType(ctx)
  7498. case label.FieldName:
  7499. return m.OldName(ctx)
  7500. case label.FieldFrom:
  7501. return m.OldFrom(ctx)
  7502. case label.FieldMode:
  7503. return m.OldMode(ctx)
  7504. case label.FieldConditions:
  7505. return m.OldConditions(ctx)
  7506. case label.FieldOrganizationID:
  7507. return m.OldOrganizationID(ctx)
  7508. }
  7509. return nil, fmt.Errorf("unknown Label field %s", name)
  7510. }
  7511. // SetField sets the value of a field with the given name. It returns an error if
  7512. // the field is not defined in the schema, or if the type mismatched the field
  7513. // type.
  7514. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  7515. switch name {
  7516. case label.FieldCreatedAt:
  7517. v, ok := value.(time.Time)
  7518. if !ok {
  7519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7520. }
  7521. m.SetCreatedAt(v)
  7522. return nil
  7523. case label.FieldUpdatedAt:
  7524. v, ok := value.(time.Time)
  7525. if !ok {
  7526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7527. }
  7528. m.SetUpdatedAt(v)
  7529. return nil
  7530. case label.FieldStatus:
  7531. v, ok := value.(uint8)
  7532. if !ok {
  7533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7534. }
  7535. m.SetStatus(v)
  7536. return nil
  7537. case label.FieldType:
  7538. v, ok := value.(int)
  7539. if !ok {
  7540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7541. }
  7542. m.SetType(v)
  7543. return nil
  7544. case label.FieldName:
  7545. v, ok := value.(string)
  7546. if !ok {
  7547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7548. }
  7549. m.SetName(v)
  7550. return nil
  7551. case label.FieldFrom:
  7552. v, ok := value.(int)
  7553. if !ok {
  7554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7555. }
  7556. m.SetFrom(v)
  7557. return nil
  7558. case label.FieldMode:
  7559. v, ok := value.(int)
  7560. if !ok {
  7561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7562. }
  7563. m.SetMode(v)
  7564. return nil
  7565. case label.FieldConditions:
  7566. v, ok := value.(string)
  7567. if !ok {
  7568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7569. }
  7570. m.SetConditions(v)
  7571. return nil
  7572. case label.FieldOrganizationID:
  7573. v, ok := value.(uint64)
  7574. if !ok {
  7575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7576. }
  7577. m.SetOrganizationID(v)
  7578. return nil
  7579. }
  7580. return fmt.Errorf("unknown Label field %s", name)
  7581. }
  7582. // AddedFields returns all numeric fields that were incremented/decremented during
  7583. // this mutation.
  7584. func (m *LabelMutation) AddedFields() []string {
  7585. var fields []string
  7586. if m.addstatus != nil {
  7587. fields = append(fields, label.FieldStatus)
  7588. }
  7589. if m.add_type != nil {
  7590. fields = append(fields, label.FieldType)
  7591. }
  7592. if m.addfrom != nil {
  7593. fields = append(fields, label.FieldFrom)
  7594. }
  7595. if m.addmode != nil {
  7596. fields = append(fields, label.FieldMode)
  7597. }
  7598. if m.addorganization_id != nil {
  7599. fields = append(fields, label.FieldOrganizationID)
  7600. }
  7601. return fields
  7602. }
  7603. // AddedField returns the numeric value that was incremented/decremented on a field
  7604. // with the given name. The second boolean return value indicates that this field
  7605. // was not set, or was not defined in the schema.
  7606. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  7607. switch name {
  7608. case label.FieldStatus:
  7609. return m.AddedStatus()
  7610. case label.FieldType:
  7611. return m.AddedType()
  7612. case label.FieldFrom:
  7613. return m.AddedFrom()
  7614. case label.FieldMode:
  7615. return m.AddedMode()
  7616. case label.FieldOrganizationID:
  7617. return m.AddedOrganizationID()
  7618. }
  7619. return nil, false
  7620. }
  7621. // AddField adds the value to the field with the given name. It returns an error if
  7622. // the field is not defined in the schema, or if the type mismatched the field
  7623. // type.
  7624. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  7625. switch name {
  7626. case label.FieldStatus:
  7627. v, ok := value.(int8)
  7628. if !ok {
  7629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7630. }
  7631. m.AddStatus(v)
  7632. return nil
  7633. case label.FieldType:
  7634. v, ok := value.(int)
  7635. if !ok {
  7636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7637. }
  7638. m.AddType(v)
  7639. return nil
  7640. case label.FieldFrom:
  7641. v, ok := value.(int)
  7642. if !ok {
  7643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7644. }
  7645. m.AddFrom(v)
  7646. return nil
  7647. case label.FieldMode:
  7648. v, ok := value.(int)
  7649. if !ok {
  7650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7651. }
  7652. m.AddMode(v)
  7653. return nil
  7654. case label.FieldOrganizationID:
  7655. v, ok := value.(int64)
  7656. if !ok {
  7657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7658. }
  7659. m.AddOrganizationID(v)
  7660. return nil
  7661. }
  7662. return fmt.Errorf("unknown Label numeric field %s", name)
  7663. }
  7664. // ClearedFields returns all nullable fields that were cleared during this
  7665. // mutation.
  7666. func (m *LabelMutation) ClearedFields() []string {
  7667. var fields []string
  7668. if m.FieldCleared(label.FieldStatus) {
  7669. fields = append(fields, label.FieldStatus)
  7670. }
  7671. if m.FieldCleared(label.FieldConditions) {
  7672. fields = append(fields, label.FieldConditions)
  7673. }
  7674. if m.FieldCleared(label.FieldOrganizationID) {
  7675. fields = append(fields, label.FieldOrganizationID)
  7676. }
  7677. return fields
  7678. }
  7679. // FieldCleared returns a boolean indicating if a field with the given name was
  7680. // cleared in this mutation.
  7681. func (m *LabelMutation) FieldCleared(name string) bool {
  7682. _, ok := m.clearedFields[name]
  7683. return ok
  7684. }
  7685. // ClearField clears the value of the field with the given name. It returns an
  7686. // error if the field is not defined in the schema.
  7687. func (m *LabelMutation) ClearField(name string) error {
  7688. switch name {
  7689. case label.FieldStatus:
  7690. m.ClearStatus()
  7691. return nil
  7692. case label.FieldConditions:
  7693. m.ClearConditions()
  7694. return nil
  7695. case label.FieldOrganizationID:
  7696. m.ClearOrganizationID()
  7697. return nil
  7698. }
  7699. return fmt.Errorf("unknown Label nullable field %s", name)
  7700. }
  7701. // ResetField resets all changes in the mutation for the field with the given name.
  7702. // It returns an error if the field is not defined in the schema.
  7703. func (m *LabelMutation) ResetField(name string) error {
  7704. switch name {
  7705. case label.FieldCreatedAt:
  7706. m.ResetCreatedAt()
  7707. return nil
  7708. case label.FieldUpdatedAt:
  7709. m.ResetUpdatedAt()
  7710. return nil
  7711. case label.FieldStatus:
  7712. m.ResetStatus()
  7713. return nil
  7714. case label.FieldType:
  7715. m.ResetType()
  7716. return nil
  7717. case label.FieldName:
  7718. m.ResetName()
  7719. return nil
  7720. case label.FieldFrom:
  7721. m.ResetFrom()
  7722. return nil
  7723. case label.FieldMode:
  7724. m.ResetMode()
  7725. return nil
  7726. case label.FieldConditions:
  7727. m.ResetConditions()
  7728. return nil
  7729. case label.FieldOrganizationID:
  7730. m.ResetOrganizationID()
  7731. return nil
  7732. }
  7733. return fmt.Errorf("unknown Label field %s", name)
  7734. }
  7735. // AddedEdges returns all edge names that were set/added in this mutation.
  7736. func (m *LabelMutation) AddedEdges() []string {
  7737. edges := make([]string, 0, 1)
  7738. if m.label_relationships != nil {
  7739. edges = append(edges, label.EdgeLabelRelationships)
  7740. }
  7741. return edges
  7742. }
  7743. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7744. // name in this mutation.
  7745. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  7746. switch name {
  7747. case label.EdgeLabelRelationships:
  7748. ids := make([]ent.Value, 0, len(m.label_relationships))
  7749. for id := range m.label_relationships {
  7750. ids = append(ids, id)
  7751. }
  7752. return ids
  7753. }
  7754. return nil
  7755. }
  7756. // RemovedEdges returns all edge names that were removed in this mutation.
  7757. func (m *LabelMutation) RemovedEdges() []string {
  7758. edges := make([]string, 0, 1)
  7759. if m.removedlabel_relationships != nil {
  7760. edges = append(edges, label.EdgeLabelRelationships)
  7761. }
  7762. return edges
  7763. }
  7764. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7765. // the given name in this mutation.
  7766. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  7767. switch name {
  7768. case label.EdgeLabelRelationships:
  7769. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  7770. for id := range m.removedlabel_relationships {
  7771. ids = append(ids, id)
  7772. }
  7773. return ids
  7774. }
  7775. return nil
  7776. }
  7777. // ClearedEdges returns all edge names that were cleared in this mutation.
  7778. func (m *LabelMutation) ClearedEdges() []string {
  7779. edges := make([]string, 0, 1)
  7780. if m.clearedlabel_relationships {
  7781. edges = append(edges, label.EdgeLabelRelationships)
  7782. }
  7783. return edges
  7784. }
  7785. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7786. // was cleared in this mutation.
  7787. func (m *LabelMutation) EdgeCleared(name string) bool {
  7788. switch name {
  7789. case label.EdgeLabelRelationships:
  7790. return m.clearedlabel_relationships
  7791. }
  7792. return false
  7793. }
  7794. // ClearEdge clears the value of the edge with the given name. It returns an error
  7795. // if that edge is not defined in the schema.
  7796. func (m *LabelMutation) ClearEdge(name string) error {
  7797. switch name {
  7798. }
  7799. return fmt.Errorf("unknown Label unique edge %s", name)
  7800. }
  7801. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7802. // It returns an error if the edge is not defined in the schema.
  7803. func (m *LabelMutation) ResetEdge(name string) error {
  7804. switch name {
  7805. case label.EdgeLabelRelationships:
  7806. m.ResetLabelRelationships()
  7807. return nil
  7808. }
  7809. return fmt.Errorf("unknown Label edge %s", name)
  7810. }
  7811. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  7812. type LabelRelationshipMutation struct {
  7813. config
  7814. op Op
  7815. typ string
  7816. id *uint64
  7817. created_at *time.Time
  7818. updated_at *time.Time
  7819. status *uint8
  7820. addstatus *int8
  7821. deleted_at *time.Time
  7822. organization_id *uint64
  7823. addorganization_id *int64
  7824. clearedFields map[string]struct{}
  7825. contacts *uint64
  7826. clearedcontacts bool
  7827. labels *uint64
  7828. clearedlabels bool
  7829. done bool
  7830. oldValue func(context.Context) (*LabelRelationship, error)
  7831. predicates []predicate.LabelRelationship
  7832. }
  7833. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  7834. // labelrelationshipOption allows management of the mutation configuration using functional options.
  7835. type labelrelationshipOption func(*LabelRelationshipMutation)
  7836. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  7837. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  7838. m := &LabelRelationshipMutation{
  7839. config: c,
  7840. op: op,
  7841. typ: TypeLabelRelationship,
  7842. clearedFields: make(map[string]struct{}),
  7843. }
  7844. for _, opt := range opts {
  7845. opt(m)
  7846. }
  7847. return m
  7848. }
  7849. // withLabelRelationshipID sets the ID field of the mutation.
  7850. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  7851. return func(m *LabelRelationshipMutation) {
  7852. var (
  7853. err error
  7854. once sync.Once
  7855. value *LabelRelationship
  7856. )
  7857. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  7858. once.Do(func() {
  7859. if m.done {
  7860. err = errors.New("querying old values post mutation is not allowed")
  7861. } else {
  7862. value, err = m.Client().LabelRelationship.Get(ctx, id)
  7863. }
  7864. })
  7865. return value, err
  7866. }
  7867. m.id = &id
  7868. }
  7869. }
  7870. // withLabelRelationship sets the old LabelRelationship of the mutation.
  7871. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  7872. return func(m *LabelRelationshipMutation) {
  7873. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  7874. return node, nil
  7875. }
  7876. m.id = &node.ID
  7877. }
  7878. }
  7879. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7880. // executed in a transaction (ent.Tx), a transactional client is returned.
  7881. func (m LabelRelationshipMutation) Client() *Client {
  7882. client := &Client{config: m.config}
  7883. client.init()
  7884. return client
  7885. }
  7886. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7887. // it returns an error otherwise.
  7888. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  7889. if _, ok := m.driver.(*txDriver); !ok {
  7890. return nil, errors.New("ent: mutation is not running in a transaction")
  7891. }
  7892. tx := &Tx{config: m.config}
  7893. tx.init()
  7894. return tx, nil
  7895. }
  7896. // SetID sets the value of the id field. Note that this
  7897. // operation is only accepted on creation of LabelRelationship entities.
  7898. func (m *LabelRelationshipMutation) SetID(id uint64) {
  7899. m.id = &id
  7900. }
  7901. // ID returns the ID value in the mutation. Note that the ID is only available
  7902. // if it was provided to the builder or after it was returned from the database.
  7903. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  7904. if m.id == nil {
  7905. return
  7906. }
  7907. return *m.id, true
  7908. }
  7909. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7910. // That means, if the mutation is applied within a transaction with an isolation level such
  7911. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7912. // or updated by the mutation.
  7913. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  7914. switch {
  7915. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7916. id, exists := m.ID()
  7917. if exists {
  7918. return []uint64{id}, nil
  7919. }
  7920. fallthrough
  7921. case m.op.Is(OpUpdate | OpDelete):
  7922. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  7923. default:
  7924. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7925. }
  7926. }
  7927. // SetCreatedAt sets the "created_at" field.
  7928. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  7929. m.created_at = &t
  7930. }
  7931. // CreatedAt returns the value of the "created_at" field in the mutation.
  7932. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  7933. v := m.created_at
  7934. if v == nil {
  7935. return
  7936. }
  7937. return *v, true
  7938. }
  7939. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  7940. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  7941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7942. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7943. if !m.op.Is(OpUpdateOne) {
  7944. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7945. }
  7946. if m.id == nil || m.oldValue == nil {
  7947. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7948. }
  7949. oldValue, err := m.oldValue(ctx)
  7950. if err != nil {
  7951. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7952. }
  7953. return oldValue.CreatedAt, nil
  7954. }
  7955. // ResetCreatedAt resets all changes to the "created_at" field.
  7956. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  7957. m.created_at = nil
  7958. }
  7959. // SetUpdatedAt sets the "updated_at" field.
  7960. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  7961. m.updated_at = &t
  7962. }
  7963. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7964. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  7965. v := m.updated_at
  7966. if v == nil {
  7967. return
  7968. }
  7969. return *v, true
  7970. }
  7971. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  7972. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  7973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7974. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7975. if !m.op.Is(OpUpdateOne) {
  7976. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7977. }
  7978. if m.id == nil || m.oldValue == nil {
  7979. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7980. }
  7981. oldValue, err := m.oldValue(ctx)
  7982. if err != nil {
  7983. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7984. }
  7985. return oldValue.UpdatedAt, nil
  7986. }
  7987. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7988. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  7989. m.updated_at = nil
  7990. }
  7991. // SetStatus sets the "status" field.
  7992. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  7993. m.status = &u
  7994. m.addstatus = nil
  7995. }
  7996. // Status returns the value of the "status" field in the mutation.
  7997. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  7998. v := m.status
  7999. if v == nil {
  8000. return
  8001. }
  8002. return *v, true
  8003. }
  8004. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  8005. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8007. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  8008. if !m.op.Is(OpUpdateOne) {
  8009. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  8010. }
  8011. if m.id == nil || m.oldValue == nil {
  8012. return v, errors.New("OldStatus requires an ID field in the mutation")
  8013. }
  8014. oldValue, err := m.oldValue(ctx)
  8015. if err != nil {
  8016. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  8017. }
  8018. return oldValue.Status, nil
  8019. }
  8020. // AddStatus adds u to the "status" field.
  8021. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  8022. if m.addstatus != nil {
  8023. *m.addstatus += u
  8024. } else {
  8025. m.addstatus = &u
  8026. }
  8027. }
  8028. // AddedStatus returns the value that was added to the "status" field in this mutation.
  8029. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  8030. v := m.addstatus
  8031. if v == nil {
  8032. return
  8033. }
  8034. return *v, true
  8035. }
  8036. // ClearStatus clears the value of the "status" field.
  8037. func (m *LabelRelationshipMutation) ClearStatus() {
  8038. m.status = nil
  8039. m.addstatus = nil
  8040. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  8041. }
  8042. // StatusCleared returns if the "status" field was cleared in this mutation.
  8043. func (m *LabelRelationshipMutation) StatusCleared() bool {
  8044. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  8045. return ok
  8046. }
  8047. // ResetStatus resets all changes to the "status" field.
  8048. func (m *LabelRelationshipMutation) ResetStatus() {
  8049. m.status = nil
  8050. m.addstatus = nil
  8051. delete(m.clearedFields, labelrelationship.FieldStatus)
  8052. }
  8053. // SetDeletedAt sets the "deleted_at" field.
  8054. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  8055. m.deleted_at = &t
  8056. }
  8057. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8058. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  8059. v := m.deleted_at
  8060. if v == nil {
  8061. return
  8062. }
  8063. return *v, true
  8064. }
  8065. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  8066. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8067. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8068. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8069. if !m.op.Is(OpUpdateOne) {
  8070. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8071. }
  8072. if m.id == nil || m.oldValue == nil {
  8073. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8074. }
  8075. oldValue, err := m.oldValue(ctx)
  8076. if err != nil {
  8077. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8078. }
  8079. return oldValue.DeletedAt, nil
  8080. }
  8081. // ClearDeletedAt clears the value of the "deleted_at" field.
  8082. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  8083. m.deleted_at = nil
  8084. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  8085. }
  8086. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8087. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  8088. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  8089. return ok
  8090. }
  8091. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8092. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  8093. m.deleted_at = nil
  8094. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  8095. }
  8096. // SetLabelID sets the "label_id" field.
  8097. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  8098. m.labels = &u
  8099. }
  8100. // LabelID returns the value of the "label_id" field in the mutation.
  8101. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  8102. v := m.labels
  8103. if v == nil {
  8104. return
  8105. }
  8106. return *v, true
  8107. }
  8108. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  8109. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8110. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8111. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  8112. if !m.op.Is(OpUpdateOne) {
  8113. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  8114. }
  8115. if m.id == nil || m.oldValue == nil {
  8116. return v, errors.New("OldLabelID requires an ID field in the mutation")
  8117. }
  8118. oldValue, err := m.oldValue(ctx)
  8119. if err != nil {
  8120. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  8121. }
  8122. return oldValue.LabelID, nil
  8123. }
  8124. // ResetLabelID resets all changes to the "label_id" field.
  8125. func (m *LabelRelationshipMutation) ResetLabelID() {
  8126. m.labels = nil
  8127. }
  8128. // SetContactID sets the "contact_id" field.
  8129. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  8130. m.contacts = &u
  8131. }
  8132. // ContactID returns the value of the "contact_id" field in the mutation.
  8133. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  8134. v := m.contacts
  8135. if v == nil {
  8136. return
  8137. }
  8138. return *v, true
  8139. }
  8140. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  8141. // If the LabelRelationship 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 *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  8144. if !m.op.Is(OpUpdateOne) {
  8145. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  8146. }
  8147. if m.id == nil || m.oldValue == nil {
  8148. return v, errors.New("OldContactID 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 OldContactID: %w", err)
  8153. }
  8154. return oldValue.ContactID, nil
  8155. }
  8156. // ResetContactID resets all changes to the "contact_id" field.
  8157. func (m *LabelRelationshipMutation) ResetContactID() {
  8158. m.contacts = nil
  8159. }
  8160. // SetOrganizationID sets the "organization_id" field.
  8161. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  8162. m.organization_id = &u
  8163. m.addorganization_id = nil
  8164. }
  8165. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8166. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  8167. v := m.organization_id
  8168. if v == nil {
  8169. return
  8170. }
  8171. return *v, true
  8172. }
  8173. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  8174. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8176. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8177. if !m.op.Is(OpUpdateOne) {
  8178. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8179. }
  8180. if m.id == nil || m.oldValue == nil {
  8181. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8182. }
  8183. oldValue, err := m.oldValue(ctx)
  8184. if err != nil {
  8185. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8186. }
  8187. return oldValue.OrganizationID, nil
  8188. }
  8189. // AddOrganizationID adds u to the "organization_id" field.
  8190. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  8191. if m.addorganization_id != nil {
  8192. *m.addorganization_id += u
  8193. } else {
  8194. m.addorganization_id = &u
  8195. }
  8196. }
  8197. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8198. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  8199. v := m.addorganization_id
  8200. if v == nil {
  8201. return
  8202. }
  8203. return *v, true
  8204. }
  8205. // ClearOrganizationID clears the value of the "organization_id" field.
  8206. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  8207. m.organization_id = nil
  8208. m.addorganization_id = nil
  8209. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  8210. }
  8211. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  8212. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  8213. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  8214. return ok
  8215. }
  8216. // ResetOrganizationID resets all changes to the "organization_id" field.
  8217. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  8218. m.organization_id = nil
  8219. m.addorganization_id = nil
  8220. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  8221. }
  8222. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  8223. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  8224. m.contacts = &id
  8225. }
  8226. // ClearContacts clears the "contacts" edge to the Contact entity.
  8227. func (m *LabelRelationshipMutation) ClearContacts() {
  8228. m.clearedcontacts = true
  8229. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  8230. }
  8231. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  8232. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  8233. return m.clearedcontacts
  8234. }
  8235. // ContactsID returns the "contacts" edge ID in the mutation.
  8236. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  8237. if m.contacts != nil {
  8238. return *m.contacts, true
  8239. }
  8240. return
  8241. }
  8242. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  8243. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  8244. // ContactsID instead. It exists only for internal usage by the builders.
  8245. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  8246. if id := m.contacts; id != nil {
  8247. ids = append(ids, *id)
  8248. }
  8249. return
  8250. }
  8251. // ResetContacts resets all changes to the "contacts" edge.
  8252. func (m *LabelRelationshipMutation) ResetContacts() {
  8253. m.contacts = nil
  8254. m.clearedcontacts = false
  8255. }
  8256. // SetLabelsID sets the "labels" edge to the Label entity by id.
  8257. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  8258. m.labels = &id
  8259. }
  8260. // ClearLabels clears the "labels" edge to the Label entity.
  8261. func (m *LabelRelationshipMutation) ClearLabels() {
  8262. m.clearedlabels = true
  8263. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  8264. }
  8265. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  8266. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  8267. return m.clearedlabels
  8268. }
  8269. // LabelsID returns the "labels" edge ID in the mutation.
  8270. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  8271. if m.labels != nil {
  8272. return *m.labels, true
  8273. }
  8274. return
  8275. }
  8276. // LabelsIDs returns the "labels" edge IDs in the mutation.
  8277. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  8278. // LabelsID instead. It exists only for internal usage by the builders.
  8279. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  8280. if id := m.labels; id != nil {
  8281. ids = append(ids, *id)
  8282. }
  8283. return
  8284. }
  8285. // ResetLabels resets all changes to the "labels" edge.
  8286. func (m *LabelRelationshipMutation) ResetLabels() {
  8287. m.labels = nil
  8288. m.clearedlabels = false
  8289. }
  8290. // Where appends a list predicates to the LabelRelationshipMutation builder.
  8291. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  8292. m.predicates = append(m.predicates, ps...)
  8293. }
  8294. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  8295. // users can use type-assertion to append predicates that do not depend on any generated package.
  8296. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  8297. p := make([]predicate.LabelRelationship, len(ps))
  8298. for i := range ps {
  8299. p[i] = ps[i]
  8300. }
  8301. m.Where(p...)
  8302. }
  8303. // Op returns the operation name.
  8304. func (m *LabelRelationshipMutation) Op() Op {
  8305. return m.op
  8306. }
  8307. // SetOp allows setting the mutation operation.
  8308. func (m *LabelRelationshipMutation) SetOp(op Op) {
  8309. m.op = op
  8310. }
  8311. // Type returns the node type of this mutation (LabelRelationship).
  8312. func (m *LabelRelationshipMutation) Type() string {
  8313. return m.typ
  8314. }
  8315. // Fields returns all fields that were changed during this mutation. Note that in
  8316. // order to get all numeric fields that were incremented/decremented, call
  8317. // AddedFields().
  8318. func (m *LabelRelationshipMutation) Fields() []string {
  8319. fields := make([]string, 0, 7)
  8320. if m.created_at != nil {
  8321. fields = append(fields, labelrelationship.FieldCreatedAt)
  8322. }
  8323. if m.updated_at != nil {
  8324. fields = append(fields, labelrelationship.FieldUpdatedAt)
  8325. }
  8326. if m.status != nil {
  8327. fields = append(fields, labelrelationship.FieldStatus)
  8328. }
  8329. if m.deleted_at != nil {
  8330. fields = append(fields, labelrelationship.FieldDeletedAt)
  8331. }
  8332. if m.labels != nil {
  8333. fields = append(fields, labelrelationship.FieldLabelID)
  8334. }
  8335. if m.contacts != nil {
  8336. fields = append(fields, labelrelationship.FieldContactID)
  8337. }
  8338. if m.organization_id != nil {
  8339. fields = append(fields, labelrelationship.FieldOrganizationID)
  8340. }
  8341. return fields
  8342. }
  8343. // Field returns the value of a field with the given name. The second boolean
  8344. // return value indicates that this field was not set, or was not defined in the
  8345. // schema.
  8346. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  8347. switch name {
  8348. case labelrelationship.FieldCreatedAt:
  8349. return m.CreatedAt()
  8350. case labelrelationship.FieldUpdatedAt:
  8351. return m.UpdatedAt()
  8352. case labelrelationship.FieldStatus:
  8353. return m.Status()
  8354. case labelrelationship.FieldDeletedAt:
  8355. return m.DeletedAt()
  8356. case labelrelationship.FieldLabelID:
  8357. return m.LabelID()
  8358. case labelrelationship.FieldContactID:
  8359. return m.ContactID()
  8360. case labelrelationship.FieldOrganizationID:
  8361. return m.OrganizationID()
  8362. }
  8363. return nil, false
  8364. }
  8365. // OldField returns the old value of the field from the database. An error is
  8366. // returned if the mutation operation is not UpdateOne, or the query to the
  8367. // database failed.
  8368. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8369. switch name {
  8370. case labelrelationship.FieldCreatedAt:
  8371. return m.OldCreatedAt(ctx)
  8372. case labelrelationship.FieldUpdatedAt:
  8373. return m.OldUpdatedAt(ctx)
  8374. case labelrelationship.FieldStatus:
  8375. return m.OldStatus(ctx)
  8376. case labelrelationship.FieldDeletedAt:
  8377. return m.OldDeletedAt(ctx)
  8378. case labelrelationship.FieldLabelID:
  8379. return m.OldLabelID(ctx)
  8380. case labelrelationship.FieldContactID:
  8381. return m.OldContactID(ctx)
  8382. case labelrelationship.FieldOrganizationID:
  8383. return m.OldOrganizationID(ctx)
  8384. }
  8385. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  8386. }
  8387. // SetField sets the value of a field with the given name. It returns an error if
  8388. // the field is not defined in the schema, or if the type mismatched the field
  8389. // type.
  8390. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  8391. switch name {
  8392. case labelrelationship.FieldCreatedAt:
  8393. v, ok := value.(time.Time)
  8394. if !ok {
  8395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8396. }
  8397. m.SetCreatedAt(v)
  8398. return nil
  8399. case labelrelationship.FieldUpdatedAt:
  8400. v, ok := value.(time.Time)
  8401. if !ok {
  8402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8403. }
  8404. m.SetUpdatedAt(v)
  8405. return nil
  8406. case labelrelationship.FieldStatus:
  8407. v, ok := value.(uint8)
  8408. if !ok {
  8409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8410. }
  8411. m.SetStatus(v)
  8412. return nil
  8413. case labelrelationship.FieldDeletedAt:
  8414. v, ok := value.(time.Time)
  8415. if !ok {
  8416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8417. }
  8418. m.SetDeletedAt(v)
  8419. return nil
  8420. case labelrelationship.FieldLabelID:
  8421. v, ok := value.(uint64)
  8422. if !ok {
  8423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8424. }
  8425. m.SetLabelID(v)
  8426. return nil
  8427. case labelrelationship.FieldContactID:
  8428. v, ok := value.(uint64)
  8429. if !ok {
  8430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8431. }
  8432. m.SetContactID(v)
  8433. return nil
  8434. case labelrelationship.FieldOrganizationID:
  8435. v, ok := value.(uint64)
  8436. if !ok {
  8437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8438. }
  8439. m.SetOrganizationID(v)
  8440. return nil
  8441. }
  8442. return fmt.Errorf("unknown LabelRelationship field %s", name)
  8443. }
  8444. // AddedFields returns all numeric fields that were incremented/decremented during
  8445. // this mutation.
  8446. func (m *LabelRelationshipMutation) AddedFields() []string {
  8447. var fields []string
  8448. if m.addstatus != nil {
  8449. fields = append(fields, labelrelationship.FieldStatus)
  8450. }
  8451. if m.addorganization_id != nil {
  8452. fields = append(fields, labelrelationship.FieldOrganizationID)
  8453. }
  8454. return fields
  8455. }
  8456. // AddedField returns the numeric value that was incremented/decremented on a field
  8457. // with the given name. The second boolean return value indicates that this field
  8458. // was not set, or was not defined in the schema.
  8459. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  8460. switch name {
  8461. case labelrelationship.FieldStatus:
  8462. return m.AddedStatus()
  8463. case labelrelationship.FieldOrganizationID:
  8464. return m.AddedOrganizationID()
  8465. }
  8466. return nil, false
  8467. }
  8468. // AddField adds the value to the field with the given name. It returns an error if
  8469. // the field is not defined in the schema, or if the type mismatched the field
  8470. // type.
  8471. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  8472. switch name {
  8473. case labelrelationship.FieldStatus:
  8474. v, ok := value.(int8)
  8475. if !ok {
  8476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8477. }
  8478. m.AddStatus(v)
  8479. return nil
  8480. case labelrelationship.FieldOrganizationID:
  8481. v, ok := value.(int64)
  8482. if !ok {
  8483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8484. }
  8485. m.AddOrganizationID(v)
  8486. return nil
  8487. }
  8488. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  8489. }
  8490. // ClearedFields returns all nullable fields that were cleared during this
  8491. // mutation.
  8492. func (m *LabelRelationshipMutation) ClearedFields() []string {
  8493. var fields []string
  8494. if m.FieldCleared(labelrelationship.FieldStatus) {
  8495. fields = append(fields, labelrelationship.FieldStatus)
  8496. }
  8497. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  8498. fields = append(fields, labelrelationship.FieldDeletedAt)
  8499. }
  8500. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  8501. fields = append(fields, labelrelationship.FieldOrganizationID)
  8502. }
  8503. return fields
  8504. }
  8505. // FieldCleared returns a boolean indicating if a field with the given name was
  8506. // cleared in this mutation.
  8507. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  8508. _, ok := m.clearedFields[name]
  8509. return ok
  8510. }
  8511. // ClearField clears the value of the field with the given name. It returns an
  8512. // error if the field is not defined in the schema.
  8513. func (m *LabelRelationshipMutation) ClearField(name string) error {
  8514. switch name {
  8515. case labelrelationship.FieldStatus:
  8516. m.ClearStatus()
  8517. return nil
  8518. case labelrelationship.FieldDeletedAt:
  8519. m.ClearDeletedAt()
  8520. return nil
  8521. case labelrelationship.FieldOrganizationID:
  8522. m.ClearOrganizationID()
  8523. return nil
  8524. }
  8525. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  8526. }
  8527. // ResetField resets all changes in the mutation for the field with the given name.
  8528. // It returns an error if the field is not defined in the schema.
  8529. func (m *LabelRelationshipMutation) ResetField(name string) error {
  8530. switch name {
  8531. case labelrelationship.FieldCreatedAt:
  8532. m.ResetCreatedAt()
  8533. return nil
  8534. case labelrelationship.FieldUpdatedAt:
  8535. m.ResetUpdatedAt()
  8536. return nil
  8537. case labelrelationship.FieldStatus:
  8538. m.ResetStatus()
  8539. return nil
  8540. case labelrelationship.FieldDeletedAt:
  8541. m.ResetDeletedAt()
  8542. return nil
  8543. case labelrelationship.FieldLabelID:
  8544. m.ResetLabelID()
  8545. return nil
  8546. case labelrelationship.FieldContactID:
  8547. m.ResetContactID()
  8548. return nil
  8549. case labelrelationship.FieldOrganizationID:
  8550. m.ResetOrganizationID()
  8551. return nil
  8552. }
  8553. return fmt.Errorf("unknown LabelRelationship field %s", name)
  8554. }
  8555. // AddedEdges returns all edge names that were set/added in this mutation.
  8556. func (m *LabelRelationshipMutation) AddedEdges() []string {
  8557. edges := make([]string, 0, 2)
  8558. if m.contacts != nil {
  8559. edges = append(edges, labelrelationship.EdgeContacts)
  8560. }
  8561. if m.labels != nil {
  8562. edges = append(edges, labelrelationship.EdgeLabels)
  8563. }
  8564. return edges
  8565. }
  8566. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8567. // name in this mutation.
  8568. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  8569. switch name {
  8570. case labelrelationship.EdgeContacts:
  8571. if id := m.contacts; id != nil {
  8572. return []ent.Value{*id}
  8573. }
  8574. case labelrelationship.EdgeLabels:
  8575. if id := m.labels; id != nil {
  8576. return []ent.Value{*id}
  8577. }
  8578. }
  8579. return nil
  8580. }
  8581. // RemovedEdges returns all edge names that were removed in this mutation.
  8582. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  8583. edges := make([]string, 0, 2)
  8584. return edges
  8585. }
  8586. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8587. // the given name in this mutation.
  8588. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  8589. return nil
  8590. }
  8591. // ClearedEdges returns all edge names that were cleared in this mutation.
  8592. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  8593. edges := make([]string, 0, 2)
  8594. if m.clearedcontacts {
  8595. edges = append(edges, labelrelationship.EdgeContacts)
  8596. }
  8597. if m.clearedlabels {
  8598. edges = append(edges, labelrelationship.EdgeLabels)
  8599. }
  8600. return edges
  8601. }
  8602. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8603. // was cleared in this mutation.
  8604. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  8605. switch name {
  8606. case labelrelationship.EdgeContacts:
  8607. return m.clearedcontacts
  8608. case labelrelationship.EdgeLabels:
  8609. return m.clearedlabels
  8610. }
  8611. return false
  8612. }
  8613. // ClearEdge clears the value of the edge with the given name. It returns an error
  8614. // if that edge is not defined in the schema.
  8615. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  8616. switch name {
  8617. case labelrelationship.EdgeContacts:
  8618. m.ClearContacts()
  8619. return nil
  8620. case labelrelationship.EdgeLabels:
  8621. m.ClearLabels()
  8622. return nil
  8623. }
  8624. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  8625. }
  8626. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8627. // It returns an error if the edge is not defined in the schema.
  8628. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  8629. switch name {
  8630. case labelrelationship.EdgeContacts:
  8631. m.ResetContacts()
  8632. return nil
  8633. case labelrelationship.EdgeLabels:
  8634. m.ResetLabels()
  8635. return nil
  8636. }
  8637. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  8638. }
  8639. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  8640. type MessageMutation struct {
  8641. config
  8642. op Op
  8643. typ string
  8644. id *int
  8645. wx_wxid *string
  8646. wxid *string
  8647. content *string
  8648. clearedFields map[string]struct{}
  8649. done bool
  8650. oldValue func(context.Context) (*Message, error)
  8651. predicates []predicate.Message
  8652. }
  8653. var _ ent.Mutation = (*MessageMutation)(nil)
  8654. // messageOption allows management of the mutation configuration using functional options.
  8655. type messageOption func(*MessageMutation)
  8656. // newMessageMutation creates new mutation for the Message entity.
  8657. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  8658. m := &MessageMutation{
  8659. config: c,
  8660. op: op,
  8661. typ: TypeMessage,
  8662. clearedFields: make(map[string]struct{}),
  8663. }
  8664. for _, opt := range opts {
  8665. opt(m)
  8666. }
  8667. return m
  8668. }
  8669. // withMessageID sets the ID field of the mutation.
  8670. func withMessageID(id int) messageOption {
  8671. return func(m *MessageMutation) {
  8672. var (
  8673. err error
  8674. once sync.Once
  8675. value *Message
  8676. )
  8677. m.oldValue = func(ctx context.Context) (*Message, error) {
  8678. once.Do(func() {
  8679. if m.done {
  8680. err = errors.New("querying old values post mutation is not allowed")
  8681. } else {
  8682. value, err = m.Client().Message.Get(ctx, id)
  8683. }
  8684. })
  8685. return value, err
  8686. }
  8687. m.id = &id
  8688. }
  8689. }
  8690. // withMessage sets the old Message of the mutation.
  8691. func withMessage(node *Message) messageOption {
  8692. return func(m *MessageMutation) {
  8693. m.oldValue = func(context.Context) (*Message, error) {
  8694. return node, nil
  8695. }
  8696. m.id = &node.ID
  8697. }
  8698. }
  8699. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8700. // executed in a transaction (ent.Tx), a transactional client is returned.
  8701. func (m MessageMutation) Client() *Client {
  8702. client := &Client{config: m.config}
  8703. client.init()
  8704. return client
  8705. }
  8706. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8707. // it returns an error otherwise.
  8708. func (m MessageMutation) Tx() (*Tx, error) {
  8709. if _, ok := m.driver.(*txDriver); !ok {
  8710. return nil, errors.New("ent: mutation is not running in a transaction")
  8711. }
  8712. tx := &Tx{config: m.config}
  8713. tx.init()
  8714. return tx, nil
  8715. }
  8716. // ID returns the ID value in the mutation. Note that the ID is only available
  8717. // if it was provided to the builder or after it was returned from the database.
  8718. func (m *MessageMutation) ID() (id int, exists bool) {
  8719. if m.id == nil {
  8720. return
  8721. }
  8722. return *m.id, true
  8723. }
  8724. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8725. // That means, if the mutation is applied within a transaction with an isolation level such
  8726. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8727. // or updated by the mutation.
  8728. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  8729. switch {
  8730. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8731. id, exists := m.ID()
  8732. if exists {
  8733. return []int{id}, nil
  8734. }
  8735. fallthrough
  8736. case m.op.Is(OpUpdate | OpDelete):
  8737. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  8738. default:
  8739. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8740. }
  8741. }
  8742. // SetWxWxid sets the "wx_wxid" field.
  8743. func (m *MessageMutation) SetWxWxid(s string) {
  8744. m.wx_wxid = &s
  8745. }
  8746. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  8747. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  8748. v := m.wx_wxid
  8749. if v == nil {
  8750. return
  8751. }
  8752. return *v, true
  8753. }
  8754. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  8755. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  8756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8757. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  8758. if !m.op.Is(OpUpdateOne) {
  8759. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  8760. }
  8761. if m.id == nil || m.oldValue == nil {
  8762. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  8763. }
  8764. oldValue, err := m.oldValue(ctx)
  8765. if err != nil {
  8766. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  8767. }
  8768. return oldValue.WxWxid, nil
  8769. }
  8770. // ClearWxWxid clears the value of the "wx_wxid" field.
  8771. func (m *MessageMutation) ClearWxWxid() {
  8772. m.wx_wxid = nil
  8773. m.clearedFields[message.FieldWxWxid] = struct{}{}
  8774. }
  8775. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  8776. func (m *MessageMutation) WxWxidCleared() bool {
  8777. _, ok := m.clearedFields[message.FieldWxWxid]
  8778. return ok
  8779. }
  8780. // ResetWxWxid resets all changes to the "wx_wxid" field.
  8781. func (m *MessageMutation) ResetWxWxid() {
  8782. m.wx_wxid = nil
  8783. delete(m.clearedFields, message.FieldWxWxid)
  8784. }
  8785. // SetWxid sets the "wxid" field.
  8786. func (m *MessageMutation) SetWxid(s string) {
  8787. m.wxid = &s
  8788. }
  8789. // Wxid returns the value of the "wxid" field in the mutation.
  8790. func (m *MessageMutation) Wxid() (r string, exists bool) {
  8791. v := m.wxid
  8792. if v == nil {
  8793. return
  8794. }
  8795. return *v, true
  8796. }
  8797. // OldWxid returns the old "wxid" field's value of the Message entity.
  8798. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  8799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8800. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  8801. if !m.op.Is(OpUpdateOne) {
  8802. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  8803. }
  8804. if m.id == nil || m.oldValue == nil {
  8805. return v, errors.New("OldWxid requires an ID field in the mutation")
  8806. }
  8807. oldValue, err := m.oldValue(ctx)
  8808. if err != nil {
  8809. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  8810. }
  8811. return oldValue.Wxid, nil
  8812. }
  8813. // ResetWxid resets all changes to the "wxid" field.
  8814. func (m *MessageMutation) ResetWxid() {
  8815. m.wxid = nil
  8816. }
  8817. // SetContent sets the "content" field.
  8818. func (m *MessageMutation) SetContent(s string) {
  8819. m.content = &s
  8820. }
  8821. // Content returns the value of the "content" field in the mutation.
  8822. func (m *MessageMutation) Content() (r string, exists bool) {
  8823. v := m.content
  8824. if v == nil {
  8825. return
  8826. }
  8827. return *v, true
  8828. }
  8829. // OldContent returns the old "content" field's value of the Message entity.
  8830. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  8831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8832. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  8833. if !m.op.Is(OpUpdateOne) {
  8834. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  8835. }
  8836. if m.id == nil || m.oldValue == nil {
  8837. return v, errors.New("OldContent requires an ID field in the mutation")
  8838. }
  8839. oldValue, err := m.oldValue(ctx)
  8840. if err != nil {
  8841. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  8842. }
  8843. return oldValue.Content, nil
  8844. }
  8845. // ResetContent resets all changes to the "content" field.
  8846. func (m *MessageMutation) ResetContent() {
  8847. m.content = nil
  8848. }
  8849. // Where appends a list predicates to the MessageMutation builder.
  8850. func (m *MessageMutation) Where(ps ...predicate.Message) {
  8851. m.predicates = append(m.predicates, ps...)
  8852. }
  8853. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  8854. // users can use type-assertion to append predicates that do not depend on any generated package.
  8855. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  8856. p := make([]predicate.Message, len(ps))
  8857. for i := range ps {
  8858. p[i] = ps[i]
  8859. }
  8860. m.Where(p...)
  8861. }
  8862. // Op returns the operation name.
  8863. func (m *MessageMutation) Op() Op {
  8864. return m.op
  8865. }
  8866. // SetOp allows setting the mutation operation.
  8867. func (m *MessageMutation) SetOp(op Op) {
  8868. m.op = op
  8869. }
  8870. // Type returns the node type of this mutation (Message).
  8871. func (m *MessageMutation) Type() string {
  8872. return m.typ
  8873. }
  8874. // Fields returns all fields that were changed during this mutation. Note that in
  8875. // order to get all numeric fields that were incremented/decremented, call
  8876. // AddedFields().
  8877. func (m *MessageMutation) Fields() []string {
  8878. fields := make([]string, 0, 3)
  8879. if m.wx_wxid != nil {
  8880. fields = append(fields, message.FieldWxWxid)
  8881. }
  8882. if m.wxid != nil {
  8883. fields = append(fields, message.FieldWxid)
  8884. }
  8885. if m.content != nil {
  8886. fields = append(fields, message.FieldContent)
  8887. }
  8888. return fields
  8889. }
  8890. // Field returns the value of a field with the given name. The second boolean
  8891. // return value indicates that this field was not set, or was not defined in the
  8892. // schema.
  8893. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  8894. switch name {
  8895. case message.FieldWxWxid:
  8896. return m.WxWxid()
  8897. case message.FieldWxid:
  8898. return m.Wxid()
  8899. case message.FieldContent:
  8900. return m.Content()
  8901. }
  8902. return nil, false
  8903. }
  8904. // OldField returns the old value of the field from the database. An error is
  8905. // returned if the mutation operation is not UpdateOne, or the query to the
  8906. // database failed.
  8907. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8908. switch name {
  8909. case message.FieldWxWxid:
  8910. return m.OldWxWxid(ctx)
  8911. case message.FieldWxid:
  8912. return m.OldWxid(ctx)
  8913. case message.FieldContent:
  8914. return m.OldContent(ctx)
  8915. }
  8916. return nil, fmt.Errorf("unknown Message field %s", name)
  8917. }
  8918. // SetField sets the value of a field with the given name. It returns an error if
  8919. // the field is not defined in the schema, or if the type mismatched the field
  8920. // type.
  8921. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  8922. switch name {
  8923. case message.FieldWxWxid:
  8924. v, ok := value.(string)
  8925. if !ok {
  8926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8927. }
  8928. m.SetWxWxid(v)
  8929. return nil
  8930. case message.FieldWxid:
  8931. v, ok := value.(string)
  8932. if !ok {
  8933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8934. }
  8935. m.SetWxid(v)
  8936. return nil
  8937. case message.FieldContent:
  8938. v, ok := value.(string)
  8939. if !ok {
  8940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8941. }
  8942. m.SetContent(v)
  8943. return nil
  8944. }
  8945. return fmt.Errorf("unknown Message field %s", name)
  8946. }
  8947. // AddedFields returns all numeric fields that were incremented/decremented during
  8948. // this mutation.
  8949. func (m *MessageMutation) AddedFields() []string {
  8950. return nil
  8951. }
  8952. // AddedField returns the numeric value that was incremented/decremented on a field
  8953. // with the given name. The second boolean return value indicates that this field
  8954. // was not set, or was not defined in the schema.
  8955. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  8956. return nil, false
  8957. }
  8958. // AddField adds the value to the field with the given name. It returns an error if
  8959. // the field is not defined in the schema, or if the type mismatched the field
  8960. // type.
  8961. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  8962. switch name {
  8963. }
  8964. return fmt.Errorf("unknown Message numeric field %s", name)
  8965. }
  8966. // ClearedFields returns all nullable fields that were cleared during this
  8967. // mutation.
  8968. func (m *MessageMutation) ClearedFields() []string {
  8969. var fields []string
  8970. if m.FieldCleared(message.FieldWxWxid) {
  8971. fields = append(fields, message.FieldWxWxid)
  8972. }
  8973. return fields
  8974. }
  8975. // FieldCleared returns a boolean indicating if a field with the given name was
  8976. // cleared in this mutation.
  8977. func (m *MessageMutation) FieldCleared(name string) bool {
  8978. _, ok := m.clearedFields[name]
  8979. return ok
  8980. }
  8981. // ClearField clears the value of the field with the given name. It returns an
  8982. // error if the field is not defined in the schema.
  8983. func (m *MessageMutation) ClearField(name string) error {
  8984. switch name {
  8985. case message.FieldWxWxid:
  8986. m.ClearWxWxid()
  8987. return nil
  8988. }
  8989. return fmt.Errorf("unknown Message nullable field %s", name)
  8990. }
  8991. // ResetField resets all changes in the mutation for the field with the given name.
  8992. // It returns an error if the field is not defined in the schema.
  8993. func (m *MessageMutation) ResetField(name string) error {
  8994. switch name {
  8995. case message.FieldWxWxid:
  8996. m.ResetWxWxid()
  8997. return nil
  8998. case message.FieldWxid:
  8999. m.ResetWxid()
  9000. return nil
  9001. case message.FieldContent:
  9002. m.ResetContent()
  9003. return nil
  9004. }
  9005. return fmt.Errorf("unknown Message field %s", name)
  9006. }
  9007. // AddedEdges returns all edge names that were set/added in this mutation.
  9008. func (m *MessageMutation) AddedEdges() []string {
  9009. edges := make([]string, 0, 0)
  9010. return edges
  9011. }
  9012. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9013. // name in this mutation.
  9014. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  9015. return nil
  9016. }
  9017. // RemovedEdges returns all edge names that were removed in this mutation.
  9018. func (m *MessageMutation) RemovedEdges() []string {
  9019. edges := make([]string, 0, 0)
  9020. return edges
  9021. }
  9022. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9023. // the given name in this mutation.
  9024. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  9025. return nil
  9026. }
  9027. // ClearedEdges returns all edge names that were cleared in this mutation.
  9028. func (m *MessageMutation) ClearedEdges() []string {
  9029. edges := make([]string, 0, 0)
  9030. return edges
  9031. }
  9032. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9033. // was cleared in this mutation.
  9034. func (m *MessageMutation) EdgeCleared(name string) bool {
  9035. return false
  9036. }
  9037. // ClearEdge clears the value of the edge with the given name. It returns an error
  9038. // if that edge is not defined in the schema.
  9039. func (m *MessageMutation) ClearEdge(name string) error {
  9040. return fmt.Errorf("unknown Message unique edge %s", name)
  9041. }
  9042. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9043. // It returns an error if the edge is not defined in the schema.
  9044. func (m *MessageMutation) ResetEdge(name string) error {
  9045. return fmt.Errorf("unknown Message edge %s", name)
  9046. }
  9047. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  9048. type MessageRecordsMutation struct {
  9049. config
  9050. op Op
  9051. typ string
  9052. id *uint64
  9053. created_at *time.Time
  9054. updated_at *time.Time
  9055. status *uint8
  9056. addstatus *int8
  9057. deleted_at *time.Time
  9058. bot_wxid *string
  9059. contact_type *int
  9060. addcontact_type *int
  9061. contact_wxid *string
  9062. content_type *int
  9063. addcontent_type *int
  9064. content *string
  9065. meta *custom_types.Meta
  9066. error_detail *string
  9067. send_time *time.Time
  9068. source_type *int
  9069. addsource_type *int
  9070. organization_id *uint64
  9071. addorganization_id *int64
  9072. clearedFields map[string]struct{}
  9073. sop_stage *uint64
  9074. clearedsop_stage bool
  9075. sop_node *uint64
  9076. clearedsop_node bool
  9077. message_contact *uint64
  9078. clearedmessage_contact bool
  9079. done bool
  9080. oldValue func(context.Context) (*MessageRecords, error)
  9081. predicates []predicate.MessageRecords
  9082. }
  9083. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  9084. // messagerecordsOption allows management of the mutation configuration using functional options.
  9085. type messagerecordsOption func(*MessageRecordsMutation)
  9086. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  9087. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  9088. m := &MessageRecordsMutation{
  9089. config: c,
  9090. op: op,
  9091. typ: TypeMessageRecords,
  9092. clearedFields: make(map[string]struct{}),
  9093. }
  9094. for _, opt := range opts {
  9095. opt(m)
  9096. }
  9097. return m
  9098. }
  9099. // withMessageRecordsID sets the ID field of the mutation.
  9100. func withMessageRecordsID(id uint64) messagerecordsOption {
  9101. return func(m *MessageRecordsMutation) {
  9102. var (
  9103. err error
  9104. once sync.Once
  9105. value *MessageRecords
  9106. )
  9107. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  9108. once.Do(func() {
  9109. if m.done {
  9110. err = errors.New("querying old values post mutation is not allowed")
  9111. } else {
  9112. value, err = m.Client().MessageRecords.Get(ctx, id)
  9113. }
  9114. })
  9115. return value, err
  9116. }
  9117. m.id = &id
  9118. }
  9119. }
  9120. // withMessageRecords sets the old MessageRecords of the mutation.
  9121. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  9122. return func(m *MessageRecordsMutation) {
  9123. m.oldValue = func(context.Context) (*MessageRecords, error) {
  9124. return node, nil
  9125. }
  9126. m.id = &node.ID
  9127. }
  9128. }
  9129. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9130. // executed in a transaction (ent.Tx), a transactional client is returned.
  9131. func (m MessageRecordsMutation) Client() *Client {
  9132. client := &Client{config: m.config}
  9133. client.init()
  9134. return client
  9135. }
  9136. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9137. // it returns an error otherwise.
  9138. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  9139. if _, ok := m.driver.(*txDriver); !ok {
  9140. return nil, errors.New("ent: mutation is not running in a transaction")
  9141. }
  9142. tx := &Tx{config: m.config}
  9143. tx.init()
  9144. return tx, nil
  9145. }
  9146. // SetID sets the value of the id field. Note that this
  9147. // operation is only accepted on creation of MessageRecords entities.
  9148. func (m *MessageRecordsMutation) SetID(id uint64) {
  9149. m.id = &id
  9150. }
  9151. // ID returns the ID value in the mutation. Note that the ID is only available
  9152. // if it was provided to the builder or after it was returned from the database.
  9153. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  9154. if m.id == nil {
  9155. return
  9156. }
  9157. return *m.id, true
  9158. }
  9159. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9160. // That means, if the mutation is applied within a transaction with an isolation level such
  9161. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9162. // or updated by the mutation.
  9163. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  9164. switch {
  9165. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9166. id, exists := m.ID()
  9167. if exists {
  9168. return []uint64{id}, nil
  9169. }
  9170. fallthrough
  9171. case m.op.Is(OpUpdate | OpDelete):
  9172. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  9173. default:
  9174. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9175. }
  9176. }
  9177. // SetCreatedAt sets the "created_at" field.
  9178. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  9179. m.created_at = &t
  9180. }
  9181. // CreatedAt returns the value of the "created_at" field in the mutation.
  9182. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  9183. v := m.created_at
  9184. if v == nil {
  9185. return
  9186. }
  9187. return *v, true
  9188. }
  9189. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  9190. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9192. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9193. if !m.op.Is(OpUpdateOne) {
  9194. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9195. }
  9196. if m.id == nil || m.oldValue == nil {
  9197. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9198. }
  9199. oldValue, err := m.oldValue(ctx)
  9200. if err != nil {
  9201. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9202. }
  9203. return oldValue.CreatedAt, nil
  9204. }
  9205. // ResetCreatedAt resets all changes to the "created_at" field.
  9206. func (m *MessageRecordsMutation) ResetCreatedAt() {
  9207. m.created_at = nil
  9208. }
  9209. // SetUpdatedAt sets the "updated_at" field.
  9210. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  9211. m.updated_at = &t
  9212. }
  9213. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9214. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  9215. v := m.updated_at
  9216. if v == nil {
  9217. return
  9218. }
  9219. return *v, true
  9220. }
  9221. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  9222. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9224. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9225. if !m.op.Is(OpUpdateOne) {
  9226. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9227. }
  9228. if m.id == nil || m.oldValue == nil {
  9229. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9230. }
  9231. oldValue, err := m.oldValue(ctx)
  9232. if err != nil {
  9233. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9234. }
  9235. return oldValue.UpdatedAt, nil
  9236. }
  9237. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9238. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  9239. m.updated_at = nil
  9240. }
  9241. // SetStatus sets the "status" field.
  9242. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  9243. m.status = &u
  9244. m.addstatus = nil
  9245. }
  9246. // Status returns the value of the "status" field in the mutation.
  9247. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  9248. v := m.status
  9249. if v == nil {
  9250. return
  9251. }
  9252. return *v, true
  9253. }
  9254. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  9255. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9257. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9258. if !m.op.Is(OpUpdateOne) {
  9259. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9260. }
  9261. if m.id == nil || m.oldValue == nil {
  9262. return v, errors.New("OldStatus requires an ID field in the mutation")
  9263. }
  9264. oldValue, err := m.oldValue(ctx)
  9265. if err != nil {
  9266. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9267. }
  9268. return oldValue.Status, nil
  9269. }
  9270. // AddStatus adds u to the "status" field.
  9271. func (m *MessageRecordsMutation) AddStatus(u int8) {
  9272. if m.addstatus != nil {
  9273. *m.addstatus += u
  9274. } else {
  9275. m.addstatus = &u
  9276. }
  9277. }
  9278. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9279. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  9280. v := m.addstatus
  9281. if v == nil {
  9282. return
  9283. }
  9284. return *v, true
  9285. }
  9286. // ClearStatus clears the value of the "status" field.
  9287. func (m *MessageRecordsMutation) ClearStatus() {
  9288. m.status = nil
  9289. m.addstatus = nil
  9290. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  9291. }
  9292. // StatusCleared returns if the "status" field was cleared in this mutation.
  9293. func (m *MessageRecordsMutation) StatusCleared() bool {
  9294. _, ok := m.clearedFields[messagerecords.FieldStatus]
  9295. return ok
  9296. }
  9297. // ResetStatus resets all changes to the "status" field.
  9298. func (m *MessageRecordsMutation) ResetStatus() {
  9299. m.status = nil
  9300. m.addstatus = nil
  9301. delete(m.clearedFields, messagerecords.FieldStatus)
  9302. }
  9303. // SetDeletedAt sets the "deleted_at" field.
  9304. func (m *MessageRecordsMutation) SetDeletedAt(t time.Time) {
  9305. m.deleted_at = &t
  9306. }
  9307. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9308. func (m *MessageRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  9309. v := m.deleted_at
  9310. if v == nil {
  9311. return
  9312. }
  9313. return *v, true
  9314. }
  9315. // OldDeletedAt returns the old "deleted_at" field's value of the MessageRecords entity.
  9316. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9318. func (m *MessageRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9319. if !m.op.Is(OpUpdateOne) {
  9320. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9321. }
  9322. if m.id == nil || m.oldValue == nil {
  9323. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9324. }
  9325. oldValue, err := m.oldValue(ctx)
  9326. if err != nil {
  9327. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9328. }
  9329. return oldValue.DeletedAt, nil
  9330. }
  9331. // ClearDeletedAt clears the value of the "deleted_at" field.
  9332. func (m *MessageRecordsMutation) ClearDeletedAt() {
  9333. m.deleted_at = nil
  9334. m.clearedFields[messagerecords.FieldDeletedAt] = struct{}{}
  9335. }
  9336. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9337. func (m *MessageRecordsMutation) DeletedAtCleared() bool {
  9338. _, ok := m.clearedFields[messagerecords.FieldDeletedAt]
  9339. return ok
  9340. }
  9341. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9342. func (m *MessageRecordsMutation) ResetDeletedAt() {
  9343. m.deleted_at = nil
  9344. delete(m.clearedFields, messagerecords.FieldDeletedAt)
  9345. }
  9346. // SetBotWxid sets the "bot_wxid" field.
  9347. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  9348. m.bot_wxid = &s
  9349. }
  9350. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  9351. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  9352. v := m.bot_wxid
  9353. if v == nil {
  9354. return
  9355. }
  9356. return *v, true
  9357. }
  9358. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  9359. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9361. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  9362. if !m.op.Is(OpUpdateOne) {
  9363. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  9364. }
  9365. if m.id == nil || m.oldValue == nil {
  9366. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  9367. }
  9368. oldValue, err := m.oldValue(ctx)
  9369. if err != nil {
  9370. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  9371. }
  9372. return oldValue.BotWxid, nil
  9373. }
  9374. // ResetBotWxid resets all changes to the "bot_wxid" field.
  9375. func (m *MessageRecordsMutation) ResetBotWxid() {
  9376. m.bot_wxid = nil
  9377. }
  9378. // SetContactID sets the "contact_id" field.
  9379. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  9380. m.message_contact = &u
  9381. }
  9382. // ContactID returns the value of the "contact_id" field in the mutation.
  9383. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  9384. v := m.message_contact
  9385. if v == nil {
  9386. return
  9387. }
  9388. return *v, true
  9389. }
  9390. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  9391. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9393. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  9394. if !m.op.Is(OpUpdateOne) {
  9395. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  9396. }
  9397. if m.id == nil || m.oldValue == nil {
  9398. return v, errors.New("OldContactID requires an ID field in the mutation")
  9399. }
  9400. oldValue, err := m.oldValue(ctx)
  9401. if err != nil {
  9402. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  9403. }
  9404. return oldValue.ContactID, nil
  9405. }
  9406. // ClearContactID clears the value of the "contact_id" field.
  9407. func (m *MessageRecordsMutation) ClearContactID() {
  9408. m.message_contact = nil
  9409. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  9410. }
  9411. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  9412. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  9413. _, ok := m.clearedFields[messagerecords.FieldContactID]
  9414. return ok
  9415. }
  9416. // ResetContactID resets all changes to the "contact_id" field.
  9417. func (m *MessageRecordsMutation) ResetContactID() {
  9418. m.message_contact = nil
  9419. delete(m.clearedFields, messagerecords.FieldContactID)
  9420. }
  9421. // SetContactType sets the "contact_type" field.
  9422. func (m *MessageRecordsMutation) SetContactType(i int) {
  9423. m.contact_type = &i
  9424. m.addcontact_type = nil
  9425. }
  9426. // ContactType returns the value of the "contact_type" field in the mutation.
  9427. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  9428. v := m.contact_type
  9429. if v == nil {
  9430. return
  9431. }
  9432. return *v, true
  9433. }
  9434. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  9435. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9437. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  9438. if !m.op.Is(OpUpdateOne) {
  9439. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  9440. }
  9441. if m.id == nil || m.oldValue == nil {
  9442. return v, errors.New("OldContactType requires an ID field in the mutation")
  9443. }
  9444. oldValue, err := m.oldValue(ctx)
  9445. if err != nil {
  9446. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  9447. }
  9448. return oldValue.ContactType, nil
  9449. }
  9450. // AddContactType adds i to the "contact_type" field.
  9451. func (m *MessageRecordsMutation) AddContactType(i int) {
  9452. if m.addcontact_type != nil {
  9453. *m.addcontact_type += i
  9454. } else {
  9455. m.addcontact_type = &i
  9456. }
  9457. }
  9458. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  9459. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  9460. v := m.addcontact_type
  9461. if v == nil {
  9462. return
  9463. }
  9464. return *v, true
  9465. }
  9466. // ResetContactType resets all changes to the "contact_type" field.
  9467. func (m *MessageRecordsMutation) ResetContactType() {
  9468. m.contact_type = nil
  9469. m.addcontact_type = nil
  9470. }
  9471. // SetContactWxid sets the "contact_wxid" field.
  9472. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  9473. m.contact_wxid = &s
  9474. }
  9475. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  9476. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  9477. v := m.contact_wxid
  9478. if v == nil {
  9479. return
  9480. }
  9481. return *v, true
  9482. }
  9483. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  9484. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9486. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  9487. if !m.op.Is(OpUpdateOne) {
  9488. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  9489. }
  9490. if m.id == nil || m.oldValue == nil {
  9491. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  9492. }
  9493. oldValue, err := m.oldValue(ctx)
  9494. if err != nil {
  9495. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  9496. }
  9497. return oldValue.ContactWxid, nil
  9498. }
  9499. // ResetContactWxid resets all changes to the "contact_wxid" field.
  9500. func (m *MessageRecordsMutation) ResetContactWxid() {
  9501. m.contact_wxid = nil
  9502. }
  9503. // SetContentType sets the "content_type" field.
  9504. func (m *MessageRecordsMutation) SetContentType(i int) {
  9505. m.content_type = &i
  9506. m.addcontent_type = nil
  9507. }
  9508. // ContentType returns the value of the "content_type" field in the mutation.
  9509. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  9510. v := m.content_type
  9511. if v == nil {
  9512. return
  9513. }
  9514. return *v, true
  9515. }
  9516. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  9517. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9519. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  9520. if !m.op.Is(OpUpdateOne) {
  9521. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  9522. }
  9523. if m.id == nil || m.oldValue == nil {
  9524. return v, errors.New("OldContentType requires an ID field in the mutation")
  9525. }
  9526. oldValue, err := m.oldValue(ctx)
  9527. if err != nil {
  9528. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  9529. }
  9530. return oldValue.ContentType, nil
  9531. }
  9532. // AddContentType adds i to the "content_type" field.
  9533. func (m *MessageRecordsMutation) AddContentType(i int) {
  9534. if m.addcontent_type != nil {
  9535. *m.addcontent_type += i
  9536. } else {
  9537. m.addcontent_type = &i
  9538. }
  9539. }
  9540. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  9541. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  9542. v := m.addcontent_type
  9543. if v == nil {
  9544. return
  9545. }
  9546. return *v, true
  9547. }
  9548. // ResetContentType resets all changes to the "content_type" field.
  9549. func (m *MessageRecordsMutation) ResetContentType() {
  9550. m.content_type = nil
  9551. m.addcontent_type = nil
  9552. }
  9553. // SetContent sets the "content" field.
  9554. func (m *MessageRecordsMutation) SetContent(s string) {
  9555. m.content = &s
  9556. }
  9557. // Content returns the value of the "content" field in the mutation.
  9558. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  9559. v := m.content
  9560. if v == nil {
  9561. return
  9562. }
  9563. return *v, true
  9564. }
  9565. // OldContent returns the old "content" field's value of the MessageRecords entity.
  9566. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9568. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  9569. if !m.op.Is(OpUpdateOne) {
  9570. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  9571. }
  9572. if m.id == nil || m.oldValue == nil {
  9573. return v, errors.New("OldContent requires an ID field in the mutation")
  9574. }
  9575. oldValue, err := m.oldValue(ctx)
  9576. if err != nil {
  9577. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  9578. }
  9579. return oldValue.Content, nil
  9580. }
  9581. // ResetContent resets all changes to the "content" field.
  9582. func (m *MessageRecordsMutation) ResetContent() {
  9583. m.content = nil
  9584. }
  9585. // SetMeta sets the "meta" field.
  9586. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  9587. m.meta = &ct
  9588. }
  9589. // Meta returns the value of the "meta" field in the mutation.
  9590. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  9591. v := m.meta
  9592. if v == nil {
  9593. return
  9594. }
  9595. return *v, true
  9596. }
  9597. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  9598. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9600. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  9601. if !m.op.Is(OpUpdateOne) {
  9602. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  9603. }
  9604. if m.id == nil || m.oldValue == nil {
  9605. return v, errors.New("OldMeta requires an ID field in the mutation")
  9606. }
  9607. oldValue, err := m.oldValue(ctx)
  9608. if err != nil {
  9609. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  9610. }
  9611. return oldValue.Meta, nil
  9612. }
  9613. // ClearMeta clears the value of the "meta" field.
  9614. func (m *MessageRecordsMutation) ClearMeta() {
  9615. m.meta = nil
  9616. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  9617. }
  9618. // MetaCleared returns if the "meta" field was cleared in this mutation.
  9619. func (m *MessageRecordsMutation) MetaCleared() bool {
  9620. _, ok := m.clearedFields[messagerecords.FieldMeta]
  9621. return ok
  9622. }
  9623. // ResetMeta resets all changes to the "meta" field.
  9624. func (m *MessageRecordsMutation) ResetMeta() {
  9625. m.meta = nil
  9626. delete(m.clearedFields, messagerecords.FieldMeta)
  9627. }
  9628. // SetErrorDetail sets the "error_detail" field.
  9629. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  9630. m.error_detail = &s
  9631. }
  9632. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  9633. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  9634. v := m.error_detail
  9635. if v == nil {
  9636. return
  9637. }
  9638. return *v, true
  9639. }
  9640. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  9641. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9643. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  9644. if !m.op.Is(OpUpdateOne) {
  9645. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  9646. }
  9647. if m.id == nil || m.oldValue == nil {
  9648. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  9649. }
  9650. oldValue, err := m.oldValue(ctx)
  9651. if err != nil {
  9652. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  9653. }
  9654. return oldValue.ErrorDetail, nil
  9655. }
  9656. // ResetErrorDetail resets all changes to the "error_detail" field.
  9657. func (m *MessageRecordsMutation) ResetErrorDetail() {
  9658. m.error_detail = nil
  9659. }
  9660. // SetSendTime sets the "send_time" field.
  9661. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  9662. m.send_time = &t
  9663. }
  9664. // SendTime returns the value of the "send_time" field in the mutation.
  9665. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  9666. v := m.send_time
  9667. if v == nil {
  9668. return
  9669. }
  9670. return *v, true
  9671. }
  9672. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  9673. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9675. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  9676. if !m.op.Is(OpUpdateOne) {
  9677. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  9678. }
  9679. if m.id == nil || m.oldValue == nil {
  9680. return v, errors.New("OldSendTime requires an ID field in the mutation")
  9681. }
  9682. oldValue, err := m.oldValue(ctx)
  9683. if err != nil {
  9684. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  9685. }
  9686. return oldValue.SendTime, nil
  9687. }
  9688. // ClearSendTime clears the value of the "send_time" field.
  9689. func (m *MessageRecordsMutation) ClearSendTime() {
  9690. m.send_time = nil
  9691. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  9692. }
  9693. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  9694. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  9695. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  9696. return ok
  9697. }
  9698. // ResetSendTime resets all changes to the "send_time" field.
  9699. func (m *MessageRecordsMutation) ResetSendTime() {
  9700. m.send_time = nil
  9701. delete(m.clearedFields, messagerecords.FieldSendTime)
  9702. }
  9703. // SetSourceType sets the "source_type" field.
  9704. func (m *MessageRecordsMutation) SetSourceType(i int) {
  9705. m.source_type = &i
  9706. m.addsource_type = nil
  9707. }
  9708. // SourceType returns the value of the "source_type" field in the mutation.
  9709. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  9710. v := m.source_type
  9711. if v == nil {
  9712. return
  9713. }
  9714. return *v, true
  9715. }
  9716. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  9717. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9719. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  9720. if !m.op.Is(OpUpdateOne) {
  9721. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  9722. }
  9723. if m.id == nil || m.oldValue == nil {
  9724. return v, errors.New("OldSourceType requires an ID field in the mutation")
  9725. }
  9726. oldValue, err := m.oldValue(ctx)
  9727. if err != nil {
  9728. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  9729. }
  9730. return oldValue.SourceType, nil
  9731. }
  9732. // AddSourceType adds i to the "source_type" field.
  9733. func (m *MessageRecordsMutation) AddSourceType(i int) {
  9734. if m.addsource_type != nil {
  9735. *m.addsource_type += i
  9736. } else {
  9737. m.addsource_type = &i
  9738. }
  9739. }
  9740. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  9741. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  9742. v := m.addsource_type
  9743. if v == nil {
  9744. return
  9745. }
  9746. return *v, true
  9747. }
  9748. // ResetSourceType resets all changes to the "source_type" field.
  9749. func (m *MessageRecordsMutation) ResetSourceType() {
  9750. m.source_type = nil
  9751. m.addsource_type = nil
  9752. }
  9753. // SetSourceID sets the "source_id" field.
  9754. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  9755. m.sop_stage = &u
  9756. }
  9757. // SourceID returns the value of the "source_id" field in the mutation.
  9758. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  9759. v := m.sop_stage
  9760. if v == nil {
  9761. return
  9762. }
  9763. return *v, true
  9764. }
  9765. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  9766. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9768. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  9769. if !m.op.Is(OpUpdateOne) {
  9770. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  9771. }
  9772. if m.id == nil || m.oldValue == nil {
  9773. return v, errors.New("OldSourceID requires an ID field in the mutation")
  9774. }
  9775. oldValue, err := m.oldValue(ctx)
  9776. if err != nil {
  9777. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  9778. }
  9779. return oldValue.SourceID, nil
  9780. }
  9781. // ClearSourceID clears the value of the "source_id" field.
  9782. func (m *MessageRecordsMutation) ClearSourceID() {
  9783. m.sop_stage = nil
  9784. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  9785. }
  9786. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  9787. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  9788. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  9789. return ok
  9790. }
  9791. // ResetSourceID resets all changes to the "source_id" field.
  9792. func (m *MessageRecordsMutation) ResetSourceID() {
  9793. m.sop_stage = nil
  9794. delete(m.clearedFields, messagerecords.FieldSourceID)
  9795. }
  9796. // SetSubSourceID sets the "sub_source_id" field.
  9797. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  9798. m.sop_node = &u
  9799. }
  9800. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  9801. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  9802. v := m.sop_node
  9803. if v == nil {
  9804. return
  9805. }
  9806. return *v, true
  9807. }
  9808. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  9809. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9811. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  9812. if !m.op.Is(OpUpdateOne) {
  9813. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  9814. }
  9815. if m.id == nil || m.oldValue == nil {
  9816. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  9817. }
  9818. oldValue, err := m.oldValue(ctx)
  9819. if err != nil {
  9820. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  9821. }
  9822. return oldValue.SubSourceID, nil
  9823. }
  9824. // ClearSubSourceID clears the value of the "sub_source_id" field.
  9825. func (m *MessageRecordsMutation) ClearSubSourceID() {
  9826. m.sop_node = nil
  9827. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  9828. }
  9829. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  9830. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  9831. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  9832. return ok
  9833. }
  9834. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  9835. func (m *MessageRecordsMutation) ResetSubSourceID() {
  9836. m.sop_node = nil
  9837. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  9838. }
  9839. // SetOrganizationID sets the "organization_id" field.
  9840. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  9841. m.organization_id = &u
  9842. m.addorganization_id = nil
  9843. }
  9844. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9845. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  9846. v := m.organization_id
  9847. if v == nil {
  9848. return
  9849. }
  9850. return *v, true
  9851. }
  9852. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  9853. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9855. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9856. if !m.op.Is(OpUpdateOne) {
  9857. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9858. }
  9859. if m.id == nil || m.oldValue == nil {
  9860. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9861. }
  9862. oldValue, err := m.oldValue(ctx)
  9863. if err != nil {
  9864. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9865. }
  9866. return oldValue.OrganizationID, nil
  9867. }
  9868. // AddOrganizationID adds u to the "organization_id" field.
  9869. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  9870. if m.addorganization_id != nil {
  9871. *m.addorganization_id += u
  9872. } else {
  9873. m.addorganization_id = &u
  9874. }
  9875. }
  9876. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9877. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  9878. v := m.addorganization_id
  9879. if v == nil {
  9880. return
  9881. }
  9882. return *v, true
  9883. }
  9884. // ClearOrganizationID clears the value of the "organization_id" field.
  9885. func (m *MessageRecordsMutation) ClearOrganizationID() {
  9886. m.organization_id = nil
  9887. m.addorganization_id = nil
  9888. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  9889. }
  9890. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  9891. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  9892. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  9893. return ok
  9894. }
  9895. // ResetOrganizationID resets all changes to the "organization_id" field.
  9896. func (m *MessageRecordsMutation) ResetOrganizationID() {
  9897. m.organization_id = nil
  9898. m.addorganization_id = nil
  9899. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  9900. }
  9901. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  9902. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  9903. m.sop_stage = &id
  9904. }
  9905. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  9906. func (m *MessageRecordsMutation) ClearSopStage() {
  9907. m.clearedsop_stage = true
  9908. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  9909. }
  9910. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  9911. func (m *MessageRecordsMutation) SopStageCleared() bool {
  9912. return m.SourceIDCleared() || m.clearedsop_stage
  9913. }
  9914. // SopStageID returns the "sop_stage" edge ID in the mutation.
  9915. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  9916. if m.sop_stage != nil {
  9917. return *m.sop_stage, true
  9918. }
  9919. return
  9920. }
  9921. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  9922. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  9923. // SopStageID instead. It exists only for internal usage by the builders.
  9924. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  9925. if id := m.sop_stage; id != nil {
  9926. ids = append(ids, *id)
  9927. }
  9928. return
  9929. }
  9930. // ResetSopStage resets all changes to the "sop_stage" edge.
  9931. func (m *MessageRecordsMutation) ResetSopStage() {
  9932. m.sop_stage = nil
  9933. m.clearedsop_stage = false
  9934. }
  9935. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  9936. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  9937. m.sop_node = &id
  9938. }
  9939. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  9940. func (m *MessageRecordsMutation) ClearSopNode() {
  9941. m.clearedsop_node = true
  9942. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  9943. }
  9944. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  9945. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  9946. return m.SubSourceIDCleared() || m.clearedsop_node
  9947. }
  9948. // SopNodeID returns the "sop_node" edge ID in the mutation.
  9949. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  9950. if m.sop_node != nil {
  9951. return *m.sop_node, true
  9952. }
  9953. return
  9954. }
  9955. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  9956. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  9957. // SopNodeID instead. It exists only for internal usage by the builders.
  9958. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  9959. if id := m.sop_node; id != nil {
  9960. ids = append(ids, *id)
  9961. }
  9962. return
  9963. }
  9964. // ResetSopNode resets all changes to the "sop_node" edge.
  9965. func (m *MessageRecordsMutation) ResetSopNode() {
  9966. m.sop_node = nil
  9967. m.clearedsop_node = false
  9968. }
  9969. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  9970. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  9971. m.message_contact = &id
  9972. }
  9973. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  9974. func (m *MessageRecordsMutation) ClearMessageContact() {
  9975. m.clearedmessage_contact = true
  9976. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  9977. }
  9978. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  9979. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  9980. return m.ContactIDCleared() || m.clearedmessage_contact
  9981. }
  9982. // MessageContactID returns the "message_contact" edge ID in the mutation.
  9983. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  9984. if m.message_contact != nil {
  9985. return *m.message_contact, true
  9986. }
  9987. return
  9988. }
  9989. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  9990. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  9991. // MessageContactID instead. It exists only for internal usage by the builders.
  9992. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  9993. if id := m.message_contact; id != nil {
  9994. ids = append(ids, *id)
  9995. }
  9996. return
  9997. }
  9998. // ResetMessageContact resets all changes to the "message_contact" edge.
  9999. func (m *MessageRecordsMutation) ResetMessageContact() {
  10000. m.message_contact = nil
  10001. m.clearedmessage_contact = false
  10002. }
  10003. // Where appends a list predicates to the MessageRecordsMutation builder.
  10004. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  10005. m.predicates = append(m.predicates, ps...)
  10006. }
  10007. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  10008. // users can use type-assertion to append predicates that do not depend on any generated package.
  10009. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  10010. p := make([]predicate.MessageRecords, len(ps))
  10011. for i := range ps {
  10012. p[i] = ps[i]
  10013. }
  10014. m.Where(p...)
  10015. }
  10016. // Op returns the operation name.
  10017. func (m *MessageRecordsMutation) Op() Op {
  10018. return m.op
  10019. }
  10020. // SetOp allows setting the mutation operation.
  10021. func (m *MessageRecordsMutation) SetOp(op Op) {
  10022. m.op = op
  10023. }
  10024. // Type returns the node type of this mutation (MessageRecords).
  10025. func (m *MessageRecordsMutation) Type() string {
  10026. return m.typ
  10027. }
  10028. // Fields returns all fields that were changed during this mutation. Note that in
  10029. // order to get all numeric fields that were incremented/decremented, call
  10030. // AddedFields().
  10031. func (m *MessageRecordsMutation) Fields() []string {
  10032. fields := make([]string, 0, 17)
  10033. if m.created_at != nil {
  10034. fields = append(fields, messagerecords.FieldCreatedAt)
  10035. }
  10036. if m.updated_at != nil {
  10037. fields = append(fields, messagerecords.FieldUpdatedAt)
  10038. }
  10039. if m.status != nil {
  10040. fields = append(fields, messagerecords.FieldStatus)
  10041. }
  10042. if m.deleted_at != nil {
  10043. fields = append(fields, messagerecords.FieldDeletedAt)
  10044. }
  10045. if m.bot_wxid != nil {
  10046. fields = append(fields, messagerecords.FieldBotWxid)
  10047. }
  10048. if m.message_contact != nil {
  10049. fields = append(fields, messagerecords.FieldContactID)
  10050. }
  10051. if m.contact_type != nil {
  10052. fields = append(fields, messagerecords.FieldContactType)
  10053. }
  10054. if m.contact_wxid != nil {
  10055. fields = append(fields, messagerecords.FieldContactWxid)
  10056. }
  10057. if m.content_type != nil {
  10058. fields = append(fields, messagerecords.FieldContentType)
  10059. }
  10060. if m.content != nil {
  10061. fields = append(fields, messagerecords.FieldContent)
  10062. }
  10063. if m.meta != nil {
  10064. fields = append(fields, messagerecords.FieldMeta)
  10065. }
  10066. if m.error_detail != nil {
  10067. fields = append(fields, messagerecords.FieldErrorDetail)
  10068. }
  10069. if m.send_time != nil {
  10070. fields = append(fields, messagerecords.FieldSendTime)
  10071. }
  10072. if m.source_type != nil {
  10073. fields = append(fields, messagerecords.FieldSourceType)
  10074. }
  10075. if m.sop_stage != nil {
  10076. fields = append(fields, messagerecords.FieldSourceID)
  10077. }
  10078. if m.sop_node != nil {
  10079. fields = append(fields, messagerecords.FieldSubSourceID)
  10080. }
  10081. if m.organization_id != nil {
  10082. fields = append(fields, messagerecords.FieldOrganizationID)
  10083. }
  10084. return fields
  10085. }
  10086. // Field returns the value of a field with the given name. The second boolean
  10087. // return value indicates that this field was not set, or was not defined in the
  10088. // schema.
  10089. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  10090. switch name {
  10091. case messagerecords.FieldCreatedAt:
  10092. return m.CreatedAt()
  10093. case messagerecords.FieldUpdatedAt:
  10094. return m.UpdatedAt()
  10095. case messagerecords.FieldStatus:
  10096. return m.Status()
  10097. case messagerecords.FieldDeletedAt:
  10098. return m.DeletedAt()
  10099. case messagerecords.FieldBotWxid:
  10100. return m.BotWxid()
  10101. case messagerecords.FieldContactID:
  10102. return m.ContactID()
  10103. case messagerecords.FieldContactType:
  10104. return m.ContactType()
  10105. case messagerecords.FieldContactWxid:
  10106. return m.ContactWxid()
  10107. case messagerecords.FieldContentType:
  10108. return m.ContentType()
  10109. case messagerecords.FieldContent:
  10110. return m.Content()
  10111. case messagerecords.FieldMeta:
  10112. return m.Meta()
  10113. case messagerecords.FieldErrorDetail:
  10114. return m.ErrorDetail()
  10115. case messagerecords.FieldSendTime:
  10116. return m.SendTime()
  10117. case messagerecords.FieldSourceType:
  10118. return m.SourceType()
  10119. case messagerecords.FieldSourceID:
  10120. return m.SourceID()
  10121. case messagerecords.FieldSubSourceID:
  10122. return m.SubSourceID()
  10123. case messagerecords.FieldOrganizationID:
  10124. return m.OrganizationID()
  10125. }
  10126. return nil, false
  10127. }
  10128. // OldField returns the old value of the field from the database. An error is
  10129. // returned if the mutation operation is not UpdateOne, or the query to the
  10130. // database failed.
  10131. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10132. switch name {
  10133. case messagerecords.FieldCreatedAt:
  10134. return m.OldCreatedAt(ctx)
  10135. case messagerecords.FieldUpdatedAt:
  10136. return m.OldUpdatedAt(ctx)
  10137. case messagerecords.FieldStatus:
  10138. return m.OldStatus(ctx)
  10139. case messagerecords.FieldDeletedAt:
  10140. return m.OldDeletedAt(ctx)
  10141. case messagerecords.FieldBotWxid:
  10142. return m.OldBotWxid(ctx)
  10143. case messagerecords.FieldContactID:
  10144. return m.OldContactID(ctx)
  10145. case messagerecords.FieldContactType:
  10146. return m.OldContactType(ctx)
  10147. case messagerecords.FieldContactWxid:
  10148. return m.OldContactWxid(ctx)
  10149. case messagerecords.FieldContentType:
  10150. return m.OldContentType(ctx)
  10151. case messagerecords.FieldContent:
  10152. return m.OldContent(ctx)
  10153. case messagerecords.FieldMeta:
  10154. return m.OldMeta(ctx)
  10155. case messagerecords.FieldErrorDetail:
  10156. return m.OldErrorDetail(ctx)
  10157. case messagerecords.FieldSendTime:
  10158. return m.OldSendTime(ctx)
  10159. case messagerecords.FieldSourceType:
  10160. return m.OldSourceType(ctx)
  10161. case messagerecords.FieldSourceID:
  10162. return m.OldSourceID(ctx)
  10163. case messagerecords.FieldSubSourceID:
  10164. return m.OldSubSourceID(ctx)
  10165. case messagerecords.FieldOrganizationID:
  10166. return m.OldOrganizationID(ctx)
  10167. }
  10168. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  10169. }
  10170. // SetField sets the value of a field with the given name. It returns an error if
  10171. // the field is not defined in the schema, or if the type mismatched the field
  10172. // type.
  10173. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  10174. switch name {
  10175. case messagerecords.FieldCreatedAt:
  10176. v, ok := value.(time.Time)
  10177. if !ok {
  10178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10179. }
  10180. m.SetCreatedAt(v)
  10181. return nil
  10182. case messagerecords.FieldUpdatedAt:
  10183. v, ok := value.(time.Time)
  10184. if !ok {
  10185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10186. }
  10187. m.SetUpdatedAt(v)
  10188. return nil
  10189. case messagerecords.FieldStatus:
  10190. v, ok := value.(uint8)
  10191. if !ok {
  10192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10193. }
  10194. m.SetStatus(v)
  10195. return nil
  10196. case messagerecords.FieldDeletedAt:
  10197. v, ok := value.(time.Time)
  10198. if !ok {
  10199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10200. }
  10201. m.SetDeletedAt(v)
  10202. return nil
  10203. case messagerecords.FieldBotWxid:
  10204. v, ok := value.(string)
  10205. if !ok {
  10206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10207. }
  10208. m.SetBotWxid(v)
  10209. return nil
  10210. case messagerecords.FieldContactID:
  10211. v, ok := value.(uint64)
  10212. if !ok {
  10213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10214. }
  10215. m.SetContactID(v)
  10216. return nil
  10217. case messagerecords.FieldContactType:
  10218. v, ok := value.(int)
  10219. if !ok {
  10220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10221. }
  10222. m.SetContactType(v)
  10223. return nil
  10224. case messagerecords.FieldContactWxid:
  10225. v, ok := value.(string)
  10226. if !ok {
  10227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10228. }
  10229. m.SetContactWxid(v)
  10230. return nil
  10231. case messagerecords.FieldContentType:
  10232. v, ok := value.(int)
  10233. if !ok {
  10234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10235. }
  10236. m.SetContentType(v)
  10237. return nil
  10238. case messagerecords.FieldContent:
  10239. v, ok := value.(string)
  10240. if !ok {
  10241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10242. }
  10243. m.SetContent(v)
  10244. return nil
  10245. case messagerecords.FieldMeta:
  10246. v, ok := value.(custom_types.Meta)
  10247. if !ok {
  10248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10249. }
  10250. m.SetMeta(v)
  10251. return nil
  10252. case messagerecords.FieldErrorDetail:
  10253. v, ok := value.(string)
  10254. if !ok {
  10255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10256. }
  10257. m.SetErrorDetail(v)
  10258. return nil
  10259. case messagerecords.FieldSendTime:
  10260. v, ok := value.(time.Time)
  10261. if !ok {
  10262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10263. }
  10264. m.SetSendTime(v)
  10265. return nil
  10266. case messagerecords.FieldSourceType:
  10267. v, ok := value.(int)
  10268. if !ok {
  10269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10270. }
  10271. m.SetSourceType(v)
  10272. return nil
  10273. case messagerecords.FieldSourceID:
  10274. v, ok := value.(uint64)
  10275. if !ok {
  10276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10277. }
  10278. m.SetSourceID(v)
  10279. return nil
  10280. case messagerecords.FieldSubSourceID:
  10281. v, ok := value.(uint64)
  10282. if !ok {
  10283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10284. }
  10285. m.SetSubSourceID(v)
  10286. return nil
  10287. case messagerecords.FieldOrganizationID:
  10288. v, ok := value.(uint64)
  10289. if !ok {
  10290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10291. }
  10292. m.SetOrganizationID(v)
  10293. return nil
  10294. }
  10295. return fmt.Errorf("unknown MessageRecords field %s", name)
  10296. }
  10297. // AddedFields returns all numeric fields that were incremented/decremented during
  10298. // this mutation.
  10299. func (m *MessageRecordsMutation) AddedFields() []string {
  10300. var fields []string
  10301. if m.addstatus != nil {
  10302. fields = append(fields, messagerecords.FieldStatus)
  10303. }
  10304. if m.addcontact_type != nil {
  10305. fields = append(fields, messagerecords.FieldContactType)
  10306. }
  10307. if m.addcontent_type != nil {
  10308. fields = append(fields, messagerecords.FieldContentType)
  10309. }
  10310. if m.addsource_type != nil {
  10311. fields = append(fields, messagerecords.FieldSourceType)
  10312. }
  10313. if m.addorganization_id != nil {
  10314. fields = append(fields, messagerecords.FieldOrganizationID)
  10315. }
  10316. return fields
  10317. }
  10318. // AddedField returns the numeric value that was incremented/decremented on a field
  10319. // with the given name. The second boolean return value indicates that this field
  10320. // was not set, or was not defined in the schema.
  10321. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  10322. switch name {
  10323. case messagerecords.FieldStatus:
  10324. return m.AddedStatus()
  10325. case messagerecords.FieldContactType:
  10326. return m.AddedContactType()
  10327. case messagerecords.FieldContentType:
  10328. return m.AddedContentType()
  10329. case messagerecords.FieldSourceType:
  10330. return m.AddedSourceType()
  10331. case messagerecords.FieldOrganizationID:
  10332. return m.AddedOrganizationID()
  10333. }
  10334. return nil, false
  10335. }
  10336. // AddField adds the value to the field with the given name. It returns an error if
  10337. // the field is not defined in the schema, or if the type mismatched the field
  10338. // type.
  10339. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  10340. switch name {
  10341. case messagerecords.FieldStatus:
  10342. v, ok := value.(int8)
  10343. if !ok {
  10344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10345. }
  10346. m.AddStatus(v)
  10347. return nil
  10348. case messagerecords.FieldContactType:
  10349. v, ok := value.(int)
  10350. if !ok {
  10351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10352. }
  10353. m.AddContactType(v)
  10354. return nil
  10355. case messagerecords.FieldContentType:
  10356. v, ok := value.(int)
  10357. if !ok {
  10358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10359. }
  10360. m.AddContentType(v)
  10361. return nil
  10362. case messagerecords.FieldSourceType:
  10363. v, ok := value.(int)
  10364. if !ok {
  10365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10366. }
  10367. m.AddSourceType(v)
  10368. return nil
  10369. case messagerecords.FieldOrganizationID:
  10370. v, ok := value.(int64)
  10371. if !ok {
  10372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10373. }
  10374. m.AddOrganizationID(v)
  10375. return nil
  10376. }
  10377. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  10378. }
  10379. // ClearedFields returns all nullable fields that were cleared during this
  10380. // mutation.
  10381. func (m *MessageRecordsMutation) ClearedFields() []string {
  10382. var fields []string
  10383. if m.FieldCleared(messagerecords.FieldStatus) {
  10384. fields = append(fields, messagerecords.FieldStatus)
  10385. }
  10386. if m.FieldCleared(messagerecords.FieldDeletedAt) {
  10387. fields = append(fields, messagerecords.FieldDeletedAt)
  10388. }
  10389. if m.FieldCleared(messagerecords.FieldContactID) {
  10390. fields = append(fields, messagerecords.FieldContactID)
  10391. }
  10392. if m.FieldCleared(messagerecords.FieldMeta) {
  10393. fields = append(fields, messagerecords.FieldMeta)
  10394. }
  10395. if m.FieldCleared(messagerecords.FieldSendTime) {
  10396. fields = append(fields, messagerecords.FieldSendTime)
  10397. }
  10398. if m.FieldCleared(messagerecords.FieldSourceID) {
  10399. fields = append(fields, messagerecords.FieldSourceID)
  10400. }
  10401. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  10402. fields = append(fields, messagerecords.FieldSubSourceID)
  10403. }
  10404. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  10405. fields = append(fields, messagerecords.FieldOrganizationID)
  10406. }
  10407. return fields
  10408. }
  10409. // FieldCleared returns a boolean indicating if a field with the given name was
  10410. // cleared in this mutation.
  10411. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  10412. _, ok := m.clearedFields[name]
  10413. return ok
  10414. }
  10415. // ClearField clears the value of the field with the given name. It returns an
  10416. // error if the field is not defined in the schema.
  10417. func (m *MessageRecordsMutation) ClearField(name string) error {
  10418. switch name {
  10419. case messagerecords.FieldStatus:
  10420. m.ClearStatus()
  10421. return nil
  10422. case messagerecords.FieldDeletedAt:
  10423. m.ClearDeletedAt()
  10424. return nil
  10425. case messagerecords.FieldContactID:
  10426. m.ClearContactID()
  10427. return nil
  10428. case messagerecords.FieldMeta:
  10429. m.ClearMeta()
  10430. return nil
  10431. case messagerecords.FieldSendTime:
  10432. m.ClearSendTime()
  10433. return nil
  10434. case messagerecords.FieldSourceID:
  10435. m.ClearSourceID()
  10436. return nil
  10437. case messagerecords.FieldSubSourceID:
  10438. m.ClearSubSourceID()
  10439. return nil
  10440. case messagerecords.FieldOrganizationID:
  10441. m.ClearOrganizationID()
  10442. return nil
  10443. }
  10444. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  10445. }
  10446. // ResetField resets all changes in the mutation for the field with the given name.
  10447. // It returns an error if the field is not defined in the schema.
  10448. func (m *MessageRecordsMutation) ResetField(name string) error {
  10449. switch name {
  10450. case messagerecords.FieldCreatedAt:
  10451. m.ResetCreatedAt()
  10452. return nil
  10453. case messagerecords.FieldUpdatedAt:
  10454. m.ResetUpdatedAt()
  10455. return nil
  10456. case messagerecords.FieldStatus:
  10457. m.ResetStatus()
  10458. return nil
  10459. case messagerecords.FieldDeletedAt:
  10460. m.ResetDeletedAt()
  10461. return nil
  10462. case messagerecords.FieldBotWxid:
  10463. m.ResetBotWxid()
  10464. return nil
  10465. case messagerecords.FieldContactID:
  10466. m.ResetContactID()
  10467. return nil
  10468. case messagerecords.FieldContactType:
  10469. m.ResetContactType()
  10470. return nil
  10471. case messagerecords.FieldContactWxid:
  10472. m.ResetContactWxid()
  10473. return nil
  10474. case messagerecords.FieldContentType:
  10475. m.ResetContentType()
  10476. return nil
  10477. case messagerecords.FieldContent:
  10478. m.ResetContent()
  10479. return nil
  10480. case messagerecords.FieldMeta:
  10481. m.ResetMeta()
  10482. return nil
  10483. case messagerecords.FieldErrorDetail:
  10484. m.ResetErrorDetail()
  10485. return nil
  10486. case messagerecords.FieldSendTime:
  10487. m.ResetSendTime()
  10488. return nil
  10489. case messagerecords.FieldSourceType:
  10490. m.ResetSourceType()
  10491. return nil
  10492. case messagerecords.FieldSourceID:
  10493. m.ResetSourceID()
  10494. return nil
  10495. case messagerecords.FieldSubSourceID:
  10496. m.ResetSubSourceID()
  10497. return nil
  10498. case messagerecords.FieldOrganizationID:
  10499. m.ResetOrganizationID()
  10500. return nil
  10501. }
  10502. return fmt.Errorf("unknown MessageRecords field %s", name)
  10503. }
  10504. // AddedEdges returns all edge names that were set/added in this mutation.
  10505. func (m *MessageRecordsMutation) AddedEdges() []string {
  10506. edges := make([]string, 0, 3)
  10507. if m.sop_stage != nil {
  10508. edges = append(edges, messagerecords.EdgeSopStage)
  10509. }
  10510. if m.sop_node != nil {
  10511. edges = append(edges, messagerecords.EdgeSopNode)
  10512. }
  10513. if m.message_contact != nil {
  10514. edges = append(edges, messagerecords.EdgeMessageContact)
  10515. }
  10516. return edges
  10517. }
  10518. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10519. // name in this mutation.
  10520. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  10521. switch name {
  10522. case messagerecords.EdgeSopStage:
  10523. if id := m.sop_stage; id != nil {
  10524. return []ent.Value{*id}
  10525. }
  10526. case messagerecords.EdgeSopNode:
  10527. if id := m.sop_node; id != nil {
  10528. return []ent.Value{*id}
  10529. }
  10530. case messagerecords.EdgeMessageContact:
  10531. if id := m.message_contact; id != nil {
  10532. return []ent.Value{*id}
  10533. }
  10534. }
  10535. return nil
  10536. }
  10537. // RemovedEdges returns all edge names that were removed in this mutation.
  10538. func (m *MessageRecordsMutation) RemovedEdges() []string {
  10539. edges := make([]string, 0, 3)
  10540. return edges
  10541. }
  10542. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10543. // the given name in this mutation.
  10544. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  10545. return nil
  10546. }
  10547. // ClearedEdges returns all edge names that were cleared in this mutation.
  10548. func (m *MessageRecordsMutation) ClearedEdges() []string {
  10549. edges := make([]string, 0, 3)
  10550. if m.clearedsop_stage {
  10551. edges = append(edges, messagerecords.EdgeSopStage)
  10552. }
  10553. if m.clearedsop_node {
  10554. edges = append(edges, messagerecords.EdgeSopNode)
  10555. }
  10556. if m.clearedmessage_contact {
  10557. edges = append(edges, messagerecords.EdgeMessageContact)
  10558. }
  10559. return edges
  10560. }
  10561. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10562. // was cleared in this mutation.
  10563. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  10564. switch name {
  10565. case messagerecords.EdgeSopStage:
  10566. return m.clearedsop_stage
  10567. case messagerecords.EdgeSopNode:
  10568. return m.clearedsop_node
  10569. case messagerecords.EdgeMessageContact:
  10570. return m.clearedmessage_contact
  10571. }
  10572. return false
  10573. }
  10574. // ClearEdge clears the value of the edge with the given name. It returns an error
  10575. // if that edge is not defined in the schema.
  10576. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  10577. switch name {
  10578. case messagerecords.EdgeSopStage:
  10579. m.ClearSopStage()
  10580. return nil
  10581. case messagerecords.EdgeSopNode:
  10582. m.ClearSopNode()
  10583. return nil
  10584. case messagerecords.EdgeMessageContact:
  10585. m.ClearMessageContact()
  10586. return nil
  10587. }
  10588. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  10589. }
  10590. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10591. // It returns an error if the edge is not defined in the schema.
  10592. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  10593. switch name {
  10594. case messagerecords.EdgeSopStage:
  10595. m.ResetSopStage()
  10596. return nil
  10597. case messagerecords.EdgeSopNode:
  10598. m.ResetSopNode()
  10599. return nil
  10600. case messagerecords.EdgeMessageContact:
  10601. m.ResetMessageContact()
  10602. return nil
  10603. }
  10604. return fmt.Errorf("unknown MessageRecords edge %s", name)
  10605. }
  10606. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  10607. type MsgMutation struct {
  10608. config
  10609. op Op
  10610. typ string
  10611. id *uint64
  10612. created_at *time.Time
  10613. updated_at *time.Time
  10614. deleted_at *time.Time
  10615. status *uint8
  10616. addstatus *int8
  10617. fromwxid *string
  10618. toid *string
  10619. msgtype *int32
  10620. addmsgtype *int32
  10621. msg *string
  10622. batch_no *string
  10623. clearedFields map[string]struct{}
  10624. done bool
  10625. oldValue func(context.Context) (*Msg, error)
  10626. predicates []predicate.Msg
  10627. }
  10628. var _ ent.Mutation = (*MsgMutation)(nil)
  10629. // msgOption allows management of the mutation configuration using functional options.
  10630. type msgOption func(*MsgMutation)
  10631. // newMsgMutation creates new mutation for the Msg entity.
  10632. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  10633. m := &MsgMutation{
  10634. config: c,
  10635. op: op,
  10636. typ: TypeMsg,
  10637. clearedFields: make(map[string]struct{}),
  10638. }
  10639. for _, opt := range opts {
  10640. opt(m)
  10641. }
  10642. return m
  10643. }
  10644. // withMsgID sets the ID field of the mutation.
  10645. func withMsgID(id uint64) msgOption {
  10646. return func(m *MsgMutation) {
  10647. var (
  10648. err error
  10649. once sync.Once
  10650. value *Msg
  10651. )
  10652. m.oldValue = func(ctx context.Context) (*Msg, error) {
  10653. once.Do(func() {
  10654. if m.done {
  10655. err = errors.New("querying old values post mutation is not allowed")
  10656. } else {
  10657. value, err = m.Client().Msg.Get(ctx, id)
  10658. }
  10659. })
  10660. return value, err
  10661. }
  10662. m.id = &id
  10663. }
  10664. }
  10665. // withMsg sets the old Msg of the mutation.
  10666. func withMsg(node *Msg) msgOption {
  10667. return func(m *MsgMutation) {
  10668. m.oldValue = func(context.Context) (*Msg, error) {
  10669. return node, nil
  10670. }
  10671. m.id = &node.ID
  10672. }
  10673. }
  10674. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10675. // executed in a transaction (ent.Tx), a transactional client is returned.
  10676. func (m MsgMutation) Client() *Client {
  10677. client := &Client{config: m.config}
  10678. client.init()
  10679. return client
  10680. }
  10681. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10682. // it returns an error otherwise.
  10683. func (m MsgMutation) Tx() (*Tx, error) {
  10684. if _, ok := m.driver.(*txDriver); !ok {
  10685. return nil, errors.New("ent: mutation is not running in a transaction")
  10686. }
  10687. tx := &Tx{config: m.config}
  10688. tx.init()
  10689. return tx, nil
  10690. }
  10691. // SetID sets the value of the id field. Note that this
  10692. // operation is only accepted on creation of Msg entities.
  10693. func (m *MsgMutation) SetID(id uint64) {
  10694. m.id = &id
  10695. }
  10696. // ID returns the ID value in the mutation. Note that the ID is only available
  10697. // if it was provided to the builder or after it was returned from the database.
  10698. func (m *MsgMutation) ID() (id uint64, exists bool) {
  10699. if m.id == nil {
  10700. return
  10701. }
  10702. return *m.id, true
  10703. }
  10704. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10705. // That means, if the mutation is applied within a transaction with an isolation level such
  10706. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10707. // or updated by the mutation.
  10708. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  10709. switch {
  10710. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10711. id, exists := m.ID()
  10712. if exists {
  10713. return []uint64{id}, nil
  10714. }
  10715. fallthrough
  10716. case m.op.Is(OpUpdate | OpDelete):
  10717. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  10718. default:
  10719. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10720. }
  10721. }
  10722. // SetCreatedAt sets the "created_at" field.
  10723. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  10724. m.created_at = &t
  10725. }
  10726. // CreatedAt returns the value of the "created_at" field in the mutation.
  10727. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  10728. v := m.created_at
  10729. if v == nil {
  10730. return
  10731. }
  10732. return *v, true
  10733. }
  10734. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  10735. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10737. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10738. if !m.op.Is(OpUpdateOne) {
  10739. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10740. }
  10741. if m.id == nil || m.oldValue == nil {
  10742. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10743. }
  10744. oldValue, err := m.oldValue(ctx)
  10745. if err != nil {
  10746. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10747. }
  10748. return oldValue.CreatedAt, nil
  10749. }
  10750. // ResetCreatedAt resets all changes to the "created_at" field.
  10751. func (m *MsgMutation) ResetCreatedAt() {
  10752. m.created_at = nil
  10753. }
  10754. // SetUpdatedAt sets the "updated_at" field.
  10755. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  10756. m.updated_at = &t
  10757. }
  10758. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10759. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  10760. v := m.updated_at
  10761. if v == nil {
  10762. return
  10763. }
  10764. return *v, true
  10765. }
  10766. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  10767. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10768. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10769. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10770. if !m.op.Is(OpUpdateOne) {
  10771. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10772. }
  10773. if m.id == nil || m.oldValue == nil {
  10774. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10775. }
  10776. oldValue, err := m.oldValue(ctx)
  10777. if err != nil {
  10778. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10779. }
  10780. return oldValue.UpdatedAt, nil
  10781. }
  10782. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10783. func (m *MsgMutation) ResetUpdatedAt() {
  10784. m.updated_at = nil
  10785. }
  10786. // SetDeletedAt sets the "deleted_at" field.
  10787. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  10788. m.deleted_at = &t
  10789. }
  10790. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10791. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  10792. v := m.deleted_at
  10793. if v == nil {
  10794. return
  10795. }
  10796. return *v, true
  10797. }
  10798. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  10799. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10801. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10802. if !m.op.Is(OpUpdateOne) {
  10803. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10804. }
  10805. if m.id == nil || m.oldValue == nil {
  10806. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10807. }
  10808. oldValue, err := m.oldValue(ctx)
  10809. if err != nil {
  10810. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10811. }
  10812. return oldValue.DeletedAt, nil
  10813. }
  10814. // ClearDeletedAt clears the value of the "deleted_at" field.
  10815. func (m *MsgMutation) ClearDeletedAt() {
  10816. m.deleted_at = nil
  10817. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  10818. }
  10819. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10820. func (m *MsgMutation) DeletedAtCleared() bool {
  10821. _, ok := m.clearedFields[msg.FieldDeletedAt]
  10822. return ok
  10823. }
  10824. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10825. func (m *MsgMutation) ResetDeletedAt() {
  10826. m.deleted_at = nil
  10827. delete(m.clearedFields, msg.FieldDeletedAt)
  10828. }
  10829. // SetStatus sets the "status" field.
  10830. func (m *MsgMutation) SetStatus(u uint8) {
  10831. m.status = &u
  10832. m.addstatus = nil
  10833. }
  10834. // Status returns the value of the "status" field in the mutation.
  10835. func (m *MsgMutation) Status() (r uint8, exists bool) {
  10836. v := m.status
  10837. if v == nil {
  10838. return
  10839. }
  10840. return *v, true
  10841. }
  10842. // OldStatus returns the old "status" field's value of the Msg entity.
  10843. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10845. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  10846. if !m.op.Is(OpUpdateOne) {
  10847. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10848. }
  10849. if m.id == nil || m.oldValue == nil {
  10850. return v, errors.New("OldStatus requires an ID field in the mutation")
  10851. }
  10852. oldValue, err := m.oldValue(ctx)
  10853. if err != nil {
  10854. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10855. }
  10856. return oldValue.Status, nil
  10857. }
  10858. // AddStatus adds u to the "status" field.
  10859. func (m *MsgMutation) AddStatus(u int8) {
  10860. if m.addstatus != nil {
  10861. *m.addstatus += u
  10862. } else {
  10863. m.addstatus = &u
  10864. }
  10865. }
  10866. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10867. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  10868. v := m.addstatus
  10869. if v == nil {
  10870. return
  10871. }
  10872. return *v, true
  10873. }
  10874. // ClearStatus clears the value of the "status" field.
  10875. func (m *MsgMutation) ClearStatus() {
  10876. m.status = nil
  10877. m.addstatus = nil
  10878. m.clearedFields[msg.FieldStatus] = struct{}{}
  10879. }
  10880. // StatusCleared returns if the "status" field was cleared in this mutation.
  10881. func (m *MsgMutation) StatusCleared() bool {
  10882. _, ok := m.clearedFields[msg.FieldStatus]
  10883. return ok
  10884. }
  10885. // ResetStatus resets all changes to the "status" field.
  10886. func (m *MsgMutation) ResetStatus() {
  10887. m.status = nil
  10888. m.addstatus = nil
  10889. delete(m.clearedFields, msg.FieldStatus)
  10890. }
  10891. // SetFromwxid sets the "fromwxid" field.
  10892. func (m *MsgMutation) SetFromwxid(s string) {
  10893. m.fromwxid = &s
  10894. }
  10895. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  10896. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  10897. v := m.fromwxid
  10898. if v == nil {
  10899. return
  10900. }
  10901. return *v, true
  10902. }
  10903. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  10904. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10906. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  10907. if !m.op.Is(OpUpdateOne) {
  10908. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  10909. }
  10910. if m.id == nil || m.oldValue == nil {
  10911. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  10912. }
  10913. oldValue, err := m.oldValue(ctx)
  10914. if err != nil {
  10915. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  10916. }
  10917. return oldValue.Fromwxid, nil
  10918. }
  10919. // ClearFromwxid clears the value of the "fromwxid" field.
  10920. func (m *MsgMutation) ClearFromwxid() {
  10921. m.fromwxid = nil
  10922. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  10923. }
  10924. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  10925. func (m *MsgMutation) FromwxidCleared() bool {
  10926. _, ok := m.clearedFields[msg.FieldFromwxid]
  10927. return ok
  10928. }
  10929. // ResetFromwxid resets all changes to the "fromwxid" field.
  10930. func (m *MsgMutation) ResetFromwxid() {
  10931. m.fromwxid = nil
  10932. delete(m.clearedFields, msg.FieldFromwxid)
  10933. }
  10934. // SetToid sets the "toid" field.
  10935. func (m *MsgMutation) SetToid(s string) {
  10936. m.toid = &s
  10937. }
  10938. // Toid returns the value of the "toid" field in the mutation.
  10939. func (m *MsgMutation) Toid() (r string, exists bool) {
  10940. v := m.toid
  10941. if v == nil {
  10942. return
  10943. }
  10944. return *v, true
  10945. }
  10946. // OldToid returns the old "toid" field's value of the Msg entity.
  10947. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10949. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  10950. if !m.op.Is(OpUpdateOne) {
  10951. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  10952. }
  10953. if m.id == nil || m.oldValue == nil {
  10954. return v, errors.New("OldToid requires an ID field in the mutation")
  10955. }
  10956. oldValue, err := m.oldValue(ctx)
  10957. if err != nil {
  10958. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  10959. }
  10960. return oldValue.Toid, nil
  10961. }
  10962. // ClearToid clears the value of the "toid" field.
  10963. func (m *MsgMutation) ClearToid() {
  10964. m.toid = nil
  10965. m.clearedFields[msg.FieldToid] = struct{}{}
  10966. }
  10967. // ToidCleared returns if the "toid" field was cleared in this mutation.
  10968. func (m *MsgMutation) ToidCleared() bool {
  10969. _, ok := m.clearedFields[msg.FieldToid]
  10970. return ok
  10971. }
  10972. // ResetToid resets all changes to the "toid" field.
  10973. func (m *MsgMutation) ResetToid() {
  10974. m.toid = nil
  10975. delete(m.clearedFields, msg.FieldToid)
  10976. }
  10977. // SetMsgtype sets the "msgtype" field.
  10978. func (m *MsgMutation) SetMsgtype(i int32) {
  10979. m.msgtype = &i
  10980. m.addmsgtype = nil
  10981. }
  10982. // Msgtype returns the value of the "msgtype" field in the mutation.
  10983. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  10984. v := m.msgtype
  10985. if v == nil {
  10986. return
  10987. }
  10988. return *v, true
  10989. }
  10990. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  10991. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10992. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10993. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  10994. if !m.op.Is(OpUpdateOne) {
  10995. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  10996. }
  10997. if m.id == nil || m.oldValue == nil {
  10998. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  10999. }
  11000. oldValue, err := m.oldValue(ctx)
  11001. if err != nil {
  11002. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  11003. }
  11004. return oldValue.Msgtype, nil
  11005. }
  11006. // AddMsgtype adds i to the "msgtype" field.
  11007. func (m *MsgMutation) AddMsgtype(i int32) {
  11008. if m.addmsgtype != nil {
  11009. *m.addmsgtype += i
  11010. } else {
  11011. m.addmsgtype = &i
  11012. }
  11013. }
  11014. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  11015. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  11016. v := m.addmsgtype
  11017. if v == nil {
  11018. return
  11019. }
  11020. return *v, true
  11021. }
  11022. // ClearMsgtype clears the value of the "msgtype" field.
  11023. func (m *MsgMutation) ClearMsgtype() {
  11024. m.msgtype = nil
  11025. m.addmsgtype = nil
  11026. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  11027. }
  11028. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  11029. func (m *MsgMutation) MsgtypeCleared() bool {
  11030. _, ok := m.clearedFields[msg.FieldMsgtype]
  11031. return ok
  11032. }
  11033. // ResetMsgtype resets all changes to the "msgtype" field.
  11034. func (m *MsgMutation) ResetMsgtype() {
  11035. m.msgtype = nil
  11036. m.addmsgtype = nil
  11037. delete(m.clearedFields, msg.FieldMsgtype)
  11038. }
  11039. // SetMsg sets the "msg" field.
  11040. func (m *MsgMutation) SetMsg(s string) {
  11041. m.msg = &s
  11042. }
  11043. // Msg returns the value of the "msg" field in the mutation.
  11044. func (m *MsgMutation) Msg() (r string, exists bool) {
  11045. v := m.msg
  11046. if v == nil {
  11047. return
  11048. }
  11049. return *v, true
  11050. }
  11051. // OldMsg returns the old "msg" field's value of the Msg entity.
  11052. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11054. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  11055. if !m.op.Is(OpUpdateOne) {
  11056. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  11057. }
  11058. if m.id == nil || m.oldValue == nil {
  11059. return v, errors.New("OldMsg requires an ID field in the mutation")
  11060. }
  11061. oldValue, err := m.oldValue(ctx)
  11062. if err != nil {
  11063. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  11064. }
  11065. return oldValue.Msg, nil
  11066. }
  11067. // ClearMsg clears the value of the "msg" field.
  11068. func (m *MsgMutation) ClearMsg() {
  11069. m.msg = nil
  11070. m.clearedFields[msg.FieldMsg] = struct{}{}
  11071. }
  11072. // MsgCleared returns if the "msg" field was cleared in this mutation.
  11073. func (m *MsgMutation) MsgCleared() bool {
  11074. _, ok := m.clearedFields[msg.FieldMsg]
  11075. return ok
  11076. }
  11077. // ResetMsg resets all changes to the "msg" field.
  11078. func (m *MsgMutation) ResetMsg() {
  11079. m.msg = nil
  11080. delete(m.clearedFields, msg.FieldMsg)
  11081. }
  11082. // SetBatchNo sets the "batch_no" field.
  11083. func (m *MsgMutation) SetBatchNo(s string) {
  11084. m.batch_no = &s
  11085. }
  11086. // BatchNo returns the value of the "batch_no" field in the mutation.
  11087. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  11088. v := m.batch_no
  11089. if v == nil {
  11090. return
  11091. }
  11092. return *v, true
  11093. }
  11094. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  11095. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11097. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  11098. if !m.op.Is(OpUpdateOne) {
  11099. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  11100. }
  11101. if m.id == nil || m.oldValue == nil {
  11102. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  11103. }
  11104. oldValue, err := m.oldValue(ctx)
  11105. if err != nil {
  11106. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  11107. }
  11108. return oldValue.BatchNo, nil
  11109. }
  11110. // ClearBatchNo clears the value of the "batch_no" field.
  11111. func (m *MsgMutation) ClearBatchNo() {
  11112. m.batch_no = nil
  11113. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  11114. }
  11115. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  11116. func (m *MsgMutation) BatchNoCleared() bool {
  11117. _, ok := m.clearedFields[msg.FieldBatchNo]
  11118. return ok
  11119. }
  11120. // ResetBatchNo resets all changes to the "batch_no" field.
  11121. func (m *MsgMutation) ResetBatchNo() {
  11122. m.batch_no = nil
  11123. delete(m.clearedFields, msg.FieldBatchNo)
  11124. }
  11125. // Where appends a list predicates to the MsgMutation builder.
  11126. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  11127. m.predicates = append(m.predicates, ps...)
  11128. }
  11129. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  11130. // users can use type-assertion to append predicates that do not depend on any generated package.
  11131. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  11132. p := make([]predicate.Msg, len(ps))
  11133. for i := range ps {
  11134. p[i] = ps[i]
  11135. }
  11136. m.Where(p...)
  11137. }
  11138. // Op returns the operation name.
  11139. func (m *MsgMutation) Op() Op {
  11140. return m.op
  11141. }
  11142. // SetOp allows setting the mutation operation.
  11143. func (m *MsgMutation) SetOp(op Op) {
  11144. m.op = op
  11145. }
  11146. // Type returns the node type of this mutation (Msg).
  11147. func (m *MsgMutation) Type() string {
  11148. return m.typ
  11149. }
  11150. // Fields returns all fields that were changed during this mutation. Note that in
  11151. // order to get all numeric fields that were incremented/decremented, call
  11152. // AddedFields().
  11153. func (m *MsgMutation) Fields() []string {
  11154. fields := make([]string, 0, 9)
  11155. if m.created_at != nil {
  11156. fields = append(fields, msg.FieldCreatedAt)
  11157. }
  11158. if m.updated_at != nil {
  11159. fields = append(fields, msg.FieldUpdatedAt)
  11160. }
  11161. if m.deleted_at != nil {
  11162. fields = append(fields, msg.FieldDeletedAt)
  11163. }
  11164. if m.status != nil {
  11165. fields = append(fields, msg.FieldStatus)
  11166. }
  11167. if m.fromwxid != nil {
  11168. fields = append(fields, msg.FieldFromwxid)
  11169. }
  11170. if m.toid != nil {
  11171. fields = append(fields, msg.FieldToid)
  11172. }
  11173. if m.msgtype != nil {
  11174. fields = append(fields, msg.FieldMsgtype)
  11175. }
  11176. if m.msg != nil {
  11177. fields = append(fields, msg.FieldMsg)
  11178. }
  11179. if m.batch_no != nil {
  11180. fields = append(fields, msg.FieldBatchNo)
  11181. }
  11182. return fields
  11183. }
  11184. // Field returns the value of a field with the given name. The second boolean
  11185. // return value indicates that this field was not set, or was not defined in the
  11186. // schema.
  11187. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  11188. switch name {
  11189. case msg.FieldCreatedAt:
  11190. return m.CreatedAt()
  11191. case msg.FieldUpdatedAt:
  11192. return m.UpdatedAt()
  11193. case msg.FieldDeletedAt:
  11194. return m.DeletedAt()
  11195. case msg.FieldStatus:
  11196. return m.Status()
  11197. case msg.FieldFromwxid:
  11198. return m.Fromwxid()
  11199. case msg.FieldToid:
  11200. return m.Toid()
  11201. case msg.FieldMsgtype:
  11202. return m.Msgtype()
  11203. case msg.FieldMsg:
  11204. return m.Msg()
  11205. case msg.FieldBatchNo:
  11206. return m.BatchNo()
  11207. }
  11208. return nil, false
  11209. }
  11210. // OldField returns the old value of the field from the database. An error is
  11211. // returned if the mutation operation is not UpdateOne, or the query to the
  11212. // database failed.
  11213. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11214. switch name {
  11215. case msg.FieldCreatedAt:
  11216. return m.OldCreatedAt(ctx)
  11217. case msg.FieldUpdatedAt:
  11218. return m.OldUpdatedAt(ctx)
  11219. case msg.FieldDeletedAt:
  11220. return m.OldDeletedAt(ctx)
  11221. case msg.FieldStatus:
  11222. return m.OldStatus(ctx)
  11223. case msg.FieldFromwxid:
  11224. return m.OldFromwxid(ctx)
  11225. case msg.FieldToid:
  11226. return m.OldToid(ctx)
  11227. case msg.FieldMsgtype:
  11228. return m.OldMsgtype(ctx)
  11229. case msg.FieldMsg:
  11230. return m.OldMsg(ctx)
  11231. case msg.FieldBatchNo:
  11232. return m.OldBatchNo(ctx)
  11233. }
  11234. return nil, fmt.Errorf("unknown Msg field %s", name)
  11235. }
  11236. // SetField sets the value of a field with the given name. It returns an error if
  11237. // the field is not defined in the schema, or if the type mismatched the field
  11238. // type.
  11239. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  11240. switch name {
  11241. case msg.FieldCreatedAt:
  11242. v, ok := value.(time.Time)
  11243. if !ok {
  11244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11245. }
  11246. m.SetCreatedAt(v)
  11247. return nil
  11248. case msg.FieldUpdatedAt:
  11249. v, ok := value.(time.Time)
  11250. if !ok {
  11251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11252. }
  11253. m.SetUpdatedAt(v)
  11254. return nil
  11255. case msg.FieldDeletedAt:
  11256. v, ok := value.(time.Time)
  11257. if !ok {
  11258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11259. }
  11260. m.SetDeletedAt(v)
  11261. return nil
  11262. case msg.FieldStatus:
  11263. v, ok := value.(uint8)
  11264. if !ok {
  11265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11266. }
  11267. m.SetStatus(v)
  11268. return nil
  11269. case msg.FieldFromwxid:
  11270. v, ok := value.(string)
  11271. if !ok {
  11272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11273. }
  11274. m.SetFromwxid(v)
  11275. return nil
  11276. case msg.FieldToid:
  11277. v, ok := value.(string)
  11278. if !ok {
  11279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11280. }
  11281. m.SetToid(v)
  11282. return nil
  11283. case msg.FieldMsgtype:
  11284. v, ok := value.(int32)
  11285. if !ok {
  11286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11287. }
  11288. m.SetMsgtype(v)
  11289. return nil
  11290. case msg.FieldMsg:
  11291. v, ok := value.(string)
  11292. if !ok {
  11293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11294. }
  11295. m.SetMsg(v)
  11296. return nil
  11297. case msg.FieldBatchNo:
  11298. v, ok := value.(string)
  11299. if !ok {
  11300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11301. }
  11302. m.SetBatchNo(v)
  11303. return nil
  11304. }
  11305. return fmt.Errorf("unknown Msg field %s", name)
  11306. }
  11307. // AddedFields returns all numeric fields that were incremented/decremented during
  11308. // this mutation.
  11309. func (m *MsgMutation) AddedFields() []string {
  11310. var fields []string
  11311. if m.addstatus != nil {
  11312. fields = append(fields, msg.FieldStatus)
  11313. }
  11314. if m.addmsgtype != nil {
  11315. fields = append(fields, msg.FieldMsgtype)
  11316. }
  11317. return fields
  11318. }
  11319. // AddedField returns the numeric value that was incremented/decremented on a field
  11320. // with the given name. The second boolean return value indicates that this field
  11321. // was not set, or was not defined in the schema.
  11322. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  11323. switch name {
  11324. case msg.FieldStatus:
  11325. return m.AddedStatus()
  11326. case msg.FieldMsgtype:
  11327. return m.AddedMsgtype()
  11328. }
  11329. return nil, false
  11330. }
  11331. // AddField adds the value to the field with the given name. It returns an error if
  11332. // the field is not defined in the schema, or if the type mismatched the field
  11333. // type.
  11334. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  11335. switch name {
  11336. case msg.FieldStatus:
  11337. v, ok := value.(int8)
  11338. if !ok {
  11339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11340. }
  11341. m.AddStatus(v)
  11342. return nil
  11343. case msg.FieldMsgtype:
  11344. v, ok := value.(int32)
  11345. if !ok {
  11346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11347. }
  11348. m.AddMsgtype(v)
  11349. return nil
  11350. }
  11351. return fmt.Errorf("unknown Msg numeric field %s", name)
  11352. }
  11353. // ClearedFields returns all nullable fields that were cleared during this
  11354. // mutation.
  11355. func (m *MsgMutation) ClearedFields() []string {
  11356. var fields []string
  11357. if m.FieldCleared(msg.FieldDeletedAt) {
  11358. fields = append(fields, msg.FieldDeletedAt)
  11359. }
  11360. if m.FieldCleared(msg.FieldStatus) {
  11361. fields = append(fields, msg.FieldStatus)
  11362. }
  11363. if m.FieldCleared(msg.FieldFromwxid) {
  11364. fields = append(fields, msg.FieldFromwxid)
  11365. }
  11366. if m.FieldCleared(msg.FieldToid) {
  11367. fields = append(fields, msg.FieldToid)
  11368. }
  11369. if m.FieldCleared(msg.FieldMsgtype) {
  11370. fields = append(fields, msg.FieldMsgtype)
  11371. }
  11372. if m.FieldCleared(msg.FieldMsg) {
  11373. fields = append(fields, msg.FieldMsg)
  11374. }
  11375. if m.FieldCleared(msg.FieldBatchNo) {
  11376. fields = append(fields, msg.FieldBatchNo)
  11377. }
  11378. return fields
  11379. }
  11380. // FieldCleared returns a boolean indicating if a field with the given name was
  11381. // cleared in this mutation.
  11382. func (m *MsgMutation) FieldCleared(name string) bool {
  11383. _, ok := m.clearedFields[name]
  11384. return ok
  11385. }
  11386. // ClearField clears the value of the field with the given name. It returns an
  11387. // error if the field is not defined in the schema.
  11388. func (m *MsgMutation) ClearField(name string) error {
  11389. switch name {
  11390. case msg.FieldDeletedAt:
  11391. m.ClearDeletedAt()
  11392. return nil
  11393. case msg.FieldStatus:
  11394. m.ClearStatus()
  11395. return nil
  11396. case msg.FieldFromwxid:
  11397. m.ClearFromwxid()
  11398. return nil
  11399. case msg.FieldToid:
  11400. m.ClearToid()
  11401. return nil
  11402. case msg.FieldMsgtype:
  11403. m.ClearMsgtype()
  11404. return nil
  11405. case msg.FieldMsg:
  11406. m.ClearMsg()
  11407. return nil
  11408. case msg.FieldBatchNo:
  11409. m.ClearBatchNo()
  11410. return nil
  11411. }
  11412. return fmt.Errorf("unknown Msg nullable field %s", name)
  11413. }
  11414. // ResetField resets all changes in the mutation for the field with the given name.
  11415. // It returns an error if the field is not defined in the schema.
  11416. func (m *MsgMutation) ResetField(name string) error {
  11417. switch name {
  11418. case msg.FieldCreatedAt:
  11419. m.ResetCreatedAt()
  11420. return nil
  11421. case msg.FieldUpdatedAt:
  11422. m.ResetUpdatedAt()
  11423. return nil
  11424. case msg.FieldDeletedAt:
  11425. m.ResetDeletedAt()
  11426. return nil
  11427. case msg.FieldStatus:
  11428. m.ResetStatus()
  11429. return nil
  11430. case msg.FieldFromwxid:
  11431. m.ResetFromwxid()
  11432. return nil
  11433. case msg.FieldToid:
  11434. m.ResetToid()
  11435. return nil
  11436. case msg.FieldMsgtype:
  11437. m.ResetMsgtype()
  11438. return nil
  11439. case msg.FieldMsg:
  11440. m.ResetMsg()
  11441. return nil
  11442. case msg.FieldBatchNo:
  11443. m.ResetBatchNo()
  11444. return nil
  11445. }
  11446. return fmt.Errorf("unknown Msg field %s", name)
  11447. }
  11448. // AddedEdges returns all edge names that were set/added in this mutation.
  11449. func (m *MsgMutation) AddedEdges() []string {
  11450. edges := make([]string, 0, 0)
  11451. return edges
  11452. }
  11453. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11454. // name in this mutation.
  11455. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  11456. return nil
  11457. }
  11458. // RemovedEdges returns all edge names that were removed in this mutation.
  11459. func (m *MsgMutation) RemovedEdges() []string {
  11460. edges := make([]string, 0, 0)
  11461. return edges
  11462. }
  11463. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11464. // the given name in this mutation.
  11465. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  11466. return nil
  11467. }
  11468. // ClearedEdges returns all edge names that were cleared in this mutation.
  11469. func (m *MsgMutation) ClearedEdges() []string {
  11470. edges := make([]string, 0, 0)
  11471. return edges
  11472. }
  11473. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11474. // was cleared in this mutation.
  11475. func (m *MsgMutation) EdgeCleared(name string) bool {
  11476. return false
  11477. }
  11478. // ClearEdge clears the value of the edge with the given name. It returns an error
  11479. // if that edge is not defined in the schema.
  11480. func (m *MsgMutation) ClearEdge(name string) error {
  11481. return fmt.Errorf("unknown Msg unique edge %s", name)
  11482. }
  11483. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11484. // It returns an error if the edge is not defined in the schema.
  11485. func (m *MsgMutation) ResetEdge(name string) error {
  11486. return fmt.Errorf("unknown Msg edge %s", name)
  11487. }
  11488. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  11489. type ServerMutation struct {
  11490. config
  11491. op Op
  11492. typ string
  11493. id *uint64
  11494. created_at *time.Time
  11495. updated_at *time.Time
  11496. status *uint8
  11497. addstatus *int8
  11498. deleted_at *time.Time
  11499. name *string
  11500. public_ip *string
  11501. private_ip *string
  11502. admin_port *string
  11503. clearedFields map[string]struct{}
  11504. wxs map[uint64]struct{}
  11505. removedwxs map[uint64]struct{}
  11506. clearedwxs bool
  11507. done bool
  11508. oldValue func(context.Context) (*Server, error)
  11509. predicates []predicate.Server
  11510. }
  11511. var _ ent.Mutation = (*ServerMutation)(nil)
  11512. // serverOption allows management of the mutation configuration using functional options.
  11513. type serverOption func(*ServerMutation)
  11514. // newServerMutation creates new mutation for the Server entity.
  11515. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  11516. m := &ServerMutation{
  11517. config: c,
  11518. op: op,
  11519. typ: TypeServer,
  11520. clearedFields: make(map[string]struct{}),
  11521. }
  11522. for _, opt := range opts {
  11523. opt(m)
  11524. }
  11525. return m
  11526. }
  11527. // withServerID sets the ID field of the mutation.
  11528. func withServerID(id uint64) serverOption {
  11529. return func(m *ServerMutation) {
  11530. var (
  11531. err error
  11532. once sync.Once
  11533. value *Server
  11534. )
  11535. m.oldValue = func(ctx context.Context) (*Server, error) {
  11536. once.Do(func() {
  11537. if m.done {
  11538. err = errors.New("querying old values post mutation is not allowed")
  11539. } else {
  11540. value, err = m.Client().Server.Get(ctx, id)
  11541. }
  11542. })
  11543. return value, err
  11544. }
  11545. m.id = &id
  11546. }
  11547. }
  11548. // withServer sets the old Server of the mutation.
  11549. func withServer(node *Server) serverOption {
  11550. return func(m *ServerMutation) {
  11551. m.oldValue = func(context.Context) (*Server, error) {
  11552. return node, nil
  11553. }
  11554. m.id = &node.ID
  11555. }
  11556. }
  11557. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11558. // executed in a transaction (ent.Tx), a transactional client is returned.
  11559. func (m ServerMutation) Client() *Client {
  11560. client := &Client{config: m.config}
  11561. client.init()
  11562. return client
  11563. }
  11564. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11565. // it returns an error otherwise.
  11566. func (m ServerMutation) Tx() (*Tx, error) {
  11567. if _, ok := m.driver.(*txDriver); !ok {
  11568. return nil, errors.New("ent: mutation is not running in a transaction")
  11569. }
  11570. tx := &Tx{config: m.config}
  11571. tx.init()
  11572. return tx, nil
  11573. }
  11574. // SetID sets the value of the id field. Note that this
  11575. // operation is only accepted on creation of Server entities.
  11576. func (m *ServerMutation) SetID(id uint64) {
  11577. m.id = &id
  11578. }
  11579. // ID returns the ID value in the mutation. Note that the ID is only available
  11580. // if it was provided to the builder or after it was returned from the database.
  11581. func (m *ServerMutation) ID() (id uint64, exists bool) {
  11582. if m.id == nil {
  11583. return
  11584. }
  11585. return *m.id, true
  11586. }
  11587. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11588. // That means, if the mutation is applied within a transaction with an isolation level such
  11589. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11590. // or updated by the mutation.
  11591. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  11592. switch {
  11593. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11594. id, exists := m.ID()
  11595. if exists {
  11596. return []uint64{id}, nil
  11597. }
  11598. fallthrough
  11599. case m.op.Is(OpUpdate | OpDelete):
  11600. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  11601. default:
  11602. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11603. }
  11604. }
  11605. // SetCreatedAt sets the "created_at" field.
  11606. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  11607. m.created_at = &t
  11608. }
  11609. // CreatedAt returns the value of the "created_at" field in the mutation.
  11610. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  11611. v := m.created_at
  11612. if v == nil {
  11613. return
  11614. }
  11615. return *v, true
  11616. }
  11617. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  11618. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11620. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11621. if !m.op.Is(OpUpdateOne) {
  11622. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11623. }
  11624. if m.id == nil || m.oldValue == nil {
  11625. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11626. }
  11627. oldValue, err := m.oldValue(ctx)
  11628. if err != nil {
  11629. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11630. }
  11631. return oldValue.CreatedAt, nil
  11632. }
  11633. // ResetCreatedAt resets all changes to the "created_at" field.
  11634. func (m *ServerMutation) ResetCreatedAt() {
  11635. m.created_at = nil
  11636. }
  11637. // SetUpdatedAt sets the "updated_at" field.
  11638. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  11639. m.updated_at = &t
  11640. }
  11641. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11642. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  11643. v := m.updated_at
  11644. if v == nil {
  11645. return
  11646. }
  11647. return *v, true
  11648. }
  11649. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  11650. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11652. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11653. if !m.op.Is(OpUpdateOne) {
  11654. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11655. }
  11656. if m.id == nil || m.oldValue == nil {
  11657. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11658. }
  11659. oldValue, err := m.oldValue(ctx)
  11660. if err != nil {
  11661. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11662. }
  11663. return oldValue.UpdatedAt, nil
  11664. }
  11665. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11666. func (m *ServerMutation) ResetUpdatedAt() {
  11667. m.updated_at = nil
  11668. }
  11669. // SetStatus sets the "status" field.
  11670. func (m *ServerMutation) SetStatus(u uint8) {
  11671. m.status = &u
  11672. m.addstatus = nil
  11673. }
  11674. // Status returns the value of the "status" field in the mutation.
  11675. func (m *ServerMutation) Status() (r uint8, exists bool) {
  11676. v := m.status
  11677. if v == nil {
  11678. return
  11679. }
  11680. return *v, true
  11681. }
  11682. // OldStatus returns the old "status" field's value of the Server entity.
  11683. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11685. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11686. if !m.op.Is(OpUpdateOne) {
  11687. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11688. }
  11689. if m.id == nil || m.oldValue == nil {
  11690. return v, errors.New("OldStatus requires an ID field in the mutation")
  11691. }
  11692. oldValue, err := m.oldValue(ctx)
  11693. if err != nil {
  11694. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11695. }
  11696. return oldValue.Status, nil
  11697. }
  11698. // AddStatus adds u to the "status" field.
  11699. func (m *ServerMutation) AddStatus(u int8) {
  11700. if m.addstatus != nil {
  11701. *m.addstatus += u
  11702. } else {
  11703. m.addstatus = &u
  11704. }
  11705. }
  11706. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11707. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  11708. v := m.addstatus
  11709. if v == nil {
  11710. return
  11711. }
  11712. return *v, true
  11713. }
  11714. // ClearStatus clears the value of the "status" field.
  11715. func (m *ServerMutation) ClearStatus() {
  11716. m.status = nil
  11717. m.addstatus = nil
  11718. m.clearedFields[server.FieldStatus] = struct{}{}
  11719. }
  11720. // StatusCleared returns if the "status" field was cleared in this mutation.
  11721. func (m *ServerMutation) StatusCleared() bool {
  11722. _, ok := m.clearedFields[server.FieldStatus]
  11723. return ok
  11724. }
  11725. // ResetStatus resets all changes to the "status" field.
  11726. func (m *ServerMutation) ResetStatus() {
  11727. m.status = nil
  11728. m.addstatus = nil
  11729. delete(m.clearedFields, server.FieldStatus)
  11730. }
  11731. // SetDeletedAt sets the "deleted_at" field.
  11732. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  11733. m.deleted_at = &t
  11734. }
  11735. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11736. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  11737. v := m.deleted_at
  11738. if v == nil {
  11739. return
  11740. }
  11741. return *v, true
  11742. }
  11743. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  11744. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11746. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11747. if !m.op.Is(OpUpdateOne) {
  11748. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11749. }
  11750. if m.id == nil || m.oldValue == nil {
  11751. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11752. }
  11753. oldValue, err := m.oldValue(ctx)
  11754. if err != nil {
  11755. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11756. }
  11757. return oldValue.DeletedAt, nil
  11758. }
  11759. // ClearDeletedAt clears the value of the "deleted_at" field.
  11760. func (m *ServerMutation) ClearDeletedAt() {
  11761. m.deleted_at = nil
  11762. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  11763. }
  11764. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11765. func (m *ServerMutation) DeletedAtCleared() bool {
  11766. _, ok := m.clearedFields[server.FieldDeletedAt]
  11767. return ok
  11768. }
  11769. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11770. func (m *ServerMutation) ResetDeletedAt() {
  11771. m.deleted_at = nil
  11772. delete(m.clearedFields, server.FieldDeletedAt)
  11773. }
  11774. // SetName sets the "name" field.
  11775. func (m *ServerMutation) SetName(s string) {
  11776. m.name = &s
  11777. }
  11778. // Name returns the value of the "name" field in the mutation.
  11779. func (m *ServerMutation) Name() (r string, exists bool) {
  11780. v := m.name
  11781. if v == nil {
  11782. return
  11783. }
  11784. return *v, true
  11785. }
  11786. // OldName returns the old "name" field's value of the Server entity.
  11787. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11789. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  11790. if !m.op.Is(OpUpdateOne) {
  11791. return v, errors.New("OldName is only allowed on UpdateOne operations")
  11792. }
  11793. if m.id == nil || m.oldValue == nil {
  11794. return v, errors.New("OldName requires an ID field in the mutation")
  11795. }
  11796. oldValue, err := m.oldValue(ctx)
  11797. if err != nil {
  11798. return v, fmt.Errorf("querying old value for OldName: %w", err)
  11799. }
  11800. return oldValue.Name, nil
  11801. }
  11802. // ResetName resets all changes to the "name" field.
  11803. func (m *ServerMutation) ResetName() {
  11804. m.name = nil
  11805. }
  11806. // SetPublicIP sets the "public_ip" field.
  11807. func (m *ServerMutation) SetPublicIP(s string) {
  11808. m.public_ip = &s
  11809. }
  11810. // PublicIP returns the value of the "public_ip" field in the mutation.
  11811. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  11812. v := m.public_ip
  11813. if v == nil {
  11814. return
  11815. }
  11816. return *v, true
  11817. }
  11818. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  11819. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11821. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  11822. if !m.op.Is(OpUpdateOne) {
  11823. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  11824. }
  11825. if m.id == nil || m.oldValue == nil {
  11826. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  11827. }
  11828. oldValue, err := m.oldValue(ctx)
  11829. if err != nil {
  11830. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  11831. }
  11832. return oldValue.PublicIP, nil
  11833. }
  11834. // ResetPublicIP resets all changes to the "public_ip" field.
  11835. func (m *ServerMutation) ResetPublicIP() {
  11836. m.public_ip = nil
  11837. }
  11838. // SetPrivateIP sets the "private_ip" field.
  11839. func (m *ServerMutation) SetPrivateIP(s string) {
  11840. m.private_ip = &s
  11841. }
  11842. // PrivateIP returns the value of the "private_ip" field in the mutation.
  11843. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  11844. v := m.private_ip
  11845. if v == nil {
  11846. return
  11847. }
  11848. return *v, true
  11849. }
  11850. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  11851. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11853. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  11854. if !m.op.Is(OpUpdateOne) {
  11855. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  11856. }
  11857. if m.id == nil || m.oldValue == nil {
  11858. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  11859. }
  11860. oldValue, err := m.oldValue(ctx)
  11861. if err != nil {
  11862. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  11863. }
  11864. return oldValue.PrivateIP, nil
  11865. }
  11866. // ResetPrivateIP resets all changes to the "private_ip" field.
  11867. func (m *ServerMutation) ResetPrivateIP() {
  11868. m.private_ip = nil
  11869. }
  11870. // SetAdminPort sets the "admin_port" field.
  11871. func (m *ServerMutation) SetAdminPort(s string) {
  11872. m.admin_port = &s
  11873. }
  11874. // AdminPort returns the value of the "admin_port" field in the mutation.
  11875. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  11876. v := m.admin_port
  11877. if v == nil {
  11878. return
  11879. }
  11880. return *v, true
  11881. }
  11882. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  11883. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11884. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11885. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  11886. if !m.op.Is(OpUpdateOne) {
  11887. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  11888. }
  11889. if m.id == nil || m.oldValue == nil {
  11890. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  11891. }
  11892. oldValue, err := m.oldValue(ctx)
  11893. if err != nil {
  11894. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  11895. }
  11896. return oldValue.AdminPort, nil
  11897. }
  11898. // ResetAdminPort resets all changes to the "admin_port" field.
  11899. func (m *ServerMutation) ResetAdminPort() {
  11900. m.admin_port = nil
  11901. }
  11902. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  11903. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  11904. if m.wxs == nil {
  11905. m.wxs = make(map[uint64]struct{})
  11906. }
  11907. for i := range ids {
  11908. m.wxs[ids[i]] = struct{}{}
  11909. }
  11910. }
  11911. // ClearWxs clears the "wxs" edge to the Wx entity.
  11912. func (m *ServerMutation) ClearWxs() {
  11913. m.clearedwxs = true
  11914. }
  11915. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  11916. func (m *ServerMutation) WxsCleared() bool {
  11917. return m.clearedwxs
  11918. }
  11919. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  11920. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  11921. if m.removedwxs == nil {
  11922. m.removedwxs = make(map[uint64]struct{})
  11923. }
  11924. for i := range ids {
  11925. delete(m.wxs, ids[i])
  11926. m.removedwxs[ids[i]] = struct{}{}
  11927. }
  11928. }
  11929. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  11930. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  11931. for id := range m.removedwxs {
  11932. ids = append(ids, id)
  11933. }
  11934. return
  11935. }
  11936. // WxsIDs returns the "wxs" edge IDs in the mutation.
  11937. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  11938. for id := range m.wxs {
  11939. ids = append(ids, id)
  11940. }
  11941. return
  11942. }
  11943. // ResetWxs resets all changes to the "wxs" edge.
  11944. func (m *ServerMutation) ResetWxs() {
  11945. m.wxs = nil
  11946. m.clearedwxs = false
  11947. m.removedwxs = nil
  11948. }
  11949. // Where appends a list predicates to the ServerMutation builder.
  11950. func (m *ServerMutation) Where(ps ...predicate.Server) {
  11951. m.predicates = append(m.predicates, ps...)
  11952. }
  11953. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  11954. // users can use type-assertion to append predicates that do not depend on any generated package.
  11955. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  11956. p := make([]predicate.Server, len(ps))
  11957. for i := range ps {
  11958. p[i] = ps[i]
  11959. }
  11960. m.Where(p...)
  11961. }
  11962. // Op returns the operation name.
  11963. func (m *ServerMutation) Op() Op {
  11964. return m.op
  11965. }
  11966. // SetOp allows setting the mutation operation.
  11967. func (m *ServerMutation) SetOp(op Op) {
  11968. m.op = op
  11969. }
  11970. // Type returns the node type of this mutation (Server).
  11971. func (m *ServerMutation) Type() string {
  11972. return m.typ
  11973. }
  11974. // Fields returns all fields that were changed during this mutation. Note that in
  11975. // order to get all numeric fields that were incremented/decremented, call
  11976. // AddedFields().
  11977. func (m *ServerMutation) Fields() []string {
  11978. fields := make([]string, 0, 8)
  11979. if m.created_at != nil {
  11980. fields = append(fields, server.FieldCreatedAt)
  11981. }
  11982. if m.updated_at != nil {
  11983. fields = append(fields, server.FieldUpdatedAt)
  11984. }
  11985. if m.status != nil {
  11986. fields = append(fields, server.FieldStatus)
  11987. }
  11988. if m.deleted_at != nil {
  11989. fields = append(fields, server.FieldDeletedAt)
  11990. }
  11991. if m.name != nil {
  11992. fields = append(fields, server.FieldName)
  11993. }
  11994. if m.public_ip != nil {
  11995. fields = append(fields, server.FieldPublicIP)
  11996. }
  11997. if m.private_ip != nil {
  11998. fields = append(fields, server.FieldPrivateIP)
  11999. }
  12000. if m.admin_port != nil {
  12001. fields = append(fields, server.FieldAdminPort)
  12002. }
  12003. return fields
  12004. }
  12005. // Field returns the value of a field with the given name. The second boolean
  12006. // return value indicates that this field was not set, or was not defined in the
  12007. // schema.
  12008. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  12009. switch name {
  12010. case server.FieldCreatedAt:
  12011. return m.CreatedAt()
  12012. case server.FieldUpdatedAt:
  12013. return m.UpdatedAt()
  12014. case server.FieldStatus:
  12015. return m.Status()
  12016. case server.FieldDeletedAt:
  12017. return m.DeletedAt()
  12018. case server.FieldName:
  12019. return m.Name()
  12020. case server.FieldPublicIP:
  12021. return m.PublicIP()
  12022. case server.FieldPrivateIP:
  12023. return m.PrivateIP()
  12024. case server.FieldAdminPort:
  12025. return m.AdminPort()
  12026. }
  12027. return nil, false
  12028. }
  12029. // OldField returns the old value of the field from the database. An error is
  12030. // returned if the mutation operation is not UpdateOne, or the query to the
  12031. // database failed.
  12032. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12033. switch name {
  12034. case server.FieldCreatedAt:
  12035. return m.OldCreatedAt(ctx)
  12036. case server.FieldUpdatedAt:
  12037. return m.OldUpdatedAt(ctx)
  12038. case server.FieldStatus:
  12039. return m.OldStatus(ctx)
  12040. case server.FieldDeletedAt:
  12041. return m.OldDeletedAt(ctx)
  12042. case server.FieldName:
  12043. return m.OldName(ctx)
  12044. case server.FieldPublicIP:
  12045. return m.OldPublicIP(ctx)
  12046. case server.FieldPrivateIP:
  12047. return m.OldPrivateIP(ctx)
  12048. case server.FieldAdminPort:
  12049. return m.OldAdminPort(ctx)
  12050. }
  12051. return nil, fmt.Errorf("unknown Server field %s", name)
  12052. }
  12053. // SetField sets the value of a field with the given name. It returns an error if
  12054. // the field is not defined in the schema, or if the type mismatched the field
  12055. // type.
  12056. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  12057. switch name {
  12058. case server.FieldCreatedAt:
  12059. v, ok := value.(time.Time)
  12060. if !ok {
  12061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12062. }
  12063. m.SetCreatedAt(v)
  12064. return nil
  12065. case server.FieldUpdatedAt:
  12066. v, ok := value.(time.Time)
  12067. if !ok {
  12068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12069. }
  12070. m.SetUpdatedAt(v)
  12071. return nil
  12072. case server.FieldStatus:
  12073. v, ok := value.(uint8)
  12074. if !ok {
  12075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12076. }
  12077. m.SetStatus(v)
  12078. return nil
  12079. case server.FieldDeletedAt:
  12080. v, ok := value.(time.Time)
  12081. if !ok {
  12082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12083. }
  12084. m.SetDeletedAt(v)
  12085. return nil
  12086. case server.FieldName:
  12087. v, ok := value.(string)
  12088. if !ok {
  12089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12090. }
  12091. m.SetName(v)
  12092. return nil
  12093. case server.FieldPublicIP:
  12094. v, ok := value.(string)
  12095. if !ok {
  12096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12097. }
  12098. m.SetPublicIP(v)
  12099. return nil
  12100. case server.FieldPrivateIP:
  12101. v, ok := value.(string)
  12102. if !ok {
  12103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12104. }
  12105. m.SetPrivateIP(v)
  12106. return nil
  12107. case server.FieldAdminPort:
  12108. v, ok := value.(string)
  12109. if !ok {
  12110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12111. }
  12112. m.SetAdminPort(v)
  12113. return nil
  12114. }
  12115. return fmt.Errorf("unknown Server field %s", name)
  12116. }
  12117. // AddedFields returns all numeric fields that were incremented/decremented during
  12118. // this mutation.
  12119. func (m *ServerMutation) AddedFields() []string {
  12120. var fields []string
  12121. if m.addstatus != nil {
  12122. fields = append(fields, server.FieldStatus)
  12123. }
  12124. return fields
  12125. }
  12126. // AddedField returns the numeric value that was incremented/decremented on a field
  12127. // with the given name. The second boolean return value indicates that this field
  12128. // was not set, or was not defined in the schema.
  12129. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  12130. switch name {
  12131. case server.FieldStatus:
  12132. return m.AddedStatus()
  12133. }
  12134. return nil, false
  12135. }
  12136. // AddField adds the value to the field with the given name. It returns an error if
  12137. // the field is not defined in the schema, or if the type mismatched the field
  12138. // type.
  12139. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  12140. switch name {
  12141. case server.FieldStatus:
  12142. v, ok := value.(int8)
  12143. if !ok {
  12144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12145. }
  12146. m.AddStatus(v)
  12147. return nil
  12148. }
  12149. return fmt.Errorf("unknown Server numeric field %s", name)
  12150. }
  12151. // ClearedFields returns all nullable fields that were cleared during this
  12152. // mutation.
  12153. func (m *ServerMutation) ClearedFields() []string {
  12154. var fields []string
  12155. if m.FieldCleared(server.FieldStatus) {
  12156. fields = append(fields, server.FieldStatus)
  12157. }
  12158. if m.FieldCleared(server.FieldDeletedAt) {
  12159. fields = append(fields, server.FieldDeletedAt)
  12160. }
  12161. return fields
  12162. }
  12163. // FieldCleared returns a boolean indicating if a field with the given name was
  12164. // cleared in this mutation.
  12165. func (m *ServerMutation) FieldCleared(name string) bool {
  12166. _, ok := m.clearedFields[name]
  12167. return ok
  12168. }
  12169. // ClearField clears the value of the field with the given name. It returns an
  12170. // error if the field is not defined in the schema.
  12171. func (m *ServerMutation) ClearField(name string) error {
  12172. switch name {
  12173. case server.FieldStatus:
  12174. m.ClearStatus()
  12175. return nil
  12176. case server.FieldDeletedAt:
  12177. m.ClearDeletedAt()
  12178. return nil
  12179. }
  12180. return fmt.Errorf("unknown Server nullable field %s", name)
  12181. }
  12182. // ResetField resets all changes in the mutation for the field with the given name.
  12183. // It returns an error if the field is not defined in the schema.
  12184. func (m *ServerMutation) ResetField(name string) error {
  12185. switch name {
  12186. case server.FieldCreatedAt:
  12187. m.ResetCreatedAt()
  12188. return nil
  12189. case server.FieldUpdatedAt:
  12190. m.ResetUpdatedAt()
  12191. return nil
  12192. case server.FieldStatus:
  12193. m.ResetStatus()
  12194. return nil
  12195. case server.FieldDeletedAt:
  12196. m.ResetDeletedAt()
  12197. return nil
  12198. case server.FieldName:
  12199. m.ResetName()
  12200. return nil
  12201. case server.FieldPublicIP:
  12202. m.ResetPublicIP()
  12203. return nil
  12204. case server.FieldPrivateIP:
  12205. m.ResetPrivateIP()
  12206. return nil
  12207. case server.FieldAdminPort:
  12208. m.ResetAdminPort()
  12209. return nil
  12210. }
  12211. return fmt.Errorf("unknown Server field %s", name)
  12212. }
  12213. // AddedEdges returns all edge names that were set/added in this mutation.
  12214. func (m *ServerMutation) AddedEdges() []string {
  12215. edges := make([]string, 0, 1)
  12216. if m.wxs != nil {
  12217. edges = append(edges, server.EdgeWxs)
  12218. }
  12219. return edges
  12220. }
  12221. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12222. // name in this mutation.
  12223. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  12224. switch name {
  12225. case server.EdgeWxs:
  12226. ids := make([]ent.Value, 0, len(m.wxs))
  12227. for id := range m.wxs {
  12228. ids = append(ids, id)
  12229. }
  12230. return ids
  12231. }
  12232. return nil
  12233. }
  12234. // RemovedEdges returns all edge names that were removed in this mutation.
  12235. func (m *ServerMutation) RemovedEdges() []string {
  12236. edges := make([]string, 0, 1)
  12237. if m.removedwxs != nil {
  12238. edges = append(edges, server.EdgeWxs)
  12239. }
  12240. return edges
  12241. }
  12242. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12243. // the given name in this mutation.
  12244. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  12245. switch name {
  12246. case server.EdgeWxs:
  12247. ids := make([]ent.Value, 0, len(m.removedwxs))
  12248. for id := range m.removedwxs {
  12249. ids = append(ids, id)
  12250. }
  12251. return ids
  12252. }
  12253. return nil
  12254. }
  12255. // ClearedEdges returns all edge names that were cleared in this mutation.
  12256. func (m *ServerMutation) ClearedEdges() []string {
  12257. edges := make([]string, 0, 1)
  12258. if m.clearedwxs {
  12259. edges = append(edges, server.EdgeWxs)
  12260. }
  12261. return edges
  12262. }
  12263. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12264. // was cleared in this mutation.
  12265. func (m *ServerMutation) EdgeCleared(name string) bool {
  12266. switch name {
  12267. case server.EdgeWxs:
  12268. return m.clearedwxs
  12269. }
  12270. return false
  12271. }
  12272. // ClearEdge clears the value of the edge with the given name. It returns an error
  12273. // if that edge is not defined in the schema.
  12274. func (m *ServerMutation) ClearEdge(name string) error {
  12275. switch name {
  12276. }
  12277. return fmt.Errorf("unknown Server unique edge %s", name)
  12278. }
  12279. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12280. // It returns an error if the edge is not defined in the schema.
  12281. func (m *ServerMutation) ResetEdge(name string) error {
  12282. switch name {
  12283. case server.EdgeWxs:
  12284. m.ResetWxs()
  12285. return nil
  12286. }
  12287. return fmt.Errorf("unknown Server edge %s", name)
  12288. }
  12289. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  12290. type SopNodeMutation struct {
  12291. config
  12292. op Op
  12293. typ string
  12294. id *uint64
  12295. created_at *time.Time
  12296. updated_at *time.Time
  12297. status *uint8
  12298. addstatus *int8
  12299. deleted_at *time.Time
  12300. parent_id *uint64
  12301. addparent_id *int64
  12302. name *string
  12303. condition_type *int
  12304. addcondition_type *int
  12305. condition_list *[]string
  12306. appendcondition_list []string
  12307. no_reply_condition *uint64
  12308. addno_reply_condition *int64
  12309. action_message *[]custom_types.Action
  12310. appendaction_message []custom_types.Action
  12311. action_label *[]uint64
  12312. appendaction_label []uint64
  12313. clearedFields map[string]struct{}
  12314. sop_stage *uint64
  12315. clearedsop_stage bool
  12316. node_messages map[uint64]struct{}
  12317. removednode_messages map[uint64]struct{}
  12318. clearednode_messages bool
  12319. done bool
  12320. oldValue func(context.Context) (*SopNode, error)
  12321. predicates []predicate.SopNode
  12322. }
  12323. var _ ent.Mutation = (*SopNodeMutation)(nil)
  12324. // sopnodeOption allows management of the mutation configuration using functional options.
  12325. type sopnodeOption func(*SopNodeMutation)
  12326. // newSopNodeMutation creates new mutation for the SopNode entity.
  12327. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  12328. m := &SopNodeMutation{
  12329. config: c,
  12330. op: op,
  12331. typ: TypeSopNode,
  12332. clearedFields: make(map[string]struct{}),
  12333. }
  12334. for _, opt := range opts {
  12335. opt(m)
  12336. }
  12337. return m
  12338. }
  12339. // withSopNodeID sets the ID field of the mutation.
  12340. func withSopNodeID(id uint64) sopnodeOption {
  12341. return func(m *SopNodeMutation) {
  12342. var (
  12343. err error
  12344. once sync.Once
  12345. value *SopNode
  12346. )
  12347. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  12348. once.Do(func() {
  12349. if m.done {
  12350. err = errors.New("querying old values post mutation is not allowed")
  12351. } else {
  12352. value, err = m.Client().SopNode.Get(ctx, id)
  12353. }
  12354. })
  12355. return value, err
  12356. }
  12357. m.id = &id
  12358. }
  12359. }
  12360. // withSopNode sets the old SopNode of the mutation.
  12361. func withSopNode(node *SopNode) sopnodeOption {
  12362. return func(m *SopNodeMutation) {
  12363. m.oldValue = func(context.Context) (*SopNode, error) {
  12364. return node, nil
  12365. }
  12366. m.id = &node.ID
  12367. }
  12368. }
  12369. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12370. // executed in a transaction (ent.Tx), a transactional client is returned.
  12371. func (m SopNodeMutation) Client() *Client {
  12372. client := &Client{config: m.config}
  12373. client.init()
  12374. return client
  12375. }
  12376. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12377. // it returns an error otherwise.
  12378. func (m SopNodeMutation) Tx() (*Tx, error) {
  12379. if _, ok := m.driver.(*txDriver); !ok {
  12380. return nil, errors.New("ent: mutation is not running in a transaction")
  12381. }
  12382. tx := &Tx{config: m.config}
  12383. tx.init()
  12384. return tx, nil
  12385. }
  12386. // SetID sets the value of the id field. Note that this
  12387. // operation is only accepted on creation of SopNode entities.
  12388. func (m *SopNodeMutation) SetID(id uint64) {
  12389. m.id = &id
  12390. }
  12391. // ID returns the ID value in the mutation. Note that the ID is only available
  12392. // if it was provided to the builder or after it was returned from the database.
  12393. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  12394. if m.id == nil {
  12395. return
  12396. }
  12397. return *m.id, true
  12398. }
  12399. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12400. // That means, if the mutation is applied within a transaction with an isolation level such
  12401. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12402. // or updated by the mutation.
  12403. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  12404. switch {
  12405. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12406. id, exists := m.ID()
  12407. if exists {
  12408. return []uint64{id}, nil
  12409. }
  12410. fallthrough
  12411. case m.op.Is(OpUpdate | OpDelete):
  12412. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  12413. default:
  12414. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12415. }
  12416. }
  12417. // SetCreatedAt sets the "created_at" field.
  12418. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  12419. m.created_at = &t
  12420. }
  12421. // CreatedAt returns the value of the "created_at" field in the mutation.
  12422. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  12423. v := m.created_at
  12424. if v == nil {
  12425. return
  12426. }
  12427. return *v, true
  12428. }
  12429. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  12430. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12432. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12433. if !m.op.Is(OpUpdateOne) {
  12434. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12435. }
  12436. if m.id == nil || m.oldValue == nil {
  12437. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12438. }
  12439. oldValue, err := m.oldValue(ctx)
  12440. if err != nil {
  12441. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12442. }
  12443. return oldValue.CreatedAt, nil
  12444. }
  12445. // ResetCreatedAt resets all changes to the "created_at" field.
  12446. func (m *SopNodeMutation) ResetCreatedAt() {
  12447. m.created_at = nil
  12448. }
  12449. // SetUpdatedAt sets the "updated_at" field.
  12450. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  12451. m.updated_at = &t
  12452. }
  12453. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12454. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  12455. v := m.updated_at
  12456. if v == nil {
  12457. return
  12458. }
  12459. return *v, true
  12460. }
  12461. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  12462. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12464. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12465. if !m.op.Is(OpUpdateOne) {
  12466. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12467. }
  12468. if m.id == nil || m.oldValue == nil {
  12469. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12470. }
  12471. oldValue, err := m.oldValue(ctx)
  12472. if err != nil {
  12473. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12474. }
  12475. return oldValue.UpdatedAt, nil
  12476. }
  12477. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12478. func (m *SopNodeMutation) ResetUpdatedAt() {
  12479. m.updated_at = nil
  12480. }
  12481. // SetStatus sets the "status" field.
  12482. func (m *SopNodeMutation) SetStatus(u uint8) {
  12483. m.status = &u
  12484. m.addstatus = nil
  12485. }
  12486. // Status returns the value of the "status" field in the mutation.
  12487. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  12488. v := m.status
  12489. if v == nil {
  12490. return
  12491. }
  12492. return *v, true
  12493. }
  12494. // OldStatus returns the old "status" field's value of the SopNode entity.
  12495. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12497. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12498. if !m.op.Is(OpUpdateOne) {
  12499. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12500. }
  12501. if m.id == nil || m.oldValue == nil {
  12502. return v, errors.New("OldStatus requires an ID field in the mutation")
  12503. }
  12504. oldValue, err := m.oldValue(ctx)
  12505. if err != nil {
  12506. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12507. }
  12508. return oldValue.Status, nil
  12509. }
  12510. // AddStatus adds u to the "status" field.
  12511. func (m *SopNodeMutation) AddStatus(u int8) {
  12512. if m.addstatus != nil {
  12513. *m.addstatus += u
  12514. } else {
  12515. m.addstatus = &u
  12516. }
  12517. }
  12518. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12519. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  12520. v := m.addstatus
  12521. if v == nil {
  12522. return
  12523. }
  12524. return *v, true
  12525. }
  12526. // ClearStatus clears the value of the "status" field.
  12527. func (m *SopNodeMutation) ClearStatus() {
  12528. m.status = nil
  12529. m.addstatus = nil
  12530. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  12531. }
  12532. // StatusCleared returns if the "status" field was cleared in this mutation.
  12533. func (m *SopNodeMutation) StatusCleared() bool {
  12534. _, ok := m.clearedFields[sopnode.FieldStatus]
  12535. return ok
  12536. }
  12537. // ResetStatus resets all changes to the "status" field.
  12538. func (m *SopNodeMutation) ResetStatus() {
  12539. m.status = nil
  12540. m.addstatus = nil
  12541. delete(m.clearedFields, sopnode.FieldStatus)
  12542. }
  12543. // SetDeletedAt sets the "deleted_at" field.
  12544. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  12545. m.deleted_at = &t
  12546. }
  12547. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12548. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  12549. v := m.deleted_at
  12550. if v == nil {
  12551. return
  12552. }
  12553. return *v, true
  12554. }
  12555. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  12556. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12558. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12559. if !m.op.Is(OpUpdateOne) {
  12560. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12561. }
  12562. if m.id == nil || m.oldValue == nil {
  12563. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12564. }
  12565. oldValue, err := m.oldValue(ctx)
  12566. if err != nil {
  12567. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12568. }
  12569. return oldValue.DeletedAt, nil
  12570. }
  12571. // ClearDeletedAt clears the value of the "deleted_at" field.
  12572. func (m *SopNodeMutation) ClearDeletedAt() {
  12573. m.deleted_at = nil
  12574. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  12575. }
  12576. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12577. func (m *SopNodeMutation) DeletedAtCleared() bool {
  12578. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  12579. return ok
  12580. }
  12581. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12582. func (m *SopNodeMutation) ResetDeletedAt() {
  12583. m.deleted_at = nil
  12584. delete(m.clearedFields, sopnode.FieldDeletedAt)
  12585. }
  12586. // SetStageID sets the "stage_id" field.
  12587. func (m *SopNodeMutation) SetStageID(u uint64) {
  12588. m.sop_stage = &u
  12589. }
  12590. // StageID returns the value of the "stage_id" field in the mutation.
  12591. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  12592. v := m.sop_stage
  12593. if v == nil {
  12594. return
  12595. }
  12596. return *v, true
  12597. }
  12598. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  12599. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12601. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  12602. if !m.op.Is(OpUpdateOne) {
  12603. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  12604. }
  12605. if m.id == nil || m.oldValue == nil {
  12606. return v, errors.New("OldStageID requires an ID field in the mutation")
  12607. }
  12608. oldValue, err := m.oldValue(ctx)
  12609. if err != nil {
  12610. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  12611. }
  12612. return oldValue.StageID, nil
  12613. }
  12614. // ResetStageID resets all changes to the "stage_id" field.
  12615. func (m *SopNodeMutation) ResetStageID() {
  12616. m.sop_stage = nil
  12617. }
  12618. // SetParentID sets the "parent_id" field.
  12619. func (m *SopNodeMutation) SetParentID(u uint64) {
  12620. m.parent_id = &u
  12621. m.addparent_id = nil
  12622. }
  12623. // ParentID returns the value of the "parent_id" field in the mutation.
  12624. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  12625. v := m.parent_id
  12626. if v == nil {
  12627. return
  12628. }
  12629. return *v, true
  12630. }
  12631. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  12632. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12634. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  12635. if !m.op.Is(OpUpdateOne) {
  12636. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  12637. }
  12638. if m.id == nil || m.oldValue == nil {
  12639. return v, errors.New("OldParentID requires an ID field in the mutation")
  12640. }
  12641. oldValue, err := m.oldValue(ctx)
  12642. if err != nil {
  12643. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  12644. }
  12645. return oldValue.ParentID, nil
  12646. }
  12647. // AddParentID adds u to the "parent_id" field.
  12648. func (m *SopNodeMutation) AddParentID(u int64) {
  12649. if m.addparent_id != nil {
  12650. *m.addparent_id += u
  12651. } else {
  12652. m.addparent_id = &u
  12653. }
  12654. }
  12655. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  12656. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  12657. v := m.addparent_id
  12658. if v == nil {
  12659. return
  12660. }
  12661. return *v, true
  12662. }
  12663. // ResetParentID resets all changes to the "parent_id" field.
  12664. func (m *SopNodeMutation) ResetParentID() {
  12665. m.parent_id = nil
  12666. m.addparent_id = nil
  12667. }
  12668. // SetName sets the "name" field.
  12669. func (m *SopNodeMutation) SetName(s string) {
  12670. m.name = &s
  12671. }
  12672. // Name returns the value of the "name" field in the mutation.
  12673. func (m *SopNodeMutation) Name() (r string, exists bool) {
  12674. v := m.name
  12675. if v == nil {
  12676. return
  12677. }
  12678. return *v, true
  12679. }
  12680. // OldName returns the old "name" field's value of the SopNode entity.
  12681. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12683. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  12684. if !m.op.Is(OpUpdateOne) {
  12685. return v, errors.New("OldName is only allowed on UpdateOne operations")
  12686. }
  12687. if m.id == nil || m.oldValue == nil {
  12688. return v, errors.New("OldName requires an ID field in the mutation")
  12689. }
  12690. oldValue, err := m.oldValue(ctx)
  12691. if err != nil {
  12692. return v, fmt.Errorf("querying old value for OldName: %w", err)
  12693. }
  12694. return oldValue.Name, nil
  12695. }
  12696. // ResetName resets all changes to the "name" field.
  12697. func (m *SopNodeMutation) ResetName() {
  12698. m.name = nil
  12699. }
  12700. // SetConditionType sets the "condition_type" field.
  12701. func (m *SopNodeMutation) SetConditionType(i int) {
  12702. m.condition_type = &i
  12703. m.addcondition_type = nil
  12704. }
  12705. // ConditionType returns the value of the "condition_type" field in the mutation.
  12706. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  12707. v := m.condition_type
  12708. if v == nil {
  12709. return
  12710. }
  12711. return *v, true
  12712. }
  12713. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  12714. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12715. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12716. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  12717. if !m.op.Is(OpUpdateOne) {
  12718. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  12719. }
  12720. if m.id == nil || m.oldValue == nil {
  12721. return v, errors.New("OldConditionType requires an ID field in the mutation")
  12722. }
  12723. oldValue, err := m.oldValue(ctx)
  12724. if err != nil {
  12725. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  12726. }
  12727. return oldValue.ConditionType, nil
  12728. }
  12729. // AddConditionType adds i to the "condition_type" field.
  12730. func (m *SopNodeMutation) AddConditionType(i int) {
  12731. if m.addcondition_type != nil {
  12732. *m.addcondition_type += i
  12733. } else {
  12734. m.addcondition_type = &i
  12735. }
  12736. }
  12737. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  12738. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  12739. v := m.addcondition_type
  12740. if v == nil {
  12741. return
  12742. }
  12743. return *v, true
  12744. }
  12745. // ResetConditionType resets all changes to the "condition_type" field.
  12746. func (m *SopNodeMutation) ResetConditionType() {
  12747. m.condition_type = nil
  12748. m.addcondition_type = nil
  12749. }
  12750. // SetConditionList sets the "condition_list" field.
  12751. func (m *SopNodeMutation) SetConditionList(s []string) {
  12752. m.condition_list = &s
  12753. m.appendcondition_list = nil
  12754. }
  12755. // ConditionList returns the value of the "condition_list" field in the mutation.
  12756. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  12757. v := m.condition_list
  12758. if v == nil {
  12759. return
  12760. }
  12761. return *v, true
  12762. }
  12763. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  12764. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12766. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  12767. if !m.op.Is(OpUpdateOne) {
  12768. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  12769. }
  12770. if m.id == nil || m.oldValue == nil {
  12771. return v, errors.New("OldConditionList requires an ID field in the mutation")
  12772. }
  12773. oldValue, err := m.oldValue(ctx)
  12774. if err != nil {
  12775. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  12776. }
  12777. return oldValue.ConditionList, nil
  12778. }
  12779. // AppendConditionList adds s to the "condition_list" field.
  12780. func (m *SopNodeMutation) AppendConditionList(s []string) {
  12781. m.appendcondition_list = append(m.appendcondition_list, s...)
  12782. }
  12783. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  12784. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  12785. if len(m.appendcondition_list) == 0 {
  12786. return nil, false
  12787. }
  12788. return m.appendcondition_list, true
  12789. }
  12790. // ClearConditionList clears the value of the "condition_list" field.
  12791. func (m *SopNodeMutation) ClearConditionList() {
  12792. m.condition_list = nil
  12793. m.appendcondition_list = nil
  12794. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  12795. }
  12796. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  12797. func (m *SopNodeMutation) ConditionListCleared() bool {
  12798. _, ok := m.clearedFields[sopnode.FieldConditionList]
  12799. return ok
  12800. }
  12801. // ResetConditionList resets all changes to the "condition_list" field.
  12802. func (m *SopNodeMutation) ResetConditionList() {
  12803. m.condition_list = nil
  12804. m.appendcondition_list = nil
  12805. delete(m.clearedFields, sopnode.FieldConditionList)
  12806. }
  12807. // SetNoReplyCondition sets the "no_reply_condition" field.
  12808. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  12809. m.no_reply_condition = &u
  12810. m.addno_reply_condition = nil
  12811. }
  12812. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  12813. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  12814. v := m.no_reply_condition
  12815. if v == nil {
  12816. return
  12817. }
  12818. return *v, true
  12819. }
  12820. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  12821. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12823. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  12824. if !m.op.Is(OpUpdateOne) {
  12825. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  12826. }
  12827. if m.id == nil || m.oldValue == nil {
  12828. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  12829. }
  12830. oldValue, err := m.oldValue(ctx)
  12831. if err != nil {
  12832. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  12833. }
  12834. return oldValue.NoReplyCondition, nil
  12835. }
  12836. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  12837. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  12838. if m.addno_reply_condition != nil {
  12839. *m.addno_reply_condition += u
  12840. } else {
  12841. m.addno_reply_condition = &u
  12842. }
  12843. }
  12844. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  12845. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  12846. v := m.addno_reply_condition
  12847. if v == nil {
  12848. return
  12849. }
  12850. return *v, true
  12851. }
  12852. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  12853. func (m *SopNodeMutation) ResetNoReplyCondition() {
  12854. m.no_reply_condition = nil
  12855. m.addno_reply_condition = nil
  12856. }
  12857. // SetActionMessage sets the "action_message" field.
  12858. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  12859. m.action_message = &ct
  12860. m.appendaction_message = nil
  12861. }
  12862. // ActionMessage returns the value of the "action_message" field in the mutation.
  12863. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  12864. v := m.action_message
  12865. if v == nil {
  12866. return
  12867. }
  12868. return *v, true
  12869. }
  12870. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  12871. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12873. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  12874. if !m.op.Is(OpUpdateOne) {
  12875. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  12876. }
  12877. if m.id == nil || m.oldValue == nil {
  12878. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  12879. }
  12880. oldValue, err := m.oldValue(ctx)
  12881. if err != nil {
  12882. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  12883. }
  12884. return oldValue.ActionMessage, nil
  12885. }
  12886. // AppendActionMessage adds ct to the "action_message" field.
  12887. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  12888. m.appendaction_message = append(m.appendaction_message, ct...)
  12889. }
  12890. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  12891. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  12892. if len(m.appendaction_message) == 0 {
  12893. return nil, false
  12894. }
  12895. return m.appendaction_message, true
  12896. }
  12897. // ClearActionMessage clears the value of the "action_message" field.
  12898. func (m *SopNodeMutation) ClearActionMessage() {
  12899. m.action_message = nil
  12900. m.appendaction_message = nil
  12901. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  12902. }
  12903. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  12904. func (m *SopNodeMutation) ActionMessageCleared() bool {
  12905. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  12906. return ok
  12907. }
  12908. // ResetActionMessage resets all changes to the "action_message" field.
  12909. func (m *SopNodeMutation) ResetActionMessage() {
  12910. m.action_message = nil
  12911. m.appendaction_message = nil
  12912. delete(m.clearedFields, sopnode.FieldActionMessage)
  12913. }
  12914. // SetActionLabel sets the "action_label" field.
  12915. func (m *SopNodeMutation) SetActionLabel(u []uint64) {
  12916. m.action_label = &u
  12917. m.appendaction_label = nil
  12918. }
  12919. // ActionLabel returns the value of the "action_label" field in the mutation.
  12920. func (m *SopNodeMutation) ActionLabel() (r []uint64, exists bool) {
  12921. v := m.action_label
  12922. if v == nil {
  12923. return
  12924. }
  12925. return *v, true
  12926. }
  12927. // OldActionLabel returns the old "action_label" field's value of the SopNode entity.
  12928. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12930. func (m *SopNodeMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  12931. if !m.op.Is(OpUpdateOne) {
  12932. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  12933. }
  12934. if m.id == nil || m.oldValue == nil {
  12935. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  12936. }
  12937. oldValue, err := m.oldValue(ctx)
  12938. if err != nil {
  12939. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  12940. }
  12941. return oldValue.ActionLabel, nil
  12942. }
  12943. // AppendActionLabel adds u to the "action_label" field.
  12944. func (m *SopNodeMutation) AppendActionLabel(u []uint64) {
  12945. m.appendaction_label = append(m.appendaction_label, u...)
  12946. }
  12947. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  12948. func (m *SopNodeMutation) AppendedActionLabel() ([]uint64, bool) {
  12949. if len(m.appendaction_label) == 0 {
  12950. return nil, false
  12951. }
  12952. return m.appendaction_label, true
  12953. }
  12954. // ClearActionLabel clears the value of the "action_label" field.
  12955. func (m *SopNodeMutation) ClearActionLabel() {
  12956. m.action_label = nil
  12957. m.appendaction_label = nil
  12958. m.clearedFields[sopnode.FieldActionLabel] = struct{}{}
  12959. }
  12960. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  12961. func (m *SopNodeMutation) ActionLabelCleared() bool {
  12962. _, ok := m.clearedFields[sopnode.FieldActionLabel]
  12963. return ok
  12964. }
  12965. // ResetActionLabel resets all changes to the "action_label" field.
  12966. func (m *SopNodeMutation) ResetActionLabel() {
  12967. m.action_label = nil
  12968. m.appendaction_label = nil
  12969. delete(m.clearedFields, sopnode.FieldActionLabel)
  12970. }
  12971. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  12972. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  12973. m.sop_stage = &id
  12974. }
  12975. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  12976. func (m *SopNodeMutation) ClearSopStage() {
  12977. m.clearedsop_stage = true
  12978. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  12979. }
  12980. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  12981. func (m *SopNodeMutation) SopStageCleared() bool {
  12982. return m.clearedsop_stage
  12983. }
  12984. // SopStageID returns the "sop_stage" edge ID in the mutation.
  12985. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  12986. if m.sop_stage != nil {
  12987. return *m.sop_stage, true
  12988. }
  12989. return
  12990. }
  12991. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  12992. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12993. // SopStageID instead. It exists only for internal usage by the builders.
  12994. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  12995. if id := m.sop_stage; id != nil {
  12996. ids = append(ids, *id)
  12997. }
  12998. return
  12999. }
  13000. // ResetSopStage resets all changes to the "sop_stage" edge.
  13001. func (m *SopNodeMutation) ResetSopStage() {
  13002. m.sop_stage = nil
  13003. m.clearedsop_stage = false
  13004. }
  13005. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  13006. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  13007. if m.node_messages == nil {
  13008. m.node_messages = make(map[uint64]struct{})
  13009. }
  13010. for i := range ids {
  13011. m.node_messages[ids[i]] = struct{}{}
  13012. }
  13013. }
  13014. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  13015. func (m *SopNodeMutation) ClearNodeMessages() {
  13016. m.clearednode_messages = true
  13017. }
  13018. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  13019. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  13020. return m.clearednode_messages
  13021. }
  13022. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  13023. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  13024. if m.removednode_messages == nil {
  13025. m.removednode_messages = make(map[uint64]struct{})
  13026. }
  13027. for i := range ids {
  13028. delete(m.node_messages, ids[i])
  13029. m.removednode_messages[ids[i]] = struct{}{}
  13030. }
  13031. }
  13032. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  13033. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  13034. for id := range m.removednode_messages {
  13035. ids = append(ids, id)
  13036. }
  13037. return
  13038. }
  13039. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  13040. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  13041. for id := range m.node_messages {
  13042. ids = append(ids, id)
  13043. }
  13044. return
  13045. }
  13046. // ResetNodeMessages resets all changes to the "node_messages" edge.
  13047. func (m *SopNodeMutation) ResetNodeMessages() {
  13048. m.node_messages = nil
  13049. m.clearednode_messages = false
  13050. m.removednode_messages = nil
  13051. }
  13052. // Where appends a list predicates to the SopNodeMutation builder.
  13053. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  13054. m.predicates = append(m.predicates, ps...)
  13055. }
  13056. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  13057. // users can use type-assertion to append predicates that do not depend on any generated package.
  13058. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  13059. p := make([]predicate.SopNode, len(ps))
  13060. for i := range ps {
  13061. p[i] = ps[i]
  13062. }
  13063. m.Where(p...)
  13064. }
  13065. // Op returns the operation name.
  13066. func (m *SopNodeMutation) Op() Op {
  13067. return m.op
  13068. }
  13069. // SetOp allows setting the mutation operation.
  13070. func (m *SopNodeMutation) SetOp(op Op) {
  13071. m.op = op
  13072. }
  13073. // Type returns the node type of this mutation (SopNode).
  13074. func (m *SopNodeMutation) Type() string {
  13075. return m.typ
  13076. }
  13077. // Fields returns all fields that were changed during this mutation. Note that in
  13078. // order to get all numeric fields that were incremented/decremented, call
  13079. // AddedFields().
  13080. func (m *SopNodeMutation) Fields() []string {
  13081. fields := make([]string, 0, 12)
  13082. if m.created_at != nil {
  13083. fields = append(fields, sopnode.FieldCreatedAt)
  13084. }
  13085. if m.updated_at != nil {
  13086. fields = append(fields, sopnode.FieldUpdatedAt)
  13087. }
  13088. if m.status != nil {
  13089. fields = append(fields, sopnode.FieldStatus)
  13090. }
  13091. if m.deleted_at != nil {
  13092. fields = append(fields, sopnode.FieldDeletedAt)
  13093. }
  13094. if m.sop_stage != nil {
  13095. fields = append(fields, sopnode.FieldStageID)
  13096. }
  13097. if m.parent_id != nil {
  13098. fields = append(fields, sopnode.FieldParentID)
  13099. }
  13100. if m.name != nil {
  13101. fields = append(fields, sopnode.FieldName)
  13102. }
  13103. if m.condition_type != nil {
  13104. fields = append(fields, sopnode.FieldConditionType)
  13105. }
  13106. if m.condition_list != nil {
  13107. fields = append(fields, sopnode.FieldConditionList)
  13108. }
  13109. if m.no_reply_condition != nil {
  13110. fields = append(fields, sopnode.FieldNoReplyCondition)
  13111. }
  13112. if m.action_message != nil {
  13113. fields = append(fields, sopnode.FieldActionMessage)
  13114. }
  13115. if m.action_label != nil {
  13116. fields = append(fields, sopnode.FieldActionLabel)
  13117. }
  13118. return fields
  13119. }
  13120. // Field returns the value of a field with the given name. The second boolean
  13121. // return value indicates that this field was not set, or was not defined in the
  13122. // schema.
  13123. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  13124. switch name {
  13125. case sopnode.FieldCreatedAt:
  13126. return m.CreatedAt()
  13127. case sopnode.FieldUpdatedAt:
  13128. return m.UpdatedAt()
  13129. case sopnode.FieldStatus:
  13130. return m.Status()
  13131. case sopnode.FieldDeletedAt:
  13132. return m.DeletedAt()
  13133. case sopnode.FieldStageID:
  13134. return m.StageID()
  13135. case sopnode.FieldParentID:
  13136. return m.ParentID()
  13137. case sopnode.FieldName:
  13138. return m.Name()
  13139. case sopnode.FieldConditionType:
  13140. return m.ConditionType()
  13141. case sopnode.FieldConditionList:
  13142. return m.ConditionList()
  13143. case sopnode.FieldNoReplyCondition:
  13144. return m.NoReplyCondition()
  13145. case sopnode.FieldActionMessage:
  13146. return m.ActionMessage()
  13147. case sopnode.FieldActionLabel:
  13148. return m.ActionLabel()
  13149. }
  13150. return nil, false
  13151. }
  13152. // OldField returns the old value of the field from the database. An error is
  13153. // returned if the mutation operation is not UpdateOne, or the query to the
  13154. // database failed.
  13155. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13156. switch name {
  13157. case sopnode.FieldCreatedAt:
  13158. return m.OldCreatedAt(ctx)
  13159. case sopnode.FieldUpdatedAt:
  13160. return m.OldUpdatedAt(ctx)
  13161. case sopnode.FieldStatus:
  13162. return m.OldStatus(ctx)
  13163. case sopnode.FieldDeletedAt:
  13164. return m.OldDeletedAt(ctx)
  13165. case sopnode.FieldStageID:
  13166. return m.OldStageID(ctx)
  13167. case sopnode.FieldParentID:
  13168. return m.OldParentID(ctx)
  13169. case sopnode.FieldName:
  13170. return m.OldName(ctx)
  13171. case sopnode.FieldConditionType:
  13172. return m.OldConditionType(ctx)
  13173. case sopnode.FieldConditionList:
  13174. return m.OldConditionList(ctx)
  13175. case sopnode.FieldNoReplyCondition:
  13176. return m.OldNoReplyCondition(ctx)
  13177. case sopnode.FieldActionMessage:
  13178. return m.OldActionMessage(ctx)
  13179. case sopnode.FieldActionLabel:
  13180. return m.OldActionLabel(ctx)
  13181. }
  13182. return nil, fmt.Errorf("unknown SopNode field %s", name)
  13183. }
  13184. // SetField sets the value of a field with the given name. It returns an error if
  13185. // the field is not defined in the schema, or if the type mismatched the field
  13186. // type.
  13187. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  13188. switch name {
  13189. case sopnode.FieldCreatedAt:
  13190. v, ok := value.(time.Time)
  13191. if !ok {
  13192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13193. }
  13194. m.SetCreatedAt(v)
  13195. return nil
  13196. case sopnode.FieldUpdatedAt:
  13197. v, ok := value.(time.Time)
  13198. if !ok {
  13199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13200. }
  13201. m.SetUpdatedAt(v)
  13202. return nil
  13203. case sopnode.FieldStatus:
  13204. v, ok := value.(uint8)
  13205. if !ok {
  13206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13207. }
  13208. m.SetStatus(v)
  13209. return nil
  13210. case sopnode.FieldDeletedAt:
  13211. v, ok := value.(time.Time)
  13212. if !ok {
  13213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13214. }
  13215. m.SetDeletedAt(v)
  13216. return nil
  13217. case sopnode.FieldStageID:
  13218. v, ok := value.(uint64)
  13219. if !ok {
  13220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13221. }
  13222. m.SetStageID(v)
  13223. return nil
  13224. case sopnode.FieldParentID:
  13225. v, ok := value.(uint64)
  13226. if !ok {
  13227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13228. }
  13229. m.SetParentID(v)
  13230. return nil
  13231. case sopnode.FieldName:
  13232. v, ok := value.(string)
  13233. if !ok {
  13234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13235. }
  13236. m.SetName(v)
  13237. return nil
  13238. case sopnode.FieldConditionType:
  13239. v, ok := value.(int)
  13240. if !ok {
  13241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13242. }
  13243. m.SetConditionType(v)
  13244. return nil
  13245. case sopnode.FieldConditionList:
  13246. v, ok := value.([]string)
  13247. if !ok {
  13248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13249. }
  13250. m.SetConditionList(v)
  13251. return nil
  13252. case sopnode.FieldNoReplyCondition:
  13253. v, ok := value.(uint64)
  13254. if !ok {
  13255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13256. }
  13257. m.SetNoReplyCondition(v)
  13258. return nil
  13259. case sopnode.FieldActionMessage:
  13260. v, ok := value.([]custom_types.Action)
  13261. if !ok {
  13262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13263. }
  13264. m.SetActionMessage(v)
  13265. return nil
  13266. case sopnode.FieldActionLabel:
  13267. v, ok := value.([]uint64)
  13268. if !ok {
  13269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13270. }
  13271. m.SetActionLabel(v)
  13272. return nil
  13273. }
  13274. return fmt.Errorf("unknown SopNode field %s", name)
  13275. }
  13276. // AddedFields returns all numeric fields that were incremented/decremented during
  13277. // this mutation.
  13278. func (m *SopNodeMutation) AddedFields() []string {
  13279. var fields []string
  13280. if m.addstatus != nil {
  13281. fields = append(fields, sopnode.FieldStatus)
  13282. }
  13283. if m.addparent_id != nil {
  13284. fields = append(fields, sopnode.FieldParentID)
  13285. }
  13286. if m.addcondition_type != nil {
  13287. fields = append(fields, sopnode.FieldConditionType)
  13288. }
  13289. if m.addno_reply_condition != nil {
  13290. fields = append(fields, sopnode.FieldNoReplyCondition)
  13291. }
  13292. return fields
  13293. }
  13294. // AddedField returns the numeric value that was incremented/decremented on a field
  13295. // with the given name. The second boolean return value indicates that this field
  13296. // was not set, or was not defined in the schema.
  13297. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  13298. switch name {
  13299. case sopnode.FieldStatus:
  13300. return m.AddedStatus()
  13301. case sopnode.FieldParentID:
  13302. return m.AddedParentID()
  13303. case sopnode.FieldConditionType:
  13304. return m.AddedConditionType()
  13305. case sopnode.FieldNoReplyCondition:
  13306. return m.AddedNoReplyCondition()
  13307. }
  13308. return nil, false
  13309. }
  13310. // AddField adds the value to the field with the given name. It returns an error if
  13311. // the field is not defined in the schema, or if the type mismatched the field
  13312. // type.
  13313. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  13314. switch name {
  13315. case sopnode.FieldStatus:
  13316. v, ok := value.(int8)
  13317. if !ok {
  13318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13319. }
  13320. m.AddStatus(v)
  13321. return nil
  13322. case sopnode.FieldParentID:
  13323. v, ok := value.(int64)
  13324. if !ok {
  13325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13326. }
  13327. m.AddParentID(v)
  13328. return nil
  13329. case sopnode.FieldConditionType:
  13330. v, ok := value.(int)
  13331. if !ok {
  13332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13333. }
  13334. m.AddConditionType(v)
  13335. return nil
  13336. case sopnode.FieldNoReplyCondition:
  13337. v, ok := value.(int64)
  13338. if !ok {
  13339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13340. }
  13341. m.AddNoReplyCondition(v)
  13342. return nil
  13343. }
  13344. return fmt.Errorf("unknown SopNode numeric field %s", name)
  13345. }
  13346. // ClearedFields returns all nullable fields that were cleared during this
  13347. // mutation.
  13348. func (m *SopNodeMutation) ClearedFields() []string {
  13349. var fields []string
  13350. if m.FieldCleared(sopnode.FieldStatus) {
  13351. fields = append(fields, sopnode.FieldStatus)
  13352. }
  13353. if m.FieldCleared(sopnode.FieldDeletedAt) {
  13354. fields = append(fields, sopnode.FieldDeletedAt)
  13355. }
  13356. if m.FieldCleared(sopnode.FieldConditionList) {
  13357. fields = append(fields, sopnode.FieldConditionList)
  13358. }
  13359. if m.FieldCleared(sopnode.FieldActionMessage) {
  13360. fields = append(fields, sopnode.FieldActionMessage)
  13361. }
  13362. if m.FieldCleared(sopnode.FieldActionLabel) {
  13363. fields = append(fields, sopnode.FieldActionLabel)
  13364. }
  13365. return fields
  13366. }
  13367. // FieldCleared returns a boolean indicating if a field with the given name was
  13368. // cleared in this mutation.
  13369. func (m *SopNodeMutation) FieldCleared(name string) bool {
  13370. _, ok := m.clearedFields[name]
  13371. return ok
  13372. }
  13373. // ClearField clears the value of the field with the given name. It returns an
  13374. // error if the field is not defined in the schema.
  13375. func (m *SopNodeMutation) ClearField(name string) error {
  13376. switch name {
  13377. case sopnode.FieldStatus:
  13378. m.ClearStatus()
  13379. return nil
  13380. case sopnode.FieldDeletedAt:
  13381. m.ClearDeletedAt()
  13382. return nil
  13383. case sopnode.FieldConditionList:
  13384. m.ClearConditionList()
  13385. return nil
  13386. case sopnode.FieldActionMessage:
  13387. m.ClearActionMessage()
  13388. return nil
  13389. case sopnode.FieldActionLabel:
  13390. m.ClearActionLabel()
  13391. return nil
  13392. }
  13393. return fmt.Errorf("unknown SopNode nullable field %s", name)
  13394. }
  13395. // ResetField resets all changes in the mutation for the field with the given name.
  13396. // It returns an error if the field is not defined in the schema.
  13397. func (m *SopNodeMutation) ResetField(name string) error {
  13398. switch name {
  13399. case sopnode.FieldCreatedAt:
  13400. m.ResetCreatedAt()
  13401. return nil
  13402. case sopnode.FieldUpdatedAt:
  13403. m.ResetUpdatedAt()
  13404. return nil
  13405. case sopnode.FieldStatus:
  13406. m.ResetStatus()
  13407. return nil
  13408. case sopnode.FieldDeletedAt:
  13409. m.ResetDeletedAt()
  13410. return nil
  13411. case sopnode.FieldStageID:
  13412. m.ResetStageID()
  13413. return nil
  13414. case sopnode.FieldParentID:
  13415. m.ResetParentID()
  13416. return nil
  13417. case sopnode.FieldName:
  13418. m.ResetName()
  13419. return nil
  13420. case sopnode.FieldConditionType:
  13421. m.ResetConditionType()
  13422. return nil
  13423. case sopnode.FieldConditionList:
  13424. m.ResetConditionList()
  13425. return nil
  13426. case sopnode.FieldNoReplyCondition:
  13427. m.ResetNoReplyCondition()
  13428. return nil
  13429. case sopnode.FieldActionMessage:
  13430. m.ResetActionMessage()
  13431. return nil
  13432. case sopnode.FieldActionLabel:
  13433. m.ResetActionLabel()
  13434. return nil
  13435. }
  13436. return fmt.Errorf("unknown SopNode field %s", name)
  13437. }
  13438. // AddedEdges returns all edge names that were set/added in this mutation.
  13439. func (m *SopNodeMutation) AddedEdges() []string {
  13440. edges := make([]string, 0, 2)
  13441. if m.sop_stage != nil {
  13442. edges = append(edges, sopnode.EdgeSopStage)
  13443. }
  13444. if m.node_messages != nil {
  13445. edges = append(edges, sopnode.EdgeNodeMessages)
  13446. }
  13447. return edges
  13448. }
  13449. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13450. // name in this mutation.
  13451. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  13452. switch name {
  13453. case sopnode.EdgeSopStage:
  13454. if id := m.sop_stage; id != nil {
  13455. return []ent.Value{*id}
  13456. }
  13457. case sopnode.EdgeNodeMessages:
  13458. ids := make([]ent.Value, 0, len(m.node_messages))
  13459. for id := range m.node_messages {
  13460. ids = append(ids, id)
  13461. }
  13462. return ids
  13463. }
  13464. return nil
  13465. }
  13466. // RemovedEdges returns all edge names that were removed in this mutation.
  13467. func (m *SopNodeMutation) RemovedEdges() []string {
  13468. edges := make([]string, 0, 2)
  13469. if m.removednode_messages != nil {
  13470. edges = append(edges, sopnode.EdgeNodeMessages)
  13471. }
  13472. return edges
  13473. }
  13474. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13475. // the given name in this mutation.
  13476. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  13477. switch name {
  13478. case sopnode.EdgeNodeMessages:
  13479. ids := make([]ent.Value, 0, len(m.removednode_messages))
  13480. for id := range m.removednode_messages {
  13481. ids = append(ids, id)
  13482. }
  13483. return ids
  13484. }
  13485. return nil
  13486. }
  13487. // ClearedEdges returns all edge names that were cleared in this mutation.
  13488. func (m *SopNodeMutation) ClearedEdges() []string {
  13489. edges := make([]string, 0, 2)
  13490. if m.clearedsop_stage {
  13491. edges = append(edges, sopnode.EdgeSopStage)
  13492. }
  13493. if m.clearednode_messages {
  13494. edges = append(edges, sopnode.EdgeNodeMessages)
  13495. }
  13496. return edges
  13497. }
  13498. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13499. // was cleared in this mutation.
  13500. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  13501. switch name {
  13502. case sopnode.EdgeSopStage:
  13503. return m.clearedsop_stage
  13504. case sopnode.EdgeNodeMessages:
  13505. return m.clearednode_messages
  13506. }
  13507. return false
  13508. }
  13509. // ClearEdge clears the value of the edge with the given name. It returns an error
  13510. // if that edge is not defined in the schema.
  13511. func (m *SopNodeMutation) ClearEdge(name string) error {
  13512. switch name {
  13513. case sopnode.EdgeSopStage:
  13514. m.ClearSopStage()
  13515. return nil
  13516. }
  13517. return fmt.Errorf("unknown SopNode unique edge %s", name)
  13518. }
  13519. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13520. // It returns an error if the edge is not defined in the schema.
  13521. func (m *SopNodeMutation) ResetEdge(name string) error {
  13522. switch name {
  13523. case sopnode.EdgeSopStage:
  13524. m.ResetSopStage()
  13525. return nil
  13526. case sopnode.EdgeNodeMessages:
  13527. m.ResetNodeMessages()
  13528. return nil
  13529. }
  13530. return fmt.Errorf("unknown SopNode edge %s", name)
  13531. }
  13532. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  13533. type SopStageMutation struct {
  13534. config
  13535. op Op
  13536. typ string
  13537. id *uint64
  13538. created_at *time.Time
  13539. updated_at *time.Time
  13540. status *uint8
  13541. addstatus *int8
  13542. deleted_at *time.Time
  13543. name *string
  13544. condition_type *int
  13545. addcondition_type *int
  13546. condition_operator *int
  13547. addcondition_operator *int
  13548. condition_list *[]custom_types.Condition
  13549. appendcondition_list []custom_types.Condition
  13550. action_message *[]custom_types.Action
  13551. appendaction_message []custom_types.Action
  13552. action_label *[]uint64
  13553. appendaction_label []uint64
  13554. index_sort *int
  13555. addindex_sort *int
  13556. clearedFields map[string]struct{}
  13557. sop_task *uint64
  13558. clearedsop_task bool
  13559. stage_nodes map[uint64]struct{}
  13560. removedstage_nodes map[uint64]struct{}
  13561. clearedstage_nodes bool
  13562. stage_messages map[uint64]struct{}
  13563. removedstage_messages map[uint64]struct{}
  13564. clearedstage_messages bool
  13565. done bool
  13566. oldValue func(context.Context) (*SopStage, error)
  13567. predicates []predicate.SopStage
  13568. }
  13569. var _ ent.Mutation = (*SopStageMutation)(nil)
  13570. // sopstageOption allows management of the mutation configuration using functional options.
  13571. type sopstageOption func(*SopStageMutation)
  13572. // newSopStageMutation creates new mutation for the SopStage entity.
  13573. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  13574. m := &SopStageMutation{
  13575. config: c,
  13576. op: op,
  13577. typ: TypeSopStage,
  13578. clearedFields: make(map[string]struct{}),
  13579. }
  13580. for _, opt := range opts {
  13581. opt(m)
  13582. }
  13583. return m
  13584. }
  13585. // withSopStageID sets the ID field of the mutation.
  13586. func withSopStageID(id uint64) sopstageOption {
  13587. return func(m *SopStageMutation) {
  13588. var (
  13589. err error
  13590. once sync.Once
  13591. value *SopStage
  13592. )
  13593. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  13594. once.Do(func() {
  13595. if m.done {
  13596. err = errors.New("querying old values post mutation is not allowed")
  13597. } else {
  13598. value, err = m.Client().SopStage.Get(ctx, id)
  13599. }
  13600. })
  13601. return value, err
  13602. }
  13603. m.id = &id
  13604. }
  13605. }
  13606. // withSopStage sets the old SopStage of the mutation.
  13607. func withSopStage(node *SopStage) sopstageOption {
  13608. return func(m *SopStageMutation) {
  13609. m.oldValue = func(context.Context) (*SopStage, error) {
  13610. return node, nil
  13611. }
  13612. m.id = &node.ID
  13613. }
  13614. }
  13615. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13616. // executed in a transaction (ent.Tx), a transactional client is returned.
  13617. func (m SopStageMutation) Client() *Client {
  13618. client := &Client{config: m.config}
  13619. client.init()
  13620. return client
  13621. }
  13622. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13623. // it returns an error otherwise.
  13624. func (m SopStageMutation) Tx() (*Tx, error) {
  13625. if _, ok := m.driver.(*txDriver); !ok {
  13626. return nil, errors.New("ent: mutation is not running in a transaction")
  13627. }
  13628. tx := &Tx{config: m.config}
  13629. tx.init()
  13630. return tx, nil
  13631. }
  13632. // SetID sets the value of the id field. Note that this
  13633. // operation is only accepted on creation of SopStage entities.
  13634. func (m *SopStageMutation) SetID(id uint64) {
  13635. m.id = &id
  13636. }
  13637. // ID returns the ID value in the mutation. Note that the ID is only available
  13638. // if it was provided to the builder or after it was returned from the database.
  13639. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  13640. if m.id == nil {
  13641. return
  13642. }
  13643. return *m.id, true
  13644. }
  13645. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13646. // That means, if the mutation is applied within a transaction with an isolation level such
  13647. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13648. // or updated by the mutation.
  13649. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  13650. switch {
  13651. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13652. id, exists := m.ID()
  13653. if exists {
  13654. return []uint64{id}, nil
  13655. }
  13656. fallthrough
  13657. case m.op.Is(OpUpdate | OpDelete):
  13658. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  13659. default:
  13660. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13661. }
  13662. }
  13663. // SetCreatedAt sets the "created_at" field.
  13664. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  13665. m.created_at = &t
  13666. }
  13667. // CreatedAt returns the value of the "created_at" field in the mutation.
  13668. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  13669. v := m.created_at
  13670. if v == nil {
  13671. return
  13672. }
  13673. return *v, true
  13674. }
  13675. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  13676. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13678. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13679. if !m.op.Is(OpUpdateOne) {
  13680. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13681. }
  13682. if m.id == nil || m.oldValue == nil {
  13683. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13684. }
  13685. oldValue, err := m.oldValue(ctx)
  13686. if err != nil {
  13687. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13688. }
  13689. return oldValue.CreatedAt, nil
  13690. }
  13691. // ResetCreatedAt resets all changes to the "created_at" field.
  13692. func (m *SopStageMutation) ResetCreatedAt() {
  13693. m.created_at = nil
  13694. }
  13695. // SetUpdatedAt sets the "updated_at" field.
  13696. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  13697. m.updated_at = &t
  13698. }
  13699. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13700. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  13701. v := m.updated_at
  13702. if v == nil {
  13703. return
  13704. }
  13705. return *v, true
  13706. }
  13707. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  13708. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13710. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13711. if !m.op.Is(OpUpdateOne) {
  13712. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13713. }
  13714. if m.id == nil || m.oldValue == nil {
  13715. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13716. }
  13717. oldValue, err := m.oldValue(ctx)
  13718. if err != nil {
  13719. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13720. }
  13721. return oldValue.UpdatedAt, nil
  13722. }
  13723. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13724. func (m *SopStageMutation) ResetUpdatedAt() {
  13725. m.updated_at = nil
  13726. }
  13727. // SetStatus sets the "status" field.
  13728. func (m *SopStageMutation) SetStatus(u uint8) {
  13729. m.status = &u
  13730. m.addstatus = nil
  13731. }
  13732. // Status returns the value of the "status" field in the mutation.
  13733. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  13734. v := m.status
  13735. if v == nil {
  13736. return
  13737. }
  13738. return *v, true
  13739. }
  13740. // OldStatus returns the old "status" field's value of the SopStage entity.
  13741. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13743. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13744. if !m.op.Is(OpUpdateOne) {
  13745. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13746. }
  13747. if m.id == nil || m.oldValue == nil {
  13748. return v, errors.New("OldStatus requires an ID field in the mutation")
  13749. }
  13750. oldValue, err := m.oldValue(ctx)
  13751. if err != nil {
  13752. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13753. }
  13754. return oldValue.Status, nil
  13755. }
  13756. // AddStatus adds u to the "status" field.
  13757. func (m *SopStageMutation) AddStatus(u int8) {
  13758. if m.addstatus != nil {
  13759. *m.addstatus += u
  13760. } else {
  13761. m.addstatus = &u
  13762. }
  13763. }
  13764. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13765. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  13766. v := m.addstatus
  13767. if v == nil {
  13768. return
  13769. }
  13770. return *v, true
  13771. }
  13772. // ClearStatus clears the value of the "status" field.
  13773. func (m *SopStageMutation) ClearStatus() {
  13774. m.status = nil
  13775. m.addstatus = nil
  13776. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  13777. }
  13778. // StatusCleared returns if the "status" field was cleared in this mutation.
  13779. func (m *SopStageMutation) StatusCleared() bool {
  13780. _, ok := m.clearedFields[sopstage.FieldStatus]
  13781. return ok
  13782. }
  13783. // ResetStatus resets all changes to the "status" field.
  13784. func (m *SopStageMutation) ResetStatus() {
  13785. m.status = nil
  13786. m.addstatus = nil
  13787. delete(m.clearedFields, sopstage.FieldStatus)
  13788. }
  13789. // SetDeletedAt sets the "deleted_at" field.
  13790. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  13791. m.deleted_at = &t
  13792. }
  13793. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13794. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  13795. v := m.deleted_at
  13796. if v == nil {
  13797. return
  13798. }
  13799. return *v, true
  13800. }
  13801. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  13802. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13803. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13804. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13805. if !m.op.Is(OpUpdateOne) {
  13806. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13807. }
  13808. if m.id == nil || m.oldValue == nil {
  13809. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13810. }
  13811. oldValue, err := m.oldValue(ctx)
  13812. if err != nil {
  13813. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13814. }
  13815. return oldValue.DeletedAt, nil
  13816. }
  13817. // ClearDeletedAt clears the value of the "deleted_at" field.
  13818. func (m *SopStageMutation) ClearDeletedAt() {
  13819. m.deleted_at = nil
  13820. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  13821. }
  13822. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13823. func (m *SopStageMutation) DeletedAtCleared() bool {
  13824. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  13825. return ok
  13826. }
  13827. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13828. func (m *SopStageMutation) ResetDeletedAt() {
  13829. m.deleted_at = nil
  13830. delete(m.clearedFields, sopstage.FieldDeletedAt)
  13831. }
  13832. // SetTaskID sets the "task_id" field.
  13833. func (m *SopStageMutation) SetTaskID(u uint64) {
  13834. m.sop_task = &u
  13835. }
  13836. // TaskID returns the value of the "task_id" field in the mutation.
  13837. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  13838. v := m.sop_task
  13839. if v == nil {
  13840. return
  13841. }
  13842. return *v, true
  13843. }
  13844. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  13845. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13847. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  13848. if !m.op.Is(OpUpdateOne) {
  13849. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  13850. }
  13851. if m.id == nil || m.oldValue == nil {
  13852. return v, errors.New("OldTaskID requires an ID field in the mutation")
  13853. }
  13854. oldValue, err := m.oldValue(ctx)
  13855. if err != nil {
  13856. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  13857. }
  13858. return oldValue.TaskID, nil
  13859. }
  13860. // ResetTaskID resets all changes to the "task_id" field.
  13861. func (m *SopStageMutation) ResetTaskID() {
  13862. m.sop_task = nil
  13863. }
  13864. // SetName sets the "name" field.
  13865. func (m *SopStageMutation) SetName(s string) {
  13866. m.name = &s
  13867. }
  13868. // Name returns the value of the "name" field in the mutation.
  13869. func (m *SopStageMutation) Name() (r string, exists bool) {
  13870. v := m.name
  13871. if v == nil {
  13872. return
  13873. }
  13874. return *v, true
  13875. }
  13876. // OldName returns the old "name" field's value of the SopStage entity.
  13877. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13879. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  13880. if !m.op.Is(OpUpdateOne) {
  13881. return v, errors.New("OldName is only allowed on UpdateOne operations")
  13882. }
  13883. if m.id == nil || m.oldValue == nil {
  13884. return v, errors.New("OldName requires an ID field in the mutation")
  13885. }
  13886. oldValue, err := m.oldValue(ctx)
  13887. if err != nil {
  13888. return v, fmt.Errorf("querying old value for OldName: %w", err)
  13889. }
  13890. return oldValue.Name, nil
  13891. }
  13892. // ResetName resets all changes to the "name" field.
  13893. func (m *SopStageMutation) ResetName() {
  13894. m.name = nil
  13895. }
  13896. // SetConditionType sets the "condition_type" field.
  13897. func (m *SopStageMutation) SetConditionType(i int) {
  13898. m.condition_type = &i
  13899. m.addcondition_type = nil
  13900. }
  13901. // ConditionType returns the value of the "condition_type" field in the mutation.
  13902. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  13903. v := m.condition_type
  13904. if v == nil {
  13905. return
  13906. }
  13907. return *v, true
  13908. }
  13909. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  13910. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13912. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  13913. if !m.op.Is(OpUpdateOne) {
  13914. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  13915. }
  13916. if m.id == nil || m.oldValue == nil {
  13917. return v, errors.New("OldConditionType requires an ID field in the mutation")
  13918. }
  13919. oldValue, err := m.oldValue(ctx)
  13920. if err != nil {
  13921. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  13922. }
  13923. return oldValue.ConditionType, nil
  13924. }
  13925. // AddConditionType adds i to the "condition_type" field.
  13926. func (m *SopStageMutation) AddConditionType(i int) {
  13927. if m.addcondition_type != nil {
  13928. *m.addcondition_type += i
  13929. } else {
  13930. m.addcondition_type = &i
  13931. }
  13932. }
  13933. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  13934. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  13935. v := m.addcondition_type
  13936. if v == nil {
  13937. return
  13938. }
  13939. return *v, true
  13940. }
  13941. // ResetConditionType resets all changes to the "condition_type" field.
  13942. func (m *SopStageMutation) ResetConditionType() {
  13943. m.condition_type = nil
  13944. m.addcondition_type = nil
  13945. }
  13946. // SetConditionOperator sets the "condition_operator" field.
  13947. func (m *SopStageMutation) SetConditionOperator(i int) {
  13948. m.condition_operator = &i
  13949. m.addcondition_operator = nil
  13950. }
  13951. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  13952. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  13953. v := m.condition_operator
  13954. if v == nil {
  13955. return
  13956. }
  13957. return *v, true
  13958. }
  13959. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  13960. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13961. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13962. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  13963. if !m.op.Is(OpUpdateOne) {
  13964. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  13965. }
  13966. if m.id == nil || m.oldValue == nil {
  13967. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  13968. }
  13969. oldValue, err := m.oldValue(ctx)
  13970. if err != nil {
  13971. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  13972. }
  13973. return oldValue.ConditionOperator, nil
  13974. }
  13975. // AddConditionOperator adds i to the "condition_operator" field.
  13976. func (m *SopStageMutation) AddConditionOperator(i int) {
  13977. if m.addcondition_operator != nil {
  13978. *m.addcondition_operator += i
  13979. } else {
  13980. m.addcondition_operator = &i
  13981. }
  13982. }
  13983. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  13984. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  13985. v := m.addcondition_operator
  13986. if v == nil {
  13987. return
  13988. }
  13989. return *v, true
  13990. }
  13991. // ResetConditionOperator resets all changes to the "condition_operator" field.
  13992. func (m *SopStageMutation) ResetConditionOperator() {
  13993. m.condition_operator = nil
  13994. m.addcondition_operator = nil
  13995. }
  13996. // SetConditionList sets the "condition_list" field.
  13997. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  13998. m.condition_list = &ct
  13999. m.appendcondition_list = nil
  14000. }
  14001. // ConditionList returns the value of the "condition_list" field in the mutation.
  14002. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  14003. v := m.condition_list
  14004. if v == nil {
  14005. return
  14006. }
  14007. return *v, true
  14008. }
  14009. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  14010. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14012. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  14013. if !m.op.Is(OpUpdateOne) {
  14014. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  14015. }
  14016. if m.id == nil || m.oldValue == nil {
  14017. return v, errors.New("OldConditionList requires an ID field in the mutation")
  14018. }
  14019. oldValue, err := m.oldValue(ctx)
  14020. if err != nil {
  14021. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  14022. }
  14023. return oldValue.ConditionList, nil
  14024. }
  14025. // AppendConditionList adds ct to the "condition_list" field.
  14026. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  14027. m.appendcondition_list = append(m.appendcondition_list, ct...)
  14028. }
  14029. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  14030. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  14031. if len(m.appendcondition_list) == 0 {
  14032. return nil, false
  14033. }
  14034. return m.appendcondition_list, true
  14035. }
  14036. // ResetConditionList resets all changes to the "condition_list" field.
  14037. func (m *SopStageMutation) ResetConditionList() {
  14038. m.condition_list = nil
  14039. m.appendcondition_list = nil
  14040. }
  14041. // SetActionMessage sets the "action_message" field.
  14042. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  14043. m.action_message = &ct
  14044. m.appendaction_message = nil
  14045. }
  14046. // ActionMessage returns the value of the "action_message" field in the mutation.
  14047. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  14048. v := m.action_message
  14049. if v == nil {
  14050. return
  14051. }
  14052. return *v, true
  14053. }
  14054. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  14055. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14057. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  14058. if !m.op.Is(OpUpdateOne) {
  14059. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  14060. }
  14061. if m.id == nil || m.oldValue == nil {
  14062. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  14063. }
  14064. oldValue, err := m.oldValue(ctx)
  14065. if err != nil {
  14066. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  14067. }
  14068. return oldValue.ActionMessage, nil
  14069. }
  14070. // AppendActionMessage adds ct to the "action_message" field.
  14071. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  14072. m.appendaction_message = append(m.appendaction_message, ct...)
  14073. }
  14074. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  14075. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  14076. if len(m.appendaction_message) == 0 {
  14077. return nil, false
  14078. }
  14079. return m.appendaction_message, true
  14080. }
  14081. // ClearActionMessage clears the value of the "action_message" field.
  14082. func (m *SopStageMutation) ClearActionMessage() {
  14083. m.action_message = nil
  14084. m.appendaction_message = nil
  14085. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  14086. }
  14087. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  14088. func (m *SopStageMutation) ActionMessageCleared() bool {
  14089. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  14090. return ok
  14091. }
  14092. // ResetActionMessage resets all changes to the "action_message" field.
  14093. func (m *SopStageMutation) ResetActionMessage() {
  14094. m.action_message = nil
  14095. m.appendaction_message = nil
  14096. delete(m.clearedFields, sopstage.FieldActionMessage)
  14097. }
  14098. // SetActionLabel sets the "action_label" field.
  14099. func (m *SopStageMutation) SetActionLabel(u []uint64) {
  14100. m.action_label = &u
  14101. m.appendaction_label = nil
  14102. }
  14103. // ActionLabel returns the value of the "action_label" field in the mutation.
  14104. func (m *SopStageMutation) ActionLabel() (r []uint64, exists bool) {
  14105. v := m.action_label
  14106. if v == nil {
  14107. return
  14108. }
  14109. return *v, true
  14110. }
  14111. // OldActionLabel returns the old "action_label" field's value of the SopStage entity.
  14112. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14114. func (m *SopStageMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  14115. if !m.op.Is(OpUpdateOne) {
  14116. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  14117. }
  14118. if m.id == nil || m.oldValue == nil {
  14119. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  14120. }
  14121. oldValue, err := m.oldValue(ctx)
  14122. if err != nil {
  14123. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  14124. }
  14125. return oldValue.ActionLabel, nil
  14126. }
  14127. // AppendActionLabel adds u to the "action_label" field.
  14128. func (m *SopStageMutation) AppendActionLabel(u []uint64) {
  14129. m.appendaction_label = append(m.appendaction_label, u...)
  14130. }
  14131. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  14132. func (m *SopStageMutation) AppendedActionLabel() ([]uint64, bool) {
  14133. if len(m.appendaction_label) == 0 {
  14134. return nil, false
  14135. }
  14136. return m.appendaction_label, true
  14137. }
  14138. // ClearActionLabel clears the value of the "action_label" field.
  14139. func (m *SopStageMutation) ClearActionLabel() {
  14140. m.action_label = nil
  14141. m.appendaction_label = nil
  14142. m.clearedFields[sopstage.FieldActionLabel] = struct{}{}
  14143. }
  14144. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  14145. func (m *SopStageMutation) ActionLabelCleared() bool {
  14146. _, ok := m.clearedFields[sopstage.FieldActionLabel]
  14147. return ok
  14148. }
  14149. // ResetActionLabel resets all changes to the "action_label" field.
  14150. func (m *SopStageMutation) ResetActionLabel() {
  14151. m.action_label = nil
  14152. m.appendaction_label = nil
  14153. delete(m.clearedFields, sopstage.FieldActionLabel)
  14154. }
  14155. // SetIndexSort sets the "index_sort" field.
  14156. func (m *SopStageMutation) SetIndexSort(i int) {
  14157. m.index_sort = &i
  14158. m.addindex_sort = nil
  14159. }
  14160. // IndexSort returns the value of the "index_sort" field in the mutation.
  14161. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  14162. v := m.index_sort
  14163. if v == nil {
  14164. return
  14165. }
  14166. return *v, true
  14167. }
  14168. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  14169. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14171. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  14172. if !m.op.Is(OpUpdateOne) {
  14173. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  14174. }
  14175. if m.id == nil || m.oldValue == nil {
  14176. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  14177. }
  14178. oldValue, err := m.oldValue(ctx)
  14179. if err != nil {
  14180. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  14181. }
  14182. return oldValue.IndexSort, nil
  14183. }
  14184. // AddIndexSort adds i to the "index_sort" field.
  14185. func (m *SopStageMutation) AddIndexSort(i int) {
  14186. if m.addindex_sort != nil {
  14187. *m.addindex_sort += i
  14188. } else {
  14189. m.addindex_sort = &i
  14190. }
  14191. }
  14192. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  14193. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  14194. v := m.addindex_sort
  14195. if v == nil {
  14196. return
  14197. }
  14198. return *v, true
  14199. }
  14200. // ClearIndexSort clears the value of the "index_sort" field.
  14201. func (m *SopStageMutation) ClearIndexSort() {
  14202. m.index_sort = nil
  14203. m.addindex_sort = nil
  14204. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  14205. }
  14206. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  14207. func (m *SopStageMutation) IndexSortCleared() bool {
  14208. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  14209. return ok
  14210. }
  14211. // ResetIndexSort resets all changes to the "index_sort" field.
  14212. func (m *SopStageMutation) ResetIndexSort() {
  14213. m.index_sort = nil
  14214. m.addindex_sort = nil
  14215. delete(m.clearedFields, sopstage.FieldIndexSort)
  14216. }
  14217. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  14218. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  14219. m.sop_task = &id
  14220. }
  14221. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  14222. func (m *SopStageMutation) ClearSopTask() {
  14223. m.clearedsop_task = true
  14224. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  14225. }
  14226. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  14227. func (m *SopStageMutation) SopTaskCleared() bool {
  14228. return m.clearedsop_task
  14229. }
  14230. // SopTaskID returns the "sop_task" edge ID in the mutation.
  14231. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  14232. if m.sop_task != nil {
  14233. return *m.sop_task, true
  14234. }
  14235. return
  14236. }
  14237. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  14238. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14239. // SopTaskID instead. It exists only for internal usage by the builders.
  14240. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  14241. if id := m.sop_task; id != nil {
  14242. ids = append(ids, *id)
  14243. }
  14244. return
  14245. }
  14246. // ResetSopTask resets all changes to the "sop_task" edge.
  14247. func (m *SopStageMutation) ResetSopTask() {
  14248. m.sop_task = nil
  14249. m.clearedsop_task = false
  14250. }
  14251. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  14252. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  14253. if m.stage_nodes == nil {
  14254. m.stage_nodes = make(map[uint64]struct{})
  14255. }
  14256. for i := range ids {
  14257. m.stage_nodes[ids[i]] = struct{}{}
  14258. }
  14259. }
  14260. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  14261. func (m *SopStageMutation) ClearStageNodes() {
  14262. m.clearedstage_nodes = true
  14263. }
  14264. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  14265. func (m *SopStageMutation) StageNodesCleared() bool {
  14266. return m.clearedstage_nodes
  14267. }
  14268. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  14269. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  14270. if m.removedstage_nodes == nil {
  14271. m.removedstage_nodes = make(map[uint64]struct{})
  14272. }
  14273. for i := range ids {
  14274. delete(m.stage_nodes, ids[i])
  14275. m.removedstage_nodes[ids[i]] = struct{}{}
  14276. }
  14277. }
  14278. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  14279. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  14280. for id := range m.removedstage_nodes {
  14281. ids = append(ids, id)
  14282. }
  14283. return
  14284. }
  14285. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  14286. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  14287. for id := range m.stage_nodes {
  14288. ids = append(ids, id)
  14289. }
  14290. return
  14291. }
  14292. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  14293. func (m *SopStageMutation) ResetStageNodes() {
  14294. m.stage_nodes = nil
  14295. m.clearedstage_nodes = false
  14296. m.removedstage_nodes = nil
  14297. }
  14298. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  14299. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  14300. if m.stage_messages == nil {
  14301. m.stage_messages = make(map[uint64]struct{})
  14302. }
  14303. for i := range ids {
  14304. m.stage_messages[ids[i]] = struct{}{}
  14305. }
  14306. }
  14307. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  14308. func (m *SopStageMutation) ClearStageMessages() {
  14309. m.clearedstage_messages = true
  14310. }
  14311. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  14312. func (m *SopStageMutation) StageMessagesCleared() bool {
  14313. return m.clearedstage_messages
  14314. }
  14315. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  14316. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  14317. if m.removedstage_messages == nil {
  14318. m.removedstage_messages = make(map[uint64]struct{})
  14319. }
  14320. for i := range ids {
  14321. delete(m.stage_messages, ids[i])
  14322. m.removedstage_messages[ids[i]] = struct{}{}
  14323. }
  14324. }
  14325. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  14326. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  14327. for id := range m.removedstage_messages {
  14328. ids = append(ids, id)
  14329. }
  14330. return
  14331. }
  14332. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  14333. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  14334. for id := range m.stage_messages {
  14335. ids = append(ids, id)
  14336. }
  14337. return
  14338. }
  14339. // ResetStageMessages resets all changes to the "stage_messages" edge.
  14340. func (m *SopStageMutation) ResetStageMessages() {
  14341. m.stage_messages = nil
  14342. m.clearedstage_messages = false
  14343. m.removedstage_messages = nil
  14344. }
  14345. // Where appends a list predicates to the SopStageMutation builder.
  14346. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  14347. m.predicates = append(m.predicates, ps...)
  14348. }
  14349. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  14350. // users can use type-assertion to append predicates that do not depend on any generated package.
  14351. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  14352. p := make([]predicate.SopStage, len(ps))
  14353. for i := range ps {
  14354. p[i] = ps[i]
  14355. }
  14356. m.Where(p...)
  14357. }
  14358. // Op returns the operation name.
  14359. func (m *SopStageMutation) Op() Op {
  14360. return m.op
  14361. }
  14362. // SetOp allows setting the mutation operation.
  14363. func (m *SopStageMutation) SetOp(op Op) {
  14364. m.op = op
  14365. }
  14366. // Type returns the node type of this mutation (SopStage).
  14367. func (m *SopStageMutation) Type() string {
  14368. return m.typ
  14369. }
  14370. // Fields returns all fields that were changed during this mutation. Note that in
  14371. // order to get all numeric fields that were incremented/decremented, call
  14372. // AddedFields().
  14373. func (m *SopStageMutation) Fields() []string {
  14374. fields := make([]string, 0, 12)
  14375. if m.created_at != nil {
  14376. fields = append(fields, sopstage.FieldCreatedAt)
  14377. }
  14378. if m.updated_at != nil {
  14379. fields = append(fields, sopstage.FieldUpdatedAt)
  14380. }
  14381. if m.status != nil {
  14382. fields = append(fields, sopstage.FieldStatus)
  14383. }
  14384. if m.deleted_at != nil {
  14385. fields = append(fields, sopstage.FieldDeletedAt)
  14386. }
  14387. if m.sop_task != nil {
  14388. fields = append(fields, sopstage.FieldTaskID)
  14389. }
  14390. if m.name != nil {
  14391. fields = append(fields, sopstage.FieldName)
  14392. }
  14393. if m.condition_type != nil {
  14394. fields = append(fields, sopstage.FieldConditionType)
  14395. }
  14396. if m.condition_operator != nil {
  14397. fields = append(fields, sopstage.FieldConditionOperator)
  14398. }
  14399. if m.condition_list != nil {
  14400. fields = append(fields, sopstage.FieldConditionList)
  14401. }
  14402. if m.action_message != nil {
  14403. fields = append(fields, sopstage.FieldActionMessage)
  14404. }
  14405. if m.action_label != nil {
  14406. fields = append(fields, sopstage.FieldActionLabel)
  14407. }
  14408. if m.index_sort != nil {
  14409. fields = append(fields, sopstage.FieldIndexSort)
  14410. }
  14411. return fields
  14412. }
  14413. // Field returns the value of a field with the given name. The second boolean
  14414. // return value indicates that this field was not set, or was not defined in the
  14415. // schema.
  14416. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  14417. switch name {
  14418. case sopstage.FieldCreatedAt:
  14419. return m.CreatedAt()
  14420. case sopstage.FieldUpdatedAt:
  14421. return m.UpdatedAt()
  14422. case sopstage.FieldStatus:
  14423. return m.Status()
  14424. case sopstage.FieldDeletedAt:
  14425. return m.DeletedAt()
  14426. case sopstage.FieldTaskID:
  14427. return m.TaskID()
  14428. case sopstage.FieldName:
  14429. return m.Name()
  14430. case sopstage.FieldConditionType:
  14431. return m.ConditionType()
  14432. case sopstage.FieldConditionOperator:
  14433. return m.ConditionOperator()
  14434. case sopstage.FieldConditionList:
  14435. return m.ConditionList()
  14436. case sopstage.FieldActionMessage:
  14437. return m.ActionMessage()
  14438. case sopstage.FieldActionLabel:
  14439. return m.ActionLabel()
  14440. case sopstage.FieldIndexSort:
  14441. return m.IndexSort()
  14442. }
  14443. return nil, false
  14444. }
  14445. // OldField returns the old value of the field from the database. An error is
  14446. // returned if the mutation operation is not UpdateOne, or the query to the
  14447. // database failed.
  14448. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14449. switch name {
  14450. case sopstage.FieldCreatedAt:
  14451. return m.OldCreatedAt(ctx)
  14452. case sopstage.FieldUpdatedAt:
  14453. return m.OldUpdatedAt(ctx)
  14454. case sopstage.FieldStatus:
  14455. return m.OldStatus(ctx)
  14456. case sopstage.FieldDeletedAt:
  14457. return m.OldDeletedAt(ctx)
  14458. case sopstage.FieldTaskID:
  14459. return m.OldTaskID(ctx)
  14460. case sopstage.FieldName:
  14461. return m.OldName(ctx)
  14462. case sopstage.FieldConditionType:
  14463. return m.OldConditionType(ctx)
  14464. case sopstage.FieldConditionOperator:
  14465. return m.OldConditionOperator(ctx)
  14466. case sopstage.FieldConditionList:
  14467. return m.OldConditionList(ctx)
  14468. case sopstage.FieldActionMessage:
  14469. return m.OldActionMessage(ctx)
  14470. case sopstage.FieldActionLabel:
  14471. return m.OldActionLabel(ctx)
  14472. case sopstage.FieldIndexSort:
  14473. return m.OldIndexSort(ctx)
  14474. }
  14475. return nil, fmt.Errorf("unknown SopStage field %s", name)
  14476. }
  14477. // SetField sets the value of a field with the given name. It returns an error if
  14478. // the field is not defined in the schema, or if the type mismatched the field
  14479. // type.
  14480. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  14481. switch name {
  14482. case sopstage.FieldCreatedAt:
  14483. v, ok := value.(time.Time)
  14484. if !ok {
  14485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14486. }
  14487. m.SetCreatedAt(v)
  14488. return nil
  14489. case sopstage.FieldUpdatedAt:
  14490. v, ok := value.(time.Time)
  14491. if !ok {
  14492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14493. }
  14494. m.SetUpdatedAt(v)
  14495. return nil
  14496. case sopstage.FieldStatus:
  14497. v, ok := value.(uint8)
  14498. if !ok {
  14499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14500. }
  14501. m.SetStatus(v)
  14502. return nil
  14503. case sopstage.FieldDeletedAt:
  14504. v, ok := value.(time.Time)
  14505. if !ok {
  14506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14507. }
  14508. m.SetDeletedAt(v)
  14509. return nil
  14510. case sopstage.FieldTaskID:
  14511. v, ok := value.(uint64)
  14512. if !ok {
  14513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14514. }
  14515. m.SetTaskID(v)
  14516. return nil
  14517. case sopstage.FieldName:
  14518. v, ok := value.(string)
  14519. if !ok {
  14520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14521. }
  14522. m.SetName(v)
  14523. return nil
  14524. case sopstage.FieldConditionType:
  14525. v, ok := value.(int)
  14526. if !ok {
  14527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14528. }
  14529. m.SetConditionType(v)
  14530. return nil
  14531. case sopstage.FieldConditionOperator:
  14532. v, ok := value.(int)
  14533. if !ok {
  14534. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14535. }
  14536. m.SetConditionOperator(v)
  14537. return nil
  14538. case sopstage.FieldConditionList:
  14539. v, ok := value.([]custom_types.Condition)
  14540. if !ok {
  14541. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14542. }
  14543. m.SetConditionList(v)
  14544. return nil
  14545. case sopstage.FieldActionMessage:
  14546. v, ok := value.([]custom_types.Action)
  14547. if !ok {
  14548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14549. }
  14550. m.SetActionMessage(v)
  14551. return nil
  14552. case sopstage.FieldActionLabel:
  14553. v, ok := value.([]uint64)
  14554. if !ok {
  14555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14556. }
  14557. m.SetActionLabel(v)
  14558. return nil
  14559. case sopstage.FieldIndexSort:
  14560. v, ok := value.(int)
  14561. if !ok {
  14562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14563. }
  14564. m.SetIndexSort(v)
  14565. return nil
  14566. }
  14567. return fmt.Errorf("unknown SopStage field %s", name)
  14568. }
  14569. // AddedFields returns all numeric fields that were incremented/decremented during
  14570. // this mutation.
  14571. func (m *SopStageMutation) AddedFields() []string {
  14572. var fields []string
  14573. if m.addstatus != nil {
  14574. fields = append(fields, sopstage.FieldStatus)
  14575. }
  14576. if m.addcondition_type != nil {
  14577. fields = append(fields, sopstage.FieldConditionType)
  14578. }
  14579. if m.addcondition_operator != nil {
  14580. fields = append(fields, sopstage.FieldConditionOperator)
  14581. }
  14582. if m.addindex_sort != nil {
  14583. fields = append(fields, sopstage.FieldIndexSort)
  14584. }
  14585. return fields
  14586. }
  14587. // AddedField returns the numeric value that was incremented/decremented on a field
  14588. // with the given name. The second boolean return value indicates that this field
  14589. // was not set, or was not defined in the schema.
  14590. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  14591. switch name {
  14592. case sopstage.FieldStatus:
  14593. return m.AddedStatus()
  14594. case sopstage.FieldConditionType:
  14595. return m.AddedConditionType()
  14596. case sopstage.FieldConditionOperator:
  14597. return m.AddedConditionOperator()
  14598. case sopstage.FieldIndexSort:
  14599. return m.AddedIndexSort()
  14600. }
  14601. return nil, false
  14602. }
  14603. // AddField adds the value to the field with the given name. It returns an error if
  14604. // the field is not defined in the schema, or if the type mismatched the field
  14605. // type.
  14606. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  14607. switch name {
  14608. case sopstage.FieldStatus:
  14609. v, ok := value.(int8)
  14610. if !ok {
  14611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14612. }
  14613. m.AddStatus(v)
  14614. return nil
  14615. case sopstage.FieldConditionType:
  14616. v, ok := value.(int)
  14617. if !ok {
  14618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14619. }
  14620. m.AddConditionType(v)
  14621. return nil
  14622. case sopstage.FieldConditionOperator:
  14623. v, ok := value.(int)
  14624. if !ok {
  14625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14626. }
  14627. m.AddConditionOperator(v)
  14628. return nil
  14629. case sopstage.FieldIndexSort:
  14630. v, ok := value.(int)
  14631. if !ok {
  14632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14633. }
  14634. m.AddIndexSort(v)
  14635. return nil
  14636. }
  14637. return fmt.Errorf("unknown SopStage numeric field %s", name)
  14638. }
  14639. // ClearedFields returns all nullable fields that were cleared during this
  14640. // mutation.
  14641. func (m *SopStageMutation) ClearedFields() []string {
  14642. var fields []string
  14643. if m.FieldCleared(sopstage.FieldStatus) {
  14644. fields = append(fields, sopstage.FieldStatus)
  14645. }
  14646. if m.FieldCleared(sopstage.FieldDeletedAt) {
  14647. fields = append(fields, sopstage.FieldDeletedAt)
  14648. }
  14649. if m.FieldCleared(sopstage.FieldActionMessage) {
  14650. fields = append(fields, sopstage.FieldActionMessage)
  14651. }
  14652. if m.FieldCleared(sopstage.FieldActionLabel) {
  14653. fields = append(fields, sopstage.FieldActionLabel)
  14654. }
  14655. if m.FieldCleared(sopstage.FieldIndexSort) {
  14656. fields = append(fields, sopstage.FieldIndexSort)
  14657. }
  14658. return fields
  14659. }
  14660. // FieldCleared returns a boolean indicating if a field with the given name was
  14661. // cleared in this mutation.
  14662. func (m *SopStageMutation) FieldCleared(name string) bool {
  14663. _, ok := m.clearedFields[name]
  14664. return ok
  14665. }
  14666. // ClearField clears the value of the field with the given name. It returns an
  14667. // error if the field is not defined in the schema.
  14668. func (m *SopStageMutation) ClearField(name string) error {
  14669. switch name {
  14670. case sopstage.FieldStatus:
  14671. m.ClearStatus()
  14672. return nil
  14673. case sopstage.FieldDeletedAt:
  14674. m.ClearDeletedAt()
  14675. return nil
  14676. case sopstage.FieldActionMessage:
  14677. m.ClearActionMessage()
  14678. return nil
  14679. case sopstage.FieldActionLabel:
  14680. m.ClearActionLabel()
  14681. return nil
  14682. case sopstage.FieldIndexSort:
  14683. m.ClearIndexSort()
  14684. return nil
  14685. }
  14686. return fmt.Errorf("unknown SopStage nullable field %s", name)
  14687. }
  14688. // ResetField resets all changes in the mutation for the field with the given name.
  14689. // It returns an error if the field is not defined in the schema.
  14690. func (m *SopStageMutation) ResetField(name string) error {
  14691. switch name {
  14692. case sopstage.FieldCreatedAt:
  14693. m.ResetCreatedAt()
  14694. return nil
  14695. case sopstage.FieldUpdatedAt:
  14696. m.ResetUpdatedAt()
  14697. return nil
  14698. case sopstage.FieldStatus:
  14699. m.ResetStatus()
  14700. return nil
  14701. case sopstage.FieldDeletedAt:
  14702. m.ResetDeletedAt()
  14703. return nil
  14704. case sopstage.FieldTaskID:
  14705. m.ResetTaskID()
  14706. return nil
  14707. case sopstage.FieldName:
  14708. m.ResetName()
  14709. return nil
  14710. case sopstage.FieldConditionType:
  14711. m.ResetConditionType()
  14712. return nil
  14713. case sopstage.FieldConditionOperator:
  14714. m.ResetConditionOperator()
  14715. return nil
  14716. case sopstage.FieldConditionList:
  14717. m.ResetConditionList()
  14718. return nil
  14719. case sopstage.FieldActionMessage:
  14720. m.ResetActionMessage()
  14721. return nil
  14722. case sopstage.FieldActionLabel:
  14723. m.ResetActionLabel()
  14724. return nil
  14725. case sopstage.FieldIndexSort:
  14726. m.ResetIndexSort()
  14727. return nil
  14728. }
  14729. return fmt.Errorf("unknown SopStage field %s", name)
  14730. }
  14731. // AddedEdges returns all edge names that were set/added in this mutation.
  14732. func (m *SopStageMutation) AddedEdges() []string {
  14733. edges := make([]string, 0, 3)
  14734. if m.sop_task != nil {
  14735. edges = append(edges, sopstage.EdgeSopTask)
  14736. }
  14737. if m.stage_nodes != nil {
  14738. edges = append(edges, sopstage.EdgeStageNodes)
  14739. }
  14740. if m.stage_messages != nil {
  14741. edges = append(edges, sopstage.EdgeStageMessages)
  14742. }
  14743. return edges
  14744. }
  14745. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14746. // name in this mutation.
  14747. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  14748. switch name {
  14749. case sopstage.EdgeSopTask:
  14750. if id := m.sop_task; id != nil {
  14751. return []ent.Value{*id}
  14752. }
  14753. case sopstage.EdgeStageNodes:
  14754. ids := make([]ent.Value, 0, len(m.stage_nodes))
  14755. for id := range m.stage_nodes {
  14756. ids = append(ids, id)
  14757. }
  14758. return ids
  14759. case sopstage.EdgeStageMessages:
  14760. ids := make([]ent.Value, 0, len(m.stage_messages))
  14761. for id := range m.stage_messages {
  14762. ids = append(ids, id)
  14763. }
  14764. return ids
  14765. }
  14766. return nil
  14767. }
  14768. // RemovedEdges returns all edge names that were removed in this mutation.
  14769. func (m *SopStageMutation) RemovedEdges() []string {
  14770. edges := make([]string, 0, 3)
  14771. if m.removedstage_nodes != nil {
  14772. edges = append(edges, sopstage.EdgeStageNodes)
  14773. }
  14774. if m.removedstage_messages != nil {
  14775. edges = append(edges, sopstage.EdgeStageMessages)
  14776. }
  14777. return edges
  14778. }
  14779. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14780. // the given name in this mutation.
  14781. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  14782. switch name {
  14783. case sopstage.EdgeStageNodes:
  14784. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  14785. for id := range m.removedstage_nodes {
  14786. ids = append(ids, id)
  14787. }
  14788. return ids
  14789. case sopstage.EdgeStageMessages:
  14790. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  14791. for id := range m.removedstage_messages {
  14792. ids = append(ids, id)
  14793. }
  14794. return ids
  14795. }
  14796. return nil
  14797. }
  14798. // ClearedEdges returns all edge names that were cleared in this mutation.
  14799. func (m *SopStageMutation) ClearedEdges() []string {
  14800. edges := make([]string, 0, 3)
  14801. if m.clearedsop_task {
  14802. edges = append(edges, sopstage.EdgeSopTask)
  14803. }
  14804. if m.clearedstage_nodes {
  14805. edges = append(edges, sopstage.EdgeStageNodes)
  14806. }
  14807. if m.clearedstage_messages {
  14808. edges = append(edges, sopstage.EdgeStageMessages)
  14809. }
  14810. return edges
  14811. }
  14812. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14813. // was cleared in this mutation.
  14814. func (m *SopStageMutation) EdgeCleared(name string) bool {
  14815. switch name {
  14816. case sopstage.EdgeSopTask:
  14817. return m.clearedsop_task
  14818. case sopstage.EdgeStageNodes:
  14819. return m.clearedstage_nodes
  14820. case sopstage.EdgeStageMessages:
  14821. return m.clearedstage_messages
  14822. }
  14823. return false
  14824. }
  14825. // ClearEdge clears the value of the edge with the given name. It returns an error
  14826. // if that edge is not defined in the schema.
  14827. func (m *SopStageMutation) ClearEdge(name string) error {
  14828. switch name {
  14829. case sopstage.EdgeSopTask:
  14830. m.ClearSopTask()
  14831. return nil
  14832. }
  14833. return fmt.Errorf("unknown SopStage unique edge %s", name)
  14834. }
  14835. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14836. // It returns an error if the edge is not defined in the schema.
  14837. func (m *SopStageMutation) ResetEdge(name string) error {
  14838. switch name {
  14839. case sopstage.EdgeSopTask:
  14840. m.ResetSopTask()
  14841. return nil
  14842. case sopstage.EdgeStageNodes:
  14843. m.ResetStageNodes()
  14844. return nil
  14845. case sopstage.EdgeStageMessages:
  14846. m.ResetStageMessages()
  14847. return nil
  14848. }
  14849. return fmt.Errorf("unknown SopStage edge %s", name)
  14850. }
  14851. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  14852. type SopTaskMutation struct {
  14853. config
  14854. op Op
  14855. typ string
  14856. id *uint64
  14857. created_at *time.Time
  14858. updated_at *time.Time
  14859. status *uint8
  14860. addstatus *int8
  14861. deleted_at *time.Time
  14862. name *string
  14863. bot_wxid_list *[]string
  14864. appendbot_wxid_list []string
  14865. _type *int
  14866. add_type *int
  14867. plan_start_time *time.Time
  14868. plan_end_time *time.Time
  14869. creator_id *string
  14870. organization_id *uint64
  14871. addorganization_id *int64
  14872. clearedFields map[string]struct{}
  14873. task_stages map[uint64]struct{}
  14874. removedtask_stages map[uint64]struct{}
  14875. clearedtask_stages bool
  14876. done bool
  14877. oldValue func(context.Context) (*SopTask, error)
  14878. predicates []predicate.SopTask
  14879. }
  14880. var _ ent.Mutation = (*SopTaskMutation)(nil)
  14881. // soptaskOption allows management of the mutation configuration using functional options.
  14882. type soptaskOption func(*SopTaskMutation)
  14883. // newSopTaskMutation creates new mutation for the SopTask entity.
  14884. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  14885. m := &SopTaskMutation{
  14886. config: c,
  14887. op: op,
  14888. typ: TypeSopTask,
  14889. clearedFields: make(map[string]struct{}),
  14890. }
  14891. for _, opt := range opts {
  14892. opt(m)
  14893. }
  14894. return m
  14895. }
  14896. // withSopTaskID sets the ID field of the mutation.
  14897. func withSopTaskID(id uint64) soptaskOption {
  14898. return func(m *SopTaskMutation) {
  14899. var (
  14900. err error
  14901. once sync.Once
  14902. value *SopTask
  14903. )
  14904. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  14905. once.Do(func() {
  14906. if m.done {
  14907. err = errors.New("querying old values post mutation is not allowed")
  14908. } else {
  14909. value, err = m.Client().SopTask.Get(ctx, id)
  14910. }
  14911. })
  14912. return value, err
  14913. }
  14914. m.id = &id
  14915. }
  14916. }
  14917. // withSopTask sets the old SopTask of the mutation.
  14918. func withSopTask(node *SopTask) soptaskOption {
  14919. return func(m *SopTaskMutation) {
  14920. m.oldValue = func(context.Context) (*SopTask, error) {
  14921. return node, nil
  14922. }
  14923. m.id = &node.ID
  14924. }
  14925. }
  14926. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14927. // executed in a transaction (ent.Tx), a transactional client is returned.
  14928. func (m SopTaskMutation) Client() *Client {
  14929. client := &Client{config: m.config}
  14930. client.init()
  14931. return client
  14932. }
  14933. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14934. // it returns an error otherwise.
  14935. func (m SopTaskMutation) Tx() (*Tx, error) {
  14936. if _, ok := m.driver.(*txDriver); !ok {
  14937. return nil, errors.New("ent: mutation is not running in a transaction")
  14938. }
  14939. tx := &Tx{config: m.config}
  14940. tx.init()
  14941. return tx, nil
  14942. }
  14943. // SetID sets the value of the id field. Note that this
  14944. // operation is only accepted on creation of SopTask entities.
  14945. func (m *SopTaskMutation) SetID(id uint64) {
  14946. m.id = &id
  14947. }
  14948. // ID returns the ID value in the mutation. Note that the ID is only available
  14949. // if it was provided to the builder or after it was returned from the database.
  14950. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  14951. if m.id == nil {
  14952. return
  14953. }
  14954. return *m.id, true
  14955. }
  14956. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14957. // That means, if the mutation is applied within a transaction with an isolation level such
  14958. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14959. // or updated by the mutation.
  14960. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  14961. switch {
  14962. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14963. id, exists := m.ID()
  14964. if exists {
  14965. return []uint64{id}, nil
  14966. }
  14967. fallthrough
  14968. case m.op.Is(OpUpdate | OpDelete):
  14969. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  14970. default:
  14971. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14972. }
  14973. }
  14974. // SetCreatedAt sets the "created_at" field.
  14975. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  14976. m.created_at = &t
  14977. }
  14978. // CreatedAt returns the value of the "created_at" field in the mutation.
  14979. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  14980. v := m.created_at
  14981. if v == nil {
  14982. return
  14983. }
  14984. return *v, true
  14985. }
  14986. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  14987. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14988. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14989. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14990. if !m.op.Is(OpUpdateOne) {
  14991. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14992. }
  14993. if m.id == nil || m.oldValue == nil {
  14994. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14995. }
  14996. oldValue, err := m.oldValue(ctx)
  14997. if err != nil {
  14998. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14999. }
  15000. return oldValue.CreatedAt, nil
  15001. }
  15002. // ResetCreatedAt resets all changes to the "created_at" field.
  15003. func (m *SopTaskMutation) ResetCreatedAt() {
  15004. m.created_at = nil
  15005. }
  15006. // SetUpdatedAt sets the "updated_at" field.
  15007. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  15008. m.updated_at = &t
  15009. }
  15010. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15011. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  15012. v := m.updated_at
  15013. if v == nil {
  15014. return
  15015. }
  15016. return *v, true
  15017. }
  15018. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  15019. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15021. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15022. if !m.op.Is(OpUpdateOne) {
  15023. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15024. }
  15025. if m.id == nil || m.oldValue == nil {
  15026. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15027. }
  15028. oldValue, err := m.oldValue(ctx)
  15029. if err != nil {
  15030. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15031. }
  15032. return oldValue.UpdatedAt, nil
  15033. }
  15034. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15035. func (m *SopTaskMutation) ResetUpdatedAt() {
  15036. m.updated_at = nil
  15037. }
  15038. // SetStatus sets the "status" field.
  15039. func (m *SopTaskMutation) SetStatus(u uint8) {
  15040. m.status = &u
  15041. m.addstatus = nil
  15042. }
  15043. // Status returns the value of the "status" field in the mutation.
  15044. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  15045. v := m.status
  15046. if v == nil {
  15047. return
  15048. }
  15049. return *v, true
  15050. }
  15051. // OldStatus returns the old "status" field's value of the SopTask entity.
  15052. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15054. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15055. if !m.op.Is(OpUpdateOne) {
  15056. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15057. }
  15058. if m.id == nil || m.oldValue == nil {
  15059. return v, errors.New("OldStatus requires an ID field in the mutation")
  15060. }
  15061. oldValue, err := m.oldValue(ctx)
  15062. if err != nil {
  15063. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15064. }
  15065. return oldValue.Status, nil
  15066. }
  15067. // AddStatus adds u to the "status" field.
  15068. func (m *SopTaskMutation) AddStatus(u int8) {
  15069. if m.addstatus != nil {
  15070. *m.addstatus += u
  15071. } else {
  15072. m.addstatus = &u
  15073. }
  15074. }
  15075. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15076. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  15077. v := m.addstatus
  15078. if v == nil {
  15079. return
  15080. }
  15081. return *v, true
  15082. }
  15083. // ClearStatus clears the value of the "status" field.
  15084. func (m *SopTaskMutation) ClearStatus() {
  15085. m.status = nil
  15086. m.addstatus = nil
  15087. m.clearedFields[soptask.FieldStatus] = struct{}{}
  15088. }
  15089. // StatusCleared returns if the "status" field was cleared in this mutation.
  15090. func (m *SopTaskMutation) StatusCleared() bool {
  15091. _, ok := m.clearedFields[soptask.FieldStatus]
  15092. return ok
  15093. }
  15094. // ResetStatus resets all changes to the "status" field.
  15095. func (m *SopTaskMutation) ResetStatus() {
  15096. m.status = nil
  15097. m.addstatus = nil
  15098. delete(m.clearedFields, soptask.FieldStatus)
  15099. }
  15100. // SetDeletedAt sets the "deleted_at" field.
  15101. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  15102. m.deleted_at = &t
  15103. }
  15104. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15105. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  15106. v := m.deleted_at
  15107. if v == nil {
  15108. return
  15109. }
  15110. return *v, true
  15111. }
  15112. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  15113. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15114. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15115. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15116. if !m.op.Is(OpUpdateOne) {
  15117. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15118. }
  15119. if m.id == nil || m.oldValue == nil {
  15120. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15121. }
  15122. oldValue, err := m.oldValue(ctx)
  15123. if err != nil {
  15124. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15125. }
  15126. return oldValue.DeletedAt, nil
  15127. }
  15128. // ClearDeletedAt clears the value of the "deleted_at" field.
  15129. func (m *SopTaskMutation) ClearDeletedAt() {
  15130. m.deleted_at = nil
  15131. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  15132. }
  15133. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15134. func (m *SopTaskMutation) DeletedAtCleared() bool {
  15135. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  15136. return ok
  15137. }
  15138. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15139. func (m *SopTaskMutation) ResetDeletedAt() {
  15140. m.deleted_at = nil
  15141. delete(m.clearedFields, soptask.FieldDeletedAt)
  15142. }
  15143. // SetName sets the "name" field.
  15144. func (m *SopTaskMutation) SetName(s string) {
  15145. m.name = &s
  15146. }
  15147. // Name returns the value of the "name" field in the mutation.
  15148. func (m *SopTaskMutation) Name() (r string, exists bool) {
  15149. v := m.name
  15150. if v == nil {
  15151. return
  15152. }
  15153. return *v, true
  15154. }
  15155. // OldName returns the old "name" field's value of the SopTask entity.
  15156. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15158. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  15159. if !m.op.Is(OpUpdateOne) {
  15160. return v, errors.New("OldName is only allowed on UpdateOne operations")
  15161. }
  15162. if m.id == nil || m.oldValue == nil {
  15163. return v, errors.New("OldName requires an ID field in the mutation")
  15164. }
  15165. oldValue, err := m.oldValue(ctx)
  15166. if err != nil {
  15167. return v, fmt.Errorf("querying old value for OldName: %w", err)
  15168. }
  15169. return oldValue.Name, nil
  15170. }
  15171. // ResetName resets all changes to the "name" field.
  15172. func (m *SopTaskMutation) ResetName() {
  15173. m.name = nil
  15174. }
  15175. // SetBotWxidList sets the "bot_wxid_list" field.
  15176. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  15177. m.bot_wxid_list = &s
  15178. m.appendbot_wxid_list = nil
  15179. }
  15180. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  15181. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  15182. v := m.bot_wxid_list
  15183. if v == nil {
  15184. return
  15185. }
  15186. return *v, true
  15187. }
  15188. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  15189. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15191. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  15192. if !m.op.Is(OpUpdateOne) {
  15193. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  15194. }
  15195. if m.id == nil || m.oldValue == nil {
  15196. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  15197. }
  15198. oldValue, err := m.oldValue(ctx)
  15199. if err != nil {
  15200. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  15201. }
  15202. return oldValue.BotWxidList, nil
  15203. }
  15204. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  15205. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  15206. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  15207. }
  15208. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  15209. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  15210. if len(m.appendbot_wxid_list) == 0 {
  15211. return nil, false
  15212. }
  15213. return m.appendbot_wxid_list, true
  15214. }
  15215. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  15216. func (m *SopTaskMutation) ClearBotWxidList() {
  15217. m.bot_wxid_list = nil
  15218. m.appendbot_wxid_list = nil
  15219. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  15220. }
  15221. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  15222. func (m *SopTaskMutation) BotWxidListCleared() bool {
  15223. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  15224. return ok
  15225. }
  15226. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  15227. func (m *SopTaskMutation) ResetBotWxidList() {
  15228. m.bot_wxid_list = nil
  15229. m.appendbot_wxid_list = nil
  15230. delete(m.clearedFields, soptask.FieldBotWxidList)
  15231. }
  15232. // SetType sets the "type" field.
  15233. func (m *SopTaskMutation) SetType(i int) {
  15234. m._type = &i
  15235. m.add_type = nil
  15236. }
  15237. // GetType returns the value of the "type" field in the mutation.
  15238. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  15239. v := m._type
  15240. if v == nil {
  15241. return
  15242. }
  15243. return *v, true
  15244. }
  15245. // OldType returns the old "type" field's value of the SopTask entity.
  15246. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15248. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  15249. if !m.op.Is(OpUpdateOne) {
  15250. return v, errors.New("OldType is only allowed on UpdateOne operations")
  15251. }
  15252. if m.id == nil || m.oldValue == nil {
  15253. return v, errors.New("OldType requires an ID field in the mutation")
  15254. }
  15255. oldValue, err := m.oldValue(ctx)
  15256. if err != nil {
  15257. return v, fmt.Errorf("querying old value for OldType: %w", err)
  15258. }
  15259. return oldValue.Type, nil
  15260. }
  15261. // AddType adds i to the "type" field.
  15262. func (m *SopTaskMutation) AddType(i int) {
  15263. if m.add_type != nil {
  15264. *m.add_type += i
  15265. } else {
  15266. m.add_type = &i
  15267. }
  15268. }
  15269. // AddedType returns the value that was added to the "type" field in this mutation.
  15270. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  15271. v := m.add_type
  15272. if v == nil {
  15273. return
  15274. }
  15275. return *v, true
  15276. }
  15277. // ResetType resets all changes to the "type" field.
  15278. func (m *SopTaskMutation) ResetType() {
  15279. m._type = nil
  15280. m.add_type = nil
  15281. }
  15282. // SetPlanStartTime sets the "plan_start_time" field.
  15283. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  15284. m.plan_start_time = &t
  15285. }
  15286. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  15287. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  15288. v := m.plan_start_time
  15289. if v == nil {
  15290. return
  15291. }
  15292. return *v, true
  15293. }
  15294. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  15295. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15296. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15297. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  15298. if !m.op.Is(OpUpdateOne) {
  15299. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  15300. }
  15301. if m.id == nil || m.oldValue == nil {
  15302. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  15303. }
  15304. oldValue, err := m.oldValue(ctx)
  15305. if err != nil {
  15306. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  15307. }
  15308. return oldValue.PlanStartTime, nil
  15309. }
  15310. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  15311. func (m *SopTaskMutation) ClearPlanStartTime() {
  15312. m.plan_start_time = nil
  15313. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  15314. }
  15315. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  15316. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  15317. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  15318. return ok
  15319. }
  15320. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  15321. func (m *SopTaskMutation) ResetPlanStartTime() {
  15322. m.plan_start_time = nil
  15323. delete(m.clearedFields, soptask.FieldPlanStartTime)
  15324. }
  15325. // SetPlanEndTime sets the "plan_end_time" field.
  15326. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  15327. m.plan_end_time = &t
  15328. }
  15329. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  15330. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  15331. v := m.plan_end_time
  15332. if v == nil {
  15333. return
  15334. }
  15335. return *v, true
  15336. }
  15337. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  15338. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15339. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15340. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  15341. if !m.op.Is(OpUpdateOne) {
  15342. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  15343. }
  15344. if m.id == nil || m.oldValue == nil {
  15345. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  15346. }
  15347. oldValue, err := m.oldValue(ctx)
  15348. if err != nil {
  15349. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  15350. }
  15351. return oldValue.PlanEndTime, nil
  15352. }
  15353. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  15354. func (m *SopTaskMutation) ClearPlanEndTime() {
  15355. m.plan_end_time = nil
  15356. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  15357. }
  15358. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  15359. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  15360. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  15361. return ok
  15362. }
  15363. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  15364. func (m *SopTaskMutation) ResetPlanEndTime() {
  15365. m.plan_end_time = nil
  15366. delete(m.clearedFields, soptask.FieldPlanEndTime)
  15367. }
  15368. // SetCreatorID sets the "creator_id" field.
  15369. func (m *SopTaskMutation) SetCreatorID(s string) {
  15370. m.creator_id = &s
  15371. }
  15372. // CreatorID returns the value of the "creator_id" field in the mutation.
  15373. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  15374. v := m.creator_id
  15375. if v == nil {
  15376. return
  15377. }
  15378. return *v, true
  15379. }
  15380. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  15381. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15383. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  15384. if !m.op.Is(OpUpdateOne) {
  15385. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  15386. }
  15387. if m.id == nil || m.oldValue == nil {
  15388. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  15389. }
  15390. oldValue, err := m.oldValue(ctx)
  15391. if err != nil {
  15392. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  15393. }
  15394. return oldValue.CreatorID, nil
  15395. }
  15396. // ClearCreatorID clears the value of the "creator_id" field.
  15397. func (m *SopTaskMutation) ClearCreatorID() {
  15398. m.creator_id = nil
  15399. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  15400. }
  15401. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  15402. func (m *SopTaskMutation) CreatorIDCleared() bool {
  15403. _, ok := m.clearedFields[soptask.FieldCreatorID]
  15404. return ok
  15405. }
  15406. // ResetCreatorID resets all changes to the "creator_id" field.
  15407. func (m *SopTaskMutation) ResetCreatorID() {
  15408. m.creator_id = nil
  15409. delete(m.clearedFields, soptask.FieldCreatorID)
  15410. }
  15411. // SetOrganizationID sets the "organization_id" field.
  15412. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  15413. m.organization_id = &u
  15414. m.addorganization_id = nil
  15415. }
  15416. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15417. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  15418. v := m.organization_id
  15419. if v == nil {
  15420. return
  15421. }
  15422. return *v, true
  15423. }
  15424. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  15425. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15427. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15428. if !m.op.Is(OpUpdateOne) {
  15429. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15430. }
  15431. if m.id == nil || m.oldValue == nil {
  15432. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15433. }
  15434. oldValue, err := m.oldValue(ctx)
  15435. if err != nil {
  15436. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15437. }
  15438. return oldValue.OrganizationID, nil
  15439. }
  15440. // AddOrganizationID adds u to the "organization_id" field.
  15441. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  15442. if m.addorganization_id != nil {
  15443. *m.addorganization_id += u
  15444. } else {
  15445. m.addorganization_id = &u
  15446. }
  15447. }
  15448. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15449. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  15450. v := m.addorganization_id
  15451. if v == nil {
  15452. return
  15453. }
  15454. return *v, true
  15455. }
  15456. // ClearOrganizationID clears the value of the "organization_id" field.
  15457. func (m *SopTaskMutation) ClearOrganizationID() {
  15458. m.organization_id = nil
  15459. m.addorganization_id = nil
  15460. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  15461. }
  15462. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15463. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  15464. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  15465. return ok
  15466. }
  15467. // ResetOrganizationID resets all changes to the "organization_id" field.
  15468. func (m *SopTaskMutation) ResetOrganizationID() {
  15469. m.organization_id = nil
  15470. m.addorganization_id = nil
  15471. delete(m.clearedFields, soptask.FieldOrganizationID)
  15472. }
  15473. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  15474. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  15475. if m.task_stages == nil {
  15476. m.task_stages = make(map[uint64]struct{})
  15477. }
  15478. for i := range ids {
  15479. m.task_stages[ids[i]] = struct{}{}
  15480. }
  15481. }
  15482. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  15483. func (m *SopTaskMutation) ClearTaskStages() {
  15484. m.clearedtask_stages = true
  15485. }
  15486. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  15487. func (m *SopTaskMutation) TaskStagesCleared() bool {
  15488. return m.clearedtask_stages
  15489. }
  15490. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  15491. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  15492. if m.removedtask_stages == nil {
  15493. m.removedtask_stages = make(map[uint64]struct{})
  15494. }
  15495. for i := range ids {
  15496. delete(m.task_stages, ids[i])
  15497. m.removedtask_stages[ids[i]] = struct{}{}
  15498. }
  15499. }
  15500. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  15501. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  15502. for id := range m.removedtask_stages {
  15503. ids = append(ids, id)
  15504. }
  15505. return
  15506. }
  15507. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  15508. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  15509. for id := range m.task_stages {
  15510. ids = append(ids, id)
  15511. }
  15512. return
  15513. }
  15514. // ResetTaskStages resets all changes to the "task_stages" edge.
  15515. func (m *SopTaskMutation) ResetTaskStages() {
  15516. m.task_stages = nil
  15517. m.clearedtask_stages = false
  15518. m.removedtask_stages = nil
  15519. }
  15520. // Where appends a list predicates to the SopTaskMutation builder.
  15521. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  15522. m.predicates = append(m.predicates, ps...)
  15523. }
  15524. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  15525. // users can use type-assertion to append predicates that do not depend on any generated package.
  15526. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  15527. p := make([]predicate.SopTask, len(ps))
  15528. for i := range ps {
  15529. p[i] = ps[i]
  15530. }
  15531. m.Where(p...)
  15532. }
  15533. // Op returns the operation name.
  15534. func (m *SopTaskMutation) Op() Op {
  15535. return m.op
  15536. }
  15537. // SetOp allows setting the mutation operation.
  15538. func (m *SopTaskMutation) SetOp(op Op) {
  15539. m.op = op
  15540. }
  15541. // Type returns the node type of this mutation (SopTask).
  15542. func (m *SopTaskMutation) Type() string {
  15543. return m.typ
  15544. }
  15545. // Fields returns all fields that were changed during this mutation. Note that in
  15546. // order to get all numeric fields that were incremented/decremented, call
  15547. // AddedFields().
  15548. func (m *SopTaskMutation) Fields() []string {
  15549. fields := make([]string, 0, 11)
  15550. if m.created_at != nil {
  15551. fields = append(fields, soptask.FieldCreatedAt)
  15552. }
  15553. if m.updated_at != nil {
  15554. fields = append(fields, soptask.FieldUpdatedAt)
  15555. }
  15556. if m.status != nil {
  15557. fields = append(fields, soptask.FieldStatus)
  15558. }
  15559. if m.deleted_at != nil {
  15560. fields = append(fields, soptask.FieldDeletedAt)
  15561. }
  15562. if m.name != nil {
  15563. fields = append(fields, soptask.FieldName)
  15564. }
  15565. if m.bot_wxid_list != nil {
  15566. fields = append(fields, soptask.FieldBotWxidList)
  15567. }
  15568. if m._type != nil {
  15569. fields = append(fields, soptask.FieldType)
  15570. }
  15571. if m.plan_start_time != nil {
  15572. fields = append(fields, soptask.FieldPlanStartTime)
  15573. }
  15574. if m.plan_end_time != nil {
  15575. fields = append(fields, soptask.FieldPlanEndTime)
  15576. }
  15577. if m.creator_id != nil {
  15578. fields = append(fields, soptask.FieldCreatorID)
  15579. }
  15580. if m.organization_id != nil {
  15581. fields = append(fields, soptask.FieldOrganizationID)
  15582. }
  15583. return fields
  15584. }
  15585. // Field returns the value of a field with the given name. The second boolean
  15586. // return value indicates that this field was not set, or was not defined in the
  15587. // schema.
  15588. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  15589. switch name {
  15590. case soptask.FieldCreatedAt:
  15591. return m.CreatedAt()
  15592. case soptask.FieldUpdatedAt:
  15593. return m.UpdatedAt()
  15594. case soptask.FieldStatus:
  15595. return m.Status()
  15596. case soptask.FieldDeletedAt:
  15597. return m.DeletedAt()
  15598. case soptask.FieldName:
  15599. return m.Name()
  15600. case soptask.FieldBotWxidList:
  15601. return m.BotWxidList()
  15602. case soptask.FieldType:
  15603. return m.GetType()
  15604. case soptask.FieldPlanStartTime:
  15605. return m.PlanStartTime()
  15606. case soptask.FieldPlanEndTime:
  15607. return m.PlanEndTime()
  15608. case soptask.FieldCreatorID:
  15609. return m.CreatorID()
  15610. case soptask.FieldOrganizationID:
  15611. return m.OrganizationID()
  15612. }
  15613. return nil, false
  15614. }
  15615. // OldField returns the old value of the field from the database. An error is
  15616. // returned if the mutation operation is not UpdateOne, or the query to the
  15617. // database failed.
  15618. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15619. switch name {
  15620. case soptask.FieldCreatedAt:
  15621. return m.OldCreatedAt(ctx)
  15622. case soptask.FieldUpdatedAt:
  15623. return m.OldUpdatedAt(ctx)
  15624. case soptask.FieldStatus:
  15625. return m.OldStatus(ctx)
  15626. case soptask.FieldDeletedAt:
  15627. return m.OldDeletedAt(ctx)
  15628. case soptask.FieldName:
  15629. return m.OldName(ctx)
  15630. case soptask.FieldBotWxidList:
  15631. return m.OldBotWxidList(ctx)
  15632. case soptask.FieldType:
  15633. return m.OldType(ctx)
  15634. case soptask.FieldPlanStartTime:
  15635. return m.OldPlanStartTime(ctx)
  15636. case soptask.FieldPlanEndTime:
  15637. return m.OldPlanEndTime(ctx)
  15638. case soptask.FieldCreatorID:
  15639. return m.OldCreatorID(ctx)
  15640. case soptask.FieldOrganizationID:
  15641. return m.OldOrganizationID(ctx)
  15642. }
  15643. return nil, fmt.Errorf("unknown SopTask field %s", name)
  15644. }
  15645. // SetField sets the value of a field with the given name. It returns an error if
  15646. // the field is not defined in the schema, or if the type mismatched the field
  15647. // type.
  15648. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  15649. switch name {
  15650. case soptask.FieldCreatedAt:
  15651. v, ok := value.(time.Time)
  15652. if !ok {
  15653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15654. }
  15655. m.SetCreatedAt(v)
  15656. return nil
  15657. case soptask.FieldUpdatedAt:
  15658. v, ok := value.(time.Time)
  15659. if !ok {
  15660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15661. }
  15662. m.SetUpdatedAt(v)
  15663. return nil
  15664. case soptask.FieldStatus:
  15665. v, ok := value.(uint8)
  15666. if !ok {
  15667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15668. }
  15669. m.SetStatus(v)
  15670. return nil
  15671. case soptask.FieldDeletedAt:
  15672. v, ok := value.(time.Time)
  15673. if !ok {
  15674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15675. }
  15676. m.SetDeletedAt(v)
  15677. return nil
  15678. case soptask.FieldName:
  15679. v, ok := value.(string)
  15680. if !ok {
  15681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15682. }
  15683. m.SetName(v)
  15684. return nil
  15685. case soptask.FieldBotWxidList:
  15686. v, ok := value.([]string)
  15687. if !ok {
  15688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15689. }
  15690. m.SetBotWxidList(v)
  15691. return nil
  15692. case soptask.FieldType:
  15693. v, ok := value.(int)
  15694. if !ok {
  15695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15696. }
  15697. m.SetType(v)
  15698. return nil
  15699. case soptask.FieldPlanStartTime:
  15700. v, ok := value.(time.Time)
  15701. if !ok {
  15702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15703. }
  15704. m.SetPlanStartTime(v)
  15705. return nil
  15706. case soptask.FieldPlanEndTime:
  15707. v, ok := value.(time.Time)
  15708. if !ok {
  15709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15710. }
  15711. m.SetPlanEndTime(v)
  15712. return nil
  15713. case soptask.FieldCreatorID:
  15714. v, ok := value.(string)
  15715. if !ok {
  15716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15717. }
  15718. m.SetCreatorID(v)
  15719. return nil
  15720. case soptask.FieldOrganizationID:
  15721. v, ok := value.(uint64)
  15722. if !ok {
  15723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15724. }
  15725. m.SetOrganizationID(v)
  15726. return nil
  15727. }
  15728. return fmt.Errorf("unknown SopTask field %s", name)
  15729. }
  15730. // AddedFields returns all numeric fields that were incremented/decremented during
  15731. // this mutation.
  15732. func (m *SopTaskMutation) AddedFields() []string {
  15733. var fields []string
  15734. if m.addstatus != nil {
  15735. fields = append(fields, soptask.FieldStatus)
  15736. }
  15737. if m.add_type != nil {
  15738. fields = append(fields, soptask.FieldType)
  15739. }
  15740. if m.addorganization_id != nil {
  15741. fields = append(fields, soptask.FieldOrganizationID)
  15742. }
  15743. return fields
  15744. }
  15745. // AddedField returns the numeric value that was incremented/decremented on a field
  15746. // with the given name. The second boolean return value indicates that this field
  15747. // was not set, or was not defined in the schema.
  15748. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  15749. switch name {
  15750. case soptask.FieldStatus:
  15751. return m.AddedStatus()
  15752. case soptask.FieldType:
  15753. return m.AddedType()
  15754. case soptask.FieldOrganizationID:
  15755. return m.AddedOrganizationID()
  15756. }
  15757. return nil, false
  15758. }
  15759. // AddField adds the value to the field with the given name. It returns an error if
  15760. // the field is not defined in the schema, or if the type mismatched the field
  15761. // type.
  15762. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  15763. switch name {
  15764. case soptask.FieldStatus:
  15765. v, ok := value.(int8)
  15766. if !ok {
  15767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15768. }
  15769. m.AddStatus(v)
  15770. return nil
  15771. case soptask.FieldType:
  15772. v, ok := value.(int)
  15773. if !ok {
  15774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15775. }
  15776. m.AddType(v)
  15777. return nil
  15778. case soptask.FieldOrganizationID:
  15779. v, ok := value.(int64)
  15780. if !ok {
  15781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15782. }
  15783. m.AddOrganizationID(v)
  15784. return nil
  15785. }
  15786. return fmt.Errorf("unknown SopTask numeric field %s", name)
  15787. }
  15788. // ClearedFields returns all nullable fields that were cleared during this
  15789. // mutation.
  15790. func (m *SopTaskMutation) ClearedFields() []string {
  15791. var fields []string
  15792. if m.FieldCleared(soptask.FieldStatus) {
  15793. fields = append(fields, soptask.FieldStatus)
  15794. }
  15795. if m.FieldCleared(soptask.FieldDeletedAt) {
  15796. fields = append(fields, soptask.FieldDeletedAt)
  15797. }
  15798. if m.FieldCleared(soptask.FieldBotWxidList) {
  15799. fields = append(fields, soptask.FieldBotWxidList)
  15800. }
  15801. if m.FieldCleared(soptask.FieldPlanStartTime) {
  15802. fields = append(fields, soptask.FieldPlanStartTime)
  15803. }
  15804. if m.FieldCleared(soptask.FieldPlanEndTime) {
  15805. fields = append(fields, soptask.FieldPlanEndTime)
  15806. }
  15807. if m.FieldCleared(soptask.FieldCreatorID) {
  15808. fields = append(fields, soptask.FieldCreatorID)
  15809. }
  15810. if m.FieldCleared(soptask.FieldOrganizationID) {
  15811. fields = append(fields, soptask.FieldOrganizationID)
  15812. }
  15813. return fields
  15814. }
  15815. // FieldCleared returns a boolean indicating if a field with the given name was
  15816. // cleared in this mutation.
  15817. func (m *SopTaskMutation) FieldCleared(name string) bool {
  15818. _, ok := m.clearedFields[name]
  15819. return ok
  15820. }
  15821. // ClearField clears the value of the field with the given name. It returns an
  15822. // error if the field is not defined in the schema.
  15823. func (m *SopTaskMutation) ClearField(name string) error {
  15824. switch name {
  15825. case soptask.FieldStatus:
  15826. m.ClearStatus()
  15827. return nil
  15828. case soptask.FieldDeletedAt:
  15829. m.ClearDeletedAt()
  15830. return nil
  15831. case soptask.FieldBotWxidList:
  15832. m.ClearBotWxidList()
  15833. return nil
  15834. case soptask.FieldPlanStartTime:
  15835. m.ClearPlanStartTime()
  15836. return nil
  15837. case soptask.FieldPlanEndTime:
  15838. m.ClearPlanEndTime()
  15839. return nil
  15840. case soptask.FieldCreatorID:
  15841. m.ClearCreatorID()
  15842. return nil
  15843. case soptask.FieldOrganizationID:
  15844. m.ClearOrganizationID()
  15845. return nil
  15846. }
  15847. return fmt.Errorf("unknown SopTask nullable field %s", name)
  15848. }
  15849. // ResetField resets all changes in the mutation for the field with the given name.
  15850. // It returns an error if the field is not defined in the schema.
  15851. func (m *SopTaskMutation) ResetField(name string) error {
  15852. switch name {
  15853. case soptask.FieldCreatedAt:
  15854. m.ResetCreatedAt()
  15855. return nil
  15856. case soptask.FieldUpdatedAt:
  15857. m.ResetUpdatedAt()
  15858. return nil
  15859. case soptask.FieldStatus:
  15860. m.ResetStatus()
  15861. return nil
  15862. case soptask.FieldDeletedAt:
  15863. m.ResetDeletedAt()
  15864. return nil
  15865. case soptask.FieldName:
  15866. m.ResetName()
  15867. return nil
  15868. case soptask.FieldBotWxidList:
  15869. m.ResetBotWxidList()
  15870. return nil
  15871. case soptask.FieldType:
  15872. m.ResetType()
  15873. return nil
  15874. case soptask.FieldPlanStartTime:
  15875. m.ResetPlanStartTime()
  15876. return nil
  15877. case soptask.FieldPlanEndTime:
  15878. m.ResetPlanEndTime()
  15879. return nil
  15880. case soptask.FieldCreatorID:
  15881. m.ResetCreatorID()
  15882. return nil
  15883. case soptask.FieldOrganizationID:
  15884. m.ResetOrganizationID()
  15885. return nil
  15886. }
  15887. return fmt.Errorf("unknown SopTask field %s", name)
  15888. }
  15889. // AddedEdges returns all edge names that were set/added in this mutation.
  15890. func (m *SopTaskMutation) AddedEdges() []string {
  15891. edges := make([]string, 0, 1)
  15892. if m.task_stages != nil {
  15893. edges = append(edges, soptask.EdgeTaskStages)
  15894. }
  15895. return edges
  15896. }
  15897. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15898. // name in this mutation.
  15899. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  15900. switch name {
  15901. case soptask.EdgeTaskStages:
  15902. ids := make([]ent.Value, 0, len(m.task_stages))
  15903. for id := range m.task_stages {
  15904. ids = append(ids, id)
  15905. }
  15906. return ids
  15907. }
  15908. return nil
  15909. }
  15910. // RemovedEdges returns all edge names that were removed in this mutation.
  15911. func (m *SopTaskMutation) RemovedEdges() []string {
  15912. edges := make([]string, 0, 1)
  15913. if m.removedtask_stages != nil {
  15914. edges = append(edges, soptask.EdgeTaskStages)
  15915. }
  15916. return edges
  15917. }
  15918. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15919. // the given name in this mutation.
  15920. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  15921. switch name {
  15922. case soptask.EdgeTaskStages:
  15923. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  15924. for id := range m.removedtask_stages {
  15925. ids = append(ids, id)
  15926. }
  15927. return ids
  15928. }
  15929. return nil
  15930. }
  15931. // ClearedEdges returns all edge names that were cleared in this mutation.
  15932. func (m *SopTaskMutation) ClearedEdges() []string {
  15933. edges := make([]string, 0, 1)
  15934. if m.clearedtask_stages {
  15935. edges = append(edges, soptask.EdgeTaskStages)
  15936. }
  15937. return edges
  15938. }
  15939. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15940. // was cleared in this mutation.
  15941. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  15942. switch name {
  15943. case soptask.EdgeTaskStages:
  15944. return m.clearedtask_stages
  15945. }
  15946. return false
  15947. }
  15948. // ClearEdge clears the value of the edge with the given name. It returns an error
  15949. // if that edge is not defined in the schema.
  15950. func (m *SopTaskMutation) ClearEdge(name string) error {
  15951. switch name {
  15952. }
  15953. return fmt.Errorf("unknown SopTask unique edge %s", name)
  15954. }
  15955. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15956. // It returns an error if the edge is not defined in the schema.
  15957. func (m *SopTaskMutation) ResetEdge(name string) error {
  15958. switch name {
  15959. case soptask.EdgeTaskStages:
  15960. m.ResetTaskStages()
  15961. return nil
  15962. }
  15963. return fmt.Errorf("unknown SopTask edge %s", name)
  15964. }
  15965. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  15966. type TokenMutation struct {
  15967. config
  15968. op Op
  15969. typ string
  15970. id *uint64
  15971. created_at *time.Time
  15972. updated_at *time.Time
  15973. deleted_at *time.Time
  15974. expire_at *time.Time
  15975. token *string
  15976. mac *string
  15977. clearedFields map[string]struct{}
  15978. done bool
  15979. oldValue func(context.Context) (*Token, error)
  15980. predicates []predicate.Token
  15981. }
  15982. var _ ent.Mutation = (*TokenMutation)(nil)
  15983. // tokenOption allows management of the mutation configuration using functional options.
  15984. type tokenOption func(*TokenMutation)
  15985. // newTokenMutation creates new mutation for the Token entity.
  15986. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  15987. m := &TokenMutation{
  15988. config: c,
  15989. op: op,
  15990. typ: TypeToken,
  15991. clearedFields: make(map[string]struct{}),
  15992. }
  15993. for _, opt := range opts {
  15994. opt(m)
  15995. }
  15996. return m
  15997. }
  15998. // withTokenID sets the ID field of the mutation.
  15999. func withTokenID(id uint64) tokenOption {
  16000. return func(m *TokenMutation) {
  16001. var (
  16002. err error
  16003. once sync.Once
  16004. value *Token
  16005. )
  16006. m.oldValue = func(ctx context.Context) (*Token, error) {
  16007. once.Do(func() {
  16008. if m.done {
  16009. err = errors.New("querying old values post mutation is not allowed")
  16010. } else {
  16011. value, err = m.Client().Token.Get(ctx, id)
  16012. }
  16013. })
  16014. return value, err
  16015. }
  16016. m.id = &id
  16017. }
  16018. }
  16019. // withToken sets the old Token of the mutation.
  16020. func withToken(node *Token) tokenOption {
  16021. return func(m *TokenMutation) {
  16022. m.oldValue = func(context.Context) (*Token, error) {
  16023. return node, nil
  16024. }
  16025. m.id = &node.ID
  16026. }
  16027. }
  16028. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16029. // executed in a transaction (ent.Tx), a transactional client is returned.
  16030. func (m TokenMutation) Client() *Client {
  16031. client := &Client{config: m.config}
  16032. client.init()
  16033. return client
  16034. }
  16035. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16036. // it returns an error otherwise.
  16037. func (m TokenMutation) Tx() (*Tx, error) {
  16038. if _, ok := m.driver.(*txDriver); !ok {
  16039. return nil, errors.New("ent: mutation is not running in a transaction")
  16040. }
  16041. tx := &Tx{config: m.config}
  16042. tx.init()
  16043. return tx, nil
  16044. }
  16045. // SetID sets the value of the id field. Note that this
  16046. // operation is only accepted on creation of Token entities.
  16047. func (m *TokenMutation) SetID(id uint64) {
  16048. m.id = &id
  16049. }
  16050. // ID returns the ID value in the mutation. Note that the ID is only available
  16051. // if it was provided to the builder or after it was returned from the database.
  16052. func (m *TokenMutation) ID() (id uint64, exists bool) {
  16053. if m.id == nil {
  16054. return
  16055. }
  16056. return *m.id, true
  16057. }
  16058. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16059. // That means, if the mutation is applied within a transaction with an isolation level such
  16060. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16061. // or updated by the mutation.
  16062. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  16063. switch {
  16064. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16065. id, exists := m.ID()
  16066. if exists {
  16067. return []uint64{id}, nil
  16068. }
  16069. fallthrough
  16070. case m.op.Is(OpUpdate | OpDelete):
  16071. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  16072. default:
  16073. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16074. }
  16075. }
  16076. // SetCreatedAt sets the "created_at" field.
  16077. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  16078. m.created_at = &t
  16079. }
  16080. // CreatedAt returns the value of the "created_at" field in the mutation.
  16081. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  16082. v := m.created_at
  16083. if v == nil {
  16084. return
  16085. }
  16086. return *v, true
  16087. }
  16088. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  16089. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16091. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16092. if !m.op.Is(OpUpdateOne) {
  16093. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16094. }
  16095. if m.id == nil || m.oldValue == nil {
  16096. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16097. }
  16098. oldValue, err := m.oldValue(ctx)
  16099. if err != nil {
  16100. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16101. }
  16102. return oldValue.CreatedAt, nil
  16103. }
  16104. // ResetCreatedAt resets all changes to the "created_at" field.
  16105. func (m *TokenMutation) ResetCreatedAt() {
  16106. m.created_at = nil
  16107. }
  16108. // SetUpdatedAt sets the "updated_at" field.
  16109. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  16110. m.updated_at = &t
  16111. }
  16112. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16113. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  16114. v := m.updated_at
  16115. if v == nil {
  16116. return
  16117. }
  16118. return *v, true
  16119. }
  16120. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  16121. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16122. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16123. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16124. if !m.op.Is(OpUpdateOne) {
  16125. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16126. }
  16127. if m.id == nil || m.oldValue == nil {
  16128. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16129. }
  16130. oldValue, err := m.oldValue(ctx)
  16131. if err != nil {
  16132. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16133. }
  16134. return oldValue.UpdatedAt, nil
  16135. }
  16136. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16137. func (m *TokenMutation) ResetUpdatedAt() {
  16138. m.updated_at = nil
  16139. }
  16140. // SetDeletedAt sets the "deleted_at" field.
  16141. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  16142. m.deleted_at = &t
  16143. }
  16144. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16145. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  16146. v := m.deleted_at
  16147. if v == nil {
  16148. return
  16149. }
  16150. return *v, true
  16151. }
  16152. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  16153. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16155. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16156. if !m.op.Is(OpUpdateOne) {
  16157. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16158. }
  16159. if m.id == nil || m.oldValue == nil {
  16160. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16161. }
  16162. oldValue, err := m.oldValue(ctx)
  16163. if err != nil {
  16164. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16165. }
  16166. return oldValue.DeletedAt, nil
  16167. }
  16168. // ClearDeletedAt clears the value of the "deleted_at" field.
  16169. func (m *TokenMutation) ClearDeletedAt() {
  16170. m.deleted_at = nil
  16171. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  16172. }
  16173. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16174. func (m *TokenMutation) DeletedAtCleared() bool {
  16175. _, ok := m.clearedFields[token.FieldDeletedAt]
  16176. return ok
  16177. }
  16178. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16179. func (m *TokenMutation) ResetDeletedAt() {
  16180. m.deleted_at = nil
  16181. delete(m.clearedFields, token.FieldDeletedAt)
  16182. }
  16183. // SetExpireAt sets the "expire_at" field.
  16184. func (m *TokenMutation) SetExpireAt(t time.Time) {
  16185. m.expire_at = &t
  16186. }
  16187. // ExpireAt returns the value of the "expire_at" field in the mutation.
  16188. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  16189. v := m.expire_at
  16190. if v == nil {
  16191. return
  16192. }
  16193. return *v, true
  16194. }
  16195. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  16196. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16197. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16198. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  16199. if !m.op.Is(OpUpdateOne) {
  16200. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  16201. }
  16202. if m.id == nil || m.oldValue == nil {
  16203. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  16204. }
  16205. oldValue, err := m.oldValue(ctx)
  16206. if err != nil {
  16207. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  16208. }
  16209. return oldValue.ExpireAt, nil
  16210. }
  16211. // ClearExpireAt clears the value of the "expire_at" field.
  16212. func (m *TokenMutation) ClearExpireAt() {
  16213. m.expire_at = nil
  16214. m.clearedFields[token.FieldExpireAt] = struct{}{}
  16215. }
  16216. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  16217. func (m *TokenMutation) ExpireAtCleared() bool {
  16218. _, ok := m.clearedFields[token.FieldExpireAt]
  16219. return ok
  16220. }
  16221. // ResetExpireAt resets all changes to the "expire_at" field.
  16222. func (m *TokenMutation) ResetExpireAt() {
  16223. m.expire_at = nil
  16224. delete(m.clearedFields, token.FieldExpireAt)
  16225. }
  16226. // SetToken sets the "token" field.
  16227. func (m *TokenMutation) SetToken(s string) {
  16228. m.token = &s
  16229. }
  16230. // Token returns the value of the "token" field in the mutation.
  16231. func (m *TokenMutation) Token() (r string, exists bool) {
  16232. v := m.token
  16233. if v == nil {
  16234. return
  16235. }
  16236. return *v, true
  16237. }
  16238. // OldToken returns the old "token" field's value of the Token entity.
  16239. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16241. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  16242. if !m.op.Is(OpUpdateOne) {
  16243. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  16244. }
  16245. if m.id == nil || m.oldValue == nil {
  16246. return v, errors.New("OldToken requires an ID field in the mutation")
  16247. }
  16248. oldValue, err := m.oldValue(ctx)
  16249. if err != nil {
  16250. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  16251. }
  16252. return oldValue.Token, nil
  16253. }
  16254. // ClearToken clears the value of the "token" field.
  16255. func (m *TokenMutation) ClearToken() {
  16256. m.token = nil
  16257. m.clearedFields[token.FieldToken] = struct{}{}
  16258. }
  16259. // TokenCleared returns if the "token" field was cleared in this mutation.
  16260. func (m *TokenMutation) TokenCleared() bool {
  16261. _, ok := m.clearedFields[token.FieldToken]
  16262. return ok
  16263. }
  16264. // ResetToken resets all changes to the "token" field.
  16265. func (m *TokenMutation) ResetToken() {
  16266. m.token = nil
  16267. delete(m.clearedFields, token.FieldToken)
  16268. }
  16269. // SetMAC sets the "mac" field.
  16270. func (m *TokenMutation) SetMAC(s string) {
  16271. m.mac = &s
  16272. }
  16273. // MAC returns the value of the "mac" field in the mutation.
  16274. func (m *TokenMutation) MAC() (r string, exists bool) {
  16275. v := m.mac
  16276. if v == nil {
  16277. return
  16278. }
  16279. return *v, true
  16280. }
  16281. // OldMAC returns the old "mac" field's value of the Token entity.
  16282. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16284. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  16285. if !m.op.Is(OpUpdateOne) {
  16286. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  16287. }
  16288. if m.id == nil || m.oldValue == nil {
  16289. return v, errors.New("OldMAC requires an ID field in the mutation")
  16290. }
  16291. oldValue, err := m.oldValue(ctx)
  16292. if err != nil {
  16293. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  16294. }
  16295. return oldValue.MAC, nil
  16296. }
  16297. // ResetMAC resets all changes to the "mac" field.
  16298. func (m *TokenMutation) ResetMAC() {
  16299. m.mac = nil
  16300. }
  16301. // Where appends a list predicates to the TokenMutation builder.
  16302. func (m *TokenMutation) Where(ps ...predicate.Token) {
  16303. m.predicates = append(m.predicates, ps...)
  16304. }
  16305. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  16306. // users can use type-assertion to append predicates that do not depend on any generated package.
  16307. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  16308. p := make([]predicate.Token, len(ps))
  16309. for i := range ps {
  16310. p[i] = ps[i]
  16311. }
  16312. m.Where(p...)
  16313. }
  16314. // Op returns the operation name.
  16315. func (m *TokenMutation) Op() Op {
  16316. return m.op
  16317. }
  16318. // SetOp allows setting the mutation operation.
  16319. func (m *TokenMutation) SetOp(op Op) {
  16320. m.op = op
  16321. }
  16322. // Type returns the node type of this mutation (Token).
  16323. func (m *TokenMutation) Type() string {
  16324. return m.typ
  16325. }
  16326. // Fields returns all fields that were changed during this mutation. Note that in
  16327. // order to get all numeric fields that were incremented/decremented, call
  16328. // AddedFields().
  16329. func (m *TokenMutation) Fields() []string {
  16330. fields := make([]string, 0, 6)
  16331. if m.created_at != nil {
  16332. fields = append(fields, token.FieldCreatedAt)
  16333. }
  16334. if m.updated_at != nil {
  16335. fields = append(fields, token.FieldUpdatedAt)
  16336. }
  16337. if m.deleted_at != nil {
  16338. fields = append(fields, token.FieldDeletedAt)
  16339. }
  16340. if m.expire_at != nil {
  16341. fields = append(fields, token.FieldExpireAt)
  16342. }
  16343. if m.token != nil {
  16344. fields = append(fields, token.FieldToken)
  16345. }
  16346. if m.mac != nil {
  16347. fields = append(fields, token.FieldMAC)
  16348. }
  16349. return fields
  16350. }
  16351. // Field returns the value of a field with the given name. The second boolean
  16352. // return value indicates that this field was not set, or was not defined in the
  16353. // schema.
  16354. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  16355. switch name {
  16356. case token.FieldCreatedAt:
  16357. return m.CreatedAt()
  16358. case token.FieldUpdatedAt:
  16359. return m.UpdatedAt()
  16360. case token.FieldDeletedAt:
  16361. return m.DeletedAt()
  16362. case token.FieldExpireAt:
  16363. return m.ExpireAt()
  16364. case token.FieldToken:
  16365. return m.Token()
  16366. case token.FieldMAC:
  16367. return m.MAC()
  16368. }
  16369. return nil, false
  16370. }
  16371. // OldField returns the old value of the field from the database. An error is
  16372. // returned if the mutation operation is not UpdateOne, or the query to the
  16373. // database failed.
  16374. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16375. switch name {
  16376. case token.FieldCreatedAt:
  16377. return m.OldCreatedAt(ctx)
  16378. case token.FieldUpdatedAt:
  16379. return m.OldUpdatedAt(ctx)
  16380. case token.FieldDeletedAt:
  16381. return m.OldDeletedAt(ctx)
  16382. case token.FieldExpireAt:
  16383. return m.OldExpireAt(ctx)
  16384. case token.FieldToken:
  16385. return m.OldToken(ctx)
  16386. case token.FieldMAC:
  16387. return m.OldMAC(ctx)
  16388. }
  16389. return nil, fmt.Errorf("unknown Token field %s", name)
  16390. }
  16391. // SetField sets the value of a field with the given name. It returns an error if
  16392. // the field is not defined in the schema, or if the type mismatched the field
  16393. // type.
  16394. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  16395. switch name {
  16396. case token.FieldCreatedAt:
  16397. v, ok := value.(time.Time)
  16398. if !ok {
  16399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16400. }
  16401. m.SetCreatedAt(v)
  16402. return nil
  16403. case token.FieldUpdatedAt:
  16404. v, ok := value.(time.Time)
  16405. if !ok {
  16406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16407. }
  16408. m.SetUpdatedAt(v)
  16409. return nil
  16410. case token.FieldDeletedAt:
  16411. v, ok := value.(time.Time)
  16412. if !ok {
  16413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16414. }
  16415. m.SetDeletedAt(v)
  16416. return nil
  16417. case token.FieldExpireAt:
  16418. v, ok := value.(time.Time)
  16419. if !ok {
  16420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16421. }
  16422. m.SetExpireAt(v)
  16423. return nil
  16424. case token.FieldToken:
  16425. v, ok := value.(string)
  16426. if !ok {
  16427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16428. }
  16429. m.SetToken(v)
  16430. return nil
  16431. case token.FieldMAC:
  16432. v, ok := value.(string)
  16433. if !ok {
  16434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16435. }
  16436. m.SetMAC(v)
  16437. return nil
  16438. }
  16439. return fmt.Errorf("unknown Token field %s", name)
  16440. }
  16441. // AddedFields returns all numeric fields that were incremented/decremented during
  16442. // this mutation.
  16443. func (m *TokenMutation) AddedFields() []string {
  16444. return nil
  16445. }
  16446. // AddedField returns the numeric value that was incremented/decremented on a field
  16447. // with the given name. The second boolean return value indicates that this field
  16448. // was not set, or was not defined in the schema.
  16449. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  16450. return nil, false
  16451. }
  16452. // AddField adds the value to the field with the given name. It returns an error if
  16453. // the field is not defined in the schema, or if the type mismatched the field
  16454. // type.
  16455. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  16456. switch name {
  16457. }
  16458. return fmt.Errorf("unknown Token numeric field %s", name)
  16459. }
  16460. // ClearedFields returns all nullable fields that were cleared during this
  16461. // mutation.
  16462. func (m *TokenMutation) ClearedFields() []string {
  16463. var fields []string
  16464. if m.FieldCleared(token.FieldDeletedAt) {
  16465. fields = append(fields, token.FieldDeletedAt)
  16466. }
  16467. if m.FieldCleared(token.FieldExpireAt) {
  16468. fields = append(fields, token.FieldExpireAt)
  16469. }
  16470. if m.FieldCleared(token.FieldToken) {
  16471. fields = append(fields, token.FieldToken)
  16472. }
  16473. return fields
  16474. }
  16475. // FieldCleared returns a boolean indicating if a field with the given name was
  16476. // cleared in this mutation.
  16477. func (m *TokenMutation) FieldCleared(name string) bool {
  16478. _, ok := m.clearedFields[name]
  16479. return ok
  16480. }
  16481. // ClearField clears the value of the field with the given name. It returns an
  16482. // error if the field is not defined in the schema.
  16483. func (m *TokenMutation) ClearField(name string) error {
  16484. switch name {
  16485. case token.FieldDeletedAt:
  16486. m.ClearDeletedAt()
  16487. return nil
  16488. case token.FieldExpireAt:
  16489. m.ClearExpireAt()
  16490. return nil
  16491. case token.FieldToken:
  16492. m.ClearToken()
  16493. return nil
  16494. }
  16495. return fmt.Errorf("unknown Token nullable field %s", name)
  16496. }
  16497. // ResetField resets all changes in the mutation for the field with the given name.
  16498. // It returns an error if the field is not defined in the schema.
  16499. func (m *TokenMutation) ResetField(name string) error {
  16500. switch name {
  16501. case token.FieldCreatedAt:
  16502. m.ResetCreatedAt()
  16503. return nil
  16504. case token.FieldUpdatedAt:
  16505. m.ResetUpdatedAt()
  16506. return nil
  16507. case token.FieldDeletedAt:
  16508. m.ResetDeletedAt()
  16509. return nil
  16510. case token.FieldExpireAt:
  16511. m.ResetExpireAt()
  16512. return nil
  16513. case token.FieldToken:
  16514. m.ResetToken()
  16515. return nil
  16516. case token.FieldMAC:
  16517. m.ResetMAC()
  16518. return nil
  16519. }
  16520. return fmt.Errorf("unknown Token field %s", name)
  16521. }
  16522. // AddedEdges returns all edge names that were set/added in this mutation.
  16523. func (m *TokenMutation) AddedEdges() []string {
  16524. edges := make([]string, 0, 0)
  16525. return edges
  16526. }
  16527. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16528. // name in this mutation.
  16529. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  16530. return nil
  16531. }
  16532. // RemovedEdges returns all edge names that were removed in this mutation.
  16533. func (m *TokenMutation) RemovedEdges() []string {
  16534. edges := make([]string, 0, 0)
  16535. return edges
  16536. }
  16537. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16538. // the given name in this mutation.
  16539. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  16540. return nil
  16541. }
  16542. // ClearedEdges returns all edge names that were cleared in this mutation.
  16543. func (m *TokenMutation) ClearedEdges() []string {
  16544. edges := make([]string, 0, 0)
  16545. return edges
  16546. }
  16547. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16548. // was cleared in this mutation.
  16549. func (m *TokenMutation) EdgeCleared(name string) bool {
  16550. return false
  16551. }
  16552. // ClearEdge clears the value of the edge with the given name. It returns an error
  16553. // if that edge is not defined in the schema.
  16554. func (m *TokenMutation) ClearEdge(name string) error {
  16555. return fmt.Errorf("unknown Token unique edge %s", name)
  16556. }
  16557. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16558. // It returns an error if the edge is not defined in the schema.
  16559. func (m *TokenMutation) ResetEdge(name string) error {
  16560. return fmt.Errorf("unknown Token edge %s", name)
  16561. }
  16562. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  16563. type TutorialMutation struct {
  16564. config
  16565. op Op
  16566. typ string
  16567. id *uint64
  16568. created_at *time.Time
  16569. updated_at *time.Time
  16570. deleted_at *time.Time
  16571. index *int
  16572. addindex *int
  16573. title *string
  16574. content *string
  16575. organization_id *uint64
  16576. addorganization_id *int64
  16577. clearedFields map[string]struct{}
  16578. employee *uint64
  16579. clearedemployee bool
  16580. done bool
  16581. oldValue func(context.Context) (*Tutorial, error)
  16582. predicates []predicate.Tutorial
  16583. }
  16584. var _ ent.Mutation = (*TutorialMutation)(nil)
  16585. // tutorialOption allows management of the mutation configuration using functional options.
  16586. type tutorialOption func(*TutorialMutation)
  16587. // newTutorialMutation creates new mutation for the Tutorial entity.
  16588. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  16589. m := &TutorialMutation{
  16590. config: c,
  16591. op: op,
  16592. typ: TypeTutorial,
  16593. clearedFields: make(map[string]struct{}),
  16594. }
  16595. for _, opt := range opts {
  16596. opt(m)
  16597. }
  16598. return m
  16599. }
  16600. // withTutorialID sets the ID field of the mutation.
  16601. func withTutorialID(id uint64) tutorialOption {
  16602. return func(m *TutorialMutation) {
  16603. var (
  16604. err error
  16605. once sync.Once
  16606. value *Tutorial
  16607. )
  16608. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  16609. once.Do(func() {
  16610. if m.done {
  16611. err = errors.New("querying old values post mutation is not allowed")
  16612. } else {
  16613. value, err = m.Client().Tutorial.Get(ctx, id)
  16614. }
  16615. })
  16616. return value, err
  16617. }
  16618. m.id = &id
  16619. }
  16620. }
  16621. // withTutorial sets the old Tutorial of the mutation.
  16622. func withTutorial(node *Tutorial) tutorialOption {
  16623. return func(m *TutorialMutation) {
  16624. m.oldValue = func(context.Context) (*Tutorial, error) {
  16625. return node, nil
  16626. }
  16627. m.id = &node.ID
  16628. }
  16629. }
  16630. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16631. // executed in a transaction (ent.Tx), a transactional client is returned.
  16632. func (m TutorialMutation) Client() *Client {
  16633. client := &Client{config: m.config}
  16634. client.init()
  16635. return client
  16636. }
  16637. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16638. // it returns an error otherwise.
  16639. func (m TutorialMutation) Tx() (*Tx, error) {
  16640. if _, ok := m.driver.(*txDriver); !ok {
  16641. return nil, errors.New("ent: mutation is not running in a transaction")
  16642. }
  16643. tx := &Tx{config: m.config}
  16644. tx.init()
  16645. return tx, nil
  16646. }
  16647. // SetID sets the value of the id field. Note that this
  16648. // operation is only accepted on creation of Tutorial entities.
  16649. func (m *TutorialMutation) SetID(id uint64) {
  16650. m.id = &id
  16651. }
  16652. // ID returns the ID value in the mutation. Note that the ID is only available
  16653. // if it was provided to the builder or after it was returned from the database.
  16654. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  16655. if m.id == nil {
  16656. return
  16657. }
  16658. return *m.id, true
  16659. }
  16660. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16661. // That means, if the mutation is applied within a transaction with an isolation level such
  16662. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16663. // or updated by the mutation.
  16664. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  16665. switch {
  16666. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16667. id, exists := m.ID()
  16668. if exists {
  16669. return []uint64{id}, nil
  16670. }
  16671. fallthrough
  16672. case m.op.Is(OpUpdate | OpDelete):
  16673. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  16674. default:
  16675. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16676. }
  16677. }
  16678. // SetCreatedAt sets the "created_at" field.
  16679. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  16680. m.created_at = &t
  16681. }
  16682. // CreatedAt returns the value of the "created_at" field in the mutation.
  16683. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  16684. v := m.created_at
  16685. if v == nil {
  16686. return
  16687. }
  16688. return *v, true
  16689. }
  16690. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  16691. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16692. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16693. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16694. if !m.op.Is(OpUpdateOne) {
  16695. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16696. }
  16697. if m.id == nil || m.oldValue == nil {
  16698. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16699. }
  16700. oldValue, err := m.oldValue(ctx)
  16701. if err != nil {
  16702. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16703. }
  16704. return oldValue.CreatedAt, nil
  16705. }
  16706. // ResetCreatedAt resets all changes to the "created_at" field.
  16707. func (m *TutorialMutation) ResetCreatedAt() {
  16708. m.created_at = nil
  16709. }
  16710. // SetUpdatedAt sets the "updated_at" field.
  16711. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  16712. m.updated_at = &t
  16713. }
  16714. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16715. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  16716. v := m.updated_at
  16717. if v == nil {
  16718. return
  16719. }
  16720. return *v, true
  16721. }
  16722. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  16723. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16724. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16725. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16726. if !m.op.Is(OpUpdateOne) {
  16727. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16728. }
  16729. if m.id == nil || m.oldValue == nil {
  16730. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16731. }
  16732. oldValue, err := m.oldValue(ctx)
  16733. if err != nil {
  16734. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16735. }
  16736. return oldValue.UpdatedAt, nil
  16737. }
  16738. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16739. func (m *TutorialMutation) ResetUpdatedAt() {
  16740. m.updated_at = nil
  16741. }
  16742. // SetDeletedAt sets the "deleted_at" field.
  16743. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  16744. m.deleted_at = &t
  16745. }
  16746. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16747. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  16748. v := m.deleted_at
  16749. if v == nil {
  16750. return
  16751. }
  16752. return *v, true
  16753. }
  16754. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  16755. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16757. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16758. if !m.op.Is(OpUpdateOne) {
  16759. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16760. }
  16761. if m.id == nil || m.oldValue == nil {
  16762. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16763. }
  16764. oldValue, err := m.oldValue(ctx)
  16765. if err != nil {
  16766. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16767. }
  16768. return oldValue.DeletedAt, nil
  16769. }
  16770. // ClearDeletedAt clears the value of the "deleted_at" field.
  16771. func (m *TutorialMutation) ClearDeletedAt() {
  16772. m.deleted_at = nil
  16773. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  16774. }
  16775. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16776. func (m *TutorialMutation) DeletedAtCleared() bool {
  16777. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  16778. return ok
  16779. }
  16780. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16781. func (m *TutorialMutation) ResetDeletedAt() {
  16782. m.deleted_at = nil
  16783. delete(m.clearedFields, tutorial.FieldDeletedAt)
  16784. }
  16785. // SetEmployeeID sets the "employee_id" field.
  16786. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  16787. m.employee = &u
  16788. }
  16789. // EmployeeID returns the value of the "employee_id" field in the mutation.
  16790. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  16791. v := m.employee
  16792. if v == nil {
  16793. return
  16794. }
  16795. return *v, true
  16796. }
  16797. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  16798. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16800. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  16801. if !m.op.Is(OpUpdateOne) {
  16802. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  16803. }
  16804. if m.id == nil || m.oldValue == nil {
  16805. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  16806. }
  16807. oldValue, err := m.oldValue(ctx)
  16808. if err != nil {
  16809. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  16810. }
  16811. return oldValue.EmployeeID, nil
  16812. }
  16813. // ResetEmployeeID resets all changes to the "employee_id" field.
  16814. func (m *TutorialMutation) ResetEmployeeID() {
  16815. m.employee = nil
  16816. }
  16817. // SetIndex sets the "index" field.
  16818. func (m *TutorialMutation) SetIndex(i int) {
  16819. m.index = &i
  16820. m.addindex = nil
  16821. }
  16822. // Index returns the value of the "index" field in the mutation.
  16823. func (m *TutorialMutation) Index() (r int, exists bool) {
  16824. v := m.index
  16825. if v == nil {
  16826. return
  16827. }
  16828. return *v, true
  16829. }
  16830. // OldIndex returns the old "index" field's value of the Tutorial entity.
  16831. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16833. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  16834. if !m.op.Is(OpUpdateOne) {
  16835. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  16836. }
  16837. if m.id == nil || m.oldValue == nil {
  16838. return v, errors.New("OldIndex requires an ID field in the mutation")
  16839. }
  16840. oldValue, err := m.oldValue(ctx)
  16841. if err != nil {
  16842. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  16843. }
  16844. return oldValue.Index, nil
  16845. }
  16846. // AddIndex adds i to the "index" field.
  16847. func (m *TutorialMutation) AddIndex(i int) {
  16848. if m.addindex != nil {
  16849. *m.addindex += i
  16850. } else {
  16851. m.addindex = &i
  16852. }
  16853. }
  16854. // AddedIndex returns the value that was added to the "index" field in this mutation.
  16855. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  16856. v := m.addindex
  16857. if v == nil {
  16858. return
  16859. }
  16860. return *v, true
  16861. }
  16862. // ResetIndex resets all changes to the "index" field.
  16863. func (m *TutorialMutation) ResetIndex() {
  16864. m.index = nil
  16865. m.addindex = nil
  16866. }
  16867. // SetTitle sets the "title" field.
  16868. func (m *TutorialMutation) SetTitle(s string) {
  16869. m.title = &s
  16870. }
  16871. // Title returns the value of the "title" field in the mutation.
  16872. func (m *TutorialMutation) Title() (r string, exists bool) {
  16873. v := m.title
  16874. if v == nil {
  16875. return
  16876. }
  16877. return *v, true
  16878. }
  16879. // OldTitle returns the old "title" field's value of the Tutorial entity.
  16880. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16882. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  16883. if !m.op.Is(OpUpdateOne) {
  16884. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  16885. }
  16886. if m.id == nil || m.oldValue == nil {
  16887. return v, errors.New("OldTitle requires an ID field in the mutation")
  16888. }
  16889. oldValue, err := m.oldValue(ctx)
  16890. if err != nil {
  16891. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  16892. }
  16893. return oldValue.Title, nil
  16894. }
  16895. // ResetTitle resets all changes to the "title" field.
  16896. func (m *TutorialMutation) ResetTitle() {
  16897. m.title = nil
  16898. }
  16899. // SetContent sets the "content" field.
  16900. func (m *TutorialMutation) SetContent(s string) {
  16901. m.content = &s
  16902. }
  16903. // Content returns the value of the "content" field in the mutation.
  16904. func (m *TutorialMutation) Content() (r string, exists bool) {
  16905. v := m.content
  16906. if v == nil {
  16907. return
  16908. }
  16909. return *v, true
  16910. }
  16911. // OldContent returns the old "content" field's value of the Tutorial entity.
  16912. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16914. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  16915. if !m.op.Is(OpUpdateOne) {
  16916. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  16917. }
  16918. if m.id == nil || m.oldValue == nil {
  16919. return v, errors.New("OldContent requires an ID field in the mutation")
  16920. }
  16921. oldValue, err := m.oldValue(ctx)
  16922. if err != nil {
  16923. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  16924. }
  16925. return oldValue.Content, nil
  16926. }
  16927. // ResetContent resets all changes to the "content" field.
  16928. func (m *TutorialMutation) ResetContent() {
  16929. m.content = nil
  16930. }
  16931. // SetOrganizationID sets the "organization_id" field.
  16932. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  16933. m.organization_id = &u
  16934. m.addorganization_id = nil
  16935. }
  16936. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16937. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  16938. v := m.organization_id
  16939. if v == nil {
  16940. return
  16941. }
  16942. return *v, true
  16943. }
  16944. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  16945. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16947. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16948. if !m.op.Is(OpUpdateOne) {
  16949. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16950. }
  16951. if m.id == nil || m.oldValue == nil {
  16952. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16953. }
  16954. oldValue, err := m.oldValue(ctx)
  16955. if err != nil {
  16956. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16957. }
  16958. return oldValue.OrganizationID, nil
  16959. }
  16960. // AddOrganizationID adds u to the "organization_id" field.
  16961. func (m *TutorialMutation) AddOrganizationID(u int64) {
  16962. if m.addorganization_id != nil {
  16963. *m.addorganization_id += u
  16964. } else {
  16965. m.addorganization_id = &u
  16966. }
  16967. }
  16968. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16969. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  16970. v := m.addorganization_id
  16971. if v == nil {
  16972. return
  16973. }
  16974. return *v, true
  16975. }
  16976. // ResetOrganizationID resets all changes to the "organization_id" field.
  16977. func (m *TutorialMutation) ResetOrganizationID() {
  16978. m.organization_id = nil
  16979. m.addorganization_id = nil
  16980. }
  16981. // ClearEmployee clears the "employee" edge to the Employee entity.
  16982. func (m *TutorialMutation) ClearEmployee() {
  16983. m.clearedemployee = true
  16984. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  16985. }
  16986. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  16987. func (m *TutorialMutation) EmployeeCleared() bool {
  16988. return m.clearedemployee
  16989. }
  16990. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  16991. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  16992. // EmployeeID instead. It exists only for internal usage by the builders.
  16993. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  16994. if id := m.employee; id != nil {
  16995. ids = append(ids, *id)
  16996. }
  16997. return
  16998. }
  16999. // ResetEmployee resets all changes to the "employee" edge.
  17000. func (m *TutorialMutation) ResetEmployee() {
  17001. m.employee = nil
  17002. m.clearedemployee = false
  17003. }
  17004. // Where appends a list predicates to the TutorialMutation builder.
  17005. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  17006. m.predicates = append(m.predicates, ps...)
  17007. }
  17008. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  17009. // users can use type-assertion to append predicates that do not depend on any generated package.
  17010. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  17011. p := make([]predicate.Tutorial, len(ps))
  17012. for i := range ps {
  17013. p[i] = ps[i]
  17014. }
  17015. m.Where(p...)
  17016. }
  17017. // Op returns the operation name.
  17018. func (m *TutorialMutation) Op() Op {
  17019. return m.op
  17020. }
  17021. // SetOp allows setting the mutation operation.
  17022. func (m *TutorialMutation) SetOp(op Op) {
  17023. m.op = op
  17024. }
  17025. // Type returns the node type of this mutation (Tutorial).
  17026. func (m *TutorialMutation) Type() string {
  17027. return m.typ
  17028. }
  17029. // Fields returns all fields that were changed during this mutation. Note that in
  17030. // order to get all numeric fields that were incremented/decremented, call
  17031. // AddedFields().
  17032. func (m *TutorialMutation) Fields() []string {
  17033. fields := make([]string, 0, 8)
  17034. if m.created_at != nil {
  17035. fields = append(fields, tutorial.FieldCreatedAt)
  17036. }
  17037. if m.updated_at != nil {
  17038. fields = append(fields, tutorial.FieldUpdatedAt)
  17039. }
  17040. if m.deleted_at != nil {
  17041. fields = append(fields, tutorial.FieldDeletedAt)
  17042. }
  17043. if m.employee != nil {
  17044. fields = append(fields, tutorial.FieldEmployeeID)
  17045. }
  17046. if m.index != nil {
  17047. fields = append(fields, tutorial.FieldIndex)
  17048. }
  17049. if m.title != nil {
  17050. fields = append(fields, tutorial.FieldTitle)
  17051. }
  17052. if m.content != nil {
  17053. fields = append(fields, tutorial.FieldContent)
  17054. }
  17055. if m.organization_id != nil {
  17056. fields = append(fields, tutorial.FieldOrganizationID)
  17057. }
  17058. return fields
  17059. }
  17060. // Field returns the value of a field with the given name. The second boolean
  17061. // return value indicates that this field was not set, or was not defined in the
  17062. // schema.
  17063. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  17064. switch name {
  17065. case tutorial.FieldCreatedAt:
  17066. return m.CreatedAt()
  17067. case tutorial.FieldUpdatedAt:
  17068. return m.UpdatedAt()
  17069. case tutorial.FieldDeletedAt:
  17070. return m.DeletedAt()
  17071. case tutorial.FieldEmployeeID:
  17072. return m.EmployeeID()
  17073. case tutorial.FieldIndex:
  17074. return m.Index()
  17075. case tutorial.FieldTitle:
  17076. return m.Title()
  17077. case tutorial.FieldContent:
  17078. return m.Content()
  17079. case tutorial.FieldOrganizationID:
  17080. return m.OrganizationID()
  17081. }
  17082. return nil, false
  17083. }
  17084. // OldField returns the old value of the field from the database. An error is
  17085. // returned if the mutation operation is not UpdateOne, or the query to the
  17086. // database failed.
  17087. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17088. switch name {
  17089. case tutorial.FieldCreatedAt:
  17090. return m.OldCreatedAt(ctx)
  17091. case tutorial.FieldUpdatedAt:
  17092. return m.OldUpdatedAt(ctx)
  17093. case tutorial.FieldDeletedAt:
  17094. return m.OldDeletedAt(ctx)
  17095. case tutorial.FieldEmployeeID:
  17096. return m.OldEmployeeID(ctx)
  17097. case tutorial.FieldIndex:
  17098. return m.OldIndex(ctx)
  17099. case tutorial.FieldTitle:
  17100. return m.OldTitle(ctx)
  17101. case tutorial.FieldContent:
  17102. return m.OldContent(ctx)
  17103. case tutorial.FieldOrganizationID:
  17104. return m.OldOrganizationID(ctx)
  17105. }
  17106. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  17107. }
  17108. // SetField sets the value of a field with the given name. It returns an error if
  17109. // the field is not defined in the schema, or if the type mismatched the field
  17110. // type.
  17111. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  17112. switch name {
  17113. case tutorial.FieldCreatedAt:
  17114. v, ok := value.(time.Time)
  17115. if !ok {
  17116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17117. }
  17118. m.SetCreatedAt(v)
  17119. return nil
  17120. case tutorial.FieldUpdatedAt:
  17121. v, ok := value.(time.Time)
  17122. if !ok {
  17123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17124. }
  17125. m.SetUpdatedAt(v)
  17126. return nil
  17127. case tutorial.FieldDeletedAt:
  17128. v, ok := value.(time.Time)
  17129. if !ok {
  17130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17131. }
  17132. m.SetDeletedAt(v)
  17133. return nil
  17134. case tutorial.FieldEmployeeID:
  17135. v, ok := value.(uint64)
  17136. if !ok {
  17137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17138. }
  17139. m.SetEmployeeID(v)
  17140. return nil
  17141. case tutorial.FieldIndex:
  17142. v, ok := value.(int)
  17143. if !ok {
  17144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17145. }
  17146. m.SetIndex(v)
  17147. return nil
  17148. case tutorial.FieldTitle:
  17149. v, ok := value.(string)
  17150. if !ok {
  17151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17152. }
  17153. m.SetTitle(v)
  17154. return nil
  17155. case tutorial.FieldContent:
  17156. v, ok := value.(string)
  17157. if !ok {
  17158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17159. }
  17160. m.SetContent(v)
  17161. return nil
  17162. case tutorial.FieldOrganizationID:
  17163. v, ok := value.(uint64)
  17164. if !ok {
  17165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17166. }
  17167. m.SetOrganizationID(v)
  17168. return nil
  17169. }
  17170. return fmt.Errorf("unknown Tutorial field %s", name)
  17171. }
  17172. // AddedFields returns all numeric fields that were incremented/decremented during
  17173. // this mutation.
  17174. func (m *TutorialMutation) AddedFields() []string {
  17175. var fields []string
  17176. if m.addindex != nil {
  17177. fields = append(fields, tutorial.FieldIndex)
  17178. }
  17179. if m.addorganization_id != nil {
  17180. fields = append(fields, tutorial.FieldOrganizationID)
  17181. }
  17182. return fields
  17183. }
  17184. // AddedField returns the numeric value that was incremented/decremented on a field
  17185. // with the given name. The second boolean return value indicates that this field
  17186. // was not set, or was not defined in the schema.
  17187. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  17188. switch name {
  17189. case tutorial.FieldIndex:
  17190. return m.AddedIndex()
  17191. case tutorial.FieldOrganizationID:
  17192. return m.AddedOrganizationID()
  17193. }
  17194. return nil, false
  17195. }
  17196. // AddField adds the value to the field with the given name. It returns an error if
  17197. // the field is not defined in the schema, or if the type mismatched the field
  17198. // type.
  17199. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  17200. switch name {
  17201. case tutorial.FieldIndex:
  17202. v, ok := value.(int)
  17203. if !ok {
  17204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17205. }
  17206. m.AddIndex(v)
  17207. return nil
  17208. case tutorial.FieldOrganizationID:
  17209. v, ok := value.(int64)
  17210. if !ok {
  17211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17212. }
  17213. m.AddOrganizationID(v)
  17214. return nil
  17215. }
  17216. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  17217. }
  17218. // ClearedFields returns all nullable fields that were cleared during this
  17219. // mutation.
  17220. func (m *TutorialMutation) ClearedFields() []string {
  17221. var fields []string
  17222. if m.FieldCleared(tutorial.FieldDeletedAt) {
  17223. fields = append(fields, tutorial.FieldDeletedAt)
  17224. }
  17225. return fields
  17226. }
  17227. // FieldCleared returns a boolean indicating if a field with the given name was
  17228. // cleared in this mutation.
  17229. func (m *TutorialMutation) FieldCleared(name string) bool {
  17230. _, ok := m.clearedFields[name]
  17231. return ok
  17232. }
  17233. // ClearField clears the value of the field with the given name. It returns an
  17234. // error if the field is not defined in the schema.
  17235. func (m *TutorialMutation) ClearField(name string) error {
  17236. switch name {
  17237. case tutorial.FieldDeletedAt:
  17238. m.ClearDeletedAt()
  17239. return nil
  17240. }
  17241. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  17242. }
  17243. // ResetField resets all changes in the mutation for the field with the given name.
  17244. // It returns an error if the field is not defined in the schema.
  17245. func (m *TutorialMutation) ResetField(name string) error {
  17246. switch name {
  17247. case tutorial.FieldCreatedAt:
  17248. m.ResetCreatedAt()
  17249. return nil
  17250. case tutorial.FieldUpdatedAt:
  17251. m.ResetUpdatedAt()
  17252. return nil
  17253. case tutorial.FieldDeletedAt:
  17254. m.ResetDeletedAt()
  17255. return nil
  17256. case tutorial.FieldEmployeeID:
  17257. m.ResetEmployeeID()
  17258. return nil
  17259. case tutorial.FieldIndex:
  17260. m.ResetIndex()
  17261. return nil
  17262. case tutorial.FieldTitle:
  17263. m.ResetTitle()
  17264. return nil
  17265. case tutorial.FieldContent:
  17266. m.ResetContent()
  17267. return nil
  17268. case tutorial.FieldOrganizationID:
  17269. m.ResetOrganizationID()
  17270. return nil
  17271. }
  17272. return fmt.Errorf("unknown Tutorial field %s", name)
  17273. }
  17274. // AddedEdges returns all edge names that were set/added in this mutation.
  17275. func (m *TutorialMutation) AddedEdges() []string {
  17276. edges := make([]string, 0, 1)
  17277. if m.employee != nil {
  17278. edges = append(edges, tutorial.EdgeEmployee)
  17279. }
  17280. return edges
  17281. }
  17282. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17283. // name in this mutation.
  17284. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  17285. switch name {
  17286. case tutorial.EdgeEmployee:
  17287. if id := m.employee; id != nil {
  17288. return []ent.Value{*id}
  17289. }
  17290. }
  17291. return nil
  17292. }
  17293. // RemovedEdges returns all edge names that were removed in this mutation.
  17294. func (m *TutorialMutation) RemovedEdges() []string {
  17295. edges := make([]string, 0, 1)
  17296. return edges
  17297. }
  17298. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17299. // the given name in this mutation.
  17300. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  17301. return nil
  17302. }
  17303. // ClearedEdges returns all edge names that were cleared in this mutation.
  17304. func (m *TutorialMutation) ClearedEdges() []string {
  17305. edges := make([]string, 0, 1)
  17306. if m.clearedemployee {
  17307. edges = append(edges, tutorial.EdgeEmployee)
  17308. }
  17309. return edges
  17310. }
  17311. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17312. // was cleared in this mutation.
  17313. func (m *TutorialMutation) EdgeCleared(name string) bool {
  17314. switch name {
  17315. case tutorial.EdgeEmployee:
  17316. return m.clearedemployee
  17317. }
  17318. return false
  17319. }
  17320. // ClearEdge clears the value of the edge with the given name. It returns an error
  17321. // if that edge is not defined in the schema.
  17322. func (m *TutorialMutation) ClearEdge(name string) error {
  17323. switch name {
  17324. case tutorial.EdgeEmployee:
  17325. m.ClearEmployee()
  17326. return nil
  17327. }
  17328. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  17329. }
  17330. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17331. // It returns an error if the edge is not defined in the schema.
  17332. func (m *TutorialMutation) ResetEdge(name string) error {
  17333. switch name {
  17334. case tutorial.EdgeEmployee:
  17335. m.ResetEmployee()
  17336. return nil
  17337. }
  17338. return fmt.Errorf("unknown Tutorial edge %s", name)
  17339. }
  17340. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  17341. type WorkExperienceMutation struct {
  17342. config
  17343. op Op
  17344. typ string
  17345. id *uint64
  17346. created_at *time.Time
  17347. updated_at *time.Time
  17348. deleted_at *time.Time
  17349. start_date *time.Time
  17350. end_date *time.Time
  17351. company *string
  17352. experience *string
  17353. organization_id *uint64
  17354. addorganization_id *int64
  17355. clearedFields map[string]struct{}
  17356. employee *uint64
  17357. clearedemployee bool
  17358. done bool
  17359. oldValue func(context.Context) (*WorkExperience, error)
  17360. predicates []predicate.WorkExperience
  17361. }
  17362. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  17363. // workexperienceOption allows management of the mutation configuration using functional options.
  17364. type workexperienceOption func(*WorkExperienceMutation)
  17365. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  17366. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  17367. m := &WorkExperienceMutation{
  17368. config: c,
  17369. op: op,
  17370. typ: TypeWorkExperience,
  17371. clearedFields: make(map[string]struct{}),
  17372. }
  17373. for _, opt := range opts {
  17374. opt(m)
  17375. }
  17376. return m
  17377. }
  17378. // withWorkExperienceID sets the ID field of the mutation.
  17379. func withWorkExperienceID(id uint64) workexperienceOption {
  17380. return func(m *WorkExperienceMutation) {
  17381. var (
  17382. err error
  17383. once sync.Once
  17384. value *WorkExperience
  17385. )
  17386. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  17387. once.Do(func() {
  17388. if m.done {
  17389. err = errors.New("querying old values post mutation is not allowed")
  17390. } else {
  17391. value, err = m.Client().WorkExperience.Get(ctx, id)
  17392. }
  17393. })
  17394. return value, err
  17395. }
  17396. m.id = &id
  17397. }
  17398. }
  17399. // withWorkExperience sets the old WorkExperience of the mutation.
  17400. func withWorkExperience(node *WorkExperience) workexperienceOption {
  17401. return func(m *WorkExperienceMutation) {
  17402. m.oldValue = func(context.Context) (*WorkExperience, error) {
  17403. return node, nil
  17404. }
  17405. m.id = &node.ID
  17406. }
  17407. }
  17408. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17409. // executed in a transaction (ent.Tx), a transactional client is returned.
  17410. func (m WorkExperienceMutation) Client() *Client {
  17411. client := &Client{config: m.config}
  17412. client.init()
  17413. return client
  17414. }
  17415. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17416. // it returns an error otherwise.
  17417. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  17418. if _, ok := m.driver.(*txDriver); !ok {
  17419. return nil, errors.New("ent: mutation is not running in a transaction")
  17420. }
  17421. tx := &Tx{config: m.config}
  17422. tx.init()
  17423. return tx, nil
  17424. }
  17425. // SetID sets the value of the id field. Note that this
  17426. // operation is only accepted on creation of WorkExperience entities.
  17427. func (m *WorkExperienceMutation) SetID(id uint64) {
  17428. m.id = &id
  17429. }
  17430. // ID returns the ID value in the mutation. Note that the ID is only available
  17431. // if it was provided to the builder or after it was returned from the database.
  17432. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  17433. if m.id == nil {
  17434. return
  17435. }
  17436. return *m.id, true
  17437. }
  17438. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17439. // That means, if the mutation is applied within a transaction with an isolation level such
  17440. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17441. // or updated by the mutation.
  17442. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  17443. switch {
  17444. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17445. id, exists := m.ID()
  17446. if exists {
  17447. return []uint64{id}, nil
  17448. }
  17449. fallthrough
  17450. case m.op.Is(OpUpdate | OpDelete):
  17451. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  17452. default:
  17453. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17454. }
  17455. }
  17456. // SetCreatedAt sets the "created_at" field.
  17457. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  17458. m.created_at = &t
  17459. }
  17460. // CreatedAt returns the value of the "created_at" field in the mutation.
  17461. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  17462. v := m.created_at
  17463. if v == nil {
  17464. return
  17465. }
  17466. return *v, true
  17467. }
  17468. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  17469. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17470. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17471. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17472. if !m.op.Is(OpUpdateOne) {
  17473. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17474. }
  17475. if m.id == nil || m.oldValue == nil {
  17476. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17477. }
  17478. oldValue, err := m.oldValue(ctx)
  17479. if err != nil {
  17480. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17481. }
  17482. return oldValue.CreatedAt, nil
  17483. }
  17484. // ResetCreatedAt resets all changes to the "created_at" field.
  17485. func (m *WorkExperienceMutation) ResetCreatedAt() {
  17486. m.created_at = nil
  17487. }
  17488. // SetUpdatedAt sets the "updated_at" field.
  17489. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  17490. m.updated_at = &t
  17491. }
  17492. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17493. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  17494. v := m.updated_at
  17495. if v == nil {
  17496. return
  17497. }
  17498. return *v, true
  17499. }
  17500. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  17501. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17503. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17504. if !m.op.Is(OpUpdateOne) {
  17505. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17506. }
  17507. if m.id == nil || m.oldValue == nil {
  17508. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17509. }
  17510. oldValue, err := m.oldValue(ctx)
  17511. if err != nil {
  17512. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17513. }
  17514. return oldValue.UpdatedAt, nil
  17515. }
  17516. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17517. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  17518. m.updated_at = nil
  17519. }
  17520. // SetDeletedAt sets the "deleted_at" field.
  17521. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  17522. m.deleted_at = &t
  17523. }
  17524. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17525. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  17526. v := m.deleted_at
  17527. if v == nil {
  17528. return
  17529. }
  17530. return *v, true
  17531. }
  17532. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  17533. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17535. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17536. if !m.op.Is(OpUpdateOne) {
  17537. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17538. }
  17539. if m.id == nil || m.oldValue == nil {
  17540. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17541. }
  17542. oldValue, err := m.oldValue(ctx)
  17543. if err != nil {
  17544. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17545. }
  17546. return oldValue.DeletedAt, nil
  17547. }
  17548. // ClearDeletedAt clears the value of the "deleted_at" field.
  17549. func (m *WorkExperienceMutation) ClearDeletedAt() {
  17550. m.deleted_at = nil
  17551. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  17552. }
  17553. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17554. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  17555. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  17556. return ok
  17557. }
  17558. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17559. func (m *WorkExperienceMutation) ResetDeletedAt() {
  17560. m.deleted_at = nil
  17561. delete(m.clearedFields, workexperience.FieldDeletedAt)
  17562. }
  17563. // SetEmployeeID sets the "employee_id" field.
  17564. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  17565. m.employee = &u
  17566. }
  17567. // EmployeeID returns the value of the "employee_id" field in the mutation.
  17568. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  17569. v := m.employee
  17570. if v == nil {
  17571. return
  17572. }
  17573. return *v, true
  17574. }
  17575. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  17576. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17577. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17578. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  17579. if !m.op.Is(OpUpdateOne) {
  17580. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  17581. }
  17582. if m.id == nil || m.oldValue == nil {
  17583. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  17584. }
  17585. oldValue, err := m.oldValue(ctx)
  17586. if err != nil {
  17587. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  17588. }
  17589. return oldValue.EmployeeID, nil
  17590. }
  17591. // ResetEmployeeID resets all changes to the "employee_id" field.
  17592. func (m *WorkExperienceMutation) ResetEmployeeID() {
  17593. m.employee = nil
  17594. }
  17595. // SetStartDate sets the "start_date" field.
  17596. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  17597. m.start_date = &t
  17598. }
  17599. // StartDate returns the value of the "start_date" field in the mutation.
  17600. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  17601. v := m.start_date
  17602. if v == nil {
  17603. return
  17604. }
  17605. return *v, true
  17606. }
  17607. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  17608. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17610. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  17611. if !m.op.Is(OpUpdateOne) {
  17612. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  17613. }
  17614. if m.id == nil || m.oldValue == nil {
  17615. return v, errors.New("OldStartDate requires an ID field in the mutation")
  17616. }
  17617. oldValue, err := m.oldValue(ctx)
  17618. if err != nil {
  17619. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  17620. }
  17621. return oldValue.StartDate, nil
  17622. }
  17623. // ResetStartDate resets all changes to the "start_date" field.
  17624. func (m *WorkExperienceMutation) ResetStartDate() {
  17625. m.start_date = nil
  17626. }
  17627. // SetEndDate sets the "end_date" field.
  17628. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  17629. m.end_date = &t
  17630. }
  17631. // EndDate returns the value of the "end_date" field in the mutation.
  17632. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  17633. v := m.end_date
  17634. if v == nil {
  17635. return
  17636. }
  17637. return *v, true
  17638. }
  17639. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  17640. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17642. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  17643. if !m.op.Is(OpUpdateOne) {
  17644. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  17645. }
  17646. if m.id == nil || m.oldValue == nil {
  17647. return v, errors.New("OldEndDate requires an ID field in the mutation")
  17648. }
  17649. oldValue, err := m.oldValue(ctx)
  17650. if err != nil {
  17651. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  17652. }
  17653. return oldValue.EndDate, nil
  17654. }
  17655. // ResetEndDate resets all changes to the "end_date" field.
  17656. func (m *WorkExperienceMutation) ResetEndDate() {
  17657. m.end_date = nil
  17658. }
  17659. // SetCompany sets the "company" field.
  17660. func (m *WorkExperienceMutation) SetCompany(s string) {
  17661. m.company = &s
  17662. }
  17663. // Company returns the value of the "company" field in the mutation.
  17664. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  17665. v := m.company
  17666. if v == nil {
  17667. return
  17668. }
  17669. return *v, true
  17670. }
  17671. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  17672. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17673. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17674. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  17675. if !m.op.Is(OpUpdateOne) {
  17676. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  17677. }
  17678. if m.id == nil || m.oldValue == nil {
  17679. return v, errors.New("OldCompany requires an ID field in the mutation")
  17680. }
  17681. oldValue, err := m.oldValue(ctx)
  17682. if err != nil {
  17683. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  17684. }
  17685. return oldValue.Company, nil
  17686. }
  17687. // ResetCompany resets all changes to the "company" field.
  17688. func (m *WorkExperienceMutation) ResetCompany() {
  17689. m.company = nil
  17690. }
  17691. // SetExperience sets the "experience" field.
  17692. func (m *WorkExperienceMutation) SetExperience(s string) {
  17693. m.experience = &s
  17694. }
  17695. // Experience returns the value of the "experience" field in the mutation.
  17696. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  17697. v := m.experience
  17698. if v == nil {
  17699. return
  17700. }
  17701. return *v, true
  17702. }
  17703. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  17704. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17705. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17706. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  17707. if !m.op.Is(OpUpdateOne) {
  17708. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  17709. }
  17710. if m.id == nil || m.oldValue == nil {
  17711. return v, errors.New("OldExperience requires an ID field in the mutation")
  17712. }
  17713. oldValue, err := m.oldValue(ctx)
  17714. if err != nil {
  17715. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  17716. }
  17717. return oldValue.Experience, nil
  17718. }
  17719. // ResetExperience resets all changes to the "experience" field.
  17720. func (m *WorkExperienceMutation) ResetExperience() {
  17721. m.experience = nil
  17722. }
  17723. // SetOrganizationID sets the "organization_id" field.
  17724. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  17725. m.organization_id = &u
  17726. m.addorganization_id = nil
  17727. }
  17728. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17729. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  17730. v := m.organization_id
  17731. if v == nil {
  17732. return
  17733. }
  17734. return *v, true
  17735. }
  17736. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  17737. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17739. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17740. if !m.op.Is(OpUpdateOne) {
  17741. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17742. }
  17743. if m.id == nil || m.oldValue == nil {
  17744. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17745. }
  17746. oldValue, err := m.oldValue(ctx)
  17747. if err != nil {
  17748. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17749. }
  17750. return oldValue.OrganizationID, nil
  17751. }
  17752. // AddOrganizationID adds u to the "organization_id" field.
  17753. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  17754. if m.addorganization_id != nil {
  17755. *m.addorganization_id += u
  17756. } else {
  17757. m.addorganization_id = &u
  17758. }
  17759. }
  17760. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17761. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  17762. v := m.addorganization_id
  17763. if v == nil {
  17764. return
  17765. }
  17766. return *v, true
  17767. }
  17768. // ResetOrganizationID resets all changes to the "organization_id" field.
  17769. func (m *WorkExperienceMutation) ResetOrganizationID() {
  17770. m.organization_id = nil
  17771. m.addorganization_id = nil
  17772. }
  17773. // ClearEmployee clears the "employee" edge to the Employee entity.
  17774. func (m *WorkExperienceMutation) ClearEmployee() {
  17775. m.clearedemployee = true
  17776. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  17777. }
  17778. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  17779. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  17780. return m.clearedemployee
  17781. }
  17782. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  17783. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17784. // EmployeeID instead. It exists only for internal usage by the builders.
  17785. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  17786. if id := m.employee; id != nil {
  17787. ids = append(ids, *id)
  17788. }
  17789. return
  17790. }
  17791. // ResetEmployee resets all changes to the "employee" edge.
  17792. func (m *WorkExperienceMutation) ResetEmployee() {
  17793. m.employee = nil
  17794. m.clearedemployee = false
  17795. }
  17796. // Where appends a list predicates to the WorkExperienceMutation builder.
  17797. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  17798. m.predicates = append(m.predicates, ps...)
  17799. }
  17800. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  17801. // users can use type-assertion to append predicates that do not depend on any generated package.
  17802. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  17803. p := make([]predicate.WorkExperience, len(ps))
  17804. for i := range ps {
  17805. p[i] = ps[i]
  17806. }
  17807. m.Where(p...)
  17808. }
  17809. // Op returns the operation name.
  17810. func (m *WorkExperienceMutation) Op() Op {
  17811. return m.op
  17812. }
  17813. // SetOp allows setting the mutation operation.
  17814. func (m *WorkExperienceMutation) SetOp(op Op) {
  17815. m.op = op
  17816. }
  17817. // Type returns the node type of this mutation (WorkExperience).
  17818. func (m *WorkExperienceMutation) Type() string {
  17819. return m.typ
  17820. }
  17821. // Fields returns all fields that were changed during this mutation. Note that in
  17822. // order to get all numeric fields that were incremented/decremented, call
  17823. // AddedFields().
  17824. func (m *WorkExperienceMutation) Fields() []string {
  17825. fields := make([]string, 0, 9)
  17826. if m.created_at != nil {
  17827. fields = append(fields, workexperience.FieldCreatedAt)
  17828. }
  17829. if m.updated_at != nil {
  17830. fields = append(fields, workexperience.FieldUpdatedAt)
  17831. }
  17832. if m.deleted_at != nil {
  17833. fields = append(fields, workexperience.FieldDeletedAt)
  17834. }
  17835. if m.employee != nil {
  17836. fields = append(fields, workexperience.FieldEmployeeID)
  17837. }
  17838. if m.start_date != nil {
  17839. fields = append(fields, workexperience.FieldStartDate)
  17840. }
  17841. if m.end_date != nil {
  17842. fields = append(fields, workexperience.FieldEndDate)
  17843. }
  17844. if m.company != nil {
  17845. fields = append(fields, workexperience.FieldCompany)
  17846. }
  17847. if m.experience != nil {
  17848. fields = append(fields, workexperience.FieldExperience)
  17849. }
  17850. if m.organization_id != nil {
  17851. fields = append(fields, workexperience.FieldOrganizationID)
  17852. }
  17853. return fields
  17854. }
  17855. // Field returns the value of a field with the given name. The second boolean
  17856. // return value indicates that this field was not set, or was not defined in the
  17857. // schema.
  17858. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  17859. switch name {
  17860. case workexperience.FieldCreatedAt:
  17861. return m.CreatedAt()
  17862. case workexperience.FieldUpdatedAt:
  17863. return m.UpdatedAt()
  17864. case workexperience.FieldDeletedAt:
  17865. return m.DeletedAt()
  17866. case workexperience.FieldEmployeeID:
  17867. return m.EmployeeID()
  17868. case workexperience.FieldStartDate:
  17869. return m.StartDate()
  17870. case workexperience.FieldEndDate:
  17871. return m.EndDate()
  17872. case workexperience.FieldCompany:
  17873. return m.Company()
  17874. case workexperience.FieldExperience:
  17875. return m.Experience()
  17876. case workexperience.FieldOrganizationID:
  17877. return m.OrganizationID()
  17878. }
  17879. return nil, false
  17880. }
  17881. // OldField returns the old value of the field from the database. An error is
  17882. // returned if the mutation operation is not UpdateOne, or the query to the
  17883. // database failed.
  17884. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17885. switch name {
  17886. case workexperience.FieldCreatedAt:
  17887. return m.OldCreatedAt(ctx)
  17888. case workexperience.FieldUpdatedAt:
  17889. return m.OldUpdatedAt(ctx)
  17890. case workexperience.FieldDeletedAt:
  17891. return m.OldDeletedAt(ctx)
  17892. case workexperience.FieldEmployeeID:
  17893. return m.OldEmployeeID(ctx)
  17894. case workexperience.FieldStartDate:
  17895. return m.OldStartDate(ctx)
  17896. case workexperience.FieldEndDate:
  17897. return m.OldEndDate(ctx)
  17898. case workexperience.FieldCompany:
  17899. return m.OldCompany(ctx)
  17900. case workexperience.FieldExperience:
  17901. return m.OldExperience(ctx)
  17902. case workexperience.FieldOrganizationID:
  17903. return m.OldOrganizationID(ctx)
  17904. }
  17905. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  17906. }
  17907. // SetField sets the value of a field with the given name. It returns an error if
  17908. // the field is not defined in the schema, or if the type mismatched the field
  17909. // type.
  17910. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  17911. switch name {
  17912. case workexperience.FieldCreatedAt:
  17913. v, ok := value.(time.Time)
  17914. if !ok {
  17915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17916. }
  17917. m.SetCreatedAt(v)
  17918. return nil
  17919. case workexperience.FieldUpdatedAt:
  17920. v, ok := value.(time.Time)
  17921. if !ok {
  17922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17923. }
  17924. m.SetUpdatedAt(v)
  17925. return nil
  17926. case workexperience.FieldDeletedAt:
  17927. v, ok := value.(time.Time)
  17928. if !ok {
  17929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17930. }
  17931. m.SetDeletedAt(v)
  17932. return nil
  17933. case workexperience.FieldEmployeeID:
  17934. v, ok := value.(uint64)
  17935. if !ok {
  17936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17937. }
  17938. m.SetEmployeeID(v)
  17939. return nil
  17940. case workexperience.FieldStartDate:
  17941. v, ok := value.(time.Time)
  17942. if !ok {
  17943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17944. }
  17945. m.SetStartDate(v)
  17946. return nil
  17947. case workexperience.FieldEndDate:
  17948. v, ok := value.(time.Time)
  17949. if !ok {
  17950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17951. }
  17952. m.SetEndDate(v)
  17953. return nil
  17954. case workexperience.FieldCompany:
  17955. v, ok := value.(string)
  17956. if !ok {
  17957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17958. }
  17959. m.SetCompany(v)
  17960. return nil
  17961. case workexperience.FieldExperience:
  17962. v, ok := value.(string)
  17963. if !ok {
  17964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17965. }
  17966. m.SetExperience(v)
  17967. return nil
  17968. case workexperience.FieldOrganizationID:
  17969. v, ok := value.(uint64)
  17970. if !ok {
  17971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17972. }
  17973. m.SetOrganizationID(v)
  17974. return nil
  17975. }
  17976. return fmt.Errorf("unknown WorkExperience field %s", name)
  17977. }
  17978. // AddedFields returns all numeric fields that were incremented/decremented during
  17979. // this mutation.
  17980. func (m *WorkExperienceMutation) AddedFields() []string {
  17981. var fields []string
  17982. if m.addorganization_id != nil {
  17983. fields = append(fields, workexperience.FieldOrganizationID)
  17984. }
  17985. return fields
  17986. }
  17987. // AddedField returns the numeric value that was incremented/decremented on a field
  17988. // with the given name. The second boolean return value indicates that this field
  17989. // was not set, or was not defined in the schema.
  17990. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  17991. switch name {
  17992. case workexperience.FieldOrganizationID:
  17993. return m.AddedOrganizationID()
  17994. }
  17995. return nil, false
  17996. }
  17997. // AddField adds the value to the field with the given name. It returns an error if
  17998. // the field is not defined in the schema, or if the type mismatched the field
  17999. // type.
  18000. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  18001. switch name {
  18002. case workexperience.FieldOrganizationID:
  18003. v, ok := value.(int64)
  18004. if !ok {
  18005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18006. }
  18007. m.AddOrganizationID(v)
  18008. return nil
  18009. }
  18010. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  18011. }
  18012. // ClearedFields returns all nullable fields that were cleared during this
  18013. // mutation.
  18014. func (m *WorkExperienceMutation) ClearedFields() []string {
  18015. var fields []string
  18016. if m.FieldCleared(workexperience.FieldDeletedAt) {
  18017. fields = append(fields, workexperience.FieldDeletedAt)
  18018. }
  18019. return fields
  18020. }
  18021. // FieldCleared returns a boolean indicating if a field with the given name was
  18022. // cleared in this mutation.
  18023. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  18024. _, ok := m.clearedFields[name]
  18025. return ok
  18026. }
  18027. // ClearField clears the value of the field with the given name. It returns an
  18028. // error if the field is not defined in the schema.
  18029. func (m *WorkExperienceMutation) ClearField(name string) error {
  18030. switch name {
  18031. case workexperience.FieldDeletedAt:
  18032. m.ClearDeletedAt()
  18033. return nil
  18034. }
  18035. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  18036. }
  18037. // ResetField resets all changes in the mutation for the field with the given name.
  18038. // It returns an error if the field is not defined in the schema.
  18039. func (m *WorkExperienceMutation) ResetField(name string) error {
  18040. switch name {
  18041. case workexperience.FieldCreatedAt:
  18042. m.ResetCreatedAt()
  18043. return nil
  18044. case workexperience.FieldUpdatedAt:
  18045. m.ResetUpdatedAt()
  18046. return nil
  18047. case workexperience.FieldDeletedAt:
  18048. m.ResetDeletedAt()
  18049. return nil
  18050. case workexperience.FieldEmployeeID:
  18051. m.ResetEmployeeID()
  18052. return nil
  18053. case workexperience.FieldStartDate:
  18054. m.ResetStartDate()
  18055. return nil
  18056. case workexperience.FieldEndDate:
  18057. m.ResetEndDate()
  18058. return nil
  18059. case workexperience.FieldCompany:
  18060. m.ResetCompany()
  18061. return nil
  18062. case workexperience.FieldExperience:
  18063. m.ResetExperience()
  18064. return nil
  18065. case workexperience.FieldOrganizationID:
  18066. m.ResetOrganizationID()
  18067. return nil
  18068. }
  18069. return fmt.Errorf("unknown WorkExperience field %s", name)
  18070. }
  18071. // AddedEdges returns all edge names that were set/added in this mutation.
  18072. func (m *WorkExperienceMutation) AddedEdges() []string {
  18073. edges := make([]string, 0, 1)
  18074. if m.employee != nil {
  18075. edges = append(edges, workexperience.EdgeEmployee)
  18076. }
  18077. return edges
  18078. }
  18079. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18080. // name in this mutation.
  18081. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  18082. switch name {
  18083. case workexperience.EdgeEmployee:
  18084. if id := m.employee; id != nil {
  18085. return []ent.Value{*id}
  18086. }
  18087. }
  18088. return nil
  18089. }
  18090. // RemovedEdges returns all edge names that were removed in this mutation.
  18091. func (m *WorkExperienceMutation) RemovedEdges() []string {
  18092. edges := make([]string, 0, 1)
  18093. return edges
  18094. }
  18095. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18096. // the given name in this mutation.
  18097. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  18098. return nil
  18099. }
  18100. // ClearedEdges returns all edge names that were cleared in this mutation.
  18101. func (m *WorkExperienceMutation) ClearedEdges() []string {
  18102. edges := make([]string, 0, 1)
  18103. if m.clearedemployee {
  18104. edges = append(edges, workexperience.EdgeEmployee)
  18105. }
  18106. return edges
  18107. }
  18108. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18109. // was cleared in this mutation.
  18110. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  18111. switch name {
  18112. case workexperience.EdgeEmployee:
  18113. return m.clearedemployee
  18114. }
  18115. return false
  18116. }
  18117. // ClearEdge clears the value of the edge with the given name. It returns an error
  18118. // if that edge is not defined in the schema.
  18119. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  18120. switch name {
  18121. case workexperience.EdgeEmployee:
  18122. m.ClearEmployee()
  18123. return nil
  18124. }
  18125. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  18126. }
  18127. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18128. // It returns an error if the edge is not defined in the schema.
  18129. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  18130. switch name {
  18131. case workexperience.EdgeEmployee:
  18132. m.ResetEmployee()
  18133. return nil
  18134. }
  18135. return fmt.Errorf("unknown WorkExperience edge %s", name)
  18136. }
  18137. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  18138. type WxMutation struct {
  18139. config
  18140. op Op
  18141. typ string
  18142. id *uint64
  18143. created_at *time.Time
  18144. updated_at *time.Time
  18145. status *uint8
  18146. addstatus *int8
  18147. deleted_at *time.Time
  18148. port *string
  18149. process_id *string
  18150. callback *string
  18151. wxid *string
  18152. account *string
  18153. nickname *string
  18154. tel *string
  18155. head_big *string
  18156. organization_id *uint64
  18157. addorganization_id *int64
  18158. api_base *string
  18159. api_key *string
  18160. clearedFields map[string]struct{}
  18161. server *uint64
  18162. clearedserver bool
  18163. agent *uint64
  18164. clearedagent bool
  18165. done bool
  18166. oldValue func(context.Context) (*Wx, error)
  18167. predicates []predicate.Wx
  18168. }
  18169. var _ ent.Mutation = (*WxMutation)(nil)
  18170. // wxOption allows management of the mutation configuration using functional options.
  18171. type wxOption func(*WxMutation)
  18172. // newWxMutation creates new mutation for the Wx entity.
  18173. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  18174. m := &WxMutation{
  18175. config: c,
  18176. op: op,
  18177. typ: TypeWx,
  18178. clearedFields: make(map[string]struct{}),
  18179. }
  18180. for _, opt := range opts {
  18181. opt(m)
  18182. }
  18183. return m
  18184. }
  18185. // withWxID sets the ID field of the mutation.
  18186. func withWxID(id uint64) wxOption {
  18187. return func(m *WxMutation) {
  18188. var (
  18189. err error
  18190. once sync.Once
  18191. value *Wx
  18192. )
  18193. m.oldValue = func(ctx context.Context) (*Wx, error) {
  18194. once.Do(func() {
  18195. if m.done {
  18196. err = errors.New("querying old values post mutation is not allowed")
  18197. } else {
  18198. value, err = m.Client().Wx.Get(ctx, id)
  18199. }
  18200. })
  18201. return value, err
  18202. }
  18203. m.id = &id
  18204. }
  18205. }
  18206. // withWx sets the old Wx of the mutation.
  18207. func withWx(node *Wx) wxOption {
  18208. return func(m *WxMutation) {
  18209. m.oldValue = func(context.Context) (*Wx, error) {
  18210. return node, nil
  18211. }
  18212. m.id = &node.ID
  18213. }
  18214. }
  18215. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18216. // executed in a transaction (ent.Tx), a transactional client is returned.
  18217. func (m WxMutation) Client() *Client {
  18218. client := &Client{config: m.config}
  18219. client.init()
  18220. return client
  18221. }
  18222. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18223. // it returns an error otherwise.
  18224. func (m WxMutation) Tx() (*Tx, error) {
  18225. if _, ok := m.driver.(*txDriver); !ok {
  18226. return nil, errors.New("ent: mutation is not running in a transaction")
  18227. }
  18228. tx := &Tx{config: m.config}
  18229. tx.init()
  18230. return tx, nil
  18231. }
  18232. // SetID sets the value of the id field. Note that this
  18233. // operation is only accepted on creation of Wx entities.
  18234. func (m *WxMutation) SetID(id uint64) {
  18235. m.id = &id
  18236. }
  18237. // ID returns the ID value in the mutation. Note that the ID is only available
  18238. // if it was provided to the builder or after it was returned from the database.
  18239. func (m *WxMutation) ID() (id uint64, exists bool) {
  18240. if m.id == nil {
  18241. return
  18242. }
  18243. return *m.id, true
  18244. }
  18245. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18246. // That means, if the mutation is applied within a transaction with an isolation level such
  18247. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18248. // or updated by the mutation.
  18249. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  18250. switch {
  18251. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18252. id, exists := m.ID()
  18253. if exists {
  18254. return []uint64{id}, nil
  18255. }
  18256. fallthrough
  18257. case m.op.Is(OpUpdate | OpDelete):
  18258. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  18259. default:
  18260. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18261. }
  18262. }
  18263. // SetCreatedAt sets the "created_at" field.
  18264. func (m *WxMutation) SetCreatedAt(t time.Time) {
  18265. m.created_at = &t
  18266. }
  18267. // CreatedAt returns the value of the "created_at" field in the mutation.
  18268. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  18269. v := m.created_at
  18270. if v == nil {
  18271. return
  18272. }
  18273. return *v, true
  18274. }
  18275. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  18276. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18278. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18279. if !m.op.Is(OpUpdateOne) {
  18280. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18281. }
  18282. if m.id == nil || m.oldValue == nil {
  18283. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18284. }
  18285. oldValue, err := m.oldValue(ctx)
  18286. if err != nil {
  18287. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18288. }
  18289. return oldValue.CreatedAt, nil
  18290. }
  18291. // ResetCreatedAt resets all changes to the "created_at" field.
  18292. func (m *WxMutation) ResetCreatedAt() {
  18293. m.created_at = nil
  18294. }
  18295. // SetUpdatedAt sets the "updated_at" field.
  18296. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  18297. m.updated_at = &t
  18298. }
  18299. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18300. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  18301. v := m.updated_at
  18302. if v == nil {
  18303. return
  18304. }
  18305. return *v, true
  18306. }
  18307. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  18308. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18310. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18311. if !m.op.Is(OpUpdateOne) {
  18312. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18313. }
  18314. if m.id == nil || m.oldValue == nil {
  18315. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18316. }
  18317. oldValue, err := m.oldValue(ctx)
  18318. if err != nil {
  18319. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18320. }
  18321. return oldValue.UpdatedAt, nil
  18322. }
  18323. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18324. func (m *WxMutation) ResetUpdatedAt() {
  18325. m.updated_at = nil
  18326. }
  18327. // SetStatus sets the "status" field.
  18328. func (m *WxMutation) SetStatus(u uint8) {
  18329. m.status = &u
  18330. m.addstatus = nil
  18331. }
  18332. // Status returns the value of the "status" field in the mutation.
  18333. func (m *WxMutation) Status() (r uint8, exists bool) {
  18334. v := m.status
  18335. if v == nil {
  18336. return
  18337. }
  18338. return *v, true
  18339. }
  18340. // OldStatus returns the old "status" field's value of the Wx entity.
  18341. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18342. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18343. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18344. if !m.op.Is(OpUpdateOne) {
  18345. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18346. }
  18347. if m.id == nil || m.oldValue == nil {
  18348. return v, errors.New("OldStatus requires an ID field in the mutation")
  18349. }
  18350. oldValue, err := m.oldValue(ctx)
  18351. if err != nil {
  18352. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18353. }
  18354. return oldValue.Status, nil
  18355. }
  18356. // AddStatus adds u to the "status" field.
  18357. func (m *WxMutation) AddStatus(u int8) {
  18358. if m.addstatus != nil {
  18359. *m.addstatus += u
  18360. } else {
  18361. m.addstatus = &u
  18362. }
  18363. }
  18364. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18365. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  18366. v := m.addstatus
  18367. if v == nil {
  18368. return
  18369. }
  18370. return *v, true
  18371. }
  18372. // ClearStatus clears the value of the "status" field.
  18373. func (m *WxMutation) ClearStatus() {
  18374. m.status = nil
  18375. m.addstatus = nil
  18376. m.clearedFields[wx.FieldStatus] = struct{}{}
  18377. }
  18378. // StatusCleared returns if the "status" field was cleared in this mutation.
  18379. func (m *WxMutation) StatusCleared() bool {
  18380. _, ok := m.clearedFields[wx.FieldStatus]
  18381. return ok
  18382. }
  18383. // ResetStatus resets all changes to the "status" field.
  18384. func (m *WxMutation) ResetStatus() {
  18385. m.status = nil
  18386. m.addstatus = nil
  18387. delete(m.clearedFields, wx.FieldStatus)
  18388. }
  18389. // SetDeletedAt sets the "deleted_at" field.
  18390. func (m *WxMutation) SetDeletedAt(t time.Time) {
  18391. m.deleted_at = &t
  18392. }
  18393. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18394. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  18395. v := m.deleted_at
  18396. if v == nil {
  18397. return
  18398. }
  18399. return *v, true
  18400. }
  18401. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  18402. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18404. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18405. if !m.op.Is(OpUpdateOne) {
  18406. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18407. }
  18408. if m.id == nil || m.oldValue == nil {
  18409. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18410. }
  18411. oldValue, err := m.oldValue(ctx)
  18412. if err != nil {
  18413. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18414. }
  18415. return oldValue.DeletedAt, nil
  18416. }
  18417. // ClearDeletedAt clears the value of the "deleted_at" field.
  18418. func (m *WxMutation) ClearDeletedAt() {
  18419. m.deleted_at = nil
  18420. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  18421. }
  18422. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18423. func (m *WxMutation) DeletedAtCleared() bool {
  18424. _, ok := m.clearedFields[wx.FieldDeletedAt]
  18425. return ok
  18426. }
  18427. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18428. func (m *WxMutation) ResetDeletedAt() {
  18429. m.deleted_at = nil
  18430. delete(m.clearedFields, wx.FieldDeletedAt)
  18431. }
  18432. // SetServerID sets the "server_id" field.
  18433. func (m *WxMutation) SetServerID(u uint64) {
  18434. m.server = &u
  18435. }
  18436. // ServerID returns the value of the "server_id" field in the mutation.
  18437. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  18438. v := m.server
  18439. if v == nil {
  18440. return
  18441. }
  18442. return *v, true
  18443. }
  18444. // OldServerID returns the old "server_id" field's value of the Wx entity.
  18445. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18447. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  18448. if !m.op.Is(OpUpdateOne) {
  18449. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  18450. }
  18451. if m.id == nil || m.oldValue == nil {
  18452. return v, errors.New("OldServerID requires an ID field in the mutation")
  18453. }
  18454. oldValue, err := m.oldValue(ctx)
  18455. if err != nil {
  18456. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  18457. }
  18458. return oldValue.ServerID, nil
  18459. }
  18460. // ClearServerID clears the value of the "server_id" field.
  18461. func (m *WxMutation) ClearServerID() {
  18462. m.server = nil
  18463. m.clearedFields[wx.FieldServerID] = struct{}{}
  18464. }
  18465. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  18466. func (m *WxMutation) ServerIDCleared() bool {
  18467. _, ok := m.clearedFields[wx.FieldServerID]
  18468. return ok
  18469. }
  18470. // ResetServerID resets all changes to the "server_id" field.
  18471. func (m *WxMutation) ResetServerID() {
  18472. m.server = nil
  18473. delete(m.clearedFields, wx.FieldServerID)
  18474. }
  18475. // SetPort sets the "port" field.
  18476. func (m *WxMutation) SetPort(s string) {
  18477. m.port = &s
  18478. }
  18479. // Port returns the value of the "port" field in the mutation.
  18480. func (m *WxMutation) Port() (r string, exists bool) {
  18481. v := m.port
  18482. if v == nil {
  18483. return
  18484. }
  18485. return *v, true
  18486. }
  18487. // OldPort returns the old "port" field's value of the Wx entity.
  18488. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18490. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  18491. if !m.op.Is(OpUpdateOne) {
  18492. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  18493. }
  18494. if m.id == nil || m.oldValue == nil {
  18495. return v, errors.New("OldPort requires an ID field in the mutation")
  18496. }
  18497. oldValue, err := m.oldValue(ctx)
  18498. if err != nil {
  18499. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  18500. }
  18501. return oldValue.Port, nil
  18502. }
  18503. // ResetPort resets all changes to the "port" field.
  18504. func (m *WxMutation) ResetPort() {
  18505. m.port = nil
  18506. }
  18507. // SetProcessID sets the "process_id" field.
  18508. func (m *WxMutation) SetProcessID(s string) {
  18509. m.process_id = &s
  18510. }
  18511. // ProcessID returns the value of the "process_id" field in the mutation.
  18512. func (m *WxMutation) ProcessID() (r string, exists bool) {
  18513. v := m.process_id
  18514. if v == nil {
  18515. return
  18516. }
  18517. return *v, true
  18518. }
  18519. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  18520. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18522. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  18523. if !m.op.Is(OpUpdateOne) {
  18524. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  18525. }
  18526. if m.id == nil || m.oldValue == nil {
  18527. return v, errors.New("OldProcessID requires an ID field in the mutation")
  18528. }
  18529. oldValue, err := m.oldValue(ctx)
  18530. if err != nil {
  18531. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  18532. }
  18533. return oldValue.ProcessID, nil
  18534. }
  18535. // ResetProcessID resets all changes to the "process_id" field.
  18536. func (m *WxMutation) ResetProcessID() {
  18537. m.process_id = nil
  18538. }
  18539. // SetCallback sets the "callback" field.
  18540. func (m *WxMutation) SetCallback(s string) {
  18541. m.callback = &s
  18542. }
  18543. // Callback returns the value of the "callback" field in the mutation.
  18544. func (m *WxMutation) Callback() (r string, exists bool) {
  18545. v := m.callback
  18546. if v == nil {
  18547. return
  18548. }
  18549. return *v, true
  18550. }
  18551. // OldCallback returns the old "callback" field's value of the Wx entity.
  18552. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18554. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  18555. if !m.op.Is(OpUpdateOne) {
  18556. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  18557. }
  18558. if m.id == nil || m.oldValue == nil {
  18559. return v, errors.New("OldCallback requires an ID field in the mutation")
  18560. }
  18561. oldValue, err := m.oldValue(ctx)
  18562. if err != nil {
  18563. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  18564. }
  18565. return oldValue.Callback, nil
  18566. }
  18567. // ResetCallback resets all changes to the "callback" field.
  18568. func (m *WxMutation) ResetCallback() {
  18569. m.callback = nil
  18570. }
  18571. // SetWxid sets the "wxid" field.
  18572. func (m *WxMutation) SetWxid(s string) {
  18573. m.wxid = &s
  18574. }
  18575. // Wxid returns the value of the "wxid" field in the mutation.
  18576. func (m *WxMutation) Wxid() (r string, exists bool) {
  18577. v := m.wxid
  18578. if v == nil {
  18579. return
  18580. }
  18581. return *v, true
  18582. }
  18583. // OldWxid returns the old "wxid" field's value of the Wx entity.
  18584. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18586. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  18587. if !m.op.Is(OpUpdateOne) {
  18588. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  18589. }
  18590. if m.id == nil || m.oldValue == nil {
  18591. return v, errors.New("OldWxid requires an ID field in the mutation")
  18592. }
  18593. oldValue, err := m.oldValue(ctx)
  18594. if err != nil {
  18595. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  18596. }
  18597. return oldValue.Wxid, nil
  18598. }
  18599. // ResetWxid resets all changes to the "wxid" field.
  18600. func (m *WxMutation) ResetWxid() {
  18601. m.wxid = nil
  18602. }
  18603. // SetAccount sets the "account" field.
  18604. func (m *WxMutation) SetAccount(s string) {
  18605. m.account = &s
  18606. }
  18607. // Account returns the value of the "account" field in the mutation.
  18608. func (m *WxMutation) Account() (r string, exists bool) {
  18609. v := m.account
  18610. if v == nil {
  18611. return
  18612. }
  18613. return *v, true
  18614. }
  18615. // OldAccount returns the old "account" field's value of the Wx entity.
  18616. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18617. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18618. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  18619. if !m.op.Is(OpUpdateOne) {
  18620. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  18621. }
  18622. if m.id == nil || m.oldValue == nil {
  18623. return v, errors.New("OldAccount requires an ID field in the mutation")
  18624. }
  18625. oldValue, err := m.oldValue(ctx)
  18626. if err != nil {
  18627. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  18628. }
  18629. return oldValue.Account, nil
  18630. }
  18631. // ResetAccount resets all changes to the "account" field.
  18632. func (m *WxMutation) ResetAccount() {
  18633. m.account = nil
  18634. }
  18635. // SetNickname sets the "nickname" field.
  18636. func (m *WxMutation) SetNickname(s string) {
  18637. m.nickname = &s
  18638. }
  18639. // Nickname returns the value of the "nickname" field in the mutation.
  18640. func (m *WxMutation) Nickname() (r string, exists bool) {
  18641. v := m.nickname
  18642. if v == nil {
  18643. return
  18644. }
  18645. return *v, true
  18646. }
  18647. // OldNickname returns the old "nickname" field's value of the Wx entity.
  18648. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18650. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  18651. if !m.op.Is(OpUpdateOne) {
  18652. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  18653. }
  18654. if m.id == nil || m.oldValue == nil {
  18655. return v, errors.New("OldNickname requires an ID field in the mutation")
  18656. }
  18657. oldValue, err := m.oldValue(ctx)
  18658. if err != nil {
  18659. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  18660. }
  18661. return oldValue.Nickname, nil
  18662. }
  18663. // ResetNickname resets all changes to the "nickname" field.
  18664. func (m *WxMutation) ResetNickname() {
  18665. m.nickname = nil
  18666. }
  18667. // SetTel sets the "tel" field.
  18668. func (m *WxMutation) SetTel(s string) {
  18669. m.tel = &s
  18670. }
  18671. // Tel returns the value of the "tel" field in the mutation.
  18672. func (m *WxMutation) Tel() (r string, exists bool) {
  18673. v := m.tel
  18674. if v == nil {
  18675. return
  18676. }
  18677. return *v, true
  18678. }
  18679. // OldTel returns the old "tel" field's value of the Wx entity.
  18680. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18682. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  18683. if !m.op.Is(OpUpdateOne) {
  18684. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  18685. }
  18686. if m.id == nil || m.oldValue == nil {
  18687. return v, errors.New("OldTel requires an ID field in the mutation")
  18688. }
  18689. oldValue, err := m.oldValue(ctx)
  18690. if err != nil {
  18691. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  18692. }
  18693. return oldValue.Tel, nil
  18694. }
  18695. // ResetTel resets all changes to the "tel" field.
  18696. func (m *WxMutation) ResetTel() {
  18697. m.tel = nil
  18698. }
  18699. // SetHeadBig sets the "head_big" field.
  18700. func (m *WxMutation) SetHeadBig(s string) {
  18701. m.head_big = &s
  18702. }
  18703. // HeadBig returns the value of the "head_big" field in the mutation.
  18704. func (m *WxMutation) HeadBig() (r string, exists bool) {
  18705. v := m.head_big
  18706. if v == nil {
  18707. return
  18708. }
  18709. return *v, true
  18710. }
  18711. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  18712. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18714. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  18715. if !m.op.Is(OpUpdateOne) {
  18716. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  18717. }
  18718. if m.id == nil || m.oldValue == nil {
  18719. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  18720. }
  18721. oldValue, err := m.oldValue(ctx)
  18722. if err != nil {
  18723. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  18724. }
  18725. return oldValue.HeadBig, nil
  18726. }
  18727. // ResetHeadBig resets all changes to the "head_big" field.
  18728. func (m *WxMutation) ResetHeadBig() {
  18729. m.head_big = nil
  18730. }
  18731. // SetOrganizationID sets the "organization_id" field.
  18732. func (m *WxMutation) SetOrganizationID(u uint64) {
  18733. m.organization_id = &u
  18734. m.addorganization_id = nil
  18735. }
  18736. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18737. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  18738. v := m.organization_id
  18739. if v == nil {
  18740. return
  18741. }
  18742. return *v, true
  18743. }
  18744. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  18745. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18747. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18748. if !m.op.Is(OpUpdateOne) {
  18749. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18750. }
  18751. if m.id == nil || m.oldValue == nil {
  18752. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18753. }
  18754. oldValue, err := m.oldValue(ctx)
  18755. if err != nil {
  18756. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18757. }
  18758. return oldValue.OrganizationID, nil
  18759. }
  18760. // AddOrganizationID adds u to the "organization_id" field.
  18761. func (m *WxMutation) AddOrganizationID(u int64) {
  18762. if m.addorganization_id != nil {
  18763. *m.addorganization_id += u
  18764. } else {
  18765. m.addorganization_id = &u
  18766. }
  18767. }
  18768. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18769. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  18770. v := m.addorganization_id
  18771. if v == nil {
  18772. return
  18773. }
  18774. return *v, true
  18775. }
  18776. // ClearOrganizationID clears the value of the "organization_id" field.
  18777. func (m *WxMutation) ClearOrganizationID() {
  18778. m.organization_id = nil
  18779. m.addorganization_id = nil
  18780. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  18781. }
  18782. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18783. func (m *WxMutation) OrganizationIDCleared() bool {
  18784. _, ok := m.clearedFields[wx.FieldOrganizationID]
  18785. return ok
  18786. }
  18787. // ResetOrganizationID resets all changes to the "organization_id" field.
  18788. func (m *WxMutation) ResetOrganizationID() {
  18789. m.organization_id = nil
  18790. m.addorganization_id = nil
  18791. delete(m.clearedFields, wx.FieldOrganizationID)
  18792. }
  18793. // SetAgentID sets the "agent_id" field.
  18794. func (m *WxMutation) SetAgentID(u uint64) {
  18795. m.agent = &u
  18796. }
  18797. // AgentID returns the value of the "agent_id" field in the mutation.
  18798. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  18799. v := m.agent
  18800. if v == nil {
  18801. return
  18802. }
  18803. return *v, true
  18804. }
  18805. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  18806. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18808. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  18809. if !m.op.Is(OpUpdateOne) {
  18810. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  18811. }
  18812. if m.id == nil || m.oldValue == nil {
  18813. return v, errors.New("OldAgentID requires an ID field in the mutation")
  18814. }
  18815. oldValue, err := m.oldValue(ctx)
  18816. if err != nil {
  18817. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  18818. }
  18819. return oldValue.AgentID, nil
  18820. }
  18821. // ResetAgentID resets all changes to the "agent_id" field.
  18822. func (m *WxMutation) ResetAgentID() {
  18823. m.agent = nil
  18824. }
  18825. // SetAPIBase sets the "api_base" field.
  18826. func (m *WxMutation) SetAPIBase(s string) {
  18827. m.api_base = &s
  18828. }
  18829. // APIBase returns the value of the "api_base" field in the mutation.
  18830. func (m *WxMutation) APIBase() (r string, exists bool) {
  18831. v := m.api_base
  18832. if v == nil {
  18833. return
  18834. }
  18835. return *v, true
  18836. }
  18837. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  18838. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18840. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  18841. if !m.op.Is(OpUpdateOne) {
  18842. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  18843. }
  18844. if m.id == nil || m.oldValue == nil {
  18845. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  18846. }
  18847. oldValue, err := m.oldValue(ctx)
  18848. if err != nil {
  18849. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  18850. }
  18851. return oldValue.APIBase, nil
  18852. }
  18853. // ClearAPIBase clears the value of the "api_base" field.
  18854. func (m *WxMutation) ClearAPIBase() {
  18855. m.api_base = nil
  18856. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  18857. }
  18858. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  18859. func (m *WxMutation) APIBaseCleared() bool {
  18860. _, ok := m.clearedFields[wx.FieldAPIBase]
  18861. return ok
  18862. }
  18863. // ResetAPIBase resets all changes to the "api_base" field.
  18864. func (m *WxMutation) ResetAPIBase() {
  18865. m.api_base = nil
  18866. delete(m.clearedFields, wx.FieldAPIBase)
  18867. }
  18868. // SetAPIKey sets the "api_key" field.
  18869. func (m *WxMutation) SetAPIKey(s string) {
  18870. m.api_key = &s
  18871. }
  18872. // APIKey returns the value of the "api_key" field in the mutation.
  18873. func (m *WxMutation) APIKey() (r string, exists bool) {
  18874. v := m.api_key
  18875. if v == nil {
  18876. return
  18877. }
  18878. return *v, true
  18879. }
  18880. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  18881. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18882. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18883. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  18884. if !m.op.Is(OpUpdateOne) {
  18885. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  18886. }
  18887. if m.id == nil || m.oldValue == nil {
  18888. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  18889. }
  18890. oldValue, err := m.oldValue(ctx)
  18891. if err != nil {
  18892. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  18893. }
  18894. return oldValue.APIKey, nil
  18895. }
  18896. // ClearAPIKey clears the value of the "api_key" field.
  18897. func (m *WxMutation) ClearAPIKey() {
  18898. m.api_key = nil
  18899. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  18900. }
  18901. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  18902. func (m *WxMutation) APIKeyCleared() bool {
  18903. _, ok := m.clearedFields[wx.FieldAPIKey]
  18904. return ok
  18905. }
  18906. // ResetAPIKey resets all changes to the "api_key" field.
  18907. func (m *WxMutation) ResetAPIKey() {
  18908. m.api_key = nil
  18909. delete(m.clearedFields, wx.FieldAPIKey)
  18910. }
  18911. // ClearServer clears the "server" edge to the Server entity.
  18912. func (m *WxMutation) ClearServer() {
  18913. m.clearedserver = true
  18914. m.clearedFields[wx.FieldServerID] = struct{}{}
  18915. }
  18916. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  18917. func (m *WxMutation) ServerCleared() bool {
  18918. return m.ServerIDCleared() || m.clearedserver
  18919. }
  18920. // ServerIDs returns the "server" edge IDs in the mutation.
  18921. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18922. // ServerID instead. It exists only for internal usage by the builders.
  18923. func (m *WxMutation) ServerIDs() (ids []uint64) {
  18924. if id := m.server; id != nil {
  18925. ids = append(ids, *id)
  18926. }
  18927. return
  18928. }
  18929. // ResetServer resets all changes to the "server" edge.
  18930. func (m *WxMutation) ResetServer() {
  18931. m.server = nil
  18932. m.clearedserver = false
  18933. }
  18934. // ClearAgent clears the "agent" edge to the Agent entity.
  18935. func (m *WxMutation) ClearAgent() {
  18936. m.clearedagent = true
  18937. m.clearedFields[wx.FieldAgentID] = struct{}{}
  18938. }
  18939. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  18940. func (m *WxMutation) AgentCleared() bool {
  18941. return m.clearedagent
  18942. }
  18943. // AgentIDs returns the "agent" edge IDs in the mutation.
  18944. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18945. // AgentID instead. It exists only for internal usage by the builders.
  18946. func (m *WxMutation) AgentIDs() (ids []uint64) {
  18947. if id := m.agent; id != nil {
  18948. ids = append(ids, *id)
  18949. }
  18950. return
  18951. }
  18952. // ResetAgent resets all changes to the "agent" edge.
  18953. func (m *WxMutation) ResetAgent() {
  18954. m.agent = nil
  18955. m.clearedagent = false
  18956. }
  18957. // Where appends a list predicates to the WxMutation builder.
  18958. func (m *WxMutation) Where(ps ...predicate.Wx) {
  18959. m.predicates = append(m.predicates, ps...)
  18960. }
  18961. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  18962. // users can use type-assertion to append predicates that do not depend on any generated package.
  18963. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  18964. p := make([]predicate.Wx, len(ps))
  18965. for i := range ps {
  18966. p[i] = ps[i]
  18967. }
  18968. m.Where(p...)
  18969. }
  18970. // Op returns the operation name.
  18971. func (m *WxMutation) Op() Op {
  18972. return m.op
  18973. }
  18974. // SetOp allows setting the mutation operation.
  18975. func (m *WxMutation) SetOp(op Op) {
  18976. m.op = op
  18977. }
  18978. // Type returns the node type of this mutation (Wx).
  18979. func (m *WxMutation) Type() string {
  18980. return m.typ
  18981. }
  18982. // Fields returns all fields that were changed during this mutation. Note that in
  18983. // order to get all numeric fields that were incremented/decremented, call
  18984. // AddedFields().
  18985. func (m *WxMutation) Fields() []string {
  18986. fields := make([]string, 0, 17)
  18987. if m.created_at != nil {
  18988. fields = append(fields, wx.FieldCreatedAt)
  18989. }
  18990. if m.updated_at != nil {
  18991. fields = append(fields, wx.FieldUpdatedAt)
  18992. }
  18993. if m.status != nil {
  18994. fields = append(fields, wx.FieldStatus)
  18995. }
  18996. if m.deleted_at != nil {
  18997. fields = append(fields, wx.FieldDeletedAt)
  18998. }
  18999. if m.server != nil {
  19000. fields = append(fields, wx.FieldServerID)
  19001. }
  19002. if m.port != nil {
  19003. fields = append(fields, wx.FieldPort)
  19004. }
  19005. if m.process_id != nil {
  19006. fields = append(fields, wx.FieldProcessID)
  19007. }
  19008. if m.callback != nil {
  19009. fields = append(fields, wx.FieldCallback)
  19010. }
  19011. if m.wxid != nil {
  19012. fields = append(fields, wx.FieldWxid)
  19013. }
  19014. if m.account != nil {
  19015. fields = append(fields, wx.FieldAccount)
  19016. }
  19017. if m.nickname != nil {
  19018. fields = append(fields, wx.FieldNickname)
  19019. }
  19020. if m.tel != nil {
  19021. fields = append(fields, wx.FieldTel)
  19022. }
  19023. if m.head_big != nil {
  19024. fields = append(fields, wx.FieldHeadBig)
  19025. }
  19026. if m.organization_id != nil {
  19027. fields = append(fields, wx.FieldOrganizationID)
  19028. }
  19029. if m.agent != nil {
  19030. fields = append(fields, wx.FieldAgentID)
  19031. }
  19032. if m.api_base != nil {
  19033. fields = append(fields, wx.FieldAPIBase)
  19034. }
  19035. if m.api_key != nil {
  19036. fields = append(fields, wx.FieldAPIKey)
  19037. }
  19038. return fields
  19039. }
  19040. // Field returns the value of a field with the given name. The second boolean
  19041. // return value indicates that this field was not set, or was not defined in the
  19042. // schema.
  19043. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  19044. switch name {
  19045. case wx.FieldCreatedAt:
  19046. return m.CreatedAt()
  19047. case wx.FieldUpdatedAt:
  19048. return m.UpdatedAt()
  19049. case wx.FieldStatus:
  19050. return m.Status()
  19051. case wx.FieldDeletedAt:
  19052. return m.DeletedAt()
  19053. case wx.FieldServerID:
  19054. return m.ServerID()
  19055. case wx.FieldPort:
  19056. return m.Port()
  19057. case wx.FieldProcessID:
  19058. return m.ProcessID()
  19059. case wx.FieldCallback:
  19060. return m.Callback()
  19061. case wx.FieldWxid:
  19062. return m.Wxid()
  19063. case wx.FieldAccount:
  19064. return m.Account()
  19065. case wx.FieldNickname:
  19066. return m.Nickname()
  19067. case wx.FieldTel:
  19068. return m.Tel()
  19069. case wx.FieldHeadBig:
  19070. return m.HeadBig()
  19071. case wx.FieldOrganizationID:
  19072. return m.OrganizationID()
  19073. case wx.FieldAgentID:
  19074. return m.AgentID()
  19075. case wx.FieldAPIBase:
  19076. return m.APIBase()
  19077. case wx.FieldAPIKey:
  19078. return m.APIKey()
  19079. }
  19080. return nil, false
  19081. }
  19082. // OldField returns the old value of the field from the database. An error is
  19083. // returned if the mutation operation is not UpdateOne, or the query to the
  19084. // database failed.
  19085. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19086. switch name {
  19087. case wx.FieldCreatedAt:
  19088. return m.OldCreatedAt(ctx)
  19089. case wx.FieldUpdatedAt:
  19090. return m.OldUpdatedAt(ctx)
  19091. case wx.FieldStatus:
  19092. return m.OldStatus(ctx)
  19093. case wx.FieldDeletedAt:
  19094. return m.OldDeletedAt(ctx)
  19095. case wx.FieldServerID:
  19096. return m.OldServerID(ctx)
  19097. case wx.FieldPort:
  19098. return m.OldPort(ctx)
  19099. case wx.FieldProcessID:
  19100. return m.OldProcessID(ctx)
  19101. case wx.FieldCallback:
  19102. return m.OldCallback(ctx)
  19103. case wx.FieldWxid:
  19104. return m.OldWxid(ctx)
  19105. case wx.FieldAccount:
  19106. return m.OldAccount(ctx)
  19107. case wx.FieldNickname:
  19108. return m.OldNickname(ctx)
  19109. case wx.FieldTel:
  19110. return m.OldTel(ctx)
  19111. case wx.FieldHeadBig:
  19112. return m.OldHeadBig(ctx)
  19113. case wx.FieldOrganizationID:
  19114. return m.OldOrganizationID(ctx)
  19115. case wx.FieldAgentID:
  19116. return m.OldAgentID(ctx)
  19117. case wx.FieldAPIBase:
  19118. return m.OldAPIBase(ctx)
  19119. case wx.FieldAPIKey:
  19120. return m.OldAPIKey(ctx)
  19121. }
  19122. return nil, fmt.Errorf("unknown Wx field %s", name)
  19123. }
  19124. // SetField sets the value of a field with the given name. It returns an error if
  19125. // the field is not defined in the schema, or if the type mismatched the field
  19126. // type.
  19127. func (m *WxMutation) SetField(name string, value ent.Value) error {
  19128. switch name {
  19129. case wx.FieldCreatedAt:
  19130. v, ok := value.(time.Time)
  19131. if !ok {
  19132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19133. }
  19134. m.SetCreatedAt(v)
  19135. return nil
  19136. case wx.FieldUpdatedAt:
  19137. v, ok := value.(time.Time)
  19138. if !ok {
  19139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19140. }
  19141. m.SetUpdatedAt(v)
  19142. return nil
  19143. case wx.FieldStatus:
  19144. v, ok := value.(uint8)
  19145. if !ok {
  19146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19147. }
  19148. m.SetStatus(v)
  19149. return nil
  19150. case wx.FieldDeletedAt:
  19151. v, ok := value.(time.Time)
  19152. if !ok {
  19153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19154. }
  19155. m.SetDeletedAt(v)
  19156. return nil
  19157. case wx.FieldServerID:
  19158. v, ok := value.(uint64)
  19159. if !ok {
  19160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19161. }
  19162. m.SetServerID(v)
  19163. return nil
  19164. case wx.FieldPort:
  19165. v, ok := value.(string)
  19166. if !ok {
  19167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19168. }
  19169. m.SetPort(v)
  19170. return nil
  19171. case wx.FieldProcessID:
  19172. v, ok := value.(string)
  19173. if !ok {
  19174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19175. }
  19176. m.SetProcessID(v)
  19177. return nil
  19178. case wx.FieldCallback:
  19179. v, ok := value.(string)
  19180. if !ok {
  19181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19182. }
  19183. m.SetCallback(v)
  19184. return nil
  19185. case wx.FieldWxid:
  19186. v, ok := value.(string)
  19187. if !ok {
  19188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19189. }
  19190. m.SetWxid(v)
  19191. return nil
  19192. case wx.FieldAccount:
  19193. v, ok := value.(string)
  19194. if !ok {
  19195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19196. }
  19197. m.SetAccount(v)
  19198. return nil
  19199. case wx.FieldNickname:
  19200. v, ok := value.(string)
  19201. if !ok {
  19202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19203. }
  19204. m.SetNickname(v)
  19205. return nil
  19206. case wx.FieldTel:
  19207. v, ok := value.(string)
  19208. if !ok {
  19209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19210. }
  19211. m.SetTel(v)
  19212. return nil
  19213. case wx.FieldHeadBig:
  19214. v, ok := value.(string)
  19215. if !ok {
  19216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19217. }
  19218. m.SetHeadBig(v)
  19219. return nil
  19220. case wx.FieldOrganizationID:
  19221. v, ok := value.(uint64)
  19222. if !ok {
  19223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19224. }
  19225. m.SetOrganizationID(v)
  19226. return nil
  19227. case wx.FieldAgentID:
  19228. v, ok := value.(uint64)
  19229. if !ok {
  19230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19231. }
  19232. m.SetAgentID(v)
  19233. return nil
  19234. case wx.FieldAPIBase:
  19235. v, ok := value.(string)
  19236. if !ok {
  19237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19238. }
  19239. m.SetAPIBase(v)
  19240. return nil
  19241. case wx.FieldAPIKey:
  19242. v, ok := value.(string)
  19243. if !ok {
  19244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19245. }
  19246. m.SetAPIKey(v)
  19247. return nil
  19248. }
  19249. return fmt.Errorf("unknown Wx field %s", name)
  19250. }
  19251. // AddedFields returns all numeric fields that were incremented/decremented during
  19252. // this mutation.
  19253. func (m *WxMutation) AddedFields() []string {
  19254. var fields []string
  19255. if m.addstatus != nil {
  19256. fields = append(fields, wx.FieldStatus)
  19257. }
  19258. if m.addorganization_id != nil {
  19259. fields = append(fields, wx.FieldOrganizationID)
  19260. }
  19261. return fields
  19262. }
  19263. // AddedField returns the numeric value that was incremented/decremented on a field
  19264. // with the given name. The second boolean return value indicates that this field
  19265. // was not set, or was not defined in the schema.
  19266. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  19267. switch name {
  19268. case wx.FieldStatus:
  19269. return m.AddedStatus()
  19270. case wx.FieldOrganizationID:
  19271. return m.AddedOrganizationID()
  19272. }
  19273. return nil, false
  19274. }
  19275. // AddField adds the value to the field with the given name. It returns an error if
  19276. // the field is not defined in the schema, or if the type mismatched the field
  19277. // type.
  19278. func (m *WxMutation) AddField(name string, value ent.Value) error {
  19279. switch name {
  19280. case wx.FieldStatus:
  19281. v, ok := value.(int8)
  19282. if !ok {
  19283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19284. }
  19285. m.AddStatus(v)
  19286. return nil
  19287. case wx.FieldOrganizationID:
  19288. v, ok := value.(int64)
  19289. if !ok {
  19290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19291. }
  19292. m.AddOrganizationID(v)
  19293. return nil
  19294. }
  19295. return fmt.Errorf("unknown Wx numeric field %s", name)
  19296. }
  19297. // ClearedFields returns all nullable fields that were cleared during this
  19298. // mutation.
  19299. func (m *WxMutation) ClearedFields() []string {
  19300. var fields []string
  19301. if m.FieldCleared(wx.FieldStatus) {
  19302. fields = append(fields, wx.FieldStatus)
  19303. }
  19304. if m.FieldCleared(wx.FieldDeletedAt) {
  19305. fields = append(fields, wx.FieldDeletedAt)
  19306. }
  19307. if m.FieldCleared(wx.FieldServerID) {
  19308. fields = append(fields, wx.FieldServerID)
  19309. }
  19310. if m.FieldCleared(wx.FieldOrganizationID) {
  19311. fields = append(fields, wx.FieldOrganizationID)
  19312. }
  19313. if m.FieldCleared(wx.FieldAPIBase) {
  19314. fields = append(fields, wx.FieldAPIBase)
  19315. }
  19316. if m.FieldCleared(wx.FieldAPIKey) {
  19317. fields = append(fields, wx.FieldAPIKey)
  19318. }
  19319. return fields
  19320. }
  19321. // FieldCleared returns a boolean indicating if a field with the given name was
  19322. // cleared in this mutation.
  19323. func (m *WxMutation) FieldCleared(name string) bool {
  19324. _, ok := m.clearedFields[name]
  19325. return ok
  19326. }
  19327. // ClearField clears the value of the field with the given name. It returns an
  19328. // error if the field is not defined in the schema.
  19329. func (m *WxMutation) ClearField(name string) error {
  19330. switch name {
  19331. case wx.FieldStatus:
  19332. m.ClearStatus()
  19333. return nil
  19334. case wx.FieldDeletedAt:
  19335. m.ClearDeletedAt()
  19336. return nil
  19337. case wx.FieldServerID:
  19338. m.ClearServerID()
  19339. return nil
  19340. case wx.FieldOrganizationID:
  19341. m.ClearOrganizationID()
  19342. return nil
  19343. case wx.FieldAPIBase:
  19344. m.ClearAPIBase()
  19345. return nil
  19346. case wx.FieldAPIKey:
  19347. m.ClearAPIKey()
  19348. return nil
  19349. }
  19350. return fmt.Errorf("unknown Wx nullable field %s", name)
  19351. }
  19352. // ResetField resets all changes in the mutation for the field with the given name.
  19353. // It returns an error if the field is not defined in the schema.
  19354. func (m *WxMutation) ResetField(name string) error {
  19355. switch name {
  19356. case wx.FieldCreatedAt:
  19357. m.ResetCreatedAt()
  19358. return nil
  19359. case wx.FieldUpdatedAt:
  19360. m.ResetUpdatedAt()
  19361. return nil
  19362. case wx.FieldStatus:
  19363. m.ResetStatus()
  19364. return nil
  19365. case wx.FieldDeletedAt:
  19366. m.ResetDeletedAt()
  19367. return nil
  19368. case wx.FieldServerID:
  19369. m.ResetServerID()
  19370. return nil
  19371. case wx.FieldPort:
  19372. m.ResetPort()
  19373. return nil
  19374. case wx.FieldProcessID:
  19375. m.ResetProcessID()
  19376. return nil
  19377. case wx.FieldCallback:
  19378. m.ResetCallback()
  19379. return nil
  19380. case wx.FieldWxid:
  19381. m.ResetWxid()
  19382. return nil
  19383. case wx.FieldAccount:
  19384. m.ResetAccount()
  19385. return nil
  19386. case wx.FieldNickname:
  19387. m.ResetNickname()
  19388. return nil
  19389. case wx.FieldTel:
  19390. m.ResetTel()
  19391. return nil
  19392. case wx.FieldHeadBig:
  19393. m.ResetHeadBig()
  19394. return nil
  19395. case wx.FieldOrganizationID:
  19396. m.ResetOrganizationID()
  19397. return nil
  19398. case wx.FieldAgentID:
  19399. m.ResetAgentID()
  19400. return nil
  19401. case wx.FieldAPIBase:
  19402. m.ResetAPIBase()
  19403. return nil
  19404. case wx.FieldAPIKey:
  19405. m.ResetAPIKey()
  19406. return nil
  19407. }
  19408. return fmt.Errorf("unknown Wx field %s", name)
  19409. }
  19410. // AddedEdges returns all edge names that were set/added in this mutation.
  19411. func (m *WxMutation) AddedEdges() []string {
  19412. edges := make([]string, 0, 2)
  19413. if m.server != nil {
  19414. edges = append(edges, wx.EdgeServer)
  19415. }
  19416. if m.agent != nil {
  19417. edges = append(edges, wx.EdgeAgent)
  19418. }
  19419. return edges
  19420. }
  19421. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19422. // name in this mutation.
  19423. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  19424. switch name {
  19425. case wx.EdgeServer:
  19426. if id := m.server; id != nil {
  19427. return []ent.Value{*id}
  19428. }
  19429. case wx.EdgeAgent:
  19430. if id := m.agent; id != nil {
  19431. return []ent.Value{*id}
  19432. }
  19433. }
  19434. return nil
  19435. }
  19436. // RemovedEdges returns all edge names that were removed in this mutation.
  19437. func (m *WxMutation) RemovedEdges() []string {
  19438. edges := make([]string, 0, 2)
  19439. return edges
  19440. }
  19441. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19442. // the given name in this mutation.
  19443. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  19444. return nil
  19445. }
  19446. // ClearedEdges returns all edge names that were cleared in this mutation.
  19447. func (m *WxMutation) ClearedEdges() []string {
  19448. edges := make([]string, 0, 2)
  19449. if m.clearedserver {
  19450. edges = append(edges, wx.EdgeServer)
  19451. }
  19452. if m.clearedagent {
  19453. edges = append(edges, wx.EdgeAgent)
  19454. }
  19455. return edges
  19456. }
  19457. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19458. // was cleared in this mutation.
  19459. func (m *WxMutation) EdgeCleared(name string) bool {
  19460. switch name {
  19461. case wx.EdgeServer:
  19462. return m.clearedserver
  19463. case wx.EdgeAgent:
  19464. return m.clearedagent
  19465. }
  19466. return false
  19467. }
  19468. // ClearEdge clears the value of the edge with the given name. It returns an error
  19469. // if that edge is not defined in the schema.
  19470. func (m *WxMutation) ClearEdge(name string) error {
  19471. switch name {
  19472. case wx.EdgeServer:
  19473. m.ClearServer()
  19474. return nil
  19475. case wx.EdgeAgent:
  19476. m.ClearAgent()
  19477. return nil
  19478. }
  19479. return fmt.Errorf("unknown Wx unique edge %s", name)
  19480. }
  19481. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19482. // It returns an error if the edge is not defined in the schema.
  19483. func (m *WxMutation) ResetEdge(name string) error {
  19484. switch name {
  19485. case wx.EdgeServer:
  19486. m.ResetServer()
  19487. return nil
  19488. case wx.EdgeAgent:
  19489. m.ResetAgent()
  19490. return nil
  19491. }
  19492. return fmt.Errorf("unknown Wx edge %s", name)
  19493. }