mutation.go 645 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917
  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. dataset_id *string
  79. collection_id *string
  80. clearedFields map[string]struct{}
  81. wx_agent map[uint64]struct{}
  82. removedwx_agent map[uint64]struct{}
  83. clearedwx_agent bool
  84. done bool
  85. oldValue func(context.Context) (*Agent, error)
  86. predicates []predicate.Agent
  87. }
  88. var _ ent.Mutation = (*AgentMutation)(nil)
  89. // agentOption allows management of the mutation configuration using functional options.
  90. type agentOption func(*AgentMutation)
  91. // newAgentMutation creates new mutation for the Agent entity.
  92. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  93. m := &AgentMutation{
  94. config: c,
  95. op: op,
  96. typ: TypeAgent,
  97. clearedFields: make(map[string]struct{}),
  98. }
  99. for _, opt := range opts {
  100. opt(m)
  101. }
  102. return m
  103. }
  104. // withAgentID sets the ID field of the mutation.
  105. func withAgentID(id uint64) agentOption {
  106. return func(m *AgentMutation) {
  107. var (
  108. err error
  109. once sync.Once
  110. value *Agent
  111. )
  112. m.oldValue = func(ctx context.Context) (*Agent, error) {
  113. once.Do(func() {
  114. if m.done {
  115. err = errors.New("querying old values post mutation is not allowed")
  116. } else {
  117. value, err = m.Client().Agent.Get(ctx, id)
  118. }
  119. })
  120. return value, err
  121. }
  122. m.id = &id
  123. }
  124. }
  125. // withAgent sets the old Agent of the mutation.
  126. func withAgent(node *Agent) agentOption {
  127. return func(m *AgentMutation) {
  128. m.oldValue = func(context.Context) (*Agent, error) {
  129. return node, nil
  130. }
  131. m.id = &node.ID
  132. }
  133. }
  134. // Client returns a new `ent.Client` from the mutation. If the mutation was
  135. // executed in a transaction (ent.Tx), a transactional client is returned.
  136. func (m AgentMutation) Client() *Client {
  137. client := &Client{config: m.config}
  138. client.init()
  139. return client
  140. }
  141. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  142. // it returns an error otherwise.
  143. func (m AgentMutation) Tx() (*Tx, error) {
  144. if _, ok := m.driver.(*txDriver); !ok {
  145. return nil, errors.New("ent: mutation is not running in a transaction")
  146. }
  147. tx := &Tx{config: m.config}
  148. tx.init()
  149. return tx, nil
  150. }
  151. // SetID sets the value of the id field. Note that this
  152. // operation is only accepted on creation of Agent entities.
  153. func (m *AgentMutation) SetID(id uint64) {
  154. m.id = &id
  155. }
  156. // ID returns the ID value in the mutation. Note that the ID is only available
  157. // if it was provided to the builder or after it was returned from the database.
  158. func (m *AgentMutation) ID() (id uint64, exists bool) {
  159. if m.id == nil {
  160. return
  161. }
  162. return *m.id, true
  163. }
  164. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  165. // That means, if the mutation is applied within a transaction with an isolation level such
  166. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  167. // or updated by the mutation.
  168. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  169. switch {
  170. case m.op.Is(OpUpdateOne | OpDeleteOne):
  171. id, exists := m.ID()
  172. if exists {
  173. return []uint64{id}, nil
  174. }
  175. fallthrough
  176. case m.op.Is(OpUpdate | OpDelete):
  177. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  178. default:
  179. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  180. }
  181. }
  182. // SetCreatedAt sets the "created_at" field.
  183. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  184. m.created_at = &t
  185. }
  186. // CreatedAt returns the value of the "created_at" field in the mutation.
  187. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  188. v := m.created_at
  189. if v == nil {
  190. return
  191. }
  192. return *v, true
  193. }
  194. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  195. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  197. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  198. if !m.op.Is(OpUpdateOne) {
  199. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  200. }
  201. if m.id == nil || m.oldValue == nil {
  202. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  203. }
  204. oldValue, err := m.oldValue(ctx)
  205. if err != nil {
  206. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  207. }
  208. return oldValue.CreatedAt, nil
  209. }
  210. // ResetCreatedAt resets all changes to the "created_at" field.
  211. func (m *AgentMutation) ResetCreatedAt() {
  212. m.created_at = nil
  213. }
  214. // SetUpdatedAt sets the "updated_at" field.
  215. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  216. m.updated_at = &t
  217. }
  218. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  219. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  220. v := m.updated_at
  221. if v == nil {
  222. return
  223. }
  224. return *v, true
  225. }
  226. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  227. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  229. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  230. if !m.op.Is(OpUpdateOne) {
  231. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  232. }
  233. if m.id == nil || m.oldValue == nil {
  234. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  235. }
  236. oldValue, err := m.oldValue(ctx)
  237. if err != nil {
  238. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  239. }
  240. return oldValue.UpdatedAt, nil
  241. }
  242. // ResetUpdatedAt resets all changes to the "updated_at" field.
  243. func (m *AgentMutation) ResetUpdatedAt() {
  244. m.updated_at = nil
  245. }
  246. // SetDeletedAt sets the "deleted_at" field.
  247. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  248. m.deleted_at = &t
  249. }
  250. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  251. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  252. v := m.deleted_at
  253. if v == nil {
  254. return
  255. }
  256. return *v, true
  257. }
  258. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  259. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  261. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  262. if !m.op.Is(OpUpdateOne) {
  263. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  264. }
  265. if m.id == nil || m.oldValue == nil {
  266. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  267. }
  268. oldValue, err := m.oldValue(ctx)
  269. if err != nil {
  270. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  271. }
  272. return oldValue.DeletedAt, nil
  273. }
  274. // ClearDeletedAt clears the value of the "deleted_at" field.
  275. func (m *AgentMutation) ClearDeletedAt() {
  276. m.deleted_at = nil
  277. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  278. }
  279. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  280. func (m *AgentMutation) DeletedAtCleared() bool {
  281. _, ok := m.clearedFields[agent.FieldDeletedAt]
  282. return ok
  283. }
  284. // ResetDeletedAt resets all changes to the "deleted_at" field.
  285. func (m *AgentMutation) ResetDeletedAt() {
  286. m.deleted_at = nil
  287. delete(m.clearedFields, agent.FieldDeletedAt)
  288. }
  289. // SetName sets the "name" field.
  290. func (m *AgentMutation) SetName(s string) {
  291. m.name = &s
  292. }
  293. // Name returns the value of the "name" field in the mutation.
  294. func (m *AgentMutation) Name() (r string, exists bool) {
  295. v := m.name
  296. if v == nil {
  297. return
  298. }
  299. return *v, true
  300. }
  301. // OldName returns the old "name" field's value of the Agent entity.
  302. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  304. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  305. if !m.op.Is(OpUpdateOne) {
  306. return v, errors.New("OldName is only allowed on UpdateOne operations")
  307. }
  308. if m.id == nil || m.oldValue == nil {
  309. return v, errors.New("OldName requires an ID field in the mutation")
  310. }
  311. oldValue, err := m.oldValue(ctx)
  312. if err != nil {
  313. return v, fmt.Errorf("querying old value for OldName: %w", err)
  314. }
  315. return oldValue.Name, nil
  316. }
  317. // ResetName resets all changes to the "name" field.
  318. func (m *AgentMutation) ResetName() {
  319. m.name = nil
  320. }
  321. // SetRole sets the "role" field.
  322. func (m *AgentMutation) SetRole(s string) {
  323. m.role = &s
  324. }
  325. // Role returns the value of the "role" field in the mutation.
  326. func (m *AgentMutation) Role() (r string, exists bool) {
  327. v := m.role
  328. if v == nil {
  329. return
  330. }
  331. return *v, true
  332. }
  333. // OldRole returns the old "role" field's value of the Agent entity.
  334. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  336. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  337. if !m.op.Is(OpUpdateOne) {
  338. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  339. }
  340. if m.id == nil || m.oldValue == nil {
  341. return v, errors.New("OldRole requires an ID field in the mutation")
  342. }
  343. oldValue, err := m.oldValue(ctx)
  344. if err != nil {
  345. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  346. }
  347. return oldValue.Role, nil
  348. }
  349. // ResetRole resets all changes to the "role" field.
  350. func (m *AgentMutation) ResetRole() {
  351. m.role = nil
  352. }
  353. // SetStatus sets the "status" field.
  354. func (m *AgentMutation) SetStatus(i int) {
  355. m.status = &i
  356. m.addstatus = nil
  357. }
  358. // Status returns the value of the "status" field in the mutation.
  359. func (m *AgentMutation) Status() (r int, exists bool) {
  360. v := m.status
  361. if v == nil {
  362. return
  363. }
  364. return *v, true
  365. }
  366. // OldStatus returns the old "status" field's value of the Agent entity.
  367. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  369. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  370. if !m.op.Is(OpUpdateOne) {
  371. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  372. }
  373. if m.id == nil || m.oldValue == nil {
  374. return v, errors.New("OldStatus requires an ID field in the mutation")
  375. }
  376. oldValue, err := m.oldValue(ctx)
  377. if err != nil {
  378. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  379. }
  380. return oldValue.Status, nil
  381. }
  382. // AddStatus adds i to the "status" field.
  383. func (m *AgentMutation) AddStatus(i int) {
  384. if m.addstatus != nil {
  385. *m.addstatus += i
  386. } else {
  387. m.addstatus = &i
  388. }
  389. }
  390. // AddedStatus returns the value that was added to the "status" field in this mutation.
  391. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  392. v := m.addstatus
  393. if v == nil {
  394. return
  395. }
  396. return *v, true
  397. }
  398. // ClearStatus clears the value of the "status" field.
  399. func (m *AgentMutation) ClearStatus() {
  400. m.status = nil
  401. m.addstatus = nil
  402. m.clearedFields[agent.FieldStatus] = struct{}{}
  403. }
  404. // StatusCleared returns if the "status" field was cleared in this mutation.
  405. func (m *AgentMutation) StatusCleared() bool {
  406. _, ok := m.clearedFields[agent.FieldStatus]
  407. return ok
  408. }
  409. // ResetStatus resets all changes to the "status" field.
  410. func (m *AgentMutation) ResetStatus() {
  411. m.status = nil
  412. m.addstatus = nil
  413. delete(m.clearedFields, agent.FieldStatus)
  414. }
  415. // SetBackground sets the "background" field.
  416. func (m *AgentMutation) SetBackground(s string) {
  417. m.background = &s
  418. }
  419. // Background returns the value of the "background" field in the mutation.
  420. func (m *AgentMutation) Background() (r string, exists bool) {
  421. v := m.background
  422. if v == nil {
  423. return
  424. }
  425. return *v, true
  426. }
  427. // OldBackground returns the old "background" field's value of the Agent entity.
  428. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  430. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  431. if !m.op.Is(OpUpdateOne) {
  432. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  433. }
  434. if m.id == nil || m.oldValue == nil {
  435. return v, errors.New("OldBackground requires an ID field in the mutation")
  436. }
  437. oldValue, err := m.oldValue(ctx)
  438. if err != nil {
  439. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  440. }
  441. return oldValue.Background, nil
  442. }
  443. // ClearBackground clears the value of the "background" field.
  444. func (m *AgentMutation) ClearBackground() {
  445. m.background = nil
  446. m.clearedFields[agent.FieldBackground] = struct{}{}
  447. }
  448. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  449. func (m *AgentMutation) BackgroundCleared() bool {
  450. _, ok := m.clearedFields[agent.FieldBackground]
  451. return ok
  452. }
  453. // ResetBackground resets all changes to the "background" field.
  454. func (m *AgentMutation) ResetBackground() {
  455. m.background = nil
  456. delete(m.clearedFields, agent.FieldBackground)
  457. }
  458. // SetExamples sets the "examples" field.
  459. func (m *AgentMutation) SetExamples(s string) {
  460. m.examples = &s
  461. }
  462. // Examples returns the value of the "examples" field in the mutation.
  463. func (m *AgentMutation) Examples() (r string, exists bool) {
  464. v := m.examples
  465. if v == nil {
  466. return
  467. }
  468. return *v, true
  469. }
  470. // OldExamples returns the old "examples" field's value of the Agent entity.
  471. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  473. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  474. if !m.op.Is(OpUpdateOne) {
  475. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  476. }
  477. if m.id == nil || m.oldValue == nil {
  478. return v, errors.New("OldExamples requires an ID field in the mutation")
  479. }
  480. oldValue, err := m.oldValue(ctx)
  481. if err != nil {
  482. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  483. }
  484. return oldValue.Examples, nil
  485. }
  486. // ClearExamples clears the value of the "examples" field.
  487. func (m *AgentMutation) ClearExamples() {
  488. m.examples = nil
  489. m.clearedFields[agent.FieldExamples] = struct{}{}
  490. }
  491. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  492. func (m *AgentMutation) ExamplesCleared() bool {
  493. _, ok := m.clearedFields[agent.FieldExamples]
  494. return ok
  495. }
  496. // ResetExamples resets all changes to the "examples" field.
  497. func (m *AgentMutation) ResetExamples() {
  498. m.examples = nil
  499. delete(m.clearedFields, agent.FieldExamples)
  500. }
  501. // SetOrganizationID sets the "organization_id" field.
  502. func (m *AgentMutation) SetOrganizationID(u uint64) {
  503. m.organization_id = &u
  504. m.addorganization_id = nil
  505. }
  506. // OrganizationID returns the value of the "organization_id" field in the mutation.
  507. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  508. v := m.organization_id
  509. if v == nil {
  510. return
  511. }
  512. return *v, true
  513. }
  514. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  515. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  516. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  517. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  518. if !m.op.Is(OpUpdateOne) {
  519. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  520. }
  521. if m.id == nil || m.oldValue == nil {
  522. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  523. }
  524. oldValue, err := m.oldValue(ctx)
  525. if err != nil {
  526. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  527. }
  528. return oldValue.OrganizationID, nil
  529. }
  530. // AddOrganizationID adds u to the "organization_id" field.
  531. func (m *AgentMutation) AddOrganizationID(u int64) {
  532. if m.addorganization_id != nil {
  533. *m.addorganization_id += u
  534. } else {
  535. m.addorganization_id = &u
  536. }
  537. }
  538. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  539. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  540. v := m.addorganization_id
  541. if v == nil {
  542. return
  543. }
  544. return *v, true
  545. }
  546. // ResetOrganizationID resets all changes to the "organization_id" field.
  547. func (m *AgentMutation) ResetOrganizationID() {
  548. m.organization_id = nil
  549. m.addorganization_id = nil
  550. }
  551. // SetDatasetID sets the "dataset_id" field.
  552. func (m *AgentMutation) SetDatasetID(s string) {
  553. m.dataset_id = &s
  554. }
  555. // DatasetID returns the value of the "dataset_id" field in the mutation.
  556. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  557. v := m.dataset_id
  558. if v == nil {
  559. return
  560. }
  561. return *v, true
  562. }
  563. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  564. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  566. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  567. if !m.op.Is(OpUpdateOne) {
  568. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  569. }
  570. if m.id == nil || m.oldValue == nil {
  571. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  572. }
  573. oldValue, err := m.oldValue(ctx)
  574. if err != nil {
  575. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  576. }
  577. return oldValue.DatasetID, nil
  578. }
  579. // ResetDatasetID resets all changes to the "dataset_id" field.
  580. func (m *AgentMutation) ResetDatasetID() {
  581. m.dataset_id = nil
  582. }
  583. // SetCollectionID sets the "collection_id" field.
  584. func (m *AgentMutation) SetCollectionID(s string) {
  585. m.collection_id = &s
  586. }
  587. // CollectionID returns the value of the "collection_id" field in the mutation.
  588. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  589. v := m.collection_id
  590. if v == nil {
  591. return
  592. }
  593. return *v, true
  594. }
  595. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  596. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  598. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  599. if !m.op.Is(OpUpdateOne) {
  600. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  601. }
  602. if m.id == nil || m.oldValue == nil {
  603. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  604. }
  605. oldValue, err := m.oldValue(ctx)
  606. if err != nil {
  607. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  608. }
  609. return oldValue.CollectionID, nil
  610. }
  611. // ResetCollectionID resets all changes to the "collection_id" field.
  612. func (m *AgentMutation) ResetCollectionID() {
  613. m.collection_id = nil
  614. }
  615. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  616. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  617. if m.wx_agent == nil {
  618. m.wx_agent = make(map[uint64]struct{})
  619. }
  620. for i := range ids {
  621. m.wx_agent[ids[i]] = struct{}{}
  622. }
  623. }
  624. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  625. func (m *AgentMutation) ClearWxAgent() {
  626. m.clearedwx_agent = true
  627. }
  628. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  629. func (m *AgentMutation) WxAgentCleared() bool {
  630. return m.clearedwx_agent
  631. }
  632. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  633. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  634. if m.removedwx_agent == nil {
  635. m.removedwx_agent = make(map[uint64]struct{})
  636. }
  637. for i := range ids {
  638. delete(m.wx_agent, ids[i])
  639. m.removedwx_agent[ids[i]] = struct{}{}
  640. }
  641. }
  642. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  643. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  644. for id := range m.removedwx_agent {
  645. ids = append(ids, id)
  646. }
  647. return
  648. }
  649. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  650. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  651. for id := range m.wx_agent {
  652. ids = append(ids, id)
  653. }
  654. return
  655. }
  656. // ResetWxAgent resets all changes to the "wx_agent" edge.
  657. func (m *AgentMutation) ResetWxAgent() {
  658. m.wx_agent = nil
  659. m.clearedwx_agent = false
  660. m.removedwx_agent = nil
  661. }
  662. // Where appends a list predicates to the AgentMutation builder.
  663. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  664. m.predicates = append(m.predicates, ps...)
  665. }
  666. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  667. // users can use type-assertion to append predicates that do not depend on any generated package.
  668. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  669. p := make([]predicate.Agent, len(ps))
  670. for i := range ps {
  671. p[i] = ps[i]
  672. }
  673. m.Where(p...)
  674. }
  675. // Op returns the operation name.
  676. func (m *AgentMutation) Op() Op {
  677. return m.op
  678. }
  679. // SetOp allows setting the mutation operation.
  680. func (m *AgentMutation) SetOp(op Op) {
  681. m.op = op
  682. }
  683. // Type returns the node type of this mutation (Agent).
  684. func (m *AgentMutation) Type() string {
  685. return m.typ
  686. }
  687. // Fields returns all fields that were changed during this mutation. Note that in
  688. // order to get all numeric fields that were incremented/decremented, call
  689. // AddedFields().
  690. func (m *AgentMutation) Fields() []string {
  691. fields := make([]string, 0, 11)
  692. if m.created_at != nil {
  693. fields = append(fields, agent.FieldCreatedAt)
  694. }
  695. if m.updated_at != nil {
  696. fields = append(fields, agent.FieldUpdatedAt)
  697. }
  698. if m.deleted_at != nil {
  699. fields = append(fields, agent.FieldDeletedAt)
  700. }
  701. if m.name != nil {
  702. fields = append(fields, agent.FieldName)
  703. }
  704. if m.role != nil {
  705. fields = append(fields, agent.FieldRole)
  706. }
  707. if m.status != nil {
  708. fields = append(fields, agent.FieldStatus)
  709. }
  710. if m.background != nil {
  711. fields = append(fields, agent.FieldBackground)
  712. }
  713. if m.examples != nil {
  714. fields = append(fields, agent.FieldExamples)
  715. }
  716. if m.organization_id != nil {
  717. fields = append(fields, agent.FieldOrganizationID)
  718. }
  719. if m.dataset_id != nil {
  720. fields = append(fields, agent.FieldDatasetID)
  721. }
  722. if m.collection_id != nil {
  723. fields = append(fields, agent.FieldCollectionID)
  724. }
  725. return fields
  726. }
  727. // Field returns the value of a field with the given name. The second boolean
  728. // return value indicates that this field was not set, or was not defined in the
  729. // schema.
  730. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  731. switch name {
  732. case agent.FieldCreatedAt:
  733. return m.CreatedAt()
  734. case agent.FieldUpdatedAt:
  735. return m.UpdatedAt()
  736. case agent.FieldDeletedAt:
  737. return m.DeletedAt()
  738. case agent.FieldName:
  739. return m.Name()
  740. case agent.FieldRole:
  741. return m.Role()
  742. case agent.FieldStatus:
  743. return m.Status()
  744. case agent.FieldBackground:
  745. return m.Background()
  746. case agent.FieldExamples:
  747. return m.Examples()
  748. case agent.FieldOrganizationID:
  749. return m.OrganizationID()
  750. case agent.FieldDatasetID:
  751. return m.DatasetID()
  752. case agent.FieldCollectionID:
  753. return m.CollectionID()
  754. }
  755. return nil, false
  756. }
  757. // OldField returns the old value of the field from the database. An error is
  758. // returned if the mutation operation is not UpdateOne, or the query to the
  759. // database failed.
  760. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  761. switch name {
  762. case agent.FieldCreatedAt:
  763. return m.OldCreatedAt(ctx)
  764. case agent.FieldUpdatedAt:
  765. return m.OldUpdatedAt(ctx)
  766. case agent.FieldDeletedAt:
  767. return m.OldDeletedAt(ctx)
  768. case agent.FieldName:
  769. return m.OldName(ctx)
  770. case agent.FieldRole:
  771. return m.OldRole(ctx)
  772. case agent.FieldStatus:
  773. return m.OldStatus(ctx)
  774. case agent.FieldBackground:
  775. return m.OldBackground(ctx)
  776. case agent.FieldExamples:
  777. return m.OldExamples(ctx)
  778. case agent.FieldOrganizationID:
  779. return m.OldOrganizationID(ctx)
  780. case agent.FieldDatasetID:
  781. return m.OldDatasetID(ctx)
  782. case agent.FieldCollectionID:
  783. return m.OldCollectionID(ctx)
  784. }
  785. return nil, fmt.Errorf("unknown Agent field %s", name)
  786. }
  787. // SetField sets the value of a field with the given name. It returns an error if
  788. // the field is not defined in the schema, or if the type mismatched the field
  789. // type.
  790. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  791. switch name {
  792. case agent.FieldCreatedAt:
  793. v, ok := value.(time.Time)
  794. if !ok {
  795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  796. }
  797. m.SetCreatedAt(v)
  798. return nil
  799. case agent.FieldUpdatedAt:
  800. v, ok := value.(time.Time)
  801. if !ok {
  802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  803. }
  804. m.SetUpdatedAt(v)
  805. return nil
  806. case agent.FieldDeletedAt:
  807. v, ok := value.(time.Time)
  808. if !ok {
  809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  810. }
  811. m.SetDeletedAt(v)
  812. return nil
  813. case agent.FieldName:
  814. v, ok := value.(string)
  815. if !ok {
  816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  817. }
  818. m.SetName(v)
  819. return nil
  820. case agent.FieldRole:
  821. v, ok := value.(string)
  822. if !ok {
  823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  824. }
  825. m.SetRole(v)
  826. return nil
  827. case agent.FieldStatus:
  828. v, ok := value.(int)
  829. if !ok {
  830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  831. }
  832. m.SetStatus(v)
  833. return nil
  834. case agent.FieldBackground:
  835. v, ok := value.(string)
  836. if !ok {
  837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  838. }
  839. m.SetBackground(v)
  840. return nil
  841. case agent.FieldExamples:
  842. v, ok := value.(string)
  843. if !ok {
  844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  845. }
  846. m.SetExamples(v)
  847. return nil
  848. case agent.FieldOrganizationID:
  849. v, ok := value.(uint64)
  850. if !ok {
  851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  852. }
  853. m.SetOrganizationID(v)
  854. return nil
  855. case agent.FieldDatasetID:
  856. v, ok := value.(string)
  857. if !ok {
  858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  859. }
  860. m.SetDatasetID(v)
  861. return nil
  862. case agent.FieldCollectionID:
  863. v, ok := value.(string)
  864. if !ok {
  865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  866. }
  867. m.SetCollectionID(v)
  868. return nil
  869. }
  870. return fmt.Errorf("unknown Agent field %s", name)
  871. }
  872. // AddedFields returns all numeric fields that were incremented/decremented during
  873. // this mutation.
  874. func (m *AgentMutation) AddedFields() []string {
  875. var fields []string
  876. if m.addstatus != nil {
  877. fields = append(fields, agent.FieldStatus)
  878. }
  879. if m.addorganization_id != nil {
  880. fields = append(fields, agent.FieldOrganizationID)
  881. }
  882. return fields
  883. }
  884. // AddedField returns the numeric value that was incremented/decremented on a field
  885. // with the given name. The second boolean return value indicates that this field
  886. // was not set, or was not defined in the schema.
  887. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  888. switch name {
  889. case agent.FieldStatus:
  890. return m.AddedStatus()
  891. case agent.FieldOrganizationID:
  892. return m.AddedOrganizationID()
  893. }
  894. return nil, false
  895. }
  896. // AddField adds the value to the field with the given name. It returns an error if
  897. // the field is not defined in the schema, or if the type mismatched the field
  898. // type.
  899. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  900. switch name {
  901. case agent.FieldStatus:
  902. v, ok := value.(int)
  903. if !ok {
  904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  905. }
  906. m.AddStatus(v)
  907. return nil
  908. case agent.FieldOrganizationID:
  909. v, ok := value.(int64)
  910. if !ok {
  911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  912. }
  913. m.AddOrganizationID(v)
  914. return nil
  915. }
  916. return fmt.Errorf("unknown Agent numeric field %s", name)
  917. }
  918. // ClearedFields returns all nullable fields that were cleared during this
  919. // mutation.
  920. func (m *AgentMutation) ClearedFields() []string {
  921. var fields []string
  922. if m.FieldCleared(agent.FieldDeletedAt) {
  923. fields = append(fields, agent.FieldDeletedAt)
  924. }
  925. if m.FieldCleared(agent.FieldStatus) {
  926. fields = append(fields, agent.FieldStatus)
  927. }
  928. if m.FieldCleared(agent.FieldBackground) {
  929. fields = append(fields, agent.FieldBackground)
  930. }
  931. if m.FieldCleared(agent.FieldExamples) {
  932. fields = append(fields, agent.FieldExamples)
  933. }
  934. return fields
  935. }
  936. // FieldCleared returns a boolean indicating if a field with the given name was
  937. // cleared in this mutation.
  938. func (m *AgentMutation) FieldCleared(name string) bool {
  939. _, ok := m.clearedFields[name]
  940. return ok
  941. }
  942. // ClearField clears the value of the field with the given name. It returns an
  943. // error if the field is not defined in the schema.
  944. func (m *AgentMutation) ClearField(name string) error {
  945. switch name {
  946. case agent.FieldDeletedAt:
  947. m.ClearDeletedAt()
  948. return nil
  949. case agent.FieldStatus:
  950. m.ClearStatus()
  951. return nil
  952. case agent.FieldBackground:
  953. m.ClearBackground()
  954. return nil
  955. case agent.FieldExamples:
  956. m.ClearExamples()
  957. return nil
  958. }
  959. return fmt.Errorf("unknown Agent nullable field %s", name)
  960. }
  961. // ResetField resets all changes in the mutation for the field with the given name.
  962. // It returns an error if the field is not defined in the schema.
  963. func (m *AgentMutation) ResetField(name string) error {
  964. switch name {
  965. case agent.FieldCreatedAt:
  966. m.ResetCreatedAt()
  967. return nil
  968. case agent.FieldUpdatedAt:
  969. m.ResetUpdatedAt()
  970. return nil
  971. case agent.FieldDeletedAt:
  972. m.ResetDeletedAt()
  973. return nil
  974. case agent.FieldName:
  975. m.ResetName()
  976. return nil
  977. case agent.FieldRole:
  978. m.ResetRole()
  979. return nil
  980. case agent.FieldStatus:
  981. m.ResetStatus()
  982. return nil
  983. case agent.FieldBackground:
  984. m.ResetBackground()
  985. return nil
  986. case agent.FieldExamples:
  987. m.ResetExamples()
  988. return nil
  989. case agent.FieldOrganizationID:
  990. m.ResetOrganizationID()
  991. return nil
  992. case agent.FieldDatasetID:
  993. m.ResetDatasetID()
  994. return nil
  995. case agent.FieldCollectionID:
  996. m.ResetCollectionID()
  997. return nil
  998. }
  999. return fmt.Errorf("unknown Agent field %s", name)
  1000. }
  1001. // AddedEdges returns all edge names that were set/added in this mutation.
  1002. func (m *AgentMutation) AddedEdges() []string {
  1003. edges := make([]string, 0, 1)
  1004. if m.wx_agent != nil {
  1005. edges = append(edges, agent.EdgeWxAgent)
  1006. }
  1007. return edges
  1008. }
  1009. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1010. // name in this mutation.
  1011. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1012. switch name {
  1013. case agent.EdgeWxAgent:
  1014. ids := make([]ent.Value, 0, len(m.wx_agent))
  1015. for id := range m.wx_agent {
  1016. ids = append(ids, id)
  1017. }
  1018. return ids
  1019. }
  1020. return nil
  1021. }
  1022. // RemovedEdges returns all edge names that were removed in this mutation.
  1023. func (m *AgentMutation) RemovedEdges() []string {
  1024. edges := make([]string, 0, 1)
  1025. if m.removedwx_agent != nil {
  1026. edges = append(edges, agent.EdgeWxAgent)
  1027. }
  1028. return edges
  1029. }
  1030. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1031. // the given name in this mutation.
  1032. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1033. switch name {
  1034. case agent.EdgeWxAgent:
  1035. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1036. for id := range m.removedwx_agent {
  1037. ids = append(ids, id)
  1038. }
  1039. return ids
  1040. }
  1041. return nil
  1042. }
  1043. // ClearedEdges returns all edge names that were cleared in this mutation.
  1044. func (m *AgentMutation) ClearedEdges() []string {
  1045. edges := make([]string, 0, 1)
  1046. if m.clearedwx_agent {
  1047. edges = append(edges, agent.EdgeWxAgent)
  1048. }
  1049. return edges
  1050. }
  1051. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1052. // was cleared in this mutation.
  1053. func (m *AgentMutation) EdgeCleared(name string) bool {
  1054. switch name {
  1055. case agent.EdgeWxAgent:
  1056. return m.clearedwx_agent
  1057. }
  1058. return false
  1059. }
  1060. // ClearEdge clears the value of the edge with the given name. It returns an error
  1061. // if that edge is not defined in the schema.
  1062. func (m *AgentMutation) ClearEdge(name string) error {
  1063. switch name {
  1064. }
  1065. return fmt.Errorf("unknown Agent unique edge %s", name)
  1066. }
  1067. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1068. // It returns an error if the edge is not defined in the schema.
  1069. func (m *AgentMutation) ResetEdge(name string) error {
  1070. switch name {
  1071. case agent.EdgeWxAgent:
  1072. m.ResetWxAgent()
  1073. return nil
  1074. }
  1075. return fmt.Errorf("unknown Agent edge %s", name)
  1076. }
  1077. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  1078. type BatchMsgMutation struct {
  1079. config
  1080. op Op
  1081. typ string
  1082. id *uint64
  1083. created_at *time.Time
  1084. updated_at *time.Time
  1085. deleted_at *time.Time
  1086. status *uint8
  1087. addstatus *int8
  1088. batch_no *string
  1089. task_name *string
  1090. fromwxid *string
  1091. msg *string
  1092. tag *string
  1093. tagids *string
  1094. total *int32
  1095. addtotal *int32
  1096. success *int32
  1097. addsuccess *int32
  1098. fail *int32
  1099. addfail *int32
  1100. start_time *time.Time
  1101. stop_time *time.Time
  1102. send_time *time.Time
  1103. _type *int32
  1104. add_type *int32
  1105. organization_id *uint64
  1106. addorganization_id *int64
  1107. clearedFields map[string]struct{}
  1108. done bool
  1109. oldValue func(context.Context) (*BatchMsg, error)
  1110. predicates []predicate.BatchMsg
  1111. }
  1112. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  1113. // batchmsgOption allows management of the mutation configuration using functional options.
  1114. type batchmsgOption func(*BatchMsgMutation)
  1115. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  1116. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  1117. m := &BatchMsgMutation{
  1118. config: c,
  1119. op: op,
  1120. typ: TypeBatchMsg,
  1121. clearedFields: make(map[string]struct{}),
  1122. }
  1123. for _, opt := range opts {
  1124. opt(m)
  1125. }
  1126. return m
  1127. }
  1128. // withBatchMsgID sets the ID field of the mutation.
  1129. func withBatchMsgID(id uint64) batchmsgOption {
  1130. return func(m *BatchMsgMutation) {
  1131. var (
  1132. err error
  1133. once sync.Once
  1134. value *BatchMsg
  1135. )
  1136. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  1137. once.Do(func() {
  1138. if m.done {
  1139. err = errors.New("querying old values post mutation is not allowed")
  1140. } else {
  1141. value, err = m.Client().BatchMsg.Get(ctx, id)
  1142. }
  1143. })
  1144. return value, err
  1145. }
  1146. m.id = &id
  1147. }
  1148. }
  1149. // withBatchMsg sets the old BatchMsg of the mutation.
  1150. func withBatchMsg(node *BatchMsg) batchmsgOption {
  1151. return func(m *BatchMsgMutation) {
  1152. m.oldValue = func(context.Context) (*BatchMsg, error) {
  1153. return node, nil
  1154. }
  1155. m.id = &node.ID
  1156. }
  1157. }
  1158. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1159. // executed in a transaction (ent.Tx), a transactional client is returned.
  1160. func (m BatchMsgMutation) Client() *Client {
  1161. client := &Client{config: m.config}
  1162. client.init()
  1163. return client
  1164. }
  1165. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1166. // it returns an error otherwise.
  1167. func (m BatchMsgMutation) Tx() (*Tx, error) {
  1168. if _, ok := m.driver.(*txDriver); !ok {
  1169. return nil, errors.New("ent: mutation is not running in a transaction")
  1170. }
  1171. tx := &Tx{config: m.config}
  1172. tx.init()
  1173. return tx, nil
  1174. }
  1175. // SetID sets the value of the id field. Note that this
  1176. // operation is only accepted on creation of BatchMsg entities.
  1177. func (m *BatchMsgMutation) SetID(id uint64) {
  1178. m.id = &id
  1179. }
  1180. // ID returns the ID value in the mutation. Note that the ID is only available
  1181. // if it was provided to the builder or after it was returned from the database.
  1182. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  1183. if m.id == nil {
  1184. return
  1185. }
  1186. return *m.id, true
  1187. }
  1188. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1189. // That means, if the mutation is applied within a transaction with an isolation level such
  1190. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1191. // or updated by the mutation.
  1192. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  1193. switch {
  1194. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1195. id, exists := m.ID()
  1196. if exists {
  1197. return []uint64{id}, nil
  1198. }
  1199. fallthrough
  1200. case m.op.Is(OpUpdate | OpDelete):
  1201. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  1202. default:
  1203. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1204. }
  1205. }
  1206. // SetCreatedAt sets the "created_at" field.
  1207. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  1208. m.created_at = &t
  1209. }
  1210. // CreatedAt returns the value of the "created_at" field in the mutation.
  1211. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  1212. v := m.created_at
  1213. if v == nil {
  1214. return
  1215. }
  1216. return *v, true
  1217. }
  1218. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  1219. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1221. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  1222. if !m.op.Is(OpUpdateOne) {
  1223. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  1224. }
  1225. if m.id == nil || m.oldValue == nil {
  1226. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  1227. }
  1228. oldValue, err := m.oldValue(ctx)
  1229. if err != nil {
  1230. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  1231. }
  1232. return oldValue.CreatedAt, nil
  1233. }
  1234. // ResetCreatedAt resets all changes to the "created_at" field.
  1235. func (m *BatchMsgMutation) ResetCreatedAt() {
  1236. m.created_at = nil
  1237. }
  1238. // SetUpdatedAt sets the "updated_at" field.
  1239. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  1240. m.updated_at = &t
  1241. }
  1242. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  1243. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  1244. v := m.updated_at
  1245. if v == nil {
  1246. return
  1247. }
  1248. return *v, true
  1249. }
  1250. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  1251. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1253. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  1254. if !m.op.Is(OpUpdateOne) {
  1255. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  1256. }
  1257. if m.id == nil || m.oldValue == nil {
  1258. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  1259. }
  1260. oldValue, err := m.oldValue(ctx)
  1261. if err != nil {
  1262. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  1263. }
  1264. return oldValue.UpdatedAt, nil
  1265. }
  1266. // ResetUpdatedAt resets all changes to the "updated_at" field.
  1267. func (m *BatchMsgMutation) ResetUpdatedAt() {
  1268. m.updated_at = nil
  1269. }
  1270. // SetDeletedAt sets the "deleted_at" field.
  1271. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  1272. m.deleted_at = &t
  1273. }
  1274. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  1275. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  1276. v := m.deleted_at
  1277. if v == nil {
  1278. return
  1279. }
  1280. return *v, true
  1281. }
  1282. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  1283. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1284. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1285. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  1286. if !m.op.Is(OpUpdateOne) {
  1287. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  1288. }
  1289. if m.id == nil || m.oldValue == nil {
  1290. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  1291. }
  1292. oldValue, err := m.oldValue(ctx)
  1293. if err != nil {
  1294. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  1295. }
  1296. return oldValue.DeletedAt, nil
  1297. }
  1298. // ClearDeletedAt clears the value of the "deleted_at" field.
  1299. func (m *BatchMsgMutation) ClearDeletedAt() {
  1300. m.deleted_at = nil
  1301. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  1302. }
  1303. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  1304. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  1305. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  1306. return ok
  1307. }
  1308. // ResetDeletedAt resets all changes to the "deleted_at" field.
  1309. func (m *BatchMsgMutation) ResetDeletedAt() {
  1310. m.deleted_at = nil
  1311. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  1312. }
  1313. // SetStatus sets the "status" field.
  1314. func (m *BatchMsgMutation) SetStatus(u uint8) {
  1315. m.status = &u
  1316. m.addstatus = nil
  1317. }
  1318. // Status returns the value of the "status" field in the mutation.
  1319. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  1320. v := m.status
  1321. if v == nil {
  1322. return
  1323. }
  1324. return *v, true
  1325. }
  1326. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  1327. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1329. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  1330. if !m.op.Is(OpUpdateOne) {
  1331. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  1332. }
  1333. if m.id == nil || m.oldValue == nil {
  1334. return v, errors.New("OldStatus requires an ID field in the mutation")
  1335. }
  1336. oldValue, err := m.oldValue(ctx)
  1337. if err != nil {
  1338. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  1339. }
  1340. return oldValue.Status, nil
  1341. }
  1342. // AddStatus adds u to the "status" field.
  1343. func (m *BatchMsgMutation) AddStatus(u int8) {
  1344. if m.addstatus != nil {
  1345. *m.addstatus += u
  1346. } else {
  1347. m.addstatus = &u
  1348. }
  1349. }
  1350. // AddedStatus returns the value that was added to the "status" field in this mutation.
  1351. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  1352. v := m.addstatus
  1353. if v == nil {
  1354. return
  1355. }
  1356. return *v, true
  1357. }
  1358. // ClearStatus clears the value of the "status" field.
  1359. func (m *BatchMsgMutation) ClearStatus() {
  1360. m.status = nil
  1361. m.addstatus = nil
  1362. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  1363. }
  1364. // StatusCleared returns if the "status" field was cleared in this mutation.
  1365. func (m *BatchMsgMutation) StatusCleared() bool {
  1366. _, ok := m.clearedFields[batchmsg.FieldStatus]
  1367. return ok
  1368. }
  1369. // ResetStatus resets all changes to the "status" field.
  1370. func (m *BatchMsgMutation) ResetStatus() {
  1371. m.status = nil
  1372. m.addstatus = nil
  1373. delete(m.clearedFields, batchmsg.FieldStatus)
  1374. }
  1375. // SetBatchNo sets the "batch_no" field.
  1376. func (m *BatchMsgMutation) SetBatchNo(s string) {
  1377. m.batch_no = &s
  1378. }
  1379. // BatchNo returns the value of the "batch_no" field in the mutation.
  1380. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  1381. v := m.batch_no
  1382. if v == nil {
  1383. return
  1384. }
  1385. return *v, true
  1386. }
  1387. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  1388. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1390. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  1391. if !m.op.Is(OpUpdateOne) {
  1392. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  1393. }
  1394. if m.id == nil || m.oldValue == nil {
  1395. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  1396. }
  1397. oldValue, err := m.oldValue(ctx)
  1398. if err != nil {
  1399. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  1400. }
  1401. return oldValue.BatchNo, nil
  1402. }
  1403. // ClearBatchNo clears the value of the "batch_no" field.
  1404. func (m *BatchMsgMutation) ClearBatchNo() {
  1405. m.batch_no = nil
  1406. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  1407. }
  1408. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  1409. func (m *BatchMsgMutation) BatchNoCleared() bool {
  1410. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  1411. return ok
  1412. }
  1413. // ResetBatchNo resets all changes to the "batch_no" field.
  1414. func (m *BatchMsgMutation) ResetBatchNo() {
  1415. m.batch_no = nil
  1416. delete(m.clearedFields, batchmsg.FieldBatchNo)
  1417. }
  1418. // SetTaskName sets the "task_name" field.
  1419. func (m *BatchMsgMutation) SetTaskName(s string) {
  1420. m.task_name = &s
  1421. }
  1422. // TaskName returns the value of the "task_name" field in the mutation.
  1423. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  1424. v := m.task_name
  1425. if v == nil {
  1426. return
  1427. }
  1428. return *v, true
  1429. }
  1430. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  1431. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1433. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  1434. if !m.op.Is(OpUpdateOne) {
  1435. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  1436. }
  1437. if m.id == nil || m.oldValue == nil {
  1438. return v, errors.New("OldTaskName requires an ID field in the mutation")
  1439. }
  1440. oldValue, err := m.oldValue(ctx)
  1441. if err != nil {
  1442. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  1443. }
  1444. return oldValue.TaskName, nil
  1445. }
  1446. // ClearTaskName clears the value of the "task_name" field.
  1447. func (m *BatchMsgMutation) ClearTaskName() {
  1448. m.task_name = nil
  1449. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  1450. }
  1451. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  1452. func (m *BatchMsgMutation) TaskNameCleared() bool {
  1453. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  1454. return ok
  1455. }
  1456. // ResetTaskName resets all changes to the "task_name" field.
  1457. func (m *BatchMsgMutation) ResetTaskName() {
  1458. m.task_name = nil
  1459. delete(m.clearedFields, batchmsg.FieldTaskName)
  1460. }
  1461. // SetFromwxid sets the "fromwxid" field.
  1462. func (m *BatchMsgMutation) SetFromwxid(s string) {
  1463. m.fromwxid = &s
  1464. }
  1465. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  1466. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  1467. v := m.fromwxid
  1468. if v == nil {
  1469. return
  1470. }
  1471. return *v, true
  1472. }
  1473. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  1474. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1476. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  1477. if !m.op.Is(OpUpdateOne) {
  1478. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  1479. }
  1480. if m.id == nil || m.oldValue == nil {
  1481. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  1482. }
  1483. oldValue, err := m.oldValue(ctx)
  1484. if err != nil {
  1485. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  1486. }
  1487. return oldValue.Fromwxid, nil
  1488. }
  1489. // ClearFromwxid clears the value of the "fromwxid" field.
  1490. func (m *BatchMsgMutation) ClearFromwxid() {
  1491. m.fromwxid = nil
  1492. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  1493. }
  1494. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  1495. func (m *BatchMsgMutation) FromwxidCleared() bool {
  1496. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  1497. return ok
  1498. }
  1499. // ResetFromwxid resets all changes to the "fromwxid" field.
  1500. func (m *BatchMsgMutation) ResetFromwxid() {
  1501. m.fromwxid = nil
  1502. delete(m.clearedFields, batchmsg.FieldFromwxid)
  1503. }
  1504. // SetMsg sets the "msg" field.
  1505. func (m *BatchMsgMutation) SetMsg(s string) {
  1506. m.msg = &s
  1507. }
  1508. // Msg returns the value of the "msg" field in the mutation.
  1509. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  1510. v := m.msg
  1511. if v == nil {
  1512. return
  1513. }
  1514. return *v, true
  1515. }
  1516. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  1517. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1519. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  1520. if !m.op.Is(OpUpdateOne) {
  1521. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  1522. }
  1523. if m.id == nil || m.oldValue == nil {
  1524. return v, errors.New("OldMsg requires an ID field in the mutation")
  1525. }
  1526. oldValue, err := m.oldValue(ctx)
  1527. if err != nil {
  1528. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  1529. }
  1530. return oldValue.Msg, nil
  1531. }
  1532. // ClearMsg clears the value of the "msg" field.
  1533. func (m *BatchMsgMutation) ClearMsg() {
  1534. m.msg = nil
  1535. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  1536. }
  1537. // MsgCleared returns if the "msg" field was cleared in this mutation.
  1538. func (m *BatchMsgMutation) MsgCleared() bool {
  1539. _, ok := m.clearedFields[batchmsg.FieldMsg]
  1540. return ok
  1541. }
  1542. // ResetMsg resets all changes to the "msg" field.
  1543. func (m *BatchMsgMutation) ResetMsg() {
  1544. m.msg = nil
  1545. delete(m.clearedFields, batchmsg.FieldMsg)
  1546. }
  1547. // SetTag sets the "tag" field.
  1548. func (m *BatchMsgMutation) SetTag(s string) {
  1549. m.tag = &s
  1550. }
  1551. // Tag returns the value of the "tag" field in the mutation.
  1552. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  1553. v := m.tag
  1554. if v == nil {
  1555. return
  1556. }
  1557. return *v, true
  1558. }
  1559. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  1560. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1562. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  1563. if !m.op.Is(OpUpdateOne) {
  1564. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  1565. }
  1566. if m.id == nil || m.oldValue == nil {
  1567. return v, errors.New("OldTag requires an ID field in the mutation")
  1568. }
  1569. oldValue, err := m.oldValue(ctx)
  1570. if err != nil {
  1571. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  1572. }
  1573. return oldValue.Tag, nil
  1574. }
  1575. // ClearTag clears the value of the "tag" field.
  1576. func (m *BatchMsgMutation) ClearTag() {
  1577. m.tag = nil
  1578. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  1579. }
  1580. // TagCleared returns if the "tag" field was cleared in this mutation.
  1581. func (m *BatchMsgMutation) TagCleared() bool {
  1582. _, ok := m.clearedFields[batchmsg.FieldTag]
  1583. return ok
  1584. }
  1585. // ResetTag resets all changes to the "tag" field.
  1586. func (m *BatchMsgMutation) ResetTag() {
  1587. m.tag = nil
  1588. delete(m.clearedFields, batchmsg.FieldTag)
  1589. }
  1590. // SetTagids sets the "tagids" field.
  1591. func (m *BatchMsgMutation) SetTagids(s string) {
  1592. m.tagids = &s
  1593. }
  1594. // Tagids returns the value of the "tagids" field in the mutation.
  1595. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  1596. v := m.tagids
  1597. if v == nil {
  1598. return
  1599. }
  1600. return *v, true
  1601. }
  1602. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  1603. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1605. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  1606. if !m.op.Is(OpUpdateOne) {
  1607. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  1608. }
  1609. if m.id == nil || m.oldValue == nil {
  1610. return v, errors.New("OldTagids requires an ID field in the mutation")
  1611. }
  1612. oldValue, err := m.oldValue(ctx)
  1613. if err != nil {
  1614. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  1615. }
  1616. return oldValue.Tagids, nil
  1617. }
  1618. // ClearTagids clears the value of the "tagids" field.
  1619. func (m *BatchMsgMutation) ClearTagids() {
  1620. m.tagids = nil
  1621. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  1622. }
  1623. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  1624. func (m *BatchMsgMutation) TagidsCleared() bool {
  1625. _, ok := m.clearedFields[batchmsg.FieldTagids]
  1626. return ok
  1627. }
  1628. // ResetTagids resets all changes to the "tagids" field.
  1629. func (m *BatchMsgMutation) ResetTagids() {
  1630. m.tagids = nil
  1631. delete(m.clearedFields, batchmsg.FieldTagids)
  1632. }
  1633. // SetTotal sets the "total" field.
  1634. func (m *BatchMsgMutation) SetTotal(i int32) {
  1635. m.total = &i
  1636. m.addtotal = nil
  1637. }
  1638. // Total returns the value of the "total" field in the mutation.
  1639. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  1640. v := m.total
  1641. if v == nil {
  1642. return
  1643. }
  1644. return *v, true
  1645. }
  1646. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  1647. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1649. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  1650. if !m.op.Is(OpUpdateOne) {
  1651. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  1652. }
  1653. if m.id == nil || m.oldValue == nil {
  1654. return v, errors.New("OldTotal requires an ID field in the mutation")
  1655. }
  1656. oldValue, err := m.oldValue(ctx)
  1657. if err != nil {
  1658. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  1659. }
  1660. return oldValue.Total, nil
  1661. }
  1662. // AddTotal adds i to the "total" field.
  1663. func (m *BatchMsgMutation) AddTotal(i int32) {
  1664. if m.addtotal != nil {
  1665. *m.addtotal += i
  1666. } else {
  1667. m.addtotal = &i
  1668. }
  1669. }
  1670. // AddedTotal returns the value that was added to the "total" field in this mutation.
  1671. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  1672. v := m.addtotal
  1673. if v == nil {
  1674. return
  1675. }
  1676. return *v, true
  1677. }
  1678. // ClearTotal clears the value of the "total" field.
  1679. func (m *BatchMsgMutation) ClearTotal() {
  1680. m.total = nil
  1681. m.addtotal = nil
  1682. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  1683. }
  1684. // TotalCleared returns if the "total" field was cleared in this mutation.
  1685. func (m *BatchMsgMutation) TotalCleared() bool {
  1686. _, ok := m.clearedFields[batchmsg.FieldTotal]
  1687. return ok
  1688. }
  1689. // ResetTotal resets all changes to the "total" field.
  1690. func (m *BatchMsgMutation) ResetTotal() {
  1691. m.total = nil
  1692. m.addtotal = nil
  1693. delete(m.clearedFields, batchmsg.FieldTotal)
  1694. }
  1695. // SetSuccess sets the "success" field.
  1696. func (m *BatchMsgMutation) SetSuccess(i int32) {
  1697. m.success = &i
  1698. m.addsuccess = nil
  1699. }
  1700. // Success returns the value of the "success" field in the mutation.
  1701. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  1702. v := m.success
  1703. if v == nil {
  1704. return
  1705. }
  1706. return *v, true
  1707. }
  1708. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  1709. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1711. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  1712. if !m.op.Is(OpUpdateOne) {
  1713. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  1714. }
  1715. if m.id == nil || m.oldValue == nil {
  1716. return v, errors.New("OldSuccess requires an ID field in the mutation")
  1717. }
  1718. oldValue, err := m.oldValue(ctx)
  1719. if err != nil {
  1720. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  1721. }
  1722. return oldValue.Success, nil
  1723. }
  1724. // AddSuccess adds i to the "success" field.
  1725. func (m *BatchMsgMutation) AddSuccess(i int32) {
  1726. if m.addsuccess != nil {
  1727. *m.addsuccess += i
  1728. } else {
  1729. m.addsuccess = &i
  1730. }
  1731. }
  1732. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  1733. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  1734. v := m.addsuccess
  1735. if v == nil {
  1736. return
  1737. }
  1738. return *v, true
  1739. }
  1740. // ClearSuccess clears the value of the "success" field.
  1741. func (m *BatchMsgMutation) ClearSuccess() {
  1742. m.success = nil
  1743. m.addsuccess = nil
  1744. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  1745. }
  1746. // SuccessCleared returns if the "success" field was cleared in this mutation.
  1747. func (m *BatchMsgMutation) SuccessCleared() bool {
  1748. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  1749. return ok
  1750. }
  1751. // ResetSuccess resets all changes to the "success" field.
  1752. func (m *BatchMsgMutation) ResetSuccess() {
  1753. m.success = nil
  1754. m.addsuccess = nil
  1755. delete(m.clearedFields, batchmsg.FieldSuccess)
  1756. }
  1757. // SetFail sets the "fail" field.
  1758. func (m *BatchMsgMutation) SetFail(i int32) {
  1759. m.fail = &i
  1760. m.addfail = nil
  1761. }
  1762. // Fail returns the value of the "fail" field in the mutation.
  1763. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  1764. v := m.fail
  1765. if v == nil {
  1766. return
  1767. }
  1768. return *v, true
  1769. }
  1770. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  1771. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1773. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  1774. if !m.op.Is(OpUpdateOne) {
  1775. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  1776. }
  1777. if m.id == nil || m.oldValue == nil {
  1778. return v, errors.New("OldFail requires an ID field in the mutation")
  1779. }
  1780. oldValue, err := m.oldValue(ctx)
  1781. if err != nil {
  1782. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  1783. }
  1784. return oldValue.Fail, nil
  1785. }
  1786. // AddFail adds i to the "fail" field.
  1787. func (m *BatchMsgMutation) AddFail(i int32) {
  1788. if m.addfail != nil {
  1789. *m.addfail += i
  1790. } else {
  1791. m.addfail = &i
  1792. }
  1793. }
  1794. // AddedFail returns the value that was added to the "fail" field in this mutation.
  1795. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  1796. v := m.addfail
  1797. if v == nil {
  1798. return
  1799. }
  1800. return *v, true
  1801. }
  1802. // ClearFail clears the value of the "fail" field.
  1803. func (m *BatchMsgMutation) ClearFail() {
  1804. m.fail = nil
  1805. m.addfail = nil
  1806. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  1807. }
  1808. // FailCleared returns if the "fail" field was cleared in this mutation.
  1809. func (m *BatchMsgMutation) FailCleared() bool {
  1810. _, ok := m.clearedFields[batchmsg.FieldFail]
  1811. return ok
  1812. }
  1813. // ResetFail resets all changes to the "fail" field.
  1814. func (m *BatchMsgMutation) ResetFail() {
  1815. m.fail = nil
  1816. m.addfail = nil
  1817. delete(m.clearedFields, batchmsg.FieldFail)
  1818. }
  1819. // SetStartTime sets the "start_time" field.
  1820. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  1821. m.start_time = &t
  1822. }
  1823. // StartTime returns the value of the "start_time" field in the mutation.
  1824. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  1825. v := m.start_time
  1826. if v == nil {
  1827. return
  1828. }
  1829. return *v, true
  1830. }
  1831. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  1832. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1834. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  1835. if !m.op.Is(OpUpdateOne) {
  1836. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  1837. }
  1838. if m.id == nil || m.oldValue == nil {
  1839. return v, errors.New("OldStartTime requires an ID field in the mutation")
  1840. }
  1841. oldValue, err := m.oldValue(ctx)
  1842. if err != nil {
  1843. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  1844. }
  1845. return oldValue.StartTime, nil
  1846. }
  1847. // ClearStartTime clears the value of the "start_time" field.
  1848. func (m *BatchMsgMutation) ClearStartTime() {
  1849. m.start_time = nil
  1850. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  1851. }
  1852. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  1853. func (m *BatchMsgMutation) StartTimeCleared() bool {
  1854. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  1855. return ok
  1856. }
  1857. // ResetStartTime resets all changes to the "start_time" field.
  1858. func (m *BatchMsgMutation) ResetStartTime() {
  1859. m.start_time = nil
  1860. delete(m.clearedFields, batchmsg.FieldStartTime)
  1861. }
  1862. // SetStopTime sets the "stop_time" field.
  1863. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  1864. m.stop_time = &t
  1865. }
  1866. // StopTime returns the value of the "stop_time" field in the mutation.
  1867. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  1868. v := m.stop_time
  1869. if v == nil {
  1870. return
  1871. }
  1872. return *v, true
  1873. }
  1874. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  1875. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1877. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  1878. if !m.op.Is(OpUpdateOne) {
  1879. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  1880. }
  1881. if m.id == nil || m.oldValue == nil {
  1882. return v, errors.New("OldStopTime requires an ID field in the mutation")
  1883. }
  1884. oldValue, err := m.oldValue(ctx)
  1885. if err != nil {
  1886. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  1887. }
  1888. return oldValue.StopTime, nil
  1889. }
  1890. // ClearStopTime clears the value of the "stop_time" field.
  1891. func (m *BatchMsgMutation) ClearStopTime() {
  1892. m.stop_time = nil
  1893. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  1894. }
  1895. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  1896. func (m *BatchMsgMutation) StopTimeCleared() bool {
  1897. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  1898. return ok
  1899. }
  1900. // ResetStopTime resets all changes to the "stop_time" field.
  1901. func (m *BatchMsgMutation) ResetStopTime() {
  1902. m.stop_time = nil
  1903. delete(m.clearedFields, batchmsg.FieldStopTime)
  1904. }
  1905. // SetSendTime sets the "send_time" field.
  1906. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  1907. m.send_time = &t
  1908. }
  1909. // SendTime returns the value of the "send_time" field in the mutation.
  1910. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  1911. v := m.send_time
  1912. if v == nil {
  1913. return
  1914. }
  1915. return *v, true
  1916. }
  1917. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  1918. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1920. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  1921. if !m.op.Is(OpUpdateOne) {
  1922. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  1923. }
  1924. if m.id == nil || m.oldValue == nil {
  1925. return v, errors.New("OldSendTime requires an ID field in the mutation")
  1926. }
  1927. oldValue, err := m.oldValue(ctx)
  1928. if err != nil {
  1929. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  1930. }
  1931. return oldValue.SendTime, nil
  1932. }
  1933. // ClearSendTime clears the value of the "send_time" field.
  1934. func (m *BatchMsgMutation) ClearSendTime() {
  1935. m.send_time = nil
  1936. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  1937. }
  1938. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  1939. func (m *BatchMsgMutation) SendTimeCleared() bool {
  1940. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  1941. return ok
  1942. }
  1943. // ResetSendTime resets all changes to the "send_time" field.
  1944. func (m *BatchMsgMutation) ResetSendTime() {
  1945. m.send_time = nil
  1946. delete(m.clearedFields, batchmsg.FieldSendTime)
  1947. }
  1948. // SetType sets the "type" field.
  1949. func (m *BatchMsgMutation) SetType(i int32) {
  1950. m._type = &i
  1951. m.add_type = nil
  1952. }
  1953. // GetType returns the value of the "type" field in the mutation.
  1954. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  1955. v := m._type
  1956. if v == nil {
  1957. return
  1958. }
  1959. return *v, true
  1960. }
  1961. // OldType returns the old "type" field's value of the BatchMsg entity.
  1962. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1964. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  1965. if !m.op.Is(OpUpdateOne) {
  1966. return v, errors.New("OldType is only allowed on UpdateOne operations")
  1967. }
  1968. if m.id == nil || m.oldValue == nil {
  1969. return v, errors.New("OldType requires an ID field in the mutation")
  1970. }
  1971. oldValue, err := m.oldValue(ctx)
  1972. if err != nil {
  1973. return v, fmt.Errorf("querying old value for OldType: %w", err)
  1974. }
  1975. return oldValue.Type, nil
  1976. }
  1977. // AddType adds i to the "type" field.
  1978. func (m *BatchMsgMutation) AddType(i int32) {
  1979. if m.add_type != nil {
  1980. *m.add_type += i
  1981. } else {
  1982. m.add_type = &i
  1983. }
  1984. }
  1985. // AddedType returns the value that was added to the "type" field in this mutation.
  1986. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  1987. v := m.add_type
  1988. if v == nil {
  1989. return
  1990. }
  1991. return *v, true
  1992. }
  1993. // ClearType clears the value of the "type" field.
  1994. func (m *BatchMsgMutation) ClearType() {
  1995. m._type = nil
  1996. m.add_type = nil
  1997. m.clearedFields[batchmsg.FieldType] = struct{}{}
  1998. }
  1999. // TypeCleared returns if the "type" field was cleared in this mutation.
  2000. func (m *BatchMsgMutation) TypeCleared() bool {
  2001. _, ok := m.clearedFields[batchmsg.FieldType]
  2002. return ok
  2003. }
  2004. // ResetType resets all changes to the "type" field.
  2005. func (m *BatchMsgMutation) ResetType() {
  2006. m._type = nil
  2007. m.add_type = nil
  2008. delete(m.clearedFields, batchmsg.FieldType)
  2009. }
  2010. // SetOrganizationID sets the "organization_id" field.
  2011. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  2012. m.organization_id = &u
  2013. m.addorganization_id = nil
  2014. }
  2015. // OrganizationID returns the value of the "organization_id" field in the mutation.
  2016. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  2017. v := m.organization_id
  2018. if v == nil {
  2019. return
  2020. }
  2021. return *v, true
  2022. }
  2023. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  2024. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2026. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  2027. if !m.op.Is(OpUpdateOne) {
  2028. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  2029. }
  2030. if m.id == nil || m.oldValue == nil {
  2031. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  2032. }
  2033. oldValue, err := m.oldValue(ctx)
  2034. if err != nil {
  2035. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  2036. }
  2037. return oldValue.OrganizationID, nil
  2038. }
  2039. // AddOrganizationID adds u to the "organization_id" field.
  2040. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  2041. if m.addorganization_id != nil {
  2042. *m.addorganization_id += u
  2043. } else {
  2044. m.addorganization_id = &u
  2045. }
  2046. }
  2047. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  2048. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  2049. v := m.addorganization_id
  2050. if v == nil {
  2051. return
  2052. }
  2053. return *v, true
  2054. }
  2055. // ResetOrganizationID resets all changes to the "organization_id" field.
  2056. func (m *BatchMsgMutation) ResetOrganizationID() {
  2057. m.organization_id = nil
  2058. m.addorganization_id = nil
  2059. }
  2060. // Where appends a list predicates to the BatchMsgMutation builder.
  2061. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  2062. m.predicates = append(m.predicates, ps...)
  2063. }
  2064. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  2065. // users can use type-assertion to append predicates that do not depend on any generated package.
  2066. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  2067. p := make([]predicate.BatchMsg, len(ps))
  2068. for i := range ps {
  2069. p[i] = ps[i]
  2070. }
  2071. m.Where(p...)
  2072. }
  2073. // Op returns the operation name.
  2074. func (m *BatchMsgMutation) Op() Op {
  2075. return m.op
  2076. }
  2077. // SetOp allows setting the mutation operation.
  2078. func (m *BatchMsgMutation) SetOp(op Op) {
  2079. m.op = op
  2080. }
  2081. // Type returns the node type of this mutation (BatchMsg).
  2082. func (m *BatchMsgMutation) Type() string {
  2083. return m.typ
  2084. }
  2085. // Fields returns all fields that were changed during this mutation. Note that in
  2086. // order to get all numeric fields that were incremented/decremented, call
  2087. // AddedFields().
  2088. func (m *BatchMsgMutation) Fields() []string {
  2089. fields := make([]string, 0, 18)
  2090. if m.created_at != nil {
  2091. fields = append(fields, batchmsg.FieldCreatedAt)
  2092. }
  2093. if m.updated_at != nil {
  2094. fields = append(fields, batchmsg.FieldUpdatedAt)
  2095. }
  2096. if m.deleted_at != nil {
  2097. fields = append(fields, batchmsg.FieldDeletedAt)
  2098. }
  2099. if m.status != nil {
  2100. fields = append(fields, batchmsg.FieldStatus)
  2101. }
  2102. if m.batch_no != nil {
  2103. fields = append(fields, batchmsg.FieldBatchNo)
  2104. }
  2105. if m.task_name != nil {
  2106. fields = append(fields, batchmsg.FieldTaskName)
  2107. }
  2108. if m.fromwxid != nil {
  2109. fields = append(fields, batchmsg.FieldFromwxid)
  2110. }
  2111. if m.msg != nil {
  2112. fields = append(fields, batchmsg.FieldMsg)
  2113. }
  2114. if m.tag != nil {
  2115. fields = append(fields, batchmsg.FieldTag)
  2116. }
  2117. if m.tagids != nil {
  2118. fields = append(fields, batchmsg.FieldTagids)
  2119. }
  2120. if m.total != nil {
  2121. fields = append(fields, batchmsg.FieldTotal)
  2122. }
  2123. if m.success != nil {
  2124. fields = append(fields, batchmsg.FieldSuccess)
  2125. }
  2126. if m.fail != nil {
  2127. fields = append(fields, batchmsg.FieldFail)
  2128. }
  2129. if m.start_time != nil {
  2130. fields = append(fields, batchmsg.FieldStartTime)
  2131. }
  2132. if m.stop_time != nil {
  2133. fields = append(fields, batchmsg.FieldStopTime)
  2134. }
  2135. if m.send_time != nil {
  2136. fields = append(fields, batchmsg.FieldSendTime)
  2137. }
  2138. if m._type != nil {
  2139. fields = append(fields, batchmsg.FieldType)
  2140. }
  2141. if m.organization_id != nil {
  2142. fields = append(fields, batchmsg.FieldOrganizationID)
  2143. }
  2144. return fields
  2145. }
  2146. // Field returns the value of a field with the given name. The second boolean
  2147. // return value indicates that this field was not set, or was not defined in the
  2148. // schema.
  2149. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  2150. switch name {
  2151. case batchmsg.FieldCreatedAt:
  2152. return m.CreatedAt()
  2153. case batchmsg.FieldUpdatedAt:
  2154. return m.UpdatedAt()
  2155. case batchmsg.FieldDeletedAt:
  2156. return m.DeletedAt()
  2157. case batchmsg.FieldStatus:
  2158. return m.Status()
  2159. case batchmsg.FieldBatchNo:
  2160. return m.BatchNo()
  2161. case batchmsg.FieldTaskName:
  2162. return m.TaskName()
  2163. case batchmsg.FieldFromwxid:
  2164. return m.Fromwxid()
  2165. case batchmsg.FieldMsg:
  2166. return m.Msg()
  2167. case batchmsg.FieldTag:
  2168. return m.Tag()
  2169. case batchmsg.FieldTagids:
  2170. return m.Tagids()
  2171. case batchmsg.FieldTotal:
  2172. return m.Total()
  2173. case batchmsg.FieldSuccess:
  2174. return m.Success()
  2175. case batchmsg.FieldFail:
  2176. return m.Fail()
  2177. case batchmsg.FieldStartTime:
  2178. return m.StartTime()
  2179. case batchmsg.FieldStopTime:
  2180. return m.StopTime()
  2181. case batchmsg.FieldSendTime:
  2182. return m.SendTime()
  2183. case batchmsg.FieldType:
  2184. return m.GetType()
  2185. case batchmsg.FieldOrganizationID:
  2186. return m.OrganizationID()
  2187. }
  2188. return nil, false
  2189. }
  2190. // OldField returns the old value of the field from the database. An error is
  2191. // returned if the mutation operation is not UpdateOne, or the query to the
  2192. // database failed.
  2193. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2194. switch name {
  2195. case batchmsg.FieldCreatedAt:
  2196. return m.OldCreatedAt(ctx)
  2197. case batchmsg.FieldUpdatedAt:
  2198. return m.OldUpdatedAt(ctx)
  2199. case batchmsg.FieldDeletedAt:
  2200. return m.OldDeletedAt(ctx)
  2201. case batchmsg.FieldStatus:
  2202. return m.OldStatus(ctx)
  2203. case batchmsg.FieldBatchNo:
  2204. return m.OldBatchNo(ctx)
  2205. case batchmsg.FieldTaskName:
  2206. return m.OldTaskName(ctx)
  2207. case batchmsg.FieldFromwxid:
  2208. return m.OldFromwxid(ctx)
  2209. case batchmsg.FieldMsg:
  2210. return m.OldMsg(ctx)
  2211. case batchmsg.FieldTag:
  2212. return m.OldTag(ctx)
  2213. case batchmsg.FieldTagids:
  2214. return m.OldTagids(ctx)
  2215. case batchmsg.FieldTotal:
  2216. return m.OldTotal(ctx)
  2217. case batchmsg.FieldSuccess:
  2218. return m.OldSuccess(ctx)
  2219. case batchmsg.FieldFail:
  2220. return m.OldFail(ctx)
  2221. case batchmsg.FieldStartTime:
  2222. return m.OldStartTime(ctx)
  2223. case batchmsg.FieldStopTime:
  2224. return m.OldStopTime(ctx)
  2225. case batchmsg.FieldSendTime:
  2226. return m.OldSendTime(ctx)
  2227. case batchmsg.FieldType:
  2228. return m.OldType(ctx)
  2229. case batchmsg.FieldOrganizationID:
  2230. return m.OldOrganizationID(ctx)
  2231. }
  2232. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  2233. }
  2234. // SetField sets the value of a field with the given name. It returns an error if
  2235. // the field is not defined in the schema, or if the type mismatched the field
  2236. // type.
  2237. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  2238. switch name {
  2239. case batchmsg.FieldCreatedAt:
  2240. v, ok := value.(time.Time)
  2241. if !ok {
  2242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2243. }
  2244. m.SetCreatedAt(v)
  2245. return nil
  2246. case batchmsg.FieldUpdatedAt:
  2247. v, ok := value.(time.Time)
  2248. if !ok {
  2249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2250. }
  2251. m.SetUpdatedAt(v)
  2252. return nil
  2253. case batchmsg.FieldDeletedAt:
  2254. v, ok := value.(time.Time)
  2255. if !ok {
  2256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2257. }
  2258. m.SetDeletedAt(v)
  2259. return nil
  2260. case batchmsg.FieldStatus:
  2261. v, ok := value.(uint8)
  2262. if !ok {
  2263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2264. }
  2265. m.SetStatus(v)
  2266. return nil
  2267. case batchmsg.FieldBatchNo:
  2268. v, ok := value.(string)
  2269. if !ok {
  2270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2271. }
  2272. m.SetBatchNo(v)
  2273. return nil
  2274. case batchmsg.FieldTaskName:
  2275. v, ok := value.(string)
  2276. if !ok {
  2277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2278. }
  2279. m.SetTaskName(v)
  2280. return nil
  2281. case batchmsg.FieldFromwxid:
  2282. v, ok := value.(string)
  2283. if !ok {
  2284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2285. }
  2286. m.SetFromwxid(v)
  2287. return nil
  2288. case batchmsg.FieldMsg:
  2289. v, ok := value.(string)
  2290. if !ok {
  2291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2292. }
  2293. m.SetMsg(v)
  2294. return nil
  2295. case batchmsg.FieldTag:
  2296. v, ok := value.(string)
  2297. if !ok {
  2298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2299. }
  2300. m.SetTag(v)
  2301. return nil
  2302. case batchmsg.FieldTagids:
  2303. v, ok := value.(string)
  2304. if !ok {
  2305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2306. }
  2307. m.SetTagids(v)
  2308. return nil
  2309. case batchmsg.FieldTotal:
  2310. v, ok := value.(int32)
  2311. if !ok {
  2312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2313. }
  2314. m.SetTotal(v)
  2315. return nil
  2316. case batchmsg.FieldSuccess:
  2317. v, ok := value.(int32)
  2318. if !ok {
  2319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2320. }
  2321. m.SetSuccess(v)
  2322. return nil
  2323. case batchmsg.FieldFail:
  2324. v, ok := value.(int32)
  2325. if !ok {
  2326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2327. }
  2328. m.SetFail(v)
  2329. return nil
  2330. case batchmsg.FieldStartTime:
  2331. v, ok := value.(time.Time)
  2332. if !ok {
  2333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2334. }
  2335. m.SetStartTime(v)
  2336. return nil
  2337. case batchmsg.FieldStopTime:
  2338. v, ok := value.(time.Time)
  2339. if !ok {
  2340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2341. }
  2342. m.SetStopTime(v)
  2343. return nil
  2344. case batchmsg.FieldSendTime:
  2345. v, ok := value.(time.Time)
  2346. if !ok {
  2347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2348. }
  2349. m.SetSendTime(v)
  2350. return nil
  2351. case batchmsg.FieldType:
  2352. v, ok := value.(int32)
  2353. if !ok {
  2354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2355. }
  2356. m.SetType(v)
  2357. return nil
  2358. case batchmsg.FieldOrganizationID:
  2359. v, ok := value.(uint64)
  2360. if !ok {
  2361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2362. }
  2363. m.SetOrganizationID(v)
  2364. return nil
  2365. }
  2366. return fmt.Errorf("unknown BatchMsg field %s", name)
  2367. }
  2368. // AddedFields returns all numeric fields that were incremented/decremented during
  2369. // this mutation.
  2370. func (m *BatchMsgMutation) AddedFields() []string {
  2371. var fields []string
  2372. if m.addstatus != nil {
  2373. fields = append(fields, batchmsg.FieldStatus)
  2374. }
  2375. if m.addtotal != nil {
  2376. fields = append(fields, batchmsg.FieldTotal)
  2377. }
  2378. if m.addsuccess != nil {
  2379. fields = append(fields, batchmsg.FieldSuccess)
  2380. }
  2381. if m.addfail != nil {
  2382. fields = append(fields, batchmsg.FieldFail)
  2383. }
  2384. if m.add_type != nil {
  2385. fields = append(fields, batchmsg.FieldType)
  2386. }
  2387. if m.addorganization_id != nil {
  2388. fields = append(fields, batchmsg.FieldOrganizationID)
  2389. }
  2390. return fields
  2391. }
  2392. // AddedField returns the numeric value that was incremented/decremented on a field
  2393. // with the given name. The second boolean return value indicates that this field
  2394. // was not set, or was not defined in the schema.
  2395. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  2396. switch name {
  2397. case batchmsg.FieldStatus:
  2398. return m.AddedStatus()
  2399. case batchmsg.FieldTotal:
  2400. return m.AddedTotal()
  2401. case batchmsg.FieldSuccess:
  2402. return m.AddedSuccess()
  2403. case batchmsg.FieldFail:
  2404. return m.AddedFail()
  2405. case batchmsg.FieldType:
  2406. return m.AddedType()
  2407. case batchmsg.FieldOrganizationID:
  2408. return m.AddedOrganizationID()
  2409. }
  2410. return nil, false
  2411. }
  2412. // AddField adds the value to the field with the given name. It returns an error if
  2413. // the field is not defined in the schema, or if the type mismatched the field
  2414. // type.
  2415. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  2416. switch name {
  2417. case batchmsg.FieldStatus:
  2418. v, ok := value.(int8)
  2419. if !ok {
  2420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2421. }
  2422. m.AddStatus(v)
  2423. return nil
  2424. case batchmsg.FieldTotal:
  2425. v, ok := value.(int32)
  2426. if !ok {
  2427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2428. }
  2429. m.AddTotal(v)
  2430. return nil
  2431. case batchmsg.FieldSuccess:
  2432. v, ok := value.(int32)
  2433. if !ok {
  2434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2435. }
  2436. m.AddSuccess(v)
  2437. return nil
  2438. case batchmsg.FieldFail:
  2439. v, ok := value.(int32)
  2440. if !ok {
  2441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2442. }
  2443. m.AddFail(v)
  2444. return nil
  2445. case batchmsg.FieldType:
  2446. v, ok := value.(int32)
  2447. if !ok {
  2448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2449. }
  2450. m.AddType(v)
  2451. return nil
  2452. case batchmsg.FieldOrganizationID:
  2453. v, ok := value.(int64)
  2454. if !ok {
  2455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2456. }
  2457. m.AddOrganizationID(v)
  2458. return nil
  2459. }
  2460. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  2461. }
  2462. // ClearedFields returns all nullable fields that were cleared during this
  2463. // mutation.
  2464. func (m *BatchMsgMutation) ClearedFields() []string {
  2465. var fields []string
  2466. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  2467. fields = append(fields, batchmsg.FieldDeletedAt)
  2468. }
  2469. if m.FieldCleared(batchmsg.FieldStatus) {
  2470. fields = append(fields, batchmsg.FieldStatus)
  2471. }
  2472. if m.FieldCleared(batchmsg.FieldBatchNo) {
  2473. fields = append(fields, batchmsg.FieldBatchNo)
  2474. }
  2475. if m.FieldCleared(batchmsg.FieldTaskName) {
  2476. fields = append(fields, batchmsg.FieldTaskName)
  2477. }
  2478. if m.FieldCleared(batchmsg.FieldFromwxid) {
  2479. fields = append(fields, batchmsg.FieldFromwxid)
  2480. }
  2481. if m.FieldCleared(batchmsg.FieldMsg) {
  2482. fields = append(fields, batchmsg.FieldMsg)
  2483. }
  2484. if m.FieldCleared(batchmsg.FieldTag) {
  2485. fields = append(fields, batchmsg.FieldTag)
  2486. }
  2487. if m.FieldCleared(batchmsg.FieldTagids) {
  2488. fields = append(fields, batchmsg.FieldTagids)
  2489. }
  2490. if m.FieldCleared(batchmsg.FieldTotal) {
  2491. fields = append(fields, batchmsg.FieldTotal)
  2492. }
  2493. if m.FieldCleared(batchmsg.FieldSuccess) {
  2494. fields = append(fields, batchmsg.FieldSuccess)
  2495. }
  2496. if m.FieldCleared(batchmsg.FieldFail) {
  2497. fields = append(fields, batchmsg.FieldFail)
  2498. }
  2499. if m.FieldCleared(batchmsg.FieldStartTime) {
  2500. fields = append(fields, batchmsg.FieldStartTime)
  2501. }
  2502. if m.FieldCleared(batchmsg.FieldStopTime) {
  2503. fields = append(fields, batchmsg.FieldStopTime)
  2504. }
  2505. if m.FieldCleared(batchmsg.FieldSendTime) {
  2506. fields = append(fields, batchmsg.FieldSendTime)
  2507. }
  2508. if m.FieldCleared(batchmsg.FieldType) {
  2509. fields = append(fields, batchmsg.FieldType)
  2510. }
  2511. return fields
  2512. }
  2513. // FieldCleared returns a boolean indicating if a field with the given name was
  2514. // cleared in this mutation.
  2515. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  2516. _, ok := m.clearedFields[name]
  2517. return ok
  2518. }
  2519. // ClearField clears the value of the field with the given name. It returns an
  2520. // error if the field is not defined in the schema.
  2521. func (m *BatchMsgMutation) ClearField(name string) error {
  2522. switch name {
  2523. case batchmsg.FieldDeletedAt:
  2524. m.ClearDeletedAt()
  2525. return nil
  2526. case batchmsg.FieldStatus:
  2527. m.ClearStatus()
  2528. return nil
  2529. case batchmsg.FieldBatchNo:
  2530. m.ClearBatchNo()
  2531. return nil
  2532. case batchmsg.FieldTaskName:
  2533. m.ClearTaskName()
  2534. return nil
  2535. case batchmsg.FieldFromwxid:
  2536. m.ClearFromwxid()
  2537. return nil
  2538. case batchmsg.FieldMsg:
  2539. m.ClearMsg()
  2540. return nil
  2541. case batchmsg.FieldTag:
  2542. m.ClearTag()
  2543. return nil
  2544. case batchmsg.FieldTagids:
  2545. m.ClearTagids()
  2546. return nil
  2547. case batchmsg.FieldTotal:
  2548. m.ClearTotal()
  2549. return nil
  2550. case batchmsg.FieldSuccess:
  2551. m.ClearSuccess()
  2552. return nil
  2553. case batchmsg.FieldFail:
  2554. m.ClearFail()
  2555. return nil
  2556. case batchmsg.FieldStartTime:
  2557. m.ClearStartTime()
  2558. return nil
  2559. case batchmsg.FieldStopTime:
  2560. m.ClearStopTime()
  2561. return nil
  2562. case batchmsg.FieldSendTime:
  2563. m.ClearSendTime()
  2564. return nil
  2565. case batchmsg.FieldType:
  2566. m.ClearType()
  2567. return nil
  2568. }
  2569. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  2570. }
  2571. // ResetField resets all changes in the mutation for the field with the given name.
  2572. // It returns an error if the field is not defined in the schema.
  2573. func (m *BatchMsgMutation) ResetField(name string) error {
  2574. switch name {
  2575. case batchmsg.FieldCreatedAt:
  2576. m.ResetCreatedAt()
  2577. return nil
  2578. case batchmsg.FieldUpdatedAt:
  2579. m.ResetUpdatedAt()
  2580. return nil
  2581. case batchmsg.FieldDeletedAt:
  2582. m.ResetDeletedAt()
  2583. return nil
  2584. case batchmsg.FieldStatus:
  2585. m.ResetStatus()
  2586. return nil
  2587. case batchmsg.FieldBatchNo:
  2588. m.ResetBatchNo()
  2589. return nil
  2590. case batchmsg.FieldTaskName:
  2591. m.ResetTaskName()
  2592. return nil
  2593. case batchmsg.FieldFromwxid:
  2594. m.ResetFromwxid()
  2595. return nil
  2596. case batchmsg.FieldMsg:
  2597. m.ResetMsg()
  2598. return nil
  2599. case batchmsg.FieldTag:
  2600. m.ResetTag()
  2601. return nil
  2602. case batchmsg.FieldTagids:
  2603. m.ResetTagids()
  2604. return nil
  2605. case batchmsg.FieldTotal:
  2606. m.ResetTotal()
  2607. return nil
  2608. case batchmsg.FieldSuccess:
  2609. m.ResetSuccess()
  2610. return nil
  2611. case batchmsg.FieldFail:
  2612. m.ResetFail()
  2613. return nil
  2614. case batchmsg.FieldStartTime:
  2615. m.ResetStartTime()
  2616. return nil
  2617. case batchmsg.FieldStopTime:
  2618. m.ResetStopTime()
  2619. return nil
  2620. case batchmsg.FieldSendTime:
  2621. m.ResetSendTime()
  2622. return nil
  2623. case batchmsg.FieldType:
  2624. m.ResetType()
  2625. return nil
  2626. case batchmsg.FieldOrganizationID:
  2627. m.ResetOrganizationID()
  2628. return nil
  2629. }
  2630. return fmt.Errorf("unknown BatchMsg field %s", name)
  2631. }
  2632. // AddedEdges returns all edge names that were set/added in this mutation.
  2633. func (m *BatchMsgMutation) AddedEdges() []string {
  2634. edges := make([]string, 0, 0)
  2635. return edges
  2636. }
  2637. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2638. // name in this mutation.
  2639. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  2640. return nil
  2641. }
  2642. // RemovedEdges returns all edge names that were removed in this mutation.
  2643. func (m *BatchMsgMutation) RemovedEdges() []string {
  2644. edges := make([]string, 0, 0)
  2645. return edges
  2646. }
  2647. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2648. // the given name in this mutation.
  2649. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  2650. return nil
  2651. }
  2652. // ClearedEdges returns all edge names that were cleared in this mutation.
  2653. func (m *BatchMsgMutation) ClearedEdges() []string {
  2654. edges := make([]string, 0, 0)
  2655. return edges
  2656. }
  2657. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2658. // was cleared in this mutation.
  2659. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  2660. return false
  2661. }
  2662. // ClearEdge clears the value of the edge with the given name. It returns an error
  2663. // if that edge is not defined in the schema.
  2664. func (m *BatchMsgMutation) ClearEdge(name string) error {
  2665. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  2666. }
  2667. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2668. // It returns an error if the edge is not defined in the schema.
  2669. func (m *BatchMsgMutation) ResetEdge(name string) error {
  2670. return fmt.Errorf("unknown BatchMsg edge %s", name)
  2671. }
  2672. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  2673. type CategoryMutation struct {
  2674. config
  2675. op Op
  2676. typ string
  2677. id *uint64
  2678. created_at *time.Time
  2679. updated_at *time.Time
  2680. deleted_at *time.Time
  2681. name *string
  2682. organization_id *uint64
  2683. addorganization_id *int64
  2684. clearedFields map[string]struct{}
  2685. done bool
  2686. oldValue func(context.Context) (*Category, error)
  2687. predicates []predicate.Category
  2688. }
  2689. var _ ent.Mutation = (*CategoryMutation)(nil)
  2690. // categoryOption allows management of the mutation configuration using functional options.
  2691. type categoryOption func(*CategoryMutation)
  2692. // newCategoryMutation creates new mutation for the Category entity.
  2693. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  2694. m := &CategoryMutation{
  2695. config: c,
  2696. op: op,
  2697. typ: TypeCategory,
  2698. clearedFields: make(map[string]struct{}),
  2699. }
  2700. for _, opt := range opts {
  2701. opt(m)
  2702. }
  2703. return m
  2704. }
  2705. // withCategoryID sets the ID field of the mutation.
  2706. func withCategoryID(id uint64) categoryOption {
  2707. return func(m *CategoryMutation) {
  2708. var (
  2709. err error
  2710. once sync.Once
  2711. value *Category
  2712. )
  2713. m.oldValue = func(ctx context.Context) (*Category, error) {
  2714. once.Do(func() {
  2715. if m.done {
  2716. err = errors.New("querying old values post mutation is not allowed")
  2717. } else {
  2718. value, err = m.Client().Category.Get(ctx, id)
  2719. }
  2720. })
  2721. return value, err
  2722. }
  2723. m.id = &id
  2724. }
  2725. }
  2726. // withCategory sets the old Category of the mutation.
  2727. func withCategory(node *Category) categoryOption {
  2728. return func(m *CategoryMutation) {
  2729. m.oldValue = func(context.Context) (*Category, error) {
  2730. return node, nil
  2731. }
  2732. m.id = &node.ID
  2733. }
  2734. }
  2735. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2736. // executed in a transaction (ent.Tx), a transactional client is returned.
  2737. func (m CategoryMutation) Client() *Client {
  2738. client := &Client{config: m.config}
  2739. client.init()
  2740. return client
  2741. }
  2742. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2743. // it returns an error otherwise.
  2744. func (m CategoryMutation) Tx() (*Tx, error) {
  2745. if _, ok := m.driver.(*txDriver); !ok {
  2746. return nil, errors.New("ent: mutation is not running in a transaction")
  2747. }
  2748. tx := &Tx{config: m.config}
  2749. tx.init()
  2750. return tx, nil
  2751. }
  2752. // SetID sets the value of the id field. Note that this
  2753. // operation is only accepted on creation of Category entities.
  2754. func (m *CategoryMutation) SetID(id uint64) {
  2755. m.id = &id
  2756. }
  2757. // ID returns the ID value in the mutation. Note that the ID is only available
  2758. // if it was provided to the builder or after it was returned from the database.
  2759. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  2760. if m.id == nil {
  2761. return
  2762. }
  2763. return *m.id, true
  2764. }
  2765. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2766. // That means, if the mutation is applied within a transaction with an isolation level such
  2767. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2768. // or updated by the mutation.
  2769. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  2770. switch {
  2771. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2772. id, exists := m.ID()
  2773. if exists {
  2774. return []uint64{id}, nil
  2775. }
  2776. fallthrough
  2777. case m.op.Is(OpUpdate | OpDelete):
  2778. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  2779. default:
  2780. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2781. }
  2782. }
  2783. // SetCreatedAt sets the "created_at" field.
  2784. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  2785. m.created_at = &t
  2786. }
  2787. // CreatedAt returns the value of the "created_at" field in the mutation.
  2788. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  2789. v := m.created_at
  2790. if v == nil {
  2791. return
  2792. }
  2793. return *v, true
  2794. }
  2795. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  2796. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  2797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2798. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2799. if !m.op.Is(OpUpdateOne) {
  2800. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2801. }
  2802. if m.id == nil || m.oldValue == nil {
  2803. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2804. }
  2805. oldValue, err := m.oldValue(ctx)
  2806. if err != nil {
  2807. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2808. }
  2809. return oldValue.CreatedAt, nil
  2810. }
  2811. // ResetCreatedAt resets all changes to the "created_at" field.
  2812. func (m *CategoryMutation) ResetCreatedAt() {
  2813. m.created_at = nil
  2814. }
  2815. // SetUpdatedAt sets the "updated_at" field.
  2816. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  2817. m.updated_at = &t
  2818. }
  2819. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2820. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  2821. v := m.updated_at
  2822. if v == nil {
  2823. return
  2824. }
  2825. return *v, true
  2826. }
  2827. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  2828. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  2829. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2830. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2831. if !m.op.Is(OpUpdateOne) {
  2832. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2833. }
  2834. if m.id == nil || m.oldValue == nil {
  2835. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2836. }
  2837. oldValue, err := m.oldValue(ctx)
  2838. if err != nil {
  2839. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2840. }
  2841. return oldValue.UpdatedAt, nil
  2842. }
  2843. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2844. func (m *CategoryMutation) ResetUpdatedAt() {
  2845. m.updated_at = nil
  2846. }
  2847. // SetDeletedAt sets the "deleted_at" field.
  2848. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  2849. m.deleted_at = &t
  2850. }
  2851. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2852. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  2853. v := m.deleted_at
  2854. if v == nil {
  2855. return
  2856. }
  2857. return *v, true
  2858. }
  2859. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  2860. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  2861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2862. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2863. if !m.op.Is(OpUpdateOne) {
  2864. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2865. }
  2866. if m.id == nil || m.oldValue == nil {
  2867. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2868. }
  2869. oldValue, err := m.oldValue(ctx)
  2870. if err != nil {
  2871. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2872. }
  2873. return oldValue.DeletedAt, nil
  2874. }
  2875. // ClearDeletedAt clears the value of the "deleted_at" field.
  2876. func (m *CategoryMutation) ClearDeletedAt() {
  2877. m.deleted_at = nil
  2878. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  2879. }
  2880. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2881. func (m *CategoryMutation) DeletedAtCleared() bool {
  2882. _, ok := m.clearedFields[category.FieldDeletedAt]
  2883. return ok
  2884. }
  2885. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2886. func (m *CategoryMutation) ResetDeletedAt() {
  2887. m.deleted_at = nil
  2888. delete(m.clearedFields, category.FieldDeletedAt)
  2889. }
  2890. // SetName sets the "name" field.
  2891. func (m *CategoryMutation) SetName(s string) {
  2892. m.name = &s
  2893. }
  2894. // Name returns the value of the "name" field in the mutation.
  2895. func (m *CategoryMutation) Name() (r string, exists bool) {
  2896. v := m.name
  2897. if v == nil {
  2898. return
  2899. }
  2900. return *v, true
  2901. }
  2902. // OldName returns the old "name" field's value of the Category entity.
  2903. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  2904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2905. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  2906. if !m.op.Is(OpUpdateOne) {
  2907. return v, errors.New("OldName is only allowed on UpdateOne operations")
  2908. }
  2909. if m.id == nil || m.oldValue == nil {
  2910. return v, errors.New("OldName requires an ID field in the mutation")
  2911. }
  2912. oldValue, err := m.oldValue(ctx)
  2913. if err != nil {
  2914. return v, fmt.Errorf("querying old value for OldName: %w", err)
  2915. }
  2916. return oldValue.Name, nil
  2917. }
  2918. // ResetName resets all changes to the "name" field.
  2919. func (m *CategoryMutation) ResetName() {
  2920. m.name = nil
  2921. }
  2922. // SetOrganizationID sets the "organization_id" field.
  2923. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  2924. m.organization_id = &u
  2925. m.addorganization_id = nil
  2926. }
  2927. // OrganizationID returns the value of the "organization_id" field in the mutation.
  2928. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  2929. v := m.organization_id
  2930. if v == nil {
  2931. return
  2932. }
  2933. return *v, true
  2934. }
  2935. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  2936. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  2937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2938. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  2939. if !m.op.Is(OpUpdateOne) {
  2940. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  2941. }
  2942. if m.id == nil || m.oldValue == nil {
  2943. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  2944. }
  2945. oldValue, err := m.oldValue(ctx)
  2946. if err != nil {
  2947. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  2948. }
  2949. return oldValue.OrganizationID, nil
  2950. }
  2951. // AddOrganizationID adds u to the "organization_id" field.
  2952. func (m *CategoryMutation) AddOrganizationID(u int64) {
  2953. if m.addorganization_id != nil {
  2954. *m.addorganization_id += u
  2955. } else {
  2956. m.addorganization_id = &u
  2957. }
  2958. }
  2959. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  2960. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  2961. v := m.addorganization_id
  2962. if v == nil {
  2963. return
  2964. }
  2965. return *v, true
  2966. }
  2967. // ResetOrganizationID resets all changes to the "organization_id" field.
  2968. func (m *CategoryMutation) ResetOrganizationID() {
  2969. m.organization_id = nil
  2970. m.addorganization_id = nil
  2971. }
  2972. // Where appends a list predicates to the CategoryMutation builder.
  2973. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  2974. m.predicates = append(m.predicates, ps...)
  2975. }
  2976. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  2977. // users can use type-assertion to append predicates that do not depend on any generated package.
  2978. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  2979. p := make([]predicate.Category, len(ps))
  2980. for i := range ps {
  2981. p[i] = ps[i]
  2982. }
  2983. m.Where(p...)
  2984. }
  2985. // Op returns the operation name.
  2986. func (m *CategoryMutation) Op() Op {
  2987. return m.op
  2988. }
  2989. // SetOp allows setting the mutation operation.
  2990. func (m *CategoryMutation) SetOp(op Op) {
  2991. m.op = op
  2992. }
  2993. // Type returns the node type of this mutation (Category).
  2994. func (m *CategoryMutation) Type() string {
  2995. return m.typ
  2996. }
  2997. // Fields returns all fields that were changed during this mutation. Note that in
  2998. // order to get all numeric fields that were incremented/decremented, call
  2999. // AddedFields().
  3000. func (m *CategoryMutation) Fields() []string {
  3001. fields := make([]string, 0, 5)
  3002. if m.created_at != nil {
  3003. fields = append(fields, category.FieldCreatedAt)
  3004. }
  3005. if m.updated_at != nil {
  3006. fields = append(fields, category.FieldUpdatedAt)
  3007. }
  3008. if m.deleted_at != nil {
  3009. fields = append(fields, category.FieldDeletedAt)
  3010. }
  3011. if m.name != nil {
  3012. fields = append(fields, category.FieldName)
  3013. }
  3014. if m.organization_id != nil {
  3015. fields = append(fields, category.FieldOrganizationID)
  3016. }
  3017. return fields
  3018. }
  3019. // Field returns the value of a field with the given name. The second boolean
  3020. // return value indicates that this field was not set, or was not defined in the
  3021. // schema.
  3022. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  3023. switch name {
  3024. case category.FieldCreatedAt:
  3025. return m.CreatedAt()
  3026. case category.FieldUpdatedAt:
  3027. return m.UpdatedAt()
  3028. case category.FieldDeletedAt:
  3029. return m.DeletedAt()
  3030. case category.FieldName:
  3031. return m.Name()
  3032. case category.FieldOrganizationID:
  3033. return m.OrganizationID()
  3034. }
  3035. return nil, false
  3036. }
  3037. // OldField returns the old value of the field from the database. An error is
  3038. // returned if the mutation operation is not UpdateOne, or the query to the
  3039. // database failed.
  3040. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3041. switch name {
  3042. case category.FieldCreatedAt:
  3043. return m.OldCreatedAt(ctx)
  3044. case category.FieldUpdatedAt:
  3045. return m.OldUpdatedAt(ctx)
  3046. case category.FieldDeletedAt:
  3047. return m.OldDeletedAt(ctx)
  3048. case category.FieldName:
  3049. return m.OldName(ctx)
  3050. case category.FieldOrganizationID:
  3051. return m.OldOrganizationID(ctx)
  3052. }
  3053. return nil, fmt.Errorf("unknown Category field %s", name)
  3054. }
  3055. // SetField sets the value of a field with the given name. It returns an error if
  3056. // the field is not defined in the schema, or if the type mismatched the field
  3057. // type.
  3058. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  3059. switch name {
  3060. case category.FieldCreatedAt:
  3061. v, ok := value.(time.Time)
  3062. if !ok {
  3063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3064. }
  3065. m.SetCreatedAt(v)
  3066. return nil
  3067. case category.FieldUpdatedAt:
  3068. v, ok := value.(time.Time)
  3069. if !ok {
  3070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3071. }
  3072. m.SetUpdatedAt(v)
  3073. return nil
  3074. case category.FieldDeletedAt:
  3075. v, ok := value.(time.Time)
  3076. if !ok {
  3077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3078. }
  3079. m.SetDeletedAt(v)
  3080. return nil
  3081. case category.FieldName:
  3082. v, ok := value.(string)
  3083. if !ok {
  3084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3085. }
  3086. m.SetName(v)
  3087. return nil
  3088. case category.FieldOrganizationID:
  3089. v, ok := value.(uint64)
  3090. if !ok {
  3091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3092. }
  3093. m.SetOrganizationID(v)
  3094. return nil
  3095. }
  3096. return fmt.Errorf("unknown Category field %s", name)
  3097. }
  3098. // AddedFields returns all numeric fields that were incremented/decremented during
  3099. // this mutation.
  3100. func (m *CategoryMutation) AddedFields() []string {
  3101. var fields []string
  3102. if m.addorganization_id != nil {
  3103. fields = append(fields, category.FieldOrganizationID)
  3104. }
  3105. return fields
  3106. }
  3107. // AddedField returns the numeric value that was incremented/decremented on a field
  3108. // with the given name. The second boolean return value indicates that this field
  3109. // was not set, or was not defined in the schema.
  3110. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  3111. switch name {
  3112. case category.FieldOrganizationID:
  3113. return m.AddedOrganizationID()
  3114. }
  3115. return nil, false
  3116. }
  3117. // AddField adds the value to the field with the given name. It returns an error if
  3118. // the field is not defined in the schema, or if the type mismatched the field
  3119. // type.
  3120. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  3121. switch name {
  3122. case category.FieldOrganizationID:
  3123. v, ok := value.(int64)
  3124. if !ok {
  3125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3126. }
  3127. m.AddOrganizationID(v)
  3128. return nil
  3129. }
  3130. return fmt.Errorf("unknown Category numeric field %s", name)
  3131. }
  3132. // ClearedFields returns all nullable fields that were cleared during this
  3133. // mutation.
  3134. func (m *CategoryMutation) ClearedFields() []string {
  3135. var fields []string
  3136. if m.FieldCleared(category.FieldDeletedAt) {
  3137. fields = append(fields, category.FieldDeletedAt)
  3138. }
  3139. return fields
  3140. }
  3141. // FieldCleared returns a boolean indicating if a field with the given name was
  3142. // cleared in this mutation.
  3143. func (m *CategoryMutation) FieldCleared(name string) bool {
  3144. _, ok := m.clearedFields[name]
  3145. return ok
  3146. }
  3147. // ClearField clears the value of the field with the given name. It returns an
  3148. // error if the field is not defined in the schema.
  3149. func (m *CategoryMutation) ClearField(name string) error {
  3150. switch name {
  3151. case category.FieldDeletedAt:
  3152. m.ClearDeletedAt()
  3153. return nil
  3154. }
  3155. return fmt.Errorf("unknown Category nullable field %s", name)
  3156. }
  3157. // ResetField resets all changes in the mutation for the field with the given name.
  3158. // It returns an error if the field is not defined in the schema.
  3159. func (m *CategoryMutation) ResetField(name string) error {
  3160. switch name {
  3161. case category.FieldCreatedAt:
  3162. m.ResetCreatedAt()
  3163. return nil
  3164. case category.FieldUpdatedAt:
  3165. m.ResetUpdatedAt()
  3166. return nil
  3167. case category.FieldDeletedAt:
  3168. m.ResetDeletedAt()
  3169. return nil
  3170. case category.FieldName:
  3171. m.ResetName()
  3172. return nil
  3173. case category.FieldOrganizationID:
  3174. m.ResetOrganizationID()
  3175. return nil
  3176. }
  3177. return fmt.Errorf("unknown Category field %s", name)
  3178. }
  3179. // AddedEdges returns all edge names that were set/added in this mutation.
  3180. func (m *CategoryMutation) AddedEdges() []string {
  3181. edges := make([]string, 0, 0)
  3182. return edges
  3183. }
  3184. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3185. // name in this mutation.
  3186. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  3187. return nil
  3188. }
  3189. // RemovedEdges returns all edge names that were removed in this mutation.
  3190. func (m *CategoryMutation) RemovedEdges() []string {
  3191. edges := make([]string, 0, 0)
  3192. return edges
  3193. }
  3194. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3195. // the given name in this mutation.
  3196. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  3197. return nil
  3198. }
  3199. // ClearedEdges returns all edge names that were cleared in this mutation.
  3200. func (m *CategoryMutation) ClearedEdges() []string {
  3201. edges := make([]string, 0, 0)
  3202. return edges
  3203. }
  3204. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3205. // was cleared in this mutation.
  3206. func (m *CategoryMutation) EdgeCleared(name string) bool {
  3207. return false
  3208. }
  3209. // ClearEdge clears the value of the edge with the given name. It returns an error
  3210. // if that edge is not defined in the schema.
  3211. func (m *CategoryMutation) ClearEdge(name string) error {
  3212. return fmt.Errorf("unknown Category unique edge %s", name)
  3213. }
  3214. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3215. // It returns an error if the edge is not defined in the schema.
  3216. func (m *CategoryMutation) ResetEdge(name string) error {
  3217. return fmt.Errorf("unknown Category edge %s", name)
  3218. }
  3219. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  3220. type ContactMutation struct {
  3221. config
  3222. op Op
  3223. typ string
  3224. id *uint64
  3225. created_at *time.Time
  3226. updated_at *time.Time
  3227. status *uint8
  3228. addstatus *int8
  3229. deleted_at *time.Time
  3230. wx_wxid *string
  3231. _type *int
  3232. add_type *int
  3233. wxid *string
  3234. account *string
  3235. nickname *string
  3236. markname *string
  3237. headimg *string
  3238. sex *int
  3239. addsex *int
  3240. starrole *string
  3241. dontseeit *int
  3242. adddontseeit *int
  3243. dontseeme *int
  3244. adddontseeme *int
  3245. lag *string
  3246. gid *string
  3247. gname *string
  3248. v3 *string
  3249. organization_id *uint64
  3250. addorganization_id *int64
  3251. clearedFields map[string]struct{}
  3252. contact_relationships map[uint64]struct{}
  3253. removedcontact_relationships map[uint64]struct{}
  3254. clearedcontact_relationships bool
  3255. contact_messages map[uint64]struct{}
  3256. removedcontact_messages map[uint64]struct{}
  3257. clearedcontact_messages bool
  3258. done bool
  3259. oldValue func(context.Context) (*Contact, error)
  3260. predicates []predicate.Contact
  3261. }
  3262. var _ ent.Mutation = (*ContactMutation)(nil)
  3263. // contactOption allows management of the mutation configuration using functional options.
  3264. type contactOption func(*ContactMutation)
  3265. // newContactMutation creates new mutation for the Contact entity.
  3266. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  3267. m := &ContactMutation{
  3268. config: c,
  3269. op: op,
  3270. typ: TypeContact,
  3271. clearedFields: make(map[string]struct{}),
  3272. }
  3273. for _, opt := range opts {
  3274. opt(m)
  3275. }
  3276. return m
  3277. }
  3278. // withContactID sets the ID field of the mutation.
  3279. func withContactID(id uint64) contactOption {
  3280. return func(m *ContactMutation) {
  3281. var (
  3282. err error
  3283. once sync.Once
  3284. value *Contact
  3285. )
  3286. m.oldValue = func(ctx context.Context) (*Contact, error) {
  3287. once.Do(func() {
  3288. if m.done {
  3289. err = errors.New("querying old values post mutation is not allowed")
  3290. } else {
  3291. value, err = m.Client().Contact.Get(ctx, id)
  3292. }
  3293. })
  3294. return value, err
  3295. }
  3296. m.id = &id
  3297. }
  3298. }
  3299. // withContact sets the old Contact of the mutation.
  3300. func withContact(node *Contact) contactOption {
  3301. return func(m *ContactMutation) {
  3302. m.oldValue = func(context.Context) (*Contact, error) {
  3303. return node, nil
  3304. }
  3305. m.id = &node.ID
  3306. }
  3307. }
  3308. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3309. // executed in a transaction (ent.Tx), a transactional client is returned.
  3310. func (m ContactMutation) Client() *Client {
  3311. client := &Client{config: m.config}
  3312. client.init()
  3313. return client
  3314. }
  3315. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3316. // it returns an error otherwise.
  3317. func (m ContactMutation) Tx() (*Tx, error) {
  3318. if _, ok := m.driver.(*txDriver); !ok {
  3319. return nil, errors.New("ent: mutation is not running in a transaction")
  3320. }
  3321. tx := &Tx{config: m.config}
  3322. tx.init()
  3323. return tx, nil
  3324. }
  3325. // SetID sets the value of the id field. Note that this
  3326. // operation is only accepted on creation of Contact entities.
  3327. func (m *ContactMutation) SetID(id uint64) {
  3328. m.id = &id
  3329. }
  3330. // ID returns the ID value in the mutation. Note that the ID is only available
  3331. // if it was provided to the builder or after it was returned from the database.
  3332. func (m *ContactMutation) ID() (id uint64, exists bool) {
  3333. if m.id == nil {
  3334. return
  3335. }
  3336. return *m.id, true
  3337. }
  3338. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3339. // That means, if the mutation is applied within a transaction with an isolation level such
  3340. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3341. // or updated by the mutation.
  3342. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  3343. switch {
  3344. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3345. id, exists := m.ID()
  3346. if exists {
  3347. return []uint64{id}, nil
  3348. }
  3349. fallthrough
  3350. case m.op.Is(OpUpdate | OpDelete):
  3351. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  3352. default:
  3353. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3354. }
  3355. }
  3356. // SetCreatedAt sets the "created_at" field.
  3357. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  3358. m.created_at = &t
  3359. }
  3360. // CreatedAt returns the value of the "created_at" field in the mutation.
  3361. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  3362. v := m.created_at
  3363. if v == nil {
  3364. return
  3365. }
  3366. return *v, true
  3367. }
  3368. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  3369. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3371. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3372. if !m.op.Is(OpUpdateOne) {
  3373. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3374. }
  3375. if m.id == nil || m.oldValue == nil {
  3376. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3377. }
  3378. oldValue, err := m.oldValue(ctx)
  3379. if err != nil {
  3380. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3381. }
  3382. return oldValue.CreatedAt, nil
  3383. }
  3384. // ResetCreatedAt resets all changes to the "created_at" field.
  3385. func (m *ContactMutation) ResetCreatedAt() {
  3386. m.created_at = nil
  3387. }
  3388. // SetUpdatedAt sets the "updated_at" field.
  3389. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  3390. m.updated_at = &t
  3391. }
  3392. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3393. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  3394. v := m.updated_at
  3395. if v == nil {
  3396. return
  3397. }
  3398. return *v, true
  3399. }
  3400. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  3401. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3403. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3404. if !m.op.Is(OpUpdateOne) {
  3405. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3406. }
  3407. if m.id == nil || m.oldValue == nil {
  3408. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3409. }
  3410. oldValue, err := m.oldValue(ctx)
  3411. if err != nil {
  3412. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3413. }
  3414. return oldValue.UpdatedAt, nil
  3415. }
  3416. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3417. func (m *ContactMutation) ResetUpdatedAt() {
  3418. m.updated_at = nil
  3419. }
  3420. // SetStatus sets the "status" field.
  3421. func (m *ContactMutation) SetStatus(u uint8) {
  3422. m.status = &u
  3423. m.addstatus = nil
  3424. }
  3425. // Status returns the value of the "status" field in the mutation.
  3426. func (m *ContactMutation) Status() (r uint8, exists bool) {
  3427. v := m.status
  3428. if v == nil {
  3429. return
  3430. }
  3431. return *v, true
  3432. }
  3433. // OldStatus returns the old "status" field's value of the Contact entity.
  3434. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3435. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3436. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  3437. if !m.op.Is(OpUpdateOne) {
  3438. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3439. }
  3440. if m.id == nil || m.oldValue == nil {
  3441. return v, errors.New("OldStatus requires an ID field in the mutation")
  3442. }
  3443. oldValue, err := m.oldValue(ctx)
  3444. if err != nil {
  3445. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3446. }
  3447. return oldValue.Status, nil
  3448. }
  3449. // AddStatus adds u to the "status" field.
  3450. func (m *ContactMutation) AddStatus(u int8) {
  3451. if m.addstatus != nil {
  3452. *m.addstatus += u
  3453. } else {
  3454. m.addstatus = &u
  3455. }
  3456. }
  3457. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3458. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  3459. v := m.addstatus
  3460. if v == nil {
  3461. return
  3462. }
  3463. return *v, true
  3464. }
  3465. // ClearStatus clears the value of the "status" field.
  3466. func (m *ContactMutation) ClearStatus() {
  3467. m.status = nil
  3468. m.addstatus = nil
  3469. m.clearedFields[contact.FieldStatus] = struct{}{}
  3470. }
  3471. // StatusCleared returns if the "status" field was cleared in this mutation.
  3472. func (m *ContactMutation) StatusCleared() bool {
  3473. _, ok := m.clearedFields[contact.FieldStatus]
  3474. return ok
  3475. }
  3476. // ResetStatus resets all changes to the "status" field.
  3477. func (m *ContactMutation) ResetStatus() {
  3478. m.status = nil
  3479. m.addstatus = nil
  3480. delete(m.clearedFields, contact.FieldStatus)
  3481. }
  3482. // SetDeletedAt sets the "deleted_at" field.
  3483. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  3484. m.deleted_at = &t
  3485. }
  3486. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3487. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  3488. v := m.deleted_at
  3489. if v == nil {
  3490. return
  3491. }
  3492. return *v, true
  3493. }
  3494. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  3495. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3497. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3498. if !m.op.Is(OpUpdateOne) {
  3499. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3500. }
  3501. if m.id == nil || m.oldValue == nil {
  3502. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3503. }
  3504. oldValue, err := m.oldValue(ctx)
  3505. if err != nil {
  3506. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3507. }
  3508. return oldValue.DeletedAt, nil
  3509. }
  3510. // ClearDeletedAt clears the value of the "deleted_at" field.
  3511. func (m *ContactMutation) ClearDeletedAt() {
  3512. m.deleted_at = nil
  3513. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  3514. }
  3515. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3516. func (m *ContactMutation) DeletedAtCleared() bool {
  3517. _, ok := m.clearedFields[contact.FieldDeletedAt]
  3518. return ok
  3519. }
  3520. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3521. func (m *ContactMutation) ResetDeletedAt() {
  3522. m.deleted_at = nil
  3523. delete(m.clearedFields, contact.FieldDeletedAt)
  3524. }
  3525. // SetWxWxid sets the "wx_wxid" field.
  3526. func (m *ContactMutation) SetWxWxid(s string) {
  3527. m.wx_wxid = &s
  3528. }
  3529. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  3530. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  3531. v := m.wx_wxid
  3532. if v == nil {
  3533. return
  3534. }
  3535. return *v, true
  3536. }
  3537. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  3538. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3540. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  3541. if !m.op.Is(OpUpdateOne) {
  3542. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  3543. }
  3544. if m.id == nil || m.oldValue == nil {
  3545. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  3546. }
  3547. oldValue, err := m.oldValue(ctx)
  3548. if err != nil {
  3549. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  3550. }
  3551. return oldValue.WxWxid, nil
  3552. }
  3553. // ClearWxWxid clears the value of the "wx_wxid" field.
  3554. func (m *ContactMutation) ClearWxWxid() {
  3555. m.wx_wxid = nil
  3556. m.clearedFields[contact.FieldWxWxid] = struct{}{}
  3557. }
  3558. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  3559. func (m *ContactMutation) WxWxidCleared() bool {
  3560. _, ok := m.clearedFields[contact.FieldWxWxid]
  3561. return ok
  3562. }
  3563. // ResetWxWxid resets all changes to the "wx_wxid" field.
  3564. func (m *ContactMutation) ResetWxWxid() {
  3565. m.wx_wxid = nil
  3566. delete(m.clearedFields, contact.FieldWxWxid)
  3567. }
  3568. // SetType sets the "type" field.
  3569. func (m *ContactMutation) SetType(i int) {
  3570. m._type = &i
  3571. m.add_type = nil
  3572. }
  3573. // GetType returns the value of the "type" field in the mutation.
  3574. func (m *ContactMutation) GetType() (r int, exists bool) {
  3575. v := m._type
  3576. if v == nil {
  3577. return
  3578. }
  3579. return *v, true
  3580. }
  3581. // OldType returns the old "type" field's value of the Contact entity.
  3582. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3583. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3584. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  3585. if !m.op.Is(OpUpdateOne) {
  3586. return v, errors.New("OldType is only allowed on UpdateOne operations")
  3587. }
  3588. if m.id == nil || m.oldValue == nil {
  3589. return v, errors.New("OldType requires an ID field in the mutation")
  3590. }
  3591. oldValue, err := m.oldValue(ctx)
  3592. if err != nil {
  3593. return v, fmt.Errorf("querying old value for OldType: %w", err)
  3594. }
  3595. return oldValue.Type, nil
  3596. }
  3597. // AddType adds i to the "type" field.
  3598. func (m *ContactMutation) AddType(i int) {
  3599. if m.add_type != nil {
  3600. *m.add_type += i
  3601. } else {
  3602. m.add_type = &i
  3603. }
  3604. }
  3605. // AddedType returns the value that was added to the "type" field in this mutation.
  3606. func (m *ContactMutation) AddedType() (r int, exists bool) {
  3607. v := m.add_type
  3608. if v == nil {
  3609. return
  3610. }
  3611. return *v, true
  3612. }
  3613. // ClearType clears the value of the "type" field.
  3614. func (m *ContactMutation) ClearType() {
  3615. m._type = nil
  3616. m.add_type = nil
  3617. m.clearedFields[contact.FieldType] = struct{}{}
  3618. }
  3619. // TypeCleared returns if the "type" field was cleared in this mutation.
  3620. func (m *ContactMutation) TypeCleared() bool {
  3621. _, ok := m.clearedFields[contact.FieldType]
  3622. return ok
  3623. }
  3624. // ResetType resets all changes to the "type" field.
  3625. func (m *ContactMutation) ResetType() {
  3626. m._type = nil
  3627. m.add_type = nil
  3628. delete(m.clearedFields, contact.FieldType)
  3629. }
  3630. // SetWxid sets the "wxid" field.
  3631. func (m *ContactMutation) SetWxid(s string) {
  3632. m.wxid = &s
  3633. }
  3634. // Wxid returns the value of the "wxid" field in the mutation.
  3635. func (m *ContactMutation) Wxid() (r string, exists bool) {
  3636. v := m.wxid
  3637. if v == nil {
  3638. return
  3639. }
  3640. return *v, true
  3641. }
  3642. // OldWxid returns the old "wxid" field's value of the Contact entity.
  3643. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3645. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  3646. if !m.op.Is(OpUpdateOne) {
  3647. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  3648. }
  3649. if m.id == nil || m.oldValue == nil {
  3650. return v, errors.New("OldWxid requires an ID field in the mutation")
  3651. }
  3652. oldValue, err := m.oldValue(ctx)
  3653. if err != nil {
  3654. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  3655. }
  3656. return oldValue.Wxid, nil
  3657. }
  3658. // ResetWxid resets all changes to the "wxid" field.
  3659. func (m *ContactMutation) ResetWxid() {
  3660. m.wxid = nil
  3661. }
  3662. // SetAccount sets the "account" field.
  3663. func (m *ContactMutation) SetAccount(s string) {
  3664. m.account = &s
  3665. }
  3666. // Account returns the value of the "account" field in the mutation.
  3667. func (m *ContactMutation) Account() (r string, exists bool) {
  3668. v := m.account
  3669. if v == nil {
  3670. return
  3671. }
  3672. return *v, true
  3673. }
  3674. // OldAccount returns the old "account" field's value of the Contact entity.
  3675. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3677. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  3678. if !m.op.Is(OpUpdateOne) {
  3679. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  3680. }
  3681. if m.id == nil || m.oldValue == nil {
  3682. return v, errors.New("OldAccount requires an ID field in the mutation")
  3683. }
  3684. oldValue, err := m.oldValue(ctx)
  3685. if err != nil {
  3686. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  3687. }
  3688. return oldValue.Account, nil
  3689. }
  3690. // ResetAccount resets all changes to the "account" field.
  3691. func (m *ContactMutation) ResetAccount() {
  3692. m.account = nil
  3693. }
  3694. // SetNickname sets the "nickname" field.
  3695. func (m *ContactMutation) SetNickname(s string) {
  3696. m.nickname = &s
  3697. }
  3698. // Nickname returns the value of the "nickname" field in the mutation.
  3699. func (m *ContactMutation) Nickname() (r string, exists bool) {
  3700. v := m.nickname
  3701. if v == nil {
  3702. return
  3703. }
  3704. return *v, true
  3705. }
  3706. // OldNickname returns the old "nickname" field's value of the Contact entity.
  3707. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3709. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  3710. if !m.op.Is(OpUpdateOne) {
  3711. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  3712. }
  3713. if m.id == nil || m.oldValue == nil {
  3714. return v, errors.New("OldNickname requires an ID field in the mutation")
  3715. }
  3716. oldValue, err := m.oldValue(ctx)
  3717. if err != nil {
  3718. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  3719. }
  3720. return oldValue.Nickname, nil
  3721. }
  3722. // ResetNickname resets all changes to the "nickname" field.
  3723. func (m *ContactMutation) ResetNickname() {
  3724. m.nickname = nil
  3725. }
  3726. // SetMarkname sets the "markname" field.
  3727. func (m *ContactMutation) SetMarkname(s string) {
  3728. m.markname = &s
  3729. }
  3730. // Markname returns the value of the "markname" field in the mutation.
  3731. func (m *ContactMutation) Markname() (r string, exists bool) {
  3732. v := m.markname
  3733. if v == nil {
  3734. return
  3735. }
  3736. return *v, true
  3737. }
  3738. // OldMarkname returns the old "markname" field's value of the Contact entity.
  3739. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3741. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  3742. if !m.op.Is(OpUpdateOne) {
  3743. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  3744. }
  3745. if m.id == nil || m.oldValue == nil {
  3746. return v, errors.New("OldMarkname requires an ID field in the mutation")
  3747. }
  3748. oldValue, err := m.oldValue(ctx)
  3749. if err != nil {
  3750. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  3751. }
  3752. return oldValue.Markname, nil
  3753. }
  3754. // ResetMarkname resets all changes to the "markname" field.
  3755. func (m *ContactMutation) ResetMarkname() {
  3756. m.markname = nil
  3757. }
  3758. // SetHeadimg sets the "headimg" field.
  3759. func (m *ContactMutation) SetHeadimg(s string) {
  3760. m.headimg = &s
  3761. }
  3762. // Headimg returns the value of the "headimg" field in the mutation.
  3763. func (m *ContactMutation) Headimg() (r string, exists bool) {
  3764. v := m.headimg
  3765. if v == nil {
  3766. return
  3767. }
  3768. return *v, true
  3769. }
  3770. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  3771. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3773. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  3774. if !m.op.Is(OpUpdateOne) {
  3775. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  3776. }
  3777. if m.id == nil || m.oldValue == nil {
  3778. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  3779. }
  3780. oldValue, err := m.oldValue(ctx)
  3781. if err != nil {
  3782. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  3783. }
  3784. return oldValue.Headimg, nil
  3785. }
  3786. // ResetHeadimg resets all changes to the "headimg" field.
  3787. func (m *ContactMutation) ResetHeadimg() {
  3788. m.headimg = nil
  3789. }
  3790. // SetSex sets the "sex" field.
  3791. func (m *ContactMutation) SetSex(i int) {
  3792. m.sex = &i
  3793. m.addsex = nil
  3794. }
  3795. // Sex returns the value of the "sex" field in the mutation.
  3796. func (m *ContactMutation) Sex() (r int, exists bool) {
  3797. v := m.sex
  3798. if v == nil {
  3799. return
  3800. }
  3801. return *v, true
  3802. }
  3803. // OldSex returns the old "sex" field's value of the Contact entity.
  3804. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3806. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  3807. if !m.op.Is(OpUpdateOne) {
  3808. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  3809. }
  3810. if m.id == nil || m.oldValue == nil {
  3811. return v, errors.New("OldSex requires an ID field in the mutation")
  3812. }
  3813. oldValue, err := m.oldValue(ctx)
  3814. if err != nil {
  3815. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  3816. }
  3817. return oldValue.Sex, nil
  3818. }
  3819. // AddSex adds i to the "sex" field.
  3820. func (m *ContactMutation) AddSex(i int) {
  3821. if m.addsex != nil {
  3822. *m.addsex += i
  3823. } else {
  3824. m.addsex = &i
  3825. }
  3826. }
  3827. // AddedSex returns the value that was added to the "sex" field in this mutation.
  3828. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  3829. v := m.addsex
  3830. if v == nil {
  3831. return
  3832. }
  3833. return *v, true
  3834. }
  3835. // ResetSex resets all changes to the "sex" field.
  3836. func (m *ContactMutation) ResetSex() {
  3837. m.sex = nil
  3838. m.addsex = nil
  3839. }
  3840. // SetStarrole sets the "starrole" field.
  3841. func (m *ContactMutation) SetStarrole(s string) {
  3842. m.starrole = &s
  3843. }
  3844. // Starrole returns the value of the "starrole" field in the mutation.
  3845. func (m *ContactMutation) Starrole() (r string, exists bool) {
  3846. v := m.starrole
  3847. if v == nil {
  3848. return
  3849. }
  3850. return *v, true
  3851. }
  3852. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  3853. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3855. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  3856. if !m.op.Is(OpUpdateOne) {
  3857. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  3858. }
  3859. if m.id == nil || m.oldValue == nil {
  3860. return v, errors.New("OldStarrole requires an ID field in the mutation")
  3861. }
  3862. oldValue, err := m.oldValue(ctx)
  3863. if err != nil {
  3864. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  3865. }
  3866. return oldValue.Starrole, nil
  3867. }
  3868. // ResetStarrole resets all changes to the "starrole" field.
  3869. func (m *ContactMutation) ResetStarrole() {
  3870. m.starrole = nil
  3871. }
  3872. // SetDontseeit sets the "dontseeit" field.
  3873. func (m *ContactMutation) SetDontseeit(i int) {
  3874. m.dontseeit = &i
  3875. m.adddontseeit = nil
  3876. }
  3877. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  3878. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  3879. v := m.dontseeit
  3880. if v == nil {
  3881. return
  3882. }
  3883. return *v, true
  3884. }
  3885. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  3886. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3888. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  3889. if !m.op.Is(OpUpdateOne) {
  3890. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  3891. }
  3892. if m.id == nil || m.oldValue == nil {
  3893. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  3894. }
  3895. oldValue, err := m.oldValue(ctx)
  3896. if err != nil {
  3897. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  3898. }
  3899. return oldValue.Dontseeit, nil
  3900. }
  3901. // AddDontseeit adds i to the "dontseeit" field.
  3902. func (m *ContactMutation) AddDontseeit(i int) {
  3903. if m.adddontseeit != nil {
  3904. *m.adddontseeit += i
  3905. } else {
  3906. m.adddontseeit = &i
  3907. }
  3908. }
  3909. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  3910. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  3911. v := m.adddontseeit
  3912. if v == nil {
  3913. return
  3914. }
  3915. return *v, true
  3916. }
  3917. // ResetDontseeit resets all changes to the "dontseeit" field.
  3918. func (m *ContactMutation) ResetDontseeit() {
  3919. m.dontseeit = nil
  3920. m.adddontseeit = nil
  3921. }
  3922. // SetDontseeme sets the "dontseeme" field.
  3923. func (m *ContactMutation) SetDontseeme(i int) {
  3924. m.dontseeme = &i
  3925. m.adddontseeme = nil
  3926. }
  3927. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  3928. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  3929. v := m.dontseeme
  3930. if v == nil {
  3931. return
  3932. }
  3933. return *v, true
  3934. }
  3935. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  3936. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3938. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  3939. if !m.op.Is(OpUpdateOne) {
  3940. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  3941. }
  3942. if m.id == nil || m.oldValue == nil {
  3943. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  3944. }
  3945. oldValue, err := m.oldValue(ctx)
  3946. if err != nil {
  3947. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  3948. }
  3949. return oldValue.Dontseeme, nil
  3950. }
  3951. // AddDontseeme adds i to the "dontseeme" field.
  3952. func (m *ContactMutation) AddDontseeme(i int) {
  3953. if m.adddontseeme != nil {
  3954. *m.adddontseeme += i
  3955. } else {
  3956. m.adddontseeme = &i
  3957. }
  3958. }
  3959. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  3960. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  3961. v := m.adddontseeme
  3962. if v == nil {
  3963. return
  3964. }
  3965. return *v, true
  3966. }
  3967. // ResetDontseeme resets all changes to the "dontseeme" field.
  3968. func (m *ContactMutation) ResetDontseeme() {
  3969. m.dontseeme = nil
  3970. m.adddontseeme = nil
  3971. }
  3972. // SetLag sets the "lag" field.
  3973. func (m *ContactMutation) SetLag(s string) {
  3974. m.lag = &s
  3975. }
  3976. // Lag returns the value of the "lag" field in the mutation.
  3977. func (m *ContactMutation) Lag() (r string, exists bool) {
  3978. v := m.lag
  3979. if v == nil {
  3980. return
  3981. }
  3982. return *v, true
  3983. }
  3984. // OldLag returns the old "lag" field's value of the Contact entity.
  3985. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3987. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  3988. if !m.op.Is(OpUpdateOne) {
  3989. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  3990. }
  3991. if m.id == nil || m.oldValue == nil {
  3992. return v, errors.New("OldLag requires an ID field in the mutation")
  3993. }
  3994. oldValue, err := m.oldValue(ctx)
  3995. if err != nil {
  3996. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  3997. }
  3998. return oldValue.Lag, nil
  3999. }
  4000. // ResetLag resets all changes to the "lag" field.
  4001. func (m *ContactMutation) ResetLag() {
  4002. m.lag = nil
  4003. }
  4004. // SetGid sets the "gid" field.
  4005. func (m *ContactMutation) SetGid(s string) {
  4006. m.gid = &s
  4007. }
  4008. // Gid returns the value of the "gid" field in the mutation.
  4009. func (m *ContactMutation) Gid() (r string, exists bool) {
  4010. v := m.gid
  4011. if v == nil {
  4012. return
  4013. }
  4014. return *v, true
  4015. }
  4016. // OldGid returns the old "gid" field's value of the Contact entity.
  4017. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  4018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4019. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  4020. if !m.op.Is(OpUpdateOne) {
  4021. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  4022. }
  4023. if m.id == nil || m.oldValue == nil {
  4024. return v, errors.New("OldGid requires an ID field in the mutation")
  4025. }
  4026. oldValue, err := m.oldValue(ctx)
  4027. if err != nil {
  4028. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  4029. }
  4030. return oldValue.Gid, nil
  4031. }
  4032. // ResetGid resets all changes to the "gid" field.
  4033. func (m *ContactMutation) ResetGid() {
  4034. m.gid = nil
  4035. }
  4036. // SetGname sets the "gname" field.
  4037. func (m *ContactMutation) SetGname(s string) {
  4038. m.gname = &s
  4039. }
  4040. // Gname returns the value of the "gname" field in the mutation.
  4041. func (m *ContactMutation) Gname() (r string, exists bool) {
  4042. v := m.gname
  4043. if v == nil {
  4044. return
  4045. }
  4046. return *v, true
  4047. }
  4048. // OldGname returns the old "gname" field's value of the Contact entity.
  4049. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  4050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4051. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  4052. if !m.op.Is(OpUpdateOne) {
  4053. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  4054. }
  4055. if m.id == nil || m.oldValue == nil {
  4056. return v, errors.New("OldGname requires an ID field in the mutation")
  4057. }
  4058. oldValue, err := m.oldValue(ctx)
  4059. if err != nil {
  4060. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  4061. }
  4062. return oldValue.Gname, nil
  4063. }
  4064. // ResetGname resets all changes to the "gname" field.
  4065. func (m *ContactMutation) ResetGname() {
  4066. m.gname = nil
  4067. }
  4068. // SetV3 sets the "v3" field.
  4069. func (m *ContactMutation) SetV3(s string) {
  4070. m.v3 = &s
  4071. }
  4072. // V3 returns the value of the "v3" field in the mutation.
  4073. func (m *ContactMutation) V3() (r string, exists bool) {
  4074. v := m.v3
  4075. if v == nil {
  4076. return
  4077. }
  4078. return *v, true
  4079. }
  4080. // OldV3 returns the old "v3" field's value of the Contact entity.
  4081. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  4082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4083. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  4084. if !m.op.Is(OpUpdateOne) {
  4085. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  4086. }
  4087. if m.id == nil || m.oldValue == nil {
  4088. return v, errors.New("OldV3 requires an ID field in the mutation")
  4089. }
  4090. oldValue, err := m.oldValue(ctx)
  4091. if err != nil {
  4092. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  4093. }
  4094. return oldValue.V3, nil
  4095. }
  4096. // ResetV3 resets all changes to the "v3" field.
  4097. func (m *ContactMutation) ResetV3() {
  4098. m.v3 = nil
  4099. }
  4100. // SetOrganizationID sets the "organization_id" field.
  4101. func (m *ContactMutation) SetOrganizationID(u uint64) {
  4102. m.organization_id = &u
  4103. m.addorganization_id = nil
  4104. }
  4105. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4106. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  4107. v := m.organization_id
  4108. if v == nil {
  4109. return
  4110. }
  4111. return *v, true
  4112. }
  4113. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  4114. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  4115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4116. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4117. if !m.op.Is(OpUpdateOne) {
  4118. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4119. }
  4120. if m.id == nil || m.oldValue == nil {
  4121. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4122. }
  4123. oldValue, err := m.oldValue(ctx)
  4124. if err != nil {
  4125. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4126. }
  4127. return oldValue.OrganizationID, nil
  4128. }
  4129. // AddOrganizationID adds u to the "organization_id" field.
  4130. func (m *ContactMutation) AddOrganizationID(u int64) {
  4131. if m.addorganization_id != nil {
  4132. *m.addorganization_id += u
  4133. } else {
  4134. m.addorganization_id = &u
  4135. }
  4136. }
  4137. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4138. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  4139. v := m.addorganization_id
  4140. if v == nil {
  4141. return
  4142. }
  4143. return *v, true
  4144. }
  4145. // ClearOrganizationID clears the value of the "organization_id" field.
  4146. func (m *ContactMutation) ClearOrganizationID() {
  4147. m.organization_id = nil
  4148. m.addorganization_id = nil
  4149. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  4150. }
  4151. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  4152. func (m *ContactMutation) OrganizationIDCleared() bool {
  4153. _, ok := m.clearedFields[contact.FieldOrganizationID]
  4154. return ok
  4155. }
  4156. // ResetOrganizationID resets all changes to the "organization_id" field.
  4157. func (m *ContactMutation) ResetOrganizationID() {
  4158. m.organization_id = nil
  4159. m.addorganization_id = nil
  4160. delete(m.clearedFields, contact.FieldOrganizationID)
  4161. }
  4162. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  4163. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  4164. if m.contact_relationships == nil {
  4165. m.contact_relationships = make(map[uint64]struct{})
  4166. }
  4167. for i := range ids {
  4168. m.contact_relationships[ids[i]] = struct{}{}
  4169. }
  4170. }
  4171. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  4172. func (m *ContactMutation) ClearContactRelationships() {
  4173. m.clearedcontact_relationships = true
  4174. }
  4175. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  4176. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  4177. return m.clearedcontact_relationships
  4178. }
  4179. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  4180. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  4181. if m.removedcontact_relationships == nil {
  4182. m.removedcontact_relationships = make(map[uint64]struct{})
  4183. }
  4184. for i := range ids {
  4185. delete(m.contact_relationships, ids[i])
  4186. m.removedcontact_relationships[ids[i]] = struct{}{}
  4187. }
  4188. }
  4189. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  4190. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  4191. for id := range m.removedcontact_relationships {
  4192. ids = append(ids, id)
  4193. }
  4194. return
  4195. }
  4196. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  4197. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  4198. for id := range m.contact_relationships {
  4199. ids = append(ids, id)
  4200. }
  4201. return
  4202. }
  4203. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  4204. func (m *ContactMutation) ResetContactRelationships() {
  4205. m.contact_relationships = nil
  4206. m.clearedcontact_relationships = false
  4207. m.removedcontact_relationships = nil
  4208. }
  4209. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  4210. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  4211. if m.contact_messages == nil {
  4212. m.contact_messages = make(map[uint64]struct{})
  4213. }
  4214. for i := range ids {
  4215. m.contact_messages[ids[i]] = struct{}{}
  4216. }
  4217. }
  4218. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  4219. func (m *ContactMutation) ClearContactMessages() {
  4220. m.clearedcontact_messages = true
  4221. }
  4222. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  4223. func (m *ContactMutation) ContactMessagesCleared() bool {
  4224. return m.clearedcontact_messages
  4225. }
  4226. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  4227. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  4228. if m.removedcontact_messages == nil {
  4229. m.removedcontact_messages = make(map[uint64]struct{})
  4230. }
  4231. for i := range ids {
  4232. delete(m.contact_messages, ids[i])
  4233. m.removedcontact_messages[ids[i]] = struct{}{}
  4234. }
  4235. }
  4236. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  4237. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  4238. for id := range m.removedcontact_messages {
  4239. ids = append(ids, id)
  4240. }
  4241. return
  4242. }
  4243. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  4244. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  4245. for id := range m.contact_messages {
  4246. ids = append(ids, id)
  4247. }
  4248. return
  4249. }
  4250. // ResetContactMessages resets all changes to the "contact_messages" edge.
  4251. func (m *ContactMutation) ResetContactMessages() {
  4252. m.contact_messages = nil
  4253. m.clearedcontact_messages = false
  4254. m.removedcontact_messages = nil
  4255. }
  4256. // Where appends a list predicates to the ContactMutation builder.
  4257. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  4258. m.predicates = append(m.predicates, ps...)
  4259. }
  4260. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  4261. // users can use type-assertion to append predicates that do not depend on any generated package.
  4262. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  4263. p := make([]predicate.Contact, len(ps))
  4264. for i := range ps {
  4265. p[i] = ps[i]
  4266. }
  4267. m.Where(p...)
  4268. }
  4269. // Op returns the operation name.
  4270. func (m *ContactMutation) Op() Op {
  4271. return m.op
  4272. }
  4273. // SetOp allows setting the mutation operation.
  4274. func (m *ContactMutation) SetOp(op Op) {
  4275. m.op = op
  4276. }
  4277. // Type returns the node type of this mutation (Contact).
  4278. func (m *ContactMutation) Type() string {
  4279. return m.typ
  4280. }
  4281. // Fields returns all fields that were changed during this mutation. Note that in
  4282. // order to get all numeric fields that were incremented/decremented, call
  4283. // AddedFields().
  4284. func (m *ContactMutation) Fields() []string {
  4285. fields := make([]string, 0, 20)
  4286. if m.created_at != nil {
  4287. fields = append(fields, contact.FieldCreatedAt)
  4288. }
  4289. if m.updated_at != nil {
  4290. fields = append(fields, contact.FieldUpdatedAt)
  4291. }
  4292. if m.status != nil {
  4293. fields = append(fields, contact.FieldStatus)
  4294. }
  4295. if m.deleted_at != nil {
  4296. fields = append(fields, contact.FieldDeletedAt)
  4297. }
  4298. if m.wx_wxid != nil {
  4299. fields = append(fields, contact.FieldWxWxid)
  4300. }
  4301. if m._type != nil {
  4302. fields = append(fields, contact.FieldType)
  4303. }
  4304. if m.wxid != nil {
  4305. fields = append(fields, contact.FieldWxid)
  4306. }
  4307. if m.account != nil {
  4308. fields = append(fields, contact.FieldAccount)
  4309. }
  4310. if m.nickname != nil {
  4311. fields = append(fields, contact.FieldNickname)
  4312. }
  4313. if m.markname != nil {
  4314. fields = append(fields, contact.FieldMarkname)
  4315. }
  4316. if m.headimg != nil {
  4317. fields = append(fields, contact.FieldHeadimg)
  4318. }
  4319. if m.sex != nil {
  4320. fields = append(fields, contact.FieldSex)
  4321. }
  4322. if m.starrole != nil {
  4323. fields = append(fields, contact.FieldStarrole)
  4324. }
  4325. if m.dontseeit != nil {
  4326. fields = append(fields, contact.FieldDontseeit)
  4327. }
  4328. if m.dontseeme != nil {
  4329. fields = append(fields, contact.FieldDontseeme)
  4330. }
  4331. if m.lag != nil {
  4332. fields = append(fields, contact.FieldLag)
  4333. }
  4334. if m.gid != nil {
  4335. fields = append(fields, contact.FieldGid)
  4336. }
  4337. if m.gname != nil {
  4338. fields = append(fields, contact.FieldGname)
  4339. }
  4340. if m.v3 != nil {
  4341. fields = append(fields, contact.FieldV3)
  4342. }
  4343. if m.organization_id != nil {
  4344. fields = append(fields, contact.FieldOrganizationID)
  4345. }
  4346. return fields
  4347. }
  4348. // Field returns the value of a field with the given name. The second boolean
  4349. // return value indicates that this field was not set, or was not defined in the
  4350. // schema.
  4351. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  4352. switch name {
  4353. case contact.FieldCreatedAt:
  4354. return m.CreatedAt()
  4355. case contact.FieldUpdatedAt:
  4356. return m.UpdatedAt()
  4357. case contact.FieldStatus:
  4358. return m.Status()
  4359. case contact.FieldDeletedAt:
  4360. return m.DeletedAt()
  4361. case contact.FieldWxWxid:
  4362. return m.WxWxid()
  4363. case contact.FieldType:
  4364. return m.GetType()
  4365. case contact.FieldWxid:
  4366. return m.Wxid()
  4367. case contact.FieldAccount:
  4368. return m.Account()
  4369. case contact.FieldNickname:
  4370. return m.Nickname()
  4371. case contact.FieldMarkname:
  4372. return m.Markname()
  4373. case contact.FieldHeadimg:
  4374. return m.Headimg()
  4375. case contact.FieldSex:
  4376. return m.Sex()
  4377. case contact.FieldStarrole:
  4378. return m.Starrole()
  4379. case contact.FieldDontseeit:
  4380. return m.Dontseeit()
  4381. case contact.FieldDontseeme:
  4382. return m.Dontseeme()
  4383. case contact.FieldLag:
  4384. return m.Lag()
  4385. case contact.FieldGid:
  4386. return m.Gid()
  4387. case contact.FieldGname:
  4388. return m.Gname()
  4389. case contact.FieldV3:
  4390. return m.V3()
  4391. case contact.FieldOrganizationID:
  4392. return m.OrganizationID()
  4393. }
  4394. return nil, false
  4395. }
  4396. // OldField returns the old value of the field from the database. An error is
  4397. // returned if the mutation operation is not UpdateOne, or the query to the
  4398. // database failed.
  4399. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4400. switch name {
  4401. case contact.FieldCreatedAt:
  4402. return m.OldCreatedAt(ctx)
  4403. case contact.FieldUpdatedAt:
  4404. return m.OldUpdatedAt(ctx)
  4405. case contact.FieldStatus:
  4406. return m.OldStatus(ctx)
  4407. case contact.FieldDeletedAt:
  4408. return m.OldDeletedAt(ctx)
  4409. case contact.FieldWxWxid:
  4410. return m.OldWxWxid(ctx)
  4411. case contact.FieldType:
  4412. return m.OldType(ctx)
  4413. case contact.FieldWxid:
  4414. return m.OldWxid(ctx)
  4415. case contact.FieldAccount:
  4416. return m.OldAccount(ctx)
  4417. case contact.FieldNickname:
  4418. return m.OldNickname(ctx)
  4419. case contact.FieldMarkname:
  4420. return m.OldMarkname(ctx)
  4421. case contact.FieldHeadimg:
  4422. return m.OldHeadimg(ctx)
  4423. case contact.FieldSex:
  4424. return m.OldSex(ctx)
  4425. case contact.FieldStarrole:
  4426. return m.OldStarrole(ctx)
  4427. case contact.FieldDontseeit:
  4428. return m.OldDontseeit(ctx)
  4429. case contact.FieldDontseeme:
  4430. return m.OldDontseeme(ctx)
  4431. case contact.FieldLag:
  4432. return m.OldLag(ctx)
  4433. case contact.FieldGid:
  4434. return m.OldGid(ctx)
  4435. case contact.FieldGname:
  4436. return m.OldGname(ctx)
  4437. case contact.FieldV3:
  4438. return m.OldV3(ctx)
  4439. case contact.FieldOrganizationID:
  4440. return m.OldOrganizationID(ctx)
  4441. }
  4442. return nil, fmt.Errorf("unknown Contact field %s", name)
  4443. }
  4444. // SetField sets the value of a field with the given name. It returns an error if
  4445. // the field is not defined in the schema, or if the type mismatched the field
  4446. // type.
  4447. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  4448. switch name {
  4449. case contact.FieldCreatedAt:
  4450. v, ok := value.(time.Time)
  4451. if !ok {
  4452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4453. }
  4454. m.SetCreatedAt(v)
  4455. return nil
  4456. case contact.FieldUpdatedAt:
  4457. v, ok := value.(time.Time)
  4458. if !ok {
  4459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4460. }
  4461. m.SetUpdatedAt(v)
  4462. return nil
  4463. case contact.FieldStatus:
  4464. v, ok := value.(uint8)
  4465. if !ok {
  4466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4467. }
  4468. m.SetStatus(v)
  4469. return nil
  4470. case contact.FieldDeletedAt:
  4471. v, ok := value.(time.Time)
  4472. if !ok {
  4473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4474. }
  4475. m.SetDeletedAt(v)
  4476. return nil
  4477. case contact.FieldWxWxid:
  4478. v, ok := value.(string)
  4479. if !ok {
  4480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4481. }
  4482. m.SetWxWxid(v)
  4483. return nil
  4484. case contact.FieldType:
  4485. v, ok := value.(int)
  4486. if !ok {
  4487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4488. }
  4489. m.SetType(v)
  4490. return nil
  4491. case contact.FieldWxid:
  4492. v, ok := value.(string)
  4493. if !ok {
  4494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4495. }
  4496. m.SetWxid(v)
  4497. return nil
  4498. case contact.FieldAccount:
  4499. v, ok := value.(string)
  4500. if !ok {
  4501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4502. }
  4503. m.SetAccount(v)
  4504. return nil
  4505. case contact.FieldNickname:
  4506. v, ok := value.(string)
  4507. if !ok {
  4508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4509. }
  4510. m.SetNickname(v)
  4511. return nil
  4512. case contact.FieldMarkname:
  4513. v, ok := value.(string)
  4514. if !ok {
  4515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4516. }
  4517. m.SetMarkname(v)
  4518. return nil
  4519. case contact.FieldHeadimg:
  4520. v, ok := value.(string)
  4521. if !ok {
  4522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4523. }
  4524. m.SetHeadimg(v)
  4525. return nil
  4526. case contact.FieldSex:
  4527. v, ok := value.(int)
  4528. if !ok {
  4529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4530. }
  4531. m.SetSex(v)
  4532. return nil
  4533. case contact.FieldStarrole:
  4534. v, ok := value.(string)
  4535. if !ok {
  4536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4537. }
  4538. m.SetStarrole(v)
  4539. return nil
  4540. case contact.FieldDontseeit:
  4541. v, ok := value.(int)
  4542. if !ok {
  4543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4544. }
  4545. m.SetDontseeit(v)
  4546. return nil
  4547. case contact.FieldDontseeme:
  4548. v, ok := value.(int)
  4549. if !ok {
  4550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4551. }
  4552. m.SetDontseeme(v)
  4553. return nil
  4554. case contact.FieldLag:
  4555. v, ok := value.(string)
  4556. if !ok {
  4557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4558. }
  4559. m.SetLag(v)
  4560. return nil
  4561. case contact.FieldGid:
  4562. v, ok := value.(string)
  4563. if !ok {
  4564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4565. }
  4566. m.SetGid(v)
  4567. return nil
  4568. case contact.FieldGname:
  4569. v, ok := value.(string)
  4570. if !ok {
  4571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4572. }
  4573. m.SetGname(v)
  4574. return nil
  4575. case contact.FieldV3:
  4576. v, ok := value.(string)
  4577. if !ok {
  4578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4579. }
  4580. m.SetV3(v)
  4581. return nil
  4582. case contact.FieldOrganizationID:
  4583. v, ok := value.(uint64)
  4584. if !ok {
  4585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4586. }
  4587. m.SetOrganizationID(v)
  4588. return nil
  4589. }
  4590. return fmt.Errorf("unknown Contact field %s", name)
  4591. }
  4592. // AddedFields returns all numeric fields that were incremented/decremented during
  4593. // this mutation.
  4594. func (m *ContactMutation) AddedFields() []string {
  4595. var fields []string
  4596. if m.addstatus != nil {
  4597. fields = append(fields, contact.FieldStatus)
  4598. }
  4599. if m.add_type != nil {
  4600. fields = append(fields, contact.FieldType)
  4601. }
  4602. if m.addsex != nil {
  4603. fields = append(fields, contact.FieldSex)
  4604. }
  4605. if m.adddontseeit != nil {
  4606. fields = append(fields, contact.FieldDontseeit)
  4607. }
  4608. if m.adddontseeme != nil {
  4609. fields = append(fields, contact.FieldDontseeme)
  4610. }
  4611. if m.addorganization_id != nil {
  4612. fields = append(fields, contact.FieldOrganizationID)
  4613. }
  4614. return fields
  4615. }
  4616. // AddedField returns the numeric value that was incremented/decremented on a field
  4617. // with the given name. The second boolean return value indicates that this field
  4618. // was not set, or was not defined in the schema.
  4619. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  4620. switch name {
  4621. case contact.FieldStatus:
  4622. return m.AddedStatus()
  4623. case contact.FieldType:
  4624. return m.AddedType()
  4625. case contact.FieldSex:
  4626. return m.AddedSex()
  4627. case contact.FieldDontseeit:
  4628. return m.AddedDontseeit()
  4629. case contact.FieldDontseeme:
  4630. return m.AddedDontseeme()
  4631. case contact.FieldOrganizationID:
  4632. return m.AddedOrganizationID()
  4633. }
  4634. return nil, false
  4635. }
  4636. // AddField adds the value to the field with the given name. It returns an error if
  4637. // the field is not defined in the schema, or if the type mismatched the field
  4638. // type.
  4639. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  4640. switch name {
  4641. case contact.FieldStatus:
  4642. v, ok := value.(int8)
  4643. if !ok {
  4644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4645. }
  4646. m.AddStatus(v)
  4647. return nil
  4648. case contact.FieldType:
  4649. v, ok := value.(int)
  4650. if !ok {
  4651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4652. }
  4653. m.AddType(v)
  4654. return nil
  4655. case contact.FieldSex:
  4656. v, ok := value.(int)
  4657. if !ok {
  4658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4659. }
  4660. m.AddSex(v)
  4661. return nil
  4662. case contact.FieldDontseeit:
  4663. v, ok := value.(int)
  4664. if !ok {
  4665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4666. }
  4667. m.AddDontseeit(v)
  4668. return nil
  4669. case contact.FieldDontseeme:
  4670. v, ok := value.(int)
  4671. if !ok {
  4672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4673. }
  4674. m.AddDontseeme(v)
  4675. return nil
  4676. case contact.FieldOrganizationID:
  4677. v, ok := value.(int64)
  4678. if !ok {
  4679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4680. }
  4681. m.AddOrganizationID(v)
  4682. return nil
  4683. }
  4684. return fmt.Errorf("unknown Contact numeric field %s", name)
  4685. }
  4686. // ClearedFields returns all nullable fields that were cleared during this
  4687. // mutation.
  4688. func (m *ContactMutation) ClearedFields() []string {
  4689. var fields []string
  4690. if m.FieldCleared(contact.FieldStatus) {
  4691. fields = append(fields, contact.FieldStatus)
  4692. }
  4693. if m.FieldCleared(contact.FieldDeletedAt) {
  4694. fields = append(fields, contact.FieldDeletedAt)
  4695. }
  4696. if m.FieldCleared(contact.FieldWxWxid) {
  4697. fields = append(fields, contact.FieldWxWxid)
  4698. }
  4699. if m.FieldCleared(contact.FieldType) {
  4700. fields = append(fields, contact.FieldType)
  4701. }
  4702. if m.FieldCleared(contact.FieldOrganizationID) {
  4703. fields = append(fields, contact.FieldOrganizationID)
  4704. }
  4705. return fields
  4706. }
  4707. // FieldCleared returns a boolean indicating if a field with the given name was
  4708. // cleared in this mutation.
  4709. func (m *ContactMutation) FieldCleared(name string) bool {
  4710. _, ok := m.clearedFields[name]
  4711. return ok
  4712. }
  4713. // ClearField clears the value of the field with the given name. It returns an
  4714. // error if the field is not defined in the schema.
  4715. func (m *ContactMutation) ClearField(name string) error {
  4716. switch name {
  4717. case contact.FieldStatus:
  4718. m.ClearStatus()
  4719. return nil
  4720. case contact.FieldDeletedAt:
  4721. m.ClearDeletedAt()
  4722. return nil
  4723. case contact.FieldWxWxid:
  4724. m.ClearWxWxid()
  4725. return nil
  4726. case contact.FieldType:
  4727. m.ClearType()
  4728. return nil
  4729. case contact.FieldOrganizationID:
  4730. m.ClearOrganizationID()
  4731. return nil
  4732. }
  4733. return fmt.Errorf("unknown Contact nullable field %s", name)
  4734. }
  4735. // ResetField resets all changes in the mutation for the field with the given name.
  4736. // It returns an error if the field is not defined in the schema.
  4737. func (m *ContactMutation) ResetField(name string) error {
  4738. switch name {
  4739. case contact.FieldCreatedAt:
  4740. m.ResetCreatedAt()
  4741. return nil
  4742. case contact.FieldUpdatedAt:
  4743. m.ResetUpdatedAt()
  4744. return nil
  4745. case contact.FieldStatus:
  4746. m.ResetStatus()
  4747. return nil
  4748. case contact.FieldDeletedAt:
  4749. m.ResetDeletedAt()
  4750. return nil
  4751. case contact.FieldWxWxid:
  4752. m.ResetWxWxid()
  4753. return nil
  4754. case contact.FieldType:
  4755. m.ResetType()
  4756. return nil
  4757. case contact.FieldWxid:
  4758. m.ResetWxid()
  4759. return nil
  4760. case contact.FieldAccount:
  4761. m.ResetAccount()
  4762. return nil
  4763. case contact.FieldNickname:
  4764. m.ResetNickname()
  4765. return nil
  4766. case contact.FieldMarkname:
  4767. m.ResetMarkname()
  4768. return nil
  4769. case contact.FieldHeadimg:
  4770. m.ResetHeadimg()
  4771. return nil
  4772. case contact.FieldSex:
  4773. m.ResetSex()
  4774. return nil
  4775. case contact.FieldStarrole:
  4776. m.ResetStarrole()
  4777. return nil
  4778. case contact.FieldDontseeit:
  4779. m.ResetDontseeit()
  4780. return nil
  4781. case contact.FieldDontseeme:
  4782. m.ResetDontseeme()
  4783. return nil
  4784. case contact.FieldLag:
  4785. m.ResetLag()
  4786. return nil
  4787. case contact.FieldGid:
  4788. m.ResetGid()
  4789. return nil
  4790. case contact.FieldGname:
  4791. m.ResetGname()
  4792. return nil
  4793. case contact.FieldV3:
  4794. m.ResetV3()
  4795. return nil
  4796. case contact.FieldOrganizationID:
  4797. m.ResetOrganizationID()
  4798. return nil
  4799. }
  4800. return fmt.Errorf("unknown Contact field %s", name)
  4801. }
  4802. // AddedEdges returns all edge names that were set/added in this mutation.
  4803. func (m *ContactMutation) AddedEdges() []string {
  4804. edges := make([]string, 0, 2)
  4805. if m.contact_relationships != nil {
  4806. edges = append(edges, contact.EdgeContactRelationships)
  4807. }
  4808. if m.contact_messages != nil {
  4809. edges = append(edges, contact.EdgeContactMessages)
  4810. }
  4811. return edges
  4812. }
  4813. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4814. // name in this mutation.
  4815. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  4816. switch name {
  4817. case contact.EdgeContactRelationships:
  4818. ids := make([]ent.Value, 0, len(m.contact_relationships))
  4819. for id := range m.contact_relationships {
  4820. ids = append(ids, id)
  4821. }
  4822. return ids
  4823. case contact.EdgeContactMessages:
  4824. ids := make([]ent.Value, 0, len(m.contact_messages))
  4825. for id := range m.contact_messages {
  4826. ids = append(ids, id)
  4827. }
  4828. return ids
  4829. }
  4830. return nil
  4831. }
  4832. // RemovedEdges returns all edge names that were removed in this mutation.
  4833. func (m *ContactMutation) RemovedEdges() []string {
  4834. edges := make([]string, 0, 2)
  4835. if m.removedcontact_relationships != nil {
  4836. edges = append(edges, contact.EdgeContactRelationships)
  4837. }
  4838. if m.removedcontact_messages != nil {
  4839. edges = append(edges, contact.EdgeContactMessages)
  4840. }
  4841. return edges
  4842. }
  4843. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4844. // the given name in this mutation.
  4845. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  4846. switch name {
  4847. case contact.EdgeContactRelationships:
  4848. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  4849. for id := range m.removedcontact_relationships {
  4850. ids = append(ids, id)
  4851. }
  4852. return ids
  4853. case contact.EdgeContactMessages:
  4854. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  4855. for id := range m.removedcontact_messages {
  4856. ids = append(ids, id)
  4857. }
  4858. return ids
  4859. }
  4860. return nil
  4861. }
  4862. // ClearedEdges returns all edge names that were cleared in this mutation.
  4863. func (m *ContactMutation) ClearedEdges() []string {
  4864. edges := make([]string, 0, 2)
  4865. if m.clearedcontact_relationships {
  4866. edges = append(edges, contact.EdgeContactRelationships)
  4867. }
  4868. if m.clearedcontact_messages {
  4869. edges = append(edges, contact.EdgeContactMessages)
  4870. }
  4871. return edges
  4872. }
  4873. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4874. // was cleared in this mutation.
  4875. func (m *ContactMutation) EdgeCleared(name string) bool {
  4876. switch name {
  4877. case contact.EdgeContactRelationships:
  4878. return m.clearedcontact_relationships
  4879. case contact.EdgeContactMessages:
  4880. return m.clearedcontact_messages
  4881. }
  4882. return false
  4883. }
  4884. // ClearEdge clears the value of the edge with the given name. It returns an error
  4885. // if that edge is not defined in the schema.
  4886. func (m *ContactMutation) ClearEdge(name string) error {
  4887. switch name {
  4888. }
  4889. return fmt.Errorf("unknown Contact unique edge %s", name)
  4890. }
  4891. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4892. // It returns an error if the edge is not defined in the schema.
  4893. func (m *ContactMutation) ResetEdge(name string) error {
  4894. switch name {
  4895. case contact.EdgeContactRelationships:
  4896. m.ResetContactRelationships()
  4897. return nil
  4898. case contact.EdgeContactMessages:
  4899. m.ResetContactMessages()
  4900. return nil
  4901. }
  4902. return fmt.Errorf("unknown Contact edge %s", name)
  4903. }
  4904. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  4905. type EmployeeMutation struct {
  4906. config
  4907. op Op
  4908. typ string
  4909. id *uint64
  4910. created_at *time.Time
  4911. updated_at *time.Time
  4912. deleted_at *time.Time
  4913. title *string
  4914. avatar *string
  4915. tags *string
  4916. hire_count *int
  4917. addhire_count *int
  4918. service_count *int
  4919. addservice_count *int
  4920. achievement_count *int
  4921. addachievement_count *int
  4922. intro *string
  4923. estimate *string
  4924. skill *string
  4925. ability_type *string
  4926. scene *string
  4927. switch_in *string
  4928. video_url *string
  4929. organization_id *uint64
  4930. addorganization_id *int64
  4931. category_id *uint64
  4932. addcategory_id *int64
  4933. clearedFields map[string]struct{}
  4934. em_work_experiences map[uint64]struct{}
  4935. removedem_work_experiences map[uint64]struct{}
  4936. clearedem_work_experiences bool
  4937. em_tutorial map[uint64]struct{}
  4938. removedem_tutorial map[uint64]struct{}
  4939. clearedem_tutorial bool
  4940. done bool
  4941. oldValue func(context.Context) (*Employee, error)
  4942. predicates []predicate.Employee
  4943. }
  4944. var _ ent.Mutation = (*EmployeeMutation)(nil)
  4945. // employeeOption allows management of the mutation configuration using functional options.
  4946. type employeeOption func(*EmployeeMutation)
  4947. // newEmployeeMutation creates new mutation for the Employee entity.
  4948. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  4949. m := &EmployeeMutation{
  4950. config: c,
  4951. op: op,
  4952. typ: TypeEmployee,
  4953. clearedFields: make(map[string]struct{}),
  4954. }
  4955. for _, opt := range opts {
  4956. opt(m)
  4957. }
  4958. return m
  4959. }
  4960. // withEmployeeID sets the ID field of the mutation.
  4961. func withEmployeeID(id uint64) employeeOption {
  4962. return func(m *EmployeeMutation) {
  4963. var (
  4964. err error
  4965. once sync.Once
  4966. value *Employee
  4967. )
  4968. m.oldValue = func(ctx context.Context) (*Employee, error) {
  4969. once.Do(func() {
  4970. if m.done {
  4971. err = errors.New("querying old values post mutation is not allowed")
  4972. } else {
  4973. value, err = m.Client().Employee.Get(ctx, id)
  4974. }
  4975. })
  4976. return value, err
  4977. }
  4978. m.id = &id
  4979. }
  4980. }
  4981. // withEmployee sets the old Employee of the mutation.
  4982. func withEmployee(node *Employee) employeeOption {
  4983. return func(m *EmployeeMutation) {
  4984. m.oldValue = func(context.Context) (*Employee, error) {
  4985. return node, nil
  4986. }
  4987. m.id = &node.ID
  4988. }
  4989. }
  4990. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4991. // executed in a transaction (ent.Tx), a transactional client is returned.
  4992. func (m EmployeeMutation) Client() *Client {
  4993. client := &Client{config: m.config}
  4994. client.init()
  4995. return client
  4996. }
  4997. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4998. // it returns an error otherwise.
  4999. func (m EmployeeMutation) Tx() (*Tx, error) {
  5000. if _, ok := m.driver.(*txDriver); !ok {
  5001. return nil, errors.New("ent: mutation is not running in a transaction")
  5002. }
  5003. tx := &Tx{config: m.config}
  5004. tx.init()
  5005. return tx, nil
  5006. }
  5007. // SetID sets the value of the id field. Note that this
  5008. // operation is only accepted on creation of Employee entities.
  5009. func (m *EmployeeMutation) SetID(id uint64) {
  5010. m.id = &id
  5011. }
  5012. // ID returns the ID value in the mutation. Note that the ID is only available
  5013. // if it was provided to the builder or after it was returned from the database.
  5014. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  5015. if m.id == nil {
  5016. return
  5017. }
  5018. return *m.id, true
  5019. }
  5020. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5021. // That means, if the mutation is applied within a transaction with an isolation level such
  5022. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5023. // or updated by the mutation.
  5024. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  5025. switch {
  5026. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5027. id, exists := m.ID()
  5028. if exists {
  5029. return []uint64{id}, nil
  5030. }
  5031. fallthrough
  5032. case m.op.Is(OpUpdate | OpDelete):
  5033. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  5034. default:
  5035. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5036. }
  5037. }
  5038. // SetCreatedAt sets the "created_at" field.
  5039. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  5040. m.created_at = &t
  5041. }
  5042. // CreatedAt returns the value of the "created_at" field in the mutation.
  5043. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  5044. v := m.created_at
  5045. if v == nil {
  5046. return
  5047. }
  5048. return *v, true
  5049. }
  5050. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  5051. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5053. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5054. if !m.op.Is(OpUpdateOne) {
  5055. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5056. }
  5057. if m.id == nil || m.oldValue == nil {
  5058. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5059. }
  5060. oldValue, err := m.oldValue(ctx)
  5061. if err != nil {
  5062. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5063. }
  5064. return oldValue.CreatedAt, nil
  5065. }
  5066. // ResetCreatedAt resets all changes to the "created_at" field.
  5067. func (m *EmployeeMutation) ResetCreatedAt() {
  5068. m.created_at = nil
  5069. }
  5070. // SetUpdatedAt sets the "updated_at" field.
  5071. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  5072. m.updated_at = &t
  5073. }
  5074. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5075. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  5076. v := m.updated_at
  5077. if v == nil {
  5078. return
  5079. }
  5080. return *v, true
  5081. }
  5082. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  5083. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5085. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5086. if !m.op.Is(OpUpdateOne) {
  5087. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5088. }
  5089. if m.id == nil || m.oldValue == nil {
  5090. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5091. }
  5092. oldValue, err := m.oldValue(ctx)
  5093. if err != nil {
  5094. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5095. }
  5096. return oldValue.UpdatedAt, nil
  5097. }
  5098. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5099. func (m *EmployeeMutation) ResetUpdatedAt() {
  5100. m.updated_at = nil
  5101. }
  5102. // SetDeletedAt sets the "deleted_at" field.
  5103. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  5104. m.deleted_at = &t
  5105. }
  5106. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5107. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  5108. v := m.deleted_at
  5109. if v == nil {
  5110. return
  5111. }
  5112. return *v, true
  5113. }
  5114. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  5115. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5116. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5117. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5118. if !m.op.Is(OpUpdateOne) {
  5119. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5120. }
  5121. if m.id == nil || m.oldValue == nil {
  5122. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5123. }
  5124. oldValue, err := m.oldValue(ctx)
  5125. if err != nil {
  5126. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5127. }
  5128. return oldValue.DeletedAt, nil
  5129. }
  5130. // ClearDeletedAt clears the value of the "deleted_at" field.
  5131. func (m *EmployeeMutation) ClearDeletedAt() {
  5132. m.deleted_at = nil
  5133. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  5134. }
  5135. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5136. func (m *EmployeeMutation) DeletedAtCleared() bool {
  5137. _, ok := m.clearedFields[employee.FieldDeletedAt]
  5138. return ok
  5139. }
  5140. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5141. func (m *EmployeeMutation) ResetDeletedAt() {
  5142. m.deleted_at = nil
  5143. delete(m.clearedFields, employee.FieldDeletedAt)
  5144. }
  5145. // SetTitle sets the "title" field.
  5146. func (m *EmployeeMutation) SetTitle(s string) {
  5147. m.title = &s
  5148. }
  5149. // Title returns the value of the "title" field in the mutation.
  5150. func (m *EmployeeMutation) Title() (r string, exists bool) {
  5151. v := m.title
  5152. if v == nil {
  5153. return
  5154. }
  5155. return *v, true
  5156. }
  5157. // OldTitle returns the old "title" field's value of the Employee entity.
  5158. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5160. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  5161. if !m.op.Is(OpUpdateOne) {
  5162. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  5163. }
  5164. if m.id == nil || m.oldValue == nil {
  5165. return v, errors.New("OldTitle requires an ID field in the mutation")
  5166. }
  5167. oldValue, err := m.oldValue(ctx)
  5168. if err != nil {
  5169. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  5170. }
  5171. return oldValue.Title, nil
  5172. }
  5173. // ResetTitle resets all changes to the "title" field.
  5174. func (m *EmployeeMutation) ResetTitle() {
  5175. m.title = nil
  5176. }
  5177. // SetAvatar sets the "avatar" field.
  5178. func (m *EmployeeMutation) SetAvatar(s string) {
  5179. m.avatar = &s
  5180. }
  5181. // Avatar returns the value of the "avatar" field in the mutation.
  5182. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  5183. v := m.avatar
  5184. if v == nil {
  5185. return
  5186. }
  5187. return *v, true
  5188. }
  5189. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  5190. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5192. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  5193. if !m.op.Is(OpUpdateOne) {
  5194. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  5195. }
  5196. if m.id == nil || m.oldValue == nil {
  5197. return v, errors.New("OldAvatar requires an ID field in the mutation")
  5198. }
  5199. oldValue, err := m.oldValue(ctx)
  5200. if err != nil {
  5201. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  5202. }
  5203. return oldValue.Avatar, nil
  5204. }
  5205. // ResetAvatar resets all changes to the "avatar" field.
  5206. func (m *EmployeeMutation) ResetAvatar() {
  5207. m.avatar = nil
  5208. }
  5209. // SetTags sets the "tags" field.
  5210. func (m *EmployeeMutation) SetTags(s string) {
  5211. m.tags = &s
  5212. }
  5213. // Tags returns the value of the "tags" field in the mutation.
  5214. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  5215. v := m.tags
  5216. if v == nil {
  5217. return
  5218. }
  5219. return *v, true
  5220. }
  5221. // OldTags returns the old "tags" field's value of the Employee entity.
  5222. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5224. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  5225. if !m.op.Is(OpUpdateOne) {
  5226. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  5227. }
  5228. if m.id == nil || m.oldValue == nil {
  5229. return v, errors.New("OldTags requires an ID field in the mutation")
  5230. }
  5231. oldValue, err := m.oldValue(ctx)
  5232. if err != nil {
  5233. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  5234. }
  5235. return oldValue.Tags, nil
  5236. }
  5237. // ResetTags resets all changes to the "tags" field.
  5238. func (m *EmployeeMutation) ResetTags() {
  5239. m.tags = nil
  5240. }
  5241. // SetHireCount sets the "hire_count" field.
  5242. func (m *EmployeeMutation) SetHireCount(i int) {
  5243. m.hire_count = &i
  5244. m.addhire_count = nil
  5245. }
  5246. // HireCount returns the value of the "hire_count" field in the mutation.
  5247. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  5248. v := m.hire_count
  5249. if v == nil {
  5250. return
  5251. }
  5252. return *v, true
  5253. }
  5254. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  5255. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5257. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  5258. if !m.op.Is(OpUpdateOne) {
  5259. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  5260. }
  5261. if m.id == nil || m.oldValue == nil {
  5262. return v, errors.New("OldHireCount requires an ID field in the mutation")
  5263. }
  5264. oldValue, err := m.oldValue(ctx)
  5265. if err != nil {
  5266. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  5267. }
  5268. return oldValue.HireCount, nil
  5269. }
  5270. // AddHireCount adds i to the "hire_count" field.
  5271. func (m *EmployeeMutation) AddHireCount(i int) {
  5272. if m.addhire_count != nil {
  5273. *m.addhire_count += i
  5274. } else {
  5275. m.addhire_count = &i
  5276. }
  5277. }
  5278. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  5279. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  5280. v := m.addhire_count
  5281. if v == nil {
  5282. return
  5283. }
  5284. return *v, true
  5285. }
  5286. // ResetHireCount resets all changes to the "hire_count" field.
  5287. func (m *EmployeeMutation) ResetHireCount() {
  5288. m.hire_count = nil
  5289. m.addhire_count = nil
  5290. }
  5291. // SetServiceCount sets the "service_count" field.
  5292. func (m *EmployeeMutation) SetServiceCount(i int) {
  5293. m.service_count = &i
  5294. m.addservice_count = nil
  5295. }
  5296. // ServiceCount returns the value of the "service_count" field in the mutation.
  5297. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  5298. v := m.service_count
  5299. if v == nil {
  5300. return
  5301. }
  5302. return *v, true
  5303. }
  5304. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  5305. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5307. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  5308. if !m.op.Is(OpUpdateOne) {
  5309. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  5310. }
  5311. if m.id == nil || m.oldValue == nil {
  5312. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  5313. }
  5314. oldValue, err := m.oldValue(ctx)
  5315. if err != nil {
  5316. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  5317. }
  5318. return oldValue.ServiceCount, nil
  5319. }
  5320. // AddServiceCount adds i to the "service_count" field.
  5321. func (m *EmployeeMutation) AddServiceCount(i int) {
  5322. if m.addservice_count != nil {
  5323. *m.addservice_count += i
  5324. } else {
  5325. m.addservice_count = &i
  5326. }
  5327. }
  5328. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  5329. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  5330. v := m.addservice_count
  5331. if v == nil {
  5332. return
  5333. }
  5334. return *v, true
  5335. }
  5336. // ResetServiceCount resets all changes to the "service_count" field.
  5337. func (m *EmployeeMutation) ResetServiceCount() {
  5338. m.service_count = nil
  5339. m.addservice_count = nil
  5340. }
  5341. // SetAchievementCount sets the "achievement_count" field.
  5342. func (m *EmployeeMutation) SetAchievementCount(i int) {
  5343. m.achievement_count = &i
  5344. m.addachievement_count = nil
  5345. }
  5346. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  5347. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  5348. v := m.achievement_count
  5349. if v == nil {
  5350. return
  5351. }
  5352. return *v, true
  5353. }
  5354. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  5355. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5357. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  5358. if !m.op.Is(OpUpdateOne) {
  5359. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  5360. }
  5361. if m.id == nil || m.oldValue == nil {
  5362. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  5363. }
  5364. oldValue, err := m.oldValue(ctx)
  5365. if err != nil {
  5366. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  5367. }
  5368. return oldValue.AchievementCount, nil
  5369. }
  5370. // AddAchievementCount adds i to the "achievement_count" field.
  5371. func (m *EmployeeMutation) AddAchievementCount(i int) {
  5372. if m.addachievement_count != nil {
  5373. *m.addachievement_count += i
  5374. } else {
  5375. m.addachievement_count = &i
  5376. }
  5377. }
  5378. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  5379. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  5380. v := m.addachievement_count
  5381. if v == nil {
  5382. return
  5383. }
  5384. return *v, true
  5385. }
  5386. // ResetAchievementCount resets all changes to the "achievement_count" field.
  5387. func (m *EmployeeMutation) ResetAchievementCount() {
  5388. m.achievement_count = nil
  5389. m.addachievement_count = nil
  5390. }
  5391. // SetIntro sets the "intro" field.
  5392. func (m *EmployeeMutation) SetIntro(s string) {
  5393. m.intro = &s
  5394. }
  5395. // Intro returns the value of the "intro" field in the mutation.
  5396. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  5397. v := m.intro
  5398. if v == nil {
  5399. return
  5400. }
  5401. return *v, true
  5402. }
  5403. // OldIntro returns the old "intro" field's value of the Employee entity.
  5404. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5406. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  5407. if !m.op.Is(OpUpdateOne) {
  5408. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  5409. }
  5410. if m.id == nil || m.oldValue == nil {
  5411. return v, errors.New("OldIntro requires an ID field in the mutation")
  5412. }
  5413. oldValue, err := m.oldValue(ctx)
  5414. if err != nil {
  5415. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  5416. }
  5417. return oldValue.Intro, nil
  5418. }
  5419. // ResetIntro resets all changes to the "intro" field.
  5420. func (m *EmployeeMutation) ResetIntro() {
  5421. m.intro = nil
  5422. }
  5423. // SetEstimate sets the "estimate" field.
  5424. func (m *EmployeeMutation) SetEstimate(s string) {
  5425. m.estimate = &s
  5426. }
  5427. // Estimate returns the value of the "estimate" field in the mutation.
  5428. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  5429. v := m.estimate
  5430. if v == nil {
  5431. return
  5432. }
  5433. return *v, true
  5434. }
  5435. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  5436. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5438. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  5439. if !m.op.Is(OpUpdateOne) {
  5440. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  5441. }
  5442. if m.id == nil || m.oldValue == nil {
  5443. return v, errors.New("OldEstimate requires an ID field in the mutation")
  5444. }
  5445. oldValue, err := m.oldValue(ctx)
  5446. if err != nil {
  5447. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  5448. }
  5449. return oldValue.Estimate, nil
  5450. }
  5451. // ResetEstimate resets all changes to the "estimate" field.
  5452. func (m *EmployeeMutation) ResetEstimate() {
  5453. m.estimate = nil
  5454. }
  5455. // SetSkill sets the "skill" field.
  5456. func (m *EmployeeMutation) SetSkill(s string) {
  5457. m.skill = &s
  5458. }
  5459. // Skill returns the value of the "skill" field in the mutation.
  5460. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  5461. v := m.skill
  5462. if v == nil {
  5463. return
  5464. }
  5465. return *v, true
  5466. }
  5467. // OldSkill returns the old "skill" field's value of the Employee entity.
  5468. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5470. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  5471. if !m.op.Is(OpUpdateOne) {
  5472. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  5473. }
  5474. if m.id == nil || m.oldValue == nil {
  5475. return v, errors.New("OldSkill requires an ID field in the mutation")
  5476. }
  5477. oldValue, err := m.oldValue(ctx)
  5478. if err != nil {
  5479. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  5480. }
  5481. return oldValue.Skill, nil
  5482. }
  5483. // ResetSkill resets all changes to the "skill" field.
  5484. func (m *EmployeeMutation) ResetSkill() {
  5485. m.skill = nil
  5486. }
  5487. // SetAbilityType sets the "ability_type" field.
  5488. func (m *EmployeeMutation) SetAbilityType(s string) {
  5489. m.ability_type = &s
  5490. }
  5491. // AbilityType returns the value of the "ability_type" field in the mutation.
  5492. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  5493. v := m.ability_type
  5494. if v == nil {
  5495. return
  5496. }
  5497. return *v, true
  5498. }
  5499. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  5500. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5501. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5502. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  5503. if !m.op.Is(OpUpdateOne) {
  5504. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  5505. }
  5506. if m.id == nil || m.oldValue == nil {
  5507. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  5508. }
  5509. oldValue, err := m.oldValue(ctx)
  5510. if err != nil {
  5511. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  5512. }
  5513. return oldValue.AbilityType, nil
  5514. }
  5515. // ResetAbilityType resets all changes to the "ability_type" field.
  5516. func (m *EmployeeMutation) ResetAbilityType() {
  5517. m.ability_type = nil
  5518. }
  5519. // SetScene sets the "scene" field.
  5520. func (m *EmployeeMutation) SetScene(s string) {
  5521. m.scene = &s
  5522. }
  5523. // Scene returns the value of the "scene" field in the mutation.
  5524. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  5525. v := m.scene
  5526. if v == nil {
  5527. return
  5528. }
  5529. return *v, true
  5530. }
  5531. // OldScene returns the old "scene" field's value of the Employee entity.
  5532. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5534. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  5535. if !m.op.Is(OpUpdateOne) {
  5536. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  5537. }
  5538. if m.id == nil || m.oldValue == nil {
  5539. return v, errors.New("OldScene requires an ID field in the mutation")
  5540. }
  5541. oldValue, err := m.oldValue(ctx)
  5542. if err != nil {
  5543. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  5544. }
  5545. return oldValue.Scene, nil
  5546. }
  5547. // ResetScene resets all changes to the "scene" field.
  5548. func (m *EmployeeMutation) ResetScene() {
  5549. m.scene = nil
  5550. }
  5551. // SetSwitchIn sets the "switch_in" field.
  5552. func (m *EmployeeMutation) SetSwitchIn(s string) {
  5553. m.switch_in = &s
  5554. }
  5555. // SwitchIn returns the value of the "switch_in" field in the mutation.
  5556. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  5557. v := m.switch_in
  5558. if v == nil {
  5559. return
  5560. }
  5561. return *v, true
  5562. }
  5563. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  5564. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5566. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  5567. if !m.op.Is(OpUpdateOne) {
  5568. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  5569. }
  5570. if m.id == nil || m.oldValue == nil {
  5571. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  5572. }
  5573. oldValue, err := m.oldValue(ctx)
  5574. if err != nil {
  5575. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  5576. }
  5577. return oldValue.SwitchIn, nil
  5578. }
  5579. // ResetSwitchIn resets all changes to the "switch_in" field.
  5580. func (m *EmployeeMutation) ResetSwitchIn() {
  5581. m.switch_in = nil
  5582. }
  5583. // SetVideoURL sets the "video_url" field.
  5584. func (m *EmployeeMutation) SetVideoURL(s string) {
  5585. m.video_url = &s
  5586. }
  5587. // VideoURL returns the value of the "video_url" field in the mutation.
  5588. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  5589. v := m.video_url
  5590. if v == nil {
  5591. return
  5592. }
  5593. return *v, true
  5594. }
  5595. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  5596. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5598. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  5599. if !m.op.Is(OpUpdateOne) {
  5600. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  5601. }
  5602. if m.id == nil || m.oldValue == nil {
  5603. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  5604. }
  5605. oldValue, err := m.oldValue(ctx)
  5606. if err != nil {
  5607. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  5608. }
  5609. return oldValue.VideoURL, nil
  5610. }
  5611. // ResetVideoURL resets all changes to the "video_url" field.
  5612. func (m *EmployeeMutation) ResetVideoURL() {
  5613. m.video_url = nil
  5614. }
  5615. // SetOrganizationID sets the "organization_id" field.
  5616. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  5617. m.organization_id = &u
  5618. m.addorganization_id = nil
  5619. }
  5620. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5621. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  5622. v := m.organization_id
  5623. if v == nil {
  5624. return
  5625. }
  5626. return *v, true
  5627. }
  5628. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  5629. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5631. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5632. if !m.op.Is(OpUpdateOne) {
  5633. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5634. }
  5635. if m.id == nil || m.oldValue == nil {
  5636. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5637. }
  5638. oldValue, err := m.oldValue(ctx)
  5639. if err != nil {
  5640. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5641. }
  5642. return oldValue.OrganizationID, nil
  5643. }
  5644. // AddOrganizationID adds u to the "organization_id" field.
  5645. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  5646. if m.addorganization_id != nil {
  5647. *m.addorganization_id += u
  5648. } else {
  5649. m.addorganization_id = &u
  5650. }
  5651. }
  5652. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5653. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  5654. v := m.addorganization_id
  5655. if v == nil {
  5656. return
  5657. }
  5658. return *v, true
  5659. }
  5660. // ResetOrganizationID resets all changes to the "organization_id" field.
  5661. func (m *EmployeeMutation) ResetOrganizationID() {
  5662. m.organization_id = nil
  5663. m.addorganization_id = nil
  5664. }
  5665. // SetCategoryID sets the "category_id" field.
  5666. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  5667. m.category_id = &u
  5668. m.addcategory_id = nil
  5669. }
  5670. // CategoryID returns the value of the "category_id" field in the mutation.
  5671. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  5672. v := m.category_id
  5673. if v == nil {
  5674. return
  5675. }
  5676. return *v, true
  5677. }
  5678. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  5679. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5681. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  5682. if !m.op.Is(OpUpdateOne) {
  5683. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  5684. }
  5685. if m.id == nil || m.oldValue == nil {
  5686. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  5687. }
  5688. oldValue, err := m.oldValue(ctx)
  5689. if err != nil {
  5690. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  5691. }
  5692. return oldValue.CategoryID, nil
  5693. }
  5694. // AddCategoryID adds u to the "category_id" field.
  5695. func (m *EmployeeMutation) AddCategoryID(u int64) {
  5696. if m.addcategory_id != nil {
  5697. *m.addcategory_id += u
  5698. } else {
  5699. m.addcategory_id = &u
  5700. }
  5701. }
  5702. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  5703. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  5704. v := m.addcategory_id
  5705. if v == nil {
  5706. return
  5707. }
  5708. return *v, true
  5709. }
  5710. // ResetCategoryID resets all changes to the "category_id" field.
  5711. func (m *EmployeeMutation) ResetCategoryID() {
  5712. m.category_id = nil
  5713. m.addcategory_id = nil
  5714. }
  5715. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  5716. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  5717. if m.em_work_experiences == nil {
  5718. m.em_work_experiences = make(map[uint64]struct{})
  5719. }
  5720. for i := range ids {
  5721. m.em_work_experiences[ids[i]] = struct{}{}
  5722. }
  5723. }
  5724. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  5725. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  5726. m.clearedem_work_experiences = true
  5727. }
  5728. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  5729. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  5730. return m.clearedem_work_experiences
  5731. }
  5732. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  5733. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  5734. if m.removedem_work_experiences == nil {
  5735. m.removedem_work_experiences = make(map[uint64]struct{})
  5736. }
  5737. for i := range ids {
  5738. delete(m.em_work_experiences, ids[i])
  5739. m.removedem_work_experiences[ids[i]] = struct{}{}
  5740. }
  5741. }
  5742. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  5743. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  5744. for id := range m.removedem_work_experiences {
  5745. ids = append(ids, id)
  5746. }
  5747. return
  5748. }
  5749. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  5750. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  5751. for id := range m.em_work_experiences {
  5752. ids = append(ids, id)
  5753. }
  5754. return
  5755. }
  5756. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  5757. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  5758. m.em_work_experiences = nil
  5759. m.clearedem_work_experiences = false
  5760. m.removedem_work_experiences = nil
  5761. }
  5762. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  5763. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  5764. if m.em_tutorial == nil {
  5765. m.em_tutorial = make(map[uint64]struct{})
  5766. }
  5767. for i := range ids {
  5768. m.em_tutorial[ids[i]] = struct{}{}
  5769. }
  5770. }
  5771. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  5772. func (m *EmployeeMutation) ClearEmTutorial() {
  5773. m.clearedem_tutorial = true
  5774. }
  5775. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  5776. func (m *EmployeeMutation) EmTutorialCleared() bool {
  5777. return m.clearedem_tutorial
  5778. }
  5779. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  5780. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  5781. if m.removedem_tutorial == nil {
  5782. m.removedem_tutorial = make(map[uint64]struct{})
  5783. }
  5784. for i := range ids {
  5785. delete(m.em_tutorial, ids[i])
  5786. m.removedem_tutorial[ids[i]] = struct{}{}
  5787. }
  5788. }
  5789. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  5790. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  5791. for id := range m.removedem_tutorial {
  5792. ids = append(ids, id)
  5793. }
  5794. return
  5795. }
  5796. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  5797. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  5798. for id := range m.em_tutorial {
  5799. ids = append(ids, id)
  5800. }
  5801. return
  5802. }
  5803. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  5804. func (m *EmployeeMutation) ResetEmTutorial() {
  5805. m.em_tutorial = nil
  5806. m.clearedem_tutorial = false
  5807. m.removedem_tutorial = nil
  5808. }
  5809. // Where appends a list predicates to the EmployeeMutation builder.
  5810. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  5811. m.predicates = append(m.predicates, ps...)
  5812. }
  5813. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  5814. // users can use type-assertion to append predicates that do not depend on any generated package.
  5815. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  5816. p := make([]predicate.Employee, len(ps))
  5817. for i := range ps {
  5818. p[i] = ps[i]
  5819. }
  5820. m.Where(p...)
  5821. }
  5822. // Op returns the operation name.
  5823. func (m *EmployeeMutation) Op() Op {
  5824. return m.op
  5825. }
  5826. // SetOp allows setting the mutation operation.
  5827. func (m *EmployeeMutation) SetOp(op Op) {
  5828. m.op = op
  5829. }
  5830. // Type returns the node type of this mutation (Employee).
  5831. func (m *EmployeeMutation) Type() string {
  5832. return m.typ
  5833. }
  5834. // Fields returns all fields that were changed during this mutation. Note that in
  5835. // order to get all numeric fields that were incremented/decremented, call
  5836. // AddedFields().
  5837. func (m *EmployeeMutation) Fields() []string {
  5838. fields := make([]string, 0, 18)
  5839. if m.created_at != nil {
  5840. fields = append(fields, employee.FieldCreatedAt)
  5841. }
  5842. if m.updated_at != nil {
  5843. fields = append(fields, employee.FieldUpdatedAt)
  5844. }
  5845. if m.deleted_at != nil {
  5846. fields = append(fields, employee.FieldDeletedAt)
  5847. }
  5848. if m.title != nil {
  5849. fields = append(fields, employee.FieldTitle)
  5850. }
  5851. if m.avatar != nil {
  5852. fields = append(fields, employee.FieldAvatar)
  5853. }
  5854. if m.tags != nil {
  5855. fields = append(fields, employee.FieldTags)
  5856. }
  5857. if m.hire_count != nil {
  5858. fields = append(fields, employee.FieldHireCount)
  5859. }
  5860. if m.service_count != nil {
  5861. fields = append(fields, employee.FieldServiceCount)
  5862. }
  5863. if m.achievement_count != nil {
  5864. fields = append(fields, employee.FieldAchievementCount)
  5865. }
  5866. if m.intro != nil {
  5867. fields = append(fields, employee.FieldIntro)
  5868. }
  5869. if m.estimate != nil {
  5870. fields = append(fields, employee.FieldEstimate)
  5871. }
  5872. if m.skill != nil {
  5873. fields = append(fields, employee.FieldSkill)
  5874. }
  5875. if m.ability_type != nil {
  5876. fields = append(fields, employee.FieldAbilityType)
  5877. }
  5878. if m.scene != nil {
  5879. fields = append(fields, employee.FieldScene)
  5880. }
  5881. if m.switch_in != nil {
  5882. fields = append(fields, employee.FieldSwitchIn)
  5883. }
  5884. if m.video_url != nil {
  5885. fields = append(fields, employee.FieldVideoURL)
  5886. }
  5887. if m.organization_id != nil {
  5888. fields = append(fields, employee.FieldOrganizationID)
  5889. }
  5890. if m.category_id != nil {
  5891. fields = append(fields, employee.FieldCategoryID)
  5892. }
  5893. return fields
  5894. }
  5895. // Field returns the value of a field with the given name. The second boolean
  5896. // return value indicates that this field was not set, or was not defined in the
  5897. // schema.
  5898. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  5899. switch name {
  5900. case employee.FieldCreatedAt:
  5901. return m.CreatedAt()
  5902. case employee.FieldUpdatedAt:
  5903. return m.UpdatedAt()
  5904. case employee.FieldDeletedAt:
  5905. return m.DeletedAt()
  5906. case employee.FieldTitle:
  5907. return m.Title()
  5908. case employee.FieldAvatar:
  5909. return m.Avatar()
  5910. case employee.FieldTags:
  5911. return m.Tags()
  5912. case employee.FieldHireCount:
  5913. return m.HireCount()
  5914. case employee.FieldServiceCount:
  5915. return m.ServiceCount()
  5916. case employee.FieldAchievementCount:
  5917. return m.AchievementCount()
  5918. case employee.FieldIntro:
  5919. return m.Intro()
  5920. case employee.FieldEstimate:
  5921. return m.Estimate()
  5922. case employee.FieldSkill:
  5923. return m.Skill()
  5924. case employee.FieldAbilityType:
  5925. return m.AbilityType()
  5926. case employee.FieldScene:
  5927. return m.Scene()
  5928. case employee.FieldSwitchIn:
  5929. return m.SwitchIn()
  5930. case employee.FieldVideoURL:
  5931. return m.VideoURL()
  5932. case employee.FieldOrganizationID:
  5933. return m.OrganizationID()
  5934. case employee.FieldCategoryID:
  5935. return m.CategoryID()
  5936. }
  5937. return nil, false
  5938. }
  5939. // OldField returns the old value of the field from the database. An error is
  5940. // returned if the mutation operation is not UpdateOne, or the query to the
  5941. // database failed.
  5942. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5943. switch name {
  5944. case employee.FieldCreatedAt:
  5945. return m.OldCreatedAt(ctx)
  5946. case employee.FieldUpdatedAt:
  5947. return m.OldUpdatedAt(ctx)
  5948. case employee.FieldDeletedAt:
  5949. return m.OldDeletedAt(ctx)
  5950. case employee.FieldTitle:
  5951. return m.OldTitle(ctx)
  5952. case employee.FieldAvatar:
  5953. return m.OldAvatar(ctx)
  5954. case employee.FieldTags:
  5955. return m.OldTags(ctx)
  5956. case employee.FieldHireCount:
  5957. return m.OldHireCount(ctx)
  5958. case employee.FieldServiceCount:
  5959. return m.OldServiceCount(ctx)
  5960. case employee.FieldAchievementCount:
  5961. return m.OldAchievementCount(ctx)
  5962. case employee.FieldIntro:
  5963. return m.OldIntro(ctx)
  5964. case employee.FieldEstimate:
  5965. return m.OldEstimate(ctx)
  5966. case employee.FieldSkill:
  5967. return m.OldSkill(ctx)
  5968. case employee.FieldAbilityType:
  5969. return m.OldAbilityType(ctx)
  5970. case employee.FieldScene:
  5971. return m.OldScene(ctx)
  5972. case employee.FieldSwitchIn:
  5973. return m.OldSwitchIn(ctx)
  5974. case employee.FieldVideoURL:
  5975. return m.OldVideoURL(ctx)
  5976. case employee.FieldOrganizationID:
  5977. return m.OldOrganizationID(ctx)
  5978. case employee.FieldCategoryID:
  5979. return m.OldCategoryID(ctx)
  5980. }
  5981. return nil, fmt.Errorf("unknown Employee field %s", name)
  5982. }
  5983. // SetField sets the value of a field with the given name. It returns an error if
  5984. // the field is not defined in the schema, or if the type mismatched the field
  5985. // type.
  5986. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  5987. switch name {
  5988. case employee.FieldCreatedAt:
  5989. v, ok := value.(time.Time)
  5990. if !ok {
  5991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5992. }
  5993. m.SetCreatedAt(v)
  5994. return nil
  5995. case employee.FieldUpdatedAt:
  5996. v, ok := value.(time.Time)
  5997. if !ok {
  5998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5999. }
  6000. m.SetUpdatedAt(v)
  6001. return nil
  6002. case employee.FieldDeletedAt:
  6003. v, ok := value.(time.Time)
  6004. if !ok {
  6005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6006. }
  6007. m.SetDeletedAt(v)
  6008. return nil
  6009. case employee.FieldTitle:
  6010. v, ok := value.(string)
  6011. if !ok {
  6012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6013. }
  6014. m.SetTitle(v)
  6015. return nil
  6016. case employee.FieldAvatar:
  6017. v, ok := value.(string)
  6018. if !ok {
  6019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6020. }
  6021. m.SetAvatar(v)
  6022. return nil
  6023. case employee.FieldTags:
  6024. v, ok := value.(string)
  6025. if !ok {
  6026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6027. }
  6028. m.SetTags(v)
  6029. return nil
  6030. case employee.FieldHireCount:
  6031. v, ok := value.(int)
  6032. if !ok {
  6033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6034. }
  6035. m.SetHireCount(v)
  6036. return nil
  6037. case employee.FieldServiceCount:
  6038. v, ok := value.(int)
  6039. if !ok {
  6040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6041. }
  6042. m.SetServiceCount(v)
  6043. return nil
  6044. case employee.FieldAchievementCount:
  6045. v, ok := value.(int)
  6046. if !ok {
  6047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6048. }
  6049. m.SetAchievementCount(v)
  6050. return nil
  6051. case employee.FieldIntro:
  6052. v, ok := value.(string)
  6053. if !ok {
  6054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6055. }
  6056. m.SetIntro(v)
  6057. return nil
  6058. case employee.FieldEstimate:
  6059. v, ok := value.(string)
  6060. if !ok {
  6061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6062. }
  6063. m.SetEstimate(v)
  6064. return nil
  6065. case employee.FieldSkill:
  6066. v, ok := value.(string)
  6067. if !ok {
  6068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6069. }
  6070. m.SetSkill(v)
  6071. return nil
  6072. case employee.FieldAbilityType:
  6073. v, ok := value.(string)
  6074. if !ok {
  6075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6076. }
  6077. m.SetAbilityType(v)
  6078. return nil
  6079. case employee.FieldScene:
  6080. v, ok := value.(string)
  6081. if !ok {
  6082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6083. }
  6084. m.SetScene(v)
  6085. return nil
  6086. case employee.FieldSwitchIn:
  6087. v, ok := value.(string)
  6088. if !ok {
  6089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6090. }
  6091. m.SetSwitchIn(v)
  6092. return nil
  6093. case employee.FieldVideoURL:
  6094. v, ok := value.(string)
  6095. if !ok {
  6096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6097. }
  6098. m.SetVideoURL(v)
  6099. return nil
  6100. case employee.FieldOrganizationID:
  6101. v, ok := value.(uint64)
  6102. if !ok {
  6103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6104. }
  6105. m.SetOrganizationID(v)
  6106. return nil
  6107. case employee.FieldCategoryID:
  6108. v, ok := value.(uint64)
  6109. if !ok {
  6110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6111. }
  6112. m.SetCategoryID(v)
  6113. return nil
  6114. }
  6115. return fmt.Errorf("unknown Employee field %s", name)
  6116. }
  6117. // AddedFields returns all numeric fields that were incremented/decremented during
  6118. // this mutation.
  6119. func (m *EmployeeMutation) AddedFields() []string {
  6120. var fields []string
  6121. if m.addhire_count != nil {
  6122. fields = append(fields, employee.FieldHireCount)
  6123. }
  6124. if m.addservice_count != nil {
  6125. fields = append(fields, employee.FieldServiceCount)
  6126. }
  6127. if m.addachievement_count != nil {
  6128. fields = append(fields, employee.FieldAchievementCount)
  6129. }
  6130. if m.addorganization_id != nil {
  6131. fields = append(fields, employee.FieldOrganizationID)
  6132. }
  6133. if m.addcategory_id != nil {
  6134. fields = append(fields, employee.FieldCategoryID)
  6135. }
  6136. return fields
  6137. }
  6138. // AddedField returns the numeric value that was incremented/decremented on a field
  6139. // with the given name. The second boolean return value indicates that this field
  6140. // was not set, or was not defined in the schema.
  6141. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  6142. switch name {
  6143. case employee.FieldHireCount:
  6144. return m.AddedHireCount()
  6145. case employee.FieldServiceCount:
  6146. return m.AddedServiceCount()
  6147. case employee.FieldAchievementCount:
  6148. return m.AddedAchievementCount()
  6149. case employee.FieldOrganizationID:
  6150. return m.AddedOrganizationID()
  6151. case employee.FieldCategoryID:
  6152. return m.AddedCategoryID()
  6153. }
  6154. return nil, false
  6155. }
  6156. // AddField adds the value to the field with the given name. It returns an error if
  6157. // the field is not defined in the schema, or if the type mismatched the field
  6158. // type.
  6159. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  6160. switch name {
  6161. case employee.FieldHireCount:
  6162. v, ok := value.(int)
  6163. if !ok {
  6164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6165. }
  6166. m.AddHireCount(v)
  6167. return nil
  6168. case employee.FieldServiceCount:
  6169. v, ok := value.(int)
  6170. if !ok {
  6171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6172. }
  6173. m.AddServiceCount(v)
  6174. return nil
  6175. case employee.FieldAchievementCount:
  6176. v, ok := value.(int)
  6177. if !ok {
  6178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6179. }
  6180. m.AddAchievementCount(v)
  6181. return nil
  6182. case employee.FieldOrganizationID:
  6183. v, ok := value.(int64)
  6184. if !ok {
  6185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6186. }
  6187. m.AddOrganizationID(v)
  6188. return nil
  6189. case employee.FieldCategoryID:
  6190. v, ok := value.(int64)
  6191. if !ok {
  6192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6193. }
  6194. m.AddCategoryID(v)
  6195. return nil
  6196. }
  6197. return fmt.Errorf("unknown Employee numeric field %s", name)
  6198. }
  6199. // ClearedFields returns all nullable fields that were cleared during this
  6200. // mutation.
  6201. func (m *EmployeeMutation) ClearedFields() []string {
  6202. var fields []string
  6203. if m.FieldCleared(employee.FieldDeletedAt) {
  6204. fields = append(fields, employee.FieldDeletedAt)
  6205. }
  6206. return fields
  6207. }
  6208. // FieldCleared returns a boolean indicating if a field with the given name was
  6209. // cleared in this mutation.
  6210. func (m *EmployeeMutation) FieldCleared(name string) bool {
  6211. _, ok := m.clearedFields[name]
  6212. return ok
  6213. }
  6214. // ClearField clears the value of the field with the given name. It returns an
  6215. // error if the field is not defined in the schema.
  6216. func (m *EmployeeMutation) ClearField(name string) error {
  6217. switch name {
  6218. case employee.FieldDeletedAt:
  6219. m.ClearDeletedAt()
  6220. return nil
  6221. }
  6222. return fmt.Errorf("unknown Employee nullable field %s", name)
  6223. }
  6224. // ResetField resets all changes in the mutation for the field with the given name.
  6225. // It returns an error if the field is not defined in the schema.
  6226. func (m *EmployeeMutation) ResetField(name string) error {
  6227. switch name {
  6228. case employee.FieldCreatedAt:
  6229. m.ResetCreatedAt()
  6230. return nil
  6231. case employee.FieldUpdatedAt:
  6232. m.ResetUpdatedAt()
  6233. return nil
  6234. case employee.FieldDeletedAt:
  6235. m.ResetDeletedAt()
  6236. return nil
  6237. case employee.FieldTitle:
  6238. m.ResetTitle()
  6239. return nil
  6240. case employee.FieldAvatar:
  6241. m.ResetAvatar()
  6242. return nil
  6243. case employee.FieldTags:
  6244. m.ResetTags()
  6245. return nil
  6246. case employee.FieldHireCount:
  6247. m.ResetHireCount()
  6248. return nil
  6249. case employee.FieldServiceCount:
  6250. m.ResetServiceCount()
  6251. return nil
  6252. case employee.FieldAchievementCount:
  6253. m.ResetAchievementCount()
  6254. return nil
  6255. case employee.FieldIntro:
  6256. m.ResetIntro()
  6257. return nil
  6258. case employee.FieldEstimate:
  6259. m.ResetEstimate()
  6260. return nil
  6261. case employee.FieldSkill:
  6262. m.ResetSkill()
  6263. return nil
  6264. case employee.FieldAbilityType:
  6265. m.ResetAbilityType()
  6266. return nil
  6267. case employee.FieldScene:
  6268. m.ResetScene()
  6269. return nil
  6270. case employee.FieldSwitchIn:
  6271. m.ResetSwitchIn()
  6272. return nil
  6273. case employee.FieldVideoURL:
  6274. m.ResetVideoURL()
  6275. return nil
  6276. case employee.FieldOrganizationID:
  6277. m.ResetOrganizationID()
  6278. return nil
  6279. case employee.FieldCategoryID:
  6280. m.ResetCategoryID()
  6281. return nil
  6282. }
  6283. return fmt.Errorf("unknown Employee field %s", name)
  6284. }
  6285. // AddedEdges returns all edge names that were set/added in this mutation.
  6286. func (m *EmployeeMutation) AddedEdges() []string {
  6287. edges := make([]string, 0, 2)
  6288. if m.em_work_experiences != nil {
  6289. edges = append(edges, employee.EdgeEmWorkExperiences)
  6290. }
  6291. if m.em_tutorial != nil {
  6292. edges = append(edges, employee.EdgeEmTutorial)
  6293. }
  6294. return edges
  6295. }
  6296. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6297. // name in this mutation.
  6298. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  6299. switch name {
  6300. case employee.EdgeEmWorkExperiences:
  6301. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  6302. for id := range m.em_work_experiences {
  6303. ids = append(ids, id)
  6304. }
  6305. return ids
  6306. case employee.EdgeEmTutorial:
  6307. ids := make([]ent.Value, 0, len(m.em_tutorial))
  6308. for id := range m.em_tutorial {
  6309. ids = append(ids, id)
  6310. }
  6311. return ids
  6312. }
  6313. return nil
  6314. }
  6315. // RemovedEdges returns all edge names that were removed in this mutation.
  6316. func (m *EmployeeMutation) RemovedEdges() []string {
  6317. edges := make([]string, 0, 2)
  6318. if m.removedem_work_experiences != nil {
  6319. edges = append(edges, employee.EdgeEmWorkExperiences)
  6320. }
  6321. if m.removedem_tutorial != nil {
  6322. edges = append(edges, employee.EdgeEmTutorial)
  6323. }
  6324. return edges
  6325. }
  6326. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6327. // the given name in this mutation.
  6328. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  6329. switch name {
  6330. case employee.EdgeEmWorkExperiences:
  6331. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  6332. for id := range m.removedem_work_experiences {
  6333. ids = append(ids, id)
  6334. }
  6335. return ids
  6336. case employee.EdgeEmTutorial:
  6337. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  6338. for id := range m.removedem_tutorial {
  6339. ids = append(ids, id)
  6340. }
  6341. return ids
  6342. }
  6343. return nil
  6344. }
  6345. // ClearedEdges returns all edge names that were cleared in this mutation.
  6346. func (m *EmployeeMutation) ClearedEdges() []string {
  6347. edges := make([]string, 0, 2)
  6348. if m.clearedem_work_experiences {
  6349. edges = append(edges, employee.EdgeEmWorkExperiences)
  6350. }
  6351. if m.clearedem_tutorial {
  6352. edges = append(edges, employee.EdgeEmTutorial)
  6353. }
  6354. return edges
  6355. }
  6356. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6357. // was cleared in this mutation.
  6358. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  6359. switch name {
  6360. case employee.EdgeEmWorkExperiences:
  6361. return m.clearedem_work_experiences
  6362. case employee.EdgeEmTutorial:
  6363. return m.clearedem_tutorial
  6364. }
  6365. return false
  6366. }
  6367. // ClearEdge clears the value of the edge with the given name. It returns an error
  6368. // if that edge is not defined in the schema.
  6369. func (m *EmployeeMutation) ClearEdge(name string) error {
  6370. switch name {
  6371. }
  6372. return fmt.Errorf("unknown Employee unique edge %s", name)
  6373. }
  6374. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6375. // It returns an error if the edge is not defined in the schema.
  6376. func (m *EmployeeMutation) ResetEdge(name string) error {
  6377. switch name {
  6378. case employee.EdgeEmWorkExperiences:
  6379. m.ResetEmWorkExperiences()
  6380. return nil
  6381. case employee.EdgeEmTutorial:
  6382. m.ResetEmTutorial()
  6383. return nil
  6384. }
  6385. return fmt.Errorf("unknown Employee edge %s", name)
  6386. }
  6387. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  6388. type EmployeeConfigMutation struct {
  6389. config
  6390. op Op
  6391. typ string
  6392. id *uint64
  6393. created_at *time.Time
  6394. updated_at *time.Time
  6395. deleted_at *time.Time
  6396. stype *string
  6397. title *string
  6398. photo *string
  6399. organization_id *uint64
  6400. addorganization_id *int64
  6401. clearedFields map[string]struct{}
  6402. done bool
  6403. oldValue func(context.Context) (*EmployeeConfig, error)
  6404. predicates []predicate.EmployeeConfig
  6405. }
  6406. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  6407. // employeeconfigOption allows management of the mutation configuration using functional options.
  6408. type employeeconfigOption func(*EmployeeConfigMutation)
  6409. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  6410. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  6411. m := &EmployeeConfigMutation{
  6412. config: c,
  6413. op: op,
  6414. typ: TypeEmployeeConfig,
  6415. clearedFields: make(map[string]struct{}),
  6416. }
  6417. for _, opt := range opts {
  6418. opt(m)
  6419. }
  6420. return m
  6421. }
  6422. // withEmployeeConfigID sets the ID field of the mutation.
  6423. func withEmployeeConfigID(id uint64) employeeconfigOption {
  6424. return func(m *EmployeeConfigMutation) {
  6425. var (
  6426. err error
  6427. once sync.Once
  6428. value *EmployeeConfig
  6429. )
  6430. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  6431. once.Do(func() {
  6432. if m.done {
  6433. err = errors.New("querying old values post mutation is not allowed")
  6434. } else {
  6435. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  6436. }
  6437. })
  6438. return value, err
  6439. }
  6440. m.id = &id
  6441. }
  6442. }
  6443. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  6444. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  6445. return func(m *EmployeeConfigMutation) {
  6446. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  6447. return node, nil
  6448. }
  6449. m.id = &node.ID
  6450. }
  6451. }
  6452. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6453. // executed in a transaction (ent.Tx), a transactional client is returned.
  6454. func (m EmployeeConfigMutation) Client() *Client {
  6455. client := &Client{config: m.config}
  6456. client.init()
  6457. return client
  6458. }
  6459. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6460. // it returns an error otherwise.
  6461. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  6462. if _, ok := m.driver.(*txDriver); !ok {
  6463. return nil, errors.New("ent: mutation is not running in a transaction")
  6464. }
  6465. tx := &Tx{config: m.config}
  6466. tx.init()
  6467. return tx, nil
  6468. }
  6469. // SetID sets the value of the id field. Note that this
  6470. // operation is only accepted on creation of EmployeeConfig entities.
  6471. func (m *EmployeeConfigMutation) SetID(id uint64) {
  6472. m.id = &id
  6473. }
  6474. // ID returns the ID value in the mutation. Note that the ID is only available
  6475. // if it was provided to the builder or after it was returned from the database.
  6476. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  6477. if m.id == nil {
  6478. return
  6479. }
  6480. return *m.id, true
  6481. }
  6482. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6483. // That means, if the mutation is applied within a transaction with an isolation level such
  6484. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6485. // or updated by the mutation.
  6486. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  6487. switch {
  6488. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6489. id, exists := m.ID()
  6490. if exists {
  6491. return []uint64{id}, nil
  6492. }
  6493. fallthrough
  6494. case m.op.Is(OpUpdate | OpDelete):
  6495. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  6496. default:
  6497. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6498. }
  6499. }
  6500. // SetCreatedAt sets the "created_at" field.
  6501. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  6502. m.created_at = &t
  6503. }
  6504. // CreatedAt returns the value of the "created_at" field in the mutation.
  6505. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  6506. v := m.created_at
  6507. if v == nil {
  6508. return
  6509. }
  6510. return *v, true
  6511. }
  6512. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  6513. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6515. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6516. if !m.op.Is(OpUpdateOne) {
  6517. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6518. }
  6519. if m.id == nil || m.oldValue == nil {
  6520. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6521. }
  6522. oldValue, err := m.oldValue(ctx)
  6523. if err != nil {
  6524. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6525. }
  6526. return oldValue.CreatedAt, nil
  6527. }
  6528. // ResetCreatedAt resets all changes to the "created_at" field.
  6529. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  6530. m.created_at = nil
  6531. }
  6532. // SetUpdatedAt sets the "updated_at" field.
  6533. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  6534. m.updated_at = &t
  6535. }
  6536. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6537. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  6538. v := m.updated_at
  6539. if v == nil {
  6540. return
  6541. }
  6542. return *v, true
  6543. }
  6544. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  6545. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6546. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6547. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6548. if !m.op.Is(OpUpdateOne) {
  6549. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6550. }
  6551. if m.id == nil || m.oldValue == nil {
  6552. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6553. }
  6554. oldValue, err := m.oldValue(ctx)
  6555. if err != nil {
  6556. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6557. }
  6558. return oldValue.UpdatedAt, nil
  6559. }
  6560. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6561. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  6562. m.updated_at = nil
  6563. }
  6564. // SetDeletedAt sets the "deleted_at" field.
  6565. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  6566. m.deleted_at = &t
  6567. }
  6568. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6569. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  6570. v := m.deleted_at
  6571. if v == nil {
  6572. return
  6573. }
  6574. return *v, true
  6575. }
  6576. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  6577. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6579. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6580. if !m.op.Is(OpUpdateOne) {
  6581. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6582. }
  6583. if m.id == nil || m.oldValue == nil {
  6584. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6585. }
  6586. oldValue, err := m.oldValue(ctx)
  6587. if err != nil {
  6588. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6589. }
  6590. return oldValue.DeletedAt, nil
  6591. }
  6592. // ClearDeletedAt clears the value of the "deleted_at" field.
  6593. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  6594. m.deleted_at = nil
  6595. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  6596. }
  6597. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6598. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  6599. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  6600. return ok
  6601. }
  6602. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6603. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  6604. m.deleted_at = nil
  6605. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  6606. }
  6607. // SetStype sets the "stype" field.
  6608. func (m *EmployeeConfigMutation) SetStype(s string) {
  6609. m.stype = &s
  6610. }
  6611. // Stype returns the value of the "stype" field in the mutation.
  6612. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  6613. v := m.stype
  6614. if v == nil {
  6615. return
  6616. }
  6617. return *v, true
  6618. }
  6619. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  6620. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6622. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  6623. if !m.op.Is(OpUpdateOne) {
  6624. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  6625. }
  6626. if m.id == nil || m.oldValue == nil {
  6627. return v, errors.New("OldStype requires an ID field in the mutation")
  6628. }
  6629. oldValue, err := m.oldValue(ctx)
  6630. if err != nil {
  6631. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  6632. }
  6633. return oldValue.Stype, nil
  6634. }
  6635. // ResetStype resets all changes to the "stype" field.
  6636. func (m *EmployeeConfigMutation) ResetStype() {
  6637. m.stype = nil
  6638. }
  6639. // SetTitle sets the "title" field.
  6640. func (m *EmployeeConfigMutation) SetTitle(s string) {
  6641. m.title = &s
  6642. }
  6643. // Title returns the value of the "title" field in the mutation.
  6644. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  6645. v := m.title
  6646. if v == nil {
  6647. return
  6648. }
  6649. return *v, true
  6650. }
  6651. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  6652. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6654. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  6655. if !m.op.Is(OpUpdateOne) {
  6656. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  6657. }
  6658. if m.id == nil || m.oldValue == nil {
  6659. return v, errors.New("OldTitle requires an ID field in the mutation")
  6660. }
  6661. oldValue, err := m.oldValue(ctx)
  6662. if err != nil {
  6663. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  6664. }
  6665. return oldValue.Title, nil
  6666. }
  6667. // ResetTitle resets all changes to the "title" field.
  6668. func (m *EmployeeConfigMutation) ResetTitle() {
  6669. m.title = nil
  6670. }
  6671. // SetPhoto sets the "photo" field.
  6672. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  6673. m.photo = &s
  6674. }
  6675. // Photo returns the value of the "photo" field in the mutation.
  6676. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  6677. v := m.photo
  6678. if v == nil {
  6679. return
  6680. }
  6681. return *v, true
  6682. }
  6683. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  6684. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6686. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  6687. if !m.op.Is(OpUpdateOne) {
  6688. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  6689. }
  6690. if m.id == nil || m.oldValue == nil {
  6691. return v, errors.New("OldPhoto requires an ID field in the mutation")
  6692. }
  6693. oldValue, err := m.oldValue(ctx)
  6694. if err != nil {
  6695. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  6696. }
  6697. return oldValue.Photo, nil
  6698. }
  6699. // ResetPhoto resets all changes to the "photo" field.
  6700. func (m *EmployeeConfigMutation) ResetPhoto() {
  6701. m.photo = nil
  6702. }
  6703. // SetOrganizationID sets the "organization_id" field.
  6704. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  6705. m.organization_id = &u
  6706. m.addorganization_id = nil
  6707. }
  6708. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6709. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  6710. v := m.organization_id
  6711. if v == nil {
  6712. return
  6713. }
  6714. return *v, true
  6715. }
  6716. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  6717. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6719. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6720. if !m.op.Is(OpUpdateOne) {
  6721. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6722. }
  6723. if m.id == nil || m.oldValue == nil {
  6724. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6725. }
  6726. oldValue, err := m.oldValue(ctx)
  6727. if err != nil {
  6728. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6729. }
  6730. return oldValue.OrganizationID, nil
  6731. }
  6732. // AddOrganizationID adds u to the "organization_id" field.
  6733. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  6734. if m.addorganization_id != nil {
  6735. *m.addorganization_id += u
  6736. } else {
  6737. m.addorganization_id = &u
  6738. }
  6739. }
  6740. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6741. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  6742. v := m.addorganization_id
  6743. if v == nil {
  6744. return
  6745. }
  6746. return *v, true
  6747. }
  6748. // ClearOrganizationID clears the value of the "organization_id" field.
  6749. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  6750. m.organization_id = nil
  6751. m.addorganization_id = nil
  6752. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  6753. }
  6754. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  6755. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  6756. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  6757. return ok
  6758. }
  6759. // ResetOrganizationID resets all changes to the "organization_id" field.
  6760. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  6761. m.organization_id = nil
  6762. m.addorganization_id = nil
  6763. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  6764. }
  6765. // Where appends a list predicates to the EmployeeConfigMutation builder.
  6766. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  6767. m.predicates = append(m.predicates, ps...)
  6768. }
  6769. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  6770. // users can use type-assertion to append predicates that do not depend on any generated package.
  6771. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  6772. p := make([]predicate.EmployeeConfig, len(ps))
  6773. for i := range ps {
  6774. p[i] = ps[i]
  6775. }
  6776. m.Where(p...)
  6777. }
  6778. // Op returns the operation name.
  6779. func (m *EmployeeConfigMutation) Op() Op {
  6780. return m.op
  6781. }
  6782. // SetOp allows setting the mutation operation.
  6783. func (m *EmployeeConfigMutation) SetOp(op Op) {
  6784. m.op = op
  6785. }
  6786. // Type returns the node type of this mutation (EmployeeConfig).
  6787. func (m *EmployeeConfigMutation) Type() string {
  6788. return m.typ
  6789. }
  6790. // Fields returns all fields that were changed during this mutation. Note that in
  6791. // order to get all numeric fields that were incremented/decremented, call
  6792. // AddedFields().
  6793. func (m *EmployeeConfigMutation) Fields() []string {
  6794. fields := make([]string, 0, 7)
  6795. if m.created_at != nil {
  6796. fields = append(fields, employeeconfig.FieldCreatedAt)
  6797. }
  6798. if m.updated_at != nil {
  6799. fields = append(fields, employeeconfig.FieldUpdatedAt)
  6800. }
  6801. if m.deleted_at != nil {
  6802. fields = append(fields, employeeconfig.FieldDeletedAt)
  6803. }
  6804. if m.stype != nil {
  6805. fields = append(fields, employeeconfig.FieldStype)
  6806. }
  6807. if m.title != nil {
  6808. fields = append(fields, employeeconfig.FieldTitle)
  6809. }
  6810. if m.photo != nil {
  6811. fields = append(fields, employeeconfig.FieldPhoto)
  6812. }
  6813. if m.organization_id != nil {
  6814. fields = append(fields, employeeconfig.FieldOrganizationID)
  6815. }
  6816. return fields
  6817. }
  6818. // Field returns the value of a field with the given name. The second boolean
  6819. // return value indicates that this field was not set, or was not defined in the
  6820. // schema.
  6821. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  6822. switch name {
  6823. case employeeconfig.FieldCreatedAt:
  6824. return m.CreatedAt()
  6825. case employeeconfig.FieldUpdatedAt:
  6826. return m.UpdatedAt()
  6827. case employeeconfig.FieldDeletedAt:
  6828. return m.DeletedAt()
  6829. case employeeconfig.FieldStype:
  6830. return m.Stype()
  6831. case employeeconfig.FieldTitle:
  6832. return m.Title()
  6833. case employeeconfig.FieldPhoto:
  6834. return m.Photo()
  6835. case employeeconfig.FieldOrganizationID:
  6836. return m.OrganizationID()
  6837. }
  6838. return nil, false
  6839. }
  6840. // OldField returns the old value of the field from the database. An error is
  6841. // returned if the mutation operation is not UpdateOne, or the query to the
  6842. // database failed.
  6843. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6844. switch name {
  6845. case employeeconfig.FieldCreatedAt:
  6846. return m.OldCreatedAt(ctx)
  6847. case employeeconfig.FieldUpdatedAt:
  6848. return m.OldUpdatedAt(ctx)
  6849. case employeeconfig.FieldDeletedAt:
  6850. return m.OldDeletedAt(ctx)
  6851. case employeeconfig.FieldStype:
  6852. return m.OldStype(ctx)
  6853. case employeeconfig.FieldTitle:
  6854. return m.OldTitle(ctx)
  6855. case employeeconfig.FieldPhoto:
  6856. return m.OldPhoto(ctx)
  6857. case employeeconfig.FieldOrganizationID:
  6858. return m.OldOrganizationID(ctx)
  6859. }
  6860. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  6861. }
  6862. // SetField sets the value of a field with the given name. It returns an error if
  6863. // the field is not defined in the schema, or if the type mismatched the field
  6864. // type.
  6865. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  6866. switch name {
  6867. case employeeconfig.FieldCreatedAt:
  6868. v, ok := value.(time.Time)
  6869. if !ok {
  6870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6871. }
  6872. m.SetCreatedAt(v)
  6873. return nil
  6874. case employeeconfig.FieldUpdatedAt:
  6875. v, ok := value.(time.Time)
  6876. if !ok {
  6877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6878. }
  6879. m.SetUpdatedAt(v)
  6880. return nil
  6881. case employeeconfig.FieldDeletedAt:
  6882. v, ok := value.(time.Time)
  6883. if !ok {
  6884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6885. }
  6886. m.SetDeletedAt(v)
  6887. return nil
  6888. case employeeconfig.FieldStype:
  6889. v, ok := value.(string)
  6890. if !ok {
  6891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6892. }
  6893. m.SetStype(v)
  6894. return nil
  6895. case employeeconfig.FieldTitle:
  6896. v, ok := value.(string)
  6897. if !ok {
  6898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6899. }
  6900. m.SetTitle(v)
  6901. return nil
  6902. case employeeconfig.FieldPhoto:
  6903. v, ok := value.(string)
  6904. if !ok {
  6905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6906. }
  6907. m.SetPhoto(v)
  6908. return nil
  6909. case employeeconfig.FieldOrganizationID:
  6910. v, ok := value.(uint64)
  6911. if !ok {
  6912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6913. }
  6914. m.SetOrganizationID(v)
  6915. return nil
  6916. }
  6917. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  6918. }
  6919. // AddedFields returns all numeric fields that were incremented/decremented during
  6920. // this mutation.
  6921. func (m *EmployeeConfigMutation) AddedFields() []string {
  6922. var fields []string
  6923. if m.addorganization_id != nil {
  6924. fields = append(fields, employeeconfig.FieldOrganizationID)
  6925. }
  6926. return fields
  6927. }
  6928. // AddedField returns the numeric value that was incremented/decremented on a field
  6929. // with the given name. The second boolean return value indicates that this field
  6930. // was not set, or was not defined in the schema.
  6931. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  6932. switch name {
  6933. case employeeconfig.FieldOrganizationID:
  6934. return m.AddedOrganizationID()
  6935. }
  6936. return nil, false
  6937. }
  6938. // AddField adds the value to the field with the given name. It returns an error if
  6939. // the field is not defined in the schema, or if the type mismatched the field
  6940. // type.
  6941. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  6942. switch name {
  6943. case employeeconfig.FieldOrganizationID:
  6944. v, ok := value.(int64)
  6945. if !ok {
  6946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6947. }
  6948. m.AddOrganizationID(v)
  6949. return nil
  6950. }
  6951. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  6952. }
  6953. // ClearedFields returns all nullable fields that were cleared during this
  6954. // mutation.
  6955. func (m *EmployeeConfigMutation) ClearedFields() []string {
  6956. var fields []string
  6957. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  6958. fields = append(fields, employeeconfig.FieldDeletedAt)
  6959. }
  6960. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  6961. fields = append(fields, employeeconfig.FieldOrganizationID)
  6962. }
  6963. return fields
  6964. }
  6965. // FieldCleared returns a boolean indicating if a field with the given name was
  6966. // cleared in this mutation.
  6967. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  6968. _, ok := m.clearedFields[name]
  6969. return ok
  6970. }
  6971. // ClearField clears the value of the field with the given name. It returns an
  6972. // error if the field is not defined in the schema.
  6973. func (m *EmployeeConfigMutation) ClearField(name string) error {
  6974. switch name {
  6975. case employeeconfig.FieldDeletedAt:
  6976. m.ClearDeletedAt()
  6977. return nil
  6978. case employeeconfig.FieldOrganizationID:
  6979. m.ClearOrganizationID()
  6980. return nil
  6981. }
  6982. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  6983. }
  6984. // ResetField resets all changes in the mutation for the field with the given name.
  6985. // It returns an error if the field is not defined in the schema.
  6986. func (m *EmployeeConfigMutation) ResetField(name string) error {
  6987. switch name {
  6988. case employeeconfig.FieldCreatedAt:
  6989. m.ResetCreatedAt()
  6990. return nil
  6991. case employeeconfig.FieldUpdatedAt:
  6992. m.ResetUpdatedAt()
  6993. return nil
  6994. case employeeconfig.FieldDeletedAt:
  6995. m.ResetDeletedAt()
  6996. return nil
  6997. case employeeconfig.FieldStype:
  6998. m.ResetStype()
  6999. return nil
  7000. case employeeconfig.FieldTitle:
  7001. m.ResetTitle()
  7002. return nil
  7003. case employeeconfig.FieldPhoto:
  7004. m.ResetPhoto()
  7005. return nil
  7006. case employeeconfig.FieldOrganizationID:
  7007. m.ResetOrganizationID()
  7008. return nil
  7009. }
  7010. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  7011. }
  7012. // AddedEdges returns all edge names that were set/added in this mutation.
  7013. func (m *EmployeeConfigMutation) AddedEdges() []string {
  7014. edges := make([]string, 0, 0)
  7015. return edges
  7016. }
  7017. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7018. // name in this mutation.
  7019. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  7020. return nil
  7021. }
  7022. // RemovedEdges returns all edge names that were removed in this mutation.
  7023. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  7024. edges := make([]string, 0, 0)
  7025. return edges
  7026. }
  7027. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7028. // the given name in this mutation.
  7029. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  7030. return nil
  7031. }
  7032. // ClearedEdges returns all edge names that were cleared in this mutation.
  7033. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  7034. edges := make([]string, 0, 0)
  7035. return edges
  7036. }
  7037. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7038. // was cleared in this mutation.
  7039. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  7040. return false
  7041. }
  7042. // ClearEdge clears the value of the edge with the given name. It returns an error
  7043. // if that edge is not defined in the schema.
  7044. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  7045. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  7046. }
  7047. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7048. // It returns an error if the edge is not defined in the schema.
  7049. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  7050. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  7051. }
  7052. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  7053. type LabelMutation struct {
  7054. config
  7055. op Op
  7056. typ string
  7057. id *uint64
  7058. created_at *time.Time
  7059. updated_at *time.Time
  7060. status *uint8
  7061. addstatus *int8
  7062. _type *int
  7063. add_type *int
  7064. name *string
  7065. from *int
  7066. addfrom *int
  7067. mode *int
  7068. addmode *int
  7069. conditions *string
  7070. organization_id *uint64
  7071. addorganization_id *int64
  7072. clearedFields map[string]struct{}
  7073. label_relationships map[uint64]struct{}
  7074. removedlabel_relationships map[uint64]struct{}
  7075. clearedlabel_relationships bool
  7076. done bool
  7077. oldValue func(context.Context) (*Label, error)
  7078. predicates []predicate.Label
  7079. }
  7080. var _ ent.Mutation = (*LabelMutation)(nil)
  7081. // labelOption allows management of the mutation configuration using functional options.
  7082. type labelOption func(*LabelMutation)
  7083. // newLabelMutation creates new mutation for the Label entity.
  7084. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  7085. m := &LabelMutation{
  7086. config: c,
  7087. op: op,
  7088. typ: TypeLabel,
  7089. clearedFields: make(map[string]struct{}),
  7090. }
  7091. for _, opt := range opts {
  7092. opt(m)
  7093. }
  7094. return m
  7095. }
  7096. // withLabelID sets the ID field of the mutation.
  7097. func withLabelID(id uint64) labelOption {
  7098. return func(m *LabelMutation) {
  7099. var (
  7100. err error
  7101. once sync.Once
  7102. value *Label
  7103. )
  7104. m.oldValue = func(ctx context.Context) (*Label, error) {
  7105. once.Do(func() {
  7106. if m.done {
  7107. err = errors.New("querying old values post mutation is not allowed")
  7108. } else {
  7109. value, err = m.Client().Label.Get(ctx, id)
  7110. }
  7111. })
  7112. return value, err
  7113. }
  7114. m.id = &id
  7115. }
  7116. }
  7117. // withLabel sets the old Label of the mutation.
  7118. func withLabel(node *Label) labelOption {
  7119. return func(m *LabelMutation) {
  7120. m.oldValue = func(context.Context) (*Label, error) {
  7121. return node, nil
  7122. }
  7123. m.id = &node.ID
  7124. }
  7125. }
  7126. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7127. // executed in a transaction (ent.Tx), a transactional client is returned.
  7128. func (m LabelMutation) Client() *Client {
  7129. client := &Client{config: m.config}
  7130. client.init()
  7131. return client
  7132. }
  7133. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7134. // it returns an error otherwise.
  7135. func (m LabelMutation) Tx() (*Tx, error) {
  7136. if _, ok := m.driver.(*txDriver); !ok {
  7137. return nil, errors.New("ent: mutation is not running in a transaction")
  7138. }
  7139. tx := &Tx{config: m.config}
  7140. tx.init()
  7141. return tx, nil
  7142. }
  7143. // SetID sets the value of the id field. Note that this
  7144. // operation is only accepted on creation of Label entities.
  7145. func (m *LabelMutation) SetID(id uint64) {
  7146. m.id = &id
  7147. }
  7148. // ID returns the ID value in the mutation. Note that the ID is only available
  7149. // if it was provided to the builder or after it was returned from the database.
  7150. func (m *LabelMutation) ID() (id uint64, exists bool) {
  7151. if m.id == nil {
  7152. return
  7153. }
  7154. return *m.id, true
  7155. }
  7156. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7157. // That means, if the mutation is applied within a transaction with an isolation level such
  7158. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7159. // or updated by the mutation.
  7160. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  7161. switch {
  7162. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7163. id, exists := m.ID()
  7164. if exists {
  7165. return []uint64{id}, nil
  7166. }
  7167. fallthrough
  7168. case m.op.Is(OpUpdate | OpDelete):
  7169. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  7170. default:
  7171. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7172. }
  7173. }
  7174. // SetCreatedAt sets the "created_at" field.
  7175. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  7176. m.created_at = &t
  7177. }
  7178. // CreatedAt returns the value of the "created_at" field in the mutation.
  7179. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  7180. v := m.created_at
  7181. if v == nil {
  7182. return
  7183. }
  7184. return *v, true
  7185. }
  7186. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  7187. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7189. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7190. if !m.op.Is(OpUpdateOne) {
  7191. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7192. }
  7193. if m.id == nil || m.oldValue == nil {
  7194. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7195. }
  7196. oldValue, err := m.oldValue(ctx)
  7197. if err != nil {
  7198. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7199. }
  7200. return oldValue.CreatedAt, nil
  7201. }
  7202. // ResetCreatedAt resets all changes to the "created_at" field.
  7203. func (m *LabelMutation) ResetCreatedAt() {
  7204. m.created_at = nil
  7205. }
  7206. // SetUpdatedAt sets the "updated_at" field.
  7207. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  7208. m.updated_at = &t
  7209. }
  7210. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7211. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  7212. v := m.updated_at
  7213. if v == nil {
  7214. return
  7215. }
  7216. return *v, true
  7217. }
  7218. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  7219. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7221. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7222. if !m.op.Is(OpUpdateOne) {
  7223. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7224. }
  7225. if m.id == nil || m.oldValue == nil {
  7226. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7227. }
  7228. oldValue, err := m.oldValue(ctx)
  7229. if err != nil {
  7230. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7231. }
  7232. return oldValue.UpdatedAt, nil
  7233. }
  7234. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7235. func (m *LabelMutation) ResetUpdatedAt() {
  7236. m.updated_at = nil
  7237. }
  7238. // SetStatus sets the "status" field.
  7239. func (m *LabelMutation) SetStatus(u uint8) {
  7240. m.status = &u
  7241. m.addstatus = nil
  7242. }
  7243. // Status returns the value of the "status" field in the mutation.
  7244. func (m *LabelMutation) Status() (r uint8, exists bool) {
  7245. v := m.status
  7246. if v == nil {
  7247. return
  7248. }
  7249. return *v, true
  7250. }
  7251. // OldStatus returns the old "status" field's value of the Label entity.
  7252. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7254. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7255. if !m.op.Is(OpUpdateOne) {
  7256. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7257. }
  7258. if m.id == nil || m.oldValue == nil {
  7259. return v, errors.New("OldStatus requires an ID field in the mutation")
  7260. }
  7261. oldValue, err := m.oldValue(ctx)
  7262. if err != nil {
  7263. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7264. }
  7265. return oldValue.Status, nil
  7266. }
  7267. // AddStatus adds u to the "status" field.
  7268. func (m *LabelMutation) AddStatus(u int8) {
  7269. if m.addstatus != nil {
  7270. *m.addstatus += u
  7271. } else {
  7272. m.addstatus = &u
  7273. }
  7274. }
  7275. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7276. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  7277. v := m.addstatus
  7278. if v == nil {
  7279. return
  7280. }
  7281. return *v, true
  7282. }
  7283. // ClearStatus clears the value of the "status" field.
  7284. func (m *LabelMutation) ClearStatus() {
  7285. m.status = nil
  7286. m.addstatus = nil
  7287. m.clearedFields[label.FieldStatus] = struct{}{}
  7288. }
  7289. // StatusCleared returns if the "status" field was cleared in this mutation.
  7290. func (m *LabelMutation) StatusCleared() bool {
  7291. _, ok := m.clearedFields[label.FieldStatus]
  7292. return ok
  7293. }
  7294. // ResetStatus resets all changes to the "status" field.
  7295. func (m *LabelMutation) ResetStatus() {
  7296. m.status = nil
  7297. m.addstatus = nil
  7298. delete(m.clearedFields, label.FieldStatus)
  7299. }
  7300. // SetType sets the "type" field.
  7301. func (m *LabelMutation) SetType(i int) {
  7302. m._type = &i
  7303. m.add_type = nil
  7304. }
  7305. // GetType returns the value of the "type" field in the mutation.
  7306. func (m *LabelMutation) GetType() (r int, exists bool) {
  7307. v := m._type
  7308. if v == nil {
  7309. return
  7310. }
  7311. return *v, true
  7312. }
  7313. // OldType returns the old "type" field's value of the Label entity.
  7314. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7316. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  7317. if !m.op.Is(OpUpdateOne) {
  7318. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7319. }
  7320. if m.id == nil || m.oldValue == nil {
  7321. return v, errors.New("OldType requires an ID field in the mutation")
  7322. }
  7323. oldValue, err := m.oldValue(ctx)
  7324. if err != nil {
  7325. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7326. }
  7327. return oldValue.Type, nil
  7328. }
  7329. // AddType adds i to the "type" field.
  7330. func (m *LabelMutation) AddType(i int) {
  7331. if m.add_type != nil {
  7332. *m.add_type += i
  7333. } else {
  7334. m.add_type = &i
  7335. }
  7336. }
  7337. // AddedType returns the value that was added to the "type" field in this mutation.
  7338. func (m *LabelMutation) AddedType() (r int, exists bool) {
  7339. v := m.add_type
  7340. if v == nil {
  7341. return
  7342. }
  7343. return *v, true
  7344. }
  7345. // ResetType resets all changes to the "type" field.
  7346. func (m *LabelMutation) ResetType() {
  7347. m._type = nil
  7348. m.add_type = nil
  7349. }
  7350. // SetName sets the "name" field.
  7351. func (m *LabelMutation) SetName(s string) {
  7352. m.name = &s
  7353. }
  7354. // Name returns the value of the "name" field in the mutation.
  7355. func (m *LabelMutation) Name() (r string, exists bool) {
  7356. v := m.name
  7357. if v == nil {
  7358. return
  7359. }
  7360. return *v, true
  7361. }
  7362. // OldName returns the old "name" field's value of the Label entity.
  7363. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7365. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  7366. if !m.op.Is(OpUpdateOne) {
  7367. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7368. }
  7369. if m.id == nil || m.oldValue == nil {
  7370. return v, errors.New("OldName requires an ID field in the mutation")
  7371. }
  7372. oldValue, err := m.oldValue(ctx)
  7373. if err != nil {
  7374. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7375. }
  7376. return oldValue.Name, nil
  7377. }
  7378. // ResetName resets all changes to the "name" field.
  7379. func (m *LabelMutation) ResetName() {
  7380. m.name = nil
  7381. }
  7382. // SetFrom sets the "from" field.
  7383. func (m *LabelMutation) SetFrom(i int) {
  7384. m.from = &i
  7385. m.addfrom = nil
  7386. }
  7387. // From returns the value of the "from" field in the mutation.
  7388. func (m *LabelMutation) From() (r int, exists bool) {
  7389. v := m.from
  7390. if v == nil {
  7391. return
  7392. }
  7393. return *v, true
  7394. }
  7395. // OldFrom returns the old "from" field's value of the Label entity.
  7396. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7398. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  7399. if !m.op.Is(OpUpdateOne) {
  7400. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  7401. }
  7402. if m.id == nil || m.oldValue == nil {
  7403. return v, errors.New("OldFrom requires an ID field in the mutation")
  7404. }
  7405. oldValue, err := m.oldValue(ctx)
  7406. if err != nil {
  7407. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  7408. }
  7409. return oldValue.From, nil
  7410. }
  7411. // AddFrom adds i to the "from" field.
  7412. func (m *LabelMutation) AddFrom(i int) {
  7413. if m.addfrom != nil {
  7414. *m.addfrom += i
  7415. } else {
  7416. m.addfrom = &i
  7417. }
  7418. }
  7419. // AddedFrom returns the value that was added to the "from" field in this mutation.
  7420. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  7421. v := m.addfrom
  7422. if v == nil {
  7423. return
  7424. }
  7425. return *v, true
  7426. }
  7427. // ResetFrom resets all changes to the "from" field.
  7428. func (m *LabelMutation) ResetFrom() {
  7429. m.from = nil
  7430. m.addfrom = nil
  7431. }
  7432. // SetMode sets the "mode" field.
  7433. func (m *LabelMutation) SetMode(i int) {
  7434. m.mode = &i
  7435. m.addmode = nil
  7436. }
  7437. // Mode returns the value of the "mode" field in the mutation.
  7438. func (m *LabelMutation) Mode() (r int, exists bool) {
  7439. v := m.mode
  7440. if v == nil {
  7441. return
  7442. }
  7443. return *v, true
  7444. }
  7445. // OldMode returns the old "mode" field's value of the Label entity.
  7446. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7447. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7448. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  7449. if !m.op.Is(OpUpdateOne) {
  7450. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  7451. }
  7452. if m.id == nil || m.oldValue == nil {
  7453. return v, errors.New("OldMode requires an ID field in the mutation")
  7454. }
  7455. oldValue, err := m.oldValue(ctx)
  7456. if err != nil {
  7457. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  7458. }
  7459. return oldValue.Mode, nil
  7460. }
  7461. // AddMode adds i to the "mode" field.
  7462. func (m *LabelMutation) AddMode(i int) {
  7463. if m.addmode != nil {
  7464. *m.addmode += i
  7465. } else {
  7466. m.addmode = &i
  7467. }
  7468. }
  7469. // AddedMode returns the value that was added to the "mode" field in this mutation.
  7470. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  7471. v := m.addmode
  7472. if v == nil {
  7473. return
  7474. }
  7475. return *v, true
  7476. }
  7477. // ResetMode resets all changes to the "mode" field.
  7478. func (m *LabelMutation) ResetMode() {
  7479. m.mode = nil
  7480. m.addmode = nil
  7481. }
  7482. // SetConditions sets the "conditions" field.
  7483. func (m *LabelMutation) SetConditions(s string) {
  7484. m.conditions = &s
  7485. }
  7486. // Conditions returns the value of the "conditions" field in the mutation.
  7487. func (m *LabelMutation) Conditions() (r string, exists bool) {
  7488. v := m.conditions
  7489. if v == nil {
  7490. return
  7491. }
  7492. return *v, true
  7493. }
  7494. // OldConditions returns the old "conditions" field's value of the Label entity.
  7495. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7497. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  7498. if !m.op.Is(OpUpdateOne) {
  7499. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  7500. }
  7501. if m.id == nil || m.oldValue == nil {
  7502. return v, errors.New("OldConditions requires an ID field in the mutation")
  7503. }
  7504. oldValue, err := m.oldValue(ctx)
  7505. if err != nil {
  7506. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  7507. }
  7508. return oldValue.Conditions, nil
  7509. }
  7510. // ClearConditions clears the value of the "conditions" field.
  7511. func (m *LabelMutation) ClearConditions() {
  7512. m.conditions = nil
  7513. m.clearedFields[label.FieldConditions] = struct{}{}
  7514. }
  7515. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  7516. func (m *LabelMutation) ConditionsCleared() bool {
  7517. _, ok := m.clearedFields[label.FieldConditions]
  7518. return ok
  7519. }
  7520. // ResetConditions resets all changes to the "conditions" field.
  7521. func (m *LabelMutation) ResetConditions() {
  7522. m.conditions = nil
  7523. delete(m.clearedFields, label.FieldConditions)
  7524. }
  7525. // SetOrganizationID sets the "organization_id" field.
  7526. func (m *LabelMutation) SetOrganizationID(u uint64) {
  7527. m.organization_id = &u
  7528. m.addorganization_id = nil
  7529. }
  7530. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7531. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  7532. v := m.organization_id
  7533. if v == nil {
  7534. return
  7535. }
  7536. return *v, true
  7537. }
  7538. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  7539. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7541. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7542. if !m.op.Is(OpUpdateOne) {
  7543. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7544. }
  7545. if m.id == nil || m.oldValue == nil {
  7546. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7547. }
  7548. oldValue, err := m.oldValue(ctx)
  7549. if err != nil {
  7550. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7551. }
  7552. return oldValue.OrganizationID, nil
  7553. }
  7554. // AddOrganizationID adds u to the "organization_id" field.
  7555. func (m *LabelMutation) AddOrganizationID(u int64) {
  7556. if m.addorganization_id != nil {
  7557. *m.addorganization_id += u
  7558. } else {
  7559. m.addorganization_id = &u
  7560. }
  7561. }
  7562. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7563. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  7564. v := m.addorganization_id
  7565. if v == nil {
  7566. return
  7567. }
  7568. return *v, true
  7569. }
  7570. // ClearOrganizationID clears the value of the "organization_id" field.
  7571. func (m *LabelMutation) ClearOrganizationID() {
  7572. m.organization_id = nil
  7573. m.addorganization_id = nil
  7574. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  7575. }
  7576. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  7577. func (m *LabelMutation) OrganizationIDCleared() bool {
  7578. _, ok := m.clearedFields[label.FieldOrganizationID]
  7579. return ok
  7580. }
  7581. // ResetOrganizationID resets all changes to the "organization_id" field.
  7582. func (m *LabelMutation) ResetOrganizationID() {
  7583. m.organization_id = nil
  7584. m.addorganization_id = nil
  7585. delete(m.clearedFields, label.FieldOrganizationID)
  7586. }
  7587. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  7588. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  7589. if m.label_relationships == nil {
  7590. m.label_relationships = make(map[uint64]struct{})
  7591. }
  7592. for i := range ids {
  7593. m.label_relationships[ids[i]] = struct{}{}
  7594. }
  7595. }
  7596. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  7597. func (m *LabelMutation) ClearLabelRelationships() {
  7598. m.clearedlabel_relationships = true
  7599. }
  7600. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  7601. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  7602. return m.clearedlabel_relationships
  7603. }
  7604. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  7605. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  7606. if m.removedlabel_relationships == nil {
  7607. m.removedlabel_relationships = make(map[uint64]struct{})
  7608. }
  7609. for i := range ids {
  7610. delete(m.label_relationships, ids[i])
  7611. m.removedlabel_relationships[ids[i]] = struct{}{}
  7612. }
  7613. }
  7614. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  7615. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  7616. for id := range m.removedlabel_relationships {
  7617. ids = append(ids, id)
  7618. }
  7619. return
  7620. }
  7621. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  7622. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  7623. for id := range m.label_relationships {
  7624. ids = append(ids, id)
  7625. }
  7626. return
  7627. }
  7628. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  7629. func (m *LabelMutation) ResetLabelRelationships() {
  7630. m.label_relationships = nil
  7631. m.clearedlabel_relationships = false
  7632. m.removedlabel_relationships = nil
  7633. }
  7634. // Where appends a list predicates to the LabelMutation builder.
  7635. func (m *LabelMutation) Where(ps ...predicate.Label) {
  7636. m.predicates = append(m.predicates, ps...)
  7637. }
  7638. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  7639. // users can use type-assertion to append predicates that do not depend on any generated package.
  7640. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  7641. p := make([]predicate.Label, len(ps))
  7642. for i := range ps {
  7643. p[i] = ps[i]
  7644. }
  7645. m.Where(p...)
  7646. }
  7647. // Op returns the operation name.
  7648. func (m *LabelMutation) Op() Op {
  7649. return m.op
  7650. }
  7651. // SetOp allows setting the mutation operation.
  7652. func (m *LabelMutation) SetOp(op Op) {
  7653. m.op = op
  7654. }
  7655. // Type returns the node type of this mutation (Label).
  7656. func (m *LabelMutation) Type() string {
  7657. return m.typ
  7658. }
  7659. // Fields returns all fields that were changed during this mutation. Note that in
  7660. // order to get all numeric fields that were incremented/decremented, call
  7661. // AddedFields().
  7662. func (m *LabelMutation) Fields() []string {
  7663. fields := make([]string, 0, 9)
  7664. if m.created_at != nil {
  7665. fields = append(fields, label.FieldCreatedAt)
  7666. }
  7667. if m.updated_at != nil {
  7668. fields = append(fields, label.FieldUpdatedAt)
  7669. }
  7670. if m.status != nil {
  7671. fields = append(fields, label.FieldStatus)
  7672. }
  7673. if m._type != nil {
  7674. fields = append(fields, label.FieldType)
  7675. }
  7676. if m.name != nil {
  7677. fields = append(fields, label.FieldName)
  7678. }
  7679. if m.from != nil {
  7680. fields = append(fields, label.FieldFrom)
  7681. }
  7682. if m.mode != nil {
  7683. fields = append(fields, label.FieldMode)
  7684. }
  7685. if m.conditions != nil {
  7686. fields = append(fields, label.FieldConditions)
  7687. }
  7688. if m.organization_id != nil {
  7689. fields = append(fields, label.FieldOrganizationID)
  7690. }
  7691. return fields
  7692. }
  7693. // Field returns the value of a field with the given name. The second boolean
  7694. // return value indicates that this field was not set, or was not defined in the
  7695. // schema.
  7696. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  7697. switch name {
  7698. case label.FieldCreatedAt:
  7699. return m.CreatedAt()
  7700. case label.FieldUpdatedAt:
  7701. return m.UpdatedAt()
  7702. case label.FieldStatus:
  7703. return m.Status()
  7704. case label.FieldType:
  7705. return m.GetType()
  7706. case label.FieldName:
  7707. return m.Name()
  7708. case label.FieldFrom:
  7709. return m.From()
  7710. case label.FieldMode:
  7711. return m.Mode()
  7712. case label.FieldConditions:
  7713. return m.Conditions()
  7714. case label.FieldOrganizationID:
  7715. return m.OrganizationID()
  7716. }
  7717. return nil, false
  7718. }
  7719. // OldField returns the old value of the field from the database. An error is
  7720. // returned if the mutation operation is not UpdateOne, or the query to the
  7721. // database failed.
  7722. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7723. switch name {
  7724. case label.FieldCreatedAt:
  7725. return m.OldCreatedAt(ctx)
  7726. case label.FieldUpdatedAt:
  7727. return m.OldUpdatedAt(ctx)
  7728. case label.FieldStatus:
  7729. return m.OldStatus(ctx)
  7730. case label.FieldType:
  7731. return m.OldType(ctx)
  7732. case label.FieldName:
  7733. return m.OldName(ctx)
  7734. case label.FieldFrom:
  7735. return m.OldFrom(ctx)
  7736. case label.FieldMode:
  7737. return m.OldMode(ctx)
  7738. case label.FieldConditions:
  7739. return m.OldConditions(ctx)
  7740. case label.FieldOrganizationID:
  7741. return m.OldOrganizationID(ctx)
  7742. }
  7743. return nil, fmt.Errorf("unknown Label field %s", name)
  7744. }
  7745. // SetField sets the value of a field with the given name. It returns an error if
  7746. // the field is not defined in the schema, or if the type mismatched the field
  7747. // type.
  7748. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  7749. switch name {
  7750. case label.FieldCreatedAt:
  7751. v, ok := value.(time.Time)
  7752. if !ok {
  7753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7754. }
  7755. m.SetCreatedAt(v)
  7756. return nil
  7757. case label.FieldUpdatedAt:
  7758. v, ok := value.(time.Time)
  7759. if !ok {
  7760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7761. }
  7762. m.SetUpdatedAt(v)
  7763. return nil
  7764. case label.FieldStatus:
  7765. v, ok := value.(uint8)
  7766. if !ok {
  7767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7768. }
  7769. m.SetStatus(v)
  7770. return nil
  7771. case label.FieldType:
  7772. v, ok := value.(int)
  7773. if !ok {
  7774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7775. }
  7776. m.SetType(v)
  7777. return nil
  7778. case label.FieldName:
  7779. v, ok := value.(string)
  7780. if !ok {
  7781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7782. }
  7783. m.SetName(v)
  7784. return nil
  7785. case label.FieldFrom:
  7786. v, ok := value.(int)
  7787. if !ok {
  7788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7789. }
  7790. m.SetFrom(v)
  7791. return nil
  7792. case label.FieldMode:
  7793. v, ok := value.(int)
  7794. if !ok {
  7795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7796. }
  7797. m.SetMode(v)
  7798. return nil
  7799. case label.FieldConditions:
  7800. v, ok := value.(string)
  7801. if !ok {
  7802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7803. }
  7804. m.SetConditions(v)
  7805. return nil
  7806. case label.FieldOrganizationID:
  7807. v, ok := value.(uint64)
  7808. if !ok {
  7809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7810. }
  7811. m.SetOrganizationID(v)
  7812. return nil
  7813. }
  7814. return fmt.Errorf("unknown Label field %s", name)
  7815. }
  7816. // AddedFields returns all numeric fields that were incremented/decremented during
  7817. // this mutation.
  7818. func (m *LabelMutation) AddedFields() []string {
  7819. var fields []string
  7820. if m.addstatus != nil {
  7821. fields = append(fields, label.FieldStatus)
  7822. }
  7823. if m.add_type != nil {
  7824. fields = append(fields, label.FieldType)
  7825. }
  7826. if m.addfrom != nil {
  7827. fields = append(fields, label.FieldFrom)
  7828. }
  7829. if m.addmode != nil {
  7830. fields = append(fields, label.FieldMode)
  7831. }
  7832. if m.addorganization_id != nil {
  7833. fields = append(fields, label.FieldOrganizationID)
  7834. }
  7835. return fields
  7836. }
  7837. // AddedField returns the numeric value that was incremented/decremented on a field
  7838. // with the given name. The second boolean return value indicates that this field
  7839. // was not set, or was not defined in the schema.
  7840. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  7841. switch name {
  7842. case label.FieldStatus:
  7843. return m.AddedStatus()
  7844. case label.FieldType:
  7845. return m.AddedType()
  7846. case label.FieldFrom:
  7847. return m.AddedFrom()
  7848. case label.FieldMode:
  7849. return m.AddedMode()
  7850. case label.FieldOrganizationID:
  7851. return m.AddedOrganizationID()
  7852. }
  7853. return nil, false
  7854. }
  7855. // AddField adds the value to the field with the given name. It returns an error if
  7856. // the field is not defined in the schema, or if the type mismatched the field
  7857. // type.
  7858. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  7859. switch name {
  7860. case label.FieldStatus:
  7861. v, ok := value.(int8)
  7862. if !ok {
  7863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7864. }
  7865. m.AddStatus(v)
  7866. return nil
  7867. case label.FieldType:
  7868. v, ok := value.(int)
  7869. if !ok {
  7870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7871. }
  7872. m.AddType(v)
  7873. return nil
  7874. case label.FieldFrom:
  7875. v, ok := value.(int)
  7876. if !ok {
  7877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7878. }
  7879. m.AddFrom(v)
  7880. return nil
  7881. case label.FieldMode:
  7882. v, ok := value.(int)
  7883. if !ok {
  7884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7885. }
  7886. m.AddMode(v)
  7887. return nil
  7888. case label.FieldOrganizationID:
  7889. v, ok := value.(int64)
  7890. if !ok {
  7891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7892. }
  7893. m.AddOrganizationID(v)
  7894. return nil
  7895. }
  7896. return fmt.Errorf("unknown Label numeric field %s", name)
  7897. }
  7898. // ClearedFields returns all nullable fields that were cleared during this
  7899. // mutation.
  7900. func (m *LabelMutation) ClearedFields() []string {
  7901. var fields []string
  7902. if m.FieldCleared(label.FieldStatus) {
  7903. fields = append(fields, label.FieldStatus)
  7904. }
  7905. if m.FieldCleared(label.FieldConditions) {
  7906. fields = append(fields, label.FieldConditions)
  7907. }
  7908. if m.FieldCleared(label.FieldOrganizationID) {
  7909. fields = append(fields, label.FieldOrganizationID)
  7910. }
  7911. return fields
  7912. }
  7913. // FieldCleared returns a boolean indicating if a field with the given name was
  7914. // cleared in this mutation.
  7915. func (m *LabelMutation) FieldCleared(name string) bool {
  7916. _, ok := m.clearedFields[name]
  7917. return ok
  7918. }
  7919. // ClearField clears the value of the field with the given name. It returns an
  7920. // error if the field is not defined in the schema.
  7921. func (m *LabelMutation) ClearField(name string) error {
  7922. switch name {
  7923. case label.FieldStatus:
  7924. m.ClearStatus()
  7925. return nil
  7926. case label.FieldConditions:
  7927. m.ClearConditions()
  7928. return nil
  7929. case label.FieldOrganizationID:
  7930. m.ClearOrganizationID()
  7931. return nil
  7932. }
  7933. return fmt.Errorf("unknown Label nullable field %s", name)
  7934. }
  7935. // ResetField resets all changes in the mutation for the field with the given name.
  7936. // It returns an error if the field is not defined in the schema.
  7937. func (m *LabelMutation) ResetField(name string) error {
  7938. switch name {
  7939. case label.FieldCreatedAt:
  7940. m.ResetCreatedAt()
  7941. return nil
  7942. case label.FieldUpdatedAt:
  7943. m.ResetUpdatedAt()
  7944. return nil
  7945. case label.FieldStatus:
  7946. m.ResetStatus()
  7947. return nil
  7948. case label.FieldType:
  7949. m.ResetType()
  7950. return nil
  7951. case label.FieldName:
  7952. m.ResetName()
  7953. return nil
  7954. case label.FieldFrom:
  7955. m.ResetFrom()
  7956. return nil
  7957. case label.FieldMode:
  7958. m.ResetMode()
  7959. return nil
  7960. case label.FieldConditions:
  7961. m.ResetConditions()
  7962. return nil
  7963. case label.FieldOrganizationID:
  7964. m.ResetOrganizationID()
  7965. return nil
  7966. }
  7967. return fmt.Errorf("unknown Label field %s", name)
  7968. }
  7969. // AddedEdges returns all edge names that were set/added in this mutation.
  7970. func (m *LabelMutation) AddedEdges() []string {
  7971. edges := make([]string, 0, 1)
  7972. if m.label_relationships != nil {
  7973. edges = append(edges, label.EdgeLabelRelationships)
  7974. }
  7975. return edges
  7976. }
  7977. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7978. // name in this mutation.
  7979. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  7980. switch name {
  7981. case label.EdgeLabelRelationships:
  7982. ids := make([]ent.Value, 0, len(m.label_relationships))
  7983. for id := range m.label_relationships {
  7984. ids = append(ids, id)
  7985. }
  7986. return ids
  7987. }
  7988. return nil
  7989. }
  7990. // RemovedEdges returns all edge names that were removed in this mutation.
  7991. func (m *LabelMutation) RemovedEdges() []string {
  7992. edges := make([]string, 0, 1)
  7993. if m.removedlabel_relationships != nil {
  7994. edges = append(edges, label.EdgeLabelRelationships)
  7995. }
  7996. return edges
  7997. }
  7998. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7999. // the given name in this mutation.
  8000. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  8001. switch name {
  8002. case label.EdgeLabelRelationships:
  8003. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  8004. for id := range m.removedlabel_relationships {
  8005. ids = append(ids, id)
  8006. }
  8007. return ids
  8008. }
  8009. return nil
  8010. }
  8011. // ClearedEdges returns all edge names that were cleared in this mutation.
  8012. func (m *LabelMutation) ClearedEdges() []string {
  8013. edges := make([]string, 0, 1)
  8014. if m.clearedlabel_relationships {
  8015. edges = append(edges, label.EdgeLabelRelationships)
  8016. }
  8017. return edges
  8018. }
  8019. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8020. // was cleared in this mutation.
  8021. func (m *LabelMutation) EdgeCleared(name string) bool {
  8022. switch name {
  8023. case label.EdgeLabelRelationships:
  8024. return m.clearedlabel_relationships
  8025. }
  8026. return false
  8027. }
  8028. // ClearEdge clears the value of the edge with the given name. It returns an error
  8029. // if that edge is not defined in the schema.
  8030. func (m *LabelMutation) ClearEdge(name string) error {
  8031. switch name {
  8032. }
  8033. return fmt.Errorf("unknown Label unique edge %s", name)
  8034. }
  8035. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8036. // It returns an error if the edge is not defined in the schema.
  8037. func (m *LabelMutation) ResetEdge(name string) error {
  8038. switch name {
  8039. case label.EdgeLabelRelationships:
  8040. m.ResetLabelRelationships()
  8041. return nil
  8042. }
  8043. return fmt.Errorf("unknown Label edge %s", name)
  8044. }
  8045. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  8046. type LabelRelationshipMutation struct {
  8047. config
  8048. op Op
  8049. typ string
  8050. id *uint64
  8051. created_at *time.Time
  8052. updated_at *time.Time
  8053. status *uint8
  8054. addstatus *int8
  8055. deleted_at *time.Time
  8056. organization_id *uint64
  8057. addorganization_id *int64
  8058. clearedFields map[string]struct{}
  8059. contacts *uint64
  8060. clearedcontacts bool
  8061. labels *uint64
  8062. clearedlabels bool
  8063. done bool
  8064. oldValue func(context.Context) (*LabelRelationship, error)
  8065. predicates []predicate.LabelRelationship
  8066. }
  8067. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  8068. // labelrelationshipOption allows management of the mutation configuration using functional options.
  8069. type labelrelationshipOption func(*LabelRelationshipMutation)
  8070. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  8071. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  8072. m := &LabelRelationshipMutation{
  8073. config: c,
  8074. op: op,
  8075. typ: TypeLabelRelationship,
  8076. clearedFields: make(map[string]struct{}),
  8077. }
  8078. for _, opt := range opts {
  8079. opt(m)
  8080. }
  8081. return m
  8082. }
  8083. // withLabelRelationshipID sets the ID field of the mutation.
  8084. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  8085. return func(m *LabelRelationshipMutation) {
  8086. var (
  8087. err error
  8088. once sync.Once
  8089. value *LabelRelationship
  8090. )
  8091. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  8092. once.Do(func() {
  8093. if m.done {
  8094. err = errors.New("querying old values post mutation is not allowed")
  8095. } else {
  8096. value, err = m.Client().LabelRelationship.Get(ctx, id)
  8097. }
  8098. })
  8099. return value, err
  8100. }
  8101. m.id = &id
  8102. }
  8103. }
  8104. // withLabelRelationship sets the old LabelRelationship of the mutation.
  8105. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  8106. return func(m *LabelRelationshipMutation) {
  8107. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  8108. return node, nil
  8109. }
  8110. m.id = &node.ID
  8111. }
  8112. }
  8113. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8114. // executed in a transaction (ent.Tx), a transactional client is returned.
  8115. func (m LabelRelationshipMutation) Client() *Client {
  8116. client := &Client{config: m.config}
  8117. client.init()
  8118. return client
  8119. }
  8120. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8121. // it returns an error otherwise.
  8122. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  8123. if _, ok := m.driver.(*txDriver); !ok {
  8124. return nil, errors.New("ent: mutation is not running in a transaction")
  8125. }
  8126. tx := &Tx{config: m.config}
  8127. tx.init()
  8128. return tx, nil
  8129. }
  8130. // SetID sets the value of the id field. Note that this
  8131. // operation is only accepted on creation of LabelRelationship entities.
  8132. func (m *LabelRelationshipMutation) SetID(id uint64) {
  8133. m.id = &id
  8134. }
  8135. // ID returns the ID value in the mutation. Note that the ID is only available
  8136. // if it was provided to the builder or after it was returned from the database.
  8137. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  8138. if m.id == nil {
  8139. return
  8140. }
  8141. return *m.id, true
  8142. }
  8143. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8144. // That means, if the mutation is applied within a transaction with an isolation level such
  8145. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8146. // or updated by the mutation.
  8147. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  8148. switch {
  8149. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8150. id, exists := m.ID()
  8151. if exists {
  8152. return []uint64{id}, nil
  8153. }
  8154. fallthrough
  8155. case m.op.Is(OpUpdate | OpDelete):
  8156. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  8157. default:
  8158. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8159. }
  8160. }
  8161. // SetCreatedAt sets the "created_at" field.
  8162. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  8163. m.created_at = &t
  8164. }
  8165. // CreatedAt returns the value of the "created_at" field in the mutation.
  8166. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  8167. v := m.created_at
  8168. if v == nil {
  8169. return
  8170. }
  8171. return *v, true
  8172. }
  8173. // OldCreatedAt returns the old "created_at" 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) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8177. if !m.op.Is(OpUpdateOne) {
  8178. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8179. }
  8180. if m.id == nil || m.oldValue == nil {
  8181. return v, errors.New("OldCreatedAt 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 OldCreatedAt: %w", err)
  8186. }
  8187. return oldValue.CreatedAt, nil
  8188. }
  8189. // ResetCreatedAt resets all changes to the "created_at" field.
  8190. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  8191. m.created_at = nil
  8192. }
  8193. // SetUpdatedAt sets the "updated_at" field.
  8194. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  8195. m.updated_at = &t
  8196. }
  8197. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8198. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  8199. v := m.updated_at
  8200. if v == nil {
  8201. return
  8202. }
  8203. return *v, true
  8204. }
  8205. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  8206. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8208. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8209. if !m.op.Is(OpUpdateOne) {
  8210. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8211. }
  8212. if m.id == nil || m.oldValue == nil {
  8213. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8214. }
  8215. oldValue, err := m.oldValue(ctx)
  8216. if err != nil {
  8217. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8218. }
  8219. return oldValue.UpdatedAt, nil
  8220. }
  8221. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8222. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  8223. m.updated_at = nil
  8224. }
  8225. // SetStatus sets the "status" field.
  8226. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  8227. m.status = &u
  8228. m.addstatus = nil
  8229. }
  8230. // Status returns the value of the "status" field in the mutation.
  8231. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  8232. v := m.status
  8233. if v == nil {
  8234. return
  8235. }
  8236. return *v, true
  8237. }
  8238. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  8239. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8241. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  8242. if !m.op.Is(OpUpdateOne) {
  8243. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  8244. }
  8245. if m.id == nil || m.oldValue == nil {
  8246. return v, errors.New("OldStatus requires an ID field in the mutation")
  8247. }
  8248. oldValue, err := m.oldValue(ctx)
  8249. if err != nil {
  8250. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  8251. }
  8252. return oldValue.Status, nil
  8253. }
  8254. // AddStatus adds u to the "status" field.
  8255. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  8256. if m.addstatus != nil {
  8257. *m.addstatus += u
  8258. } else {
  8259. m.addstatus = &u
  8260. }
  8261. }
  8262. // AddedStatus returns the value that was added to the "status" field in this mutation.
  8263. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  8264. v := m.addstatus
  8265. if v == nil {
  8266. return
  8267. }
  8268. return *v, true
  8269. }
  8270. // ClearStatus clears the value of the "status" field.
  8271. func (m *LabelRelationshipMutation) ClearStatus() {
  8272. m.status = nil
  8273. m.addstatus = nil
  8274. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  8275. }
  8276. // StatusCleared returns if the "status" field was cleared in this mutation.
  8277. func (m *LabelRelationshipMutation) StatusCleared() bool {
  8278. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  8279. return ok
  8280. }
  8281. // ResetStatus resets all changes to the "status" field.
  8282. func (m *LabelRelationshipMutation) ResetStatus() {
  8283. m.status = nil
  8284. m.addstatus = nil
  8285. delete(m.clearedFields, labelrelationship.FieldStatus)
  8286. }
  8287. // SetDeletedAt sets the "deleted_at" field.
  8288. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  8289. m.deleted_at = &t
  8290. }
  8291. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8292. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  8293. v := m.deleted_at
  8294. if v == nil {
  8295. return
  8296. }
  8297. return *v, true
  8298. }
  8299. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  8300. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8302. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8303. if !m.op.Is(OpUpdateOne) {
  8304. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8305. }
  8306. if m.id == nil || m.oldValue == nil {
  8307. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8308. }
  8309. oldValue, err := m.oldValue(ctx)
  8310. if err != nil {
  8311. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8312. }
  8313. return oldValue.DeletedAt, nil
  8314. }
  8315. // ClearDeletedAt clears the value of the "deleted_at" field.
  8316. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  8317. m.deleted_at = nil
  8318. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  8319. }
  8320. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8321. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  8322. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  8323. return ok
  8324. }
  8325. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8326. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  8327. m.deleted_at = nil
  8328. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  8329. }
  8330. // SetLabelID sets the "label_id" field.
  8331. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  8332. m.labels = &u
  8333. }
  8334. // LabelID returns the value of the "label_id" field in the mutation.
  8335. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  8336. v := m.labels
  8337. if v == nil {
  8338. return
  8339. }
  8340. return *v, true
  8341. }
  8342. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  8343. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8345. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  8346. if !m.op.Is(OpUpdateOne) {
  8347. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  8348. }
  8349. if m.id == nil || m.oldValue == nil {
  8350. return v, errors.New("OldLabelID requires an ID field in the mutation")
  8351. }
  8352. oldValue, err := m.oldValue(ctx)
  8353. if err != nil {
  8354. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  8355. }
  8356. return oldValue.LabelID, nil
  8357. }
  8358. // ResetLabelID resets all changes to the "label_id" field.
  8359. func (m *LabelRelationshipMutation) ResetLabelID() {
  8360. m.labels = nil
  8361. }
  8362. // SetContactID sets the "contact_id" field.
  8363. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  8364. m.contacts = &u
  8365. }
  8366. // ContactID returns the value of the "contact_id" field in the mutation.
  8367. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  8368. v := m.contacts
  8369. if v == nil {
  8370. return
  8371. }
  8372. return *v, true
  8373. }
  8374. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  8375. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8377. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  8378. if !m.op.Is(OpUpdateOne) {
  8379. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  8380. }
  8381. if m.id == nil || m.oldValue == nil {
  8382. return v, errors.New("OldContactID requires an ID field in the mutation")
  8383. }
  8384. oldValue, err := m.oldValue(ctx)
  8385. if err != nil {
  8386. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  8387. }
  8388. return oldValue.ContactID, nil
  8389. }
  8390. // ResetContactID resets all changes to the "contact_id" field.
  8391. func (m *LabelRelationshipMutation) ResetContactID() {
  8392. m.contacts = nil
  8393. }
  8394. // SetOrganizationID sets the "organization_id" field.
  8395. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  8396. m.organization_id = &u
  8397. m.addorganization_id = nil
  8398. }
  8399. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8400. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  8401. v := m.organization_id
  8402. if v == nil {
  8403. return
  8404. }
  8405. return *v, true
  8406. }
  8407. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  8408. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8410. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8411. if !m.op.Is(OpUpdateOne) {
  8412. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8413. }
  8414. if m.id == nil || m.oldValue == nil {
  8415. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8416. }
  8417. oldValue, err := m.oldValue(ctx)
  8418. if err != nil {
  8419. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8420. }
  8421. return oldValue.OrganizationID, nil
  8422. }
  8423. // AddOrganizationID adds u to the "organization_id" field.
  8424. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  8425. if m.addorganization_id != nil {
  8426. *m.addorganization_id += u
  8427. } else {
  8428. m.addorganization_id = &u
  8429. }
  8430. }
  8431. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8432. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  8433. v := m.addorganization_id
  8434. if v == nil {
  8435. return
  8436. }
  8437. return *v, true
  8438. }
  8439. // ClearOrganizationID clears the value of the "organization_id" field.
  8440. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  8441. m.organization_id = nil
  8442. m.addorganization_id = nil
  8443. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  8444. }
  8445. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  8446. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  8447. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  8448. return ok
  8449. }
  8450. // ResetOrganizationID resets all changes to the "organization_id" field.
  8451. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  8452. m.organization_id = nil
  8453. m.addorganization_id = nil
  8454. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  8455. }
  8456. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  8457. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  8458. m.contacts = &id
  8459. }
  8460. // ClearContacts clears the "contacts" edge to the Contact entity.
  8461. func (m *LabelRelationshipMutation) ClearContacts() {
  8462. m.clearedcontacts = true
  8463. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  8464. }
  8465. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  8466. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  8467. return m.clearedcontacts
  8468. }
  8469. // ContactsID returns the "contacts" edge ID in the mutation.
  8470. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  8471. if m.contacts != nil {
  8472. return *m.contacts, true
  8473. }
  8474. return
  8475. }
  8476. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  8477. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  8478. // ContactsID instead. It exists only for internal usage by the builders.
  8479. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  8480. if id := m.contacts; id != nil {
  8481. ids = append(ids, *id)
  8482. }
  8483. return
  8484. }
  8485. // ResetContacts resets all changes to the "contacts" edge.
  8486. func (m *LabelRelationshipMutation) ResetContacts() {
  8487. m.contacts = nil
  8488. m.clearedcontacts = false
  8489. }
  8490. // SetLabelsID sets the "labels" edge to the Label entity by id.
  8491. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  8492. m.labels = &id
  8493. }
  8494. // ClearLabels clears the "labels" edge to the Label entity.
  8495. func (m *LabelRelationshipMutation) ClearLabels() {
  8496. m.clearedlabels = true
  8497. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  8498. }
  8499. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  8500. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  8501. return m.clearedlabels
  8502. }
  8503. // LabelsID returns the "labels" edge ID in the mutation.
  8504. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  8505. if m.labels != nil {
  8506. return *m.labels, true
  8507. }
  8508. return
  8509. }
  8510. // LabelsIDs returns the "labels" edge IDs in the mutation.
  8511. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  8512. // LabelsID instead. It exists only for internal usage by the builders.
  8513. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  8514. if id := m.labels; id != nil {
  8515. ids = append(ids, *id)
  8516. }
  8517. return
  8518. }
  8519. // ResetLabels resets all changes to the "labels" edge.
  8520. func (m *LabelRelationshipMutation) ResetLabels() {
  8521. m.labels = nil
  8522. m.clearedlabels = false
  8523. }
  8524. // Where appends a list predicates to the LabelRelationshipMutation builder.
  8525. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  8526. m.predicates = append(m.predicates, ps...)
  8527. }
  8528. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  8529. // users can use type-assertion to append predicates that do not depend on any generated package.
  8530. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  8531. p := make([]predicate.LabelRelationship, len(ps))
  8532. for i := range ps {
  8533. p[i] = ps[i]
  8534. }
  8535. m.Where(p...)
  8536. }
  8537. // Op returns the operation name.
  8538. func (m *LabelRelationshipMutation) Op() Op {
  8539. return m.op
  8540. }
  8541. // SetOp allows setting the mutation operation.
  8542. func (m *LabelRelationshipMutation) SetOp(op Op) {
  8543. m.op = op
  8544. }
  8545. // Type returns the node type of this mutation (LabelRelationship).
  8546. func (m *LabelRelationshipMutation) Type() string {
  8547. return m.typ
  8548. }
  8549. // Fields returns all fields that were changed during this mutation. Note that in
  8550. // order to get all numeric fields that were incremented/decremented, call
  8551. // AddedFields().
  8552. func (m *LabelRelationshipMutation) Fields() []string {
  8553. fields := make([]string, 0, 7)
  8554. if m.created_at != nil {
  8555. fields = append(fields, labelrelationship.FieldCreatedAt)
  8556. }
  8557. if m.updated_at != nil {
  8558. fields = append(fields, labelrelationship.FieldUpdatedAt)
  8559. }
  8560. if m.status != nil {
  8561. fields = append(fields, labelrelationship.FieldStatus)
  8562. }
  8563. if m.deleted_at != nil {
  8564. fields = append(fields, labelrelationship.FieldDeletedAt)
  8565. }
  8566. if m.labels != nil {
  8567. fields = append(fields, labelrelationship.FieldLabelID)
  8568. }
  8569. if m.contacts != nil {
  8570. fields = append(fields, labelrelationship.FieldContactID)
  8571. }
  8572. if m.organization_id != nil {
  8573. fields = append(fields, labelrelationship.FieldOrganizationID)
  8574. }
  8575. return fields
  8576. }
  8577. // Field returns the value of a field with the given name. The second boolean
  8578. // return value indicates that this field was not set, or was not defined in the
  8579. // schema.
  8580. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  8581. switch name {
  8582. case labelrelationship.FieldCreatedAt:
  8583. return m.CreatedAt()
  8584. case labelrelationship.FieldUpdatedAt:
  8585. return m.UpdatedAt()
  8586. case labelrelationship.FieldStatus:
  8587. return m.Status()
  8588. case labelrelationship.FieldDeletedAt:
  8589. return m.DeletedAt()
  8590. case labelrelationship.FieldLabelID:
  8591. return m.LabelID()
  8592. case labelrelationship.FieldContactID:
  8593. return m.ContactID()
  8594. case labelrelationship.FieldOrganizationID:
  8595. return m.OrganizationID()
  8596. }
  8597. return nil, false
  8598. }
  8599. // OldField returns the old value of the field from the database. An error is
  8600. // returned if the mutation operation is not UpdateOne, or the query to the
  8601. // database failed.
  8602. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8603. switch name {
  8604. case labelrelationship.FieldCreatedAt:
  8605. return m.OldCreatedAt(ctx)
  8606. case labelrelationship.FieldUpdatedAt:
  8607. return m.OldUpdatedAt(ctx)
  8608. case labelrelationship.FieldStatus:
  8609. return m.OldStatus(ctx)
  8610. case labelrelationship.FieldDeletedAt:
  8611. return m.OldDeletedAt(ctx)
  8612. case labelrelationship.FieldLabelID:
  8613. return m.OldLabelID(ctx)
  8614. case labelrelationship.FieldContactID:
  8615. return m.OldContactID(ctx)
  8616. case labelrelationship.FieldOrganizationID:
  8617. return m.OldOrganizationID(ctx)
  8618. }
  8619. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  8620. }
  8621. // SetField sets the value of a field with the given name. It returns an error if
  8622. // the field is not defined in the schema, or if the type mismatched the field
  8623. // type.
  8624. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  8625. switch name {
  8626. case labelrelationship.FieldCreatedAt:
  8627. v, ok := value.(time.Time)
  8628. if !ok {
  8629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8630. }
  8631. m.SetCreatedAt(v)
  8632. return nil
  8633. case labelrelationship.FieldUpdatedAt:
  8634. v, ok := value.(time.Time)
  8635. if !ok {
  8636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8637. }
  8638. m.SetUpdatedAt(v)
  8639. return nil
  8640. case labelrelationship.FieldStatus:
  8641. v, ok := value.(uint8)
  8642. if !ok {
  8643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8644. }
  8645. m.SetStatus(v)
  8646. return nil
  8647. case labelrelationship.FieldDeletedAt:
  8648. v, ok := value.(time.Time)
  8649. if !ok {
  8650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8651. }
  8652. m.SetDeletedAt(v)
  8653. return nil
  8654. case labelrelationship.FieldLabelID:
  8655. v, ok := value.(uint64)
  8656. if !ok {
  8657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8658. }
  8659. m.SetLabelID(v)
  8660. return nil
  8661. case labelrelationship.FieldContactID:
  8662. v, ok := value.(uint64)
  8663. if !ok {
  8664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8665. }
  8666. m.SetContactID(v)
  8667. return nil
  8668. case labelrelationship.FieldOrganizationID:
  8669. v, ok := value.(uint64)
  8670. if !ok {
  8671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8672. }
  8673. m.SetOrganizationID(v)
  8674. return nil
  8675. }
  8676. return fmt.Errorf("unknown LabelRelationship field %s", name)
  8677. }
  8678. // AddedFields returns all numeric fields that were incremented/decremented during
  8679. // this mutation.
  8680. func (m *LabelRelationshipMutation) AddedFields() []string {
  8681. var fields []string
  8682. if m.addstatus != nil {
  8683. fields = append(fields, labelrelationship.FieldStatus)
  8684. }
  8685. if m.addorganization_id != nil {
  8686. fields = append(fields, labelrelationship.FieldOrganizationID)
  8687. }
  8688. return fields
  8689. }
  8690. // AddedField returns the numeric value that was incremented/decremented on a field
  8691. // with the given name. The second boolean return value indicates that this field
  8692. // was not set, or was not defined in the schema.
  8693. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  8694. switch name {
  8695. case labelrelationship.FieldStatus:
  8696. return m.AddedStatus()
  8697. case labelrelationship.FieldOrganizationID:
  8698. return m.AddedOrganizationID()
  8699. }
  8700. return nil, false
  8701. }
  8702. // AddField adds the value to the field with the given name. It returns an error if
  8703. // the field is not defined in the schema, or if the type mismatched the field
  8704. // type.
  8705. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  8706. switch name {
  8707. case labelrelationship.FieldStatus:
  8708. v, ok := value.(int8)
  8709. if !ok {
  8710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8711. }
  8712. m.AddStatus(v)
  8713. return nil
  8714. case labelrelationship.FieldOrganizationID:
  8715. v, ok := value.(int64)
  8716. if !ok {
  8717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8718. }
  8719. m.AddOrganizationID(v)
  8720. return nil
  8721. }
  8722. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  8723. }
  8724. // ClearedFields returns all nullable fields that were cleared during this
  8725. // mutation.
  8726. func (m *LabelRelationshipMutation) ClearedFields() []string {
  8727. var fields []string
  8728. if m.FieldCleared(labelrelationship.FieldStatus) {
  8729. fields = append(fields, labelrelationship.FieldStatus)
  8730. }
  8731. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  8732. fields = append(fields, labelrelationship.FieldDeletedAt)
  8733. }
  8734. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  8735. fields = append(fields, labelrelationship.FieldOrganizationID)
  8736. }
  8737. return fields
  8738. }
  8739. // FieldCleared returns a boolean indicating if a field with the given name was
  8740. // cleared in this mutation.
  8741. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  8742. _, ok := m.clearedFields[name]
  8743. return ok
  8744. }
  8745. // ClearField clears the value of the field with the given name. It returns an
  8746. // error if the field is not defined in the schema.
  8747. func (m *LabelRelationshipMutation) ClearField(name string) error {
  8748. switch name {
  8749. case labelrelationship.FieldStatus:
  8750. m.ClearStatus()
  8751. return nil
  8752. case labelrelationship.FieldDeletedAt:
  8753. m.ClearDeletedAt()
  8754. return nil
  8755. case labelrelationship.FieldOrganizationID:
  8756. m.ClearOrganizationID()
  8757. return nil
  8758. }
  8759. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  8760. }
  8761. // ResetField resets all changes in the mutation for the field with the given name.
  8762. // It returns an error if the field is not defined in the schema.
  8763. func (m *LabelRelationshipMutation) ResetField(name string) error {
  8764. switch name {
  8765. case labelrelationship.FieldCreatedAt:
  8766. m.ResetCreatedAt()
  8767. return nil
  8768. case labelrelationship.FieldUpdatedAt:
  8769. m.ResetUpdatedAt()
  8770. return nil
  8771. case labelrelationship.FieldStatus:
  8772. m.ResetStatus()
  8773. return nil
  8774. case labelrelationship.FieldDeletedAt:
  8775. m.ResetDeletedAt()
  8776. return nil
  8777. case labelrelationship.FieldLabelID:
  8778. m.ResetLabelID()
  8779. return nil
  8780. case labelrelationship.FieldContactID:
  8781. m.ResetContactID()
  8782. return nil
  8783. case labelrelationship.FieldOrganizationID:
  8784. m.ResetOrganizationID()
  8785. return nil
  8786. }
  8787. return fmt.Errorf("unknown LabelRelationship field %s", name)
  8788. }
  8789. // AddedEdges returns all edge names that were set/added in this mutation.
  8790. func (m *LabelRelationshipMutation) AddedEdges() []string {
  8791. edges := make([]string, 0, 2)
  8792. if m.contacts != nil {
  8793. edges = append(edges, labelrelationship.EdgeContacts)
  8794. }
  8795. if m.labels != nil {
  8796. edges = append(edges, labelrelationship.EdgeLabels)
  8797. }
  8798. return edges
  8799. }
  8800. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8801. // name in this mutation.
  8802. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  8803. switch name {
  8804. case labelrelationship.EdgeContacts:
  8805. if id := m.contacts; id != nil {
  8806. return []ent.Value{*id}
  8807. }
  8808. case labelrelationship.EdgeLabels:
  8809. if id := m.labels; id != nil {
  8810. return []ent.Value{*id}
  8811. }
  8812. }
  8813. return nil
  8814. }
  8815. // RemovedEdges returns all edge names that were removed in this mutation.
  8816. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  8817. edges := make([]string, 0, 2)
  8818. return edges
  8819. }
  8820. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8821. // the given name in this mutation.
  8822. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  8823. return nil
  8824. }
  8825. // ClearedEdges returns all edge names that were cleared in this mutation.
  8826. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  8827. edges := make([]string, 0, 2)
  8828. if m.clearedcontacts {
  8829. edges = append(edges, labelrelationship.EdgeContacts)
  8830. }
  8831. if m.clearedlabels {
  8832. edges = append(edges, labelrelationship.EdgeLabels)
  8833. }
  8834. return edges
  8835. }
  8836. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8837. // was cleared in this mutation.
  8838. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  8839. switch name {
  8840. case labelrelationship.EdgeContacts:
  8841. return m.clearedcontacts
  8842. case labelrelationship.EdgeLabels:
  8843. return m.clearedlabels
  8844. }
  8845. return false
  8846. }
  8847. // ClearEdge clears the value of the edge with the given name. It returns an error
  8848. // if that edge is not defined in the schema.
  8849. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  8850. switch name {
  8851. case labelrelationship.EdgeContacts:
  8852. m.ClearContacts()
  8853. return nil
  8854. case labelrelationship.EdgeLabels:
  8855. m.ClearLabels()
  8856. return nil
  8857. }
  8858. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  8859. }
  8860. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8861. // It returns an error if the edge is not defined in the schema.
  8862. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  8863. switch name {
  8864. case labelrelationship.EdgeContacts:
  8865. m.ResetContacts()
  8866. return nil
  8867. case labelrelationship.EdgeLabels:
  8868. m.ResetLabels()
  8869. return nil
  8870. }
  8871. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  8872. }
  8873. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  8874. type MessageMutation struct {
  8875. config
  8876. op Op
  8877. typ string
  8878. id *int
  8879. wx_wxid *string
  8880. wxid *string
  8881. content *string
  8882. clearedFields map[string]struct{}
  8883. done bool
  8884. oldValue func(context.Context) (*Message, error)
  8885. predicates []predicate.Message
  8886. }
  8887. var _ ent.Mutation = (*MessageMutation)(nil)
  8888. // messageOption allows management of the mutation configuration using functional options.
  8889. type messageOption func(*MessageMutation)
  8890. // newMessageMutation creates new mutation for the Message entity.
  8891. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  8892. m := &MessageMutation{
  8893. config: c,
  8894. op: op,
  8895. typ: TypeMessage,
  8896. clearedFields: make(map[string]struct{}),
  8897. }
  8898. for _, opt := range opts {
  8899. opt(m)
  8900. }
  8901. return m
  8902. }
  8903. // withMessageID sets the ID field of the mutation.
  8904. func withMessageID(id int) messageOption {
  8905. return func(m *MessageMutation) {
  8906. var (
  8907. err error
  8908. once sync.Once
  8909. value *Message
  8910. )
  8911. m.oldValue = func(ctx context.Context) (*Message, error) {
  8912. once.Do(func() {
  8913. if m.done {
  8914. err = errors.New("querying old values post mutation is not allowed")
  8915. } else {
  8916. value, err = m.Client().Message.Get(ctx, id)
  8917. }
  8918. })
  8919. return value, err
  8920. }
  8921. m.id = &id
  8922. }
  8923. }
  8924. // withMessage sets the old Message of the mutation.
  8925. func withMessage(node *Message) messageOption {
  8926. return func(m *MessageMutation) {
  8927. m.oldValue = func(context.Context) (*Message, error) {
  8928. return node, nil
  8929. }
  8930. m.id = &node.ID
  8931. }
  8932. }
  8933. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8934. // executed in a transaction (ent.Tx), a transactional client is returned.
  8935. func (m MessageMutation) Client() *Client {
  8936. client := &Client{config: m.config}
  8937. client.init()
  8938. return client
  8939. }
  8940. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8941. // it returns an error otherwise.
  8942. func (m MessageMutation) Tx() (*Tx, error) {
  8943. if _, ok := m.driver.(*txDriver); !ok {
  8944. return nil, errors.New("ent: mutation is not running in a transaction")
  8945. }
  8946. tx := &Tx{config: m.config}
  8947. tx.init()
  8948. return tx, nil
  8949. }
  8950. // ID returns the ID value in the mutation. Note that the ID is only available
  8951. // if it was provided to the builder or after it was returned from the database.
  8952. func (m *MessageMutation) ID() (id int, exists bool) {
  8953. if m.id == nil {
  8954. return
  8955. }
  8956. return *m.id, true
  8957. }
  8958. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8959. // That means, if the mutation is applied within a transaction with an isolation level such
  8960. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8961. // or updated by the mutation.
  8962. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  8963. switch {
  8964. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8965. id, exists := m.ID()
  8966. if exists {
  8967. return []int{id}, nil
  8968. }
  8969. fallthrough
  8970. case m.op.Is(OpUpdate | OpDelete):
  8971. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  8972. default:
  8973. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8974. }
  8975. }
  8976. // SetWxWxid sets the "wx_wxid" field.
  8977. func (m *MessageMutation) SetWxWxid(s string) {
  8978. m.wx_wxid = &s
  8979. }
  8980. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  8981. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  8982. v := m.wx_wxid
  8983. if v == nil {
  8984. return
  8985. }
  8986. return *v, true
  8987. }
  8988. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  8989. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  8990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8991. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  8992. if !m.op.Is(OpUpdateOne) {
  8993. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  8994. }
  8995. if m.id == nil || m.oldValue == nil {
  8996. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  8997. }
  8998. oldValue, err := m.oldValue(ctx)
  8999. if err != nil {
  9000. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  9001. }
  9002. return oldValue.WxWxid, nil
  9003. }
  9004. // ClearWxWxid clears the value of the "wx_wxid" field.
  9005. func (m *MessageMutation) ClearWxWxid() {
  9006. m.wx_wxid = nil
  9007. m.clearedFields[message.FieldWxWxid] = struct{}{}
  9008. }
  9009. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  9010. func (m *MessageMutation) WxWxidCleared() bool {
  9011. _, ok := m.clearedFields[message.FieldWxWxid]
  9012. return ok
  9013. }
  9014. // ResetWxWxid resets all changes to the "wx_wxid" field.
  9015. func (m *MessageMutation) ResetWxWxid() {
  9016. m.wx_wxid = nil
  9017. delete(m.clearedFields, message.FieldWxWxid)
  9018. }
  9019. // SetWxid sets the "wxid" field.
  9020. func (m *MessageMutation) SetWxid(s string) {
  9021. m.wxid = &s
  9022. }
  9023. // Wxid returns the value of the "wxid" field in the mutation.
  9024. func (m *MessageMutation) Wxid() (r string, exists bool) {
  9025. v := m.wxid
  9026. if v == nil {
  9027. return
  9028. }
  9029. return *v, true
  9030. }
  9031. // OldWxid returns the old "wxid" field's value of the Message entity.
  9032. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  9033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9034. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  9035. if !m.op.Is(OpUpdateOne) {
  9036. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  9037. }
  9038. if m.id == nil || m.oldValue == nil {
  9039. return v, errors.New("OldWxid requires an ID field in the mutation")
  9040. }
  9041. oldValue, err := m.oldValue(ctx)
  9042. if err != nil {
  9043. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  9044. }
  9045. return oldValue.Wxid, nil
  9046. }
  9047. // ResetWxid resets all changes to the "wxid" field.
  9048. func (m *MessageMutation) ResetWxid() {
  9049. m.wxid = nil
  9050. }
  9051. // SetContent sets the "content" field.
  9052. func (m *MessageMutation) SetContent(s string) {
  9053. m.content = &s
  9054. }
  9055. // Content returns the value of the "content" field in the mutation.
  9056. func (m *MessageMutation) Content() (r string, exists bool) {
  9057. v := m.content
  9058. if v == nil {
  9059. return
  9060. }
  9061. return *v, true
  9062. }
  9063. // OldContent returns the old "content" field's value of the Message entity.
  9064. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  9065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9066. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  9067. if !m.op.Is(OpUpdateOne) {
  9068. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  9069. }
  9070. if m.id == nil || m.oldValue == nil {
  9071. return v, errors.New("OldContent requires an ID field in the mutation")
  9072. }
  9073. oldValue, err := m.oldValue(ctx)
  9074. if err != nil {
  9075. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  9076. }
  9077. return oldValue.Content, nil
  9078. }
  9079. // ResetContent resets all changes to the "content" field.
  9080. func (m *MessageMutation) ResetContent() {
  9081. m.content = nil
  9082. }
  9083. // Where appends a list predicates to the MessageMutation builder.
  9084. func (m *MessageMutation) Where(ps ...predicate.Message) {
  9085. m.predicates = append(m.predicates, ps...)
  9086. }
  9087. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  9088. // users can use type-assertion to append predicates that do not depend on any generated package.
  9089. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  9090. p := make([]predicate.Message, len(ps))
  9091. for i := range ps {
  9092. p[i] = ps[i]
  9093. }
  9094. m.Where(p...)
  9095. }
  9096. // Op returns the operation name.
  9097. func (m *MessageMutation) Op() Op {
  9098. return m.op
  9099. }
  9100. // SetOp allows setting the mutation operation.
  9101. func (m *MessageMutation) SetOp(op Op) {
  9102. m.op = op
  9103. }
  9104. // Type returns the node type of this mutation (Message).
  9105. func (m *MessageMutation) Type() string {
  9106. return m.typ
  9107. }
  9108. // Fields returns all fields that were changed during this mutation. Note that in
  9109. // order to get all numeric fields that were incremented/decremented, call
  9110. // AddedFields().
  9111. func (m *MessageMutation) Fields() []string {
  9112. fields := make([]string, 0, 3)
  9113. if m.wx_wxid != nil {
  9114. fields = append(fields, message.FieldWxWxid)
  9115. }
  9116. if m.wxid != nil {
  9117. fields = append(fields, message.FieldWxid)
  9118. }
  9119. if m.content != nil {
  9120. fields = append(fields, message.FieldContent)
  9121. }
  9122. return fields
  9123. }
  9124. // Field returns the value of a field with the given name. The second boolean
  9125. // return value indicates that this field was not set, or was not defined in the
  9126. // schema.
  9127. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  9128. switch name {
  9129. case message.FieldWxWxid:
  9130. return m.WxWxid()
  9131. case message.FieldWxid:
  9132. return m.Wxid()
  9133. case message.FieldContent:
  9134. return m.Content()
  9135. }
  9136. return nil, false
  9137. }
  9138. // OldField returns the old value of the field from the database. An error is
  9139. // returned if the mutation operation is not UpdateOne, or the query to the
  9140. // database failed.
  9141. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9142. switch name {
  9143. case message.FieldWxWxid:
  9144. return m.OldWxWxid(ctx)
  9145. case message.FieldWxid:
  9146. return m.OldWxid(ctx)
  9147. case message.FieldContent:
  9148. return m.OldContent(ctx)
  9149. }
  9150. return nil, fmt.Errorf("unknown Message field %s", name)
  9151. }
  9152. // SetField sets the value of a field with the given name. It returns an error if
  9153. // the field is not defined in the schema, or if the type mismatched the field
  9154. // type.
  9155. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  9156. switch name {
  9157. case message.FieldWxWxid:
  9158. v, ok := value.(string)
  9159. if !ok {
  9160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9161. }
  9162. m.SetWxWxid(v)
  9163. return nil
  9164. case message.FieldWxid:
  9165. v, ok := value.(string)
  9166. if !ok {
  9167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9168. }
  9169. m.SetWxid(v)
  9170. return nil
  9171. case message.FieldContent:
  9172. v, ok := value.(string)
  9173. if !ok {
  9174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9175. }
  9176. m.SetContent(v)
  9177. return nil
  9178. }
  9179. return fmt.Errorf("unknown Message field %s", name)
  9180. }
  9181. // AddedFields returns all numeric fields that were incremented/decremented during
  9182. // this mutation.
  9183. func (m *MessageMutation) AddedFields() []string {
  9184. return nil
  9185. }
  9186. // AddedField returns the numeric value that was incremented/decremented on a field
  9187. // with the given name. The second boolean return value indicates that this field
  9188. // was not set, or was not defined in the schema.
  9189. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  9190. return nil, false
  9191. }
  9192. // AddField adds the value to the field with the given name. It returns an error if
  9193. // the field is not defined in the schema, or if the type mismatched the field
  9194. // type.
  9195. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  9196. switch name {
  9197. }
  9198. return fmt.Errorf("unknown Message numeric field %s", name)
  9199. }
  9200. // ClearedFields returns all nullable fields that were cleared during this
  9201. // mutation.
  9202. func (m *MessageMutation) ClearedFields() []string {
  9203. var fields []string
  9204. if m.FieldCleared(message.FieldWxWxid) {
  9205. fields = append(fields, message.FieldWxWxid)
  9206. }
  9207. return fields
  9208. }
  9209. // FieldCleared returns a boolean indicating if a field with the given name was
  9210. // cleared in this mutation.
  9211. func (m *MessageMutation) FieldCleared(name string) bool {
  9212. _, ok := m.clearedFields[name]
  9213. return ok
  9214. }
  9215. // ClearField clears the value of the field with the given name. It returns an
  9216. // error if the field is not defined in the schema.
  9217. func (m *MessageMutation) ClearField(name string) error {
  9218. switch name {
  9219. case message.FieldWxWxid:
  9220. m.ClearWxWxid()
  9221. return nil
  9222. }
  9223. return fmt.Errorf("unknown Message nullable field %s", name)
  9224. }
  9225. // ResetField resets all changes in the mutation for the field with the given name.
  9226. // It returns an error if the field is not defined in the schema.
  9227. func (m *MessageMutation) ResetField(name string) error {
  9228. switch name {
  9229. case message.FieldWxWxid:
  9230. m.ResetWxWxid()
  9231. return nil
  9232. case message.FieldWxid:
  9233. m.ResetWxid()
  9234. return nil
  9235. case message.FieldContent:
  9236. m.ResetContent()
  9237. return nil
  9238. }
  9239. return fmt.Errorf("unknown Message field %s", name)
  9240. }
  9241. // AddedEdges returns all edge names that were set/added in this mutation.
  9242. func (m *MessageMutation) AddedEdges() []string {
  9243. edges := make([]string, 0, 0)
  9244. return edges
  9245. }
  9246. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9247. // name in this mutation.
  9248. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  9249. return nil
  9250. }
  9251. // RemovedEdges returns all edge names that were removed in this mutation.
  9252. func (m *MessageMutation) RemovedEdges() []string {
  9253. edges := make([]string, 0, 0)
  9254. return edges
  9255. }
  9256. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9257. // the given name in this mutation.
  9258. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  9259. return nil
  9260. }
  9261. // ClearedEdges returns all edge names that were cleared in this mutation.
  9262. func (m *MessageMutation) ClearedEdges() []string {
  9263. edges := make([]string, 0, 0)
  9264. return edges
  9265. }
  9266. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9267. // was cleared in this mutation.
  9268. func (m *MessageMutation) EdgeCleared(name string) bool {
  9269. return false
  9270. }
  9271. // ClearEdge clears the value of the edge with the given name. It returns an error
  9272. // if that edge is not defined in the schema.
  9273. func (m *MessageMutation) ClearEdge(name string) error {
  9274. return fmt.Errorf("unknown Message unique edge %s", name)
  9275. }
  9276. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9277. // It returns an error if the edge is not defined in the schema.
  9278. func (m *MessageMutation) ResetEdge(name string) error {
  9279. return fmt.Errorf("unknown Message edge %s", name)
  9280. }
  9281. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  9282. type MessageRecordsMutation struct {
  9283. config
  9284. op Op
  9285. typ string
  9286. id *uint64
  9287. created_at *time.Time
  9288. updated_at *time.Time
  9289. status *uint8
  9290. addstatus *int8
  9291. deleted_at *time.Time
  9292. bot_wxid *string
  9293. contact_type *int
  9294. addcontact_type *int
  9295. contact_wxid *string
  9296. content_type *int
  9297. addcontent_type *int
  9298. content *string
  9299. meta *custom_types.Meta
  9300. error_detail *string
  9301. send_time *time.Time
  9302. source_type *int
  9303. addsource_type *int
  9304. organization_id *uint64
  9305. addorganization_id *int64
  9306. clearedFields map[string]struct{}
  9307. sop_stage *uint64
  9308. clearedsop_stage bool
  9309. sop_node *uint64
  9310. clearedsop_node bool
  9311. message_contact *uint64
  9312. clearedmessage_contact bool
  9313. done bool
  9314. oldValue func(context.Context) (*MessageRecords, error)
  9315. predicates []predicate.MessageRecords
  9316. }
  9317. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  9318. // messagerecordsOption allows management of the mutation configuration using functional options.
  9319. type messagerecordsOption func(*MessageRecordsMutation)
  9320. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  9321. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  9322. m := &MessageRecordsMutation{
  9323. config: c,
  9324. op: op,
  9325. typ: TypeMessageRecords,
  9326. clearedFields: make(map[string]struct{}),
  9327. }
  9328. for _, opt := range opts {
  9329. opt(m)
  9330. }
  9331. return m
  9332. }
  9333. // withMessageRecordsID sets the ID field of the mutation.
  9334. func withMessageRecordsID(id uint64) messagerecordsOption {
  9335. return func(m *MessageRecordsMutation) {
  9336. var (
  9337. err error
  9338. once sync.Once
  9339. value *MessageRecords
  9340. )
  9341. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  9342. once.Do(func() {
  9343. if m.done {
  9344. err = errors.New("querying old values post mutation is not allowed")
  9345. } else {
  9346. value, err = m.Client().MessageRecords.Get(ctx, id)
  9347. }
  9348. })
  9349. return value, err
  9350. }
  9351. m.id = &id
  9352. }
  9353. }
  9354. // withMessageRecords sets the old MessageRecords of the mutation.
  9355. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  9356. return func(m *MessageRecordsMutation) {
  9357. m.oldValue = func(context.Context) (*MessageRecords, error) {
  9358. return node, nil
  9359. }
  9360. m.id = &node.ID
  9361. }
  9362. }
  9363. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9364. // executed in a transaction (ent.Tx), a transactional client is returned.
  9365. func (m MessageRecordsMutation) Client() *Client {
  9366. client := &Client{config: m.config}
  9367. client.init()
  9368. return client
  9369. }
  9370. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9371. // it returns an error otherwise.
  9372. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  9373. if _, ok := m.driver.(*txDriver); !ok {
  9374. return nil, errors.New("ent: mutation is not running in a transaction")
  9375. }
  9376. tx := &Tx{config: m.config}
  9377. tx.init()
  9378. return tx, nil
  9379. }
  9380. // SetID sets the value of the id field. Note that this
  9381. // operation is only accepted on creation of MessageRecords entities.
  9382. func (m *MessageRecordsMutation) SetID(id uint64) {
  9383. m.id = &id
  9384. }
  9385. // ID returns the ID value in the mutation. Note that the ID is only available
  9386. // if it was provided to the builder or after it was returned from the database.
  9387. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  9388. if m.id == nil {
  9389. return
  9390. }
  9391. return *m.id, true
  9392. }
  9393. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9394. // That means, if the mutation is applied within a transaction with an isolation level such
  9395. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9396. // or updated by the mutation.
  9397. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  9398. switch {
  9399. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9400. id, exists := m.ID()
  9401. if exists {
  9402. return []uint64{id}, nil
  9403. }
  9404. fallthrough
  9405. case m.op.Is(OpUpdate | OpDelete):
  9406. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  9407. default:
  9408. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9409. }
  9410. }
  9411. // SetCreatedAt sets the "created_at" field.
  9412. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  9413. m.created_at = &t
  9414. }
  9415. // CreatedAt returns the value of the "created_at" field in the mutation.
  9416. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  9417. v := m.created_at
  9418. if v == nil {
  9419. return
  9420. }
  9421. return *v, true
  9422. }
  9423. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  9424. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9426. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9427. if !m.op.Is(OpUpdateOne) {
  9428. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9429. }
  9430. if m.id == nil || m.oldValue == nil {
  9431. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9432. }
  9433. oldValue, err := m.oldValue(ctx)
  9434. if err != nil {
  9435. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9436. }
  9437. return oldValue.CreatedAt, nil
  9438. }
  9439. // ResetCreatedAt resets all changes to the "created_at" field.
  9440. func (m *MessageRecordsMutation) ResetCreatedAt() {
  9441. m.created_at = nil
  9442. }
  9443. // SetUpdatedAt sets the "updated_at" field.
  9444. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  9445. m.updated_at = &t
  9446. }
  9447. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9448. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  9449. v := m.updated_at
  9450. if v == nil {
  9451. return
  9452. }
  9453. return *v, true
  9454. }
  9455. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  9456. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9458. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9459. if !m.op.Is(OpUpdateOne) {
  9460. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9461. }
  9462. if m.id == nil || m.oldValue == nil {
  9463. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9464. }
  9465. oldValue, err := m.oldValue(ctx)
  9466. if err != nil {
  9467. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9468. }
  9469. return oldValue.UpdatedAt, nil
  9470. }
  9471. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9472. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  9473. m.updated_at = nil
  9474. }
  9475. // SetStatus sets the "status" field.
  9476. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  9477. m.status = &u
  9478. m.addstatus = nil
  9479. }
  9480. // Status returns the value of the "status" field in the mutation.
  9481. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  9482. v := m.status
  9483. if v == nil {
  9484. return
  9485. }
  9486. return *v, true
  9487. }
  9488. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  9489. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9491. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9492. if !m.op.Is(OpUpdateOne) {
  9493. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9494. }
  9495. if m.id == nil || m.oldValue == nil {
  9496. return v, errors.New("OldStatus requires an ID field in the mutation")
  9497. }
  9498. oldValue, err := m.oldValue(ctx)
  9499. if err != nil {
  9500. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9501. }
  9502. return oldValue.Status, nil
  9503. }
  9504. // AddStatus adds u to the "status" field.
  9505. func (m *MessageRecordsMutation) AddStatus(u int8) {
  9506. if m.addstatus != nil {
  9507. *m.addstatus += u
  9508. } else {
  9509. m.addstatus = &u
  9510. }
  9511. }
  9512. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9513. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  9514. v := m.addstatus
  9515. if v == nil {
  9516. return
  9517. }
  9518. return *v, true
  9519. }
  9520. // ClearStatus clears the value of the "status" field.
  9521. func (m *MessageRecordsMutation) ClearStatus() {
  9522. m.status = nil
  9523. m.addstatus = nil
  9524. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  9525. }
  9526. // StatusCleared returns if the "status" field was cleared in this mutation.
  9527. func (m *MessageRecordsMutation) StatusCleared() bool {
  9528. _, ok := m.clearedFields[messagerecords.FieldStatus]
  9529. return ok
  9530. }
  9531. // ResetStatus resets all changes to the "status" field.
  9532. func (m *MessageRecordsMutation) ResetStatus() {
  9533. m.status = nil
  9534. m.addstatus = nil
  9535. delete(m.clearedFields, messagerecords.FieldStatus)
  9536. }
  9537. // SetDeletedAt sets the "deleted_at" field.
  9538. func (m *MessageRecordsMutation) SetDeletedAt(t time.Time) {
  9539. m.deleted_at = &t
  9540. }
  9541. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9542. func (m *MessageRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  9543. v := m.deleted_at
  9544. if v == nil {
  9545. return
  9546. }
  9547. return *v, true
  9548. }
  9549. // OldDeletedAt returns the old "deleted_at" field's value of the MessageRecords entity.
  9550. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9552. func (m *MessageRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9553. if !m.op.Is(OpUpdateOne) {
  9554. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9555. }
  9556. if m.id == nil || m.oldValue == nil {
  9557. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9558. }
  9559. oldValue, err := m.oldValue(ctx)
  9560. if err != nil {
  9561. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9562. }
  9563. return oldValue.DeletedAt, nil
  9564. }
  9565. // ClearDeletedAt clears the value of the "deleted_at" field.
  9566. func (m *MessageRecordsMutation) ClearDeletedAt() {
  9567. m.deleted_at = nil
  9568. m.clearedFields[messagerecords.FieldDeletedAt] = struct{}{}
  9569. }
  9570. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9571. func (m *MessageRecordsMutation) DeletedAtCleared() bool {
  9572. _, ok := m.clearedFields[messagerecords.FieldDeletedAt]
  9573. return ok
  9574. }
  9575. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9576. func (m *MessageRecordsMutation) ResetDeletedAt() {
  9577. m.deleted_at = nil
  9578. delete(m.clearedFields, messagerecords.FieldDeletedAt)
  9579. }
  9580. // SetBotWxid sets the "bot_wxid" field.
  9581. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  9582. m.bot_wxid = &s
  9583. }
  9584. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  9585. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  9586. v := m.bot_wxid
  9587. if v == nil {
  9588. return
  9589. }
  9590. return *v, true
  9591. }
  9592. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  9593. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9595. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  9596. if !m.op.Is(OpUpdateOne) {
  9597. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  9598. }
  9599. if m.id == nil || m.oldValue == nil {
  9600. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  9601. }
  9602. oldValue, err := m.oldValue(ctx)
  9603. if err != nil {
  9604. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  9605. }
  9606. return oldValue.BotWxid, nil
  9607. }
  9608. // ResetBotWxid resets all changes to the "bot_wxid" field.
  9609. func (m *MessageRecordsMutation) ResetBotWxid() {
  9610. m.bot_wxid = nil
  9611. }
  9612. // SetContactID sets the "contact_id" field.
  9613. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  9614. m.message_contact = &u
  9615. }
  9616. // ContactID returns the value of the "contact_id" field in the mutation.
  9617. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  9618. v := m.message_contact
  9619. if v == nil {
  9620. return
  9621. }
  9622. return *v, true
  9623. }
  9624. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  9625. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9627. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  9628. if !m.op.Is(OpUpdateOne) {
  9629. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  9630. }
  9631. if m.id == nil || m.oldValue == nil {
  9632. return v, errors.New("OldContactID requires an ID field in the mutation")
  9633. }
  9634. oldValue, err := m.oldValue(ctx)
  9635. if err != nil {
  9636. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  9637. }
  9638. return oldValue.ContactID, nil
  9639. }
  9640. // ClearContactID clears the value of the "contact_id" field.
  9641. func (m *MessageRecordsMutation) ClearContactID() {
  9642. m.message_contact = nil
  9643. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  9644. }
  9645. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  9646. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  9647. _, ok := m.clearedFields[messagerecords.FieldContactID]
  9648. return ok
  9649. }
  9650. // ResetContactID resets all changes to the "contact_id" field.
  9651. func (m *MessageRecordsMutation) ResetContactID() {
  9652. m.message_contact = nil
  9653. delete(m.clearedFields, messagerecords.FieldContactID)
  9654. }
  9655. // SetContactType sets the "contact_type" field.
  9656. func (m *MessageRecordsMutation) SetContactType(i int) {
  9657. m.contact_type = &i
  9658. m.addcontact_type = nil
  9659. }
  9660. // ContactType returns the value of the "contact_type" field in the mutation.
  9661. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  9662. v := m.contact_type
  9663. if v == nil {
  9664. return
  9665. }
  9666. return *v, true
  9667. }
  9668. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  9669. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9671. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  9672. if !m.op.Is(OpUpdateOne) {
  9673. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  9674. }
  9675. if m.id == nil || m.oldValue == nil {
  9676. return v, errors.New("OldContactType requires an ID field in the mutation")
  9677. }
  9678. oldValue, err := m.oldValue(ctx)
  9679. if err != nil {
  9680. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  9681. }
  9682. return oldValue.ContactType, nil
  9683. }
  9684. // AddContactType adds i to the "contact_type" field.
  9685. func (m *MessageRecordsMutation) AddContactType(i int) {
  9686. if m.addcontact_type != nil {
  9687. *m.addcontact_type += i
  9688. } else {
  9689. m.addcontact_type = &i
  9690. }
  9691. }
  9692. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  9693. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  9694. v := m.addcontact_type
  9695. if v == nil {
  9696. return
  9697. }
  9698. return *v, true
  9699. }
  9700. // ResetContactType resets all changes to the "contact_type" field.
  9701. func (m *MessageRecordsMutation) ResetContactType() {
  9702. m.contact_type = nil
  9703. m.addcontact_type = nil
  9704. }
  9705. // SetContactWxid sets the "contact_wxid" field.
  9706. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  9707. m.contact_wxid = &s
  9708. }
  9709. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  9710. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  9711. v := m.contact_wxid
  9712. if v == nil {
  9713. return
  9714. }
  9715. return *v, true
  9716. }
  9717. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  9718. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9720. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  9721. if !m.op.Is(OpUpdateOne) {
  9722. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  9723. }
  9724. if m.id == nil || m.oldValue == nil {
  9725. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  9726. }
  9727. oldValue, err := m.oldValue(ctx)
  9728. if err != nil {
  9729. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  9730. }
  9731. return oldValue.ContactWxid, nil
  9732. }
  9733. // ResetContactWxid resets all changes to the "contact_wxid" field.
  9734. func (m *MessageRecordsMutation) ResetContactWxid() {
  9735. m.contact_wxid = nil
  9736. }
  9737. // SetContentType sets the "content_type" field.
  9738. func (m *MessageRecordsMutation) SetContentType(i int) {
  9739. m.content_type = &i
  9740. m.addcontent_type = nil
  9741. }
  9742. // ContentType returns the value of the "content_type" field in the mutation.
  9743. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  9744. v := m.content_type
  9745. if v == nil {
  9746. return
  9747. }
  9748. return *v, true
  9749. }
  9750. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  9751. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9753. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  9754. if !m.op.Is(OpUpdateOne) {
  9755. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  9756. }
  9757. if m.id == nil || m.oldValue == nil {
  9758. return v, errors.New("OldContentType requires an ID field in the mutation")
  9759. }
  9760. oldValue, err := m.oldValue(ctx)
  9761. if err != nil {
  9762. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  9763. }
  9764. return oldValue.ContentType, nil
  9765. }
  9766. // AddContentType adds i to the "content_type" field.
  9767. func (m *MessageRecordsMutation) AddContentType(i int) {
  9768. if m.addcontent_type != nil {
  9769. *m.addcontent_type += i
  9770. } else {
  9771. m.addcontent_type = &i
  9772. }
  9773. }
  9774. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  9775. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  9776. v := m.addcontent_type
  9777. if v == nil {
  9778. return
  9779. }
  9780. return *v, true
  9781. }
  9782. // ResetContentType resets all changes to the "content_type" field.
  9783. func (m *MessageRecordsMutation) ResetContentType() {
  9784. m.content_type = nil
  9785. m.addcontent_type = nil
  9786. }
  9787. // SetContent sets the "content" field.
  9788. func (m *MessageRecordsMutation) SetContent(s string) {
  9789. m.content = &s
  9790. }
  9791. // Content returns the value of the "content" field in the mutation.
  9792. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  9793. v := m.content
  9794. if v == nil {
  9795. return
  9796. }
  9797. return *v, true
  9798. }
  9799. // OldContent returns the old "content" field's value of the MessageRecords entity.
  9800. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9802. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  9803. if !m.op.Is(OpUpdateOne) {
  9804. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  9805. }
  9806. if m.id == nil || m.oldValue == nil {
  9807. return v, errors.New("OldContent requires an ID field in the mutation")
  9808. }
  9809. oldValue, err := m.oldValue(ctx)
  9810. if err != nil {
  9811. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  9812. }
  9813. return oldValue.Content, nil
  9814. }
  9815. // ResetContent resets all changes to the "content" field.
  9816. func (m *MessageRecordsMutation) ResetContent() {
  9817. m.content = nil
  9818. }
  9819. // SetMeta sets the "meta" field.
  9820. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  9821. m.meta = &ct
  9822. }
  9823. // Meta returns the value of the "meta" field in the mutation.
  9824. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  9825. v := m.meta
  9826. if v == nil {
  9827. return
  9828. }
  9829. return *v, true
  9830. }
  9831. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  9832. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9834. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  9835. if !m.op.Is(OpUpdateOne) {
  9836. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  9837. }
  9838. if m.id == nil || m.oldValue == nil {
  9839. return v, errors.New("OldMeta requires an ID field in the mutation")
  9840. }
  9841. oldValue, err := m.oldValue(ctx)
  9842. if err != nil {
  9843. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  9844. }
  9845. return oldValue.Meta, nil
  9846. }
  9847. // ClearMeta clears the value of the "meta" field.
  9848. func (m *MessageRecordsMutation) ClearMeta() {
  9849. m.meta = nil
  9850. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  9851. }
  9852. // MetaCleared returns if the "meta" field was cleared in this mutation.
  9853. func (m *MessageRecordsMutation) MetaCleared() bool {
  9854. _, ok := m.clearedFields[messagerecords.FieldMeta]
  9855. return ok
  9856. }
  9857. // ResetMeta resets all changes to the "meta" field.
  9858. func (m *MessageRecordsMutation) ResetMeta() {
  9859. m.meta = nil
  9860. delete(m.clearedFields, messagerecords.FieldMeta)
  9861. }
  9862. // SetErrorDetail sets the "error_detail" field.
  9863. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  9864. m.error_detail = &s
  9865. }
  9866. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  9867. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  9868. v := m.error_detail
  9869. if v == nil {
  9870. return
  9871. }
  9872. return *v, true
  9873. }
  9874. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  9875. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9877. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  9878. if !m.op.Is(OpUpdateOne) {
  9879. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  9880. }
  9881. if m.id == nil || m.oldValue == nil {
  9882. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  9883. }
  9884. oldValue, err := m.oldValue(ctx)
  9885. if err != nil {
  9886. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  9887. }
  9888. return oldValue.ErrorDetail, nil
  9889. }
  9890. // ResetErrorDetail resets all changes to the "error_detail" field.
  9891. func (m *MessageRecordsMutation) ResetErrorDetail() {
  9892. m.error_detail = nil
  9893. }
  9894. // SetSendTime sets the "send_time" field.
  9895. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  9896. m.send_time = &t
  9897. }
  9898. // SendTime returns the value of the "send_time" field in the mutation.
  9899. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  9900. v := m.send_time
  9901. if v == nil {
  9902. return
  9903. }
  9904. return *v, true
  9905. }
  9906. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  9907. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9909. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  9910. if !m.op.Is(OpUpdateOne) {
  9911. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  9912. }
  9913. if m.id == nil || m.oldValue == nil {
  9914. return v, errors.New("OldSendTime requires an ID field in the mutation")
  9915. }
  9916. oldValue, err := m.oldValue(ctx)
  9917. if err != nil {
  9918. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  9919. }
  9920. return oldValue.SendTime, nil
  9921. }
  9922. // ClearSendTime clears the value of the "send_time" field.
  9923. func (m *MessageRecordsMutation) ClearSendTime() {
  9924. m.send_time = nil
  9925. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  9926. }
  9927. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  9928. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  9929. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  9930. return ok
  9931. }
  9932. // ResetSendTime resets all changes to the "send_time" field.
  9933. func (m *MessageRecordsMutation) ResetSendTime() {
  9934. m.send_time = nil
  9935. delete(m.clearedFields, messagerecords.FieldSendTime)
  9936. }
  9937. // SetSourceType sets the "source_type" field.
  9938. func (m *MessageRecordsMutation) SetSourceType(i int) {
  9939. m.source_type = &i
  9940. m.addsource_type = nil
  9941. }
  9942. // SourceType returns the value of the "source_type" field in the mutation.
  9943. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  9944. v := m.source_type
  9945. if v == nil {
  9946. return
  9947. }
  9948. return *v, true
  9949. }
  9950. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  9951. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9953. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  9954. if !m.op.Is(OpUpdateOne) {
  9955. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  9956. }
  9957. if m.id == nil || m.oldValue == nil {
  9958. return v, errors.New("OldSourceType requires an ID field in the mutation")
  9959. }
  9960. oldValue, err := m.oldValue(ctx)
  9961. if err != nil {
  9962. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  9963. }
  9964. return oldValue.SourceType, nil
  9965. }
  9966. // AddSourceType adds i to the "source_type" field.
  9967. func (m *MessageRecordsMutation) AddSourceType(i int) {
  9968. if m.addsource_type != nil {
  9969. *m.addsource_type += i
  9970. } else {
  9971. m.addsource_type = &i
  9972. }
  9973. }
  9974. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  9975. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  9976. v := m.addsource_type
  9977. if v == nil {
  9978. return
  9979. }
  9980. return *v, true
  9981. }
  9982. // ResetSourceType resets all changes to the "source_type" field.
  9983. func (m *MessageRecordsMutation) ResetSourceType() {
  9984. m.source_type = nil
  9985. m.addsource_type = nil
  9986. }
  9987. // SetSourceID sets the "source_id" field.
  9988. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  9989. m.sop_stage = &u
  9990. }
  9991. // SourceID returns the value of the "source_id" field in the mutation.
  9992. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  9993. v := m.sop_stage
  9994. if v == nil {
  9995. return
  9996. }
  9997. return *v, true
  9998. }
  9999. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  10000. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  10001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10002. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  10003. if !m.op.Is(OpUpdateOne) {
  10004. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  10005. }
  10006. if m.id == nil || m.oldValue == nil {
  10007. return v, errors.New("OldSourceID requires an ID field in the mutation")
  10008. }
  10009. oldValue, err := m.oldValue(ctx)
  10010. if err != nil {
  10011. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  10012. }
  10013. return oldValue.SourceID, nil
  10014. }
  10015. // ClearSourceID clears the value of the "source_id" field.
  10016. func (m *MessageRecordsMutation) ClearSourceID() {
  10017. m.sop_stage = nil
  10018. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  10019. }
  10020. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  10021. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  10022. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  10023. return ok
  10024. }
  10025. // ResetSourceID resets all changes to the "source_id" field.
  10026. func (m *MessageRecordsMutation) ResetSourceID() {
  10027. m.sop_stage = nil
  10028. delete(m.clearedFields, messagerecords.FieldSourceID)
  10029. }
  10030. // SetSubSourceID sets the "sub_source_id" field.
  10031. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  10032. m.sop_node = &u
  10033. }
  10034. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  10035. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  10036. v := m.sop_node
  10037. if v == nil {
  10038. return
  10039. }
  10040. return *v, true
  10041. }
  10042. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  10043. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  10044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10045. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  10046. if !m.op.Is(OpUpdateOne) {
  10047. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  10048. }
  10049. if m.id == nil || m.oldValue == nil {
  10050. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  10051. }
  10052. oldValue, err := m.oldValue(ctx)
  10053. if err != nil {
  10054. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  10055. }
  10056. return oldValue.SubSourceID, nil
  10057. }
  10058. // ClearSubSourceID clears the value of the "sub_source_id" field.
  10059. func (m *MessageRecordsMutation) ClearSubSourceID() {
  10060. m.sop_node = nil
  10061. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  10062. }
  10063. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  10064. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  10065. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  10066. return ok
  10067. }
  10068. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  10069. func (m *MessageRecordsMutation) ResetSubSourceID() {
  10070. m.sop_node = nil
  10071. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  10072. }
  10073. // SetOrganizationID sets the "organization_id" field.
  10074. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  10075. m.organization_id = &u
  10076. m.addorganization_id = nil
  10077. }
  10078. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10079. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  10080. v := m.organization_id
  10081. if v == nil {
  10082. return
  10083. }
  10084. return *v, true
  10085. }
  10086. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  10087. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  10088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10089. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10090. if !m.op.Is(OpUpdateOne) {
  10091. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10092. }
  10093. if m.id == nil || m.oldValue == nil {
  10094. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10095. }
  10096. oldValue, err := m.oldValue(ctx)
  10097. if err != nil {
  10098. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10099. }
  10100. return oldValue.OrganizationID, nil
  10101. }
  10102. // AddOrganizationID adds u to the "organization_id" field.
  10103. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  10104. if m.addorganization_id != nil {
  10105. *m.addorganization_id += u
  10106. } else {
  10107. m.addorganization_id = &u
  10108. }
  10109. }
  10110. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10111. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  10112. v := m.addorganization_id
  10113. if v == nil {
  10114. return
  10115. }
  10116. return *v, true
  10117. }
  10118. // ClearOrganizationID clears the value of the "organization_id" field.
  10119. func (m *MessageRecordsMutation) ClearOrganizationID() {
  10120. m.organization_id = nil
  10121. m.addorganization_id = nil
  10122. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  10123. }
  10124. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10125. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  10126. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  10127. return ok
  10128. }
  10129. // ResetOrganizationID resets all changes to the "organization_id" field.
  10130. func (m *MessageRecordsMutation) ResetOrganizationID() {
  10131. m.organization_id = nil
  10132. m.addorganization_id = nil
  10133. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  10134. }
  10135. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  10136. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  10137. m.sop_stage = &id
  10138. }
  10139. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  10140. func (m *MessageRecordsMutation) ClearSopStage() {
  10141. m.clearedsop_stage = true
  10142. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  10143. }
  10144. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  10145. func (m *MessageRecordsMutation) SopStageCleared() bool {
  10146. return m.SourceIDCleared() || m.clearedsop_stage
  10147. }
  10148. // SopStageID returns the "sop_stage" edge ID in the mutation.
  10149. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  10150. if m.sop_stage != nil {
  10151. return *m.sop_stage, true
  10152. }
  10153. return
  10154. }
  10155. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  10156. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  10157. // SopStageID instead. It exists only for internal usage by the builders.
  10158. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  10159. if id := m.sop_stage; id != nil {
  10160. ids = append(ids, *id)
  10161. }
  10162. return
  10163. }
  10164. // ResetSopStage resets all changes to the "sop_stage" edge.
  10165. func (m *MessageRecordsMutation) ResetSopStage() {
  10166. m.sop_stage = nil
  10167. m.clearedsop_stage = false
  10168. }
  10169. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  10170. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  10171. m.sop_node = &id
  10172. }
  10173. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  10174. func (m *MessageRecordsMutation) ClearSopNode() {
  10175. m.clearedsop_node = true
  10176. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  10177. }
  10178. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  10179. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  10180. return m.SubSourceIDCleared() || m.clearedsop_node
  10181. }
  10182. // SopNodeID returns the "sop_node" edge ID in the mutation.
  10183. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  10184. if m.sop_node != nil {
  10185. return *m.sop_node, true
  10186. }
  10187. return
  10188. }
  10189. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  10190. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  10191. // SopNodeID instead. It exists only for internal usage by the builders.
  10192. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  10193. if id := m.sop_node; id != nil {
  10194. ids = append(ids, *id)
  10195. }
  10196. return
  10197. }
  10198. // ResetSopNode resets all changes to the "sop_node" edge.
  10199. func (m *MessageRecordsMutation) ResetSopNode() {
  10200. m.sop_node = nil
  10201. m.clearedsop_node = false
  10202. }
  10203. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  10204. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  10205. m.message_contact = &id
  10206. }
  10207. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  10208. func (m *MessageRecordsMutation) ClearMessageContact() {
  10209. m.clearedmessage_contact = true
  10210. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  10211. }
  10212. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  10213. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  10214. return m.ContactIDCleared() || m.clearedmessage_contact
  10215. }
  10216. // MessageContactID returns the "message_contact" edge ID in the mutation.
  10217. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  10218. if m.message_contact != nil {
  10219. return *m.message_contact, true
  10220. }
  10221. return
  10222. }
  10223. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  10224. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  10225. // MessageContactID instead. It exists only for internal usage by the builders.
  10226. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  10227. if id := m.message_contact; id != nil {
  10228. ids = append(ids, *id)
  10229. }
  10230. return
  10231. }
  10232. // ResetMessageContact resets all changes to the "message_contact" edge.
  10233. func (m *MessageRecordsMutation) ResetMessageContact() {
  10234. m.message_contact = nil
  10235. m.clearedmessage_contact = false
  10236. }
  10237. // Where appends a list predicates to the MessageRecordsMutation builder.
  10238. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  10239. m.predicates = append(m.predicates, ps...)
  10240. }
  10241. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  10242. // users can use type-assertion to append predicates that do not depend on any generated package.
  10243. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  10244. p := make([]predicate.MessageRecords, len(ps))
  10245. for i := range ps {
  10246. p[i] = ps[i]
  10247. }
  10248. m.Where(p...)
  10249. }
  10250. // Op returns the operation name.
  10251. func (m *MessageRecordsMutation) Op() Op {
  10252. return m.op
  10253. }
  10254. // SetOp allows setting the mutation operation.
  10255. func (m *MessageRecordsMutation) SetOp(op Op) {
  10256. m.op = op
  10257. }
  10258. // Type returns the node type of this mutation (MessageRecords).
  10259. func (m *MessageRecordsMutation) Type() string {
  10260. return m.typ
  10261. }
  10262. // Fields returns all fields that were changed during this mutation. Note that in
  10263. // order to get all numeric fields that were incremented/decremented, call
  10264. // AddedFields().
  10265. func (m *MessageRecordsMutation) Fields() []string {
  10266. fields := make([]string, 0, 17)
  10267. if m.created_at != nil {
  10268. fields = append(fields, messagerecords.FieldCreatedAt)
  10269. }
  10270. if m.updated_at != nil {
  10271. fields = append(fields, messagerecords.FieldUpdatedAt)
  10272. }
  10273. if m.status != nil {
  10274. fields = append(fields, messagerecords.FieldStatus)
  10275. }
  10276. if m.deleted_at != nil {
  10277. fields = append(fields, messagerecords.FieldDeletedAt)
  10278. }
  10279. if m.bot_wxid != nil {
  10280. fields = append(fields, messagerecords.FieldBotWxid)
  10281. }
  10282. if m.message_contact != nil {
  10283. fields = append(fields, messagerecords.FieldContactID)
  10284. }
  10285. if m.contact_type != nil {
  10286. fields = append(fields, messagerecords.FieldContactType)
  10287. }
  10288. if m.contact_wxid != nil {
  10289. fields = append(fields, messagerecords.FieldContactWxid)
  10290. }
  10291. if m.content_type != nil {
  10292. fields = append(fields, messagerecords.FieldContentType)
  10293. }
  10294. if m.content != nil {
  10295. fields = append(fields, messagerecords.FieldContent)
  10296. }
  10297. if m.meta != nil {
  10298. fields = append(fields, messagerecords.FieldMeta)
  10299. }
  10300. if m.error_detail != nil {
  10301. fields = append(fields, messagerecords.FieldErrorDetail)
  10302. }
  10303. if m.send_time != nil {
  10304. fields = append(fields, messagerecords.FieldSendTime)
  10305. }
  10306. if m.source_type != nil {
  10307. fields = append(fields, messagerecords.FieldSourceType)
  10308. }
  10309. if m.sop_stage != nil {
  10310. fields = append(fields, messagerecords.FieldSourceID)
  10311. }
  10312. if m.sop_node != nil {
  10313. fields = append(fields, messagerecords.FieldSubSourceID)
  10314. }
  10315. if m.organization_id != nil {
  10316. fields = append(fields, messagerecords.FieldOrganizationID)
  10317. }
  10318. return fields
  10319. }
  10320. // Field returns the value of a field with the given name. The second boolean
  10321. // return value indicates that this field was not set, or was not defined in the
  10322. // schema.
  10323. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  10324. switch name {
  10325. case messagerecords.FieldCreatedAt:
  10326. return m.CreatedAt()
  10327. case messagerecords.FieldUpdatedAt:
  10328. return m.UpdatedAt()
  10329. case messagerecords.FieldStatus:
  10330. return m.Status()
  10331. case messagerecords.FieldDeletedAt:
  10332. return m.DeletedAt()
  10333. case messagerecords.FieldBotWxid:
  10334. return m.BotWxid()
  10335. case messagerecords.FieldContactID:
  10336. return m.ContactID()
  10337. case messagerecords.FieldContactType:
  10338. return m.ContactType()
  10339. case messagerecords.FieldContactWxid:
  10340. return m.ContactWxid()
  10341. case messagerecords.FieldContentType:
  10342. return m.ContentType()
  10343. case messagerecords.FieldContent:
  10344. return m.Content()
  10345. case messagerecords.FieldMeta:
  10346. return m.Meta()
  10347. case messagerecords.FieldErrorDetail:
  10348. return m.ErrorDetail()
  10349. case messagerecords.FieldSendTime:
  10350. return m.SendTime()
  10351. case messagerecords.FieldSourceType:
  10352. return m.SourceType()
  10353. case messagerecords.FieldSourceID:
  10354. return m.SourceID()
  10355. case messagerecords.FieldSubSourceID:
  10356. return m.SubSourceID()
  10357. case messagerecords.FieldOrganizationID:
  10358. return m.OrganizationID()
  10359. }
  10360. return nil, false
  10361. }
  10362. // OldField returns the old value of the field from the database. An error is
  10363. // returned if the mutation operation is not UpdateOne, or the query to the
  10364. // database failed.
  10365. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10366. switch name {
  10367. case messagerecords.FieldCreatedAt:
  10368. return m.OldCreatedAt(ctx)
  10369. case messagerecords.FieldUpdatedAt:
  10370. return m.OldUpdatedAt(ctx)
  10371. case messagerecords.FieldStatus:
  10372. return m.OldStatus(ctx)
  10373. case messagerecords.FieldDeletedAt:
  10374. return m.OldDeletedAt(ctx)
  10375. case messagerecords.FieldBotWxid:
  10376. return m.OldBotWxid(ctx)
  10377. case messagerecords.FieldContactID:
  10378. return m.OldContactID(ctx)
  10379. case messagerecords.FieldContactType:
  10380. return m.OldContactType(ctx)
  10381. case messagerecords.FieldContactWxid:
  10382. return m.OldContactWxid(ctx)
  10383. case messagerecords.FieldContentType:
  10384. return m.OldContentType(ctx)
  10385. case messagerecords.FieldContent:
  10386. return m.OldContent(ctx)
  10387. case messagerecords.FieldMeta:
  10388. return m.OldMeta(ctx)
  10389. case messagerecords.FieldErrorDetail:
  10390. return m.OldErrorDetail(ctx)
  10391. case messagerecords.FieldSendTime:
  10392. return m.OldSendTime(ctx)
  10393. case messagerecords.FieldSourceType:
  10394. return m.OldSourceType(ctx)
  10395. case messagerecords.FieldSourceID:
  10396. return m.OldSourceID(ctx)
  10397. case messagerecords.FieldSubSourceID:
  10398. return m.OldSubSourceID(ctx)
  10399. case messagerecords.FieldOrganizationID:
  10400. return m.OldOrganizationID(ctx)
  10401. }
  10402. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  10403. }
  10404. // SetField sets the value of a field with the given name. It returns an error if
  10405. // the field is not defined in the schema, or if the type mismatched the field
  10406. // type.
  10407. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  10408. switch name {
  10409. case messagerecords.FieldCreatedAt:
  10410. v, ok := value.(time.Time)
  10411. if !ok {
  10412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10413. }
  10414. m.SetCreatedAt(v)
  10415. return nil
  10416. case messagerecords.FieldUpdatedAt:
  10417. v, ok := value.(time.Time)
  10418. if !ok {
  10419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10420. }
  10421. m.SetUpdatedAt(v)
  10422. return nil
  10423. case messagerecords.FieldStatus:
  10424. v, ok := value.(uint8)
  10425. if !ok {
  10426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10427. }
  10428. m.SetStatus(v)
  10429. return nil
  10430. case messagerecords.FieldDeletedAt:
  10431. v, ok := value.(time.Time)
  10432. if !ok {
  10433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10434. }
  10435. m.SetDeletedAt(v)
  10436. return nil
  10437. case messagerecords.FieldBotWxid:
  10438. v, ok := value.(string)
  10439. if !ok {
  10440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10441. }
  10442. m.SetBotWxid(v)
  10443. return nil
  10444. case messagerecords.FieldContactID:
  10445. v, ok := value.(uint64)
  10446. if !ok {
  10447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10448. }
  10449. m.SetContactID(v)
  10450. return nil
  10451. case messagerecords.FieldContactType:
  10452. v, ok := value.(int)
  10453. if !ok {
  10454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10455. }
  10456. m.SetContactType(v)
  10457. return nil
  10458. case messagerecords.FieldContactWxid:
  10459. v, ok := value.(string)
  10460. if !ok {
  10461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10462. }
  10463. m.SetContactWxid(v)
  10464. return nil
  10465. case messagerecords.FieldContentType:
  10466. v, ok := value.(int)
  10467. if !ok {
  10468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10469. }
  10470. m.SetContentType(v)
  10471. return nil
  10472. case messagerecords.FieldContent:
  10473. v, ok := value.(string)
  10474. if !ok {
  10475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10476. }
  10477. m.SetContent(v)
  10478. return nil
  10479. case messagerecords.FieldMeta:
  10480. v, ok := value.(custom_types.Meta)
  10481. if !ok {
  10482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10483. }
  10484. m.SetMeta(v)
  10485. return nil
  10486. case messagerecords.FieldErrorDetail:
  10487. v, ok := value.(string)
  10488. if !ok {
  10489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10490. }
  10491. m.SetErrorDetail(v)
  10492. return nil
  10493. case messagerecords.FieldSendTime:
  10494. v, ok := value.(time.Time)
  10495. if !ok {
  10496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10497. }
  10498. m.SetSendTime(v)
  10499. return nil
  10500. case messagerecords.FieldSourceType:
  10501. v, ok := value.(int)
  10502. if !ok {
  10503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10504. }
  10505. m.SetSourceType(v)
  10506. return nil
  10507. case messagerecords.FieldSourceID:
  10508. v, ok := value.(uint64)
  10509. if !ok {
  10510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10511. }
  10512. m.SetSourceID(v)
  10513. return nil
  10514. case messagerecords.FieldSubSourceID:
  10515. v, ok := value.(uint64)
  10516. if !ok {
  10517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10518. }
  10519. m.SetSubSourceID(v)
  10520. return nil
  10521. case messagerecords.FieldOrganizationID:
  10522. v, ok := value.(uint64)
  10523. if !ok {
  10524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10525. }
  10526. m.SetOrganizationID(v)
  10527. return nil
  10528. }
  10529. return fmt.Errorf("unknown MessageRecords field %s", name)
  10530. }
  10531. // AddedFields returns all numeric fields that were incremented/decremented during
  10532. // this mutation.
  10533. func (m *MessageRecordsMutation) AddedFields() []string {
  10534. var fields []string
  10535. if m.addstatus != nil {
  10536. fields = append(fields, messagerecords.FieldStatus)
  10537. }
  10538. if m.addcontact_type != nil {
  10539. fields = append(fields, messagerecords.FieldContactType)
  10540. }
  10541. if m.addcontent_type != nil {
  10542. fields = append(fields, messagerecords.FieldContentType)
  10543. }
  10544. if m.addsource_type != nil {
  10545. fields = append(fields, messagerecords.FieldSourceType)
  10546. }
  10547. if m.addorganization_id != nil {
  10548. fields = append(fields, messagerecords.FieldOrganizationID)
  10549. }
  10550. return fields
  10551. }
  10552. // AddedField returns the numeric value that was incremented/decremented on a field
  10553. // with the given name. The second boolean return value indicates that this field
  10554. // was not set, or was not defined in the schema.
  10555. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  10556. switch name {
  10557. case messagerecords.FieldStatus:
  10558. return m.AddedStatus()
  10559. case messagerecords.FieldContactType:
  10560. return m.AddedContactType()
  10561. case messagerecords.FieldContentType:
  10562. return m.AddedContentType()
  10563. case messagerecords.FieldSourceType:
  10564. return m.AddedSourceType()
  10565. case messagerecords.FieldOrganizationID:
  10566. return m.AddedOrganizationID()
  10567. }
  10568. return nil, false
  10569. }
  10570. // AddField adds the value to the field with the given name. It returns an error if
  10571. // the field is not defined in the schema, or if the type mismatched the field
  10572. // type.
  10573. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  10574. switch name {
  10575. case messagerecords.FieldStatus:
  10576. v, ok := value.(int8)
  10577. if !ok {
  10578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10579. }
  10580. m.AddStatus(v)
  10581. return nil
  10582. case messagerecords.FieldContactType:
  10583. v, ok := value.(int)
  10584. if !ok {
  10585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10586. }
  10587. m.AddContactType(v)
  10588. return nil
  10589. case messagerecords.FieldContentType:
  10590. v, ok := value.(int)
  10591. if !ok {
  10592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10593. }
  10594. m.AddContentType(v)
  10595. return nil
  10596. case messagerecords.FieldSourceType:
  10597. v, ok := value.(int)
  10598. if !ok {
  10599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10600. }
  10601. m.AddSourceType(v)
  10602. return nil
  10603. case messagerecords.FieldOrganizationID:
  10604. v, ok := value.(int64)
  10605. if !ok {
  10606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10607. }
  10608. m.AddOrganizationID(v)
  10609. return nil
  10610. }
  10611. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  10612. }
  10613. // ClearedFields returns all nullable fields that were cleared during this
  10614. // mutation.
  10615. func (m *MessageRecordsMutation) ClearedFields() []string {
  10616. var fields []string
  10617. if m.FieldCleared(messagerecords.FieldStatus) {
  10618. fields = append(fields, messagerecords.FieldStatus)
  10619. }
  10620. if m.FieldCleared(messagerecords.FieldDeletedAt) {
  10621. fields = append(fields, messagerecords.FieldDeletedAt)
  10622. }
  10623. if m.FieldCleared(messagerecords.FieldContactID) {
  10624. fields = append(fields, messagerecords.FieldContactID)
  10625. }
  10626. if m.FieldCleared(messagerecords.FieldMeta) {
  10627. fields = append(fields, messagerecords.FieldMeta)
  10628. }
  10629. if m.FieldCleared(messagerecords.FieldSendTime) {
  10630. fields = append(fields, messagerecords.FieldSendTime)
  10631. }
  10632. if m.FieldCleared(messagerecords.FieldSourceID) {
  10633. fields = append(fields, messagerecords.FieldSourceID)
  10634. }
  10635. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  10636. fields = append(fields, messagerecords.FieldSubSourceID)
  10637. }
  10638. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  10639. fields = append(fields, messagerecords.FieldOrganizationID)
  10640. }
  10641. return fields
  10642. }
  10643. // FieldCleared returns a boolean indicating if a field with the given name was
  10644. // cleared in this mutation.
  10645. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  10646. _, ok := m.clearedFields[name]
  10647. return ok
  10648. }
  10649. // ClearField clears the value of the field with the given name. It returns an
  10650. // error if the field is not defined in the schema.
  10651. func (m *MessageRecordsMutation) ClearField(name string) error {
  10652. switch name {
  10653. case messagerecords.FieldStatus:
  10654. m.ClearStatus()
  10655. return nil
  10656. case messagerecords.FieldDeletedAt:
  10657. m.ClearDeletedAt()
  10658. return nil
  10659. case messagerecords.FieldContactID:
  10660. m.ClearContactID()
  10661. return nil
  10662. case messagerecords.FieldMeta:
  10663. m.ClearMeta()
  10664. return nil
  10665. case messagerecords.FieldSendTime:
  10666. m.ClearSendTime()
  10667. return nil
  10668. case messagerecords.FieldSourceID:
  10669. m.ClearSourceID()
  10670. return nil
  10671. case messagerecords.FieldSubSourceID:
  10672. m.ClearSubSourceID()
  10673. return nil
  10674. case messagerecords.FieldOrganizationID:
  10675. m.ClearOrganizationID()
  10676. return nil
  10677. }
  10678. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  10679. }
  10680. // ResetField resets all changes in the mutation for the field with the given name.
  10681. // It returns an error if the field is not defined in the schema.
  10682. func (m *MessageRecordsMutation) ResetField(name string) error {
  10683. switch name {
  10684. case messagerecords.FieldCreatedAt:
  10685. m.ResetCreatedAt()
  10686. return nil
  10687. case messagerecords.FieldUpdatedAt:
  10688. m.ResetUpdatedAt()
  10689. return nil
  10690. case messagerecords.FieldStatus:
  10691. m.ResetStatus()
  10692. return nil
  10693. case messagerecords.FieldDeletedAt:
  10694. m.ResetDeletedAt()
  10695. return nil
  10696. case messagerecords.FieldBotWxid:
  10697. m.ResetBotWxid()
  10698. return nil
  10699. case messagerecords.FieldContactID:
  10700. m.ResetContactID()
  10701. return nil
  10702. case messagerecords.FieldContactType:
  10703. m.ResetContactType()
  10704. return nil
  10705. case messagerecords.FieldContactWxid:
  10706. m.ResetContactWxid()
  10707. return nil
  10708. case messagerecords.FieldContentType:
  10709. m.ResetContentType()
  10710. return nil
  10711. case messagerecords.FieldContent:
  10712. m.ResetContent()
  10713. return nil
  10714. case messagerecords.FieldMeta:
  10715. m.ResetMeta()
  10716. return nil
  10717. case messagerecords.FieldErrorDetail:
  10718. m.ResetErrorDetail()
  10719. return nil
  10720. case messagerecords.FieldSendTime:
  10721. m.ResetSendTime()
  10722. return nil
  10723. case messagerecords.FieldSourceType:
  10724. m.ResetSourceType()
  10725. return nil
  10726. case messagerecords.FieldSourceID:
  10727. m.ResetSourceID()
  10728. return nil
  10729. case messagerecords.FieldSubSourceID:
  10730. m.ResetSubSourceID()
  10731. return nil
  10732. case messagerecords.FieldOrganizationID:
  10733. m.ResetOrganizationID()
  10734. return nil
  10735. }
  10736. return fmt.Errorf("unknown MessageRecords field %s", name)
  10737. }
  10738. // AddedEdges returns all edge names that were set/added in this mutation.
  10739. func (m *MessageRecordsMutation) AddedEdges() []string {
  10740. edges := make([]string, 0, 3)
  10741. if m.sop_stage != nil {
  10742. edges = append(edges, messagerecords.EdgeSopStage)
  10743. }
  10744. if m.sop_node != nil {
  10745. edges = append(edges, messagerecords.EdgeSopNode)
  10746. }
  10747. if m.message_contact != nil {
  10748. edges = append(edges, messagerecords.EdgeMessageContact)
  10749. }
  10750. return edges
  10751. }
  10752. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10753. // name in this mutation.
  10754. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  10755. switch name {
  10756. case messagerecords.EdgeSopStage:
  10757. if id := m.sop_stage; id != nil {
  10758. return []ent.Value{*id}
  10759. }
  10760. case messagerecords.EdgeSopNode:
  10761. if id := m.sop_node; id != nil {
  10762. return []ent.Value{*id}
  10763. }
  10764. case messagerecords.EdgeMessageContact:
  10765. if id := m.message_contact; id != nil {
  10766. return []ent.Value{*id}
  10767. }
  10768. }
  10769. return nil
  10770. }
  10771. // RemovedEdges returns all edge names that were removed in this mutation.
  10772. func (m *MessageRecordsMutation) RemovedEdges() []string {
  10773. edges := make([]string, 0, 3)
  10774. return edges
  10775. }
  10776. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10777. // the given name in this mutation.
  10778. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  10779. return nil
  10780. }
  10781. // ClearedEdges returns all edge names that were cleared in this mutation.
  10782. func (m *MessageRecordsMutation) ClearedEdges() []string {
  10783. edges := make([]string, 0, 3)
  10784. if m.clearedsop_stage {
  10785. edges = append(edges, messagerecords.EdgeSopStage)
  10786. }
  10787. if m.clearedsop_node {
  10788. edges = append(edges, messagerecords.EdgeSopNode)
  10789. }
  10790. if m.clearedmessage_contact {
  10791. edges = append(edges, messagerecords.EdgeMessageContact)
  10792. }
  10793. return edges
  10794. }
  10795. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10796. // was cleared in this mutation.
  10797. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  10798. switch name {
  10799. case messagerecords.EdgeSopStage:
  10800. return m.clearedsop_stage
  10801. case messagerecords.EdgeSopNode:
  10802. return m.clearedsop_node
  10803. case messagerecords.EdgeMessageContact:
  10804. return m.clearedmessage_contact
  10805. }
  10806. return false
  10807. }
  10808. // ClearEdge clears the value of the edge with the given name. It returns an error
  10809. // if that edge is not defined in the schema.
  10810. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  10811. switch name {
  10812. case messagerecords.EdgeSopStage:
  10813. m.ClearSopStage()
  10814. return nil
  10815. case messagerecords.EdgeSopNode:
  10816. m.ClearSopNode()
  10817. return nil
  10818. case messagerecords.EdgeMessageContact:
  10819. m.ClearMessageContact()
  10820. return nil
  10821. }
  10822. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  10823. }
  10824. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10825. // It returns an error if the edge is not defined in the schema.
  10826. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  10827. switch name {
  10828. case messagerecords.EdgeSopStage:
  10829. m.ResetSopStage()
  10830. return nil
  10831. case messagerecords.EdgeSopNode:
  10832. m.ResetSopNode()
  10833. return nil
  10834. case messagerecords.EdgeMessageContact:
  10835. m.ResetMessageContact()
  10836. return nil
  10837. }
  10838. return fmt.Errorf("unknown MessageRecords edge %s", name)
  10839. }
  10840. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  10841. type MsgMutation struct {
  10842. config
  10843. op Op
  10844. typ string
  10845. id *uint64
  10846. created_at *time.Time
  10847. updated_at *time.Time
  10848. deleted_at *time.Time
  10849. status *uint8
  10850. addstatus *int8
  10851. fromwxid *string
  10852. toid *string
  10853. msgtype *int32
  10854. addmsgtype *int32
  10855. msg *string
  10856. batch_no *string
  10857. clearedFields map[string]struct{}
  10858. done bool
  10859. oldValue func(context.Context) (*Msg, error)
  10860. predicates []predicate.Msg
  10861. }
  10862. var _ ent.Mutation = (*MsgMutation)(nil)
  10863. // msgOption allows management of the mutation configuration using functional options.
  10864. type msgOption func(*MsgMutation)
  10865. // newMsgMutation creates new mutation for the Msg entity.
  10866. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  10867. m := &MsgMutation{
  10868. config: c,
  10869. op: op,
  10870. typ: TypeMsg,
  10871. clearedFields: make(map[string]struct{}),
  10872. }
  10873. for _, opt := range opts {
  10874. opt(m)
  10875. }
  10876. return m
  10877. }
  10878. // withMsgID sets the ID field of the mutation.
  10879. func withMsgID(id uint64) msgOption {
  10880. return func(m *MsgMutation) {
  10881. var (
  10882. err error
  10883. once sync.Once
  10884. value *Msg
  10885. )
  10886. m.oldValue = func(ctx context.Context) (*Msg, error) {
  10887. once.Do(func() {
  10888. if m.done {
  10889. err = errors.New("querying old values post mutation is not allowed")
  10890. } else {
  10891. value, err = m.Client().Msg.Get(ctx, id)
  10892. }
  10893. })
  10894. return value, err
  10895. }
  10896. m.id = &id
  10897. }
  10898. }
  10899. // withMsg sets the old Msg of the mutation.
  10900. func withMsg(node *Msg) msgOption {
  10901. return func(m *MsgMutation) {
  10902. m.oldValue = func(context.Context) (*Msg, error) {
  10903. return node, nil
  10904. }
  10905. m.id = &node.ID
  10906. }
  10907. }
  10908. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10909. // executed in a transaction (ent.Tx), a transactional client is returned.
  10910. func (m MsgMutation) Client() *Client {
  10911. client := &Client{config: m.config}
  10912. client.init()
  10913. return client
  10914. }
  10915. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10916. // it returns an error otherwise.
  10917. func (m MsgMutation) Tx() (*Tx, error) {
  10918. if _, ok := m.driver.(*txDriver); !ok {
  10919. return nil, errors.New("ent: mutation is not running in a transaction")
  10920. }
  10921. tx := &Tx{config: m.config}
  10922. tx.init()
  10923. return tx, nil
  10924. }
  10925. // SetID sets the value of the id field. Note that this
  10926. // operation is only accepted on creation of Msg entities.
  10927. func (m *MsgMutation) SetID(id uint64) {
  10928. m.id = &id
  10929. }
  10930. // ID returns the ID value in the mutation. Note that the ID is only available
  10931. // if it was provided to the builder or after it was returned from the database.
  10932. func (m *MsgMutation) ID() (id uint64, exists bool) {
  10933. if m.id == nil {
  10934. return
  10935. }
  10936. return *m.id, true
  10937. }
  10938. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10939. // That means, if the mutation is applied within a transaction with an isolation level such
  10940. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10941. // or updated by the mutation.
  10942. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  10943. switch {
  10944. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10945. id, exists := m.ID()
  10946. if exists {
  10947. return []uint64{id}, nil
  10948. }
  10949. fallthrough
  10950. case m.op.Is(OpUpdate | OpDelete):
  10951. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  10952. default:
  10953. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10954. }
  10955. }
  10956. // SetCreatedAt sets the "created_at" field.
  10957. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  10958. m.created_at = &t
  10959. }
  10960. // CreatedAt returns the value of the "created_at" field in the mutation.
  10961. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  10962. v := m.created_at
  10963. if v == nil {
  10964. return
  10965. }
  10966. return *v, true
  10967. }
  10968. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  10969. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10971. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10972. if !m.op.Is(OpUpdateOne) {
  10973. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10974. }
  10975. if m.id == nil || m.oldValue == nil {
  10976. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10977. }
  10978. oldValue, err := m.oldValue(ctx)
  10979. if err != nil {
  10980. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10981. }
  10982. return oldValue.CreatedAt, nil
  10983. }
  10984. // ResetCreatedAt resets all changes to the "created_at" field.
  10985. func (m *MsgMutation) ResetCreatedAt() {
  10986. m.created_at = nil
  10987. }
  10988. // SetUpdatedAt sets the "updated_at" field.
  10989. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  10990. m.updated_at = &t
  10991. }
  10992. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10993. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  10994. v := m.updated_at
  10995. if v == nil {
  10996. return
  10997. }
  10998. return *v, true
  10999. }
  11000. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  11001. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11002. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11003. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11004. if !m.op.Is(OpUpdateOne) {
  11005. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11006. }
  11007. if m.id == nil || m.oldValue == nil {
  11008. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11009. }
  11010. oldValue, err := m.oldValue(ctx)
  11011. if err != nil {
  11012. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11013. }
  11014. return oldValue.UpdatedAt, nil
  11015. }
  11016. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11017. func (m *MsgMutation) ResetUpdatedAt() {
  11018. m.updated_at = nil
  11019. }
  11020. // SetDeletedAt sets the "deleted_at" field.
  11021. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  11022. m.deleted_at = &t
  11023. }
  11024. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11025. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  11026. v := m.deleted_at
  11027. if v == nil {
  11028. return
  11029. }
  11030. return *v, true
  11031. }
  11032. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  11033. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11035. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11036. if !m.op.Is(OpUpdateOne) {
  11037. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11038. }
  11039. if m.id == nil || m.oldValue == nil {
  11040. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11041. }
  11042. oldValue, err := m.oldValue(ctx)
  11043. if err != nil {
  11044. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11045. }
  11046. return oldValue.DeletedAt, nil
  11047. }
  11048. // ClearDeletedAt clears the value of the "deleted_at" field.
  11049. func (m *MsgMutation) ClearDeletedAt() {
  11050. m.deleted_at = nil
  11051. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  11052. }
  11053. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11054. func (m *MsgMutation) DeletedAtCleared() bool {
  11055. _, ok := m.clearedFields[msg.FieldDeletedAt]
  11056. return ok
  11057. }
  11058. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11059. func (m *MsgMutation) ResetDeletedAt() {
  11060. m.deleted_at = nil
  11061. delete(m.clearedFields, msg.FieldDeletedAt)
  11062. }
  11063. // SetStatus sets the "status" field.
  11064. func (m *MsgMutation) SetStatus(u uint8) {
  11065. m.status = &u
  11066. m.addstatus = nil
  11067. }
  11068. // Status returns the value of the "status" field in the mutation.
  11069. func (m *MsgMutation) Status() (r uint8, exists bool) {
  11070. v := m.status
  11071. if v == nil {
  11072. return
  11073. }
  11074. return *v, true
  11075. }
  11076. // OldStatus returns the old "status" field's value of the Msg entity.
  11077. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11079. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11080. if !m.op.Is(OpUpdateOne) {
  11081. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11082. }
  11083. if m.id == nil || m.oldValue == nil {
  11084. return v, errors.New("OldStatus requires an ID field in the mutation")
  11085. }
  11086. oldValue, err := m.oldValue(ctx)
  11087. if err != nil {
  11088. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11089. }
  11090. return oldValue.Status, nil
  11091. }
  11092. // AddStatus adds u to the "status" field.
  11093. func (m *MsgMutation) AddStatus(u int8) {
  11094. if m.addstatus != nil {
  11095. *m.addstatus += u
  11096. } else {
  11097. m.addstatus = &u
  11098. }
  11099. }
  11100. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11101. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  11102. v := m.addstatus
  11103. if v == nil {
  11104. return
  11105. }
  11106. return *v, true
  11107. }
  11108. // ClearStatus clears the value of the "status" field.
  11109. func (m *MsgMutation) ClearStatus() {
  11110. m.status = nil
  11111. m.addstatus = nil
  11112. m.clearedFields[msg.FieldStatus] = struct{}{}
  11113. }
  11114. // StatusCleared returns if the "status" field was cleared in this mutation.
  11115. func (m *MsgMutation) StatusCleared() bool {
  11116. _, ok := m.clearedFields[msg.FieldStatus]
  11117. return ok
  11118. }
  11119. // ResetStatus resets all changes to the "status" field.
  11120. func (m *MsgMutation) ResetStatus() {
  11121. m.status = nil
  11122. m.addstatus = nil
  11123. delete(m.clearedFields, msg.FieldStatus)
  11124. }
  11125. // SetFromwxid sets the "fromwxid" field.
  11126. func (m *MsgMutation) SetFromwxid(s string) {
  11127. m.fromwxid = &s
  11128. }
  11129. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  11130. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  11131. v := m.fromwxid
  11132. if v == nil {
  11133. return
  11134. }
  11135. return *v, true
  11136. }
  11137. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  11138. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11140. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  11141. if !m.op.Is(OpUpdateOne) {
  11142. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  11143. }
  11144. if m.id == nil || m.oldValue == nil {
  11145. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  11146. }
  11147. oldValue, err := m.oldValue(ctx)
  11148. if err != nil {
  11149. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  11150. }
  11151. return oldValue.Fromwxid, nil
  11152. }
  11153. // ClearFromwxid clears the value of the "fromwxid" field.
  11154. func (m *MsgMutation) ClearFromwxid() {
  11155. m.fromwxid = nil
  11156. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  11157. }
  11158. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  11159. func (m *MsgMutation) FromwxidCleared() bool {
  11160. _, ok := m.clearedFields[msg.FieldFromwxid]
  11161. return ok
  11162. }
  11163. // ResetFromwxid resets all changes to the "fromwxid" field.
  11164. func (m *MsgMutation) ResetFromwxid() {
  11165. m.fromwxid = nil
  11166. delete(m.clearedFields, msg.FieldFromwxid)
  11167. }
  11168. // SetToid sets the "toid" field.
  11169. func (m *MsgMutation) SetToid(s string) {
  11170. m.toid = &s
  11171. }
  11172. // Toid returns the value of the "toid" field in the mutation.
  11173. func (m *MsgMutation) Toid() (r string, exists bool) {
  11174. v := m.toid
  11175. if v == nil {
  11176. return
  11177. }
  11178. return *v, true
  11179. }
  11180. // OldToid returns the old "toid" field's value of the Msg entity.
  11181. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11183. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  11184. if !m.op.Is(OpUpdateOne) {
  11185. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  11186. }
  11187. if m.id == nil || m.oldValue == nil {
  11188. return v, errors.New("OldToid requires an ID field in the mutation")
  11189. }
  11190. oldValue, err := m.oldValue(ctx)
  11191. if err != nil {
  11192. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  11193. }
  11194. return oldValue.Toid, nil
  11195. }
  11196. // ClearToid clears the value of the "toid" field.
  11197. func (m *MsgMutation) ClearToid() {
  11198. m.toid = nil
  11199. m.clearedFields[msg.FieldToid] = struct{}{}
  11200. }
  11201. // ToidCleared returns if the "toid" field was cleared in this mutation.
  11202. func (m *MsgMutation) ToidCleared() bool {
  11203. _, ok := m.clearedFields[msg.FieldToid]
  11204. return ok
  11205. }
  11206. // ResetToid resets all changes to the "toid" field.
  11207. func (m *MsgMutation) ResetToid() {
  11208. m.toid = nil
  11209. delete(m.clearedFields, msg.FieldToid)
  11210. }
  11211. // SetMsgtype sets the "msgtype" field.
  11212. func (m *MsgMutation) SetMsgtype(i int32) {
  11213. m.msgtype = &i
  11214. m.addmsgtype = nil
  11215. }
  11216. // Msgtype returns the value of the "msgtype" field in the mutation.
  11217. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  11218. v := m.msgtype
  11219. if v == nil {
  11220. return
  11221. }
  11222. return *v, true
  11223. }
  11224. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  11225. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11227. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  11228. if !m.op.Is(OpUpdateOne) {
  11229. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  11230. }
  11231. if m.id == nil || m.oldValue == nil {
  11232. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  11233. }
  11234. oldValue, err := m.oldValue(ctx)
  11235. if err != nil {
  11236. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  11237. }
  11238. return oldValue.Msgtype, nil
  11239. }
  11240. // AddMsgtype adds i to the "msgtype" field.
  11241. func (m *MsgMutation) AddMsgtype(i int32) {
  11242. if m.addmsgtype != nil {
  11243. *m.addmsgtype += i
  11244. } else {
  11245. m.addmsgtype = &i
  11246. }
  11247. }
  11248. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  11249. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  11250. v := m.addmsgtype
  11251. if v == nil {
  11252. return
  11253. }
  11254. return *v, true
  11255. }
  11256. // ClearMsgtype clears the value of the "msgtype" field.
  11257. func (m *MsgMutation) ClearMsgtype() {
  11258. m.msgtype = nil
  11259. m.addmsgtype = nil
  11260. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  11261. }
  11262. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  11263. func (m *MsgMutation) MsgtypeCleared() bool {
  11264. _, ok := m.clearedFields[msg.FieldMsgtype]
  11265. return ok
  11266. }
  11267. // ResetMsgtype resets all changes to the "msgtype" field.
  11268. func (m *MsgMutation) ResetMsgtype() {
  11269. m.msgtype = nil
  11270. m.addmsgtype = nil
  11271. delete(m.clearedFields, msg.FieldMsgtype)
  11272. }
  11273. // SetMsg sets the "msg" field.
  11274. func (m *MsgMutation) SetMsg(s string) {
  11275. m.msg = &s
  11276. }
  11277. // Msg returns the value of the "msg" field in the mutation.
  11278. func (m *MsgMutation) Msg() (r string, exists bool) {
  11279. v := m.msg
  11280. if v == nil {
  11281. return
  11282. }
  11283. return *v, true
  11284. }
  11285. // OldMsg returns the old "msg" field's value of the Msg entity.
  11286. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11288. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  11289. if !m.op.Is(OpUpdateOne) {
  11290. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  11291. }
  11292. if m.id == nil || m.oldValue == nil {
  11293. return v, errors.New("OldMsg requires an ID field in the mutation")
  11294. }
  11295. oldValue, err := m.oldValue(ctx)
  11296. if err != nil {
  11297. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  11298. }
  11299. return oldValue.Msg, nil
  11300. }
  11301. // ClearMsg clears the value of the "msg" field.
  11302. func (m *MsgMutation) ClearMsg() {
  11303. m.msg = nil
  11304. m.clearedFields[msg.FieldMsg] = struct{}{}
  11305. }
  11306. // MsgCleared returns if the "msg" field was cleared in this mutation.
  11307. func (m *MsgMutation) MsgCleared() bool {
  11308. _, ok := m.clearedFields[msg.FieldMsg]
  11309. return ok
  11310. }
  11311. // ResetMsg resets all changes to the "msg" field.
  11312. func (m *MsgMutation) ResetMsg() {
  11313. m.msg = nil
  11314. delete(m.clearedFields, msg.FieldMsg)
  11315. }
  11316. // SetBatchNo sets the "batch_no" field.
  11317. func (m *MsgMutation) SetBatchNo(s string) {
  11318. m.batch_no = &s
  11319. }
  11320. // BatchNo returns the value of the "batch_no" field in the mutation.
  11321. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  11322. v := m.batch_no
  11323. if v == nil {
  11324. return
  11325. }
  11326. return *v, true
  11327. }
  11328. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  11329. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11331. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  11332. if !m.op.Is(OpUpdateOne) {
  11333. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  11334. }
  11335. if m.id == nil || m.oldValue == nil {
  11336. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  11337. }
  11338. oldValue, err := m.oldValue(ctx)
  11339. if err != nil {
  11340. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  11341. }
  11342. return oldValue.BatchNo, nil
  11343. }
  11344. // ClearBatchNo clears the value of the "batch_no" field.
  11345. func (m *MsgMutation) ClearBatchNo() {
  11346. m.batch_no = nil
  11347. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  11348. }
  11349. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  11350. func (m *MsgMutation) BatchNoCleared() bool {
  11351. _, ok := m.clearedFields[msg.FieldBatchNo]
  11352. return ok
  11353. }
  11354. // ResetBatchNo resets all changes to the "batch_no" field.
  11355. func (m *MsgMutation) ResetBatchNo() {
  11356. m.batch_no = nil
  11357. delete(m.clearedFields, msg.FieldBatchNo)
  11358. }
  11359. // Where appends a list predicates to the MsgMutation builder.
  11360. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  11361. m.predicates = append(m.predicates, ps...)
  11362. }
  11363. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  11364. // users can use type-assertion to append predicates that do not depend on any generated package.
  11365. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  11366. p := make([]predicate.Msg, len(ps))
  11367. for i := range ps {
  11368. p[i] = ps[i]
  11369. }
  11370. m.Where(p...)
  11371. }
  11372. // Op returns the operation name.
  11373. func (m *MsgMutation) Op() Op {
  11374. return m.op
  11375. }
  11376. // SetOp allows setting the mutation operation.
  11377. func (m *MsgMutation) SetOp(op Op) {
  11378. m.op = op
  11379. }
  11380. // Type returns the node type of this mutation (Msg).
  11381. func (m *MsgMutation) Type() string {
  11382. return m.typ
  11383. }
  11384. // Fields returns all fields that were changed during this mutation. Note that in
  11385. // order to get all numeric fields that were incremented/decremented, call
  11386. // AddedFields().
  11387. func (m *MsgMutation) Fields() []string {
  11388. fields := make([]string, 0, 9)
  11389. if m.created_at != nil {
  11390. fields = append(fields, msg.FieldCreatedAt)
  11391. }
  11392. if m.updated_at != nil {
  11393. fields = append(fields, msg.FieldUpdatedAt)
  11394. }
  11395. if m.deleted_at != nil {
  11396. fields = append(fields, msg.FieldDeletedAt)
  11397. }
  11398. if m.status != nil {
  11399. fields = append(fields, msg.FieldStatus)
  11400. }
  11401. if m.fromwxid != nil {
  11402. fields = append(fields, msg.FieldFromwxid)
  11403. }
  11404. if m.toid != nil {
  11405. fields = append(fields, msg.FieldToid)
  11406. }
  11407. if m.msgtype != nil {
  11408. fields = append(fields, msg.FieldMsgtype)
  11409. }
  11410. if m.msg != nil {
  11411. fields = append(fields, msg.FieldMsg)
  11412. }
  11413. if m.batch_no != nil {
  11414. fields = append(fields, msg.FieldBatchNo)
  11415. }
  11416. return fields
  11417. }
  11418. // Field returns the value of a field with the given name. The second boolean
  11419. // return value indicates that this field was not set, or was not defined in the
  11420. // schema.
  11421. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  11422. switch name {
  11423. case msg.FieldCreatedAt:
  11424. return m.CreatedAt()
  11425. case msg.FieldUpdatedAt:
  11426. return m.UpdatedAt()
  11427. case msg.FieldDeletedAt:
  11428. return m.DeletedAt()
  11429. case msg.FieldStatus:
  11430. return m.Status()
  11431. case msg.FieldFromwxid:
  11432. return m.Fromwxid()
  11433. case msg.FieldToid:
  11434. return m.Toid()
  11435. case msg.FieldMsgtype:
  11436. return m.Msgtype()
  11437. case msg.FieldMsg:
  11438. return m.Msg()
  11439. case msg.FieldBatchNo:
  11440. return m.BatchNo()
  11441. }
  11442. return nil, false
  11443. }
  11444. // OldField returns the old value of the field from the database. An error is
  11445. // returned if the mutation operation is not UpdateOne, or the query to the
  11446. // database failed.
  11447. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11448. switch name {
  11449. case msg.FieldCreatedAt:
  11450. return m.OldCreatedAt(ctx)
  11451. case msg.FieldUpdatedAt:
  11452. return m.OldUpdatedAt(ctx)
  11453. case msg.FieldDeletedAt:
  11454. return m.OldDeletedAt(ctx)
  11455. case msg.FieldStatus:
  11456. return m.OldStatus(ctx)
  11457. case msg.FieldFromwxid:
  11458. return m.OldFromwxid(ctx)
  11459. case msg.FieldToid:
  11460. return m.OldToid(ctx)
  11461. case msg.FieldMsgtype:
  11462. return m.OldMsgtype(ctx)
  11463. case msg.FieldMsg:
  11464. return m.OldMsg(ctx)
  11465. case msg.FieldBatchNo:
  11466. return m.OldBatchNo(ctx)
  11467. }
  11468. return nil, fmt.Errorf("unknown Msg field %s", name)
  11469. }
  11470. // SetField sets the value of a field with the given name. It returns an error if
  11471. // the field is not defined in the schema, or if the type mismatched the field
  11472. // type.
  11473. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  11474. switch name {
  11475. case msg.FieldCreatedAt:
  11476. v, ok := value.(time.Time)
  11477. if !ok {
  11478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11479. }
  11480. m.SetCreatedAt(v)
  11481. return nil
  11482. case msg.FieldUpdatedAt:
  11483. v, ok := value.(time.Time)
  11484. if !ok {
  11485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11486. }
  11487. m.SetUpdatedAt(v)
  11488. return nil
  11489. case msg.FieldDeletedAt:
  11490. v, ok := value.(time.Time)
  11491. if !ok {
  11492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11493. }
  11494. m.SetDeletedAt(v)
  11495. return nil
  11496. case msg.FieldStatus:
  11497. v, ok := value.(uint8)
  11498. if !ok {
  11499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11500. }
  11501. m.SetStatus(v)
  11502. return nil
  11503. case msg.FieldFromwxid:
  11504. v, ok := value.(string)
  11505. if !ok {
  11506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11507. }
  11508. m.SetFromwxid(v)
  11509. return nil
  11510. case msg.FieldToid:
  11511. v, ok := value.(string)
  11512. if !ok {
  11513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11514. }
  11515. m.SetToid(v)
  11516. return nil
  11517. case msg.FieldMsgtype:
  11518. v, ok := value.(int32)
  11519. if !ok {
  11520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11521. }
  11522. m.SetMsgtype(v)
  11523. return nil
  11524. case msg.FieldMsg:
  11525. v, ok := value.(string)
  11526. if !ok {
  11527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11528. }
  11529. m.SetMsg(v)
  11530. return nil
  11531. case msg.FieldBatchNo:
  11532. v, ok := value.(string)
  11533. if !ok {
  11534. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11535. }
  11536. m.SetBatchNo(v)
  11537. return nil
  11538. }
  11539. return fmt.Errorf("unknown Msg field %s", name)
  11540. }
  11541. // AddedFields returns all numeric fields that were incremented/decremented during
  11542. // this mutation.
  11543. func (m *MsgMutation) AddedFields() []string {
  11544. var fields []string
  11545. if m.addstatus != nil {
  11546. fields = append(fields, msg.FieldStatus)
  11547. }
  11548. if m.addmsgtype != nil {
  11549. fields = append(fields, msg.FieldMsgtype)
  11550. }
  11551. return fields
  11552. }
  11553. // AddedField returns the numeric value that was incremented/decremented on a field
  11554. // with the given name. The second boolean return value indicates that this field
  11555. // was not set, or was not defined in the schema.
  11556. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  11557. switch name {
  11558. case msg.FieldStatus:
  11559. return m.AddedStatus()
  11560. case msg.FieldMsgtype:
  11561. return m.AddedMsgtype()
  11562. }
  11563. return nil, false
  11564. }
  11565. // AddField adds the value to the field with the given name. It returns an error if
  11566. // the field is not defined in the schema, or if the type mismatched the field
  11567. // type.
  11568. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  11569. switch name {
  11570. case msg.FieldStatus:
  11571. v, ok := value.(int8)
  11572. if !ok {
  11573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11574. }
  11575. m.AddStatus(v)
  11576. return nil
  11577. case msg.FieldMsgtype:
  11578. v, ok := value.(int32)
  11579. if !ok {
  11580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11581. }
  11582. m.AddMsgtype(v)
  11583. return nil
  11584. }
  11585. return fmt.Errorf("unknown Msg numeric field %s", name)
  11586. }
  11587. // ClearedFields returns all nullable fields that were cleared during this
  11588. // mutation.
  11589. func (m *MsgMutation) ClearedFields() []string {
  11590. var fields []string
  11591. if m.FieldCleared(msg.FieldDeletedAt) {
  11592. fields = append(fields, msg.FieldDeletedAt)
  11593. }
  11594. if m.FieldCleared(msg.FieldStatus) {
  11595. fields = append(fields, msg.FieldStatus)
  11596. }
  11597. if m.FieldCleared(msg.FieldFromwxid) {
  11598. fields = append(fields, msg.FieldFromwxid)
  11599. }
  11600. if m.FieldCleared(msg.FieldToid) {
  11601. fields = append(fields, msg.FieldToid)
  11602. }
  11603. if m.FieldCleared(msg.FieldMsgtype) {
  11604. fields = append(fields, msg.FieldMsgtype)
  11605. }
  11606. if m.FieldCleared(msg.FieldMsg) {
  11607. fields = append(fields, msg.FieldMsg)
  11608. }
  11609. if m.FieldCleared(msg.FieldBatchNo) {
  11610. fields = append(fields, msg.FieldBatchNo)
  11611. }
  11612. return fields
  11613. }
  11614. // FieldCleared returns a boolean indicating if a field with the given name was
  11615. // cleared in this mutation.
  11616. func (m *MsgMutation) FieldCleared(name string) bool {
  11617. _, ok := m.clearedFields[name]
  11618. return ok
  11619. }
  11620. // ClearField clears the value of the field with the given name. It returns an
  11621. // error if the field is not defined in the schema.
  11622. func (m *MsgMutation) ClearField(name string) error {
  11623. switch name {
  11624. case msg.FieldDeletedAt:
  11625. m.ClearDeletedAt()
  11626. return nil
  11627. case msg.FieldStatus:
  11628. m.ClearStatus()
  11629. return nil
  11630. case msg.FieldFromwxid:
  11631. m.ClearFromwxid()
  11632. return nil
  11633. case msg.FieldToid:
  11634. m.ClearToid()
  11635. return nil
  11636. case msg.FieldMsgtype:
  11637. m.ClearMsgtype()
  11638. return nil
  11639. case msg.FieldMsg:
  11640. m.ClearMsg()
  11641. return nil
  11642. case msg.FieldBatchNo:
  11643. m.ClearBatchNo()
  11644. return nil
  11645. }
  11646. return fmt.Errorf("unknown Msg nullable field %s", name)
  11647. }
  11648. // ResetField resets all changes in the mutation for the field with the given name.
  11649. // It returns an error if the field is not defined in the schema.
  11650. func (m *MsgMutation) ResetField(name string) error {
  11651. switch name {
  11652. case msg.FieldCreatedAt:
  11653. m.ResetCreatedAt()
  11654. return nil
  11655. case msg.FieldUpdatedAt:
  11656. m.ResetUpdatedAt()
  11657. return nil
  11658. case msg.FieldDeletedAt:
  11659. m.ResetDeletedAt()
  11660. return nil
  11661. case msg.FieldStatus:
  11662. m.ResetStatus()
  11663. return nil
  11664. case msg.FieldFromwxid:
  11665. m.ResetFromwxid()
  11666. return nil
  11667. case msg.FieldToid:
  11668. m.ResetToid()
  11669. return nil
  11670. case msg.FieldMsgtype:
  11671. m.ResetMsgtype()
  11672. return nil
  11673. case msg.FieldMsg:
  11674. m.ResetMsg()
  11675. return nil
  11676. case msg.FieldBatchNo:
  11677. m.ResetBatchNo()
  11678. return nil
  11679. }
  11680. return fmt.Errorf("unknown Msg field %s", name)
  11681. }
  11682. // AddedEdges returns all edge names that were set/added in this mutation.
  11683. func (m *MsgMutation) AddedEdges() []string {
  11684. edges := make([]string, 0, 0)
  11685. return edges
  11686. }
  11687. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11688. // name in this mutation.
  11689. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  11690. return nil
  11691. }
  11692. // RemovedEdges returns all edge names that were removed in this mutation.
  11693. func (m *MsgMutation) RemovedEdges() []string {
  11694. edges := make([]string, 0, 0)
  11695. return edges
  11696. }
  11697. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11698. // the given name in this mutation.
  11699. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  11700. return nil
  11701. }
  11702. // ClearedEdges returns all edge names that were cleared in this mutation.
  11703. func (m *MsgMutation) ClearedEdges() []string {
  11704. edges := make([]string, 0, 0)
  11705. return edges
  11706. }
  11707. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11708. // was cleared in this mutation.
  11709. func (m *MsgMutation) EdgeCleared(name string) bool {
  11710. return false
  11711. }
  11712. // ClearEdge clears the value of the edge with the given name. It returns an error
  11713. // if that edge is not defined in the schema.
  11714. func (m *MsgMutation) ClearEdge(name string) error {
  11715. return fmt.Errorf("unknown Msg unique edge %s", name)
  11716. }
  11717. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11718. // It returns an error if the edge is not defined in the schema.
  11719. func (m *MsgMutation) ResetEdge(name string) error {
  11720. return fmt.Errorf("unknown Msg edge %s", name)
  11721. }
  11722. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  11723. type ServerMutation struct {
  11724. config
  11725. op Op
  11726. typ string
  11727. id *uint64
  11728. created_at *time.Time
  11729. updated_at *time.Time
  11730. status *uint8
  11731. addstatus *int8
  11732. deleted_at *time.Time
  11733. name *string
  11734. public_ip *string
  11735. private_ip *string
  11736. admin_port *string
  11737. clearedFields map[string]struct{}
  11738. wxs map[uint64]struct{}
  11739. removedwxs map[uint64]struct{}
  11740. clearedwxs bool
  11741. done bool
  11742. oldValue func(context.Context) (*Server, error)
  11743. predicates []predicate.Server
  11744. }
  11745. var _ ent.Mutation = (*ServerMutation)(nil)
  11746. // serverOption allows management of the mutation configuration using functional options.
  11747. type serverOption func(*ServerMutation)
  11748. // newServerMutation creates new mutation for the Server entity.
  11749. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  11750. m := &ServerMutation{
  11751. config: c,
  11752. op: op,
  11753. typ: TypeServer,
  11754. clearedFields: make(map[string]struct{}),
  11755. }
  11756. for _, opt := range opts {
  11757. opt(m)
  11758. }
  11759. return m
  11760. }
  11761. // withServerID sets the ID field of the mutation.
  11762. func withServerID(id uint64) serverOption {
  11763. return func(m *ServerMutation) {
  11764. var (
  11765. err error
  11766. once sync.Once
  11767. value *Server
  11768. )
  11769. m.oldValue = func(ctx context.Context) (*Server, error) {
  11770. once.Do(func() {
  11771. if m.done {
  11772. err = errors.New("querying old values post mutation is not allowed")
  11773. } else {
  11774. value, err = m.Client().Server.Get(ctx, id)
  11775. }
  11776. })
  11777. return value, err
  11778. }
  11779. m.id = &id
  11780. }
  11781. }
  11782. // withServer sets the old Server of the mutation.
  11783. func withServer(node *Server) serverOption {
  11784. return func(m *ServerMutation) {
  11785. m.oldValue = func(context.Context) (*Server, error) {
  11786. return node, nil
  11787. }
  11788. m.id = &node.ID
  11789. }
  11790. }
  11791. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11792. // executed in a transaction (ent.Tx), a transactional client is returned.
  11793. func (m ServerMutation) Client() *Client {
  11794. client := &Client{config: m.config}
  11795. client.init()
  11796. return client
  11797. }
  11798. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11799. // it returns an error otherwise.
  11800. func (m ServerMutation) Tx() (*Tx, error) {
  11801. if _, ok := m.driver.(*txDriver); !ok {
  11802. return nil, errors.New("ent: mutation is not running in a transaction")
  11803. }
  11804. tx := &Tx{config: m.config}
  11805. tx.init()
  11806. return tx, nil
  11807. }
  11808. // SetID sets the value of the id field. Note that this
  11809. // operation is only accepted on creation of Server entities.
  11810. func (m *ServerMutation) SetID(id uint64) {
  11811. m.id = &id
  11812. }
  11813. // ID returns the ID value in the mutation. Note that the ID is only available
  11814. // if it was provided to the builder or after it was returned from the database.
  11815. func (m *ServerMutation) ID() (id uint64, exists bool) {
  11816. if m.id == nil {
  11817. return
  11818. }
  11819. return *m.id, true
  11820. }
  11821. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11822. // That means, if the mutation is applied within a transaction with an isolation level such
  11823. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11824. // or updated by the mutation.
  11825. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  11826. switch {
  11827. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11828. id, exists := m.ID()
  11829. if exists {
  11830. return []uint64{id}, nil
  11831. }
  11832. fallthrough
  11833. case m.op.Is(OpUpdate | OpDelete):
  11834. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  11835. default:
  11836. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11837. }
  11838. }
  11839. // SetCreatedAt sets the "created_at" field.
  11840. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  11841. m.created_at = &t
  11842. }
  11843. // CreatedAt returns the value of the "created_at" field in the mutation.
  11844. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  11845. v := m.created_at
  11846. if v == nil {
  11847. return
  11848. }
  11849. return *v, true
  11850. }
  11851. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  11852. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11853. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11854. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11855. if !m.op.Is(OpUpdateOne) {
  11856. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11857. }
  11858. if m.id == nil || m.oldValue == nil {
  11859. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11860. }
  11861. oldValue, err := m.oldValue(ctx)
  11862. if err != nil {
  11863. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11864. }
  11865. return oldValue.CreatedAt, nil
  11866. }
  11867. // ResetCreatedAt resets all changes to the "created_at" field.
  11868. func (m *ServerMutation) ResetCreatedAt() {
  11869. m.created_at = nil
  11870. }
  11871. // SetUpdatedAt sets the "updated_at" field.
  11872. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  11873. m.updated_at = &t
  11874. }
  11875. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11876. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  11877. v := m.updated_at
  11878. if v == nil {
  11879. return
  11880. }
  11881. return *v, true
  11882. }
  11883. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  11884. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11885. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11886. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11887. if !m.op.Is(OpUpdateOne) {
  11888. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11889. }
  11890. if m.id == nil || m.oldValue == nil {
  11891. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11892. }
  11893. oldValue, err := m.oldValue(ctx)
  11894. if err != nil {
  11895. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11896. }
  11897. return oldValue.UpdatedAt, nil
  11898. }
  11899. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11900. func (m *ServerMutation) ResetUpdatedAt() {
  11901. m.updated_at = nil
  11902. }
  11903. // SetStatus sets the "status" field.
  11904. func (m *ServerMutation) SetStatus(u uint8) {
  11905. m.status = &u
  11906. m.addstatus = nil
  11907. }
  11908. // Status returns the value of the "status" field in the mutation.
  11909. func (m *ServerMutation) Status() (r uint8, exists bool) {
  11910. v := m.status
  11911. if v == nil {
  11912. return
  11913. }
  11914. return *v, true
  11915. }
  11916. // OldStatus returns the old "status" field's value of the Server entity.
  11917. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11919. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11920. if !m.op.Is(OpUpdateOne) {
  11921. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11922. }
  11923. if m.id == nil || m.oldValue == nil {
  11924. return v, errors.New("OldStatus requires an ID field in the mutation")
  11925. }
  11926. oldValue, err := m.oldValue(ctx)
  11927. if err != nil {
  11928. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11929. }
  11930. return oldValue.Status, nil
  11931. }
  11932. // AddStatus adds u to the "status" field.
  11933. func (m *ServerMutation) AddStatus(u int8) {
  11934. if m.addstatus != nil {
  11935. *m.addstatus += u
  11936. } else {
  11937. m.addstatus = &u
  11938. }
  11939. }
  11940. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11941. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  11942. v := m.addstatus
  11943. if v == nil {
  11944. return
  11945. }
  11946. return *v, true
  11947. }
  11948. // ClearStatus clears the value of the "status" field.
  11949. func (m *ServerMutation) ClearStatus() {
  11950. m.status = nil
  11951. m.addstatus = nil
  11952. m.clearedFields[server.FieldStatus] = struct{}{}
  11953. }
  11954. // StatusCleared returns if the "status" field was cleared in this mutation.
  11955. func (m *ServerMutation) StatusCleared() bool {
  11956. _, ok := m.clearedFields[server.FieldStatus]
  11957. return ok
  11958. }
  11959. // ResetStatus resets all changes to the "status" field.
  11960. func (m *ServerMutation) ResetStatus() {
  11961. m.status = nil
  11962. m.addstatus = nil
  11963. delete(m.clearedFields, server.FieldStatus)
  11964. }
  11965. // SetDeletedAt sets the "deleted_at" field.
  11966. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  11967. m.deleted_at = &t
  11968. }
  11969. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11970. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  11971. v := m.deleted_at
  11972. if v == nil {
  11973. return
  11974. }
  11975. return *v, true
  11976. }
  11977. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  11978. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11980. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11981. if !m.op.Is(OpUpdateOne) {
  11982. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11983. }
  11984. if m.id == nil || m.oldValue == nil {
  11985. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11986. }
  11987. oldValue, err := m.oldValue(ctx)
  11988. if err != nil {
  11989. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11990. }
  11991. return oldValue.DeletedAt, nil
  11992. }
  11993. // ClearDeletedAt clears the value of the "deleted_at" field.
  11994. func (m *ServerMutation) ClearDeletedAt() {
  11995. m.deleted_at = nil
  11996. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  11997. }
  11998. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11999. func (m *ServerMutation) DeletedAtCleared() bool {
  12000. _, ok := m.clearedFields[server.FieldDeletedAt]
  12001. return ok
  12002. }
  12003. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12004. func (m *ServerMutation) ResetDeletedAt() {
  12005. m.deleted_at = nil
  12006. delete(m.clearedFields, server.FieldDeletedAt)
  12007. }
  12008. // SetName sets the "name" field.
  12009. func (m *ServerMutation) SetName(s string) {
  12010. m.name = &s
  12011. }
  12012. // Name returns the value of the "name" field in the mutation.
  12013. func (m *ServerMutation) Name() (r string, exists bool) {
  12014. v := m.name
  12015. if v == nil {
  12016. return
  12017. }
  12018. return *v, true
  12019. }
  12020. // OldName returns the old "name" field's value of the Server entity.
  12021. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  12022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12023. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  12024. if !m.op.Is(OpUpdateOne) {
  12025. return v, errors.New("OldName is only allowed on UpdateOne operations")
  12026. }
  12027. if m.id == nil || m.oldValue == nil {
  12028. return v, errors.New("OldName requires an ID field in the mutation")
  12029. }
  12030. oldValue, err := m.oldValue(ctx)
  12031. if err != nil {
  12032. return v, fmt.Errorf("querying old value for OldName: %w", err)
  12033. }
  12034. return oldValue.Name, nil
  12035. }
  12036. // ResetName resets all changes to the "name" field.
  12037. func (m *ServerMutation) ResetName() {
  12038. m.name = nil
  12039. }
  12040. // SetPublicIP sets the "public_ip" field.
  12041. func (m *ServerMutation) SetPublicIP(s string) {
  12042. m.public_ip = &s
  12043. }
  12044. // PublicIP returns the value of the "public_ip" field in the mutation.
  12045. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  12046. v := m.public_ip
  12047. if v == nil {
  12048. return
  12049. }
  12050. return *v, true
  12051. }
  12052. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  12053. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  12054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12055. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  12056. if !m.op.Is(OpUpdateOne) {
  12057. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  12058. }
  12059. if m.id == nil || m.oldValue == nil {
  12060. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  12061. }
  12062. oldValue, err := m.oldValue(ctx)
  12063. if err != nil {
  12064. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  12065. }
  12066. return oldValue.PublicIP, nil
  12067. }
  12068. // ResetPublicIP resets all changes to the "public_ip" field.
  12069. func (m *ServerMutation) ResetPublicIP() {
  12070. m.public_ip = nil
  12071. }
  12072. // SetPrivateIP sets the "private_ip" field.
  12073. func (m *ServerMutation) SetPrivateIP(s string) {
  12074. m.private_ip = &s
  12075. }
  12076. // PrivateIP returns the value of the "private_ip" field in the mutation.
  12077. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  12078. v := m.private_ip
  12079. if v == nil {
  12080. return
  12081. }
  12082. return *v, true
  12083. }
  12084. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  12085. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  12086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12087. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  12088. if !m.op.Is(OpUpdateOne) {
  12089. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  12090. }
  12091. if m.id == nil || m.oldValue == nil {
  12092. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  12093. }
  12094. oldValue, err := m.oldValue(ctx)
  12095. if err != nil {
  12096. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  12097. }
  12098. return oldValue.PrivateIP, nil
  12099. }
  12100. // ResetPrivateIP resets all changes to the "private_ip" field.
  12101. func (m *ServerMutation) ResetPrivateIP() {
  12102. m.private_ip = nil
  12103. }
  12104. // SetAdminPort sets the "admin_port" field.
  12105. func (m *ServerMutation) SetAdminPort(s string) {
  12106. m.admin_port = &s
  12107. }
  12108. // AdminPort returns the value of the "admin_port" field in the mutation.
  12109. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  12110. v := m.admin_port
  12111. if v == nil {
  12112. return
  12113. }
  12114. return *v, true
  12115. }
  12116. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  12117. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  12118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12119. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  12120. if !m.op.Is(OpUpdateOne) {
  12121. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  12122. }
  12123. if m.id == nil || m.oldValue == nil {
  12124. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  12125. }
  12126. oldValue, err := m.oldValue(ctx)
  12127. if err != nil {
  12128. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  12129. }
  12130. return oldValue.AdminPort, nil
  12131. }
  12132. // ResetAdminPort resets all changes to the "admin_port" field.
  12133. func (m *ServerMutation) ResetAdminPort() {
  12134. m.admin_port = nil
  12135. }
  12136. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  12137. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  12138. if m.wxs == nil {
  12139. m.wxs = make(map[uint64]struct{})
  12140. }
  12141. for i := range ids {
  12142. m.wxs[ids[i]] = struct{}{}
  12143. }
  12144. }
  12145. // ClearWxs clears the "wxs" edge to the Wx entity.
  12146. func (m *ServerMutation) ClearWxs() {
  12147. m.clearedwxs = true
  12148. }
  12149. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  12150. func (m *ServerMutation) WxsCleared() bool {
  12151. return m.clearedwxs
  12152. }
  12153. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  12154. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  12155. if m.removedwxs == nil {
  12156. m.removedwxs = make(map[uint64]struct{})
  12157. }
  12158. for i := range ids {
  12159. delete(m.wxs, ids[i])
  12160. m.removedwxs[ids[i]] = struct{}{}
  12161. }
  12162. }
  12163. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  12164. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  12165. for id := range m.removedwxs {
  12166. ids = append(ids, id)
  12167. }
  12168. return
  12169. }
  12170. // WxsIDs returns the "wxs" edge IDs in the mutation.
  12171. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  12172. for id := range m.wxs {
  12173. ids = append(ids, id)
  12174. }
  12175. return
  12176. }
  12177. // ResetWxs resets all changes to the "wxs" edge.
  12178. func (m *ServerMutation) ResetWxs() {
  12179. m.wxs = nil
  12180. m.clearedwxs = false
  12181. m.removedwxs = nil
  12182. }
  12183. // Where appends a list predicates to the ServerMutation builder.
  12184. func (m *ServerMutation) Where(ps ...predicate.Server) {
  12185. m.predicates = append(m.predicates, ps...)
  12186. }
  12187. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  12188. // users can use type-assertion to append predicates that do not depend on any generated package.
  12189. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  12190. p := make([]predicate.Server, len(ps))
  12191. for i := range ps {
  12192. p[i] = ps[i]
  12193. }
  12194. m.Where(p...)
  12195. }
  12196. // Op returns the operation name.
  12197. func (m *ServerMutation) Op() Op {
  12198. return m.op
  12199. }
  12200. // SetOp allows setting the mutation operation.
  12201. func (m *ServerMutation) SetOp(op Op) {
  12202. m.op = op
  12203. }
  12204. // Type returns the node type of this mutation (Server).
  12205. func (m *ServerMutation) Type() string {
  12206. return m.typ
  12207. }
  12208. // Fields returns all fields that were changed during this mutation. Note that in
  12209. // order to get all numeric fields that were incremented/decremented, call
  12210. // AddedFields().
  12211. func (m *ServerMutation) Fields() []string {
  12212. fields := make([]string, 0, 8)
  12213. if m.created_at != nil {
  12214. fields = append(fields, server.FieldCreatedAt)
  12215. }
  12216. if m.updated_at != nil {
  12217. fields = append(fields, server.FieldUpdatedAt)
  12218. }
  12219. if m.status != nil {
  12220. fields = append(fields, server.FieldStatus)
  12221. }
  12222. if m.deleted_at != nil {
  12223. fields = append(fields, server.FieldDeletedAt)
  12224. }
  12225. if m.name != nil {
  12226. fields = append(fields, server.FieldName)
  12227. }
  12228. if m.public_ip != nil {
  12229. fields = append(fields, server.FieldPublicIP)
  12230. }
  12231. if m.private_ip != nil {
  12232. fields = append(fields, server.FieldPrivateIP)
  12233. }
  12234. if m.admin_port != nil {
  12235. fields = append(fields, server.FieldAdminPort)
  12236. }
  12237. return fields
  12238. }
  12239. // Field returns the value of a field with the given name. The second boolean
  12240. // return value indicates that this field was not set, or was not defined in the
  12241. // schema.
  12242. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  12243. switch name {
  12244. case server.FieldCreatedAt:
  12245. return m.CreatedAt()
  12246. case server.FieldUpdatedAt:
  12247. return m.UpdatedAt()
  12248. case server.FieldStatus:
  12249. return m.Status()
  12250. case server.FieldDeletedAt:
  12251. return m.DeletedAt()
  12252. case server.FieldName:
  12253. return m.Name()
  12254. case server.FieldPublicIP:
  12255. return m.PublicIP()
  12256. case server.FieldPrivateIP:
  12257. return m.PrivateIP()
  12258. case server.FieldAdminPort:
  12259. return m.AdminPort()
  12260. }
  12261. return nil, false
  12262. }
  12263. // OldField returns the old value of the field from the database. An error is
  12264. // returned if the mutation operation is not UpdateOne, or the query to the
  12265. // database failed.
  12266. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12267. switch name {
  12268. case server.FieldCreatedAt:
  12269. return m.OldCreatedAt(ctx)
  12270. case server.FieldUpdatedAt:
  12271. return m.OldUpdatedAt(ctx)
  12272. case server.FieldStatus:
  12273. return m.OldStatus(ctx)
  12274. case server.FieldDeletedAt:
  12275. return m.OldDeletedAt(ctx)
  12276. case server.FieldName:
  12277. return m.OldName(ctx)
  12278. case server.FieldPublicIP:
  12279. return m.OldPublicIP(ctx)
  12280. case server.FieldPrivateIP:
  12281. return m.OldPrivateIP(ctx)
  12282. case server.FieldAdminPort:
  12283. return m.OldAdminPort(ctx)
  12284. }
  12285. return nil, fmt.Errorf("unknown Server field %s", name)
  12286. }
  12287. // SetField sets the value of a field with the given name. It returns an error if
  12288. // the field is not defined in the schema, or if the type mismatched the field
  12289. // type.
  12290. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  12291. switch name {
  12292. case server.FieldCreatedAt:
  12293. v, ok := value.(time.Time)
  12294. if !ok {
  12295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12296. }
  12297. m.SetCreatedAt(v)
  12298. return nil
  12299. case server.FieldUpdatedAt:
  12300. v, ok := value.(time.Time)
  12301. if !ok {
  12302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12303. }
  12304. m.SetUpdatedAt(v)
  12305. return nil
  12306. case server.FieldStatus:
  12307. v, ok := value.(uint8)
  12308. if !ok {
  12309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12310. }
  12311. m.SetStatus(v)
  12312. return nil
  12313. case server.FieldDeletedAt:
  12314. v, ok := value.(time.Time)
  12315. if !ok {
  12316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12317. }
  12318. m.SetDeletedAt(v)
  12319. return nil
  12320. case server.FieldName:
  12321. v, ok := value.(string)
  12322. if !ok {
  12323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12324. }
  12325. m.SetName(v)
  12326. return nil
  12327. case server.FieldPublicIP:
  12328. v, ok := value.(string)
  12329. if !ok {
  12330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12331. }
  12332. m.SetPublicIP(v)
  12333. return nil
  12334. case server.FieldPrivateIP:
  12335. v, ok := value.(string)
  12336. if !ok {
  12337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12338. }
  12339. m.SetPrivateIP(v)
  12340. return nil
  12341. case server.FieldAdminPort:
  12342. v, ok := value.(string)
  12343. if !ok {
  12344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12345. }
  12346. m.SetAdminPort(v)
  12347. return nil
  12348. }
  12349. return fmt.Errorf("unknown Server field %s", name)
  12350. }
  12351. // AddedFields returns all numeric fields that were incremented/decremented during
  12352. // this mutation.
  12353. func (m *ServerMutation) AddedFields() []string {
  12354. var fields []string
  12355. if m.addstatus != nil {
  12356. fields = append(fields, server.FieldStatus)
  12357. }
  12358. return fields
  12359. }
  12360. // AddedField returns the numeric value that was incremented/decremented on a field
  12361. // with the given name. The second boolean return value indicates that this field
  12362. // was not set, or was not defined in the schema.
  12363. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  12364. switch name {
  12365. case server.FieldStatus:
  12366. return m.AddedStatus()
  12367. }
  12368. return nil, false
  12369. }
  12370. // AddField adds the value to the field with the given name. It returns an error if
  12371. // the field is not defined in the schema, or if the type mismatched the field
  12372. // type.
  12373. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  12374. switch name {
  12375. case server.FieldStatus:
  12376. v, ok := value.(int8)
  12377. if !ok {
  12378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12379. }
  12380. m.AddStatus(v)
  12381. return nil
  12382. }
  12383. return fmt.Errorf("unknown Server numeric field %s", name)
  12384. }
  12385. // ClearedFields returns all nullable fields that were cleared during this
  12386. // mutation.
  12387. func (m *ServerMutation) ClearedFields() []string {
  12388. var fields []string
  12389. if m.FieldCleared(server.FieldStatus) {
  12390. fields = append(fields, server.FieldStatus)
  12391. }
  12392. if m.FieldCleared(server.FieldDeletedAt) {
  12393. fields = append(fields, server.FieldDeletedAt)
  12394. }
  12395. return fields
  12396. }
  12397. // FieldCleared returns a boolean indicating if a field with the given name was
  12398. // cleared in this mutation.
  12399. func (m *ServerMutation) FieldCleared(name string) bool {
  12400. _, ok := m.clearedFields[name]
  12401. return ok
  12402. }
  12403. // ClearField clears the value of the field with the given name. It returns an
  12404. // error if the field is not defined in the schema.
  12405. func (m *ServerMutation) ClearField(name string) error {
  12406. switch name {
  12407. case server.FieldStatus:
  12408. m.ClearStatus()
  12409. return nil
  12410. case server.FieldDeletedAt:
  12411. m.ClearDeletedAt()
  12412. return nil
  12413. }
  12414. return fmt.Errorf("unknown Server nullable field %s", name)
  12415. }
  12416. // ResetField resets all changes in the mutation for the field with the given name.
  12417. // It returns an error if the field is not defined in the schema.
  12418. func (m *ServerMutation) ResetField(name string) error {
  12419. switch name {
  12420. case server.FieldCreatedAt:
  12421. m.ResetCreatedAt()
  12422. return nil
  12423. case server.FieldUpdatedAt:
  12424. m.ResetUpdatedAt()
  12425. return nil
  12426. case server.FieldStatus:
  12427. m.ResetStatus()
  12428. return nil
  12429. case server.FieldDeletedAt:
  12430. m.ResetDeletedAt()
  12431. return nil
  12432. case server.FieldName:
  12433. m.ResetName()
  12434. return nil
  12435. case server.FieldPublicIP:
  12436. m.ResetPublicIP()
  12437. return nil
  12438. case server.FieldPrivateIP:
  12439. m.ResetPrivateIP()
  12440. return nil
  12441. case server.FieldAdminPort:
  12442. m.ResetAdminPort()
  12443. return nil
  12444. }
  12445. return fmt.Errorf("unknown Server field %s", name)
  12446. }
  12447. // AddedEdges returns all edge names that were set/added in this mutation.
  12448. func (m *ServerMutation) AddedEdges() []string {
  12449. edges := make([]string, 0, 1)
  12450. if m.wxs != nil {
  12451. edges = append(edges, server.EdgeWxs)
  12452. }
  12453. return edges
  12454. }
  12455. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12456. // name in this mutation.
  12457. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  12458. switch name {
  12459. case server.EdgeWxs:
  12460. ids := make([]ent.Value, 0, len(m.wxs))
  12461. for id := range m.wxs {
  12462. ids = append(ids, id)
  12463. }
  12464. return ids
  12465. }
  12466. return nil
  12467. }
  12468. // RemovedEdges returns all edge names that were removed in this mutation.
  12469. func (m *ServerMutation) RemovedEdges() []string {
  12470. edges := make([]string, 0, 1)
  12471. if m.removedwxs != nil {
  12472. edges = append(edges, server.EdgeWxs)
  12473. }
  12474. return edges
  12475. }
  12476. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12477. // the given name in this mutation.
  12478. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  12479. switch name {
  12480. case server.EdgeWxs:
  12481. ids := make([]ent.Value, 0, len(m.removedwxs))
  12482. for id := range m.removedwxs {
  12483. ids = append(ids, id)
  12484. }
  12485. return ids
  12486. }
  12487. return nil
  12488. }
  12489. // ClearedEdges returns all edge names that were cleared in this mutation.
  12490. func (m *ServerMutation) ClearedEdges() []string {
  12491. edges := make([]string, 0, 1)
  12492. if m.clearedwxs {
  12493. edges = append(edges, server.EdgeWxs)
  12494. }
  12495. return edges
  12496. }
  12497. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12498. // was cleared in this mutation.
  12499. func (m *ServerMutation) EdgeCleared(name string) bool {
  12500. switch name {
  12501. case server.EdgeWxs:
  12502. return m.clearedwxs
  12503. }
  12504. return false
  12505. }
  12506. // ClearEdge clears the value of the edge with the given name. It returns an error
  12507. // if that edge is not defined in the schema.
  12508. func (m *ServerMutation) ClearEdge(name string) error {
  12509. switch name {
  12510. }
  12511. return fmt.Errorf("unknown Server unique edge %s", name)
  12512. }
  12513. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12514. // It returns an error if the edge is not defined in the schema.
  12515. func (m *ServerMutation) ResetEdge(name string) error {
  12516. switch name {
  12517. case server.EdgeWxs:
  12518. m.ResetWxs()
  12519. return nil
  12520. }
  12521. return fmt.Errorf("unknown Server edge %s", name)
  12522. }
  12523. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  12524. type SopNodeMutation struct {
  12525. config
  12526. op Op
  12527. typ string
  12528. id *uint64
  12529. created_at *time.Time
  12530. updated_at *time.Time
  12531. status *uint8
  12532. addstatus *int8
  12533. deleted_at *time.Time
  12534. parent_id *uint64
  12535. addparent_id *int64
  12536. name *string
  12537. condition_type *int
  12538. addcondition_type *int
  12539. condition_list *[]string
  12540. appendcondition_list []string
  12541. no_reply_condition *uint64
  12542. addno_reply_condition *int64
  12543. action_message *[]custom_types.Action
  12544. appendaction_message []custom_types.Action
  12545. action_label *[]uint64
  12546. appendaction_label []uint64
  12547. clearedFields map[string]struct{}
  12548. sop_stage *uint64
  12549. clearedsop_stage bool
  12550. node_messages map[uint64]struct{}
  12551. removednode_messages map[uint64]struct{}
  12552. clearednode_messages bool
  12553. done bool
  12554. oldValue func(context.Context) (*SopNode, error)
  12555. predicates []predicate.SopNode
  12556. }
  12557. var _ ent.Mutation = (*SopNodeMutation)(nil)
  12558. // sopnodeOption allows management of the mutation configuration using functional options.
  12559. type sopnodeOption func(*SopNodeMutation)
  12560. // newSopNodeMutation creates new mutation for the SopNode entity.
  12561. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  12562. m := &SopNodeMutation{
  12563. config: c,
  12564. op: op,
  12565. typ: TypeSopNode,
  12566. clearedFields: make(map[string]struct{}),
  12567. }
  12568. for _, opt := range opts {
  12569. opt(m)
  12570. }
  12571. return m
  12572. }
  12573. // withSopNodeID sets the ID field of the mutation.
  12574. func withSopNodeID(id uint64) sopnodeOption {
  12575. return func(m *SopNodeMutation) {
  12576. var (
  12577. err error
  12578. once sync.Once
  12579. value *SopNode
  12580. )
  12581. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  12582. once.Do(func() {
  12583. if m.done {
  12584. err = errors.New("querying old values post mutation is not allowed")
  12585. } else {
  12586. value, err = m.Client().SopNode.Get(ctx, id)
  12587. }
  12588. })
  12589. return value, err
  12590. }
  12591. m.id = &id
  12592. }
  12593. }
  12594. // withSopNode sets the old SopNode of the mutation.
  12595. func withSopNode(node *SopNode) sopnodeOption {
  12596. return func(m *SopNodeMutation) {
  12597. m.oldValue = func(context.Context) (*SopNode, error) {
  12598. return node, nil
  12599. }
  12600. m.id = &node.ID
  12601. }
  12602. }
  12603. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12604. // executed in a transaction (ent.Tx), a transactional client is returned.
  12605. func (m SopNodeMutation) Client() *Client {
  12606. client := &Client{config: m.config}
  12607. client.init()
  12608. return client
  12609. }
  12610. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12611. // it returns an error otherwise.
  12612. func (m SopNodeMutation) Tx() (*Tx, error) {
  12613. if _, ok := m.driver.(*txDriver); !ok {
  12614. return nil, errors.New("ent: mutation is not running in a transaction")
  12615. }
  12616. tx := &Tx{config: m.config}
  12617. tx.init()
  12618. return tx, nil
  12619. }
  12620. // SetID sets the value of the id field. Note that this
  12621. // operation is only accepted on creation of SopNode entities.
  12622. func (m *SopNodeMutation) SetID(id uint64) {
  12623. m.id = &id
  12624. }
  12625. // ID returns the ID value in the mutation. Note that the ID is only available
  12626. // if it was provided to the builder or after it was returned from the database.
  12627. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  12628. if m.id == nil {
  12629. return
  12630. }
  12631. return *m.id, true
  12632. }
  12633. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12634. // That means, if the mutation is applied within a transaction with an isolation level such
  12635. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12636. // or updated by the mutation.
  12637. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  12638. switch {
  12639. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12640. id, exists := m.ID()
  12641. if exists {
  12642. return []uint64{id}, nil
  12643. }
  12644. fallthrough
  12645. case m.op.Is(OpUpdate | OpDelete):
  12646. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  12647. default:
  12648. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12649. }
  12650. }
  12651. // SetCreatedAt sets the "created_at" field.
  12652. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  12653. m.created_at = &t
  12654. }
  12655. // CreatedAt returns the value of the "created_at" field in the mutation.
  12656. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  12657. v := m.created_at
  12658. if v == nil {
  12659. return
  12660. }
  12661. return *v, true
  12662. }
  12663. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  12664. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12666. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12667. if !m.op.Is(OpUpdateOne) {
  12668. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12669. }
  12670. if m.id == nil || m.oldValue == nil {
  12671. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12672. }
  12673. oldValue, err := m.oldValue(ctx)
  12674. if err != nil {
  12675. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12676. }
  12677. return oldValue.CreatedAt, nil
  12678. }
  12679. // ResetCreatedAt resets all changes to the "created_at" field.
  12680. func (m *SopNodeMutation) ResetCreatedAt() {
  12681. m.created_at = nil
  12682. }
  12683. // SetUpdatedAt sets the "updated_at" field.
  12684. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  12685. m.updated_at = &t
  12686. }
  12687. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12688. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  12689. v := m.updated_at
  12690. if v == nil {
  12691. return
  12692. }
  12693. return *v, true
  12694. }
  12695. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  12696. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12698. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12699. if !m.op.Is(OpUpdateOne) {
  12700. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12701. }
  12702. if m.id == nil || m.oldValue == nil {
  12703. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12704. }
  12705. oldValue, err := m.oldValue(ctx)
  12706. if err != nil {
  12707. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12708. }
  12709. return oldValue.UpdatedAt, nil
  12710. }
  12711. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12712. func (m *SopNodeMutation) ResetUpdatedAt() {
  12713. m.updated_at = nil
  12714. }
  12715. // SetStatus sets the "status" field.
  12716. func (m *SopNodeMutation) SetStatus(u uint8) {
  12717. m.status = &u
  12718. m.addstatus = nil
  12719. }
  12720. // Status returns the value of the "status" field in the mutation.
  12721. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  12722. v := m.status
  12723. if v == nil {
  12724. return
  12725. }
  12726. return *v, true
  12727. }
  12728. // OldStatus returns the old "status" field's value of the SopNode entity.
  12729. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12731. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12732. if !m.op.Is(OpUpdateOne) {
  12733. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12734. }
  12735. if m.id == nil || m.oldValue == nil {
  12736. return v, errors.New("OldStatus requires an ID field in the mutation")
  12737. }
  12738. oldValue, err := m.oldValue(ctx)
  12739. if err != nil {
  12740. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12741. }
  12742. return oldValue.Status, nil
  12743. }
  12744. // AddStatus adds u to the "status" field.
  12745. func (m *SopNodeMutation) AddStatus(u int8) {
  12746. if m.addstatus != nil {
  12747. *m.addstatus += u
  12748. } else {
  12749. m.addstatus = &u
  12750. }
  12751. }
  12752. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12753. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  12754. v := m.addstatus
  12755. if v == nil {
  12756. return
  12757. }
  12758. return *v, true
  12759. }
  12760. // ClearStatus clears the value of the "status" field.
  12761. func (m *SopNodeMutation) ClearStatus() {
  12762. m.status = nil
  12763. m.addstatus = nil
  12764. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  12765. }
  12766. // StatusCleared returns if the "status" field was cleared in this mutation.
  12767. func (m *SopNodeMutation) StatusCleared() bool {
  12768. _, ok := m.clearedFields[sopnode.FieldStatus]
  12769. return ok
  12770. }
  12771. // ResetStatus resets all changes to the "status" field.
  12772. func (m *SopNodeMutation) ResetStatus() {
  12773. m.status = nil
  12774. m.addstatus = nil
  12775. delete(m.clearedFields, sopnode.FieldStatus)
  12776. }
  12777. // SetDeletedAt sets the "deleted_at" field.
  12778. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  12779. m.deleted_at = &t
  12780. }
  12781. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12782. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  12783. v := m.deleted_at
  12784. if v == nil {
  12785. return
  12786. }
  12787. return *v, true
  12788. }
  12789. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  12790. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12791. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12792. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12793. if !m.op.Is(OpUpdateOne) {
  12794. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12795. }
  12796. if m.id == nil || m.oldValue == nil {
  12797. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12798. }
  12799. oldValue, err := m.oldValue(ctx)
  12800. if err != nil {
  12801. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12802. }
  12803. return oldValue.DeletedAt, nil
  12804. }
  12805. // ClearDeletedAt clears the value of the "deleted_at" field.
  12806. func (m *SopNodeMutation) ClearDeletedAt() {
  12807. m.deleted_at = nil
  12808. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  12809. }
  12810. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12811. func (m *SopNodeMutation) DeletedAtCleared() bool {
  12812. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  12813. return ok
  12814. }
  12815. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12816. func (m *SopNodeMutation) ResetDeletedAt() {
  12817. m.deleted_at = nil
  12818. delete(m.clearedFields, sopnode.FieldDeletedAt)
  12819. }
  12820. // SetStageID sets the "stage_id" field.
  12821. func (m *SopNodeMutation) SetStageID(u uint64) {
  12822. m.sop_stage = &u
  12823. }
  12824. // StageID returns the value of the "stage_id" field in the mutation.
  12825. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  12826. v := m.sop_stage
  12827. if v == nil {
  12828. return
  12829. }
  12830. return *v, true
  12831. }
  12832. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  12833. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12835. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  12836. if !m.op.Is(OpUpdateOne) {
  12837. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  12838. }
  12839. if m.id == nil || m.oldValue == nil {
  12840. return v, errors.New("OldStageID requires an ID field in the mutation")
  12841. }
  12842. oldValue, err := m.oldValue(ctx)
  12843. if err != nil {
  12844. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  12845. }
  12846. return oldValue.StageID, nil
  12847. }
  12848. // ResetStageID resets all changes to the "stage_id" field.
  12849. func (m *SopNodeMutation) ResetStageID() {
  12850. m.sop_stage = nil
  12851. }
  12852. // SetParentID sets the "parent_id" field.
  12853. func (m *SopNodeMutation) SetParentID(u uint64) {
  12854. m.parent_id = &u
  12855. m.addparent_id = nil
  12856. }
  12857. // ParentID returns the value of the "parent_id" field in the mutation.
  12858. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  12859. v := m.parent_id
  12860. if v == nil {
  12861. return
  12862. }
  12863. return *v, true
  12864. }
  12865. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  12866. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12868. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  12869. if !m.op.Is(OpUpdateOne) {
  12870. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  12871. }
  12872. if m.id == nil || m.oldValue == nil {
  12873. return v, errors.New("OldParentID requires an ID field in the mutation")
  12874. }
  12875. oldValue, err := m.oldValue(ctx)
  12876. if err != nil {
  12877. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  12878. }
  12879. return oldValue.ParentID, nil
  12880. }
  12881. // AddParentID adds u to the "parent_id" field.
  12882. func (m *SopNodeMutation) AddParentID(u int64) {
  12883. if m.addparent_id != nil {
  12884. *m.addparent_id += u
  12885. } else {
  12886. m.addparent_id = &u
  12887. }
  12888. }
  12889. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  12890. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  12891. v := m.addparent_id
  12892. if v == nil {
  12893. return
  12894. }
  12895. return *v, true
  12896. }
  12897. // ResetParentID resets all changes to the "parent_id" field.
  12898. func (m *SopNodeMutation) ResetParentID() {
  12899. m.parent_id = nil
  12900. m.addparent_id = nil
  12901. }
  12902. // SetName sets the "name" field.
  12903. func (m *SopNodeMutation) SetName(s string) {
  12904. m.name = &s
  12905. }
  12906. // Name returns the value of the "name" field in the mutation.
  12907. func (m *SopNodeMutation) Name() (r string, exists bool) {
  12908. v := m.name
  12909. if v == nil {
  12910. return
  12911. }
  12912. return *v, true
  12913. }
  12914. // OldName returns the old "name" field's value of the SopNode entity.
  12915. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12917. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  12918. if !m.op.Is(OpUpdateOne) {
  12919. return v, errors.New("OldName is only allowed on UpdateOne operations")
  12920. }
  12921. if m.id == nil || m.oldValue == nil {
  12922. return v, errors.New("OldName requires an ID field in the mutation")
  12923. }
  12924. oldValue, err := m.oldValue(ctx)
  12925. if err != nil {
  12926. return v, fmt.Errorf("querying old value for OldName: %w", err)
  12927. }
  12928. return oldValue.Name, nil
  12929. }
  12930. // ResetName resets all changes to the "name" field.
  12931. func (m *SopNodeMutation) ResetName() {
  12932. m.name = nil
  12933. }
  12934. // SetConditionType sets the "condition_type" field.
  12935. func (m *SopNodeMutation) SetConditionType(i int) {
  12936. m.condition_type = &i
  12937. m.addcondition_type = nil
  12938. }
  12939. // ConditionType returns the value of the "condition_type" field in the mutation.
  12940. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  12941. v := m.condition_type
  12942. if v == nil {
  12943. return
  12944. }
  12945. return *v, true
  12946. }
  12947. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  12948. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12950. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  12951. if !m.op.Is(OpUpdateOne) {
  12952. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  12953. }
  12954. if m.id == nil || m.oldValue == nil {
  12955. return v, errors.New("OldConditionType requires an ID field in the mutation")
  12956. }
  12957. oldValue, err := m.oldValue(ctx)
  12958. if err != nil {
  12959. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  12960. }
  12961. return oldValue.ConditionType, nil
  12962. }
  12963. // AddConditionType adds i to the "condition_type" field.
  12964. func (m *SopNodeMutation) AddConditionType(i int) {
  12965. if m.addcondition_type != nil {
  12966. *m.addcondition_type += i
  12967. } else {
  12968. m.addcondition_type = &i
  12969. }
  12970. }
  12971. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  12972. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  12973. v := m.addcondition_type
  12974. if v == nil {
  12975. return
  12976. }
  12977. return *v, true
  12978. }
  12979. // ResetConditionType resets all changes to the "condition_type" field.
  12980. func (m *SopNodeMutation) ResetConditionType() {
  12981. m.condition_type = nil
  12982. m.addcondition_type = nil
  12983. }
  12984. // SetConditionList sets the "condition_list" field.
  12985. func (m *SopNodeMutation) SetConditionList(s []string) {
  12986. m.condition_list = &s
  12987. m.appendcondition_list = nil
  12988. }
  12989. // ConditionList returns the value of the "condition_list" field in the mutation.
  12990. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  12991. v := m.condition_list
  12992. if v == nil {
  12993. return
  12994. }
  12995. return *v, true
  12996. }
  12997. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  12998. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13000. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  13001. if !m.op.Is(OpUpdateOne) {
  13002. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  13003. }
  13004. if m.id == nil || m.oldValue == nil {
  13005. return v, errors.New("OldConditionList requires an ID field in the mutation")
  13006. }
  13007. oldValue, err := m.oldValue(ctx)
  13008. if err != nil {
  13009. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  13010. }
  13011. return oldValue.ConditionList, nil
  13012. }
  13013. // AppendConditionList adds s to the "condition_list" field.
  13014. func (m *SopNodeMutation) AppendConditionList(s []string) {
  13015. m.appendcondition_list = append(m.appendcondition_list, s...)
  13016. }
  13017. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  13018. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  13019. if len(m.appendcondition_list) == 0 {
  13020. return nil, false
  13021. }
  13022. return m.appendcondition_list, true
  13023. }
  13024. // ClearConditionList clears the value of the "condition_list" field.
  13025. func (m *SopNodeMutation) ClearConditionList() {
  13026. m.condition_list = nil
  13027. m.appendcondition_list = nil
  13028. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  13029. }
  13030. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  13031. func (m *SopNodeMutation) ConditionListCleared() bool {
  13032. _, ok := m.clearedFields[sopnode.FieldConditionList]
  13033. return ok
  13034. }
  13035. // ResetConditionList resets all changes to the "condition_list" field.
  13036. func (m *SopNodeMutation) ResetConditionList() {
  13037. m.condition_list = nil
  13038. m.appendcondition_list = nil
  13039. delete(m.clearedFields, sopnode.FieldConditionList)
  13040. }
  13041. // SetNoReplyCondition sets the "no_reply_condition" field.
  13042. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  13043. m.no_reply_condition = &u
  13044. m.addno_reply_condition = nil
  13045. }
  13046. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  13047. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  13048. v := m.no_reply_condition
  13049. if v == nil {
  13050. return
  13051. }
  13052. return *v, true
  13053. }
  13054. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  13055. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  13056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13057. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  13058. if !m.op.Is(OpUpdateOne) {
  13059. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  13060. }
  13061. if m.id == nil || m.oldValue == nil {
  13062. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  13063. }
  13064. oldValue, err := m.oldValue(ctx)
  13065. if err != nil {
  13066. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  13067. }
  13068. return oldValue.NoReplyCondition, nil
  13069. }
  13070. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  13071. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  13072. if m.addno_reply_condition != nil {
  13073. *m.addno_reply_condition += u
  13074. } else {
  13075. m.addno_reply_condition = &u
  13076. }
  13077. }
  13078. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  13079. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  13080. v := m.addno_reply_condition
  13081. if v == nil {
  13082. return
  13083. }
  13084. return *v, true
  13085. }
  13086. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  13087. func (m *SopNodeMutation) ResetNoReplyCondition() {
  13088. m.no_reply_condition = nil
  13089. m.addno_reply_condition = nil
  13090. }
  13091. // SetActionMessage sets the "action_message" field.
  13092. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  13093. m.action_message = &ct
  13094. m.appendaction_message = nil
  13095. }
  13096. // ActionMessage returns the value of the "action_message" field in the mutation.
  13097. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  13098. v := m.action_message
  13099. if v == nil {
  13100. return
  13101. }
  13102. return *v, true
  13103. }
  13104. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  13105. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  13106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13107. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  13108. if !m.op.Is(OpUpdateOne) {
  13109. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  13110. }
  13111. if m.id == nil || m.oldValue == nil {
  13112. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  13113. }
  13114. oldValue, err := m.oldValue(ctx)
  13115. if err != nil {
  13116. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  13117. }
  13118. return oldValue.ActionMessage, nil
  13119. }
  13120. // AppendActionMessage adds ct to the "action_message" field.
  13121. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  13122. m.appendaction_message = append(m.appendaction_message, ct...)
  13123. }
  13124. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  13125. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  13126. if len(m.appendaction_message) == 0 {
  13127. return nil, false
  13128. }
  13129. return m.appendaction_message, true
  13130. }
  13131. // ClearActionMessage clears the value of the "action_message" field.
  13132. func (m *SopNodeMutation) ClearActionMessage() {
  13133. m.action_message = nil
  13134. m.appendaction_message = nil
  13135. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  13136. }
  13137. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  13138. func (m *SopNodeMutation) ActionMessageCleared() bool {
  13139. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  13140. return ok
  13141. }
  13142. // ResetActionMessage resets all changes to the "action_message" field.
  13143. func (m *SopNodeMutation) ResetActionMessage() {
  13144. m.action_message = nil
  13145. m.appendaction_message = nil
  13146. delete(m.clearedFields, sopnode.FieldActionMessage)
  13147. }
  13148. // SetActionLabel sets the "action_label" field.
  13149. func (m *SopNodeMutation) SetActionLabel(u []uint64) {
  13150. m.action_label = &u
  13151. m.appendaction_label = nil
  13152. }
  13153. // ActionLabel returns the value of the "action_label" field in the mutation.
  13154. func (m *SopNodeMutation) ActionLabel() (r []uint64, exists bool) {
  13155. v := m.action_label
  13156. if v == nil {
  13157. return
  13158. }
  13159. return *v, true
  13160. }
  13161. // OldActionLabel returns the old "action_label" field's value of the SopNode entity.
  13162. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  13163. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13164. func (m *SopNodeMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  13165. if !m.op.Is(OpUpdateOne) {
  13166. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  13167. }
  13168. if m.id == nil || m.oldValue == nil {
  13169. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  13170. }
  13171. oldValue, err := m.oldValue(ctx)
  13172. if err != nil {
  13173. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  13174. }
  13175. return oldValue.ActionLabel, nil
  13176. }
  13177. // AppendActionLabel adds u to the "action_label" field.
  13178. func (m *SopNodeMutation) AppendActionLabel(u []uint64) {
  13179. m.appendaction_label = append(m.appendaction_label, u...)
  13180. }
  13181. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  13182. func (m *SopNodeMutation) AppendedActionLabel() ([]uint64, bool) {
  13183. if len(m.appendaction_label) == 0 {
  13184. return nil, false
  13185. }
  13186. return m.appendaction_label, true
  13187. }
  13188. // ClearActionLabel clears the value of the "action_label" field.
  13189. func (m *SopNodeMutation) ClearActionLabel() {
  13190. m.action_label = nil
  13191. m.appendaction_label = nil
  13192. m.clearedFields[sopnode.FieldActionLabel] = struct{}{}
  13193. }
  13194. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  13195. func (m *SopNodeMutation) ActionLabelCleared() bool {
  13196. _, ok := m.clearedFields[sopnode.FieldActionLabel]
  13197. return ok
  13198. }
  13199. // ResetActionLabel resets all changes to the "action_label" field.
  13200. func (m *SopNodeMutation) ResetActionLabel() {
  13201. m.action_label = nil
  13202. m.appendaction_label = nil
  13203. delete(m.clearedFields, sopnode.FieldActionLabel)
  13204. }
  13205. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  13206. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  13207. m.sop_stage = &id
  13208. }
  13209. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  13210. func (m *SopNodeMutation) ClearSopStage() {
  13211. m.clearedsop_stage = true
  13212. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  13213. }
  13214. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  13215. func (m *SopNodeMutation) SopStageCleared() bool {
  13216. return m.clearedsop_stage
  13217. }
  13218. // SopStageID returns the "sop_stage" edge ID in the mutation.
  13219. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  13220. if m.sop_stage != nil {
  13221. return *m.sop_stage, true
  13222. }
  13223. return
  13224. }
  13225. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  13226. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13227. // SopStageID instead. It exists only for internal usage by the builders.
  13228. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  13229. if id := m.sop_stage; id != nil {
  13230. ids = append(ids, *id)
  13231. }
  13232. return
  13233. }
  13234. // ResetSopStage resets all changes to the "sop_stage" edge.
  13235. func (m *SopNodeMutation) ResetSopStage() {
  13236. m.sop_stage = nil
  13237. m.clearedsop_stage = false
  13238. }
  13239. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  13240. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  13241. if m.node_messages == nil {
  13242. m.node_messages = make(map[uint64]struct{})
  13243. }
  13244. for i := range ids {
  13245. m.node_messages[ids[i]] = struct{}{}
  13246. }
  13247. }
  13248. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  13249. func (m *SopNodeMutation) ClearNodeMessages() {
  13250. m.clearednode_messages = true
  13251. }
  13252. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  13253. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  13254. return m.clearednode_messages
  13255. }
  13256. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  13257. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  13258. if m.removednode_messages == nil {
  13259. m.removednode_messages = make(map[uint64]struct{})
  13260. }
  13261. for i := range ids {
  13262. delete(m.node_messages, ids[i])
  13263. m.removednode_messages[ids[i]] = struct{}{}
  13264. }
  13265. }
  13266. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  13267. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  13268. for id := range m.removednode_messages {
  13269. ids = append(ids, id)
  13270. }
  13271. return
  13272. }
  13273. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  13274. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  13275. for id := range m.node_messages {
  13276. ids = append(ids, id)
  13277. }
  13278. return
  13279. }
  13280. // ResetNodeMessages resets all changes to the "node_messages" edge.
  13281. func (m *SopNodeMutation) ResetNodeMessages() {
  13282. m.node_messages = nil
  13283. m.clearednode_messages = false
  13284. m.removednode_messages = nil
  13285. }
  13286. // Where appends a list predicates to the SopNodeMutation builder.
  13287. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  13288. m.predicates = append(m.predicates, ps...)
  13289. }
  13290. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  13291. // users can use type-assertion to append predicates that do not depend on any generated package.
  13292. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  13293. p := make([]predicate.SopNode, len(ps))
  13294. for i := range ps {
  13295. p[i] = ps[i]
  13296. }
  13297. m.Where(p...)
  13298. }
  13299. // Op returns the operation name.
  13300. func (m *SopNodeMutation) Op() Op {
  13301. return m.op
  13302. }
  13303. // SetOp allows setting the mutation operation.
  13304. func (m *SopNodeMutation) SetOp(op Op) {
  13305. m.op = op
  13306. }
  13307. // Type returns the node type of this mutation (SopNode).
  13308. func (m *SopNodeMutation) Type() string {
  13309. return m.typ
  13310. }
  13311. // Fields returns all fields that were changed during this mutation. Note that in
  13312. // order to get all numeric fields that were incremented/decremented, call
  13313. // AddedFields().
  13314. func (m *SopNodeMutation) Fields() []string {
  13315. fields := make([]string, 0, 12)
  13316. if m.created_at != nil {
  13317. fields = append(fields, sopnode.FieldCreatedAt)
  13318. }
  13319. if m.updated_at != nil {
  13320. fields = append(fields, sopnode.FieldUpdatedAt)
  13321. }
  13322. if m.status != nil {
  13323. fields = append(fields, sopnode.FieldStatus)
  13324. }
  13325. if m.deleted_at != nil {
  13326. fields = append(fields, sopnode.FieldDeletedAt)
  13327. }
  13328. if m.sop_stage != nil {
  13329. fields = append(fields, sopnode.FieldStageID)
  13330. }
  13331. if m.parent_id != nil {
  13332. fields = append(fields, sopnode.FieldParentID)
  13333. }
  13334. if m.name != nil {
  13335. fields = append(fields, sopnode.FieldName)
  13336. }
  13337. if m.condition_type != nil {
  13338. fields = append(fields, sopnode.FieldConditionType)
  13339. }
  13340. if m.condition_list != nil {
  13341. fields = append(fields, sopnode.FieldConditionList)
  13342. }
  13343. if m.no_reply_condition != nil {
  13344. fields = append(fields, sopnode.FieldNoReplyCondition)
  13345. }
  13346. if m.action_message != nil {
  13347. fields = append(fields, sopnode.FieldActionMessage)
  13348. }
  13349. if m.action_label != nil {
  13350. fields = append(fields, sopnode.FieldActionLabel)
  13351. }
  13352. return fields
  13353. }
  13354. // Field returns the value of a field with the given name. The second boolean
  13355. // return value indicates that this field was not set, or was not defined in the
  13356. // schema.
  13357. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  13358. switch name {
  13359. case sopnode.FieldCreatedAt:
  13360. return m.CreatedAt()
  13361. case sopnode.FieldUpdatedAt:
  13362. return m.UpdatedAt()
  13363. case sopnode.FieldStatus:
  13364. return m.Status()
  13365. case sopnode.FieldDeletedAt:
  13366. return m.DeletedAt()
  13367. case sopnode.FieldStageID:
  13368. return m.StageID()
  13369. case sopnode.FieldParentID:
  13370. return m.ParentID()
  13371. case sopnode.FieldName:
  13372. return m.Name()
  13373. case sopnode.FieldConditionType:
  13374. return m.ConditionType()
  13375. case sopnode.FieldConditionList:
  13376. return m.ConditionList()
  13377. case sopnode.FieldNoReplyCondition:
  13378. return m.NoReplyCondition()
  13379. case sopnode.FieldActionMessage:
  13380. return m.ActionMessage()
  13381. case sopnode.FieldActionLabel:
  13382. return m.ActionLabel()
  13383. }
  13384. return nil, false
  13385. }
  13386. // OldField returns the old value of the field from the database. An error is
  13387. // returned if the mutation operation is not UpdateOne, or the query to the
  13388. // database failed.
  13389. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13390. switch name {
  13391. case sopnode.FieldCreatedAt:
  13392. return m.OldCreatedAt(ctx)
  13393. case sopnode.FieldUpdatedAt:
  13394. return m.OldUpdatedAt(ctx)
  13395. case sopnode.FieldStatus:
  13396. return m.OldStatus(ctx)
  13397. case sopnode.FieldDeletedAt:
  13398. return m.OldDeletedAt(ctx)
  13399. case sopnode.FieldStageID:
  13400. return m.OldStageID(ctx)
  13401. case sopnode.FieldParentID:
  13402. return m.OldParentID(ctx)
  13403. case sopnode.FieldName:
  13404. return m.OldName(ctx)
  13405. case sopnode.FieldConditionType:
  13406. return m.OldConditionType(ctx)
  13407. case sopnode.FieldConditionList:
  13408. return m.OldConditionList(ctx)
  13409. case sopnode.FieldNoReplyCondition:
  13410. return m.OldNoReplyCondition(ctx)
  13411. case sopnode.FieldActionMessage:
  13412. return m.OldActionMessage(ctx)
  13413. case sopnode.FieldActionLabel:
  13414. return m.OldActionLabel(ctx)
  13415. }
  13416. return nil, fmt.Errorf("unknown SopNode field %s", name)
  13417. }
  13418. // SetField sets the value of a field with the given name. It returns an error if
  13419. // the field is not defined in the schema, or if the type mismatched the field
  13420. // type.
  13421. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  13422. switch name {
  13423. case sopnode.FieldCreatedAt:
  13424. v, ok := value.(time.Time)
  13425. if !ok {
  13426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13427. }
  13428. m.SetCreatedAt(v)
  13429. return nil
  13430. case sopnode.FieldUpdatedAt:
  13431. v, ok := value.(time.Time)
  13432. if !ok {
  13433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13434. }
  13435. m.SetUpdatedAt(v)
  13436. return nil
  13437. case sopnode.FieldStatus:
  13438. v, ok := value.(uint8)
  13439. if !ok {
  13440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13441. }
  13442. m.SetStatus(v)
  13443. return nil
  13444. case sopnode.FieldDeletedAt:
  13445. v, ok := value.(time.Time)
  13446. if !ok {
  13447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13448. }
  13449. m.SetDeletedAt(v)
  13450. return nil
  13451. case sopnode.FieldStageID:
  13452. v, ok := value.(uint64)
  13453. if !ok {
  13454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13455. }
  13456. m.SetStageID(v)
  13457. return nil
  13458. case sopnode.FieldParentID:
  13459. v, ok := value.(uint64)
  13460. if !ok {
  13461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13462. }
  13463. m.SetParentID(v)
  13464. return nil
  13465. case sopnode.FieldName:
  13466. v, ok := value.(string)
  13467. if !ok {
  13468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13469. }
  13470. m.SetName(v)
  13471. return nil
  13472. case sopnode.FieldConditionType:
  13473. v, ok := value.(int)
  13474. if !ok {
  13475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13476. }
  13477. m.SetConditionType(v)
  13478. return nil
  13479. case sopnode.FieldConditionList:
  13480. v, ok := value.([]string)
  13481. if !ok {
  13482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13483. }
  13484. m.SetConditionList(v)
  13485. return nil
  13486. case sopnode.FieldNoReplyCondition:
  13487. v, ok := value.(uint64)
  13488. if !ok {
  13489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13490. }
  13491. m.SetNoReplyCondition(v)
  13492. return nil
  13493. case sopnode.FieldActionMessage:
  13494. v, ok := value.([]custom_types.Action)
  13495. if !ok {
  13496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13497. }
  13498. m.SetActionMessage(v)
  13499. return nil
  13500. case sopnode.FieldActionLabel:
  13501. v, ok := value.([]uint64)
  13502. if !ok {
  13503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13504. }
  13505. m.SetActionLabel(v)
  13506. return nil
  13507. }
  13508. return fmt.Errorf("unknown SopNode field %s", name)
  13509. }
  13510. // AddedFields returns all numeric fields that were incremented/decremented during
  13511. // this mutation.
  13512. func (m *SopNodeMutation) AddedFields() []string {
  13513. var fields []string
  13514. if m.addstatus != nil {
  13515. fields = append(fields, sopnode.FieldStatus)
  13516. }
  13517. if m.addparent_id != nil {
  13518. fields = append(fields, sopnode.FieldParentID)
  13519. }
  13520. if m.addcondition_type != nil {
  13521. fields = append(fields, sopnode.FieldConditionType)
  13522. }
  13523. if m.addno_reply_condition != nil {
  13524. fields = append(fields, sopnode.FieldNoReplyCondition)
  13525. }
  13526. return fields
  13527. }
  13528. // AddedField returns the numeric value that was incremented/decremented on a field
  13529. // with the given name. The second boolean return value indicates that this field
  13530. // was not set, or was not defined in the schema.
  13531. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  13532. switch name {
  13533. case sopnode.FieldStatus:
  13534. return m.AddedStatus()
  13535. case sopnode.FieldParentID:
  13536. return m.AddedParentID()
  13537. case sopnode.FieldConditionType:
  13538. return m.AddedConditionType()
  13539. case sopnode.FieldNoReplyCondition:
  13540. return m.AddedNoReplyCondition()
  13541. }
  13542. return nil, false
  13543. }
  13544. // AddField adds the value to the field with the given name. It returns an error if
  13545. // the field is not defined in the schema, or if the type mismatched the field
  13546. // type.
  13547. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  13548. switch name {
  13549. case sopnode.FieldStatus:
  13550. v, ok := value.(int8)
  13551. if !ok {
  13552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13553. }
  13554. m.AddStatus(v)
  13555. return nil
  13556. case sopnode.FieldParentID:
  13557. v, ok := value.(int64)
  13558. if !ok {
  13559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13560. }
  13561. m.AddParentID(v)
  13562. return nil
  13563. case sopnode.FieldConditionType:
  13564. v, ok := value.(int)
  13565. if !ok {
  13566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13567. }
  13568. m.AddConditionType(v)
  13569. return nil
  13570. case sopnode.FieldNoReplyCondition:
  13571. v, ok := value.(int64)
  13572. if !ok {
  13573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13574. }
  13575. m.AddNoReplyCondition(v)
  13576. return nil
  13577. }
  13578. return fmt.Errorf("unknown SopNode numeric field %s", name)
  13579. }
  13580. // ClearedFields returns all nullable fields that were cleared during this
  13581. // mutation.
  13582. func (m *SopNodeMutation) ClearedFields() []string {
  13583. var fields []string
  13584. if m.FieldCleared(sopnode.FieldStatus) {
  13585. fields = append(fields, sopnode.FieldStatus)
  13586. }
  13587. if m.FieldCleared(sopnode.FieldDeletedAt) {
  13588. fields = append(fields, sopnode.FieldDeletedAt)
  13589. }
  13590. if m.FieldCleared(sopnode.FieldConditionList) {
  13591. fields = append(fields, sopnode.FieldConditionList)
  13592. }
  13593. if m.FieldCleared(sopnode.FieldActionMessage) {
  13594. fields = append(fields, sopnode.FieldActionMessage)
  13595. }
  13596. if m.FieldCleared(sopnode.FieldActionLabel) {
  13597. fields = append(fields, sopnode.FieldActionLabel)
  13598. }
  13599. return fields
  13600. }
  13601. // FieldCleared returns a boolean indicating if a field with the given name was
  13602. // cleared in this mutation.
  13603. func (m *SopNodeMutation) FieldCleared(name string) bool {
  13604. _, ok := m.clearedFields[name]
  13605. return ok
  13606. }
  13607. // ClearField clears the value of the field with the given name. It returns an
  13608. // error if the field is not defined in the schema.
  13609. func (m *SopNodeMutation) ClearField(name string) error {
  13610. switch name {
  13611. case sopnode.FieldStatus:
  13612. m.ClearStatus()
  13613. return nil
  13614. case sopnode.FieldDeletedAt:
  13615. m.ClearDeletedAt()
  13616. return nil
  13617. case sopnode.FieldConditionList:
  13618. m.ClearConditionList()
  13619. return nil
  13620. case sopnode.FieldActionMessage:
  13621. m.ClearActionMessage()
  13622. return nil
  13623. case sopnode.FieldActionLabel:
  13624. m.ClearActionLabel()
  13625. return nil
  13626. }
  13627. return fmt.Errorf("unknown SopNode nullable field %s", name)
  13628. }
  13629. // ResetField resets all changes in the mutation for the field with the given name.
  13630. // It returns an error if the field is not defined in the schema.
  13631. func (m *SopNodeMutation) ResetField(name string) error {
  13632. switch name {
  13633. case sopnode.FieldCreatedAt:
  13634. m.ResetCreatedAt()
  13635. return nil
  13636. case sopnode.FieldUpdatedAt:
  13637. m.ResetUpdatedAt()
  13638. return nil
  13639. case sopnode.FieldStatus:
  13640. m.ResetStatus()
  13641. return nil
  13642. case sopnode.FieldDeletedAt:
  13643. m.ResetDeletedAt()
  13644. return nil
  13645. case sopnode.FieldStageID:
  13646. m.ResetStageID()
  13647. return nil
  13648. case sopnode.FieldParentID:
  13649. m.ResetParentID()
  13650. return nil
  13651. case sopnode.FieldName:
  13652. m.ResetName()
  13653. return nil
  13654. case sopnode.FieldConditionType:
  13655. m.ResetConditionType()
  13656. return nil
  13657. case sopnode.FieldConditionList:
  13658. m.ResetConditionList()
  13659. return nil
  13660. case sopnode.FieldNoReplyCondition:
  13661. m.ResetNoReplyCondition()
  13662. return nil
  13663. case sopnode.FieldActionMessage:
  13664. m.ResetActionMessage()
  13665. return nil
  13666. case sopnode.FieldActionLabel:
  13667. m.ResetActionLabel()
  13668. return nil
  13669. }
  13670. return fmt.Errorf("unknown SopNode field %s", name)
  13671. }
  13672. // AddedEdges returns all edge names that were set/added in this mutation.
  13673. func (m *SopNodeMutation) AddedEdges() []string {
  13674. edges := make([]string, 0, 2)
  13675. if m.sop_stage != nil {
  13676. edges = append(edges, sopnode.EdgeSopStage)
  13677. }
  13678. if m.node_messages != nil {
  13679. edges = append(edges, sopnode.EdgeNodeMessages)
  13680. }
  13681. return edges
  13682. }
  13683. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13684. // name in this mutation.
  13685. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  13686. switch name {
  13687. case sopnode.EdgeSopStage:
  13688. if id := m.sop_stage; id != nil {
  13689. return []ent.Value{*id}
  13690. }
  13691. case sopnode.EdgeNodeMessages:
  13692. ids := make([]ent.Value, 0, len(m.node_messages))
  13693. for id := range m.node_messages {
  13694. ids = append(ids, id)
  13695. }
  13696. return ids
  13697. }
  13698. return nil
  13699. }
  13700. // RemovedEdges returns all edge names that were removed in this mutation.
  13701. func (m *SopNodeMutation) RemovedEdges() []string {
  13702. edges := make([]string, 0, 2)
  13703. if m.removednode_messages != nil {
  13704. edges = append(edges, sopnode.EdgeNodeMessages)
  13705. }
  13706. return edges
  13707. }
  13708. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13709. // the given name in this mutation.
  13710. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  13711. switch name {
  13712. case sopnode.EdgeNodeMessages:
  13713. ids := make([]ent.Value, 0, len(m.removednode_messages))
  13714. for id := range m.removednode_messages {
  13715. ids = append(ids, id)
  13716. }
  13717. return ids
  13718. }
  13719. return nil
  13720. }
  13721. // ClearedEdges returns all edge names that were cleared in this mutation.
  13722. func (m *SopNodeMutation) ClearedEdges() []string {
  13723. edges := make([]string, 0, 2)
  13724. if m.clearedsop_stage {
  13725. edges = append(edges, sopnode.EdgeSopStage)
  13726. }
  13727. if m.clearednode_messages {
  13728. edges = append(edges, sopnode.EdgeNodeMessages)
  13729. }
  13730. return edges
  13731. }
  13732. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13733. // was cleared in this mutation.
  13734. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  13735. switch name {
  13736. case sopnode.EdgeSopStage:
  13737. return m.clearedsop_stage
  13738. case sopnode.EdgeNodeMessages:
  13739. return m.clearednode_messages
  13740. }
  13741. return false
  13742. }
  13743. // ClearEdge clears the value of the edge with the given name. It returns an error
  13744. // if that edge is not defined in the schema.
  13745. func (m *SopNodeMutation) ClearEdge(name string) error {
  13746. switch name {
  13747. case sopnode.EdgeSopStage:
  13748. m.ClearSopStage()
  13749. return nil
  13750. }
  13751. return fmt.Errorf("unknown SopNode unique edge %s", name)
  13752. }
  13753. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13754. // It returns an error if the edge is not defined in the schema.
  13755. func (m *SopNodeMutation) ResetEdge(name string) error {
  13756. switch name {
  13757. case sopnode.EdgeSopStage:
  13758. m.ResetSopStage()
  13759. return nil
  13760. case sopnode.EdgeNodeMessages:
  13761. m.ResetNodeMessages()
  13762. return nil
  13763. }
  13764. return fmt.Errorf("unknown SopNode edge %s", name)
  13765. }
  13766. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  13767. type SopStageMutation struct {
  13768. config
  13769. op Op
  13770. typ string
  13771. id *uint64
  13772. created_at *time.Time
  13773. updated_at *time.Time
  13774. status *uint8
  13775. addstatus *int8
  13776. deleted_at *time.Time
  13777. name *string
  13778. condition_type *int
  13779. addcondition_type *int
  13780. condition_operator *int
  13781. addcondition_operator *int
  13782. condition_list *[]custom_types.Condition
  13783. appendcondition_list []custom_types.Condition
  13784. action_message *[]custom_types.Action
  13785. appendaction_message []custom_types.Action
  13786. action_label *[]uint64
  13787. appendaction_label []uint64
  13788. index_sort *int
  13789. addindex_sort *int
  13790. clearedFields map[string]struct{}
  13791. sop_task *uint64
  13792. clearedsop_task bool
  13793. stage_nodes map[uint64]struct{}
  13794. removedstage_nodes map[uint64]struct{}
  13795. clearedstage_nodes bool
  13796. stage_messages map[uint64]struct{}
  13797. removedstage_messages map[uint64]struct{}
  13798. clearedstage_messages bool
  13799. done bool
  13800. oldValue func(context.Context) (*SopStage, error)
  13801. predicates []predicate.SopStage
  13802. }
  13803. var _ ent.Mutation = (*SopStageMutation)(nil)
  13804. // sopstageOption allows management of the mutation configuration using functional options.
  13805. type sopstageOption func(*SopStageMutation)
  13806. // newSopStageMutation creates new mutation for the SopStage entity.
  13807. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  13808. m := &SopStageMutation{
  13809. config: c,
  13810. op: op,
  13811. typ: TypeSopStage,
  13812. clearedFields: make(map[string]struct{}),
  13813. }
  13814. for _, opt := range opts {
  13815. opt(m)
  13816. }
  13817. return m
  13818. }
  13819. // withSopStageID sets the ID field of the mutation.
  13820. func withSopStageID(id uint64) sopstageOption {
  13821. return func(m *SopStageMutation) {
  13822. var (
  13823. err error
  13824. once sync.Once
  13825. value *SopStage
  13826. )
  13827. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  13828. once.Do(func() {
  13829. if m.done {
  13830. err = errors.New("querying old values post mutation is not allowed")
  13831. } else {
  13832. value, err = m.Client().SopStage.Get(ctx, id)
  13833. }
  13834. })
  13835. return value, err
  13836. }
  13837. m.id = &id
  13838. }
  13839. }
  13840. // withSopStage sets the old SopStage of the mutation.
  13841. func withSopStage(node *SopStage) sopstageOption {
  13842. return func(m *SopStageMutation) {
  13843. m.oldValue = func(context.Context) (*SopStage, error) {
  13844. return node, nil
  13845. }
  13846. m.id = &node.ID
  13847. }
  13848. }
  13849. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13850. // executed in a transaction (ent.Tx), a transactional client is returned.
  13851. func (m SopStageMutation) Client() *Client {
  13852. client := &Client{config: m.config}
  13853. client.init()
  13854. return client
  13855. }
  13856. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13857. // it returns an error otherwise.
  13858. func (m SopStageMutation) Tx() (*Tx, error) {
  13859. if _, ok := m.driver.(*txDriver); !ok {
  13860. return nil, errors.New("ent: mutation is not running in a transaction")
  13861. }
  13862. tx := &Tx{config: m.config}
  13863. tx.init()
  13864. return tx, nil
  13865. }
  13866. // SetID sets the value of the id field. Note that this
  13867. // operation is only accepted on creation of SopStage entities.
  13868. func (m *SopStageMutation) SetID(id uint64) {
  13869. m.id = &id
  13870. }
  13871. // ID returns the ID value in the mutation. Note that the ID is only available
  13872. // if it was provided to the builder or after it was returned from the database.
  13873. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  13874. if m.id == nil {
  13875. return
  13876. }
  13877. return *m.id, true
  13878. }
  13879. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13880. // That means, if the mutation is applied within a transaction with an isolation level such
  13881. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13882. // or updated by the mutation.
  13883. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  13884. switch {
  13885. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13886. id, exists := m.ID()
  13887. if exists {
  13888. return []uint64{id}, nil
  13889. }
  13890. fallthrough
  13891. case m.op.Is(OpUpdate | OpDelete):
  13892. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  13893. default:
  13894. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13895. }
  13896. }
  13897. // SetCreatedAt sets the "created_at" field.
  13898. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  13899. m.created_at = &t
  13900. }
  13901. // CreatedAt returns the value of the "created_at" field in the mutation.
  13902. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  13903. v := m.created_at
  13904. if v == nil {
  13905. return
  13906. }
  13907. return *v, true
  13908. }
  13909. // OldCreatedAt returns the old "created_at" 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) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13913. if !m.op.Is(OpUpdateOne) {
  13914. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13915. }
  13916. if m.id == nil || m.oldValue == nil {
  13917. return v, errors.New("OldCreatedAt 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 OldCreatedAt: %w", err)
  13922. }
  13923. return oldValue.CreatedAt, nil
  13924. }
  13925. // ResetCreatedAt resets all changes to the "created_at" field.
  13926. func (m *SopStageMutation) ResetCreatedAt() {
  13927. m.created_at = nil
  13928. }
  13929. // SetUpdatedAt sets the "updated_at" field.
  13930. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  13931. m.updated_at = &t
  13932. }
  13933. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13934. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  13935. v := m.updated_at
  13936. if v == nil {
  13937. return
  13938. }
  13939. return *v, true
  13940. }
  13941. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  13942. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13944. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13945. if !m.op.Is(OpUpdateOne) {
  13946. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13947. }
  13948. if m.id == nil || m.oldValue == nil {
  13949. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13950. }
  13951. oldValue, err := m.oldValue(ctx)
  13952. if err != nil {
  13953. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13954. }
  13955. return oldValue.UpdatedAt, nil
  13956. }
  13957. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13958. func (m *SopStageMutation) ResetUpdatedAt() {
  13959. m.updated_at = nil
  13960. }
  13961. // SetStatus sets the "status" field.
  13962. func (m *SopStageMutation) SetStatus(u uint8) {
  13963. m.status = &u
  13964. m.addstatus = nil
  13965. }
  13966. // Status returns the value of the "status" field in the mutation.
  13967. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  13968. v := m.status
  13969. if v == nil {
  13970. return
  13971. }
  13972. return *v, true
  13973. }
  13974. // OldStatus returns the old "status" field's value of the SopStage entity.
  13975. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13977. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13978. if !m.op.Is(OpUpdateOne) {
  13979. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13980. }
  13981. if m.id == nil || m.oldValue == nil {
  13982. return v, errors.New("OldStatus requires an ID field in the mutation")
  13983. }
  13984. oldValue, err := m.oldValue(ctx)
  13985. if err != nil {
  13986. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13987. }
  13988. return oldValue.Status, nil
  13989. }
  13990. // AddStatus adds u to the "status" field.
  13991. func (m *SopStageMutation) AddStatus(u int8) {
  13992. if m.addstatus != nil {
  13993. *m.addstatus += u
  13994. } else {
  13995. m.addstatus = &u
  13996. }
  13997. }
  13998. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13999. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  14000. v := m.addstatus
  14001. if v == nil {
  14002. return
  14003. }
  14004. return *v, true
  14005. }
  14006. // ClearStatus clears the value of the "status" field.
  14007. func (m *SopStageMutation) ClearStatus() {
  14008. m.status = nil
  14009. m.addstatus = nil
  14010. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  14011. }
  14012. // StatusCleared returns if the "status" field was cleared in this mutation.
  14013. func (m *SopStageMutation) StatusCleared() bool {
  14014. _, ok := m.clearedFields[sopstage.FieldStatus]
  14015. return ok
  14016. }
  14017. // ResetStatus resets all changes to the "status" field.
  14018. func (m *SopStageMutation) ResetStatus() {
  14019. m.status = nil
  14020. m.addstatus = nil
  14021. delete(m.clearedFields, sopstage.FieldStatus)
  14022. }
  14023. // SetDeletedAt sets the "deleted_at" field.
  14024. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  14025. m.deleted_at = &t
  14026. }
  14027. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14028. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  14029. v := m.deleted_at
  14030. if v == nil {
  14031. return
  14032. }
  14033. return *v, true
  14034. }
  14035. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  14036. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14037. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14038. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14039. if !m.op.Is(OpUpdateOne) {
  14040. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14041. }
  14042. if m.id == nil || m.oldValue == nil {
  14043. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14044. }
  14045. oldValue, err := m.oldValue(ctx)
  14046. if err != nil {
  14047. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14048. }
  14049. return oldValue.DeletedAt, nil
  14050. }
  14051. // ClearDeletedAt clears the value of the "deleted_at" field.
  14052. func (m *SopStageMutation) ClearDeletedAt() {
  14053. m.deleted_at = nil
  14054. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  14055. }
  14056. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14057. func (m *SopStageMutation) DeletedAtCleared() bool {
  14058. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  14059. return ok
  14060. }
  14061. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14062. func (m *SopStageMutation) ResetDeletedAt() {
  14063. m.deleted_at = nil
  14064. delete(m.clearedFields, sopstage.FieldDeletedAt)
  14065. }
  14066. // SetTaskID sets the "task_id" field.
  14067. func (m *SopStageMutation) SetTaskID(u uint64) {
  14068. m.sop_task = &u
  14069. }
  14070. // TaskID returns the value of the "task_id" field in the mutation.
  14071. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  14072. v := m.sop_task
  14073. if v == nil {
  14074. return
  14075. }
  14076. return *v, true
  14077. }
  14078. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  14079. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14081. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  14082. if !m.op.Is(OpUpdateOne) {
  14083. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  14084. }
  14085. if m.id == nil || m.oldValue == nil {
  14086. return v, errors.New("OldTaskID requires an ID field in the mutation")
  14087. }
  14088. oldValue, err := m.oldValue(ctx)
  14089. if err != nil {
  14090. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  14091. }
  14092. return oldValue.TaskID, nil
  14093. }
  14094. // ResetTaskID resets all changes to the "task_id" field.
  14095. func (m *SopStageMutation) ResetTaskID() {
  14096. m.sop_task = nil
  14097. }
  14098. // SetName sets the "name" field.
  14099. func (m *SopStageMutation) SetName(s string) {
  14100. m.name = &s
  14101. }
  14102. // Name returns the value of the "name" field in the mutation.
  14103. func (m *SopStageMutation) Name() (r string, exists bool) {
  14104. v := m.name
  14105. if v == nil {
  14106. return
  14107. }
  14108. return *v, true
  14109. }
  14110. // OldName returns the old "name" field's value of the SopStage entity.
  14111. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14113. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  14114. if !m.op.Is(OpUpdateOne) {
  14115. return v, errors.New("OldName is only allowed on UpdateOne operations")
  14116. }
  14117. if m.id == nil || m.oldValue == nil {
  14118. return v, errors.New("OldName requires an ID field in the mutation")
  14119. }
  14120. oldValue, err := m.oldValue(ctx)
  14121. if err != nil {
  14122. return v, fmt.Errorf("querying old value for OldName: %w", err)
  14123. }
  14124. return oldValue.Name, nil
  14125. }
  14126. // ResetName resets all changes to the "name" field.
  14127. func (m *SopStageMutation) ResetName() {
  14128. m.name = nil
  14129. }
  14130. // SetConditionType sets the "condition_type" field.
  14131. func (m *SopStageMutation) SetConditionType(i int) {
  14132. m.condition_type = &i
  14133. m.addcondition_type = nil
  14134. }
  14135. // ConditionType returns the value of the "condition_type" field in the mutation.
  14136. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  14137. v := m.condition_type
  14138. if v == nil {
  14139. return
  14140. }
  14141. return *v, true
  14142. }
  14143. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  14144. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14146. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  14147. if !m.op.Is(OpUpdateOne) {
  14148. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  14149. }
  14150. if m.id == nil || m.oldValue == nil {
  14151. return v, errors.New("OldConditionType requires an ID field in the mutation")
  14152. }
  14153. oldValue, err := m.oldValue(ctx)
  14154. if err != nil {
  14155. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  14156. }
  14157. return oldValue.ConditionType, nil
  14158. }
  14159. // AddConditionType adds i to the "condition_type" field.
  14160. func (m *SopStageMutation) AddConditionType(i int) {
  14161. if m.addcondition_type != nil {
  14162. *m.addcondition_type += i
  14163. } else {
  14164. m.addcondition_type = &i
  14165. }
  14166. }
  14167. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  14168. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  14169. v := m.addcondition_type
  14170. if v == nil {
  14171. return
  14172. }
  14173. return *v, true
  14174. }
  14175. // ResetConditionType resets all changes to the "condition_type" field.
  14176. func (m *SopStageMutation) ResetConditionType() {
  14177. m.condition_type = nil
  14178. m.addcondition_type = nil
  14179. }
  14180. // SetConditionOperator sets the "condition_operator" field.
  14181. func (m *SopStageMutation) SetConditionOperator(i int) {
  14182. m.condition_operator = &i
  14183. m.addcondition_operator = nil
  14184. }
  14185. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  14186. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  14187. v := m.condition_operator
  14188. if v == nil {
  14189. return
  14190. }
  14191. return *v, true
  14192. }
  14193. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  14194. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14196. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  14197. if !m.op.Is(OpUpdateOne) {
  14198. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  14199. }
  14200. if m.id == nil || m.oldValue == nil {
  14201. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  14202. }
  14203. oldValue, err := m.oldValue(ctx)
  14204. if err != nil {
  14205. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  14206. }
  14207. return oldValue.ConditionOperator, nil
  14208. }
  14209. // AddConditionOperator adds i to the "condition_operator" field.
  14210. func (m *SopStageMutation) AddConditionOperator(i int) {
  14211. if m.addcondition_operator != nil {
  14212. *m.addcondition_operator += i
  14213. } else {
  14214. m.addcondition_operator = &i
  14215. }
  14216. }
  14217. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  14218. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  14219. v := m.addcondition_operator
  14220. if v == nil {
  14221. return
  14222. }
  14223. return *v, true
  14224. }
  14225. // ResetConditionOperator resets all changes to the "condition_operator" field.
  14226. func (m *SopStageMutation) ResetConditionOperator() {
  14227. m.condition_operator = nil
  14228. m.addcondition_operator = nil
  14229. }
  14230. // SetConditionList sets the "condition_list" field.
  14231. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  14232. m.condition_list = &ct
  14233. m.appendcondition_list = nil
  14234. }
  14235. // ConditionList returns the value of the "condition_list" field in the mutation.
  14236. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  14237. v := m.condition_list
  14238. if v == nil {
  14239. return
  14240. }
  14241. return *v, true
  14242. }
  14243. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  14244. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14246. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  14247. if !m.op.Is(OpUpdateOne) {
  14248. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  14249. }
  14250. if m.id == nil || m.oldValue == nil {
  14251. return v, errors.New("OldConditionList requires an ID field in the mutation")
  14252. }
  14253. oldValue, err := m.oldValue(ctx)
  14254. if err != nil {
  14255. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  14256. }
  14257. return oldValue.ConditionList, nil
  14258. }
  14259. // AppendConditionList adds ct to the "condition_list" field.
  14260. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  14261. m.appendcondition_list = append(m.appendcondition_list, ct...)
  14262. }
  14263. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  14264. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  14265. if len(m.appendcondition_list) == 0 {
  14266. return nil, false
  14267. }
  14268. return m.appendcondition_list, true
  14269. }
  14270. // ResetConditionList resets all changes to the "condition_list" field.
  14271. func (m *SopStageMutation) ResetConditionList() {
  14272. m.condition_list = nil
  14273. m.appendcondition_list = nil
  14274. }
  14275. // SetActionMessage sets the "action_message" field.
  14276. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  14277. m.action_message = &ct
  14278. m.appendaction_message = nil
  14279. }
  14280. // ActionMessage returns the value of the "action_message" field in the mutation.
  14281. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  14282. v := m.action_message
  14283. if v == nil {
  14284. return
  14285. }
  14286. return *v, true
  14287. }
  14288. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  14289. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14291. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  14292. if !m.op.Is(OpUpdateOne) {
  14293. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  14294. }
  14295. if m.id == nil || m.oldValue == nil {
  14296. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  14297. }
  14298. oldValue, err := m.oldValue(ctx)
  14299. if err != nil {
  14300. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  14301. }
  14302. return oldValue.ActionMessage, nil
  14303. }
  14304. // AppendActionMessage adds ct to the "action_message" field.
  14305. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  14306. m.appendaction_message = append(m.appendaction_message, ct...)
  14307. }
  14308. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  14309. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  14310. if len(m.appendaction_message) == 0 {
  14311. return nil, false
  14312. }
  14313. return m.appendaction_message, true
  14314. }
  14315. // ClearActionMessage clears the value of the "action_message" field.
  14316. func (m *SopStageMutation) ClearActionMessage() {
  14317. m.action_message = nil
  14318. m.appendaction_message = nil
  14319. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  14320. }
  14321. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  14322. func (m *SopStageMutation) ActionMessageCleared() bool {
  14323. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  14324. return ok
  14325. }
  14326. // ResetActionMessage resets all changes to the "action_message" field.
  14327. func (m *SopStageMutation) ResetActionMessage() {
  14328. m.action_message = nil
  14329. m.appendaction_message = nil
  14330. delete(m.clearedFields, sopstage.FieldActionMessage)
  14331. }
  14332. // SetActionLabel sets the "action_label" field.
  14333. func (m *SopStageMutation) SetActionLabel(u []uint64) {
  14334. m.action_label = &u
  14335. m.appendaction_label = nil
  14336. }
  14337. // ActionLabel returns the value of the "action_label" field in the mutation.
  14338. func (m *SopStageMutation) ActionLabel() (r []uint64, exists bool) {
  14339. v := m.action_label
  14340. if v == nil {
  14341. return
  14342. }
  14343. return *v, true
  14344. }
  14345. // OldActionLabel returns the old "action_label" field's value of the SopStage entity.
  14346. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14348. func (m *SopStageMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  14349. if !m.op.Is(OpUpdateOne) {
  14350. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  14351. }
  14352. if m.id == nil || m.oldValue == nil {
  14353. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  14354. }
  14355. oldValue, err := m.oldValue(ctx)
  14356. if err != nil {
  14357. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  14358. }
  14359. return oldValue.ActionLabel, nil
  14360. }
  14361. // AppendActionLabel adds u to the "action_label" field.
  14362. func (m *SopStageMutation) AppendActionLabel(u []uint64) {
  14363. m.appendaction_label = append(m.appendaction_label, u...)
  14364. }
  14365. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  14366. func (m *SopStageMutation) AppendedActionLabel() ([]uint64, bool) {
  14367. if len(m.appendaction_label) == 0 {
  14368. return nil, false
  14369. }
  14370. return m.appendaction_label, true
  14371. }
  14372. // ClearActionLabel clears the value of the "action_label" field.
  14373. func (m *SopStageMutation) ClearActionLabel() {
  14374. m.action_label = nil
  14375. m.appendaction_label = nil
  14376. m.clearedFields[sopstage.FieldActionLabel] = struct{}{}
  14377. }
  14378. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  14379. func (m *SopStageMutation) ActionLabelCleared() bool {
  14380. _, ok := m.clearedFields[sopstage.FieldActionLabel]
  14381. return ok
  14382. }
  14383. // ResetActionLabel resets all changes to the "action_label" field.
  14384. func (m *SopStageMutation) ResetActionLabel() {
  14385. m.action_label = nil
  14386. m.appendaction_label = nil
  14387. delete(m.clearedFields, sopstage.FieldActionLabel)
  14388. }
  14389. // SetIndexSort sets the "index_sort" field.
  14390. func (m *SopStageMutation) SetIndexSort(i int) {
  14391. m.index_sort = &i
  14392. m.addindex_sort = nil
  14393. }
  14394. // IndexSort returns the value of the "index_sort" field in the mutation.
  14395. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  14396. v := m.index_sort
  14397. if v == nil {
  14398. return
  14399. }
  14400. return *v, true
  14401. }
  14402. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  14403. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14405. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  14406. if !m.op.Is(OpUpdateOne) {
  14407. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  14408. }
  14409. if m.id == nil || m.oldValue == nil {
  14410. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  14411. }
  14412. oldValue, err := m.oldValue(ctx)
  14413. if err != nil {
  14414. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  14415. }
  14416. return oldValue.IndexSort, nil
  14417. }
  14418. // AddIndexSort adds i to the "index_sort" field.
  14419. func (m *SopStageMutation) AddIndexSort(i int) {
  14420. if m.addindex_sort != nil {
  14421. *m.addindex_sort += i
  14422. } else {
  14423. m.addindex_sort = &i
  14424. }
  14425. }
  14426. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  14427. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  14428. v := m.addindex_sort
  14429. if v == nil {
  14430. return
  14431. }
  14432. return *v, true
  14433. }
  14434. // ClearIndexSort clears the value of the "index_sort" field.
  14435. func (m *SopStageMutation) ClearIndexSort() {
  14436. m.index_sort = nil
  14437. m.addindex_sort = nil
  14438. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  14439. }
  14440. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  14441. func (m *SopStageMutation) IndexSortCleared() bool {
  14442. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  14443. return ok
  14444. }
  14445. // ResetIndexSort resets all changes to the "index_sort" field.
  14446. func (m *SopStageMutation) ResetIndexSort() {
  14447. m.index_sort = nil
  14448. m.addindex_sort = nil
  14449. delete(m.clearedFields, sopstage.FieldIndexSort)
  14450. }
  14451. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  14452. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  14453. m.sop_task = &id
  14454. }
  14455. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  14456. func (m *SopStageMutation) ClearSopTask() {
  14457. m.clearedsop_task = true
  14458. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  14459. }
  14460. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  14461. func (m *SopStageMutation) SopTaskCleared() bool {
  14462. return m.clearedsop_task
  14463. }
  14464. // SopTaskID returns the "sop_task" edge ID in the mutation.
  14465. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  14466. if m.sop_task != nil {
  14467. return *m.sop_task, true
  14468. }
  14469. return
  14470. }
  14471. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  14472. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14473. // SopTaskID instead. It exists only for internal usage by the builders.
  14474. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  14475. if id := m.sop_task; id != nil {
  14476. ids = append(ids, *id)
  14477. }
  14478. return
  14479. }
  14480. // ResetSopTask resets all changes to the "sop_task" edge.
  14481. func (m *SopStageMutation) ResetSopTask() {
  14482. m.sop_task = nil
  14483. m.clearedsop_task = false
  14484. }
  14485. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  14486. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  14487. if m.stage_nodes == nil {
  14488. m.stage_nodes = make(map[uint64]struct{})
  14489. }
  14490. for i := range ids {
  14491. m.stage_nodes[ids[i]] = struct{}{}
  14492. }
  14493. }
  14494. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  14495. func (m *SopStageMutation) ClearStageNodes() {
  14496. m.clearedstage_nodes = true
  14497. }
  14498. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  14499. func (m *SopStageMutation) StageNodesCleared() bool {
  14500. return m.clearedstage_nodes
  14501. }
  14502. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  14503. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  14504. if m.removedstage_nodes == nil {
  14505. m.removedstage_nodes = make(map[uint64]struct{})
  14506. }
  14507. for i := range ids {
  14508. delete(m.stage_nodes, ids[i])
  14509. m.removedstage_nodes[ids[i]] = struct{}{}
  14510. }
  14511. }
  14512. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  14513. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  14514. for id := range m.removedstage_nodes {
  14515. ids = append(ids, id)
  14516. }
  14517. return
  14518. }
  14519. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  14520. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  14521. for id := range m.stage_nodes {
  14522. ids = append(ids, id)
  14523. }
  14524. return
  14525. }
  14526. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  14527. func (m *SopStageMutation) ResetStageNodes() {
  14528. m.stage_nodes = nil
  14529. m.clearedstage_nodes = false
  14530. m.removedstage_nodes = nil
  14531. }
  14532. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  14533. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  14534. if m.stage_messages == nil {
  14535. m.stage_messages = make(map[uint64]struct{})
  14536. }
  14537. for i := range ids {
  14538. m.stage_messages[ids[i]] = struct{}{}
  14539. }
  14540. }
  14541. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  14542. func (m *SopStageMutation) ClearStageMessages() {
  14543. m.clearedstage_messages = true
  14544. }
  14545. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  14546. func (m *SopStageMutation) StageMessagesCleared() bool {
  14547. return m.clearedstage_messages
  14548. }
  14549. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  14550. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  14551. if m.removedstage_messages == nil {
  14552. m.removedstage_messages = make(map[uint64]struct{})
  14553. }
  14554. for i := range ids {
  14555. delete(m.stage_messages, ids[i])
  14556. m.removedstage_messages[ids[i]] = struct{}{}
  14557. }
  14558. }
  14559. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  14560. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  14561. for id := range m.removedstage_messages {
  14562. ids = append(ids, id)
  14563. }
  14564. return
  14565. }
  14566. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  14567. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  14568. for id := range m.stage_messages {
  14569. ids = append(ids, id)
  14570. }
  14571. return
  14572. }
  14573. // ResetStageMessages resets all changes to the "stage_messages" edge.
  14574. func (m *SopStageMutation) ResetStageMessages() {
  14575. m.stage_messages = nil
  14576. m.clearedstage_messages = false
  14577. m.removedstage_messages = nil
  14578. }
  14579. // Where appends a list predicates to the SopStageMutation builder.
  14580. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  14581. m.predicates = append(m.predicates, ps...)
  14582. }
  14583. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  14584. // users can use type-assertion to append predicates that do not depend on any generated package.
  14585. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  14586. p := make([]predicate.SopStage, len(ps))
  14587. for i := range ps {
  14588. p[i] = ps[i]
  14589. }
  14590. m.Where(p...)
  14591. }
  14592. // Op returns the operation name.
  14593. func (m *SopStageMutation) Op() Op {
  14594. return m.op
  14595. }
  14596. // SetOp allows setting the mutation operation.
  14597. func (m *SopStageMutation) SetOp(op Op) {
  14598. m.op = op
  14599. }
  14600. // Type returns the node type of this mutation (SopStage).
  14601. func (m *SopStageMutation) Type() string {
  14602. return m.typ
  14603. }
  14604. // Fields returns all fields that were changed during this mutation. Note that in
  14605. // order to get all numeric fields that were incremented/decremented, call
  14606. // AddedFields().
  14607. func (m *SopStageMutation) Fields() []string {
  14608. fields := make([]string, 0, 12)
  14609. if m.created_at != nil {
  14610. fields = append(fields, sopstage.FieldCreatedAt)
  14611. }
  14612. if m.updated_at != nil {
  14613. fields = append(fields, sopstage.FieldUpdatedAt)
  14614. }
  14615. if m.status != nil {
  14616. fields = append(fields, sopstage.FieldStatus)
  14617. }
  14618. if m.deleted_at != nil {
  14619. fields = append(fields, sopstage.FieldDeletedAt)
  14620. }
  14621. if m.sop_task != nil {
  14622. fields = append(fields, sopstage.FieldTaskID)
  14623. }
  14624. if m.name != nil {
  14625. fields = append(fields, sopstage.FieldName)
  14626. }
  14627. if m.condition_type != nil {
  14628. fields = append(fields, sopstage.FieldConditionType)
  14629. }
  14630. if m.condition_operator != nil {
  14631. fields = append(fields, sopstage.FieldConditionOperator)
  14632. }
  14633. if m.condition_list != nil {
  14634. fields = append(fields, sopstage.FieldConditionList)
  14635. }
  14636. if m.action_message != nil {
  14637. fields = append(fields, sopstage.FieldActionMessage)
  14638. }
  14639. if m.action_label != nil {
  14640. fields = append(fields, sopstage.FieldActionLabel)
  14641. }
  14642. if m.index_sort != nil {
  14643. fields = append(fields, sopstage.FieldIndexSort)
  14644. }
  14645. return fields
  14646. }
  14647. // Field returns the value of a field with the given name. The second boolean
  14648. // return value indicates that this field was not set, or was not defined in the
  14649. // schema.
  14650. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  14651. switch name {
  14652. case sopstage.FieldCreatedAt:
  14653. return m.CreatedAt()
  14654. case sopstage.FieldUpdatedAt:
  14655. return m.UpdatedAt()
  14656. case sopstage.FieldStatus:
  14657. return m.Status()
  14658. case sopstage.FieldDeletedAt:
  14659. return m.DeletedAt()
  14660. case sopstage.FieldTaskID:
  14661. return m.TaskID()
  14662. case sopstage.FieldName:
  14663. return m.Name()
  14664. case sopstage.FieldConditionType:
  14665. return m.ConditionType()
  14666. case sopstage.FieldConditionOperator:
  14667. return m.ConditionOperator()
  14668. case sopstage.FieldConditionList:
  14669. return m.ConditionList()
  14670. case sopstage.FieldActionMessage:
  14671. return m.ActionMessage()
  14672. case sopstage.FieldActionLabel:
  14673. return m.ActionLabel()
  14674. case sopstage.FieldIndexSort:
  14675. return m.IndexSort()
  14676. }
  14677. return nil, false
  14678. }
  14679. // OldField returns the old value of the field from the database. An error is
  14680. // returned if the mutation operation is not UpdateOne, or the query to the
  14681. // database failed.
  14682. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14683. switch name {
  14684. case sopstage.FieldCreatedAt:
  14685. return m.OldCreatedAt(ctx)
  14686. case sopstage.FieldUpdatedAt:
  14687. return m.OldUpdatedAt(ctx)
  14688. case sopstage.FieldStatus:
  14689. return m.OldStatus(ctx)
  14690. case sopstage.FieldDeletedAt:
  14691. return m.OldDeletedAt(ctx)
  14692. case sopstage.FieldTaskID:
  14693. return m.OldTaskID(ctx)
  14694. case sopstage.FieldName:
  14695. return m.OldName(ctx)
  14696. case sopstage.FieldConditionType:
  14697. return m.OldConditionType(ctx)
  14698. case sopstage.FieldConditionOperator:
  14699. return m.OldConditionOperator(ctx)
  14700. case sopstage.FieldConditionList:
  14701. return m.OldConditionList(ctx)
  14702. case sopstage.FieldActionMessage:
  14703. return m.OldActionMessage(ctx)
  14704. case sopstage.FieldActionLabel:
  14705. return m.OldActionLabel(ctx)
  14706. case sopstage.FieldIndexSort:
  14707. return m.OldIndexSort(ctx)
  14708. }
  14709. return nil, fmt.Errorf("unknown SopStage field %s", name)
  14710. }
  14711. // SetField sets the value of a field with the given name. It returns an error if
  14712. // the field is not defined in the schema, or if the type mismatched the field
  14713. // type.
  14714. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  14715. switch name {
  14716. case sopstage.FieldCreatedAt:
  14717. v, ok := value.(time.Time)
  14718. if !ok {
  14719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14720. }
  14721. m.SetCreatedAt(v)
  14722. return nil
  14723. case sopstage.FieldUpdatedAt:
  14724. v, ok := value.(time.Time)
  14725. if !ok {
  14726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14727. }
  14728. m.SetUpdatedAt(v)
  14729. return nil
  14730. case sopstage.FieldStatus:
  14731. v, ok := value.(uint8)
  14732. if !ok {
  14733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14734. }
  14735. m.SetStatus(v)
  14736. return nil
  14737. case sopstage.FieldDeletedAt:
  14738. v, ok := value.(time.Time)
  14739. if !ok {
  14740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14741. }
  14742. m.SetDeletedAt(v)
  14743. return nil
  14744. case sopstage.FieldTaskID:
  14745. v, ok := value.(uint64)
  14746. if !ok {
  14747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14748. }
  14749. m.SetTaskID(v)
  14750. return nil
  14751. case sopstage.FieldName:
  14752. v, ok := value.(string)
  14753. if !ok {
  14754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14755. }
  14756. m.SetName(v)
  14757. return nil
  14758. case sopstage.FieldConditionType:
  14759. v, ok := value.(int)
  14760. if !ok {
  14761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14762. }
  14763. m.SetConditionType(v)
  14764. return nil
  14765. case sopstage.FieldConditionOperator:
  14766. v, ok := value.(int)
  14767. if !ok {
  14768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14769. }
  14770. m.SetConditionOperator(v)
  14771. return nil
  14772. case sopstage.FieldConditionList:
  14773. v, ok := value.([]custom_types.Condition)
  14774. if !ok {
  14775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14776. }
  14777. m.SetConditionList(v)
  14778. return nil
  14779. case sopstage.FieldActionMessage:
  14780. v, ok := value.([]custom_types.Action)
  14781. if !ok {
  14782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14783. }
  14784. m.SetActionMessage(v)
  14785. return nil
  14786. case sopstage.FieldActionLabel:
  14787. v, ok := value.([]uint64)
  14788. if !ok {
  14789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14790. }
  14791. m.SetActionLabel(v)
  14792. return nil
  14793. case sopstage.FieldIndexSort:
  14794. v, ok := value.(int)
  14795. if !ok {
  14796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14797. }
  14798. m.SetIndexSort(v)
  14799. return nil
  14800. }
  14801. return fmt.Errorf("unknown SopStage field %s", name)
  14802. }
  14803. // AddedFields returns all numeric fields that were incremented/decremented during
  14804. // this mutation.
  14805. func (m *SopStageMutation) AddedFields() []string {
  14806. var fields []string
  14807. if m.addstatus != nil {
  14808. fields = append(fields, sopstage.FieldStatus)
  14809. }
  14810. if m.addcondition_type != nil {
  14811. fields = append(fields, sopstage.FieldConditionType)
  14812. }
  14813. if m.addcondition_operator != nil {
  14814. fields = append(fields, sopstage.FieldConditionOperator)
  14815. }
  14816. if m.addindex_sort != nil {
  14817. fields = append(fields, sopstage.FieldIndexSort)
  14818. }
  14819. return fields
  14820. }
  14821. // AddedField returns the numeric value that was incremented/decremented on a field
  14822. // with the given name. The second boolean return value indicates that this field
  14823. // was not set, or was not defined in the schema.
  14824. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  14825. switch name {
  14826. case sopstage.FieldStatus:
  14827. return m.AddedStatus()
  14828. case sopstage.FieldConditionType:
  14829. return m.AddedConditionType()
  14830. case sopstage.FieldConditionOperator:
  14831. return m.AddedConditionOperator()
  14832. case sopstage.FieldIndexSort:
  14833. return m.AddedIndexSort()
  14834. }
  14835. return nil, false
  14836. }
  14837. // AddField adds the value to the field with the given name. It returns an error if
  14838. // the field is not defined in the schema, or if the type mismatched the field
  14839. // type.
  14840. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  14841. switch name {
  14842. case sopstage.FieldStatus:
  14843. v, ok := value.(int8)
  14844. if !ok {
  14845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14846. }
  14847. m.AddStatus(v)
  14848. return nil
  14849. case sopstage.FieldConditionType:
  14850. v, ok := value.(int)
  14851. if !ok {
  14852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14853. }
  14854. m.AddConditionType(v)
  14855. return nil
  14856. case sopstage.FieldConditionOperator:
  14857. v, ok := value.(int)
  14858. if !ok {
  14859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14860. }
  14861. m.AddConditionOperator(v)
  14862. return nil
  14863. case sopstage.FieldIndexSort:
  14864. v, ok := value.(int)
  14865. if !ok {
  14866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14867. }
  14868. m.AddIndexSort(v)
  14869. return nil
  14870. }
  14871. return fmt.Errorf("unknown SopStage numeric field %s", name)
  14872. }
  14873. // ClearedFields returns all nullable fields that were cleared during this
  14874. // mutation.
  14875. func (m *SopStageMutation) ClearedFields() []string {
  14876. var fields []string
  14877. if m.FieldCleared(sopstage.FieldStatus) {
  14878. fields = append(fields, sopstage.FieldStatus)
  14879. }
  14880. if m.FieldCleared(sopstage.FieldDeletedAt) {
  14881. fields = append(fields, sopstage.FieldDeletedAt)
  14882. }
  14883. if m.FieldCleared(sopstage.FieldActionMessage) {
  14884. fields = append(fields, sopstage.FieldActionMessage)
  14885. }
  14886. if m.FieldCleared(sopstage.FieldActionLabel) {
  14887. fields = append(fields, sopstage.FieldActionLabel)
  14888. }
  14889. if m.FieldCleared(sopstage.FieldIndexSort) {
  14890. fields = append(fields, sopstage.FieldIndexSort)
  14891. }
  14892. return fields
  14893. }
  14894. // FieldCleared returns a boolean indicating if a field with the given name was
  14895. // cleared in this mutation.
  14896. func (m *SopStageMutation) FieldCleared(name string) bool {
  14897. _, ok := m.clearedFields[name]
  14898. return ok
  14899. }
  14900. // ClearField clears the value of the field with the given name. It returns an
  14901. // error if the field is not defined in the schema.
  14902. func (m *SopStageMutation) ClearField(name string) error {
  14903. switch name {
  14904. case sopstage.FieldStatus:
  14905. m.ClearStatus()
  14906. return nil
  14907. case sopstage.FieldDeletedAt:
  14908. m.ClearDeletedAt()
  14909. return nil
  14910. case sopstage.FieldActionMessage:
  14911. m.ClearActionMessage()
  14912. return nil
  14913. case sopstage.FieldActionLabel:
  14914. m.ClearActionLabel()
  14915. return nil
  14916. case sopstage.FieldIndexSort:
  14917. m.ClearIndexSort()
  14918. return nil
  14919. }
  14920. return fmt.Errorf("unknown SopStage nullable field %s", name)
  14921. }
  14922. // ResetField resets all changes in the mutation for the field with the given name.
  14923. // It returns an error if the field is not defined in the schema.
  14924. func (m *SopStageMutation) ResetField(name string) error {
  14925. switch name {
  14926. case sopstage.FieldCreatedAt:
  14927. m.ResetCreatedAt()
  14928. return nil
  14929. case sopstage.FieldUpdatedAt:
  14930. m.ResetUpdatedAt()
  14931. return nil
  14932. case sopstage.FieldStatus:
  14933. m.ResetStatus()
  14934. return nil
  14935. case sopstage.FieldDeletedAt:
  14936. m.ResetDeletedAt()
  14937. return nil
  14938. case sopstage.FieldTaskID:
  14939. m.ResetTaskID()
  14940. return nil
  14941. case sopstage.FieldName:
  14942. m.ResetName()
  14943. return nil
  14944. case sopstage.FieldConditionType:
  14945. m.ResetConditionType()
  14946. return nil
  14947. case sopstage.FieldConditionOperator:
  14948. m.ResetConditionOperator()
  14949. return nil
  14950. case sopstage.FieldConditionList:
  14951. m.ResetConditionList()
  14952. return nil
  14953. case sopstage.FieldActionMessage:
  14954. m.ResetActionMessage()
  14955. return nil
  14956. case sopstage.FieldActionLabel:
  14957. m.ResetActionLabel()
  14958. return nil
  14959. case sopstage.FieldIndexSort:
  14960. m.ResetIndexSort()
  14961. return nil
  14962. }
  14963. return fmt.Errorf("unknown SopStage field %s", name)
  14964. }
  14965. // AddedEdges returns all edge names that were set/added in this mutation.
  14966. func (m *SopStageMutation) AddedEdges() []string {
  14967. edges := make([]string, 0, 3)
  14968. if m.sop_task != nil {
  14969. edges = append(edges, sopstage.EdgeSopTask)
  14970. }
  14971. if m.stage_nodes != nil {
  14972. edges = append(edges, sopstage.EdgeStageNodes)
  14973. }
  14974. if m.stage_messages != nil {
  14975. edges = append(edges, sopstage.EdgeStageMessages)
  14976. }
  14977. return edges
  14978. }
  14979. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14980. // name in this mutation.
  14981. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  14982. switch name {
  14983. case sopstage.EdgeSopTask:
  14984. if id := m.sop_task; id != nil {
  14985. return []ent.Value{*id}
  14986. }
  14987. case sopstage.EdgeStageNodes:
  14988. ids := make([]ent.Value, 0, len(m.stage_nodes))
  14989. for id := range m.stage_nodes {
  14990. ids = append(ids, id)
  14991. }
  14992. return ids
  14993. case sopstage.EdgeStageMessages:
  14994. ids := make([]ent.Value, 0, len(m.stage_messages))
  14995. for id := range m.stage_messages {
  14996. ids = append(ids, id)
  14997. }
  14998. return ids
  14999. }
  15000. return nil
  15001. }
  15002. // RemovedEdges returns all edge names that were removed in this mutation.
  15003. func (m *SopStageMutation) RemovedEdges() []string {
  15004. edges := make([]string, 0, 3)
  15005. if m.removedstage_nodes != nil {
  15006. edges = append(edges, sopstage.EdgeStageNodes)
  15007. }
  15008. if m.removedstage_messages != nil {
  15009. edges = append(edges, sopstage.EdgeStageMessages)
  15010. }
  15011. return edges
  15012. }
  15013. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15014. // the given name in this mutation.
  15015. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  15016. switch name {
  15017. case sopstage.EdgeStageNodes:
  15018. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  15019. for id := range m.removedstage_nodes {
  15020. ids = append(ids, id)
  15021. }
  15022. return ids
  15023. case sopstage.EdgeStageMessages:
  15024. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  15025. for id := range m.removedstage_messages {
  15026. ids = append(ids, id)
  15027. }
  15028. return ids
  15029. }
  15030. return nil
  15031. }
  15032. // ClearedEdges returns all edge names that were cleared in this mutation.
  15033. func (m *SopStageMutation) ClearedEdges() []string {
  15034. edges := make([]string, 0, 3)
  15035. if m.clearedsop_task {
  15036. edges = append(edges, sopstage.EdgeSopTask)
  15037. }
  15038. if m.clearedstage_nodes {
  15039. edges = append(edges, sopstage.EdgeStageNodes)
  15040. }
  15041. if m.clearedstage_messages {
  15042. edges = append(edges, sopstage.EdgeStageMessages)
  15043. }
  15044. return edges
  15045. }
  15046. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15047. // was cleared in this mutation.
  15048. func (m *SopStageMutation) EdgeCleared(name string) bool {
  15049. switch name {
  15050. case sopstage.EdgeSopTask:
  15051. return m.clearedsop_task
  15052. case sopstage.EdgeStageNodes:
  15053. return m.clearedstage_nodes
  15054. case sopstage.EdgeStageMessages:
  15055. return m.clearedstage_messages
  15056. }
  15057. return false
  15058. }
  15059. // ClearEdge clears the value of the edge with the given name. It returns an error
  15060. // if that edge is not defined in the schema.
  15061. func (m *SopStageMutation) ClearEdge(name string) error {
  15062. switch name {
  15063. case sopstage.EdgeSopTask:
  15064. m.ClearSopTask()
  15065. return nil
  15066. }
  15067. return fmt.Errorf("unknown SopStage unique edge %s", name)
  15068. }
  15069. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15070. // It returns an error if the edge is not defined in the schema.
  15071. func (m *SopStageMutation) ResetEdge(name string) error {
  15072. switch name {
  15073. case sopstage.EdgeSopTask:
  15074. m.ResetSopTask()
  15075. return nil
  15076. case sopstage.EdgeStageNodes:
  15077. m.ResetStageNodes()
  15078. return nil
  15079. case sopstage.EdgeStageMessages:
  15080. m.ResetStageMessages()
  15081. return nil
  15082. }
  15083. return fmt.Errorf("unknown SopStage edge %s", name)
  15084. }
  15085. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  15086. type SopTaskMutation struct {
  15087. config
  15088. op Op
  15089. typ string
  15090. id *uint64
  15091. created_at *time.Time
  15092. updated_at *time.Time
  15093. status *uint8
  15094. addstatus *int8
  15095. deleted_at *time.Time
  15096. name *string
  15097. bot_wxid_list *[]string
  15098. appendbot_wxid_list []string
  15099. _type *int
  15100. add_type *int
  15101. plan_start_time *time.Time
  15102. plan_end_time *time.Time
  15103. creator_id *string
  15104. organization_id *uint64
  15105. addorganization_id *int64
  15106. clearedFields map[string]struct{}
  15107. task_stages map[uint64]struct{}
  15108. removedtask_stages map[uint64]struct{}
  15109. clearedtask_stages bool
  15110. done bool
  15111. oldValue func(context.Context) (*SopTask, error)
  15112. predicates []predicate.SopTask
  15113. }
  15114. var _ ent.Mutation = (*SopTaskMutation)(nil)
  15115. // soptaskOption allows management of the mutation configuration using functional options.
  15116. type soptaskOption func(*SopTaskMutation)
  15117. // newSopTaskMutation creates new mutation for the SopTask entity.
  15118. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  15119. m := &SopTaskMutation{
  15120. config: c,
  15121. op: op,
  15122. typ: TypeSopTask,
  15123. clearedFields: make(map[string]struct{}),
  15124. }
  15125. for _, opt := range opts {
  15126. opt(m)
  15127. }
  15128. return m
  15129. }
  15130. // withSopTaskID sets the ID field of the mutation.
  15131. func withSopTaskID(id uint64) soptaskOption {
  15132. return func(m *SopTaskMutation) {
  15133. var (
  15134. err error
  15135. once sync.Once
  15136. value *SopTask
  15137. )
  15138. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  15139. once.Do(func() {
  15140. if m.done {
  15141. err = errors.New("querying old values post mutation is not allowed")
  15142. } else {
  15143. value, err = m.Client().SopTask.Get(ctx, id)
  15144. }
  15145. })
  15146. return value, err
  15147. }
  15148. m.id = &id
  15149. }
  15150. }
  15151. // withSopTask sets the old SopTask of the mutation.
  15152. func withSopTask(node *SopTask) soptaskOption {
  15153. return func(m *SopTaskMutation) {
  15154. m.oldValue = func(context.Context) (*SopTask, error) {
  15155. return node, nil
  15156. }
  15157. m.id = &node.ID
  15158. }
  15159. }
  15160. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15161. // executed in a transaction (ent.Tx), a transactional client is returned.
  15162. func (m SopTaskMutation) Client() *Client {
  15163. client := &Client{config: m.config}
  15164. client.init()
  15165. return client
  15166. }
  15167. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15168. // it returns an error otherwise.
  15169. func (m SopTaskMutation) Tx() (*Tx, error) {
  15170. if _, ok := m.driver.(*txDriver); !ok {
  15171. return nil, errors.New("ent: mutation is not running in a transaction")
  15172. }
  15173. tx := &Tx{config: m.config}
  15174. tx.init()
  15175. return tx, nil
  15176. }
  15177. // SetID sets the value of the id field. Note that this
  15178. // operation is only accepted on creation of SopTask entities.
  15179. func (m *SopTaskMutation) SetID(id uint64) {
  15180. m.id = &id
  15181. }
  15182. // ID returns the ID value in the mutation. Note that the ID is only available
  15183. // if it was provided to the builder or after it was returned from the database.
  15184. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  15185. if m.id == nil {
  15186. return
  15187. }
  15188. return *m.id, true
  15189. }
  15190. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15191. // That means, if the mutation is applied within a transaction with an isolation level such
  15192. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15193. // or updated by the mutation.
  15194. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  15195. switch {
  15196. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15197. id, exists := m.ID()
  15198. if exists {
  15199. return []uint64{id}, nil
  15200. }
  15201. fallthrough
  15202. case m.op.Is(OpUpdate | OpDelete):
  15203. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  15204. default:
  15205. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15206. }
  15207. }
  15208. // SetCreatedAt sets the "created_at" field.
  15209. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  15210. m.created_at = &t
  15211. }
  15212. // CreatedAt returns the value of the "created_at" field in the mutation.
  15213. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  15214. v := m.created_at
  15215. if v == nil {
  15216. return
  15217. }
  15218. return *v, true
  15219. }
  15220. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  15221. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15223. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15224. if !m.op.Is(OpUpdateOne) {
  15225. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15226. }
  15227. if m.id == nil || m.oldValue == nil {
  15228. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15229. }
  15230. oldValue, err := m.oldValue(ctx)
  15231. if err != nil {
  15232. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15233. }
  15234. return oldValue.CreatedAt, nil
  15235. }
  15236. // ResetCreatedAt resets all changes to the "created_at" field.
  15237. func (m *SopTaskMutation) ResetCreatedAt() {
  15238. m.created_at = nil
  15239. }
  15240. // SetUpdatedAt sets the "updated_at" field.
  15241. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  15242. m.updated_at = &t
  15243. }
  15244. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15245. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  15246. v := m.updated_at
  15247. if v == nil {
  15248. return
  15249. }
  15250. return *v, true
  15251. }
  15252. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  15253. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15255. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15256. if !m.op.Is(OpUpdateOne) {
  15257. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15258. }
  15259. if m.id == nil || m.oldValue == nil {
  15260. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15261. }
  15262. oldValue, err := m.oldValue(ctx)
  15263. if err != nil {
  15264. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15265. }
  15266. return oldValue.UpdatedAt, nil
  15267. }
  15268. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15269. func (m *SopTaskMutation) ResetUpdatedAt() {
  15270. m.updated_at = nil
  15271. }
  15272. // SetStatus sets the "status" field.
  15273. func (m *SopTaskMutation) SetStatus(u uint8) {
  15274. m.status = &u
  15275. m.addstatus = nil
  15276. }
  15277. // Status returns the value of the "status" field in the mutation.
  15278. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  15279. v := m.status
  15280. if v == nil {
  15281. return
  15282. }
  15283. return *v, true
  15284. }
  15285. // OldStatus returns the old "status" field's value of the SopTask entity.
  15286. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15288. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15289. if !m.op.Is(OpUpdateOne) {
  15290. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15291. }
  15292. if m.id == nil || m.oldValue == nil {
  15293. return v, errors.New("OldStatus requires an ID field in the mutation")
  15294. }
  15295. oldValue, err := m.oldValue(ctx)
  15296. if err != nil {
  15297. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15298. }
  15299. return oldValue.Status, nil
  15300. }
  15301. // AddStatus adds u to the "status" field.
  15302. func (m *SopTaskMutation) AddStatus(u int8) {
  15303. if m.addstatus != nil {
  15304. *m.addstatus += u
  15305. } else {
  15306. m.addstatus = &u
  15307. }
  15308. }
  15309. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15310. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  15311. v := m.addstatus
  15312. if v == nil {
  15313. return
  15314. }
  15315. return *v, true
  15316. }
  15317. // ClearStatus clears the value of the "status" field.
  15318. func (m *SopTaskMutation) ClearStatus() {
  15319. m.status = nil
  15320. m.addstatus = nil
  15321. m.clearedFields[soptask.FieldStatus] = struct{}{}
  15322. }
  15323. // StatusCleared returns if the "status" field was cleared in this mutation.
  15324. func (m *SopTaskMutation) StatusCleared() bool {
  15325. _, ok := m.clearedFields[soptask.FieldStatus]
  15326. return ok
  15327. }
  15328. // ResetStatus resets all changes to the "status" field.
  15329. func (m *SopTaskMutation) ResetStatus() {
  15330. m.status = nil
  15331. m.addstatus = nil
  15332. delete(m.clearedFields, soptask.FieldStatus)
  15333. }
  15334. // SetDeletedAt sets the "deleted_at" field.
  15335. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  15336. m.deleted_at = &t
  15337. }
  15338. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15339. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  15340. v := m.deleted_at
  15341. if v == nil {
  15342. return
  15343. }
  15344. return *v, true
  15345. }
  15346. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  15347. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15348. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15349. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15350. if !m.op.Is(OpUpdateOne) {
  15351. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15352. }
  15353. if m.id == nil || m.oldValue == nil {
  15354. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15355. }
  15356. oldValue, err := m.oldValue(ctx)
  15357. if err != nil {
  15358. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15359. }
  15360. return oldValue.DeletedAt, nil
  15361. }
  15362. // ClearDeletedAt clears the value of the "deleted_at" field.
  15363. func (m *SopTaskMutation) ClearDeletedAt() {
  15364. m.deleted_at = nil
  15365. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  15366. }
  15367. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15368. func (m *SopTaskMutation) DeletedAtCleared() bool {
  15369. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  15370. return ok
  15371. }
  15372. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15373. func (m *SopTaskMutation) ResetDeletedAt() {
  15374. m.deleted_at = nil
  15375. delete(m.clearedFields, soptask.FieldDeletedAt)
  15376. }
  15377. // SetName sets the "name" field.
  15378. func (m *SopTaskMutation) SetName(s string) {
  15379. m.name = &s
  15380. }
  15381. // Name returns the value of the "name" field in the mutation.
  15382. func (m *SopTaskMutation) Name() (r string, exists bool) {
  15383. v := m.name
  15384. if v == nil {
  15385. return
  15386. }
  15387. return *v, true
  15388. }
  15389. // OldName returns the old "name" field's value of the SopTask entity.
  15390. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15392. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  15393. if !m.op.Is(OpUpdateOne) {
  15394. return v, errors.New("OldName is only allowed on UpdateOne operations")
  15395. }
  15396. if m.id == nil || m.oldValue == nil {
  15397. return v, errors.New("OldName requires an ID field in the mutation")
  15398. }
  15399. oldValue, err := m.oldValue(ctx)
  15400. if err != nil {
  15401. return v, fmt.Errorf("querying old value for OldName: %w", err)
  15402. }
  15403. return oldValue.Name, nil
  15404. }
  15405. // ResetName resets all changes to the "name" field.
  15406. func (m *SopTaskMutation) ResetName() {
  15407. m.name = nil
  15408. }
  15409. // SetBotWxidList sets the "bot_wxid_list" field.
  15410. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  15411. m.bot_wxid_list = &s
  15412. m.appendbot_wxid_list = nil
  15413. }
  15414. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  15415. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  15416. v := m.bot_wxid_list
  15417. if v == nil {
  15418. return
  15419. }
  15420. return *v, true
  15421. }
  15422. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  15423. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15425. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  15426. if !m.op.Is(OpUpdateOne) {
  15427. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  15428. }
  15429. if m.id == nil || m.oldValue == nil {
  15430. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  15431. }
  15432. oldValue, err := m.oldValue(ctx)
  15433. if err != nil {
  15434. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  15435. }
  15436. return oldValue.BotWxidList, nil
  15437. }
  15438. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  15439. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  15440. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  15441. }
  15442. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  15443. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  15444. if len(m.appendbot_wxid_list) == 0 {
  15445. return nil, false
  15446. }
  15447. return m.appendbot_wxid_list, true
  15448. }
  15449. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  15450. func (m *SopTaskMutation) ClearBotWxidList() {
  15451. m.bot_wxid_list = nil
  15452. m.appendbot_wxid_list = nil
  15453. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  15454. }
  15455. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  15456. func (m *SopTaskMutation) BotWxidListCleared() bool {
  15457. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  15458. return ok
  15459. }
  15460. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  15461. func (m *SopTaskMutation) ResetBotWxidList() {
  15462. m.bot_wxid_list = nil
  15463. m.appendbot_wxid_list = nil
  15464. delete(m.clearedFields, soptask.FieldBotWxidList)
  15465. }
  15466. // SetType sets the "type" field.
  15467. func (m *SopTaskMutation) SetType(i int) {
  15468. m._type = &i
  15469. m.add_type = nil
  15470. }
  15471. // GetType returns the value of the "type" field in the mutation.
  15472. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  15473. v := m._type
  15474. if v == nil {
  15475. return
  15476. }
  15477. return *v, true
  15478. }
  15479. // OldType returns the old "type" field's value of the SopTask entity.
  15480. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15482. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  15483. if !m.op.Is(OpUpdateOne) {
  15484. return v, errors.New("OldType is only allowed on UpdateOne operations")
  15485. }
  15486. if m.id == nil || m.oldValue == nil {
  15487. return v, errors.New("OldType requires an ID field in the mutation")
  15488. }
  15489. oldValue, err := m.oldValue(ctx)
  15490. if err != nil {
  15491. return v, fmt.Errorf("querying old value for OldType: %w", err)
  15492. }
  15493. return oldValue.Type, nil
  15494. }
  15495. // AddType adds i to the "type" field.
  15496. func (m *SopTaskMutation) AddType(i int) {
  15497. if m.add_type != nil {
  15498. *m.add_type += i
  15499. } else {
  15500. m.add_type = &i
  15501. }
  15502. }
  15503. // AddedType returns the value that was added to the "type" field in this mutation.
  15504. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  15505. v := m.add_type
  15506. if v == nil {
  15507. return
  15508. }
  15509. return *v, true
  15510. }
  15511. // ResetType resets all changes to the "type" field.
  15512. func (m *SopTaskMutation) ResetType() {
  15513. m._type = nil
  15514. m.add_type = nil
  15515. }
  15516. // SetPlanStartTime sets the "plan_start_time" field.
  15517. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  15518. m.plan_start_time = &t
  15519. }
  15520. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  15521. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  15522. v := m.plan_start_time
  15523. if v == nil {
  15524. return
  15525. }
  15526. return *v, true
  15527. }
  15528. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  15529. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15531. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  15532. if !m.op.Is(OpUpdateOne) {
  15533. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  15534. }
  15535. if m.id == nil || m.oldValue == nil {
  15536. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  15537. }
  15538. oldValue, err := m.oldValue(ctx)
  15539. if err != nil {
  15540. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  15541. }
  15542. return oldValue.PlanStartTime, nil
  15543. }
  15544. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  15545. func (m *SopTaskMutation) ClearPlanStartTime() {
  15546. m.plan_start_time = nil
  15547. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  15548. }
  15549. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  15550. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  15551. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  15552. return ok
  15553. }
  15554. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  15555. func (m *SopTaskMutation) ResetPlanStartTime() {
  15556. m.plan_start_time = nil
  15557. delete(m.clearedFields, soptask.FieldPlanStartTime)
  15558. }
  15559. // SetPlanEndTime sets the "plan_end_time" field.
  15560. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  15561. m.plan_end_time = &t
  15562. }
  15563. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  15564. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  15565. v := m.plan_end_time
  15566. if v == nil {
  15567. return
  15568. }
  15569. return *v, true
  15570. }
  15571. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  15572. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15574. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  15575. if !m.op.Is(OpUpdateOne) {
  15576. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  15577. }
  15578. if m.id == nil || m.oldValue == nil {
  15579. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  15580. }
  15581. oldValue, err := m.oldValue(ctx)
  15582. if err != nil {
  15583. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  15584. }
  15585. return oldValue.PlanEndTime, nil
  15586. }
  15587. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  15588. func (m *SopTaskMutation) ClearPlanEndTime() {
  15589. m.plan_end_time = nil
  15590. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  15591. }
  15592. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  15593. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  15594. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  15595. return ok
  15596. }
  15597. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  15598. func (m *SopTaskMutation) ResetPlanEndTime() {
  15599. m.plan_end_time = nil
  15600. delete(m.clearedFields, soptask.FieldPlanEndTime)
  15601. }
  15602. // SetCreatorID sets the "creator_id" field.
  15603. func (m *SopTaskMutation) SetCreatorID(s string) {
  15604. m.creator_id = &s
  15605. }
  15606. // CreatorID returns the value of the "creator_id" field in the mutation.
  15607. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  15608. v := m.creator_id
  15609. if v == nil {
  15610. return
  15611. }
  15612. return *v, true
  15613. }
  15614. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  15615. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15617. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  15618. if !m.op.Is(OpUpdateOne) {
  15619. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  15620. }
  15621. if m.id == nil || m.oldValue == nil {
  15622. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  15623. }
  15624. oldValue, err := m.oldValue(ctx)
  15625. if err != nil {
  15626. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  15627. }
  15628. return oldValue.CreatorID, nil
  15629. }
  15630. // ClearCreatorID clears the value of the "creator_id" field.
  15631. func (m *SopTaskMutation) ClearCreatorID() {
  15632. m.creator_id = nil
  15633. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  15634. }
  15635. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  15636. func (m *SopTaskMutation) CreatorIDCleared() bool {
  15637. _, ok := m.clearedFields[soptask.FieldCreatorID]
  15638. return ok
  15639. }
  15640. // ResetCreatorID resets all changes to the "creator_id" field.
  15641. func (m *SopTaskMutation) ResetCreatorID() {
  15642. m.creator_id = nil
  15643. delete(m.clearedFields, soptask.FieldCreatorID)
  15644. }
  15645. // SetOrganizationID sets the "organization_id" field.
  15646. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  15647. m.organization_id = &u
  15648. m.addorganization_id = nil
  15649. }
  15650. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15651. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  15652. v := m.organization_id
  15653. if v == nil {
  15654. return
  15655. }
  15656. return *v, true
  15657. }
  15658. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  15659. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15660. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15661. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15662. if !m.op.Is(OpUpdateOne) {
  15663. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15664. }
  15665. if m.id == nil || m.oldValue == nil {
  15666. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15667. }
  15668. oldValue, err := m.oldValue(ctx)
  15669. if err != nil {
  15670. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15671. }
  15672. return oldValue.OrganizationID, nil
  15673. }
  15674. // AddOrganizationID adds u to the "organization_id" field.
  15675. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  15676. if m.addorganization_id != nil {
  15677. *m.addorganization_id += u
  15678. } else {
  15679. m.addorganization_id = &u
  15680. }
  15681. }
  15682. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15683. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  15684. v := m.addorganization_id
  15685. if v == nil {
  15686. return
  15687. }
  15688. return *v, true
  15689. }
  15690. // ClearOrganizationID clears the value of the "organization_id" field.
  15691. func (m *SopTaskMutation) ClearOrganizationID() {
  15692. m.organization_id = nil
  15693. m.addorganization_id = nil
  15694. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  15695. }
  15696. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15697. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  15698. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  15699. return ok
  15700. }
  15701. // ResetOrganizationID resets all changes to the "organization_id" field.
  15702. func (m *SopTaskMutation) ResetOrganizationID() {
  15703. m.organization_id = nil
  15704. m.addorganization_id = nil
  15705. delete(m.clearedFields, soptask.FieldOrganizationID)
  15706. }
  15707. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  15708. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  15709. if m.task_stages == nil {
  15710. m.task_stages = make(map[uint64]struct{})
  15711. }
  15712. for i := range ids {
  15713. m.task_stages[ids[i]] = struct{}{}
  15714. }
  15715. }
  15716. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  15717. func (m *SopTaskMutation) ClearTaskStages() {
  15718. m.clearedtask_stages = true
  15719. }
  15720. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  15721. func (m *SopTaskMutation) TaskStagesCleared() bool {
  15722. return m.clearedtask_stages
  15723. }
  15724. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  15725. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  15726. if m.removedtask_stages == nil {
  15727. m.removedtask_stages = make(map[uint64]struct{})
  15728. }
  15729. for i := range ids {
  15730. delete(m.task_stages, ids[i])
  15731. m.removedtask_stages[ids[i]] = struct{}{}
  15732. }
  15733. }
  15734. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  15735. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  15736. for id := range m.removedtask_stages {
  15737. ids = append(ids, id)
  15738. }
  15739. return
  15740. }
  15741. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  15742. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  15743. for id := range m.task_stages {
  15744. ids = append(ids, id)
  15745. }
  15746. return
  15747. }
  15748. // ResetTaskStages resets all changes to the "task_stages" edge.
  15749. func (m *SopTaskMutation) ResetTaskStages() {
  15750. m.task_stages = nil
  15751. m.clearedtask_stages = false
  15752. m.removedtask_stages = nil
  15753. }
  15754. // Where appends a list predicates to the SopTaskMutation builder.
  15755. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  15756. m.predicates = append(m.predicates, ps...)
  15757. }
  15758. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  15759. // users can use type-assertion to append predicates that do not depend on any generated package.
  15760. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  15761. p := make([]predicate.SopTask, len(ps))
  15762. for i := range ps {
  15763. p[i] = ps[i]
  15764. }
  15765. m.Where(p...)
  15766. }
  15767. // Op returns the operation name.
  15768. func (m *SopTaskMutation) Op() Op {
  15769. return m.op
  15770. }
  15771. // SetOp allows setting the mutation operation.
  15772. func (m *SopTaskMutation) SetOp(op Op) {
  15773. m.op = op
  15774. }
  15775. // Type returns the node type of this mutation (SopTask).
  15776. func (m *SopTaskMutation) Type() string {
  15777. return m.typ
  15778. }
  15779. // Fields returns all fields that were changed during this mutation. Note that in
  15780. // order to get all numeric fields that were incremented/decremented, call
  15781. // AddedFields().
  15782. func (m *SopTaskMutation) Fields() []string {
  15783. fields := make([]string, 0, 11)
  15784. if m.created_at != nil {
  15785. fields = append(fields, soptask.FieldCreatedAt)
  15786. }
  15787. if m.updated_at != nil {
  15788. fields = append(fields, soptask.FieldUpdatedAt)
  15789. }
  15790. if m.status != nil {
  15791. fields = append(fields, soptask.FieldStatus)
  15792. }
  15793. if m.deleted_at != nil {
  15794. fields = append(fields, soptask.FieldDeletedAt)
  15795. }
  15796. if m.name != nil {
  15797. fields = append(fields, soptask.FieldName)
  15798. }
  15799. if m.bot_wxid_list != nil {
  15800. fields = append(fields, soptask.FieldBotWxidList)
  15801. }
  15802. if m._type != nil {
  15803. fields = append(fields, soptask.FieldType)
  15804. }
  15805. if m.plan_start_time != nil {
  15806. fields = append(fields, soptask.FieldPlanStartTime)
  15807. }
  15808. if m.plan_end_time != nil {
  15809. fields = append(fields, soptask.FieldPlanEndTime)
  15810. }
  15811. if m.creator_id != nil {
  15812. fields = append(fields, soptask.FieldCreatorID)
  15813. }
  15814. if m.organization_id != nil {
  15815. fields = append(fields, soptask.FieldOrganizationID)
  15816. }
  15817. return fields
  15818. }
  15819. // Field returns the value of a field with the given name. The second boolean
  15820. // return value indicates that this field was not set, or was not defined in the
  15821. // schema.
  15822. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  15823. switch name {
  15824. case soptask.FieldCreatedAt:
  15825. return m.CreatedAt()
  15826. case soptask.FieldUpdatedAt:
  15827. return m.UpdatedAt()
  15828. case soptask.FieldStatus:
  15829. return m.Status()
  15830. case soptask.FieldDeletedAt:
  15831. return m.DeletedAt()
  15832. case soptask.FieldName:
  15833. return m.Name()
  15834. case soptask.FieldBotWxidList:
  15835. return m.BotWxidList()
  15836. case soptask.FieldType:
  15837. return m.GetType()
  15838. case soptask.FieldPlanStartTime:
  15839. return m.PlanStartTime()
  15840. case soptask.FieldPlanEndTime:
  15841. return m.PlanEndTime()
  15842. case soptask.FieldCreatorID:
  15843. return m.CreatorID()
  15844. case soptask.FieldOrganizationID:
  15845. return m.OrganizationID()
  15846. }
  15847. return nil, false
  15848. }
  15849. // OldField returns the old value of the field from the database. An error is
  15850. // returned if the mutation operation is not UpdateOne, or the query to the
  15851. // database failed.
  15852. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15853. switch name {
  15854. case soptask.FieldCreatedAt:
  15855. return m.OldCreatedAt(ctx)
  15856. case soptask.FieldUpdatedAt:
  15857. return m.OldUpdatedAt(ctx)
  15858. case soptask.FieldStatus:
  15859. return m.OldStatus(ctx)
  15860. case soptask.FieldDeletedAt:
  15861. return m.OldDeletedAt(ctx)
  15862. case soptask.FieldName:
  15863. return m.OldName(ctx)
  15864. case soptask.FieldBotWxidList:
  15865. return m.OldBotWxidList(ctx)
  15866. case soptask.FieldType:
  15867. return m.OldType(ctx)
  15868. case soptask.FieldPlanStartTime:
  15869. return m.OldPlanStartTime(ctx)
  15870. case soptask.FieldPlanEndTime:
  15871. return m.OldPlanEndTime(ctx)
  15872. case soptask.FieldCreatorID:
  15873. return m.OldCreatorID(ctx)
  15874. case soptask.FieldOrganizationID:
  15875. return m.OldOrganizationID(ctx)
  15876. }
  15877. return nil, fmt.Errorf("unknown SopTask field %s", name)
  15878. }
  15879. // SetField sets the value of a field with the given name. It returns an error if
  15880. // the field is not defined in the schema, or if the type mismatched the field
  15881. // type.
  15882. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  15883. switch name {
  15884. case soptask.FieldCreatedAt:
  15885. v, ok := value.(time.Time)
  15886. if !ok {
  15887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15888. }
  15889. m.SetCreatedAt(v)
  15890. return nil
  15891. case soptask.FieldUpdatedAt:
  15892. v, ok := value.(time.Time)
  15893. if !ok {
  15894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15895. }
  15896. m.SetUpdatedAt(v)
  15897. return nil
  15898. case soptask.FieldStatus:
  15899. v, ok := value.(uint8)
  15900. if !ok {
  15901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15902. }
  15903. m.SetStatus(v)
  15904. return nil
  15905. case soptask.FieldDeletedAt:
  15906. v, ok := value.(time.Time)
  15907. if !ok {
  15908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15909. }
  15910. m.SetDeletedAt(v)
  15911. return nil
  15912. case soptask.FieldName:
  15913. v, ok := value.(string)
  15914. if !ok {
  15915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15916. }
  15917. m.SetName(v)
  15918. return nil
  15919. case soptask.FieldBotWxidList:
  15920. v, ok := value.([]string)
  15921. if !ok {
  15922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15923. }
  15924. m.SetBotWxidList(v)
  15925. return nil
  15926. case soptask.FieldType:
  15927. v, ok := value.(int)
  15928. if !ok {
  15929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15930. }
  15931. m.SetType(v)
  15932. return nil
  15933. case soptask.FieldPlanStartTime:
  15934. v, ok := value.(time.Time)
  15935. if !ok {
  15936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15937. }
  15938. m.SetPlanStartTime(v)
  15939. return nil
  15940. case soptask.FieldPlanEndTime:
  15941. v, ok := value.(time.Time)
  15942. if !ok {
  15943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15944. }
  15945. m.SetPlanEndTime(v)
  15946. return nil
  15947. case soptask.FieldCreatorID:
  15948. v, ok := value.(string)
  15949. if !ok {
  15950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15951. }
  15952. m.SetCreatorID(v)
  15953. return nil
  15954. case soptask.FieldOrganizationID:
  15955. v, ok := value.(uint64)
  15956. if !ok {
  15957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15958. }
  15959. m.SetOrganizationID(v)
  15960. return nil
  15961. }
  15962. return fmt.Errorf("unknown SopTask field %s", name)
  15963. }
  15964. // AddedFields returns all numeric fields that were incremented/decremented during
  15965. // this mutation.
  15966. func (m *SopTaskMutation) AddedFields() []string {
  15967. var fields []string
  15968. if m.addstatus != nil {
  15969. fields = append(fields, soptask.FieldStatus)
  15970. }
  15971. if m.add_type != nil {
  15972. fields = append(fields, soptask.FieldType)
  15973. }
  15974. if m.addorganization_id != nil {
  15975. fields = append(fields, soptask.FieldOrganizationID)
  15976. }
  15977. return fields
  15978. }
  15979. // AddedField returns the numeric value that was incremented/decremented on a field
  15980. // with the given name. The second boolean return value indicates that this field
  15981. // was not set, or was not defined in the schema.
  15982. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  15983. switch name {
  15984. case soptask.FieldStatus:
  15985. return m.AddedStatus()
  15986. case soptask.FieldType:
  15987. return m.AddedType()
  15988. case soptask.FieldOrganizationID:
  15989. return m.AddedOrganizationID()
  15990. }
  15991. return nil, false
  15992. }
  15993. // AddField adds the value to the field with the given name. It returns an error if
  15994. // the field is not defined in the schema, or if the type mismatched the field
  15995. // type.
  15996. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  15997. switch name {
  15998. case soptask.FieldStatus:
  15999. v, ok := value.(int8)
  16000. if !ok {
  16001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16002. }
  16003. m.AddStatus(v)
  16004. return nil
  16005. case soptask.FieldType:
  16006. v, ok := value.(int)
  16007. if !ok {
  16008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16009. }
  16010. m.AddType(v)
  16011. return nil
  16012. case soptask.FieldOrganizationID:
  16013. v, ok := value.(int64)
  16014. if !ok {
  16015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16016. }
  16017. m.AddOrganizationID(v)
  16018. return nil
  16019. }
  16020. return fmt.Errorf("unknown SopTask numeric field %s", name)
  16021. }
  16022. // ClearedFields returns all nullable fields that were cleared during this
  16023. // mutation.
  16024. func (m *SopTaskMutation) ClearedFields() []string {
  16025. var fields []string
  16026. if m.FieldCleared(soptask.FieldStatus) {
  16027. fields = append(fields, soptask.FieldStatus)
  16028. }
  16029. if m.FieldCleared(soptask.FieldDeletedAt) {
  16030. fields = append(fields, soptask.FieldDeletedAt)
  16031. }
  16032. if m.FieldCleared(soptask.FieldBotWxidList) {
  16033. fields = append(fields, soptask.FieldBotWxidList)
  16034. }
  16035. if m.FieldCleared(soptask.FieldPlanStartTime) {
  16036. fields = append(fields, soptask.FieldPlanStartTime)
  16037. }
  16038. if m.FieldCleared(soptask.FieldPlanEndTime) {
  16039. fields = append(fields, soptask.FieldPlanEndTime)
  16040. }
  16041. if m.FieldCleared(soptask.FieldCreatorID) {
  16042. fields = append(fields, soptask.FieldCreatorID)
  16043. }
  16044. if m.FieldCleared(soptask.FieldOrganizationID) {
  16045. fields = append(fields, soptask.FieldOrganizationID)
  16046. }
  16047. return fields
  16048. }
  16049. // FieldCleared returns a boolean indicating if a field with the given name was
  16050. // cleared in this mutation.
  16051. func (m *SopTaskMutation) FieldCleared(name string) bool {
  16052. _, ok := m.clearedFields[name]
  16053. return ok
  16054. }
  16055. // ClearField clears the value of the field with the given name. It returns an
  16056. // error if the field is not defined in the schema.
  16057. func (m *SopTaskMutation) ClearField(name string) error {
  16058. switch name {
  16059. case soptask.FieldStatus:
  16060. m.ClearStatus()
  16061. return nil
  16062. case soptask.FieldDeletedAt:
  16063. m.ClearDeletedAt()
  16064. return nil
  16065. case soptask.FieldBotWxidList:
  16066. m.ClearBotWxidList()
  16067. return nil
  16068. case soptask.FieldPlanStartTime:
  16069. m.ClearPlanStartTime()
  16070. return nil
  16071. case soptask.FieldPlanEndTime:
  16072. m.ClearPlanEndTime()
  16073. return nil
  16074. case soptask.FieldCreatorID:
  16075. m.ClearCreatorID()
  16076. return nil
  16077. case soptask.FieldOrganizationID:
  16078. m.ClearOrganizationID()
  16079. return nil
  16080. }
  16081. return fmt.Errorf("unknown SopTask nullable field %s", name)
  16082. }
  16083. // ResetField resets all changes in the mutation for the field with the given name.
  16084. // It returns an error if the field is not defined in the schema.
  16085. func (m *SopTaskMutation) ResetField(name string) error {
  16086. switch name {
  16087. case soptask.FieldCreatedAt:
  16088. m.ResetCreatedAt()
  16089. return nil
  16090. case soptask.FieldUpdatedAt:
  16091. m.ResetUpdatedAt()
  16092. return nil
  16093. case soptask.FieldStatus:
  16094. m.ResetStatus()
  16095. return nil
  16096. case soptask.FieldDeletedAt:
  16097. m.ResetDeletedAt()
  16098. return nil
  16099. case soptask.FieldName:
  16100. m.ResetName()
  16101. return nil
  16102. case soptask.FieldBotWxidList:
  16103. m.ResetBotWxidList()
  16104. return nil
  16105. case soptask.FieldType:
  16106. m.ResetType()
  16107. return nil
  16108. case soptask.FieldPlanStartTime:
  16109. m.ResetPlanStartTime()
  16110. return nil
  16111. case soptask.FieldPlanEndTime:
  16112. m.ResetPlanEndTime()
  16113. return nil
  16114. case soptask.FieldCreatorID:
  16115. m.ResetCreatorID()
  16116. return nil
  16117. case soptask.FieldOrganizationID:
  16118. m.ResetOrganizationID()
  16119. return nil
  16120. }
  16121. return fmt.Errorf("unknown SopTask field %s", name)
  16122. }
  16123. // AddedEdges returns all edge names that were set/added in this mutation.
  16124. func (m *SopTaskMutation) AddedEdges() []string {
  16125. edges := make([]string, 0, 1)
  16126. if m.task_stages != nil {
  16127. edges = append(edges, soptask.EdgeTaskStages)
  16128. }
  16129. return edges
  16130. }
  16131. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16132. // name in this mutation.
  16133. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  16134. switch name {
  16135. case soptask.EdgeTaskStages:
  16136. ids := make([]ent.Value, 0, len(m.task_stages))
  16137. for id := range m.task_stages {
  16138. ids = append(ids, id)
  16139. }
  16140. return ids
  16141. }
  16142. return nil
  16143. }
  16144. // RemovedEdges returns all edge names that were removed in this mutation.
  16145. func (m *SopTaskMutation) RemovedEdges() []string {
  16146. edges := make([]string, 0, 1)
  16147. if m.removedtask_stages != nil {
  16148. edges = append(edges, soptask.EdgeTaskStages)
  16149. }
  16150. return edges
  16151. }
  16152. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16153. // the given name in this mutation.
  16154. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  16155. switch name {
  16156. case soptask.EdgeTaskStages:
  16157. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  16158. for id := range m.removedtask_stages {
  16159. ids = append(ids, id)
  16160. }
  16161. return ids
  16162. }
  16163. return nil
  16164. }
  16165. // ClearedEdges returns all edge names that were cleared in this mutation.
  16166. func (m *SopTaskMutation) ClearedEdges() []string {
  16167. edges := make([]string, 0, 1)
  16168. if m.clearedtask_stages {
  16169. edges = append(edges, soptask.EdgeTaskStages)
  16170. }
  16171. return edges
  16172. }
  16173. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16174. // was cleared in this mutation.
  16175. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  16176. switch name {
  16177. case soptask.EdgeTaskStages:
  16178. return m.clearedtask_stages
  16179. }
  16180. return false
  16181. }
  16182. // ClearEdge clears the value of the edge with the given name. It returns an error
  16183. // if that edge is not defined in the schema.
  16184. func (m *SopTaskMutation) ClearEdge(name string) error {
  16185. switch name {
  16186. }
  16187. return fmt.Errorf("unknown SopTask unique edge %s", name)
  16188. }
  16189. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16190. // It returns an error if the edge is not defined in the schema.
  16191. func (m *SopTaskMutation) ResetEdge(name string) error {
  16192. switch name {
  16193. case soptask.EdgeTaskStages:
  16194. m.ResetTaskStages()
  16195. return nil
  16196. }
  16197. return fmt.Errorf("unknown SopTask edge %s", name)
  16198. }
  16199. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  16200. type TokenMutation struct {
  16201. config
  16202. op Op
  16203. typ string
  16204. id *uint64
  16205. created_at *time.Time
  16206. updated_at *time.Time
  16207. deleted_at *time.Time
  16208. expire_at *time.Time
  16209. token *string
  16210. mac *string
  16211. clearedFields map[string]struct{}
  16212. done bool
  16213. oldValue func(context.Context) (*Token, error)
  16214. predicates []predicate.Token
  16215. }
  16216. var _ ent.Mutation = (*TokenMutation)(nil)
  16217. // tokenOption allows management of the mutation configuration using functional options.
  16218. type tokenOption func(*TokenMutation)
  16219. // newTokenMutation creates new mutation for the Token entity.
  16220. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  16221. m := &TokenMutation{
  16222. config: c,
  16223. op: op,
  16224. typ: TypeToken,
  16225. clearedFields: make(map[string]struct{}),
  16226. }
  16227. for _, opt := range opts {
  16228. opt(m)
  16229. }
  16230. return m
  16231. }
  16232. // withTokenID sets the ID field of the mutation.
  16233. func withTokenID(id uint64) tokenOption {
  16234. return func(m *TokenMutation) {
  16235. var (
  16236. err error
  16237. once sync.Once
  16238. value *Token
  16239. )
  16240. m.oldValue = func(ctx context.Context) (*Token, error) {
  16241. once.Do(func() {
  16242. if m.done {
  16243. err = errors.New("querying old values post mutation is not allowed")
  16244. } else {
  16245. value, err = m.Client().Token.Get(ctx, id)
  16246. }
  16247. })
  16248. return value, err
  16249. }
  16250. m.id = &id
  16251. }
  16252. }
  16253. // withToken sets the old Token of the mutation.
  16254. func withToken(node *Token) tokenOption {
  16255. return func(m *TokenMutation) {
  16256. m.oldValue = func(context.Context) (*Token, error) {
  16257. return node, nil
  16258. }
  16259. m.id = &node.ID
  16260. }
  16261. }
  16262. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16263. // executed in a transaction (ent.Tx), a transactional client is returned.
  16264. func (m TokenMutation) Client() *Client {
  16265. client := &Client{config: m.config}
  16266. client.init()
  16267. return client
  16268. }
  16269. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16270. // it returns an error otherwise.
  16271. func (m TokenMutation) Tx() (*Tx, error) {
  16272. if _, ok := m.driver.(*txDriver); !ok {
  16273. return nil, errors.New("ent: mutation is not running in a transaction")
  16274. }
  16275. tx := &Tx{config: m.config}
  16276. tx.init()
  16277. return tx, nil
  16278. }
  16279. // SetID sets the value of the id field. Note that this
  16280. // operation is only accepted on creation of Token entities.
  16281. func (m *TokenMutation) SetID(id uint64) {
  16282. m.id = &id
  16283. }
  16284. // ID returns the ID value in the mutation. Note that the ID is only available
  16285. // if it was provided to the builder or after it was returned from the database.
  16286. func (m *TokenMutation) ID() (id uint64, exists bool) {
  16287. if m.id == nil {
  16288. return
  16289. }
  16290. return *m.id, true
  16291. }
  16292. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16293. // That means, if the mutation is applied within a transaction with an isolation level such
  16294. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16295. // or updated by the mutation.
  16296. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  16297. switch {
  16298. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16299. id, exists := m.ID()
  16300. if exists {
  16301. return []uint64{id}, nil
  16302. }
  16303. fallthrough
  16304. case m.op.Is(OpUpdate | OpDelete):
  16305. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  16306. default:
  16307. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16308. }
  16309. }
  16310. // SetCreatedAt sets the "created_at" field.
  16311. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  16312. m.created_at = &t
  16313. }
  16314. // CreatedAt returns the value of the "created_at" field in the mutation.
  16315. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  16316. v := m.created_at
  16317. if v == nil {
  16318. return
  16319. }
  16320. return *v, true
  16321. }
  16322. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  16323. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16325. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16326. if !m.op.Is(OpUpdateOne) {
  16327. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16328. }
  16329. if m.id == nil || m.oldValue == nil {
  16330. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16331. }
  16332. oldValue, err := m.oldValue(ctx)
  16333. if err != nil {
  16334. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16335. }
  16336. return oldValue.CreatedAt, nil
  16337. }
  16338. // ResetCreatedAt resets all changes to the "created_at" field.
  16339. func (m *TokenMutation) ResetCreatedAt() {
  16340. m.created_at = nil
  16341. }
  16342. // SetUpdatedAt sets the "updated_at" field.
  16343. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  16344. m.updated_at = &t
  16345. }
  16346. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16347. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  16348. v := m.updated_at
  16349. if v == nil {
  16350. return
  16351. }
  16352. return *v, true
  16353. }
  16354. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  16355. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16357. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16358. if !m.op.Is(OpUpdateOne) {
  16359. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16360. }
  16361. if m.id == nil || m.oldValue == nil {
  16362. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16363. }
  16364. oldValue, err := m.oldValue(ctx)
  16365. if err != nil {
  16366. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16367. }
  16368. return oldValue.UpdatedAt, nil
  16369. }
  16370. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16371. func (m *TokenMutation) ResetUpdatedAt() {
  16372. m.updated_at = nil
  16373. }
  16374. // SetDeletedAt sets the "deleted_at" field.
  16375. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  16376. m.deleted_at = &t
  16377. }
  16378. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16379. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  16380. v := m.deleted_at
  16381. if v == nil {
  16382. return
  16383. }
  16384. return *v, true
  16385. }
  16386. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  16387. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16389. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16390. if !m.op.Is(OpUpdateOne) {
  16391. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16392. }
  16393. if m.id == nil || m.oldValue == nil {
  16394. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16395. }
  16396. oldValue, err := m.oldValue(ctx)
  16397. if err != nil {
  16398. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16399. }
  16400. return oldValue.DeletedAt, nil
  16401. }
  16402. // ClearDeletedAt clears the value of the "deleted_at" field.
  16403. func (m *TokenMutation) ClearDeletedAt() {
  16404. m.deleted_at = nil
  16405. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  16406. }
  16407. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16408. func (m *TokenMutation) DeletedAtCleared() bool {
  16409. _, ok := m.clearedFields[token.FieldDeletedAt]
  16410. return ok
  16411. }
  16412. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16413. func (m *TokenMutation) ResetDeletedAt() {
  16414. m.deleted_at = nil
  16415. delete(m.clearedFields, token.FieldDeletedAt)
  16416. }
  16417. // SetExpireAt sets the "expire_at" field.
  16418. func (m *TokenMutation) SetExpireAt(t time.Time) {
  16419. m.expire_at = &t
  16420. }
  16421. // ExpireAt returns the value of the "expire_at" field in the mutation.
  16422. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  16423. v := m.expire_at
  16424. if v == nil {
  16425. return
  16426. }
  16427. return *v, true
  16428. }
  16429. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  16430. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16432. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  16433. if !m.op.Is(OpUpdateOne) {
  16434. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  16435. }
  16436. if m.id == nil || m.oldValue == nil {
  16437. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  16438. }
  16439. oldValue, err := m.oldValue(ctx)
  16440. if err != nil {
  16441. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  16442. }
  16443. return oldValue.ExpireAt, nil
  16444. }
  16445. // ClearExpireAt clears the value of the "expire_at" field.
  16446. func (m *TokenMutation) ClearExpireAt() {
  16447. m.expire_at = nil
  16448. m.clearedFields[token.FieldExpireAt] = struct{}{}
  16449. }
  16450. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  16451. func (m *TokenMutation) ExpireAtCleared() bool {
  16452. _, ok := m.clearedFields[token.FieldExpireAt]
  16453. return ok
  16454. }
  16455. // ResetExpireAt resets all changes to the "expire_at" field.
  16456. func (m *TokenMutation) ResetExpireAt() {
  16457. m.expire_at = nil
  16458. delete(m.clearedFields, token.FieldExpireAt)
  16459. }
  16460. // SetToken sets the "token" field.
  16461. func (m *TokenMutation) SetToken(s string) {
  16462. m.token = &s
  16463. }
  16464. // Token returns the value of the "token" field in the mutation.
  16465. func (m *TokenMutation) Token() (r string, exists bool) {
  16466. v := m.token
  16467. if v == nil {
  16468. return
  16469. }
  16470. return *v, true
  16471. }
  16472. // OldToken returns the old "token" field's value of the Token entity.
  16473. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16475. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  16476. if !m.op.Is(OpUpdateOne) {
  16477. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  16478. }
  16479. if m.id == nil || m.oldValue == nil {
  16480. return v, errors.New("OldToken requires an ID field in the mutation")
  16481. }
  16482. oldValue, err := m.oldValue(ctx)
  16483. if err != nil {
  16484. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  16485. }
  16486. return oldValue.Token, nil
  16487. }
  16488. // ClearToken clears the value of the "token" field.
  16489. func (m *TokenMutation) ClearToken() {
  16490. m.token = nil
  16491. m.clearedFields[token.FieldToken] = struct{}{}
  16492. }
  16493. // TokenCleared returns if the "token" field was cleared in this mutation.
  16494. func (m *TokenMutation) TokenCleared() bool {
  16495. _, ok := m.clearedFields[token.FieldToken]
  16496. return ok
  16497. }
  16498. // ResetToken resets all changes to the "token" field.
  16499. func (m *TokenMutation) ResetToken() {
  16500. m.token = nil
  16501. delete(m.clearedFields, token.FieldToken)
  16502. }
  16503. // SetMAC sets the "mac" field.
  16504. func (m *TokenMutation) SetMAC(s string) {
  16505. m.mac = &s
  16506. }
  16507. // MAC returns the value of the "mac" field in the mutation.
  16508. func (m *TokenMutation) MAC() (r string, exists bool) {
  16509. v := m.mac
  16510. if v == nil {
  16511. return
  16512. }
  16513. return *v, true
  16514. }
  16515. // OldMAC returns the old "mac" field's value of the Token entity.
  16516. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16518. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  16519. if !m.op.Is(OpUpdateOne) {
  16520. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  16521. }
  16522. if m.id == nil || m.oldValue == nil {
  16523. return v, errors.New("OldMAC requires an ID field in the mutation")
  16524. }
  16525. oldValue, err := m.oldValue(ctx)
  16526. if err != nil {
  16527. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  16528. }
  16529. return oldValue.MAC, nil
  16530. }
  16531. // ResetMAC resets all changes to the "mac" field.
  16532. func (m *TokenMutation) ResetMAC() {
  16533. m.mac = nil
  16534. }
  16535. // Where appends a list predicates to the TokenMutation builder.
  16536. func (m *TokenMutation) Where(ps ...predicate.Token) {
  16537. m.predicates = append(m.predicates, ps...)
  16538. }
  16539. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  16540. // users can use type-assertion to append predicates that do not depend on any generated package.
  16541. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  16542. p := make([]predicate.Token, len(ps))
  16543. for i := range ps {
  16544. p[i] = ps[i]
  16545. }
  16546. m.Where(p...)
  16547. }
  16548. // Op returns the operation name.
  16549. func (m *TokenMutation) Op() Op {
  16550. return m.op
  16551. }
  16552. // SetOp allows setting the mutation operation.
  16553. func (m *TokenMutation) SetOp(op Op) {
  16554. m.op = op
  16555. }
  16556. // Type returns the node type of this mutation (Token).
  16557. func (m *TokenMutation) Type() string {
  16558. return m.typ
  16559. }
  16560. // Fields returns all fields that were changed during this mutation. Note that in
  16561. // order to get all numeric fields that were incremented/decremented, call
  16562. // AddedFields().
  16563. func (m *TokenMutation) Fields() []string {
  16564. fields := make([]string, 0, 6)
  16565. if m.created_at != nil {
  16566. fields = append(fields, token.FieldCreatedAt)
  16567. }
  16568. if m.updated_at != nil {
  16569. fields = append(fields, token.FieldUpdatedAt)
  16570. }
  16571. if m.deleted_at != nil {
  16572. fields = append(fields, token.FieldDeletedAt)
  16573. }
  16574. if m.expire_at != nil {
  16575. fields = append(fields, token.FieldExpireAt)
  16576. }
  16577. if m.token != nil {
  16578. fields = append(fields, token.FieldToken)
  16579. }
  16580. if m.mac != nil {
  16581. fields = append(fields, token.FieldMAC)
  16582. }
  16583. return fields
  16584. }
  16585. // Field returns the value of a field with the given name. The second boolean
  16586. // return value indicates that this field was not set, or was not defined in the
  16587. // schema.
  16588. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  16589. switch name {
  16590. case token.FieldCreatedAt:
  16591. return m.CreatedAt()
  16592. case token.FieldUpdatedAt:
  16593. return m.UpdatedAt()
  16594. case token.FieldDeletedAt:
  16595. return m.DeletedAt()
  16596. case token.FieldExpireAt:
  16597. return m.ExpireAt()
  16598. case token.FieldToken:
  16599. return m.Token()
  16600. case token.FieldMAC:
  16601. return m.MAC()
  16602. }
  16603. return nil, false
  16604. }
  16605. // OldField returns the old value of the field from the database. An error is
  16606. // returned if the mutation operation is not UpdateOne, or the query to the
  16607. // database failed.
  16608. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16609. switch name {
  16610. case token.FieldCreatedAt:
  16611. return m.OldCreatedAt(ctx)
  16612. case token.FieldUpdatedAt:
  16613. return m.OldUpdatedAt(ctx)
  16614. case token.FieldDeletedAt:
  16615. return m.OldDeletedAt(ctx)
  16616. case token.FieldExpireAt:
  16617. return m.OldExpireAt(ctx)
  16618. case token.FieldToken:
  16619. return m.OldToken(ctx)
  16620. case token.FieldMAC:
  16621. return m.OldMAC(ctx)
  16622. }
  16623. return nil, fmt.Errorf("unknown Token field %s", name)
  16624. }
  16625. // SetField sets the value of a field with the given name. It returns an error if
  16626. // the field is not defined in the schema, or if the type mismatched the field
  16627. // type.
  16628. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  16629. switch name {
  16630. case token.FieldCreatedAt:
  16631. v, ok := value.(time.Time)
  16632. if !ok {
  16633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16634. }
  16635. m.SetCreatedAt(v)
  16636. return nil
  16637. case token.FieldUpdatedAt:
  16638. v, ok := value.(time.Time)
  16639. if !ok {
  16640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16641. }
  16642. m.SetUpdatedAt(v)
  16643. return nil
  16644. case token.FieldDeletedAt:
  16645. v, ok := value.(time.Time)
  16646. if !ok {
  16647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16648. }
  16649. m.SetDeletedAt(v)
  16650. return nil
  16651. case token.FieldExpireAt:
  16652. v, ok := value.(time.Time)
  16653. if !ok {
  16654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16655. }
  16656. m.SetExpireAt(v)
  16657. return nil
  16658. case token.FieldToken:
  16659. v, ok := value.(string)
  16660. if !ok {
  16661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16662. }
  16663. m.SetToken(v)
  16664. return nil
  16665. case token.FieldMAC:
  16666. v, ok := value.(string)
  16667. if !ok {
  16668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16669. }
  16670. m.SetMAC(v)
  16671. return nil
  16672. }
  16673. return fmt.Errorf("unknown Token field %s", name)
  16674. }
  16675. // AddedFields returns all numeric fields that were incremented/decremented during
  16676. // this mutation.
  16677. func (m *TokenMutation) AddedFields() []string {
  16678. return nil
  16679. }
  16680. // AddedField returns the numeric value that was incremented/decremented on a field
  16681. // with the given name. The second boolean return value indicates that this field
  16682. // was not set, or was not defined in the schema.
  16683. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  16684. return nil, false
  16685. }
  16686. // AddField adds the value to the field with the given name. It returns an error if
  16687. // the field is not defined in the schema, or if the type mismatched the field
  16688. // type.
  16689. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  16690. switch name {
  16691. }
  16692. return fmt.Errorf("unknown Token numeric field %s", name)
  16693. }
  16694. // ClearedFields returns all nullable fields that were cleared during this
  16695. // mutation.
  16696. func (m *TokenMutation) ClearedFields() []string {
  16697. var fields []string
  16698. if m.FieldCleared(token.FieldDeletedAt) {
  16699. fields = append(fields, token.FieldDeletedAt)
  16700. }
  16701. if m.FieldCleared(token.FieldExpireAt) {
  16702. fields = append(fields, token.FieldExpireAt)
  16703. }
  16704. if m.FieldCleared(token.FieldToken) {
  16705. fields = append(fields, token.FieldToken)
  16706. }
  16707. return fields
  16708. }
  16709. // FieldCleared returns a boolean indicating if a field with the given name was
  16710. // cleared in this mutation.
  16711. func (m *TokenMutation) FieldCleared(name string) bool {
  16712. _, ok := m.clearedFields[name]
  16713. return ok
  16714. }
  16715. // ClearField clears the value of the field with the given name. It returns an
  16716. // error if the field is not defined in the schema.
  16717. func (m *TokenMutation) ClearField(name string) error {
  16718. switch name {
  16719. case token.FieldDeletedAt:
  16720. m.ClearDeletedAt()
  16721. return nil
  16722. case token.FieldExpireAt:
  16723. m.ClearExpireAt()
  16724. return nil
  16725. case token.FieldToken:
  16726. m.ClearToken()
  16727. return nil
  16728. }
  16729. return fmt.Errorf("unknown Token nullable field %s", name)
  16730. }
  16731. // ResetField resets all changes in the mutation for the field with the given name.
  16732. // It returns an error if the field is not defined in the schema.
  16733. func (m *TokenMutation) ResetField(name string) error {
  16734. switch name {
  16735. case token.FieldCreatedAt:
  16736. m.ResetCreatedAt()
  16737. return nil
  16738. case token.FieldUpdatedAt:
  16739. m.ResetUpdatedAt()
  16740. return nil
  16741. case token.FieldDeletedAt:
  16742. m.ResetDeletedAt()
  16743. return nil
  16744. case token.FieldExpireAt:
  16745. m.ResetExpireAt()
  16746. return nil
  16747. case token.FieldToken:
  16748. m.ResetToken()
  16749. return nil
  16750. case token.FieldMAC:
  16751. m.ResetMAC()
  16752. return nil
  16753. }
  16754. return fmt.Errorf("unknown Token field %s", name)
  16755. }
  16756. // AddedEdges returns all edge names that were set/added in this mutation.
  16757. func (m *TokenMutation) AddedEdges() []string {
  16758. edges := make([]string, 0, 0)
  16759. return edges
  16760. }
  16761. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16762. // name in this mutation.
  16763. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  16764. return nil
  16765. }
  16766. // RemovedEdges returns all edge names that were removed in this mutation.
  16767. func (m *TokenMutation) RemovedEdges() []string {
  16768. edges := make([]string, 0, 0)
  16769. return edges
  16770. }
  16771. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16772. // the given name in this mutation.
  16773. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  16774. return nil
  16775. }
  16776. // ClearedEdges returns all edge names that were cleared in this mutation.
  16777. func (m *TokenMutation) ClearedEdges() []string {
  16778. edges := make([]string, 0, 0)
  16779. return edges
  16780. }
  16781. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16782. // was cleared in this mutation.
  16783. func (m *TokenMutation) EdgeCleared(name string) bool {
  16784. return false
  16785. }
  16786. // ClearEdge clears the value of the edge with the given name. It returns an error
  16787. // if that edge is not defined in the schema.
  16788. func (m *TokenMutation) ClearEdge(name string) error {
  16789. return fmt.Errorf("unknown Token unique edge %s", name)
  16790. }
  16791. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16792. // It returns an error if the edge is not defined in the schema.
  16793. func (m *TokenMutation) ResetEdge(name string) error {
  16794. return fmt.Errorf("unknown Token edge %s", name)
  16795. }
  16796. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  16797. type TutorialMutation struct {
  16798. config
  16799. op Op
  16800. typ string
  16801. id *uint64
  16802. created_at *time.Time
  16803. updated_at *time.Time
  16804. deleted_at *time.Time
  16805. index *int
  16806. addindex *int
  16807. title *string
  16808. content *string
  16809. organization_id *uint64
  16810. addorganization_id *int64
  16811. clearedFields map[string]struct{}
  16812. employee *uint64
  16813. clearedemployee bool
  16814. done bool
  16815. oldValue func(context.Context) (*Tutorial, error)
  16816. predicates []predicate.Tutorial
  16817. }
  16818. var _ ent.Mutation = (*TutorialMutation)(nil)
  16819. // tutorialOption allows management of the mutation configuration using functional options.
  16820. type tutorialOption func(*TutorialMutation)
  16821. // newTutorialMutation creates new mutation for the Tutorial entity.
  16822. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  16823. m := &TutorialMutation{
  16824. config: c,
  16825. op: op,
  16826. typ: TypeTutorial,
  16827. clearedFields: make(map[string]struct{}),
  16828. }
  16829. for _, opt := range opts {
  16830. opt(m)
  16831. }
  16832. return m
  16833. }
  16834. // withTutorialID sets the ID field of the mutation.
  16835. func withTutorialID(id uint64) tutorialOption {
  16836. return func(m *TutorialMutation) {
  16837. var (
  16838. err error
  16839. once sync.Once
  16840. value *Tutorial
  16841. )
  16842. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  16843. once.Do(func() {
  16844. if m.done {
  16845. err = errors.New("querying old values post mutation is not allowed")
  16846. } else {
  16847. value, err = m.Client().Tutorial.Get(ctx, id)
  16848. }
  16849. })
  16850. return value, err
  16851. }
  16852. m.id = &id
  16853. }
  16854. }
  16855. // withTutorial sets the old Tutorial of the mutation.
  16856. func withTutorial(node *Tutorial) tutorialOption {
  16857. return func(m *TutorialMutation) {
  16858. m.oldValue = func(context.Context) (*Tutorial, error) {
  16859. return node, nil
  16860. }
  16861. m.id = &node.ID
  16862. }
  16863. }
  16864. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16865. // executed in a transaction (ent.Tx), a transactional client is returned.
  16866. func (m TutorialMutation) Client() *Client {
  16867. client := &Client{config: m.config}
  16868. client.init()
  16869. return client
  16870. }
  16871. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16872. // it returns an error otherwise.
  16873. func (m TutorialMutation) Tx() (*Tx, error) {
  16874. if _, ok := m.driver.(*txDriver); !ok {
  16875. return nil, errors.New("ent: mutation is not running in a transaction")
  16876. }
  16877. tx := &Tx{config: m.config}
  16878. tx.init()
  16879. return tx, nil
  16880. }
  16881. // SetID sets the value of the id field. Note that this
  16882. // operation is only accepted on creation of Tutorial entities.
  16883. func (m *TutorialMutation) SetID(id uint64) {
  16884. m.id = &id
  16885. }
  16886. // ID returns the ID value in the mutation. Note that the ID is only available
  16887. // if it was provided to the builder or after it was returned from the database.
  16888. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  16889. if m.id == nil {
  16890. return
  16891. }
  16892. return *m.id, true
  16893. }
  16894. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16895. // That means, if the mutation is applied within a transaction with an isolation level such
  16896. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16897. // or updated by the mutation.
  16898. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  16899. switch {
  16900. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16901. id, exists := m.ID()
  16902. if exists {
  16903. return []uint64{id}, nil
  16904. }
  16905. fallthrough
  16906. case m.op.Is(OpUpdate | OpDelete):
  16907. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  16908. default:
  16909. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16910. }
  16911. }
  16912. // SetCreatedAt sets the "created_at" field.
  16913. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  16914. m.created_at = &t
  16915. }
  16916. // CreatedAt returns the value of the "created_at" field in the mutation.
  16917. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  16918. v := m.created_at
  16919. if v == nil {
  16920. return
  16921. }
  16922. return *v, true
  16923. }
  16924. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  16925. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16927. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16928. if !m.op.Is(OpUpdateOne) {
  16929. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16930. }
  16931. if m.id == nil || m.oldValue == nil {
  16932. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16933. }
  16934. oldValue, err := m.oldValue(ctx)
  16935. if err != nil {
  16936. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16937. }
  16938. return oldValue.CreatedAt, nil
  16939. }
  16940. // ResetCreatedAt resets all changes to the "created_at" field.
  16941. func (m *TutorialMutation) ResetCreatedAt() {
  16942. m.created_at = nil
  16943. }
  16944. // SetUpdatedAt sets the "updated_at" field.
  16945. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  16946. m.updated_at = &t
  16947. }
  16948. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16949. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  16950. v := m.updated_at
  16951. if v == nil {
  16952. return
  16953. }
  16954. return *v, true
  16955. }
  16956. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  16957. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16959. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16960. if !m.op.Is(OpUpdateOne) {
  16961. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16962. }
  16963. if m.id == nil || m.oldValue == nil {
  16964. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16965. }
  16966. oldValue, err := m.oldValue(ctx)
  16967. if err != nil {
  16968. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16969. }
  16970. return oldValue.UpdatedAt, nil
  16971. }
  16972. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16973. func (m *TutorialMutation) ResetUpdatedAt() {
  16974. m.updated_at = nil
  16975. }
  16976. // SetDeletedAt sets the "deleted_at" field.
  16977. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  16978. m.deleted_at = &t
  16979. }
  16980. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16981. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  16982. v := m.deleted_at
  16983. if v == nil {
  16984. return
  16985. }
  16986. return *v, true
  16987. }
  16988. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  16989. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16991. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16992. if !m.op.Is(OpUpdateOne) {
  16993. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16994. }
  16995. if m.id == nil || m.oldValue == nil {
  16996. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16997. }
  16998. oldValue, err := m.oldValue(ctx)
  16999. if err != nil {
  17000. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17001. }
  17002. return oldValue.DeletedAt, nil
  17003. }
  17004. // ClearDeletedAt clears the value of the "deleted_at" field.
  17005. func (m *TutorialMutation) ClearDeletedAt() {
  17006. m.deleted_at = nil
  17007. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  17008. }
  17009. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17010. func (m *TutorialMutation) DeletedAtCleared() bool {
  17011. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  17012. return ok
  17013. }
  17014. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17015. func (m *TutorialMutation) ResetDeletedAt() {
  17016. m.deleted_at = nil
  17017. delete(m.clearedFields, tutorial.FieldDeletedAt)
  17018. }
  17019. // SetEmployeeID sets the "employee_id" field.
  17020. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  17021. m.employee = &u
  17022. }
  17023. // EmployeeID returns the value of the "employee_id" field in the mutation.
  17024. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  17025. v := m.employee
  17026. if v == nil {
  17027. return
  17028. }
  17029. return *v, true
  17030. }
  17031. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  17032. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  17033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17034. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  17035. if !m.op.Is(OpUpdateOne) {
  17036. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  17037. }
  17038. if m.id == nil || m.oldValue == nil {
  17039. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  17040. }
  17041. oldValue, err := m.oldValue(ctx)
  17042. if err != nil {
  17043. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  17044. }
  17045. return oldValue.EmployeeID, nil
  17046. }
  17047. // ResetEmployeeID resets all changes to the "employee_id" field.
  17048. func (m *TutorialMutation) ResetEmployeeID() {
  17049. m.employee = nil
  17050. }
  17051. // SetIndex sets the "index" field.
  17052. func (m *TutorialMutation) SetIndex(i int) {
  17053. m.index = &i
  17054. m.addindex = nil
  17055. }
  17056. // Index returns the value of the "index" field in the mutation.
  17057. func (m *TutorialMutation) Index() (r int, exists bool) {
  17058. v := m.index
  17059. if v == nil {
  17060. return
  17061. }
  17062. return *v, true
  17063. }
  17064. // OldIndex returns the old "index" field's value of the Tutorial entity.
  17065. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  17066. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17067. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  17068. if !m.op.Is(OpUpdateOne) {
  17069. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  17070. }
  17071. if m.id == nil || m.oldValue == nil {
  17072. return v, errors.New("OldIndex requires an ID field in the mutation")
  17073. }
  17074. oldValue, err := m.oldValue(ctx)
  17075. if err != nil {
  17076. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  17077. }
  17078. return oldValue.Index, nil
  17079. }
  17080. // AddIndex adds i to the "index" field.
  17081. func (m *TutorialMutation) AddIndex(i int) {
  17082. if m.addindex != nil {
  17083. *m.addindex += i
  17084. } else {
  17085. m.addindex = &i
  17086. }
  17087. }
  17088. // AddedIndex returns the value that was added to the "index" field in this mutation.
  17089. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  17090. v := m.addindex
  17091. if v == nil {
  17092. return
  17093. }
  17094. return *v, true
  17095. }
  17096. // ResetIndex resets all changes to the "index" field.
  17097. func (m *TutorialMutation) ResetIndex() {
  17098. m.index = nil
  17099. m.addindex = nil
  17100. }
  17101. // SetTitle sets the "title" field.
  17102. func (m *TutorialMutation) SetTitle(s string) {
  17103. m.title = &s
  17104. }
  17105. // Title returns the value of the "title" field in the mutation.
  17106. func (m *TutorialMutation) Title() (r string, exists bool) {
  17107. v := m.title
  17108. if v == nil {
  17109. return
  17110. }
  17111. return *v, true
  17112. }
  17113. // OldTitle returns the old "title" field's value of the Tutorial entity.
  17114. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  17115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17116. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  17117. if !m.op.Is(OpUpdateOne) {
  17118. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  17119. }
  17120. if m.id == nil || m.oldValue == nil {
  17121. return v, errors.New("OldTitle requires an ID field in the mutation")
  17122. }
  17123. oldValue, err := m.oldValue(ctx)
  17124. if err != nil {
  17125. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  17126. }
  17127. return oldValue.Title, nil
  17128. }
  17129. // ResetTitle resets all changes to the "title" field.
  17130. func (m *TutorialMutation) ResetTitle() {
  17131. m.title = nil
  17132. }
  17133. // SetContent sets the "content" field.
  17134. func (m *TutorialMutation) SetContent(s string) {
  17135. m.content = &s
  17136. }
  17137. // Content returns the value of the "content" field in the mutation.
  17138. func (m *TutorialMutation) Content() (r string, exists bool) {
  17139. v := m.content
  17140. if v == nil {
  17141. return
  17142. }
  17143. return *v, true
  17144. }
  17145. // OldContent returns the old "content" field's value of the Tutorial entity.
  17146. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  17147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17148. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  17149. if !m.op.Is(OpUpdateOne) {
  17150. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  17151. }
  17152. if m.id == nil || m.oldValue == nil {
  17153. return v, errors.New("OldContent requires an ID field in the mutation")
  17154. }
  17155. oldValue, err := m.oldValue(ctx)
  17156. if err != nil {
  17157. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  17158. }
  17159. return oldValue.Content, nil
  17160. }
  17161. // ResetContent resets all changes to the "content" field.
  17162. func (m *TutorialMutation) ResetContent() {
  17163. m.content = nil
  17164. }
  17165. // SetOrganizationID sets the "organization_id" field.
  17166. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  17167. m.organization_id = &u
  17168. m.addorganization_id = nil
  17169. }
  17170. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17171. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  17172. v := m.organization_id
  17173. if v == nil {
  17174. return
  17175. }
  17176. return *v, true
  17177. }
  17178. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  17179. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  17180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17181. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17182. if !m.op.Is(OpUpdateOne) {
  17183. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17184. }
  17185. if m.id == nil || m.oldValue == nil {
  17186. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17187. }
  17188. oldValue, err := m.oldValue(ctx)
  17189. if err != nil {
  17190. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17191. }
  17192. return oldValue.OrganizationID, nil
  17193. }
  17194. // AddOrganizationID adds u to the "organization_id" field.
  17195. func (m *TutorialMutation) AddOrganizationID(u int64) {
  17196. if m.addorganization_id != nil {
  17197. *m.addorganization_id += u
  17198. } else {
  17199. m.addorganization_id = &u
  17200. }
  17201. }
  17202. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17203. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  17204. v := m.addorganization_id
  17205. if v == nil {
  17206. return
  17207. }
  17208. return *v, true
  17209. }
  17210. // ResetOrganizationID resets all changes to the "organization_id" field.
  17211. func (m *TutorialMutation) ResetOrganizationID() {
  17212. m.organization_id = nil
  17213. m.addorganization_id = nil
  17214. }
  17215. // ClearEmployee clears the "employee" edge to the Employee entity.
  17216. func (m *TutorialMutation) ClearEmployee() {
  17217. m.clearedemployee = true
  17218. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  17219. }
  17220. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  17221. func (m *TutorialMutation) EmployeeCleared() bool {
  17222. return m.clearedemployee
  17223. }
  17224. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  17225. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17226. // EmployeeID instead. It exists only for internal usage by the builders.
  17227. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  17228. if id := m.employee; id != nil {
  17229. ids = append(ids, *id)
  17230. }
  17231. return
  17232. }
  17233. // ResetEmployee resets all changes to the "employee" edge.
  17234. func (m *TutorialMutation) ResetEmployee() {
  17235. m.employee = nil
  17236. m.clearedemployee = false
  17237. }
  17238. // Where appends a list predicates to the TutorialMutation builder.
  17239. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  17240. m.predicates = append(m.predicates, ps...)
  17241. }
  17242. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  17243. // users can use type-assertion to append predicates that do not depend on any generated package.
  17244. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  17245. p := make([]predicate.Tutorial, len(ps))
  17246. for i := range ps {
  17247. p[i] = ps[i]
  17248. }
  17249. m.Where(p...)
  17250. }
  17251. // Op returns the operation name.
  17252. func (m *TutorialMutation) Op() Op {
  17253. return m.op
  17254. }
  17255. // SetOp allows setting the mutation operation.
  17256. func (m *TutorialMutation) SetOp(op Op) {
  17257. m.op = op
  17258. }
  17259. // Type returns the node type of this mutation (Tutorial).
  17260. func (m *TutorialMutation) Type() string {
  17261. return m.typ
  17262. }
  17263. // Fields returns all fields that were changed during this mutation. Note that in
  17264. // order to get all numeric fields that were incremented/decremented, call
  17265. // AddedFields().
  17266. func (m *TutorialMutation) Fields() []string {
  17267. fields := make([]string, 0, 8)
  17268. if m.created_at != nil {
  17269. fields = append(fields, tutorial.FieldCreatedAt)
  17270. }
  17271. if m.updated_at != nil {
  17272. fields = append(fields, tutorial.FieldUpdatedAt)
  17273. }
  17274. if m.deleted_at != nil {
  17275. fields = append(fields, tutorial.FieldDeletedAt)
  17276. }
  17277. if m.employee != nil {
  17278. fields = append(fields, tutorial.FieldEmployeeID)
  17279. }
  17280. if m.index != nil {
  17281. fields = append(fields, tutorial.FieldIndex)
  17282. }
  17283. if m.title != nil {
  17284. fields = append(fields, tutorial.FieldTitle)
  17285. }
  17286. if m.content != nil {
  17287. fields = append(fields, tutorial.FieldContent)
  17288. }
  17289. if m.organization_id != nil {
  17290. fields = append(fields, tutorial.FieldOrganizationID)
  17291. }
  17292. return fields
  17293. }
  17294. // Field returns the value of a field with the given name. The second boolean
  17295. // return value indicates that this field was not set, or was not defined in the
  17296. // schema.
  17297. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  17298. switch name {
  17299. case tutorial.FieldCreatedAt:
  17300. return m.CreatedAt()
  17301. case tutorial.FieldUpdatedAt:
  17302. return m.UpdatedAt()
  17303. case tutorial.FieldDeletedAt:
  17304. return m.DeletedAt()
  17305. case tutorial.FieldEmployeeID:
  17306. return m.EmployeeID()
  17307. case tutorial.FieldIndex:
  17308. return m.Index()
  17309. case tutorial.FieldTitle:
  17310. return m.Title()
  17311. case tutorial.FieldContent:
  17312. return m.Content()
  17313. case tutorial.FieldOrganizationID:
  17314. return m.OrganizationID()
  17315. }
  17316. return nil, false
  17317. }
  17318. // OldField returns the old value of the field from the database. An error is
  17319. // returned if the mutation operation is not UpdateOne, or the query to the
  17320. // database failed.
  17321. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17322. switch name {
  17323. case tutorial.FieldCreatedAt:
  17324. return m.OldCreatedAt(ctx)
  17325. case tutorial.FieldUpdatedAt:
  17326. return m.OldUpdatedAt(ctx)
  17327. case tutorial.FieldDeletedAt:
  17328. return m.OldDeletedAt(ctx)
  17329. case tutorial.FieldEmployeeID:
  17330. return m.OldEmployeeID(ctx)
  17331. case tutorial.FieldIndex:
  17332. return m.OldIndex(ctx)
  17333. case tutorial.FieldTitle:
  17334. return m.OldTitle(ctx)
  17335. case tutorial.FieldContent:
  17336. return m.OldContent(ctx)
  17337. case tutorial.FieldOrganizationID:
  17338. return m.OldOrganizationID(ctx)
  17339. }
  17340. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  17341. }
  17342. // SetField sets the value of a field with the given name. It returns an error if
  17343. // the field is not defined in the schema, or if the type mismatched the field
  17344. // type.
  17345. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  17346. switch name {
  17347. case tutorial.FieldCreatedAt:
  17348. v, ok := value.(time.Time)
  17349. if !ok {
  17350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17351. }
  17352. m.SetCreatedAt(v)
  17353. return nil
  17354. case tutorial.FieldUpdatedAt:
  17355. v, ok := value.(time.Time)
  17356. if !ok {
  17357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17358. }
  17359. m.SetUpdatedAt(v)
  17360. return nil
  17361. case tutorial.FieldDeletedAt:
  17362. v, ok := value.(time.Time)
  17363. if !ok {
  17364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17365. }
  17366. m.SetDeletedAt(v)
  17367. return nil
  17368. case tutorial.FieldEmployeeID:
  17369. v, ok := value.(uint64)
  17370. if !ok {
  17371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17372. }
  17373. m.SetEmployeeID(v)
  17374. return nil
  17375. case tutorial.FieldIndex:
  17376. v, ok := value.(int)
  17377. if !ok {
  17378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17379. }
  17380. m.SetIndex(v)
  17381. return nil
  17382. case tutorial.FieldTitle:
  17383. v, ok := value.(string)
  17384. if !ok {
  17385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17386. }
  17387. m.SetTitle(v)
  17388. return nil
  17389. case tutorial.FieldContent:
  17390. v, ok := value.(string)
  17391. if !ok {
  17392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17393. }
  17394. m.SetContent(v)
  17395. return nil
  17396. case tutorial.FieldOrganizationID:
  17397. v, ok := value.(uint64)
  17398. if !ok {
  17399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17400. }
  17401. m.SetOrganizationID(v)
  17402. return nil
  17403. }
  17404. return fmt.Errorf("unknown Tutorial field %s", name)
  17405. }
  17406. // AddedFields returns all numeric fields that were incremented/decremented during
  17407. // this mutation.
  17408. func (m *TutorialMutation) AddedFields() []string {
  17409. var fields []string
  17410. if m.addindex != nil {
  17411. fields = append(fields, tutorial.FieldIndex)
  17412. }
  17413. if m.addorganization_id != nil {
  17414. fields = append(fields, tutorial.FieldOrganizationID)
  17415. }
  17416. return fields
  17417. }
  17418. // AddedField returns the numeric value that was incremented/decremented on a field
  17419. // with the given name. The second boolean return value indicates that this field
  17420. // was not set, or was not defined in the schema.
  17421. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  17422. switch name {
  17423. case tutorial.FieldIndex:
  17424. return m.AddedIndex()
  17425. case tutorial.FieldOrganizationID:
  17426. return m.AddedOrganizationID()
  17427. }
  17428. return nil, false
  17429. }
  17430. // AddField adds the value to the field with the given name. It returns an error if
  17431. // the field is not defined in the schema, or if the type mismatched the field
  17432. // type.
  17433. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  17434. switch name {
  17435. case tutorial.FieldIndex:
  17436. v, ok := value.(int)
  17437. if !ok {
  17438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17439. }
  17440. m.AddIndex(v)
  17441. return nil
  17442. case tutorial.FieldOrganizationID:
  17443. v, ok := value.(int64)
  17444. if !ok {
  17445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17446. }
  17447. m.AddOrganizationID(v)
  17448. return nil
  17449. }
  17450. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  17451. }
  17452. // ClearedFields returns all nullable fields that were cleared during this
  17453. // mutation.
  17454. func (m *TutorialMutation) ClearedFields() []string {
  17455. var fields []string
  17456. if m.FieldCleared(tutorial.FieldDeletedAt) {
  17457. fields = append(fields, tutorial.FieldDeletedAt)
  17458. }
  17459. return fields
  17460. }
  17461. // FieldCleared returns a boolean indicating if a field with the given name was
  17462. // cleared in this mutation.
  17463. func (m *TutorialMutation) FieldCleared(name string) bool {
  17464. _, ok := m.clearedFields[name]
  17465. return ok
  17466. }
  17467. // ClearField clears the value of the field with the given name. It returns an
  17468. // error if the field is not defined in the schema.
  17469. func (m *TutorialMutation) ClearField(name string) error {
  17470. switch name {
  17471. case tutorial.FieldDeletedAt:
  17472. m.ClearDeletedAt()
  17473. return nil
  17474. }
  17475. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  17476. }
  17477. // ResetField resets all changes in the mutation for the field with the given name.
  17478. // It returns an error if the field is not defined in the schema.
  17479. func (m *TutorialMutation) ResetField(name string) error {
  17480. switch name {
  17481. case tutorial.FieldCreatedAt:
  17482. m.ResetCreatedAt()
  17483. return nil
  17484. case tutorial.FieldUpdatedAt:
  17485. m.ResetUpdatedAt()
  17486. return nil
  17487. case tutorial.FieldDeletedAt:
  17488. m.ResetDeletedAt()
  17489. return nil
  17490. case tutorial.FieldEmployeeID:
  17491. m.ResetEmployeeID()
  17492. return nil
  17493. case tutorial.FieldIndex:
  17494. m.ResetIndex()
  17495. return nil
  17496. case tutorial.FieldTitle:
  17497. m.ResetTitle()
  17498. return nil
  17499. case tutorial.FieldContent:
  17500. m.ResetContent()
  17501. return nil
  17502. case tutorial.FieldOrganizationID:
  17503. m.ResetOrganizationID()
  17504. return nil
  17505. }
  17506. return fmt.Errorf("unknown Tutorial field %s", name)
  17507. }
  17508. // AddedEdges returns all edge names that were set/added in this mutation.
  17509. func (m *TutorialMutation) AddedEdges() []string {
  17510. edges := make([]string, 0, 1)
  17511. if m.employee != nil {
  17512. edges = append(edges, tutorial.EdgeEmployee)
  17513. }
  17514. return edges
  17515. }
  17516. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17517. // name in this mutation.
  17518. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  17519. switch name {
  17520. case tutorial.EdgeEmployee:
  17521. if id := m.employee; id != nil {
  17522. return []ent.Value{*id}
  17523. }
  17524. }
  17525. return nil
  17526. }
  17527. // RemovedEdges returns all edge names that were removed in this mutation.
  17528. func (m *TutorialMutation) RemovedEdges() []string {
  17529. edges := make([]string, 0, 1)
  17530. return edges
  17531. }
  17532. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17533. // the given name in this mutation.
  17534. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  17535. return nil
  17536. }
  17537. // ClearedEdges returns all edge names that were cleared in this mutation.
  17538. func (m *TutorialMutation) ClearedEdges() []string {
  17539. edges := make([]string, 0, 1)
  17540. if m.clearedemployee {
  17541. edges = append(edges, tutorial.EdgeEmployee)
  17542. }
  17543. return edges
  17544. }
  17545. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17546. // was cleared in this mutation.
  17547. func (m *TutorialMutation) EdgeCleared(name string) bool {
  17548. switch name {
  17549. case tutorial.EdgeEmployee:
  17550. return m.clearedemployee
  17551. }
  17552. return false
  17553. }
  17554. // ClearEdge clears the value of the edge with the given name. It returns an error
  17555. // if that edge is not defined in the schema.
  17556. func (m *TutorialMutation) ClearEdge(name string) error {
  17557. switch name {
  17558. case tutorial.EdgeEmployee:
  17559. m.ClearEmployee()
  17560. return nil
  17561. }
  17562. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  17563. }
  17564. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17565. // It returns an error if the edge is not defined in the schema.
  17566. func (m *TutorialMutation) ResetEdge(name string) error {
  17567. switch name {
  17568. case tutorial.EdgeEmployee:
  17569. m.ResetEmployee()
  17570. return nil
  17571. }
  17572. return fmt.Errorf("unknown Tutorial edge %s", name)
  17573. }
  17574. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  17575. type WorkExperienceMutation struct {
  17576. config
  17577. op Op
  17578. typ string
  17579. id *uint64
  17580. created_at *time.Time
  17581. updated_at *time.Time
  17582. deleted_at *time.Time
  17583. start_date *time.Time
  17584. end_date *time.Time
  17585. company *string
  17586. experience *string
  17587. organization_id *uint64
  17588. addorganization_id *int64
  17589. clearedFields map[string]struct{}
  17590. employee *uint64
  17591. clearedemployee bool
  17592. done bool
  17593. oldValue func(context.Context) (*WorkExperience, error)
  17594. predicates []predicate.WorkExperience
  17595. }
  17596. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  17597. // workexperienceOption allows management of the mutation configuration using functional options.
  17598. type workexperienceOption func(*WorkExperienceMutation)
  17599. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  17600. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  17601. m := &WorkExperienceMutation{
  17602. config: c,
  17603. op: op,
  17604. typ: TypeWorkExperience,
  17605. clearedFields: make(map[string]struct{}),
  17606. }
  17607. for _, opt := range opts {
  17608. opt(m)
  17609. }
  17610. return m
  17611. }
  17612. // withWorkExperienceID sets the ID field of the mutation.
  17613. func withWorkExperienceID(id uint64) workexperienceOption {
  17614. return func(m *WorkExperienceMutation) {
  17615. var (
  17616. err error
  17617. once sync.Once
  17618. value *WorkExperience
  17619. )
  17620. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  17621. once.Do(func() {
  17622. if m.done {
  17623. err = errors.New("querying old values post mutation is not allowed")
  17624. } else {
  17625. value, err = m.Client().WorkExperience.Get(ctx, id)
  17626. }
  17627. })
  17628. return value, err
  17629. }
  17630. m.id = &id
  17631. }
  17632. }
  17633. // withWorkExperience sets the old WorkExperience of the mutation.
  17634. func withWorkExperience(node *WorkExperience) workexperienceOption {
  17635. return func(m *WorkExperienceMutation) {
  17636. m.oldValue = func(context.Context) (*WorkExperience, error) {
  17637. return node, nil
  17638. }
  17639. m.id = &node.ID
  17640. }
  17641. }
  17642. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17643. // executed in a transaction (ent.Tx), a transactional client is returned.
  17644. func (m WorkExperienceMutation) Client() *Client {
  17645. client := &Client{config: m.config}
  17646. client.init()
  17647. return client
  17648. }
  17649. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17650. // it returns an error otherwise.
  17651. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  17652. if _, ok := m.driver.(*txDriver); !ok {
  17653. return nil, errors.New("ent: mutation is not running in a transaction")
  17654. }
  17655. tx := &Tx{config: m.config}
  17656. tx.init()
  17657. return tx, nil
  17658. }
  17659. // SetID sets the value of the id field. Note that this
  17660. // operation is only accepted on creation of WorkExperience entities.
  17661. func (m *WorkExperienceMutation) SetID(id uint64) {
  17662. m.id = &id
  17663. }
  17664. // ID returns the ID value in the mutation. Note that the ID is only available
  17665. // if it was provided to the builder or after it was returned from the database.
  17666. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  17667. if m.id == nil {
  17668. return
  17669. }
  17670. return *m.id, true
  17671. }
  17672. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17673. // That means, if the mutation is applied within a transaction with an isolation level such
  17674. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17675. // or updated by the mutation.
  17676. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  17677. switch {
  17678. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17679. id, exists := m.ID()
  17680. if exists {
  17681. return []uint64{id}, nil
  17682. }
  17683. fallthrough
  17684. case m.op.Is(OpUpdate | OpDelete):
  17685. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  17686. default:
  17687. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17688. }
  17689. }
  17690. // SetCreatedAt sets the "created_at" field.
  17691. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  17692. m.created_at = &t
  17693. }
  17694. // CreatedAt returns the value of the "created_at" field in the mutation.
  17695. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  17696. v := m.created_at
  17697. if v == nil {
  17698. return
  17699. }
  17700. return *v, true
  17701. }
  17702. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  17703. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17705. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17706. if !m.op.Is(OpUpdateOne) {
  17707. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17708. }
  17709. if m.id == nil || m.oldValue == nil {
  17710. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17711. }
  17712. oldValue, err := m.oldValue(ctx)
  17713. if err != nil {
  17714. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17715. }
  17716. return oldValue.CreatedAt, nil
  17717. }
  17718. // ResetCreatedAt resets all changes to the "created_at" field.
  17719. func (m *WorkExperienceMutation) ResetCreatedAt() {
  17720. m.created_at = nil
  17721. }
  17722. // SetUpdatedAt sets the "updated_at" field.
  17723. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  17724. m.updated_at = &t
  17725. }
  17726. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17727. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  17728. v := m.updated_at
  17729. if v == nil {
  17730. return
  17731. }
  17732. return *v, true
  17733. }
  17734. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  17735. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17737. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17738. if !m.op.Is(OpUpdateOne) {
  17739. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17740. }
  17741. if m.id == nil || m.oldValue == nil {
  17742. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17743. }
  17744. oldValue, err := m.oldValue(ctx)
  17745. if err != nil {
  17746. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17747. }
  17748. return oldValue.UpdatedAt, nil
  17749. }
  17750. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17751. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  17752. m.updated_at = nil
  17753. }
  17754. // SetDeletedAt sets the "deleted_at" field.
  17755. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  17756. m.deleted_at = &t
  17757. }
  17758. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17759. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  17760. v := m.deleted_at
  17761. if v == nil {
  17762. return
  17763. }
  17764. return *v, true
  17765. }
  17766. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  17767. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17768. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17769. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17770. if !m.op.Is(OpUpdateOne) {
  17771. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17772. }
  17773. if m.id == nil || m.oldValue == nil {
  17774. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17775. }
  17776. oldValue, err := m.oldValue(ctx)
  17777. if err != nil {
  17778. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17779. }
  17780. return oldValue.DeletedAt, nil
  17781. }
  17782. // ClearDeletedAt clears the value of the "deleted_at" field.
  17783. func (m *WorkExperienceMutation) ClearDeletedAt() {
  17784. m.deleted_at = nil
  17785. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  17786. }
  17787. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17788. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  17789. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  17790. return ok
  17791. }
  17792. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17793. func (m *WorkExperienceMutation) ResetDeletedAt() {
  17794. m.deleted_at = nil
  17795. delete(m.clearedFields, workexperience.FieldDeletedAt)
  17796. }
  17797. // SetEmployeeID sets the "employee_id" field.
  17798. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  17799. m.employee = &u
  17800. }
  17801. // EmployeeID returns the value of the "employee_id" field in the mutation.
  17802. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  17803. v := m.employee
  17804. if v == nil {
  17805. return
  17806. }
  17807. return *v, true
  17808. }
  17809. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  17810. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17812. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  17813. if !m.op.Is(OpUpdateOne) {
  17814. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  17815. }
  17816. if m.id == nil || m.oldValue == nil {
  17817. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  17818. }
  17819. oldValue, err := m.oldValue(ctx)
  17820. if err != nil {
  17821. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  17822. }
  17823. return oldValue.EmployeeID, nil
  17824. }
  17825. // ResetEmployeeID resets all changes to the "employee_id" field.
  17826. func (m *WorkExperienceMutation) ResetEmployeeID() {
  17827. m.employee = nil
  17828. }
  17829. // SetStartDate sets the "start_date" field.
  17830. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  17831. m.start_date = &t
  17832. }
  17833. // StartDate returns the value of the "start_date" field in the mutation.
  17834. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  17835. v := m.start_date
  17836. if v == nil {
  17837. return
  17838. }
  17839. return *v, true
  17840. }
  17841. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  17842. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17844. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  17845. if !m.op.Is(OpUpdateOne) {
  17846. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  17847. }
  17848. if m.id == nil || m.oldValue == nil {
  17849. return v, errors.New("OldStartDate requires an ID field in the mutation")
  17850. }
  17851. oldValue, err := m.oldValue(ctx)
  17852. if err != nil {
  17853. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  17854. }
  17855. return oldValue.StartDate, nil
  17856. }
  17857. // ResetStartDate resets all changes to the "start_date" field.
  17858. func (m *WorkExperienceMutation) ResetStartDate() {
  17859. m.start_date = nil
  17860. }
  17861. // SetEndDate sets the "end_date" field.
  17862. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  17863. m.end_date = &t
  17864. }
  17865. // EndDate returns the value of the "end_date" field in the mutation.
  17866. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  17867. v := m.end_date
  17868. if v == nil {
  17869. return
  17870. }
  17871. return *v, true
  17872. }
  17873. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  17874. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17876. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  17877. if !m.op.Is(OpUpdateOne) {
  17878. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  17879. }
  17880. if m.id == nil || m.oldValue == nil {
  17881. return v, errors.New("OldEndDate requires an ID field in the mutation")
  17882. }
  17883. oldValue, err := m.oldValue(ctx)
  17884. if err != nil {
  17885. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  17886. }
  17887. return oldValue.EndDate, nil
  17888. }
  17889. // ResetEndDate resets all changes to the "end_date" field.
  17890. func (m *WorkExperienceMutation) ResetEndDate() {
  17891. m.end_date = nil
  17892. }
  17893. // SetCompany sets the "company" field.
  17894. func (m *WorkExperienceMutation) SetCompany(s string) {
  17895. m.company = &s
  17896. }
  17897. // Company returns the value of the "company" field in the mutation.
  17898. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  17899. v := m.company
  17900. if v == nil {
  17901. return
  17902. }
  17903. return *v, true
  17904. }
  17905. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  17906. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17908. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  17909. if !m.op.Is(OpUpdateOne) {
  17910. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  17911. }
  17912. if m.id == nil || m.oldValue == nil {
  17913. return v, errors.New("OldCompany requires an ID field in the mutation")
  17914. }
  17915. oldValue, err := m.oldValue(ctx)
  17916. if err != nil {
  17917. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  17918. }
  17919. return oldValue.Company, nil
  17920. }
  17921. // ResetCompany resets all changes to the "company" field.
  17922. func (m *WorkExperienceMutation) ResetCompany() {
  17923. m.company = nil
  17924. }
  17925. // SetExperience sets the "experience" field.
  17926. func (m *WorkExperienceMutation) SetExperience(s string) {
  17927. m.experience = &s
  17928. }
  17929. // Experience returns the value of the "experience" field in the mutation.
  17930. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  17931. v := m.experience
  17932. if v == nil {
  17933. return
  17934. }
  17935. return *v, true
  17936. }
  17937. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  17938. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17940. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  17941. if !m.op.Is(OpUpdateOne) {
  17942. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  17943. }
  17944. if m.id == nil || m.oldValue == nil {
  17945. return v, errors.New("OldExperience requires an ID field in the mutation")
  17946. }
  17947. oldValue, err := m.oldValue(ctx)
  17948. if err != nil {
  17949. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  17950. }
  17951. return oldValue.Experience, nil
  17952. }
  17953. // ResetExperience resets all changes to the "experience" field.
  17954. func (m *WorkExperienceMutation) ResetExperience() {
  17955. m.experience = nil
  17956. }
  17957. // SetOrganizationID sets the "organization_id" field.
  17958. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  17959. m.organization_id = &u
  17960. m.addorganization_id = nil
  17961. }
  17962. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17963. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  17964. v := m.organization_id
  17965. if v == nil {
  17966. return
  17967. }
  17968. return *v, true
  17969. }
  17970. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  17971. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17973. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17974. if !m.op.Is(OpUpdateOne) {
  17975. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17976. }
  17977. if m.id == nil || m.oldValue == nil {
  17978. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17979. }
  17980. oldValue, err := m.oldValue(ctx)
  17981. if err != nil {
  17982. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17983. }
  17984. return oldValue.OrganizationID, nil
  17985. }
  17986. // AddOrganizationID adds u to the "organization_id" field.
  17987. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  17988. if m.addorganization_id != nil {
  17989. *m.addorganization_id += u
  17990. } else {
  17991. m.addorganization_id = &u
  17992. }
  17993. }
  17994. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17995. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  17996. v := m.addorganization_id
  17997. if v == nil {
  17998. return
  17999. }
  18000. return *v, true
  18001. }
  18002. // ResetOrganizationID resets all changes to the "organization_id" field.
  18003. func (m *WorkExperienceMutation) ResetOrganizationID() {
  18004. m.organization_id = nil
  18005. m.addorganization_id = nil
  18006. }
  18007. // ClearEmployee clears the "employee" edge to the Employee entity.
  18008. func (m *WorkExperienceMutation) ClearEmployee() {
  18009. m.clearedemployee = true
  18010. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  18011. }
  18012. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  18013. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  18014. return m.clearedemployee
  18015. }
  18016. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  18017. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18018. // EmployeeID instead. It exists only for internal usage by the builders.
  18019. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  18020. if id := m.employee; id != nil {
  18021. ids = append(ids, *id)
  18022. }
  18023. return
  18024. }
  18025. // ResetEmployee resets all changes to the "employee" edge.
  18026. func (m *WorkExperienceMutation) ResetEmployee() {
  18027. m.employee = nil
  18028. m.clearedemployee = false
  18029. }
  18030. // Where appends a list predicates to the WorkExperienceMutation builder.
  18031. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  18032. m.predicates = append(m.predicates, ps...)
  18033. }
  18034. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  18035. // users can use type-assertion to append predicates that do not depend on any generated package.
  18036. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  18037. p := make([]predicate.WorkExperience, len(ps))
  18038. for i := range ps {
  18039. p[i] = ps[i]
  18040. }
  18041. m.Where(p...)
  18042. }
  18043. // Op returns the operation name.
  18044. func (m *WorkExperienceMutation) Op() Op {
  18045. return m.op
  18046. }
  18047. // SetOp allows setting the mutation operation.
  18048. func (m *WorkExperienceMutation) SetOp(op Op) {
  18049. m.op = op
  18050. }
  18051. // Type returns the node type of this mutation (WorkExperience).
  18052. func (m *WorkExperienceMutation) Type() string {
  18053. return m.typ
  18054. }
  18055. // Fields returns all fields that were changed during this mutation. Note that in
  18056. // order to get all numeric fields that were incremented/decremented, call
  18057. // AddedFields().
  18058. func (m *WorkExperienceMutation) Fields() []string {
  18059. fields := make([]string, 0, 9)
  18060. if m.created_at != nil {
  18061. fields = append(fields, workexperience.FieldCreatedAt)
  18062. }
  18063. if m.updated_at != nil {
  18064. fields = append(fields, workexperience.FieldUpdatedAt)
  18065. }
  18066. if m.deleted_at != nil {
  18067. fields = append(fields, workexperience.FieldDeletedAt)
  18068. }
  18069. if m.employee != nil {
  18070. fields = append(fields, workexperience.FieldEmployeeID)
  18071. }
  18072. if m.start_date != nil {
  18073. fields = append(fields, workexperience.FieldStartDate)
  18074. }
  18075. if m.end_date != nil {
  18076. fields = append(fields, workexperience.FieldEndDate)
  18077. }
  18078. if m.company != nil {
  18079. fields = append(fields, workexperience.FieldCompany)
  18080. }
  18081. if m.experience != nil {
  18082. fields = append(fields, workexperience.FieldExperience)
  18083. }
  18084. if m.organization_id != nil {
  18085. fields = append(fields, workexperience.FieldOrganizationID)
  18086. }
  18087. return fields
  18088. }
  18089. // Field returns the value of a field with the given name. The second boolean
  18090. // return value indicates that this field was not set, or was not defined in the
  18091. // schema.
  18092. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  18093. switch name {
  18094. case workexperience.FieldCreatedAt:
  18095. return m.CreatedAt()
  18096. case workexperience.FieldUpdatedAt:
  18097. return m.UpdatedAt()
  18098. case workexperience.FieldDeletedAt:
  18099. return m.DeletedAt()
  18100. case workexperience.FieldEmployeeID:
  18101. return m.EmployeeID()
  18102. case workexperience.FieldStartDate:
  18103. return m.StartDate()
  18104. case workexperience.FieldEndDate:
  18105. return m.EndDate()
  18106. case workexperience.FieldCompany:
  18107. return m.Company()
  18108. case workexperience.FieldExperience:
  18109. return m.Experience()
  18110. case workexperience.FieldOrganizationID:
  18111. return m.OrganizationID()
  18112. }
  18113. return nil, false
  18114. }
  18115. // OldField returns the old value of the field from the database. An error is
  18116. // returned if the mutation operation is not UpdateOne, or the query to the
  18117. // database failed.
  18118. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18119. switch name {
  18120. case workexperience.FieldCreatedAt:
  18121. return m.OldCreatedAt(ctx)
  18122. case workexperience.FieldUpdatedAt:
  18123. return m.OldUpdatedAt(ctx)
  18124. case workexperience.FieldDeletedAt:
  18125. return m.OldDeletedAt(ctx)
  18126. case workexperience.FieldEmployeeID:
  18127. return m.OldEmployeeID(ctx)
  18128. case workexperience.FieldStartDate:
  18129. return m.OldStartDate(ctx)
  18130. case workexperience.FieldEndDate:
  18131. return m.OldEndDate(ctx)
  18132. case workexperience.FieldCompany:
  18133. return m.OldCompany(ctx)
  18134. case workexperience.FieldExperience:
  18135. return m.OldExperience(ctx)
  18136. case workexperience.FieldOrganizationID:
  18137. return m.OldOrganizationID(ctx)
  18138. }
  18139. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  18140. }
  18141. // SetField sets the value of a field with the given name. It returns an error if
  18142. // the field is not defined in the schema, or if the type mismatched the field
  18143. // type.
  18144. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  18145. switch name {
  18146. case workexperience.FieldCreatedAt:
  18147. v, ok := value.(time.Time)
  18148. if !ok {
  18149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18150. }
  18151. m.SetCreatedAt(v)
  18152. return nil
  18153. case workexperience.FieldUpdatedAt:
  18154. v, ok := value.(time.Time)
  18155. if !ok {
  18156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18157. }
  18158. m.SetUpdatedAt(v)
  18159. return nil
  18160. case workexperience.FieldDeletedAt:
  18161. v, ok := value.(time.Time)
  18162. if !ok {
  18163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18164. }
  18165. m.SetDeletedAt(v)
  18166. return nil
  18167. case workexperience.FieldEmployeeID:
  18168. v, ok := value.(uint64)
  18169. if !ok {
  18170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18171. }
  18172. m.SetEmployeeID(v)
  18173. return nil
  18174. case workexperience.FieldStartDate:
  18175. v, ok := value.(time.Time)
  18176. if !ok {
  18177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18178. }
  18179. m.SetStartDate(v)
  18180. return nil
  18181. case workexperience.FieldEndDate:
  18182. v, ok := value.(time.Time)
  18183. if !ok {
  18184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18185. }
  18186. m.SetEndDate(v)
  18187. return nil
  18188. case workexperience.FieldCompany:
  18189. v, ok := value.(string)
  18190. if !ok {
  18191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18192. }
  18193. m.SetCompany(v)
  18194. return nil
  18195. case workexperience.FieldExperience:
  18196. v, ok := value.(string)
  18197. if !ok {
  18198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18199. }
  18200. m.SetExperience(v)
  18201. return nil
  18202. case workexperience.FieldOrganizationID:
  18203. v, ok := value.(uint64)
  18204. if !ok {
  18205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18206. }
  18207. m.SetOrganizationID(v)
  18208. return nil
  18209. }
  18210. return fmt.Errorf("unknown WorkExperience field %s", name)
  18211. }
  18212. // AddedFields returns all numeric fields that were incremented/decremented during
  18213. // this mutation.
  18214. func (m *WorkExperienceMutation) AddedFields() []string {
  18215. var fields []string
  18216. if m.addorganization_id != nil {
  18217. fields = append(fields, workexperience.FieldOrganizationID)
  18218. }
  18219. return fields
  18220. }
  18221. // AddedField returns the numeric value that was incremented/decremented on a field
  18222. // with the given name. The second boolean return value indicates that this field
  18223. // was not set, or was not defined in the schema.
  18224. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  18225. switch name {
  18226. case workexperience.FieldOrganizationID:
  18227. return m.AddedOrganizationID()
  18228. }
  18229. return nil, false
  18230. }
  18231. // AddField adds the value to the field with the given name. It returns an error if
  18232. // the field is not defined in the schema, or if the type mismatched the field
  18233. // type.
  18234. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  18235. switch name {
  18236. case workexperience.FieldOrganizationID:
  18237. v, ok := value.(int64)
  18238. if !ok {
  18239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18240. }
  18241. m.AddOrganizationID(v)
  18242. return nil
  18243. }
  18244. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  18245. }
  18246. // ClearedFields returns all nullable fields that were cleared during this
  18247. // mutation.
  18248. func (m *WorkExperienceMutation) ClearedFields() []string {
  18249. var fields []string
  18250. if m.FieldCleared(workexperience.FieldDeletedAt) {
  18251. fields = append(fields, workexperience.FieldDeletedAt)
  18252. }
  18253. return fields
  18254. }
  18255. // FieldCleared returns a boolean indicating if a field with the given name was
  18256. // cleared in this mutation.
  18257. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  18258. _, ok := m.clearedFields[name]
  18259. return ok
  18260. }
  18261. // ClearField clears the value of the field with the given name. It returns an
  18262. // error if the field is not defined in the schema.
  18263. func (m *WorkExperienceMutation) ClearField(name string) error {
  18264. switch name {
  18265. case workexperience.FieldDeletedAt:
  18266. m.ClearDeletedAt()
  18267. return nil
  18268. }
  18269. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  18270. }
  18271. // ResetField resets all changes in the mutation for the field with the given name.
  18272. // It returns an error if the field is not defined in the schema.
  18273. func (m *WorkExperienceMutation) ResetField(name string) error {
  18274. switch name {
  18275. case workexperience.FieldCreatedAt:
  18276. m.ResetCreatedAt()
  18277. return nil
  18278. case workexperience.FieldUpdatedAt:
  18279. m.ResetUpdatedAt()
  18280. return nil
  18281. case workexperience.FieldDeletedAt:
  18282. m.ResetDeletedAt()
  18283. return nil
  18284. case workexperience.FieldEmployeeID:
  18285. m.ResetEmployeeID()
  18286. return nil
  18287. case workexperience.FieldStartDate:
  18288. m.ResetStartDate()
  18289. return nil
  18290. case workexperience.FieldEndDate:
  18291. m.ResetEndDate()
  18292. return nil
  18293. case workexperience.FieldCompany:
  18294. m.ResetCompany()
  18295. return nil
  18296. case workexperience.FieldExperience:
  18297. m.ResetExperience()
  18298. return nil
  18299. case workexperience.FieldOrganizationID:
  18300. m.ResetOrganizationID()
  18301. return nil
  18302. }
  18303. return fmt.Errorf("unknown WorkExperience field %s", name)
  18304. }
  18305. // AddedEdges returns all edge names that were set/added in this mutation.
  18306. func (m *WorkExperienceMutation) AddedEdges() []string {
  18307. edges := make([]string, 0, 1)
  18308. if m.employee != nil {
  18309. edges = append(edges, workexperience.EdgeEmployee)
  18310. }
  18311. return edges
  18312. }
  18313. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18314. // name in this mutation.
  18315. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  18316. switch name {
  18317. case workexperience.EdgeEmployee:
  18318. if id := m.employee; id != nil {
  18319. return []ent.Value{*id}
  18320. }
  18321. }
  18322. return nil
  18323. }
  18324. // RemovedEdges returns all edge names that were removed in this mutation.
  18325. func (m *WorkExperienceMutation) RemovedEdges() []string {
  18326. edges := make([]string, 0, 1)
  18327. return edges
  18328. }
  18329. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18330. // the given name in this mutation.
  18331. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  18332. return nil
  18333. }
  18334. // ClearedEdges returns all edge names that were cleared in this mutation.
  18335. func (m *WorkExperienceMutation) ClearedEdges() []string {
  18336. edges := make([]string, 0, 1)
  18337. if m.clearedemployee {
  18338. edges = append(edges, workexperience.EdgeEmployee)
  18339. }
  18340. return edges
  18341. }
  18342. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18343. // was cleared in this mutation.
  18344. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  18345. switch name {
  18346. case workexperience.EdgeEmployee:
  18347. return m.clearedemployee
  18348. }
  18349. return false
  18350. }
  18351. // ClearEdge clears the value of the edge with the given name. It returns an error
  18352. // if that edge is not defined in the schema.
  18353. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  18354. switch name {
  18355. case workexperience.EdgeEmployee:
  18356. m.ClearEmployee()
  18357. return nil
  18358. }
  18359. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  18360. }
  18361. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18362. // It returns an error if the edge is not defined in the schema.
  18363. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  18364. switch name {
  18365. case workexperience.EdgeEmployee:
  18366. m.ResetEmployee()
  18367. return nil
  18368. }
  18369. return fmt.Errorf("unknown WorkExperience edge %s", name)
  18370. }
  18371. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  18372. type WxMutation struct {
  18373. config
  18374. op Op
  18375. typ string
  18376. id *uint64
  18377. created_at *time.Time
  18378. updated_at *time.Time
  18379. status *uint8
  18380. addstatus *int8
  18381. deleted_at *time.Time
  18382. port *string
  18383. process_id *string
  18384. callback *string
  18385. wxid *string
  18386. account *string
  18387. nickname *string
  18388. tel *string
  18389. head_big *string
  18390. organization_id *uint64
  18391. addorganization_id *int64
  18392. api_base *string
  18393. api_key *string
  18394. allow_list *[]string
  18395. appendallow_list []string
  18396. group_allow_list *[]string
  18397. appendgroup_allow_list []string
  18398. block_list *[]string
  18399. appendblock_list []string
  18400. group_block_list *[]string
  18401. appendgroup_block_list []string
  18402. clearedFields map[string]struct{}
  18403. server *uint64
  18404. clearedserver bool
  18405. agent *uint64
  18406. clearedagent bool
  18407. done bool
  18408. oldValue func(context.Context) (*Wx, error)
  18409. predicates []predicate.Wx
  18410. }
  18411. var _ ent.Mutation = (*WxMutation)(nil)
  18412. // wxOption allows management of the mutation configuration using functional options.
  18413. type wxOption func(*WxMutation)
  18414. // newWxMutation creates new mutation for the Wx entity.
  18415. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  18416. m := &WxMutation{
  18417. config: c,
  18418. op: op,
  18419. typ: TypeWx,
  18420. clearedFields: make(map[string]struct{}),
  18421. }
  18422. for _, opt := range opts {
  18423. opt(m)
  18424. }
  18425. return m
  18426. }
  18427. // withWxID sets the ID field of the mutation.
  18428. func withWxID(id uint64) wxOption {
  18429. return func(m *WxMutation) {
  18430. var (
  18431. err error
  18432. once sync.Once
  18433. value *Wx
  18434. )
  18435. m.oldValue = func(ctx context.Context) (*Wx, error) {
  18436. once.Do(func() {
  18437. if m.done {
  18438. err = errors.New("querying old values post mutation is not allowed")
  18439. } else {
  18440. value, err = m.Client().Wx.Get(ctx, id)
  18441. }
  18442. })
  18443. return value, err
  18444. }
  18445. m.id = &id
  18446. }
  18447. }
  18448. // withWx sets the old Wx of the mutation.
  18449. func withWx(node *Wx) wxOption {
  18450. return func(m *WxMutation) {
  18451. m.oldValue = func(context.Context) (*Wx, error) {
  18452. return node, nil
  18453. }
  18454. m.id = &node.ID
  18455. }
  18456. }
  18457. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18458. // executed in a transaction (ent.Tx), a transactional client is returned.
  18459. func (m WxMutation) Client() *Client {
  18460. client := &Client{config: m.config}
  18461. client.init()
  18462. return client
  18463. }
  18464. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18465. // it returns an error otherwise.
  18466. func (m WxMutation) Tx() (*Tx, error) {
  18467. if _, ok := m.driver.(*txDriver); !ok {
  18468. return nil, errors.New("ent: mutation is not running in a transaction")
  18469. }
  18470. tx := &Tx{config: m.config}
  18471. tx.init()
  18472. return tx, nil
  18473. }
  18474. // SetID sets the value of the id field. Note that this
  18475. // operation is only accepted on creation of Wx entities.
  18476. func (m *WxMutation) SetID(id uint64) {
  18477. m.id = &id
  18478. }
  18479. // ID returns the ID value in the mutation. Note that the ID is only available
  18480. // if it was provided to the builder or after it was returned from the database.
  18481. func (m *WxMutation) ID() (id uint64, exists bool) {
  18482. if m.id == nil {
  18483. return
  18484. }
  18485. return *m.id, true
  18486. }
  18487. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18488. // That means, if the mutation is applied within a transaction with an isolation level such
  18489. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18490. // or updated by the mutation.
  18491. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  18492. switch {
  18493. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18494. id, exists := m.ID()
  18495. if exists {
  18496. return []uint64{id}, nil
  18497. }
  18498. fallthrough
  18499. case m.op.Is(OpUpdate | OpDelete):
  18500. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  18501. default:
  18502. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18503. }
  18504. }
  18505. // SetCreatedAt sets the "created_at" field.
  18506. func (m *WxMutation) SetCreatedAt(t time.Time) {
  18507. m.created_at = &t
  18508. }
  18509. // CreatedAt returns the value of the "created_at" field in the mutation.
  18510. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  18511. v := m.created_at
  18512. if v == nil {
  18513. return
  18514. }
  18515. return *v, true
  18516. }
  18517. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  18518. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18520. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18521. if !m.op.Is(OpUpdateOne) {
  18522. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18523. }
  18524. if m.id == nil || m.oldValue == nil {
  18525. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18526. }
  18527. oldValue, err := m.oldValue(ctx)
  18528. if err != nil {
  18529. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18530. }
  18531. return oldValue.CreatedAt, nil
  18532. }
  18533. // ResetCreatedAt resets all changes to the "created_at" field.
  18534. func (m *WxMutation) ResetCreatedAt() {
  18535. m.created_at = nil
  18536. }
  18537. // SetUpdatedAt sets the "updated_at" field.
  18538. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  18539. m.updated_at = &t
  18540. }
  18541. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18542. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  18543. v := m.updated_at
  18544. if v == nil {
  18545. return
  18546. }
  18547. return *v, true
  18548. }
  18549. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  18550. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18552. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18553. if !m.op.Is(OpUpdateOne) {
  18554. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18555. }
  18556. if m.id == nil || m.oldValue == nil {
  18557. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18558. }
  18559. oldValue, err := m.oldValue(ctx)
  18560. if err != nil {
  18561. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18562. }
  18563. return oldValue.UpdatedAt, nil
  18564. }
  18565. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18566. func (m *WxMutation) ResetUpdatedAt() {
  18567. m.updated_at = nil
  18568. }
  18569. // SetStatus sets the "status" field.
  18570. func (m *WxMutation) SetStatus(u uint8) {
  18571. m.status = &u
  18572. m.addstatus = nil
  18573. }
  18574. // Status returns the value of the "status" field in the mutation.
  18575. func (m *WxMutation) Status() (r uint8, exists bool) {
  18576. v := m.status
  18577. if v == nil {
  18578. return
  18579. }
  18580. return *v, true
  18581. }
  18582. // OldStatus returns the old "status" field's value of the Wx entity.
  18583. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18585. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18586. if !m.op.Is(OpUpdateOne) {
  18587. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18588. }
  18589. if m.id == nil || m.oldValue == nil {
  18590. return v, errors.New("OldStatus requires an ID field in the mutation")
  18591. }
  18592. oldValue, err := m.oldValue(ctx)
  18593. if err != nil {
  18594. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18595. }
  18596. return oldValue.Status, nil
  18597. }
  18598. // AddStatus adds u to the "status" field.
  18599. func (m *WxMutation) AddStatus(u int8) {
  18600. if m.addstatus != nil {
  18601. *m.addstatus += u
  18602. } else {
  18603. m.addstatus = &u
  18604. }
  18605. }
  18606. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18607. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  18608. v := m.addstatus
  18609. if v == nil {
  18610. return
  18611. }
  18612. return *v, true
  18613. }
  18614. // ClearStatus clears the value of the "status" field.
  18615. func (m *WxMutation) ClearStatus() {
  18616. m.status = nil
  18617. m.addstatus = nil
  18618. m.clearedFields[wx.FieldStatus] = struct{}{}
  18619. }
  18620. // StatusCleared returns if the "status" field was cleared in this mutation.
  18621. func (m *WxMutation) StatusCleared() bool {
  18622. _, ok := m.clearedFields[wx.FieldStatus]
  18623. return ok
  18624. }
  18625. // ResetStatus resets all changes to the "status" field.
  18626. func (m *WxMutation) ResetStatus() {
  18627. m.status = nil
  18628. m.addstatus = nil
  18629. delete(m.clearedFields, wx.FieldStatus)
  18630. }
  18631. // SetDeletedAt sets the "deleted_at" field.
  18632. func (m *WxMutation) SetDeletedAt(t time.Time) {
  18633. m.deleted_at = &t
  18634. }
  18635. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18636. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  18637. v := m.deleted_at
  18638. if v == nil {
  18639. return
  18640. }
  18641. return *v, true
  18642. }
  18643. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  18644. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18646. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18647. if !m.op.Is(OpUpdateOne) {
  18648. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18649. }
  18650. if m.id == nil || m.oldValue == nil {
  18651. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18652. }
  18653. oldValue, err := m.oldValue(ctx)
  18654. if err != nil {
  18655. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18656. }
  18657. return oldValue.DeletedAt, nil
  18658. }
  18659. // ClearDeletedAt clears the value of the "deleted_at" field.
  18660. func (m *WxMutation) ClearDeletedAt() {
  18661. m.deleted_at = nil
  18662. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  18663. }
  18664. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18665. func (m *WxMutation) DeletedAtCleared() bool {
  18666. _, ok := m.clearedFields[wx.FieldDeletedAt]
  18667. return ok
  18668. }
  18669. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18670. func (m *WxMutation) ResetDeletedAt() {
  18671. m.deleted_at = nil
  18672. delete(m.clearedFields, wx.FieldDeletedAt)
  18673. }
  18674. // SetServerID sets the "server_id" field.
  18675. func (m *WxMutation) SetServerID(u uint64) {
  18676. m.server = &u
  18677. }
  18678. // ServerID returns the value of the "server_id" field in the mutation.
  18679. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  18680. v := m.server
  18681. if v == nil {
  18682. return
  18683. }
  18684. return *v, true
  18685. }
  18686. // OldServerID returns the old "server_id" field's value of the Wx entity.
  18687. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18689. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  18690. if !m.op.Is(OpUpdateOne) {
  18691. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  18692. }
  18693. if m.id == nil || m.oldValue == nil {
  18694. return v, errors.New("OldServerID requires an ID field in the mutation")
  18695. }
  18696. oldValue, err := m.oldValue(ctx)
  18697. if err != nil {
  18698. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  18699. }
  18700. return oldValue.ServerID, nil
  18701. }
  18702. // ClearServerID clears the value of the "server_id" field.
  18703. func (m *WxMutation) ClearServerID() {
  18704. m.server = nil
  18705. m.clearedFields[wx.FieldServerID] = struct{}{}
  18706. }
  18707. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  18708. func (m *WxMutation) ServerIDCleared() bool {
  18709. _, ok := m.clearedFields[wx.FieldServerID]
  18710. return ok
  18711. }
  18712. // ResetServerID resets all changes to the "server_id" field.
  18713. func (m *WxMutation) ResetServerID() {
  18714. m.server = nil
  18715. delete(m.clearedFields, wx.FieldServerID)
  18716. }
  18717. // SetPort sets the "port" field.
  18718. func (m *WxMutation) SetPort(s string) {
  18719. m.port = &s
  18720. }
  18721. // Port returns the value of the "port" field in the mutation.
  18722. func (m *WxMutation) Port() (r string, exists bool) {
  18723. v := m.port
  18724. if v == nil {
  18725. return
  18726. }
  18727. return *v, true
  18728. }
  18729. // OldPort returns the old "port" field's value of the Wx entity.
  18730. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18732. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  18733. if !m.op.Is(OpUpdateOne) {
  18734. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  18735. }
  18736. if m.id == nil || m.oldValue == nil {
  18737. return v, errors.New("OldPort requires an ID field in the mutation")
  18738. }
  18739. oldValue, err := m.oldValue(ctx)
  18740. if err != nil {
  18741. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  18742. }
  18743. return oldValue.Port, nil
  18744. }
  18745. // ResetPort resets all changes to the "port" field.
  18746. func (m *WxMutation) ResetPort() {
  18747. m.port = nil
  18748. }
  18749. // SetProcessID sets the "process_id" field.
  18750. func (m *WxMutation) SetProcessID(s string) {
  18751. m.process_id = &s
  18752. }
  18753. // ProcessID returns the value of the "process_id" field in the mutation.
  18754. func (m *WxMutation) ProcessID() (r string, exists bool) {
  18755. v := m.process_id
  18756. if v == nil {
  18757. return
  18758. }
  18759. return *v, true
  18760. }
  18761. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  18762. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18764. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  18765. if !m.op.Is(OpUpdateOne) {
  18766. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  18767. }
  18768. if m.id == nil || m.oldValue == nil {
  18769. return v, errors.New("OldProcessID requires an ID field in the mutation")
  18770. }
  18771. oldValue, err := m.oldValue(ctx)
  18772. if err != nil {
  18773. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  18774. }
  18775. return oldValue.ProcessID, nil
  18776. }
  18777. // ResetProcessID resets all changes to the "process_id" field.
  18778. func (m *WxMutation) ResetProcessID() {
  18779. m.process_id = nil
  18780. }
  18781. // SetCallback sets the "callback" field.
  18782. func (m *WxMutation) SetCallback(s string) {
  18783. m.callback = &s
  18784. }
  18785. // Callback returns the value of the "callback" field in the mutation.
  18786. func (m *WxMutation) Callback() (r string, exists bool) {
  18787. v := m.callback
  18788. if v == nil {
  18789. return
  18790. }
  18791. return *v, true
  18792. }
  18793. // OldCallback returns the old "callback" field's value of the Wx entity.
  18794. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18796. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  18797. if !m.op.Is(OpUpdateOne) {
  18798. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  18799. }
  18800. if m.id == nil || m.oldValue == nil {
  18801. return v, errors.New("OldCallback requires an ID field in the mutation")
  18802. }
  18803. oldValue, err := m.oldValue(ctx)
  18804. if err != nil {
  18805. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  18806. }
  18807. return oldValue.Callback, nil
  18808. }
  18809. // ResetCallback resets all changes to the "callback" field.
  18810. func (m *WxMutation) ResetCallback() {
  18811. m.callback = nil
  18812. }
  18813. // SetWxid sets the "wxid" field.
  18814. func (m *WxMutation) SetWxid(s string) {
  18815. m.wxid = &s
  18816. }
  18817. // Wxid returns the value of the "wxid" field in the mutation.
  18818. func (m *WxMutation) Wxid() (r string, exists bool) {
  18819. v := m.wxid
  18820. if v == nil {
  18821. return
  18822. }
  18823. return *v, true
  18824. }
  18825. // OldWxid returns the old "wxid" field's value of the Wx entity.
  18826. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18828. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  18829. if !m.op.Is(OpUpdateOne) {
  18830. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  18831. }
  18832. if m.id == nil || m.oldValue == nil {
  18833. return v, errors.New("OldWxid requires an ID field in the mutation")
  18834. }
  18835. oldValue, err := m.oldValue(ctx)
  18836. if err != nil {
  18837. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  18838. }
  18839. return oldValue.Wxid, nil
  18840. }
  18841. // ResetWxid resets all changes to the "wxid" field.
  18842. func (m *WxMutation) ResetWxid() {
  18843. m.wxid = nil
  18844. }
  18845. // SetAccount sets the "account" field.
  18846. func (m *WxMutation) SetAccount(s string) {
  18847. m.account = &s
  18848. }
  18849. // Account returns the value of the "account" field in the mutation.
  18850. func (m *WxMutation) Account() (r string, exists bool) {
  18851. v := m.account
  18852. if v == nil {
  18853. return
  18854. }
  18855. return *v, true
  18856. }
  18857. // OldAccount returns the old "account" field's value of the Wx entity.
  18858. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18860. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  18861. if !m.op.Is(OpUpdateOne) {
  18862. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  18863. }
  18864. if m.id == nil || m.oldValue == nil {
  18865. return v, errors.New("OldAccount requires an ID field in the mutation")
  18866. }
  18867. oldValue, err := m.oldValue(ctx)
  18868. if err != nil {
  18869. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  18870. }
  18871. return oldValue.Account, nil
  18872. }
  18873. // ResetAccount resets all changes to the "account" field.
  18874. func (m *WxMutation) ResetAccount() {
  18875. m.account = nil
  18876. }
  18877. // SetNickname sets the "nickname" field.
  18878. func (m *WxMutation) SetNickname(s string) {
  18879. m.nickname = &s
  18880. }
  18881. // Nickname returns the value of the "nickname" field in the mutation.
  18882. func (m *WxMutation) Nickname() (r string, exists bool) {
  18883. v := m.nickname
  18884. if v == nil {
  18885. return
  18886. }
  18887. return *v, true
  18888. }
  18889. // OldNickname returns the old "nickname" field's value of the Wx entity.
  18890. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18892. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  18893. if !m.op.Is(OpUpdateOne) {
  18894. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  18895. }
  18896. if m.id == nil || m.oldValue == nil {
  18897. return v, errors.New("OldNickname requires an ID field in the mutation")
  18898. }
  18899. oldValue, err := m.oldValue(ctx)
  18900. if err != nil {
  18901. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  18902. }
  18903. return oldValue.Nickname, nil
  18904. }
  18905. // ResetNickname resets all changes to the "nickname" field.
  18906. func (m *WxMutation) ResetNickname() {
  18907. m.nickname = nil
  18908. }
  18909. // SetTel sets the "tel" field.
  18910. func (m *WxMutation) SetTel(s string) {
  18911. m.tel = &s
  18912. }
  18913. // Tel returns the value of the "tel" field in the mutation.
  18914. func (m *WxMutation) Tel() (r string, exists bool) {
  18915. v := m.tel
  18916. if v == nil {
  18917. return
  18918. }
  18919. return *v, true
  18920. }
  18921. // OldTel returns the old "tel" field's value of the Wx entity.
  18922. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18924. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  18925. if !m.op.Is(OpUpdateOne) {
  18926. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  18927. }
  18928. if m.id == nil || m.oldValue == nil {
  18929. return v, errors.New("OldTel requires an ID field in the mutation")
  18930. }
  18931. oldValue, err := m.oldValue(ctx)
  18932. if err != nil {
  18933. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  18934. }
  18935. return oldValue.Tel, nil
  18936. }
  18937. // ResetTel resets all changes to the "tel" field.
  18938. func (m *WxMutation) ResetTel() {
  18939. m.tel = nil
  18940. }
  18941. // SetHeadBig sets the "head_big" field.
  18942. func (m *WxMutation) SetHeadBig(s string) {
  18943. m.head_big = &s
  18944. }
  18945. // HeadBig returns the value of the "head_big" field in the mutation.
  18946. func (m *WxMutation) HeadBig() (r string, exists bool) {
  18947. v := m.head_big
  18948. if v == nil {
  18949. return
  18950. }
  18951. return *v, true
  18952. }
  18953. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  18954. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18956. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  18957. if !m.op.Is(OpUpdateOne) {
  18958. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  18959. }
  18960. if m.id == nil || m.oldValue == nil {
  18961. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  18962. }
  18963. oldValue, err := m.oldValue(ctx)
  18964. if err != nil {
  18965. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  18966. }
  18967. return oldValue.HeadBig, nil
  18968. }
  18969. // ResetHeadBig resets all changes to the "head_big" field.
  18970. func (m *WxMutation) ResetHeadBig() {
  18971. m.head_big = nil
  18972. }
  18973. // SetOrganizationID sets the "organization_id" field.
  18974. func (m *WxMutation) SetOrganizationID(u uint64) {
  18975. m.organization_id = &u
  18976. m.addorganization_id = nil
  18977. }
  18978. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18979. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  18980. v := m.organization_id
  18981. if v == nil {
  18982. return
  18983. }
  18984. return *v, true
  18985. }
  18986. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  18987. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18988. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18989. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18990. if !m.op.Is(OpUpdateOne) {
  18991. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18992. }
  18993. if m.id == nil || m.oldValue == nil {
  18994. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18995. }
  18996. oldValue, err := m.oldValue(ctx)
  18997. if err != nil {
  18998. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18999. }
  19000. return oldValue.OrganizationID, nil
  19001. }
  19002. // AddOrganizationID adds u to the "organization_id" field.
  19003. func (m *WxMutation) AddOrganizationID(u int64) {
  19004. if m.addorganization_id != nil {
  19005. *m.addorganization_id += u
  19006. } else {
  19007. m.addorganization_id = &u
  19008. }
  19009. }
  19010. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19011. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  19012. v := m.addorganization_id
  19013. if v == nil {
  19014. return
  19015. }
  19016. return *v, true
  19017. }
  19018. // ClearOrganizationID clears the value of the "organization_id" field.
  19019. func (m *WxMutation) ClearOrganizationID() {
  19020. m.organization_id = nil
  19021. m.addorganization_id = nil
  19022. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  19023. }
  19024. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  19025. func (m *WxMutation) OrganizationIDCleared() bool {
  19026. _, ok := m.clearedFields[wx.FieldOrganizationID]
  19027. return ok
  19028. }
  19029. // ResetOrganizationID resets all changes to the "organization_id" field.
  19030. func (m *WxMutation) ResetOrganizationID() {
  19031. m.organization_id = nil
  19032. m.addorganization_id = nil
  19033. delete(m.clearedFields, wx.FieldOrganizationID)
  19034. }
  19035. // SetAgentID sets the "agent_id" field.
  19036. func (m *WxMutation) SetAgentID(u uint64) {
  19037. m.agent = &u
  19038. }
  19039. // AgentID returns the value of the "agent_id" field in the mutation.
  19040. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  19041. v := m.agent
  19042. if v == nil {
  19043. return
  19044. }
  19045. return *v, true
  19046. }
  19047. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  19048. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19050. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  19051. if !m.op.Is(OpUpdateOne) {
  19052. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  19053. }
  19054. if m.id == nil || m.oldValue == nil {
  19055. return v, errors.New("OldAgentID requires an ID field in the mutation")
  19056. }
  19057. oldValue, err := m.oldValue(ctx)
  19058. if err != nil {
  19059. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  19060. }
  19061. return oldValue.AgentID, nil
  19062. }
  19063. // ResetAgentID resets all changes to the "agent_id" field.
  19064. func (m *WxMutation) ResetAgentID() {
  19065. m.agent = nil
  19066. }
  19067. // SetAPIBase sets the "api_base" field.
  19068. func (m *WxMutation) SetAPIBase(s string) {
  19069. m.api_base = &s
  19070. }
  19071. // APIBase returns the value of the "api_base" field in the mutation.
  19072. func (m *WxMutation) APIBase() (r string, exists bool) {
  19073. v := m.api_base
  19074. if v == nil {
  19075. return
  19076. }
  19077. return *v, true
  19078. }
  19079. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  19080. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19082. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  19083. if !m.op.Is(OpUpdateOne) {
  19084. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  19085. }
  19086. if m.id == nil || m.oldValue == nil {
  19087. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  19088. }
  19089. oldValue, err := m.oldValue(ctx)
  19090. if err != nil {
  19091. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  19092. }
  19093. return oldValue.APIBase, nil
  19094. }
  19095. // ClearAPIBase clears the value of the "api_base" field.
  19096. func (m *WxMutation) ClearAPIBase() {
  19097. m.api_base = nil
  19098. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  19099. }
  19100. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  19101. func (m *WxMutation) APIBaseCleared() bool {
  19102. _, ok := m.clearedFields[wx.FieldAPIBase]
  19103. return ok
  19104. }
  19105. // ResetAPIBase resets all changes to the "api_base" field.
  19106. func (m *WxMutation) ResetAPIBase() {
  19107. m.api_base = nil
  19108. delete(m.clearedFields, wx.FieldAPIBase)
  19109. }
  19110. // SetAPIKey sets the "api_key" field.
  19111. func (m *WxMutation) SetAPIKey(s string) {
  19112. m.api_key = &s
  19113. }
  19114. // APIKey returns the value of the "api_key" field in the mutation.
  19115. func (m *WxMutation) APIKey() (r string, exists bool) {
  19116. v := m.api_key
  19117. if v == nil {
  19118. return
  19119. }
  19120. return *v, true
  19121. }
  19122. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  19123. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19125. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  19126. if !m.op.Is(OpUpdateOne) {
  19127. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  19128. }
  19129. if m.id == nil || m.oldValue == nil {
  19130. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  19131. }
  19132. oldValue, err := m.oldValue(ctx)
  19133. if err != nil {
  19134. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  19135. }
  19136. return oldValue.APIKey, nil
  19137. }
  19138. // ClearAPIKey clears the value of the "api_key" field.
  19139. func (m *WxMutation) ClearAPIKey() {
  19140. m.api_key = nil
  19141. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  19142. }
  19143. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  19144. func (m *WxMutation) APIKeyCleared() bool {
  19145. _, ok := m.clearedFields[wx.FieldAPIKey]
  19146. return ok
  19147. }
  19148. // ResetAPIKey resets all changes to the "api_key" field.
  19149. func (m *WxMutation) ResetAPIKey() {
  19150. m.api_key = nil
  19151. delete(m.clearedFields, wx.FieldAPIKey)
  19152. }
  19153. // SetAllowList sets the "allow_list" field.
  19154. func (m *WxMutation) SetAllowList(s []string) {
  19155. m.allow_list = &s
  19156. m.appendallow_list = nil
  19157. }
  19158. // AllowList returns the value of the "allow_list" field in the mutation.
  19159. func (m *WxMutation) AllowList() (r []string, exists bool) {
  19160. v := m.allow_list
  19161. if v == nil {
  19162. return
  19163. }
  19164. return *v, true
  19165. }
  19166. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  19167. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19168. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19169. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  19170. if !m.op.Is(OpUpdateOne) {
  19171. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  19172. }
  19173. if m.id == nil || m.oldValue == nil {
  19174. return v, errors.New("OldAllowList requires an ID field in the mutation")
  19175. }
  19176. oldValue, err := m.oldValue(ctx)
  19177. if err != nil {
  19178. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  19179. }
  19180. return oldValue.AllowList, nil
  19181. }
  19182. // AppendAllowList adds s to the "allow_list" field.
  19183. func (m *WxMutation) AppendAllowList(s []string) {
  19184. m.appendallow_list = append(m.appendallow_list, s...)
  19185. }
  19186. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  19187. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  19188. if len(m.appendallow_list) == 0 {
  19189. return nil, false
  19190. }
  19191. return m.appendallow_list, true
  19192. }
  19193. // ResetAllowList resets all changes to the "allow_list" field.
  19194. func (m *WxMutation) ResetAllowList() {
  19195. m.allow_list = nil
  19196. m.appendallow_list = nil
  19197. }
  19198. // SetGroupAllowList sets the "group_allow_list" field.
  19199. func (m *WxMutation) SetGroupAllowList(s []string) {
  19200. m.group_allow_list = &s
  19201. m.appendgroup_allow_list = nil
  19202. }
  19203. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  19204. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  19205. v := m.group_allow_list
  19206. if v == nil {
  19207. return
  19208. }
  19209. return *v, true
  19210. }
  19211. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  19212. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19214. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  19215. if !m.op.Is(OpUpdateOne) {
  19216. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  19217. }
  19218. if m.id == nil || m.oldValue == nil {
  19219. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  19220. }
  19221. oldValue, err := m.oldValue(ctx)
  19222. if err != nil {
  19223. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  19224. }
  19225. return oldValue.GroupAllowList, nil
  19226. }
  19227. // AppendGroupAllowList adds s to the "group_allow_list" field.
  19228. func (m *WxMutation) AppendGroupAllowList(s []string) {
  19229. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  19230. }
  19231. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  19232. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  19233. if len(m.appendgroup_allow_list) == 0 {
  19234. return nil, false
  19235. }
  19236. return m.appendgroup_allow_list, true
  19237. }
  19238. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  19239. func (m *WxMutation) ResetGroupAllowList() {
  19240. m.group_allow_list = nil
  19241. m.appendgroup_allow_list = nil
  19242. }
  19243. // SetBlockList sets the "block_list" field.
  19244. func (m *WxMutation) SetBlockList(s []string) {
  19245. m.block_list = &s
  19246. m.appendblock_list = nil
  19247. }
  19248. // BlockList returns the value of the "block_list" field in the mutation.
  19249. func (m *WxMutation) BlockList() (r []string, exists bool) {
  19250. v := m.block_list
  19251. if v == nil {
  19252. return
  19253. }
  19254. return *v, true
  19255. }
  19256. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  19257. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19259. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  19260. if !m.op.Is(OpUpdateOne) {
  19261. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  19262. }
  19263. if m.id == nil || m.oldValue == nil {
  19264. return v, errors.New("OldBlockList requires an ID field in the mutation")
  19265. }
  19266. oldValue, err := m.oldValue(ctx)
  19267. if err != nil {
  19268. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  19269. }
  19270. return oldValue.BlockList, nil
  19271. }
  19272. // AppendBlockList adds s to the "block_list" field.
  19273. func (m *WxMutation) AppendBlockList(s []string) {
  19274. m.appendblock_list = append(m.appendblock_list, s...)
  19275. }
  19276. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  19277. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  19278. if len(m.appendblock_list) == 0 {
  19279. return nil, false
  19280. }
  19281. return m.appendblock_list, true
  19282. }
  19283. // ResetBlockList resets all changes to the "block_list" field.
  19284. func (m *WxMutation) ResetBlockList() {
  19285. m.block_list = nil
  19286. m.appendblock_list = nil
  19287. }
  19288. // SetGroupBlockList sets the "group_block_list" field.
  19289. func (m *WxMutation) SetGroupBlockList(s []string) {
  19290. m.group_block_list = &s
  19291. m.appendgroup_block_list = nil
  19292. }
  19293. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  19294. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  19295. v := m.group_block_list
  19296. if v == nil {
  19297. return
  19298. }
  19299. return *v, true
  19300. }
  19301. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  19302. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19304. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  19305. if !m.op.Is(OpUpdateOne) {
  19306. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  19307. }
  19308. if m.id == nil || m.oldValue == nil {
  19309. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  19310. }
  19311. oldValue, err := m.oldValue(ctx)
  19312. if err != nil {
  19313. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  19314. }
  19315. return oldValue.GroupBlockList, nil
  19316. }
  19317. // AppendGroupBlockList adds s to the "group_block_list" field.
  19318. func (m *WxMutation) AppendGroupBlockList(s []string) {
  19319. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  19320. }
  19321. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  19322. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  19323. if len(m.appendgroup_block_list) == 0 {
  19324. return nil, false
  19325. }
  19326. return m.appendgroup_block_list, true
  19327. }
  19328. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  19329. func (m *WxMutation) ResetGroupBlockList() {
  19330. m.group_block_list = nil
  19331. m.appendgroup_block_list = nil
  19332. }
  19333. // ClearServer clears the "server" edge to the Server entity.
  19334. func (m *WxMutation) ClearServer() {
  19335. m.clearedserver = true
  19336. m.clearedFields[wx.FieldServerID] = struct{}{}
  19337. }
  19338. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  19339. func (m *WxMutation) ServerCleared() bool {
  19340. return m.ServerIDCleared() || m.clearedserver
  19341. }
  19342. // ServerIDs returns the "server" edge IDs in the mutation.
  19343. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19344. // ServerID instead. It exists only for internal usage by the builders.
  19345. func (m *WxMutation) ServerIDs() (ids []uint64) {
  19346. if id := m.server; id != nil {
  19347. ids = append(ids, *id)
  19348. }
  19349. return
  19350. }
  19351. // ResetServer resets all changes to the "server" edge.
  19352. func (m *WxMutation) ResetServer() {
  19353. m.server = nil
  19354. m.clearedserver = false
  19355. }
  19356. // ClearAgent clears the "agent" edge to the Agent entity.
  19357. func (m *WxMutation) ClearAgent() {
  19358. m.clearedagent = true
  19359. m.clearedFields[wx.FieldAgentID] = struct{}{}
  19360. }
  19361. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  19362. func (m *WxMutation) AgentCleared() bool {
  19363. return m.clearedagent
  19364. }
  19365. // AgentIDs returns the "agent" edge IDs in the mutation.
  19366. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19367. // AgentID instead. It exists only for internal usage by the builders.
  19368. func (m *WxMutation) AgentIDs() (ids []uint64) {
  19369. if id := m.agent; id != nil {
  19370. ids = append(ids, *id)
  19371. }
  19372. return
  19373. }
  19374. // ResetAgent resets all changes to the "agent" edge.
  19375. func (m *WxMutation) ResetAgent() {
  19376. m.agent = nil
  19377. m.clearedagent = false
  19378. }
  19379. // Where appends a list predicates to the WxMutation builder.
  19380. func (m *WxMutation) Where(ps ...predicate.Wx) {
  19381. m.predicates = append(m.predicates, ps...)
  19382. }
  19383. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  19384. // users can use type-assertion to append predicates that do not depend on any generated package.
  19385. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  19386. p := make([]predicate.Wx, len(ps))
  19387. for i := range ps {
  19388. p[i] = ps[i]
  19389. }
  19390. m.Where(p...)
  19391. }
  19392. // Op returns the operation name.
  19393. func (m *WxMutation) Op() Op {
  19394. return m.op
  19395. }
  19396. // SetOp allows setting the mutation operation.
  19397. func (m *WxMutation) SetOp(op Op) {
  19398. m.op = op
  19399. }
  19400. // Type returns the node type of this mutation (Wx).
  19401. func (m *WxMutation) Type() string {
  19402. return m.typ
  19403. }
  19404. // Fields returns all fields that were changed during this mutation. Note that in
  19405. // order to get all numeric fields that were incremented/decremented, call
  19406. // AddedFields().
  19407. func (m *WxMutation) Fields() []string {
  19408. fields := make([]string, 0, 21)
  19409. if m.created_at != nil {
  19410. fields = append(fields, wx.FieldCreatedAt)
  19411. }
  19412. if m.updated_at != nil {
  19413. fields = append(fields, wx.FieldUpdatedAt)
  19414. }
  19415. if m.status != nil {
  19416. fields = append(fields, wx.FieldStatus)
  19417. }
  19418. if m.deleted_at != nil {
  19419. fields = append(fields, wx.FieldDeletedAt)
  19420. }
  19421. if m.server != nil {
  19422. fields = append(fields, wx.FieldServerID)
  19423. }
  19424. if m.port != nil {
  19425. fields = append(fields, wx.FieldPort)
  19426. }
  19427. if m.process_id != nil {
  19428. fields = append(fields, wx.FieldProcessID)
  19429. }
  19430. if m.callback != nil {
  19431. fields = append(fields, wx.FieldCallback)
  19432. }
  19433. if m.wxid != nil {
  19434. fields = append(fields, wx.FieldWxid)
  19435. }
  19436. if m.account != nil {
  19437. fields = append(fields, wx.FieldAccount)
  19438. }
  19439. if m.nickname != nil {
  19440. fields = append(fields, wx.FieldNickname)
  19441. }
  19442. if m.tel != nil {
  19443. fields = append(fields, wx.FieldTel)
  19444. }
  19445. if m.head_big != nil {
  19446. fields = append(fields, wx.FieldHeadBig)
  19447. }
  19448. if m.organization_id != nil {
  19449. fields = append(fields, wx.FieldOrganizationID)
  19450. }
  19451. if m.agent != nil {
  19452. fields = append(fields, wx.FieldAgentID)
  19453. }
  19454. if m.api_base != nil {
  19455. fields = append(fields, wx.FieldAPIBase)
  19456. }
  19457. if m.api_key != nil {
  19458. fields = append(fields, wx.FieldAPIKey)
  19459. }
  19460. if m.allow_list != nil {
  19461. fields = append(fields, wx.FieldAllowList)
  19462. }
  19463. if m.group_allow_list != nil {
  19464. fields = append(fields, wx.FieldGroupAllowList)
  19465. }
  19466. if m.block_list != nil {
  19467. fields = append(fields, wx.FieldBlockList)
  19468. }
  19469. if m.group_block_list != nil {
  19470. fields = append(fields, wx.FieldGroupBlockList)
  19471. }
  19472. return fields
  19473. }
  19474. // Field returns the value of a field with the given name. The second boolean
  19475. // return value indicates that this field was not set, or was not defined in the
  19476. // schema.
  19477. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  19478. switch name {
  19479. case wx.FieldCreatedAt:
  19480. return m.CreatedAt()
  19481. case wx.FieldUpdatedAt:
  19482. return m.UpdatedAt()
  19483. case wx.FieldStatus:
  19484. return m.Status()
  19485. case wx.FieldDeletedAt:
  19486. return m.DeletedAt()
  19487. case wx.FieldServerID:
  19488. return m.ServerID()
  19489. case wx.FieldPort:
  19490. return m.Port()
  19491. case wx.FieldProcessID:
  19492. return m.ProcessID()
  19493. case wx.FieldCallback:
  19494. return m.Callback()
  19495. case wx.FieldWxid:
  19496. return m.Wxid()
  19497. case wx.FieldAccount:
  19498. return m.Account()
  19499. case wx.FieldNickname:
  19500. return m.Nickname()
  19501. case wx.FieldTel:
  19502. return m.Tel()
  19503. case wx.FieldHeadBig:
  19504. return m.HeadBig()
  19505. case wx.FieldOrganizationID:
  19506. return m.OrganizationID()
  19507. case wx.FieldAgentID:
  19508. return m.AgentID()
  19509. case wx.FieldAPIBase:
  19510. return m.APIBase()
  19511. case wx.FieldAPIKey:
  19512. return m.APIKey()
  19513. case wx.FieldAllowList:
  19514. return m.AllowList()
  19515. case wx.FieldGroupAllowList:
  19516. return m.GroupAllowList()
  19517. case wx.FieldBlockList:
  19518. return m.BlockList()
  19519. case wx.FieldGroupBlockList:
  19520. return m.GroupBlockList()
  19521. }
  19522. return nil, false
  19523. }
  19524. // OldField returns the old value of the field from the database. An error is
  19525. // returned if the mutation operation is not UpdateOne, or the query to the
  19526. // database failed.
  19527. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19528. switch name {
  19529. case wx.FieldCreatedAt:
  19530. return m.OldCreatedAt(ctx)
  19531. case wx.FieldUpdatedAt:
  19532. return m.OldUpdatedAt(ctx)
  19533. case wx.FieldStatus:
  19534. return m.OldStatus(ctx)
  19535. case wx.FieldDeletedAt:
  19536. return m.OldDeletedAt(ctx)
  19537. case wx.FieldServerID:
  19538. return m.OldServerID(ctx)
  19539. case wx.FieldPort:
  19540. return m.OldPort(ctx)
  19541. case wx.FieldProcessID:
  19542. return m.OldProcessID(ctx)
  19543. case wx.FieldCallback:
  19544. return m.OldCallback(ctx)
  19545. case wx.FieldWxid:
  19546. return m.OldWxid(ctx)
  19547. case wx.FieldAccount:
  19548. return m.OldAccount(ctx)
  19549. case wx.FieldNickname:
  19550. return m.OldNickname(ctx)
  19551. case wx.FieldTel:
  19552. return m.OldTel(ctx)
  19553. case wx.FieldHeadBig:
  19554. return m.OldHeadBig(ctx)
  19555. case wx.FieldOrganizationID:
  19556. return m.OldOrganizationID(ctx)
  19557. case wx.FieldAgentID:
  19558. return m.OldAgentID(ctx)
  19559. case wx.FieldAPIBase:
  19560. return m.OldAPIBase(ctx)
  19561. case wx.FieldAPIKey:
  19562. return m.OldAPIKey(ctx)
  19563. case wx.FieldAllowList:
  19564. return m.OldAllowList(ctx)
  19565. case wx.FieldGroupAllowList:
  19566. return m.OldGroupAllowList(ctx)
  19567. case wx.FieldBlockList:
  19568. return m.OldBlockList(ctx)
  19569. case wx.FieldGroupBlockList:
  19570. return m.OldGroupBlockList(ctx)
  19571. }
  19572. return nil, fmt.Errorf("unknown Wx field %s", name)
  19573. }
  19574. // SetField sets the value of a field with the given name. It returns an error if
  19575. // the field is not defined in the schema, or if the type mismatched the field
  19576. // type.
  19577. func (m *WxMutation) SetField(name string, value ent.Value) error {
  19578. switch name {
  19579. case wx.FieldCreatedAt:
  19580. v, ok := value.(time.Time)
  19581. if !ok {
  19582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19583. }
  19584. m.SetCreatedAt(v)
  19585. return nil
  19586. case wx.FieldUpdatedAt:
  19587. v, ok := value.(time.Time)
  19588. if !ok {
  19589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19590. }
  19591. m.SetUpdatedAt(v)
  19592. return nil
  19593. case wx.FieldStatus:
  19594. v, ok := value.(uint8)
  19595. if !ok {
  19596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19597. }
  19598. m.SetStatus(v)
  19599. return nil
  19600. case wx.FieldDeletedAt:
  19601. v, ok := value.(time.Time)
  19602. if !ok {
  19603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19604. }
  19605. m.SetDeletedAt(v)
  19606. return nil
  19607. case wx.FieldServerID:
  19608. v, ok := value.(uint64)
  19609. if !ok {
  19610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19611. }
  19612. m.SetServerID(v)
  19613. return nil
  19614. case wx.FieldPort:
  19615. v, ok := value.(string)
  19616. if !ok {
  19617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19618. }
  19619. m.SetPort(v)
  19620. return nil
  19621. case wx.FieldProcessID:
  19622. v, ok := value.(string)
  19623. if !ok {
  19624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19625. }
  19626. m.SetProcessID(v)
  19627. return nil
  19628. case wx.FieldCallback:
  19629. v, ok := value.(string)
  19630. if !ok {
  19631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19632. }
  19633. m.SetCallback(v)
  19634. return nil
  19635. case wx.FieldWxid:
  19636. v, ok := value.(string)
  19637. if !ok {
  19638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19639. }
  19640. m.SetWxid(v)
  19641. return nil
  19642. case wx.FieldAccount:
  19643. v, ok := value.(string)
  19644. if !ok {
  19645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19646. }
  19647. m.SetAccount(v)
  19648. return nil
  19649. case wx.FieldNickname:
  19650. v, ok := value.(string)
  19651. if !ok {
  19652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19653. }
  19654. m.SetNickname(v)
  19655. return nil
  19656. case wx.FieldTel:
  19657. v, ok := value.(string)
  19658. if !ok {
  19659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19660. }
  19661. m.SetTel(v)
  19662. return nil
  19663. case wx.FieldHeadBig:
  19664. v, ok := value.(string)
  19665. if !ok {
  19666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19667. }
  19668. m.SetHeadBig(v)
  19669. return nil
  19670. case wx.FieldOrganizationID:
  19671. v, ok := value.(uint64)
  19672. if !ok {
  19673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19674. }
  19675. m.SetOrganizationID(v)
  19676. return nil
  19677. case wx.FieldAgentID:
  19678. v, ok := value.(uint64)
  19679. if !ok {
  19680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19681. }
  19682. m.SetAgentID(v)
  19683. return nil
  19684. case wx.FieldAPIBase:
  19685. v, ok := value.(string)
  19686. if !ok {
  19687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19688. }
  19689. m.SetAPIBase(v)
  19690. return nil
  19691. case wx.FieldAPIKey:
  19692. v, ok := value.(string)
  19693. if !ok {
  19694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19695. }
  19696. m.SetAPIKey(v)
  19697. return nil
  19698. case wx.FieldAllowList:
  19699. v, ok := value.([]string)
  19700. if !ok {
  19701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19702. }
  19703. m.SetAllowList(v)
  19704. return nil
  19705. case wx.FieldGroupAllowList:
  19706. v, ok := value.([]string)
  19707. if !ok {
  19708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19709. }
  19710. m.SetGroupAllowList(v)
  19711. return nil
  19712. case wx.FieldBlockList:
  19713. v, ok := value.([]string)
  19714. if !ok {
  19715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19716. }
  19717. m.SetBlockList(v)
  19718. return nil
  19719. case wx.FieldGroupBlockList:
  19720. v, ok := value.([]string)
  19721. if !ok {
  19722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19723. }
  19724. m.SetGroupBlockList(v)
  19725. return nil
  19726. }
  19727. return fmt.Errorf("unknown Wx field %s", name)
  19728. }
  19729. // AddedFields returns all numeric fields that were incremented/decremented during
  19730. // this mutation.
  19731. func (m *WxMutation) AddedFields() []string {
  19732. var fields []string
  19733. if m.addstatus != nil {
  19734. fields = append(fields, wx.FieldStatus)
  19735. }
  19736. if m.addorganization_id != nil {
  19737. fields = append(fields, wx.FieldOrganizationID)
  19738. }
  19739. return fields
  19740. }
  19741. // AddedField returns the numeric value that was incremented/decremented on a field
  19742. // with the given name. The second boolean return value indicates that this field
  19743. // was not set, or was not defined in the schema.
  19744. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  19745. switch name {
  19746. case wx.FieldStatus:
  19747. return m.AddedStatus()
  19748. case wx.FieldOrganizationID:
  19749. return m.AddedOrganizationID()
  19750. }
  19751. return nil, false
  19752. }
  19753. // AddField adds the value to the field with the given name. It returns an error if
  19754. // the field is not defined in the schema, or if the type mismatched the field
  19755. // type.
  19756. func (m *WxMutation) AddField(name string, value ent.Value) error {
  19757. switch name {
  19758. case wx.FieldStatus:
  19759. v, ok := value.(int8)
  19760. if !ok {
  19761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19762. }
  19763. m.AddStatus(v)
  19764. return nil
  19765. case wx.FieldOrganizationID:
  19766. v, ok := value.(int64)
  19767. if !ok {
  19768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19769. }
  19770. m.AddOrganizationID(v)
  19771. return nil
  19772. }
  19773. return fmt.Errorf("unknown Wx numeric field %s", name)
  19774. }
  19775. // ClearedFields returns all nullable fields that were cleared during this
  19776. // mutation.
  19777. func (m *WxMutation) ClearedFields() []string {
  19778. var fields []string
  19779. if m.FieldCleared(wx.FieldStatus) {
  19780. fields = append(fields, wx.FieldStatus)
  19781. }
  19782. if m.FieldCleared(wx.FieldDeletedAt) {
  19783. fields = append(fields, wx.FieldDeletedAt)
  19784. }
  19785. if m.FieldCleared(wx.FieldServerID) {
  19786. fields = append(fields, wx.FieldServerID)
  19787. }
  19788. if m.FieldCleared(wx.FieldOrganizationID) {
  19789. fields = append(fields, wx.FieldOrganizationID)
  19790. }
  19791. if m.FieldCleared(wx.FieldAPIBase) {
  19792. fields = append(fields, wx.FieldAPIBase)
  19793. }
  19794. if m.FieldCleared(wx.FieldAPIKey) {
  19795. fields = append(fields, wx.FieldAPIKey)
  19796. }
  19797. return fields
  19798. }
  19799. // FieldCleared returns a boolean indicating if a field with the given name was
  19800. // cleared in this mutation.
  19801. func (m *WxMutation) FieldCleared(name string) bool {
  19802. _, ok := m.clearedFields[name]
  19803. return ok
  19804. }
  19805. // ClearField clears the value of the field with the given name. It returns an
  19806. // error if the field is not defined in the schema.
  19807. func (m *WxMutation) ClearField(name string) error {
  19808. switch name {
  19809. case wx.FieldStatus:
  19810. m.ClearStatus()
  19811. return nil
  19812. case wx.FieldDeletedAt:
  19813. m.ClearDeletedAt()
  19814. return nil
  19815. case wx.FieldServerID:
  19816. m.ClearServerID()
  19817. return nil
  19818. case wx.FieldOrganizationID:
  19819. m.ClearOrganizationID()
  19820. return nil
  19821. case wx.FieldAPIBase:
  19822. m.ClearAPIBase()
  19823. return nil
  19824. case wx.FieldAPIKey:
  19825. m.ClearAPIKey()
  19826. return nil
  19827. }
  19828. return fmt.Errorf("unknown Wx nullable field %s", name)
  19829. }
  19830. // ResetField resets all changes in the mutation for the field with the given name.
  19831. // It returns an error if the field is not defined in the schema.
  19832. func (m *WxMutation) ResetField(name string) error {
  19833. switch name {
  19834. case wx.FieldCreatedAt:
  19835. m.ResetCreatedAt()
  19836. return nil
  19837. case wx.FieldUpdatedAt:
  19838. m.ResetUpdatedAt()
  19839. return nil
  19840. case wx.FieldStatus:
  19841. m.ResetStatus()
  19842. return nil
  19843. case wx.FieldDeletedAt:
  19844. m.ResetDeletedAt()
  19845. return nil
  19846. case wx.FieldServerID:
  19847. m.ResetServerID()
  19848. return nil
  19849. case wx.FieldPort:
  19850. m.ResetPort()
  19851. return nil
  19852. case wx.FieldProcessID:
  19853. m.ResetProcessID()
  19854. return nil
  19855. case wx.FieldCallback:
  19856. m.ResetCallback()
  19857. return nil
  19858. case wx.FieldWxid:
  19859. m.ResetWxid()
  19860. return nil
  19861. case wx.FieldAccount:
  19862. m.ResetAccount()
  19863. return nil
  19864. case wx.FieldNickname:
  19865. m.ResetNickname()
  19866. return nil
  19867. case wx.FieldTel:
  19868. m.ResetTel()
  19869. return nil
  19870. case wx.FieldHeadBig:
  19871. m.ResetHeadBig()
  19872. return nil
  19873. case wx.FieldOrganizationID:
  19874. m.ResetOrganizationID()
  19875. return nil
  19876. case wx.FieldAgentID:
  19877. m.ResetAgentID()
  19878. return nil
  19879. case wx.FieldAPIBase:
  19880. m.ResetAPIBase()
  19881. return nil
  19882. case wx.FieldAPIKey:
  19883. m.ResetAPIKey()
  19884. return nil
  19885. case wx.FieldAllowList:
  19886. m.ResetAllowList()
  19887. return nil
  19888. case wx.FieldGroupAllowList:
  19889. m.ResetGroupAllowList()
  19890. return nil
  19891. case wx.FieldBlockList:
  19892. m.ResetBlockList()
  19893. return nil
  19894. case wx.FieldGroupBlockList:
  19895. m.ResetGroupBlockList()
  19896. return nil
  19897. }
  19898. return fmt.Errorf("unknown Wx field %s", name)
  19899. }
  19900. // AddedEdges returns all edge names that were set/added in this mutation.
  19901. func (m *WxMutation) AddedEdges() []string {
  19902. edges := make([]string, 0, 2)
  19903. if m.server != nil {
  19904. edges = append(edges, wx.EdgeServer)
  19905. }
  19906. if m.agent != nil {
  19907. edges = append(edges, wx.EdgeAgent)
  19908. }
  19909. return edges
  19910. }
  19911. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19912. // name in this mutation.
  19913. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  19914. switch name {
  19915. case wx.EdgeServer:
  19916. if id := m.server; id != nil {
  19917. return []ent.Value{*id}
  19918. }
  19919. case wx.EdgeAgent:
  19920. if id := m.agent; id != nil {
  19921. return []ent.Value{*id}
  19922. }
  19923. }
  19924. return nil
  19925. }
  19926. // RemovedEdges returns all edge names that were removed in this mutation.
  19927. func (m *WxMutation) RemovedEdges() []string {
  19928. edges := make([]string, 0, 2)
  19929. return edges
  19930. }
  19931. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19932. // the given name in this mutation.
  19933. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  19934. return nil
  19935. }
  19936. // ClearedEdges returns all edge names that were cleared in this mutation.
  19937. func (m *WxMutation) ClearedEdges() []string {
  19938. edges := make([]string, 0, 2)
  19939. if m.clearedserver {
  19940. edges = append(edges, wx.EdgeServer)
  19941. }
  19942. if m.clearedagent {
  19943. edges = append(edges, wx.EdgeAgent)
  19944. }
  19945. return edges
  19946. }
  19947. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19948. // was cleared in this mutation.
  19949. func (m *WxMutation) EdgeCleared(name string) bool {
  19950. switch name {
  19951. case wx.EdgeServer:
  19952. return m.clearedserver
  19953. case wx.EdgeAgent:
  19954. return m.clearedagent
  19955. }
  19956. return false
  19957. }
  19958. // ClearEdge clears the value of the edge with the given name. It returns an error
  19959. // if that edge is not defined in the schema.
  19960. func (m *WxMutation) ClearEdge(name string) error {
  19961. switch name {
  19962. case wx.EdgeServer:
  19963. m.ClearServer()
  19964. return nil
  19965. case wx.EdgeAgent:
  19966. m.ClearAgent()
  19967. return nil
  19968. }
  19969. return fmt.Errorf("unknown Wx unique edge %s", name)
  19970. }
  19971. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19972. // It returns an error if the edge is not defined in the schema.
  19973. func (m *WxMutation) ResetEdge(name string) error {
  19974. switch name {
  19975. case wx.EdgeServer:
  19976. m.ResetServer()
  19977. return nil
  19978. case wx.EdgeAgent:
  19979. m.ResetAgent()
  19980. return nil
  19981. }
  19982. return fmt.Errorf("unknown Wx edge %s", name)
  19983. }