mutation.go 608 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/batchmsg"
  11. "wechat-api/ent/contact"
  12. "wechat-api/ent/custom_types"
  13. "wechat-api/ent/employee"
  14. "wechat-api/ent/employeeconfig"
  15. "wechat-api/ent/label"
  16. "wechat-api/ent/labelrelationship"
  17. "wechat-api/ent/message"
  18. "wechat-api/ent/messagerecords"
  19. "wechat-api/ent/msg"
  20. "wechat-api/ent/predicate"
  21. "wechat-api/ent/server"
  22. "wechat-api/ent/sopnode"
  23. "wechat-api/ent/sopstage"
  24. "wechat-api/ent/soptask"
  25. "wechat-api/ent/token"
  26. "wechat-api/ent/tutorial"
  27. "wechat-api/ent/workexperience"
  28. "wechat-api/ent/wx"
  29. "entgo.io/ent"
  30. "entgo.io/ent/dialect/sql"
  31. )
  32. const (
  33. // Operation types.
  34. OpCreate = ent.OpCreate
  35. OpDelete = ent.OpDelete
  36. OpDeleteOne = ent.OpDeleteOne
  37. OpUpdate = ent.OpUpdate
  38. OpUpdateOne = ent.OpUpdateOne
  39. // Node types.
  40. TypeAgent = "Agent"
  41. TypeBatchMsg = "BatchMsg"
  42. TypeContact = "Contact"
  43. TypeEmployee = "Employee"
  44. TypeEmployeeConfig = "EmployeeConfig"
  45. TypeLabel = "Label"
  46. TypeLabelRelationship = "LabelRelationship"
  47. TypeMessage = "Message"
  48. TypeMessageRecords = "MessageRecords"
  49. TypeMsg = "Msg"
  50. TypeServer = "Server"
  51. TypeSopNode = "SopNode"
  52. TypeSopStage = "SopStage"
  53. TypeSopTask = "SopTask"
  54. TypeToken = "Token"
  55. TypeTutorial = "Tutorial"
  56. TypeWorkExperience = "WorkExperience"
  57. TypeWx = "Wx"
  58. )
  59. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  60. type AgentMutation struct {
  61. config
  62. op Op
  63. typ string
  64. id *uint64
  65. created_at *time.Time
  66. updated_at *time.Time
  67. deleted_at *time.Time
  68. name *string
  69. role *string
  70. status *int
  71. addstatus *int
  72. background *string
  73. examples *string
  74. organization_id *uint64
  75. addorganization_id *int64
  76. clearedFields map[string]struct{}
  77. wx_agent map[uint64]struct{}
  78. removedwx_agent map[uint64]struct{}
  79. clearedwx_agent bool
  80. done bool
  81. oldValue func(context.Context) (*Agent, error)
  82. predicates []predicate.Agent
  83. }
  84. var _ ent.Mutation = (*AgentMutation)(nil)
  85. // agentOption allows management of the mutation configuration using functional options.
  86. type agentOption func(*AgentMutation)
  87. // newAgentMutation creates new mutation for the Agent entity.
  88. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  89. m := &AgentMutation{
  90. config: c,
  91. op: op,
  92. typ: TypeAgent,
  93. clearedFields: make(map[string]struct{}),
  94. }
  95. for _, opt := range opts {
  96. opt(m)
  97. }
  98. return m
  99. }
  100. // withAgentID sets the ID field of the mutation.
  101. func withAgentID(id uint64) agentOption {
  102. return func(m *AgentMutation) {
  103. var (
  104. err error
  105. once sync.Once
  106. value *Agent
  107. )
  108. m.oldValue = func(ctx context.Context) (*Agent, error) {
  109. once.Do(func() {
  110. if m.done {
  111. err = errors.New("querying old values post mutation is not allowed")
  112. } else {
  113. value, err = m.Client().Agent.Get(ctx, id)
  114. }
  115. })
  116. return value, err
  117. }
  118. m.id = &id
  119. }
  120. }
  121. // withAgent sets the old Agent of the mutation.
  122. func withAgent(node *Agent) agentOption {
  123. return func(m *AgentMutation) {
  124. m.oldValue = func(context.Context) (*Agent, error) {
  125. return node, nil
  126. }
  127. m.id = &node.ID
  128. }
  129. }
  130. // Client returns a new `ent.Client` from the mutation. If the mutation was
  131. // executed in a transaction (ent.Tx), a transactional client is returned.
  132. func (m AgentMutation) Client() *Client {
  133. client := &Client{config: m.config}
  134. client.init()
  135. return client
  136. }
  137. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  138. // it returns an error otherwise.
  139. func (m AgentMutation) Tx() (*Tx, error) {
  140. if _, ok := m.driver.(*txDriver); !ok {
  141. return nil, errors.New("ent: mutation is not running in a transaction")
  142. }
  143. tx := &Tx{config: m.config}
  144. tx.init()
  145. return tx, nil
  146. }
  147. // SetID sets the value of the id field. Note that this
  148. // operation is only accepted on creation of Agent entities.
  149. func (m *AgentMutation) SetID(id uint64) {
  150. m.id = &id
  151. }
  152. // ID returns the ID value in the mutation. Note that the ID is only available
  153. // if it was provided to the builder or after it was returned from the database.
  154. func (m *AgentMutation) ID() (id uint64, exists bool) {
  155. if m.id == nil {
  156. return
  157. }
  158. return *m.id, true
  159. }
  160. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  161. // That means, if the mutation is applied within a transaction with an isolation level such
  162. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  163. // or updated by the mutation.
  164. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  165. switch {
  166. case m.op.Is(OpUpdateOne | OpDeleteOne):
  167. id, exists := m.ID()
  168. if exists {
  169. return []uint64{id}, nil
  170. }
  171. fallthrough
  172. case m.op.Is(OpUpdate | OpDelete):
  173. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  174. default:
  175. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  176. }
  177. }
  178. // SetCreatedAt sets the "created_at" field.
  179. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  180. m.created_at = &t
  181. }
  182. // CreatedAt returns the value of the "created_at" field in the mutation.
  183. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  184. v := m.created_at
  185. if v == nil {
  186. return
  187. }
  188. return *v, true
  189. }
  190. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  191. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  193. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  194. if !m.op.Is(OpUpdateOne) {
  195. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  196. }
  197. if m.id == nil || m.oldValue == nil {
  198. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  199. }
  200. oldValue, err := m.oldValue(ctx)
  201. if err != nil {
  202. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  203. }
  204. return oldValue.CreatedAt, nil
  205. }
  206. // ResetCreatedAt resets all changes to the "created_at" field.
  207. func (m *AgentMutation) ResetCreatedAt() {
  208. m.created_at = nil
  209. }
  210. // SetUpdatedAt sets the "updated_at" field.
  211. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  212. m.updated_at = &t
  213. }
  214. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  215. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  216. v := m.updated_at
  217. if v == nil {
  218. return
  219. }
  220. return *v, true
  221. }
  222. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  223. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  225. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  226. if !m.op.Is(OpUpdateOne) {
  227. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  228. }
  229. if m.id == nil || m.oldValue == nil {
  230. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  231. }
  232. oldValue, err := m.oldValue(ctx)
  233. if err != nil {
  234. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  235. }
  236. return oldValue.UpdatedAt, nil
  237. }
  238. // ResetUpdatedAt resets all changes to the "updated_at" field.
  239. func (m *AgentMutation) ResetUpdatedAt() {
  240. m.updated_at = nil
  241. }
  242. // SetDeletedAt sets the "deleted_at" field.
  243. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  244. m.deleted_at = &t
  245. }
  246. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  247. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  248. v := m.deleted_at
  249. if v == nil {
  250. return
  251. }
  252. return *v, true
  253. }
  254. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  255. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  257. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  258. if !m.op.Is(OpUpdateOne) {
  259. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  260. }
  261. if m.id == nil || m.oldValue == nil {
  262. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  263. }
  264. oldValue, err := m.oldValue(ctx)
  265. if err != nil {
  266. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  267. }
  268. return oldValue.DeletedAt, nil
  269. }
  270. // ClearDeletedAt clears the value of the "deleted_at" field.
  271. func (m *AgentMutation) ClearDeletedAt() {
  272. m.deleted_at = nil
  273. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  274. }
  275. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  276. func (m *AgentMutation) DeletedAtCleared() bool {
  277. _, ok := m.clearedFields[agent.FieldDeletedAt]
  278. return ok
  279. }
  280. // ResetDeletedAt resets all changes to the "deleted_at" field.
  281. func (m *AgentMutation) ResetDeletedAt() {
  282. m.deleted_at = nil
  283. delete(m.clearedFields, agent.FieldDeletedAt)
  284. }
  285. // SetName sets the "name" field.
  286. func (m *AgentMutation) SetName(s string) {
  287. m.name = &s
  288. }
  289. // Name returns the value of the "name" field in the mutation.
  290. func (m *AgentMutation) Name() (r string, exists bool) {
  291. v := m.name
  292. if v == nil {
  293. return
  294. }
  295. return *v, true
  296. }
  297. // OldName returns the old "name" field's value of the Agent entity.
  298. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  300. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  301. if !m.op.Is(OpUpdateOne) {
  302. return v, errors.New("OldName is only allowed on UpdateOne operations")
  303. }
  304. if m.id == nil || m.oldValue == nil {
  305. return v, errors.New("OldName requires an ID field in the mutation")
  306. }
  307. oldValue, err := m.oldValue(ctx)
  308. if err != nil {
  309. return v, fmt.Errorf("querying old value for OldName: %w", err)
  310. }
  311. return oldValue.Name, nil
  312. }
  313. // ResetName resets all changes to the "name" field.
  314. func (m *AgentMutation) ResetName() {
  315. m.name = nil
  316. }
  317. // SetRole sets the "role" field.
  318. func (m *AgentMutation) SetRole(s string) {
  319. m.role = &s
  320. }
  321. // Role returns the value of the "role" field in the mutation.
  322. func (m *AgentMutation) Role() (r string, exists bool) {
  323. v := m.role
  324. if v == nil {
  325. return
  326. }
  327. return *v, true
  328. }
  329. // OldRole returns the old "role" field's value of the Agent entity.
  330. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  332. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  333. if !m.op.Is(OpUpdateOne) {
  334. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  335. }
  336. if m.id == nil || m.oldValue == nil {
  337. return v, errors.New("OldRole requires an ID field in the mutation")
  338. }
  339. oldValue, err := m.oldValue(ctx)
  340. if err != nil {
  341. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  342. }
  343. return oldValue.Role, nil
  344. }
  345. // ResetRole resets all changes to the "role" field.
  346. func (m *AgentMutation) ResetRole() {
  347. m.role = nil
  348. }
  349. // SetStatus sets the "status" field.
  350. func (m *AgentMutation) SetStatus(i int) {
  351. m.status = &i
  352. m.addstatus = nil
  353. }
  354. // Status returns the value of the "status" field in the mutation.
  355. func (m *AgentMutation) Status() (r int, exists bool) {
  356. v := m.status
  357. if v == nil {
  358. return
  359. }
  360. return *v, true
  361. }
  362. // OldStatus returns the old "status" field's value of the Agent entity.
  363. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  365. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  366. if !m.op.Is(OpUpdateOne) {
  367. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  368. }
  369. if m.id == nil || m.oldValue == nil {
  370. return v, errors.New("OldStatus requires an ID field in the mutation")
  371. }
  372. oldValue, err := m.oldValue(ctx)
  373. if err != nil {
  374. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  375. }
  376. return oldValue.Status, nil
  377. }
  378. // AddStatus adds i to the "status" field.
  379. func (m *AgentMutation) AddStatus(i int) {
  380. if m.addstatus != nil {
  381. *m.addstatus += i
  382. } else {
  383. m.addstatus = &i
  384. }
  385. }
  386. // AddedStatus returns the value that was added to the "status" field in this mutation.
  387. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  388. v := m.addstatus
  389. if v == nil {
  390. return
  391. }
  392. return *v, true
  393. }
  394. // ClearStatus clears the value of the "status" field.
  395. func (m *AgentMutation) ClearStatus() {
  396. m.status = nil
  397. m.addstatus = nil
  398. m.clearedFields[agent.FieldStatus] = struct{}{}
  399. }
  400. // StatusCleared returns if the "status" field was cleared in this mutation.
  401. func (m *AgentMutation) StatusCleared() bool {
  402. _, ok := m.clearedFields[agent.FieldStatus]
  403. return ok
  404. }
  405. // ResetStatus resets all changes to the "status" field.
  406. func (m *AgentMutation) ResetStatus() {
  407. m.status = nil
  408. m.addstatus = nil
  409. delete(m.clearedFields, agent.FieldStatus)
  410. }
  411. // SetBackground sets the "background" field.
  412. func (m *AgentMutation) SetBackground(s string) {
  413. m.background = &s
  414. }
  415. // Background returns the value of the "background" field in the mutation.
  416. func (m *AgentMutation) Background() (r string, exists bool) {
  417. v := m.background
  418. if v == nil {
  419. return
  420. }
  421. return *v, true
  422. }
  423. // OldBackground returns the old "background" field's value of the Agent entity.
  424. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  426. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  427. if !m.op.Is(OpUpdateOne) {
  428. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  429. }
  430. if m.id == nil || m.oldValue == nil {
  431. return v, errors.New("OldBackground requires an ID field in the mutation")
  432. }
  433. oldValue, err := m.oldValue(ctx)
  434. if err != nil {
  435. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  436. }
  437. return oldValue.Background, nil
  438. }
  439. // ClearBackground clears the value of the "background" field.
  440. func (m *AgentMutation) ClearBackground() {
  441. m.background = nil
  442. m.clearedFields[agent.FieldBackground] = struct{}{}
  443. }
  444. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  445. func (m *AgentMutation) BackgroundCleared() bool {
  446. _, ok := m.clearedFields[agent.FieldBackground]
  447. return ok
  448. }
  449. // ResetBackground resets all changes to the "background" field.
  450. func (m *AgentMutation) ResetBackground() {
  451. m.background = nil
  452. delete(m.clearedFields, agent.FieldBackground)
  453. }
  454. // SetExamples sets the "examples" field.
  455. func (m *AgentMutation) SetExamples(s string) {
  456. m.examples = &s
  457. }
  458. // Examples returns the value of the "examples" field in the mutation.
  459. func (m *AgentMutation) Examples() (r string, exists bool) {
  460. v := m.examples
  461. if v == nil {
  462. return
  463. }
  464. return *v, true
  465. }
  466. // OldExamples returns the old "examples" field's value of the Agent entity.
  467. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  469. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  470. if !m.op.Is(OpUpdateOne) {
  471. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  472. }
  473. if m.id == nil || m.oldValue == nil {
  474. return v, errors.New("OldExamples requires an ID field in the mutation")
  475. }
  476. oldValue, err := m.oldValue(ctx)
  477. if err != nil {
  478. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  479. }
  480. return oldValue.Examples, nil
  481. }
  482. // ClearExamples clears the value of the "examples" field.
  483. func (m *AgentMutation) ClearExamples() {
  484. m.examples = nil
  485. m.clearedFields[agent.FieldExamples] = struct{}{}
  486. }
  487. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  488. func (m *AgentMutation) ExamplesCleared() bool {
  489. _, ok := m.clearedFields[agent.FieldExamples]
  490. return ok
  491. }
  492. // ResetExamples resets all changes to the "examples" field.
  493. func (m *AgentMutation) ResetExamples() {
  494. m.examples = nil
  495. delete(m.clearedFields, agent.FieldExamples)
  496. }
  497. // SetOrganizationID sets the "organization_id" field.
  498. func (m *AgentMutation) SetOrganizationID(u uint64) {
  499. m.organization_id = &u
  500. m.addorganization_id = nil
  501. }
  502. // OrganizationID returns the value of the "organization_id" field in the mutation.
  503. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  504. v := m.organization_id
  505. if v == nil {
  506. return
  507. }
  508. return *v, true
  509. }
  510. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  511. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  512. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  513. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  514. if !m.op.Is(OpUpdateOne) {
  515. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  516. }
  517. if m.id == nil || m.oldValue == nil {
  518. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  519. }
  520. oldValue, err := m.oldValue(ctx)
  521. if err != nil {
  522. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  523. }
  524. return oldValue.OrganizationID, nil
  525. }
  526. // AddOrganizationID adds u to the "organization_id" field.
  527. func (m *AgentMutation) AddOrganizationID(u int64) {
  528. if m.addorganization_id != nil {
  529. *m.addorganization_id += u
  530. } else {
  531. m.addorganization_id = &u
  532. }
  533. }
  534. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  535. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  536. v := m.addorganization_id
  537. if v == nil {
  538. return
  539. }
  540. return *v, true
  541. }
  542. // ResetOrganizationID resets all changes to the "organization_id" field.
  543. func (m *AgentMutation) ResetOrganizationID() {
  544. m.organization_id = nil
  545. m.addorganization_id = nil
  546. }
  547. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  548. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  549. if m.wx_agent == nil {
  550. m.wx_agent = make(map[uint64]struct{})
  551. }
  552. for i := range ids {
  553. m.wx_agent[ids[i]] = struct{}{}
  554. }
  555. }
  556. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  557. func (m *AgentMutation) ClearWxAgent() {
  558. m.clearedwx_agent = true
  559. }
  560. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  561. func (m *AgentMutation) WxAgentCleared() bool {
  562. return m.clearedwx_agent
  563. }
  564. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  565. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  566. if m.removedwx_agent == nil {
  567. m.removedwx_agent = make(map[uint64]struct{})
  568. }
  569. for i := range ids {
  570. delete(m.wx_agent, ids[i])
  571. m.removedwx_agent[ids[i]] = struct{}{}
  572. }
  573. }
  574. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  575. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  576. for id := range m.removedwx_agent {
  577. ids = append(ids, id)
  578. }
  579. return
  580. }
  581. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  582. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  583. for id := range m.wx_agent {
  584. ids = append(ids, id)
  585. }
  586. return
  587. }
  588. // ResetWxAgent resets all changes to the "wx_agent" edge.
  589. func (m *AgentMutation) ResetWxAgent() {
  590. m.wx_agent = nil
  591. m.clearedwx_agent = false
  592. m.removedwx_agent = nil
  593. }
  594. // Where appends a list predicates to the AgentMutation builder.
  595. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  596. m.predicates = append(m.predicates, ps...)
  597. }
  598. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  599. // users can use type-assertion to append predicates that do not depend on any generated package.
  600. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  601. p := make([]predicate.Agent, len(ps))
  602. for i := range ps {
  603. p[i] = ps[i]
  604. }
  605. m.Where(p...)
  606. }
  607. // Op returns the operation name.
  608. func (m *AgentMutation) Op() Op {
  609. return m.op
  610. }
  611. // SetOp allows setting the mutation operation.
  612. func (m *AgentMutation) SetOp(op Op) {
  613. m.op = op
  614. }
  615. // Type returns the node type of this mutation (Agent).
  616. func (m *AgentMutation) Type() string {
  617. return m.typ
  618. }
  619. // Fields returns all fields that were changed during this mutation. Note that in
  620. // order to get all numeric fields that were incremented/decremented, call
  621. // AddedFields().
  622. func (m *AgentMutation) Fields() []string {
  623. fields := make([]string, 0, 9)
  624. if m.created_at != nil {
  625. fields = append(fields, agent.FieldCreatedAt)
  626. }
  627. if m.updated_at != nil {
  628. fields = append(fields, agent.FieldUpdatedAt)
  629. }
  630. if m.deleted_at != nil {
  631. fields = append(fields, agent.FieldDeletedAt)
  632. }
  633. if m.name != nil {
  634. fields = append(fields, agent.FieldName)
  635. }
  636. if m.role != nil {
  637. fields = append(fields, agent.FieldRole)
  638. }
  639. if m.status != nil {
  640. fields = append(fields, agent.FieldStatus)
  641. }
  642. if m.background != nil {
  643. fields = append(fields, agent.FieldBackground)
  644. }
  645. if m.examples != nil {
  646. fields = append(fields, agent.FieldExamples)
  647. }
  648. if m.organization_id != nil {
  649. fields = append(fields, agent.FieldOrganizationID)
  650. }
  651. return fields
  652. }
  653. // Field returns the value of a field with the given name. The second boolean
  654. // return value indicates that this field was not set, or was not defined in the
  655. // schema.
  656. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  657. switch name {
  658. case agent.FieldCreatedAt:
  659. return m.CreatedAt()
  660. case agent.FieldUpdatedAt:
  661. return m.UpdatedAt()
  662. case agent.FieldDeletedAt:
  663. return m.DeletedAt()
  664. case agent.FieldName:
  665. return m.Name()
  666. case agent.FieldRole:
  667. return m.Role()
  668. case agent.FieldStatus:
  669. return m.Status()
  670. case agent.FieldBackground:
  671. return m.Background()
  672. case agent.FieldExamples:
  673. return m.Examples()
  674. case agent.FieldOrganizationID:
  675. return m.OrganizationID()
  676. }
  677. return nil, false
  678. }
  679. // OldField returns the old value of the field from the database. An error is
  680. // returned if the mutation operation is not UpdateOne, or the query to the
  681. // database failed.
  682. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  683. switch name {
  684. case agent.FieldCreatedAt:
  685. return m.OldCreatedAt(ctx)
  686. case agent.FieldUpdatedAt:
  687. return m.OldUpdatedAt(ctx)
  688. case agent.FieldDeletedAt:
  689. return m.OldDeletedAt(ctx)
  690. case agent.FieldName:
  691. return m.OldName(ctx)
  692. case agent.FieldRole:
  693. return m.OldRole(ctx)
  694. case agent.FieldStatus:
  695. return m.OldStatus(ctx)
  696. case agent.FieldBackground:
  697. return m.OldBackground(ctx)
  698. case agent.FieldExamples:
  699. return m.OldExamples(ctx)
  700. case agent.FieldOrganizationID:
  701. return m.OldOrganizationID(ctx)
  702. }
  703. return nil, fmt.Errorf("unknown Agent field %s", name)
  704. }
  705. // SetField sets the value of a field with the given name. It returns an error if
  706. // the field is not defined in the schema, or if the type mismatched the field
  707. // type.
  708. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  709. switch name {
  710. case agent.FieldCreatedAt:
  711. v, ok := value.(time.Time)
  712. if !ok {
  713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  714. }
  715. m.SetCreatedAt(v)
  716. return nil
  717. case agent.FieldUpdatedAt:
  718. v, ok := value.(time.Time)
  719. if !ok {
  720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  721. }
  722. m.SetUpdatedAt(v)
  723. return nil
  724. case agent.FieldDeletedAt:
  725. v, ok := value.(time.Time)
  726. if !ok {
  727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  728. }
  729. m.SetDeletedAt(v)
  730. return nil
  731. case agent.FieldName:
  732. v, ok := value.(string)
  733. if !ok {
  734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  735. }
  736. m.SetName(v)
  737. return nil
  738. case agent.FieldRole:
  739. v, ok := value.(string)
  740. if !ok {
  741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  742. }
  743. m.SetRole(v)
  744. return nil
  745. case agent.FieldStatus:
  746. v, ok := value.(int)
  747. if !ok {
  748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  749. }
  750. m.SetStatus(v)
  751. return nil
  752. case agent.FieldBackground:
  753. v, ok := value.(string)
  754. if !ok {
  755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  756. }
  757. m.SetBackground(v)
  758. return nil
  759. case agent.FieldExamples:
  760. v, ok := value.(string)
  761. if !ok {
  762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  763. }
  764. m.SetExamples(v)
  765. return nil
  766. case agent.FieldOrganizationID:
  767. v, ok := value.(uint64)
  768. if !ok {
  769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  770. }
  771. m.SetOrganizationID(v)
  772. return nil
  773. }
  774. return fmt.Errorf("unknown Agent field %s", name)
  775. }
  776. // AddedFields returns all numeric fields that were incremented/decremented during
  777. // this mutation.
  778. func (m *AgentMutation) AddedFields() []string {
  779. var fields []string
  780. if m.addstatus != nil {
  781. fields = append(fields, agent.FieldStatus)
  782. }
  783. if m.addorganization_id != nil {
  784. fields = append(fields, agent.FieldOrganizationID)
  785. }
  786. return fields
  787. }
  788. // AddedField returns the numeric value that was incremented/decremented on a field
  789. // with the given name. The second boolean return value indicates that this field
  790. // was not set, or was not defined in the schema.
  791. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  792. switch name {
  793. case agent.FieldStatus:
  794. return m.AddedStatus()
  795. case agent.FieldOrganizationID:
  796. return m.AddedOrganizationID()
  797. }
  798. return nil, false
  799. }
  800. // AddField adds the value to the field with the given name. It returns an error if
  801. // the field is not defined in the schema, or if the type mismatched the field
  802. // type.
  803. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  804. switch name {
  805. case agent.FieldStatus:
  806. v, ok := value.(int)
  807. if !ok {
  808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  809. }
  810. m.AddStatus(v)
  811. return nil
  812. case agent.FieldOrganizationID:
  813. v, ok := value.(int64)
  814. if !ok {
  815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  816. }
  817. m.AddOrganizationID(v)
  818. return nil
  819. }
  820. return fmt.Errorf("unknown Agent numeric field %s", name)
  821. }
  822. // ClearedFields returns all nullable fields that were cleared during this
  823. // mutation.
  824. func (m *AgentMutation) ClearedFields() []string {
  825. var fields []string
  826. if m.FieldCleared(agent.FieldDeletedAt) {
  827. fields = append(fields, agent.FieldDeletedAt)
  828. }
  829. if m.FieldCleared(agent.FieldStatus) {
  830. fields = append(fields, agent.FieldStatus)
  831. }
  832. if m.FieldCleared(agent.FieldBackground) {
  833. fields = append(fields, agent.FieldBackground)
  834. }
  835. if m.FieldCleared(agent.FieldExamples) {
  836. fields = append(fields, agent.FieldExamples)
  837. }
  838. return fields
  839. }
  840. // FieldCleared returns a boolean indicating if a field with the given name was
  841. // cleared in this mutation.
  842. func (m *AgentMutation) FieldCleared(name string) bool {
  843. _, ok := m.clearedFields[name]
  844. return ok
  845. }
  846. // ClearField clears the value of the field with the given name. It returns an
  847. // error if the field is not defined in the schema.
  848. func (m *AgentMutation) ClearField(name string) error {
  849. switch name {
  850. case agent.FieldDeletedAt:
  851. m.ClearDeletedAt()
  852. return nil
  853. case agent.FieldStatus:
  854. m.ClearStatus()
  855. return nil
  856. case agent.FieldBackground:
  857. m.ClearBackground()
  858. return nil
  859. case agent.FieldExamples:
  860. m.ClearExamples()
  861. return nil
  862. }
  863. return fmt.Errorf("unknown Agent nullable field %s", name)
  864. }
  865. // ResetField resets all changes in the mutation for the field with the given name.
  866. // It returns an error if the field is not defined in the schema.
  867. func (m *AgentMutation) ResetField(name string) error {
  868. switch name {
  869. case agent.FieldCreatedAt:
  870. m.ResetCreatedAt()
  871. return nil
  872. case agent.FieldUpdatedAt:
  873. m.ResetUpdatedAt()
  874. return nil
  875. case agent.FieldDeletedAt:
  876. m.ResetDeletedAt()
  877. return nil
  878. case agent.FieldName:
  879. m.ResetName()
  880. return nil
  881. case agent.FieldRole:
  882. m.ResetRole()
  883. return nil
  884. case agent.FieldStatus:
  885. m.ResetStatus()
  886. return nil
  887. case agent.FieldBackground:
  888. m.ResetBackground()
  889. return nil
  890. case agent.FieldExamples:
  891. m.ResetExamples()
  892. return nil
  893. case agent.FieldOrganizationID:
  894. m.ResetOrganizationID()
  895. return nil
  896. }
  897. return fmt.Errorf("unknown Agent field %s", name)
  898. }
  899. // AddedEdges returns all edge names that were set/added in this mutation.
  900. func (m *AgentMutation) AddedEdges() []string {
  901. edges := make([]string, 0, 1)
  902. if m.wx_agent != nil {
  903. edges = append(edges, agent.EdgeWxAgent)
  904. }
  905. return edges
  906. }
  907. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  908. // name in this mutation.
  909. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  910. switch name {
  911. case agent.EdgeWxAgent:
  912. ids := make([]ent.Value, 0, len(m.wx_agent))
  913. for id := range m.wx_agent {
  914. ids = append(ids, id)
  915. }
  916. return ids
  917. }
  918. return nil
  919. }
  920. // RemovedEdges returns all edge names that were removed in this mutation.
  921. func (m *AgentMutation) RemovedEdges() []string {
  922. edges := make([]string, 0, 1)
  923. if m.removedwx_agent != nil {
  924. edges = append(edges, agent.EdgeWxAgent)
  925. }
  926. return edges
  927. }
  928. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  929. // the given name in this mutation.
  930. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  931. switch name {
  932. case agent.EdgeWxAgent:
  933. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  934. for id := range m.removedwx_agent {
  935. ids = append(ids, id)
  936. }
  937. return ids
  938. }
  939. return nil
  940. }
  941. // ClearedEdges returns all edge names that were cleared in this mutation.
  942. func (m *AgentMutation) ClearedEdges() []string {
  943. edges := make([]string, 0, 1)
  944. if m.clearedwx_agent {
  945. edges = append(edges, agent.EdgeWxAgent)
  946. }
  947. return edges
  948. }
  949. // EdgeCleared returns a boolean which indicates if the edge with the given name
  950. // was cleared in this mutation.
  951. func (m *AgentMutation) EdgeCleared(name string) bool {
  952. switch name {
  953. case agent.EdgeWxAgent:
  954. return m.clearedwx_agent
  955. }
  956. return false
  957. }
  958. // ClearEdge clears the value of the edge with the given name. It returns an error
  959. // if that edge is not defined in the schema.
  960. func (m *AgentMutation) ClearEdge(name string) error {
  961. switch name {
  962. }
  963. return fmt.Errorf("unknown Agent unique edge %s", name)
  964. }
  965. // ResetEdge resets all changes to the edge with the given name in this mutation.
  966. // It returns an error if the edge is not defined in the schema.
  967. func (m *AgentMutation) ResetEdge(name string) error {
  968. switch name {
  969. case agent.EdgeWxAgent:
  970. m.ResetWxAgent()
  971. return nil
  972. }
  973. return fmt.Errorf("unknown Agent edge %s", name)
  974. }
  975. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  976. type BatchMsgMutation struct {
  977. config
  978. op Op
  979. typ string
  980. id *uint64
  981. created_at *time.Time
  982. updated_at *time.Time
  983. deleted_at *time.Time
  984. status *uint8
  985. addstatus *int8
  986. batch_no *string
  987. task_name *string
  988. fromwxid *string
  989. msg *string
  990. tag *string
  991. total *int32
  992. addtotal *int32
  993. success *int32
  994. addsuccess *int32
  995. fail *int32
  996. addfail *int32
  997. start_time *time.Time
  998. stop_time *time.Time
  999. _type *int32
  1000. add_type *int32
  1001. organization_id *uint64
  1002. addorganization_id *int64
  1003. clearedFields map[string]struct{}
  1004. done bool
  1005. oldValue func(context.Context) (*BatchMsg, error)
  1006. predicates []predicate.BatchMsg
  1007. }
  1008. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  1009. // batchmsgOption allows management of the mutation configuration using functional options.
  1010. type batchmsgOption func(*BatchMsgMutation)
  1011. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  1012. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  1013. m := &BatchMsgMutation{
  1014. config: c,
  1015. op: op,
  1016. typ: TypeBatchMsg,
  1017. clearedFields: make(map[string]struct{}),
  1018. }
  1019. for _, opt := range opts {
  1020. opt(m)
  1021. }
  1022. return m
  1023. }
  1024. // withBatchMsgID sets the ID field of the mutation.
  1025. func withBatchMsgID(id uint64) batchmsgOption {
  1026. return func(m *BatchMsgMutation) {
  1027. var (
  1028. err error
  1029. once sync.Once
  1030. value *BatchMsg
  1031. )
  1032. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  1033. once.Do(func() {
  1034. if m.done {
  1035. err = errors.New("querying old values post mutation is not allowed")
  1036. } else {
  1037. value, err = m.Client().BatchMsg.Get(ctx, id)
  1038. }
  1039. })
  1040. return value, err
  1041. }
  1042. m.id = &id
  1043. }
  1044. }
  1045. // withBatchMsg sets the old BatchMsg of the mutation.
  1046. func withBatchMsg(node *BatchMsg) batchmsgOption {
  1047. return func(m *BatchMsgMutation) {
  1048. m.oldValue = func(context.Context) (*BatchMsg, error) {
  1049. return node, nil
  1050. }
  1051. m.id = &node.ID
  1052. }
  1053. }
  1054. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1055. // executed in a transaction (ent.Tx), a transactional client is returned.
  1056. func (m BatchMsgMutation) Client() *Client {
  1057. client := &Client{config: m.config}
  1058. client.init()
  1059. return client
  1060. }
  1061. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1062. // it returns an error otherwise.
  1063. func (m BatchMsgMutation) Tx() (*Tx, error) {
  1064. if _, ok := m.driver.(*txDriver); !ok {
  1065. return nil, errors.New("ent: mutation is not running in a transaction")
  1066. }
  1067. tx := &Tx{config: m.config}
  1068. tx.init()
  1069. return tx, nil
  1070. }
  1071. // SetID sets the value of the id field. Note that this
  1072. // operation is only accepted on creation of BatchMsg entities.
  1073. func (m *BatchMsgMutation) SetID(id uint64) {
  1074. m.id = &id
  1075. }
  1076. // ID returns the ID value in the mutation. Note that the ID is only available
  1077. // if it was provided to the builder or after it was returned from the database.
  1078. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  1079. if m.id == nil {
  1080. return
  1081. }
  1082. return *m.id, true
  1083. }
  1084. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1085. // That means, if the mutation is applied within a transaction with an isolation level such
  1086. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1087. // or updated by the mutation.
  1088. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  1089. switch {
  1090. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1091. id, exists := m.ID()
  1092. if exists {
  1093. return []uint64{id}, nil
  1094. }
  1095. fallthrough
  1096. case m.op.Is(OpUpdate | OpDelete):
  1097. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  1098. default:
  1099. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1100. }
  1101. }
  1102. // SetCreatedAt sets the "created_at" field.
  1103. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  1104. m.created_at = &t
  1105. }
  1106. // CreatedAt returns the value of the "created_at" field in the mutation.
  1107. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  1108. v := m.created_at
  1109. if v == nil {
  1110. return
  1111. }
  1112. return *v, true
  1113. }
  1114. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  1115. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1116. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1117. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  1118. if !m.op.Is(OpUpdateOne) {
  1119. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  1120. }
  1121. if m.id == nil || m.oldValue == nil {
  1122. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  1123. }
  1124. oldValue, err := m.oldValue(ctx)
  1125. if err != nil {
  1126. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  1127. }
  1128. return oldValue.CreatedAt, nil
  1129. }
  1130. // ResetCreatedAt resets all changes to the "created_at" field.
  1131. func (m *BatchMsgMutation) ResetCreatedAt() {
  1132. m.created_at = nil
  1133. }
  1134. // SetUpdatedAt sets the "updated_at" field.
  1135. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  1136. m.updated_at = &t
  1137. }
  1138. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  1139. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  1140. v := m.updated_at
  1141. if v == nil {
  1142. return
  1143. }
  1144. return *v, true
  1145. }
  1146. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  1147. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1149. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  1150. if !m.op.Is(OpUpdateOne) {
  1151. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  1152. }
  1153. if m.id == nil || m.oldValue == nil {
  1154. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  1155. }
  1156. oldValue, err := m.oldValue(ctx)
  1157. if err != nil {
  1158. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  1159. }
  1160. return oldValue.UpdatedAt, nil
  1161. }
  1162. // ResetUpdatedAt resets all changes to the "updated_at" field.
  1163. func (m *BatchMsgMutation) ResetUpdatedAt() {
  1164. m.updated_at = nil
  1165. }
  1166. // SetDeletedAt sets the "deleted_at" field.
  1167. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  1168. m.deleted_at = &t
  1169. }
  1170. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  1171. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  1172. v := m.deleted_at
  1173. if v == nil {
  1174. return
  1175. }
  1176. return *v, true
  1177. }
  1178. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  1179. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1181. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  1182. if !m.op.Is(OpUpdateOne) {
  1183. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  1184. }
  1185. if m.id == nil || m.oldValue == nil {
  1186. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  1187. }
  1188. oldValue, err := m.oldValue(ctx)
  1189. if err != nil {
  1190. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  1191. }
  1192. return oldValue.DeletedAt, nil
  1193. }
  1194. // ClearDeletedAt clears the value of the "deleted_at" field.
  1195. func (m *BatchMsgMutation) ClearDeletedAt() {
  1196. m.deleted_at = nil
  1197. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  1198. }
  1199. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  1200. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  1201. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  1202. return ok
  1203. }
  1204. // ResetDeletedAt resets all changes to the "deleted_at" field.
  1205. func (m *BatchMsgMutation) ResetDeletedAt() {
  1206. m.deleted_at = nil
  1207. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  1208. }
  1209. // SetStatus sets the "status" field.
  1210. func (m *BatchMsgMutation) SetStatus(u uint8) {
  1211. m.status = &u
  1212. m.addstatus = nil
  1213. }
  1214. // Status returns the value of the "status" field in the mutation.
  1215. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  1216. v := m.status
  1217. if v == nil {
  1218. return
  1219. }
  1220. return *v, true
  1221. }
  1222. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  1223. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1225. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  1226. if !m.op.Is(OpUpdateOne) {
  1227. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  1228. }
  1229. if m.id == nil || m.oldValue == nil {
  1230. return v, errors.New("OldStatus requires an ID field in the mutation")
  1231. }
  1232. oldValue, err := m.oldValue(ctx)
  1233. if err != nil {
  1234. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  1235. }
  1236. return oldValue.Status, nil
  1237. }
  1238. // AddStatus adds u to the "status" field.
  1239. func (m *BatchMsgMutation) AddStatus(u int8) {
  1240. if m.addstatus != nil {
  1241. *m.addstatus += u
  1242. } else {
  1243. m.addstatus = &u
  1244. }
  1245. }
  1246. // AddedStatus returns the value that was added to the "status" field in this mutation.
  1247. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  1248. v := m.addstatus
  1249. if v == nil {
  1250. return
  1251. }
  1252. return *v, true
  1253. }
  1254. // ClearStatus clears the value of the "status" field.
  1255. func (m *BatchMsgMutation) ClearStatus() {
  1256. m.status = nil
  1257. m.addstatus = nil
  1258. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  1259. }
  1260. // StatusCleared returns if the "status" field was cleared in this mutation.
  1261. func (m *BatchMsgMutation) StatusCleared() bool {
  1262. _, ok := m.clearedFields[batchmsg.FieldStatus]
  1263. return ok
  1264. }
  1265. // ResetStatus resets all changes to the "status" field.
  1266. func (m *BatchMsgMutation) ResetStatus() {
  1267. m.status = nil
  1268. m.addstatus = nil
  1269. delete(m.clearedFields, batchmsg.FieldStatus)
  1270. }
  1271. // SetBatchNo sets the "batch_no" field.
  1272. func (m *BatchMsgMutation) SetBatchNo(s string) {
  1273. m.batch_no = &s
  1274. }
  1275. // BatchNo returns the value of the "batch_no" field in the mutation.
  1276. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  1277. v := m.batch_no
  1278. if v == nil {
  1279. return
  1280. }
  1281. return *v, true
  1282. }
  1283. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  1284. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1286. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  1287. if !m.op.Is(OpUpdateOne) {
  1288. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  1289. }
  1290. if m.id == nil || m.oldValue == nil {
  1291. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  1292. }
  1293. oldValue, err := m.oldValue(ctx)
  1294. if err != nil {
  1295. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  1296. }
  1297. return oldValue.BatchNo, nil
  1298. }
  1299. // ClearBatchNo clears the value of the "batch_no" field.
  1300. func (m *BatchMsgMutation) ClearBatchNo() {
  1301. m.batch_no = nil
  1302. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  1303. }
  1304. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  1305. func (m *BatchMsgMutation) BatchNoCleared() bool {
  1306. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  1307. return ok
  1308. }
  1309. // ResetBatchNo resets all changes to the "batch_no" field.
  1310. func (m *BatchMsgMutation) ResetBatchNo() {
  1311. m.batch_no = nil
  1312. delete(m.clearedFields, batchmsg.FieldBatchNo)
  1313. }
  1314. // SetTaskName sets the "task_name" field.
  1315. func (m *BatchMsgMutation) SetTaskName(s string) {
  1316. m.task_name = &s
  1317. }
  1318. // TaskName returns the value of the "task_name" field in the mutation.
  1319. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  1320. v := m.task_name
  1321. if v == nil {
  1322. return
  1323. }
  1324. return *v, true
  1325. }
  1326. // OldTaskName returns the old "task_name" 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) OldTaskName(ctx context.Context) (v string, err error) {
  1330. if !m.op.Is(OpUpdateOne) {
  1331. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  1332. }
  1333. if m.id == nil || m.oldValue == nil {
  1334. return v, errors.New("OldTaskName 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 OldTaskName: %w", err)
  1339. }
  1340. return oldValue.TaskName, nil
  1341. }
  1342. // ClearTaskName clears the value of the "task_name" field.
  1343. func (m *BatchMsgMutation) ClearTaskName() {
  1344. m.task_name = nil
  1345. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  1346. }
  1347. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  1348. func (m *BatchMsgMutation) TaskNameCleared() bool {
  1349. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  1350. return ok
  1351. }
  1352. // ResetTaskName resets all changes to the "task_name" field.
  1353. func (m *BatchMsgMutation) ResetTaskName() {
  1354. m.task_name = nil
  1355. delete(m.clearedFields, batchmsg.FieldTaskName)
  1356. }
  1357. // SetFromwxid sets the "fromwxid" field.
  1358. func (m *BatchMsgMutation) SetFromwxid(s string) {
  1359. m.fromwxid = &s
  1360. }
  1361. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  1362. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  1363. v := m.fromwxid
  1364. if v == nil {
  1365. return
  1366. }
  1367. return *v, true
  1368. }
  1369. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  1370. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1372. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  1373. if !m.op.Is(OpUpdateOne) {
  1374. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  1375. }
  1376. if m.id == nil || m.oldValue == nil {
  1377. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  1378. }
  1379. oldValue, err := m.oldValue(ctx)
  1380. if err != nil {
  1381. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  1382. }
  1383. return oldValue.Fromwxid, nil
  1384. }
  1385. // ClearFromwxid clears the value of the "fromwxid" field.
  1386. func (m *BatchMsgMutation) ClearFromwxid() {
  1387. m.fromwxid = nil
  1388. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  1389. }
  1390. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  1391. func (m *BatchMsgMutation) FromwxidCleared() bool {
  1392. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  1393. return ok
  1394. }
  1395. // ResetFromwxid resets all changes to the "fromwxid" field.
  1396. func (m *BatchMsgMutation) ResetFromwxid() {
  1397. m.fromwxid = nil
  1398. delete(m.clearedFields, batchmsg.FieldFromwxid)
  1399. }
  1400. // SetMsg sets the "msg" field.
  1401. func (m *BatchMsgMutation) SetMsg(s string) {
  1402. m.msg = &s
  1403. }
  1404. // Msg returns the value of the "msg" field in the mutation.
  1405. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  1406. v := m.msg
  1407. if v == nil {
  1408. return
  1409. }
  1410. return *v, true
  1411. }
  1412. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  1413. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1415. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  1416. if !m.op.Is(OpUpdateOne) {
  1417. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  1418. }
  1419. if m.id == nil || m.oldValue == nil {
  1420. return v, errors.New("OldMsg requires an ID field in the mutation")
  1421. }
  1422. oldValue, err := m.oldValue(ctx)
  1423. if err != nil {
  1424. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  1425. }
  1426. return oldValue.Msg, nil
  1427. }
  1428. // ClearMsg clears the value of the "msg" field.
  1429. func (m *BatchMsgMutation) ClearMsg() {
  1430. m.msg = nil
  1431. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  1432. }
  1433. // MsgCleared returns if the "msg" field was cleared in this mutation.
  1434. func (m *BatchMsgMutation) MsgCleared() bool {
  1435. _, ok := m.clearedFields[batchmsg.FieldMsg]
  1436. return ok
  1437. }
  1438. // ResetMsg resets all changes to the "msg" field.
  1439. func (m *BatchMsgMutation) ResetMsg() {
  1440. m.msg = nil
  1441. delete(m.clearedFields, batchmsg.FieldMsg)
  1442. }
  1443. // SetTag sets the "tag" field.
  1444. func (m *BatchMsgMutation) SetTag(s string) {
  1445. m.tag = &s
  1446. }
  1447. // Tag returns the value of the "tag" field in the mutation.
  1448. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  1449. v := m.tag
  1450. if v == nil {
  1451. return
  1452. }
  1453. return *v, true
  1454. }
  1455. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  1456. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1458. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  1459. if !m.op.Is(OpUpdateOne) {
  1460. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  1461. }
  1462. if m.id == nil || m.oldValue == nil {
  1463. return v, errors.New("OldTag requires an ID field in the mutation")
  1464. }
  1465. oldValue, err := m.oldValue(ctx)
  1466. if err != nil {
  1467. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  1468. }
  1469. return oldValue.Tag, nil
  1470. }
  1471. // ClearTag clears the value of the "tag" field.
  1472. func (m *BatchMsgMutation) ClearTag() {
  1473. m.tag = nil
  1474. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  1475. }
  1476. // TagCleared returns if the "tag" field was cleared in this mutation.
  1477. func (m *BatchMsgMutation) TagCleared() bool {
  1478. _, ok := m.clearedFields[batchmsg.FieldTag]
  1479. return ok
  1480. }
  1481. // ResetTag resets all changes to the "tag" field.
  1482. func (m *BatchMsgMutation) ResetTag() {
  1483. m.tag = nil
  1484. delete(m.clearedFields, batchmsg.FieldTag)
  1485. }
  1486. // SetTotal sets the "total" field.
  1487. func (m *BatchMsgMutation) SetTotal(i int32) {
  1488. m.total = &i
  1489. m.addtotal = nil
  1490. }
  1491. // Total returns the value of the "total" field in the mutation.
  1492. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  1493. v := m.total
  1494. if v == nil {
  1495. return
  1496. }
  1497. return *v, true
  1498. }
  1499. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  1500. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1501. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1502. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  1503. if !m.op.Is(OpUpdateOne) {
  1504. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  1505. }
  1506. if m.id == nil || m.oldValue == nil {
  1507. return v, errors.New("OldTotal requires an ID field in the mutation")
  1508. }
  1509. oldValue, err := m.oldValue(ctx)
  1510. if err != nil {
  1511. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  1512. }
  1513. return oldValue.Total, nil
  1514. }
  1515. // AddTotal adds i to the "total" field.
  1516. func (m *BatchMsgMutation) AddTotal(i int32) {
  1517. if m.addtotal != nil {
  1518. *m.addtotal += i
  1519. } else {
  1520. m.addtotal = &i
  1521. }
  1522. }
  1523. // AddedTotal returns the value that was added to the "total" field in this mutation.
  1524. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  1525. v := m.addtotal
  1526. if v == nil {
  1527. return
  1528. }
  1529. return *v, true
  1530. }
  1531. // ClearTotal clears the value of the "total" field.
  1532. func (m *BatchMsgMutation) ClearTotal() {
  1533. m.total = nil
  1534. m.addtotal = nil
  1535. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  1536. }
  1537. // TotalCleared returns if the "total" field was cleared in this mutation.
  1538. func (m *BatchMsgMutation) TotalCleared() bool {
  1539. _, ok := m.clearedFields[batchmsg.FieldTotal]
  1540. return ok
  1541. }
  1542. // ResetTotal resets all changes to the "total" field.
  1543. func (m *BatchMsgMutation) ResetTotal() {
  1544. m.total = nil
  1545. m.addtotal = nil
  1546. delete(m.clearedFields, batchmsg.FieldTotal)
  1547. }
  1548. // SetSuccess sets the "success" field.
  1549. func (m *BatchMsgMutation) SetSuccess(i int32) {
  1550. m.success = &i
  1551. m.addsuccess = nil
  1552. }
  1553. // Success returns the value of the "success" field in the mutation.
  1554. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  1555. v := m.success
  1556. if v == nil {
  1557. return
  1558. }
  1559. return *v, true
  1560. }
  1561. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  1562. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1564. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  1565. if !m.op.Is(OpUpdateOne) {
  1566. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  1567. }
  1568. if m.id == nil || m.oldValue == nil {
  1569. return v, errors.New("OldSuccess requires an ID field in the mutation")
  1570. }
  1571. oldValue, err := m.oldValue(ctx)
  1572. if err != nil {
  1573. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  1574. }
  1575. return oldValue.Success, nil
  1576. }
  1577. // AddSuccess adds i to the "success" field.
  1578. func (m *BatchMsgMutation) AddSuccess(i int32) {
  1579. if m.addsuccess != nil {
  1580. *m.addsuccess += i
  1581. } else {
  1582. m.addsuccess = &i
  1583. }
  1584. }
  1585. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  1586. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  1587. v := m.addsuccess
  1588. if v == nil {
  1589. return
  1590. }
  1591. return *v, true
  1592. }
  1593. // ClearSuccess clears the value of the "success" field.
  1594. func (m *BatchMsgMutation) ClearSuccess() {
  1595. m.success = nil
  1596. m.addsuccess = nil
  1597. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  1598. }
  1599. // SuccessCleared returns if the "success" field was cleared in this mutation.
  1600. func (m *BatchMsgMutation) SuccessCleared() bool {
  1601. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  1602. return ok
  1603. }
  1604. // ResetSuccess resets all changes to the "success" field.
  1605. func (m *BatchMsgMutation) ResetSuccess() {
  1606. m.success = nil
  1607. m.addsuccess = nil
  1608. delete(m.clearedFields, batchmsg.FieldSuccess)
  1609. }
  1610. // SetFail sets the "fail" field.
  1611. func (m *BatchMsgMutation) SetFail(i int32) {
  1612. m.fail = &i
  1613. m.addfail = nil
  1614. }
  1615. // Fail returns the value of the "fail" field in the mutation.
  1616. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  1617. v := m.fail
  1618. if v == nil {
  1619. return
  1620. }
  1621. return *v, true
  1622. }
  1623. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  1624. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1626. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  1627. if !m.op.Is(OpUpdateOne) {
  1628. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  1629. }
  1630. if m.id == nil || m.oldValue == nil {
  1631. return v, errors.New("OldFail requires an ID field in the mutation")
  1632. }
  1633. oldValue, err := m.oldValue(ctx)
  1634. if err != nil {
  1635. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  1636. }
  1637. return oldValue.Fail, nil
  1638. }
  1639. // AddFail adds i to the "fail" field.
  1640. func (m *BatchMsgMutation) AddFail(i int32) {
  1641. if m.addfail != nil {
  1642. *m.addfail += i
  1643. } else {
  1644. m.addfail = &i
  1645. }
  1646. }
  1647. // AddedFail returns the value that was added to the "fail" field in this mutation.
  1648. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  1649. v := m.addfail
  1650. if v == nil {
  1651. return
  1652. }
  1653. return *v, true
  1654. }
  1655. // ClearFail clears the value of the "fail" field.
  1656. func (m *BatchMsgMutation) ClearFail() {
  1657. m.fail = nil
  1658. m.addfail = nil
  1659. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  1660. }
  1661. // FailCleared returns if the "fail" field was cleared in this mutation.
  1662. func (m *BatchMsgMutation) FailCleared() bool {
  1663. _, ok := m.clearedFields[batchmsg.FieldFail]
  1664. return ok
  1665. }
  1666. // ResetFail resets all changes to the "fail" field.
  1667. func (m *BatchMsgMutation) ResetFail() {
  1668. m.fail = nil
  1669. m.addfail = nil
  1670. delete(m.clearedFields, batchmsg.FieldFail)
  1671. }
  1672. // SetStartTime sets the "start_time" field.
  1673. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  1674. m.start_time = &t
  1675. }
  1676. // StartTime returns the value of the "start_time" field in the mutation.
  1677. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  1678. v := m.start_time
  1679. if v == nil {
  1680. return
  1681. }
  1682. return *v, true
  1683. }
  1684. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  1685. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1687. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  1688. if !m.op.Is(OpUpdateOne) {
  1689. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  1690. }
  1691. if m.id == nil || m.oldValue == nil {
  1692. return v, errors.New("OldStartTime requires an ID field in the mutation")
  1693. }
  1694. oldValue, err := m.oldValue(ctx)
  1695. if err != nil {
  1696. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  1697. }
  1698. return oldValue.StartTime, nil
  1699. }
  1700. // ClearStartTime clears the value of the "start_time" field.
  1701. func (m *BatchMsgMutation) ClearStartTime() {
  1702. m.start_time = nil
  1703. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  1704. }
  1705. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  1706. func (m *BatchMsgMutation) StartTimeCleared() bool {
  1707. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  1708. return ok
  1709. }
  1710. // ResetStartTime resets all changes to the "start_time" field.
  1711. func (m *BatchMsgMutation) ResetStartTime() {
  1712. m.start_time = nil
  1713. delete(m.clearedFields, batchmsg.FieldStartTime)
  1714. }
  1715. // SetStopTime sets the "stop_time" field.
  1716. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  1717. m.stop_time = &t
  1718. }
  1719. // StopTime returns the value of the "stop_time" field in the mutation.
  1720. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  1721. v := m.stop_time
  1722. if v == nil {
  1723. return
  1724. }
  1725. return *v, true
  1726. }
  1727. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  1728. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1730. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  1731. if !m.op.Is(OpUpdateOne) {
  1732. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  1733. }
  1734. if m.id == nil || m.oldValue == nil {
  1735. return v, errors.New("OldStopTime requires an ID field in the mutation")
  1736. }
  1737. oldValue, err := m.oldValue(ctx)
  1738. if err != nil {
  1739. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  1740. }
  1741. return oldValue.StopTime, nil
  1742. }
  1743. // ClearStopTime clears the value of the "stop_time" field.
  1744. func (m *BatchMsgMutation) ClearStopTime() {
  1745. m.stop_time = nil
  1746. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  1747. }
  1748. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  1749. func (m *BatchMsgMutation) StopTimeCleared() bool {
  1750. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  1751. return ok
  1752. }
  1753. // ResetStopTime resets all changes to the "stop_time" field.
  1754. func (m *BatchMsgMutation) ResetStopTime() {
  1755. m.stop_time = nil
  1756. delete(m.clearedFields, batchmsg.FieldStopTime)
  1757. }
  1758. // SetType sets the "type" field.
  1759. func (m *BatchMsgMutation) SetType(i int32) {
  1760. m._type = &i
  1761. m.add_type = nil
  1762. }
  1763. // GetType returns the value of the "type" field in the mutation.
  1764. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  1765. v := m._type
  1766. if v == nil {
  1767. return
  1768. }
  1769. return *v, true
  1770. }
  1771. // OldType returns the old "type" field's value of the BatchMsg entity.
  1772. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1774. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  1775. if !m.op.Is(OpUpdateOne) {
  1776. return v, errors.New("OldType is only allowed on UpdateOne operations")
  1777. }
  1778. if m.id == nil || m.oldValue == nil {
  1779. return v, errors.New("OldType requires an ID field in the mutation")
  1780. }
  1781. oldValue, err := m.oldValue(ctx)
  1782. if err != nil {
  1783. return v, fmt.Errorf("querying old value for OldType: %w", err)
  1784. }
  1785. return oldValue.Type, nil
  1786. }
  1787. // AddType adds i to the "type" field.
  1788. func (m *BatchMsgMutation) AddType(i int32) {
  1789. if m.add_type != nil {
  1790. *m.add_type += i
  1791. } else {
  1792. m.add_type = &i
  1793. }
  1794. }
  1795. // AddedType returns the value that was added to the "type" field in this mutation.
  1796. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  1797. v := m.add_type
  1798. if v == nil {
  1799. return
  1800. }
  1801. return *v, true
  1802. }
  1803. // ClearType clears the value of the "type" field.
  1804. func (m *BatchMsgMutation) ClearType() {
  1805. m._type = nil
  1806. m.add_type = nil
  1807. m.clearedFields[batchmsg.FieldType] = struct{}{}
  1808. }
  1809. // TypeCleared returns if the "type" field was cleared in this mutation.
  1810. func (m *BatchMsgMutation) TypeCleared() bool {
  1811. _, ok := m.clearedFields[batchmsg.FieldType]
  1812. return ok
  1813. }
  1814. // ResetType resets all changes to the "type" field.
  1815. func (m *BatchMsgMutation) ResetType() {
  1816. m._type = nil
  1817. m.add_type = nil
  1818. delete(m.clearedFields, batchmsg.FieldType)
  1819. }
  1820. // SetOrganizationID sets the "organization_id" field.
  1821. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  1822. m.organization_id = &u
  1823. m.addorganization_id = nil
  1824. }
  1825. // OrganizationID returns the value of the "organization_id" field in the mutation.
  1826. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  1827. v := m.organization_id
  1828. if v == nil {
  1829. return
  1830. }
  1831. return *v, true
  1832. }
  1833. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  1834. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1835. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1836. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  1837. if !m.op.Is(OpUpdateOne) {
  1838. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  1839. }
  1840. if m.id == nil || m.oldValue == nil {
  1841. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  1842. }
  1843. oldValue, err := m.oldValue(ctx)
  1844. if err != nil {
  1845. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  1846. }
  1847. return oldValue.OrganizationID, nil
  1848. }
  1849. // AddOrganizationID adds u to the "organization_id" field.
  1850. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  1851. if m.addorganization_id != nil {
  1852. *m.addorganization_id += u
  1853. } else {
  1854. m.addorganization_id = &u
  1855. }
  1856. }
  1857. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  1858. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  1859. v := m.addorganization_id
  1860. if v == nil {
  1861. return
  1862. }
  1863. return *v, true
  1864. }
  1865. // ResetOrganizationID resets all changes to the "organization_id" field.
  1866. func (m *BatchMsgMutation) ResetOrganizationID() {
  1867. m.organization_id = nil
  1868. m.addorganization_id = nil
  1869. }
  1870. // Where appends a list predicates to the BatchMsgMutation builder.
  1871. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  1872. m.predicates = append(m.predicates, ps...)
  1873. }
  1874. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  1875. // users can use type-assertion to append predicates that do not depend on any generated package.
  1876. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  1877. p := make([]predicate.BatchMsg, len(ps))
  1878. for i := range ps {
  1879. p[i] = ps[i]
  1880. }
  1881. m.Where(p...)
  1882. }
  1883. // Op returns the operation name.
  1884. func (m *BatchMsgMutation) Op() Op {
  1885. return m.op
  1886. }
  1887. // SetOp allows setting the mutation operation.
  1888. func (m *BatchMsgMutation) SetOp(op Op) {
  1889. m.op = op
  1890. }
  1891. // Type returns the node type of this mutation (BatchMsg).
  1892. func (m *BatchMsgMutation) Type() string {
  1893. return m.typ
  1894. }
  1895. // Fields returns all fields that were changed during this mutation. Note that in
  1896. // order to get all numeric fields that were incremented/decremented, call
  1897. // AddedFields().
  1898. func (m *BatchMsgMutation) Fields() []string {
  1899. fields := make([]string, 0, 16)
  1900. if m.created_at != nil {
  1901. fields = append(fields, batchmsg.FieldCreatedAt)
  1902. }
  1903. if m.updated_at != nil {
  1904. fields = append(fields, batchmsg.FieldUpdatedAt)
  1905. }
  1906. if m.deleted_at != nil {
  1907. fields = append(fields, batchmsg.FieldDeletedAt)
  1908. }
  1909. if m.status != nil {
  1910. fields = append(fields, batchmsg.FieldStatus)
  1911. }
  1912. if m.batch_no != nil {
  1913. fields = append(fields, batchmsg.FieldBatchNo)
  1914. }
  1915. if m.task_name != nil {
  1916. fields = append(fields, batchmsg.FieldTaskName)
  1917. }
  1918. if m.fromwxid != nil {
  1919. fields = append(fields, batchmsg.FieldFromwxid)
  1920. }
  1921. if m.msg != nil {
  1922. fields = append(fields, batchmsg.FieldMsg)
  1923. }
  1924. if m.tag != nil {
  1925. fields = append(fields, batchmsg.FieldTag)
  1926. }
  1927. if m.total != nil {
  1928. fields = append(fields, batchmsg.FieldTotal)
  1929. }
  1930. if m.success != nil {
  1931. fields = append(fields, batchmsg.FieldSuccess)
  1932. }
  1933. if m.fail != nil {
  1934. fields = append(fields, batchmsg.FieldFail)
  1935. }
  1936. if m.start_time != nil {
  1937. fields = append(fields, batchmsg.FieldStartTime)
  1938. }
  1939. if m.stop_time != nil {
  1940. fields = append(fields, batchmsg.FieldStopTime)
  1941. }
  1942. if m._type != nil {
  1943. fields = append(fields, batchmsg.FieldType)
  1944. }
  1945. if m.organization_id != nil {
  1946. fields = append(fields, batchmsg.FieldOrganizationID)
  1947. }
  1948. return fields
  1949. }
  1950. // Field returns the value of a field with the given name. The second boolean
  1951. // return value indicates that this field was not set, or was not defined in the
  1952. // schema.
  1953. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  1954. switch name {
  1955. case batchmsg.FieldCreatedAt:
  1956. return m.CreatedAt()
  1957. case batchmsg.FieldUpdatedAt:
  1958. return m.UpdatedAt()
  1959. case batchmsg.FieldDeletedAt:
  1960. return m.DeletedAt()
  1961. case batchmsg.FieldStatus:
  1962. return m.Status()
  1963. case batchmsg.FieldBatchNo:
  1964. return m.BatchNo()
  1965. case batchmsg.FieldTaskName:
  1966. return m.TaskName()
  1967. case batchmsg.FieldFromwxid:
  1968. return m.Fromwxid()
  1969. case batchmsg.FieldMsg:
  1970. return m.Msg()
  1971. case batchmsg.FieldTag:
  1972. return m.Tag()
  1973. case batchmsg.FieldTotal:
  1974. return m.Total()
  1975. case batchmsg.FieldSuccess:
  1976. return m.Success()
  1977. case batchmsg.FieldFail:
  1978. return m.Fail()
  1979. case batchmsg.FieldStartTime:
  1980. return m.StartTime()
  1981. case batchmsg.FieldStopTime:
  1982. return m.StopTime()
  1983. case batchmsg.FieldType:
  1984. return m.GetType()
  1985. case batchmsg.FieldOrganizationID:
  1986. return m.OrganizationID()
  1987. }
  1988. return nil, false
  1989. }
  1990. // OldField returns the old value of the field from the database. An error is
  1991. // returned if the mutation operation is not UpdateOne, or the query to the
  1992. // database failed.
  1993. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1994. switch name {
  1995. case batchmsg.FieldCreatedAt:
  1996. return m.OldCreatedAt(ctx)
  1997. case batchmsg.FieldUpdatedAt:
  1998. return m.OldUpdatedAt(ctx)
  1999. case batchmsg.FieldDeletedAt:
  2000. return m.OldDeletedAt(ctx)
  2001. case batchmsg.FieldStatus:
  2002. return m.OldStatus(ctx)
  2003. case batchmsg.FieldBatchNo:
  2004. return m.OldBatchNo(ctx)
  2005. case batchmsg.FieldTaskName:
  2006. return m.OldTaskName(ctx)
  2007. case batchmsg.FieldFromwxid:
  2008. return m.OldFromwxid(ctx)
  2009. case batchmsg.FieldMsg:
  2010. return m.OldMsg(ctx)
  2011. case batchmsg.FieldTag:
  2012. return m.OldTag(ctx)
  2013. case batchmsg.FieldTotal:
  2014. return m.OldTotal(ctx)
  2015. case batchmsg.FieldSuccess:
  2016. return m.OldSuccess(ctx)
  2017. case batchmsg.FieldFail:
  2018. return m.OldFail(ctx)
  2019. case batchmsg.FieldStartTime:
  2020. return m.OldStartTime(ctx)
  2021. case batchmsg.FieldStopTime:
  2022. return m.OldStopTime(ctx)
  2023. case batchmsg.FieldType:
  2024. return m.OldType(ctx)
  2025. case batchmsg.FieldOrganizationID:
  2026. return m.OldOrganizationID(ctx)
  2027. }
  2028. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  2029. }
  2030. // SetField sets the value of a field with the given name. It returns an error if
  2031. // the field is not defined in the schema, or if the type mismatched the field
  2032. // type.
  2033. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  2034. switch name {
  2035. case batchmsg.FieldCreatedAt:
  2036. v, ok := value.(time.Time)
  2037. if !ok {
  2038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2039. }
  2040. m.SetCreatedAt(v)
  2041. return nil
  2042. case batchmsg.FieldUpdatedAt:
  2043. v, ok := value.(time.Time)
  2044. if !ok {
  2045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2046. }
  2047. m.SetUpdatedAt(v)
  2048. return nil
  2049. case batchmsg.FieldDeletedAt:
  2050. v, ok := value.(time.Time)
  2051. if !ok {
  2052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2053. }
  2054. m.SetDeletedAt(v)
  2055. return nil
  2056. case batchmsg.FieldStatus:
  2057. v, ok := value.(uint8)
  2058. if !ok {
  2059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2060. }
  2061. m.SetStatus(v)
  2062. return nil
  2063. case batchmsg.FieldBatchNo:
  2064. v, ok := value.(string)
  2065. if !ok {
  2066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2067. }
  2068. m.SetBatchNo(v)
  2069. return nil
  2070. case batchmsg.FieldTaskName:
  2071. v, ok := value.(string)
  2072. if !ok {
  2073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2074. }
  2075. m.SetTaskName(v)
  2076. return nil
  2077. case batchmsg.FieldFromwxid:
  2078. v, ok := value.(string)
  2079. if !ok {
  2080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2081. }
  2082. m.SetFromwxid(v)
  2083. return nil
  2084. case batchmsg.FieldMsg:
  2085. v, ok := value.(string)
  2086. if !ok {
  2087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2088. }
  2089. m.SetMsg(v)
  2090. return nil
  2091. case batchmsg.FieldTag:
  2092. v, ok := value.(string)
  2093. if !ok {
  2094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2095. }
  2096. m.SetTag(v)
  2097. return nil
  2098. case batchmsg.FieldTotal:
  2099. v, ok := value.(int32)
  2100. if !ok {
  2101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2102. }
  2103. m.SetTotal(v)
  2104. return nil
  2105. case batchmsg.FieldSuccess:
  2106. v, ok := value.(int32)
  2107. if !ok {
  2108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2109. }
  2110. m.SetSuccess(v)
  2111. return nil
  2112. case batchmsg.FieldFail:
  2113. v, ok := value.(int32)
  2114. if !ok {
  2115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2116. }
  2117. m.SetFail(v)
  2118. return nil
  2119. case batchmsg.FieldStartTime:
  2120. v, ok := value.(time.Time)
  2121. if !ok {
  2122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2123. }
  2124. m.SetStartTime(v)
  2125. return nil
  2126. case batchmsg.FieldStopTime:
  2127. v, ok := value.(time.Time)
  2128. if !ok {
  2129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2130. }
  2131. m.SetStopTime(v)
  2132. return nil
  2133. case batchmsg.FieldType:
  2134. v, ok := value.(int32)
  2135. if !ok {
  2136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2137. }
  2138. m.SetType(v)
  2139. return nil
  2140. case batchmsg.FieldOrganizationID:
  2141. v, ok := value.(uint64)
  2142. if !ok {
  2143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2144. }
  2145. m.SetOrganizationID(v)
  2146. return nil
  2147. }
  2148. return fmt.Errorf("unknown BatchMsg field %s", name)
  2149. }
  2150. // AddedFields returns all numeric fields that were incremented/decremented during
  2151. // this mutation.
  2152. func (m *BatchMsgMutation) AddedFields() []string {
  2153. var fields []string
  2154. if m.addstatus != nil {
  2155. fields = append(fields, batchmsg.FieldStatus)
  2156. }
  2157. if m.addtotal != nil {
  2158. fields = append(fields, batchmsg.FieldTotal)
  2159. }
  2160. if m.addsuccess != nil {
  2161. fields = append(fields, batchmsg.FieldSuccess)
  2162. }
  2163. if m.addfail != nil {
  2164. fields = append(fields, batchmsg.FieldFail)
  2165. }
  2166. if m.add_type != nil {
  2167. fields = append(fields, batchmsg.FieldType)
  2168. }
  2169. if m.addorganization_id != nil {
  2170. fields = append(fields, batchmsg.FieldOrganizationID)
  2171. }
  2172. return fields
  2173. }
  2174. // AddedField returns the numeric value that was incremented/decremented on a field
  2175. // with the given name. The second boolean return value indicates that this field
  2176. // was not set, or was not defined in the schema.
  2177. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  2178. switch name {
  2179. case batchmsg.FieldStatus:
  2180. return m.AddedStatus()
  2181. case batchmsg.FieldTotal:
  2182. return m.AddedTotal()
  2183. case batchmsg.FieldSuccess:
  2184. return m.AddedSuccess()
  2185. case batchmsg.FieldFail:
  2186. return m.AddedFail()
  2187. case batchmsg.FieldType:
  2188. return m.AddedType()
  2189. case batchmsg.FieldOrganizationID:
  2190. return m.AddedOrganizationID()
  2191. }
  2192. return nil, false
  2193. }
  2194. // AddField adds the value to the field with the given name. It returns an error if
  2195. // the field is not defined in the schema, or if the type mismatched the field
  2196. // type.
  2197. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  2198. switch name {
  2199. case batchmsg.FieldStatus:
  2200. v, ok := value.(int8)
  2201. if !ok {
  2202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2203. }
  2204. m.AddStatus(v)
  2205. return nil
  2206. case batchmsg.FieldTotal:
  2207. v, ok := value.(int32)
  2208. if !ok {
  2209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2210. }
  2211. m.AddTotal(v)
  2212. return nil
  2213. case batchmsg.FieldSuccess:
  2214. v, ok := value.(int32)
  2215. if !ok {
  2216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2217. }
  2218. m.AddSuccess(v)
  2219. return nil
  2220. case batchmsg.FieldFail:
  2221. v, ok := value.(int32)
  2222. if !ok {
  2223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2224. }
  2225. m.AddFail(v)
  2226. return nil
  2227. case batchmsg.FieldType:
  2228. v, ok := value.(int32)
  2229. if !ok {
  2230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2231. }
  2232. m.AddType(v)
  2233. return nil
  2234. case batchmsg.FieldOrganizationID:
  2235. v, ok := value.(int64)
  2236. if !ok {
  2237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2238. }
  2239. m.AddOrganizationID(v)
  2240. return nil
  2241. }
  2242. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  2243. }
  2244. // ClearedFields returns all nullable fields that were cleared during this
  2245. // mutation.
  2246. func (m *BatchMsgMutation) ClearedFields() []string {
  2247. var fields []string
  2248. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  2249. fields = append(fields, batchmsg.FieldDeletedAt)
  2250. }
  2251. if m.FieldCleared(batchmsg.FieldStatus) {
  2252. fields = append(fields, batchmsg.FieldStatus)
  2253. }
  2254. if m.FieldCleared(batchmsg.FieldBatchNo) {
  2255. fields = append(fields, batchmsg.FieldBatchNo)
  2256. }
  2257. if m.FieldCleared(batchmsg.FieldTaskName) {
  2258. fields = append(fields, batchmsg.FieldTaskName)
  2259. }
  2260. if m.FieldCleared(batchmsg.FieldFromwxid) {
  2261. fields = append(fields, batchmsg.FieldFromwxid)
  2262. }
  2263. if m.FieldCleared(batchmsg.FieldMsg) {
  2264. fields = append(fields, batchmsg.FieldMsg)
  2265. }
  2266. if m.FieldCleared(batchmsg.FieldTag) {
  2267. fields = append(fields, batchmsg.FieldTag)
  2268. }
  2269. if m.FieldCleared(batchmsg.FieldTotal) {
  2270. fields = append(fields, batchmsg.FieldTotal)
  2271. }
  2272. if m.FieldCleared(batchmsg.FieldSuccess) {
  2273. fields = append(fields, batchmsg.FieldSuccess)
  2274. }
  2275. if m.FieldCleared(batchmsg.FieldFail) {
  2276. fields = append(fields, batchmsg.FieldFail)
  2277. }
  2278. if m.FieldCleared(batchmsg.FieldStartTime) {
  2279. fields = append(fields, batchmsg.FieldStartTime)
  2280. }
  2281. if m.FieldCleared(batchmsg.FieldStopTime) {
  2282. fields = append(fields, batchmsg.FieldStopTime)
  2283. }
  2284. if m.FieldCleared(batchmsg.FieldType) {
  2285. fields = append(fields, batchmsg.FieldType)
  2286. }
  2287. return fields
  2288. }
  2289. // FieldCleared returns a boolean indicating if a field with the given name was
  2290. // cleared in this mutation.
  2291. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  2292. _, ok := m.clearedFields[name]
  2293. return ok
  2294. }
  2295. // ClearField clears the value of the field with the given name. It returns an
  2296. // error if the field is not defined in the schema.
  2297. func (m *BatchMsgMutation) ClearField(name string) error {
  2298. switch name {
  2299. case batchmsg.FieldDeletedAt:
  2300. m.ClearDeletedAt()
  2301. return nil
  2302. case batchmsg.FieldStatus:
  2303. m.ClearStatus()
  2304. return nil
  2305. case batchmsg.FieldBatchNo:
  2306. m.ClearBatchNo()
  2307. return nil
  2308. case batchmsg.FieldTaskName:
  2309. m.ClearTaskName()
  2310. return nil
  2311. case batchmsg.FieldFromwxid:
  2312. m.ClearFromwxid()
  2313. return nil
  2314. case batchmsg.FieldMsg:
  2315. m.ClearMsg()
  2316. return nil
  2317. case batchmsg.FieldTag:
  2318. m.ClearTag()
  2319. return nil
  2320. case batchmsg.FieldTotal:
  2321. m.ClearTotal()
  2322. return nil
  2323. case batchmsg.FieldSuccess:
  2324. m.ClearSuccess()
  2325. return nil
  2326. case batchmsg.FieldFail:
  2327. m.ClearFail()
  2328. return nil
  2329. case batchmsg.FieldStartTime:
  2330. m.ClearStartTime()
  2331. return nil
  2332. case batchmsg.FieldStopTime:
  2333. m.ClearStopTime()
  2334. return nil
  2335. case batchmsg.FieldType:
  2336. m.ClearType()
  2337. return nil
  2338. }
  2339. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  2340. }
  2341. // ResetField resets all changes in the mutation for the field with the given name.
  2342. // It returns an error if the field is not defined in the schema.
  2343. func (m *BatchMsgMutation) ResetField(name string) error {
  2344. switch name {
  2345. case batchmsg.FieldCreatedAt:
  2346. m.ResetCreatedAt()
  2347. return nil
  2348. case batchmsg.FieldUpdatedAt:
  2349. m.ResetUpdatedAt()
  2350. return nil
  2351. case batchmsg.FieldDeletedAt:
  2352. m.ResetDeletedAt()
  2353. return nil
  2354. case batchmsg.FieldStatus:
  2355. m.ResetStatus()
  2356. return nil
  2357. case batchmsg.FieldBatchNo:
  2358. m.ResetBatchNo()
  2359. return nil
  2360. case batchmsg.FieldTaskName:
  2361. m.ResetTaskName()
  2362. return nil
  2363. case batchmsg.FieldFromwxid:
  2364. m.ResetFromwxid()
  2365. return nil
  2366. case batchmsg.FieldMsg:
  2367. m.ResetMsg()
  2368. return nil
  2369. case batchmsg.FieldTag:
  2370. m.ResetTag()
  2371. return nil
  2372. case batchmsg.FieldTotal:
  2373. m.ResetTotal()
  2374. return nil
  2375. case batchmsg.FieldSuccess:
  2376. m.ResetSuccess()
  2377. return nil
  2378. case batchmsg.FieldFail:
  2379. m.ResetFail()
  2380. return nil
  2381. case batchmsg.FieldStartTime:
  2382. m.ResetStartTime()
  2383. return nil
  2384. case batchmsg.FieldStopTime:
  2385. m.ResetStopTime()
  2386. return nil
  2387. case batchmsg.FieldType:
  2388. m.ResetType()
  2389. return nil
  2390. case batchmsg.FieldOrganizationID:
  2391. m.ResetOrganizationID()
  2392. return nil
  2393. }
  2394. return fmt.Errorf("unknown BatchMsg field %s", name)
  2395. }
  2396. // AddedEdges returns all edge names that were set/added in this mutation.
  2397. func (m *BatchMsgMutation) AddedEdges() []string {
  2398. edges := make([]string, 0, 0)
  2399. return edges
  2400. }
  2401. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2402. // name in this mutation.
  2403. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  2404. return nil
  2405. }
  2406. // RemovedEdges returns all edge names that were removed in this mutation.
  2407. func (m *BatchMsgMutation) RemovedEdges() []string {
  2408. edges := make([]string, 0, 0)
  2409. return edges
  2410. }
  2411. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2412. // the given name in this mutation.
  2413. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  2414. return nil
  2415. }
  2416. // ClearedEdges returns all edge names that were cleared in this mutation.
  2417. func (m *BatchMsgMutation) ClearedEdges() []string {
  2418. edges := make([]string, 0, 0)
  2419. return edges
  2420. }
  2421. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2422. // was cleared in this mutation.
  2423. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  2424. return false
  2425. }
  2426. // ClearEdge clears the value of the edge with the given name. It returns an error
  2427. // if that edge is not defined in the schema.
  2428. func (m *BatchMsgMutation) ClearEdge(name string) error {
  2429. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  2430. }
  2431. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2432. // It returns an error if the edge is not defined in the schema.
  2433. func (m *BatchMsgMutation) ResetEdge(name string) error {
  2434. return fmt.Errorf("unknown BatchMsg edge %s", name)
  2435. }
  2436. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  2437. type ContactMutation struct {
  2438. config
  2439. op Op
  2440. typ string
  2441. id *uint64
  2442. created_at *time.Time
  2443. updated_at *time.Time
  2444. status *uint8
  2445. addstatus *int8
  2446. deleted_at *time.Time
  2447. wx_wxid *string
  2448. _type *int
  2449. add_type *int
  2450. wxid *string
  2451. account *string
  2452. nickname *string
  2453. markname *string
  2454. headimg *string
  2455. sex *int
  2456. addsex *int
  2457. starrole *string
  2458. dontseeit *int
  2459. adddontseeit *int
  2460. dontseeme *int
  2461. adddontseeme *int
  2462. lag *string
  2463. gid *string
  2464. gname *string
  2465. v3 *string
  2466. organization_id *uint64
  2467. addorganization_id *int64
  2468. clearedFields map[string]struct{}
  2469. contact_relationships map[uint64]struct{}
  2470. removedcontact_relationships map[uint64]struct{}
  2471. clearedcontact_relationships bool
  2472. contact_messages map[uint64]struct{}
  2473. removedcontact_messages map[uint64]struct{}
  2474. clearedcontact_messages bool
  2475. done bool
  2476. oldValue func(context.Context) (*Contact, error)
  2477. predicates []predicate.Contact
  2478. }
  2479. var _ ent.Mutation = (*ContactMutation)(nil)
  2480. // contactOption allows management of the mutation configuration using functional options.
  2481. type contactOption func(*ContactMutation)
  2482. // newContactMutation creates new mutation for the Contact entity.
  2483. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  2484. m := &ContactMutation{
  2485. config: c,
  2486. op: op,
  2487. typ: TypeContact,
  2488. clearedFields: make(map[string]struct{}),
  2489. }
  2490. for _, opt := range opts {
  2491. opt(m)
  2492. }
  2493. return m
  2494. }
  2495. // withContactID sets the ID field of the mutation.
  2496. func withContactID(id uint64) contactOption {
  2497. return func(m *ContactMutation) {
  2498. var (
  2499. err error
  2500. once sync.Once
  2501. value *Contact
  2502. )
  2503. m.oldValue = func(ctx context.Context) (*Contact, error) {
  2504. once.Do(func() {
  2505. if m.done {
  2506. err = errors.New("querying old values post mutation is not allowed")
  2507. } else {
  2508. value, err = m.Client().Contact.Get(ctx, id)
  2509. }
  2510. })
  2511. return value, err
  2512. }
  2513. m.id = &id
  2514. }
  2515. }
  2516. // withContact sets the old Contact of the mutation.
  2517. func withContact(node *Contact) contactOption {
  2518. return func(m *ContactMutation) {
  2519. m.oldValue = func(context.Context) (*Contact, error) {
  2520. return node, nil
  2521. }
  2522. m.id = &node.ID
  2523. }
  2524. }
  2525. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2526. // executed in a transaction (ent.Tx), a transactional client is returned.
  2527. func (m ContactMutation) Client() *Client {
  2528. client := &Client{config: m.config}
  2529. client.init()
  2530. return client
  2531. }
  2532. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2533. // it returns an error otherwise.
  2534. func (m ContactMutation) Tx() (*Tx, error) {
  2535. if _, ok := m.driver.(*txDriver); !ok {
  2536. return nil, errors.New("ent: mutation is not running in a transaction")
  2537. }
  2538. tx := &Tx{config: m.config}
  2539. tx.init()
  2540. return tx, nil
  2541. }
  2542. // SetID sets the value of the id field. Note that this
  2543. // operation is only accepted on creation of Contact entities.
  2544. func (m *ContactMutation) SetID(id uint64) {
  2545. m.id = &id
  2546. }
  2547. // ID returns the ID value in the mutation. Note that the ID is only available
  2548. // if it was provided to the builder or after it was returned from the database.
  2549. func (m *ContactMutation) ID() (id uint64, exists bool) {
  2550. if m.id == nil {
  2551. return
  2552. }
  2553. return *m.id, true
  2554. }
  2555. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2556. // That means, if the mutation is applied within a transaction with an isolation level such
  2557. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2558. // or updated by the mutation.
  2559. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  2560. switch {
  2561. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2562. id, exists := m.ID()
  2563. if exists {
  2564. return []uint64{id}, nil
  2565. }
  2566. fallthrough
  2567. case m.op.Is(OpUpdate | OpDelete):
  2568. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  2569. default:
  2570. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2571. }
  2572. }
  2573. // SetCreatedAt sets the "created_at" field.
  2574. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  2575. m.created_at = &t
  2576. }
  2577. // CreatedAt returns the value of the "created_at" field in the mutation.
  2578. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  2579. v := m.created_at
  2580. if v == nil {
  2581. return
  2582. }
  2583. return *v, true
  2584. }
  2585. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  2586. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2588. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2589. if !m.op.Is(OpUpdateOne) {
  2590. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2591. }
  2592. if m.id == nil || m.oldValue == nil {
  2593. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2594. }
  2595. oldValue, err := m.oldValue(ctx)
  2596. if err != nil {
  2597. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2598. }
  2599. return oldValue.CreatedAt, nil
  2600. }
  2601. // ResetCreatedAt resets all changes to the "created_at" field.
  2602. func (m *ContactMutation) ResetCreatedAt() {
  2603. m.created_at = nil
  2604. }
  2605. // SetUpdatedAt sets the "updated_at" field.
  2606. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  2607. m.updated_at = &t
  2608. }
  2609. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2610. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  2611. v := m.updated_at
  2612. if v == nil {
  2613. return
  2614. }
  2615. return *v, true
  2616. }
  2617. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  2618. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2620. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2621. if !m.op.Is(OpUpdateOne) {
  2622. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2623. }
  2624. if m.id == nil || m.oldValue == nil {
  2625. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2626. }
  2627. oldValue, err := m.oldValue(ctx)
  2628. if err != nil {
  2629. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2630. }
  2631. return oldValue.UpdatedAt, nil
  2632. }
  2633. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2634. func (m *ContactMutation) ResetUpdatedAt() {
  2635. m.updated_at = nil
  2636. }
  2637. // SetStatus sets the "status" field.
  2638. func (m *ContactMutation) SetStatus(u uint8) {
  2639. m.status = &u
  2640. m.addstatus = nil
  2641. }
  2642. // Status returns the value of the "status" field in the mutation.
  2643. func (m *ContactMutation) Status() (r uint8, exists bool) {
  2644. v := m.status
  2645. if v == nil {
  2646. return
  2647. }
  2648. return *v, true
  2649. }
  2650. // OldStatus returns the old "status" field's value of the Contact entity.
  2651. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2653. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  2654. if !m.op.Is(OpUpdateOne) {
  2655. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  2656. }
  2657. if m.id == nil || m.oldValue == nil {
  2658. return v, errors.New("OldStatus requires an ID field in the mutation")
  2659. }
  2660. oldValue, err := m.oldValue(ctx)
  2661. if err != nil {
  2662. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  2663. }
  2664. return oldValue.Status, nil
  2665. }
  2666. // AddStatus adds u to the "status" field.
  2667. func (m *ContactMutation) AddStatus(u int8) {
  2668. if m.addstatus != nil {
  2669. *m.addstatus += u
  2670. } else {
  2671. m.addstatus = &u
  2672. }
  2673. }
  2674. // AddedStatus returns the value that was added to the "status" field in this mutation.
  2675. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  2676. v := m.addstatus
  2677. if v == nil {
  2678. return
  2679. }
  2680. return *v, true
  2681. }
  2682. // ClearStatus clears the value of the "status" field.
  2683. func (m *ContactMutation) ClearStatus() {
  2684. m.status = nil
  2685. m.addstatus = nil
  2686. m.clearedFields[contact.FieldStatus] = struct{}{}
  2687. }
  2688. // StatusCleared returns if the "status" field was cleared in this mutation.
  2689. func (m *ContactMutation) StatusCleared() bool {
  2690. _, ok := m.clearedFields[contact.FieldStatus]
  2691. return ok
  2692. }
  2693. // ResetStatus resets all changes to the "status" field.
  2694. func (m *ContactMutation) ResetStatus() {
  2695. m.status = nil
  2696. m.addstatus = nil
  2697. delete(m.clearedFields, contact.FieldStatus)
  2698. }
  2699. // SetDeletedAt sets the "deleted_at" field.
  2700. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  2701. m.deleted_at = &t
  2702. }
  2703. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2704. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  2705. v := m.deleted_at
  2706. if v == nil {
  2707. return
  2708. }
  2709. return *v, true
  2710. }
  2711. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  2712. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2714. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2715. if !m.op.Is(OpUpdateOne) {
  2716. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2717. }
  2718. if m.id == nil || m.oldValue == nil {
  2719. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2720. }
  2721. oldValue, err := m.oldValue(ctx)
  2722. if err != nil {
  2723. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2724. }
  2725. return oldValue.DeletedAt, nil
  2726. }
  2727. // ClearDeletedAt clears the value of the "deleted_at" field.
  2728. func (m *ContactMutation) ClearDeletedAt() {
  2729. m.deleted_at = nil
  2730. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  2731. }
  2732. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2733. func (m *ContactMutation) DeletedAtCleared() bool {
  2734. _, ok := m.clearedFields[contact.FieldDeletedAt]
  2735. return ok
  2736. }
  2737. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2738. func (m *ContactMutation) ResetDeletedAt() {
  2739. m.deleted_at = nil
  2740. delete(m.clearedFields, contact.FieldDeletedAt)
  2741. }
  2742. // SetWxWxid sets the "wx_wxid" field.
  2743. func (m *ContactMutation) SetWxWxid(s string) {
  2744. m.wx_wxid = &s
  2745. }
  2746. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  2747. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  2748. v := m.wx_wxid
  2749. if v == nil {
  2750. return
  2751. }
  2752. return *v, true
  2753. }
  2754. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  2755. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2757. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  2758. if !m.op.Is(OpUpdateOne) {
  2759. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  2760. }
  2761. if m.id == nil || m.oldValue == nil {
  2762. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  2763. }
  2764. oldValue, err := m.oldValue(ctx)
  2765. if err != nil {
  2766. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  2767. }
  2768. return oldValue.WxWxid, nil
  2769. }
  2770. // ClearWxWxid clears the value of the "wx_wxid" field.
  2771. func (m *ContactMutation) ClearWxWxid() {
  2772. m.wx_wxid = nil
  2773. m.clearedFields[contact.FieldWxWxid] = struct{}{}
  2774. }
  2775. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  2776. func (m *ContactMutation) WxWxidCleared() bool {
  2777. _, ok := m.clearedFields[contact.FieldWxWxid]
  2778. return ok
  2779. }
  2780. // ResetWxWxid resets all changes to the "wx_wxid" field.
  2781. func (m *ContactMutation) ResetWxWxid() {
  2782. m.wx_wxid = nil
  2783. delete(m.clearedFields, contact.FieldWxWxid)
  2784. }
  2785. // SetType sets the "type" field.
  2786. func (m *ContactMutation) SetType(i int) {
  2787. m._type = &i
  2788. m.add_type = nil
  2789. }
  2790. // GetType returns the value of the "type" field in the mutation.
  2791. func (m *ContactMutation) GetType() (r int, exists bool) {
  2792. v := m._type
  2793. if v == nil {
  2794. return
  2795. }
  2796. return *v, true
  2797. }
  2798. // OldType returns the old "type" field's value of the Contact entity.
  2799. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2801. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  2802. if !m.op.Is(OpUpdateOne) {
  2803. return v, errors.New("OldType is only allowed on UpdateOne operations")
  2804. }
  2805. if m.id == nil || m.oldValue == nil {
  2806. return v, errors.New("OldType requires an ID field in the mutation")
  2807. }
  2808. oldValue, err := m.oldValue(ctx)
  2809. if err != nil {
  2810. return v, fmt.Errorf("querying old value for OldType: %w", err)
  2811. }
  2812. return oldValue.Type, nil
  2813. }
  2814. // AddType adds i to the "type" field.
  2815. func (m *ContactMutation) AddType(i int) {
  2816. if m.add_type != nil {
  2817. *m.add_type += i
  2818. } else {
  2819. m.add_type = &i
  2820. }
  2821. }
  2822. // AddedType returns the value that was added to the "type" field in this mutation.
  2823. func (m *ContactMutation) AddedType() (r int, exists bool) {
  2824. v := m.add_type
  2825. if v == nil {
  2826. return
  2827. }
  2828. return *v, true
  2829. }
  2830. // ClearType clears the value of the "type" field.
  2831. func (m *ContactMutation) ClearType() {
  2832. m._type = nil
  2833. m.add_type = nil
  2834. m.clearedFields[contact.FieldType] = struct{}{}
  2835. }
  2836. // TypeCleared returns if the "type" field was cleared in this mutation.
  2837. func (m *ContactMutation) TypeCleared() bool {
  2838. _, ok := m.clearedFields[contact.FieldType]
  2839. return ok
  2840. }
  2841. // ResetType resets all changes to the "type" field.
  2842. func (m *ContactMutation) ResetType() {
  2843. m._type = nil
  2844. m.add_type = nil
  2845. delete(m.clearedFields, contact.FieldType)
  2846. }
  2847. // SetWxid sets the "wxid" field.
  2848. func (m *ContactMutation) SetWxid(s string) {
  2849. m.wxid = &s
  2850. }
  2851. // Wxid returns the value of the "wxid" field in the mutation.
  2852. func (m *ContactMutation) Wxid() (r string, exists bool) {
  2853. v := m.wxid
  2854. if v == nil {
  2855. return
  2856. }
  2857. return *v, true
  2858. }
  2859. // OldWxid returns the old "wxid" field's value of the Contact entity.
  2860. // If the Contact 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 *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  2863. if !m.op.Is(OpUpdateOne) {
  2864. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  2865. }
  2866. if m.id == nil || m.oldValue == nil {
  2867. return v, errors.New("OldWxid 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 OldWxid: %w", err)
  2872. }
  2873. return oldValue.Wxid, nil
  2874. }
  2875. // ResetWxid resets all changes to the "wxid" field.
  2876. func (m *ContactMutation) ResetWxid() {
  2877. m.wxid = nil
  2878. }
  2879. // SetAccount sets the "account" field.
  2880. func (m *ContactMutation) SetAccount(s string) {
  2881. m.account = &s
  2882. }
  2883. // Account returns the value of the "account" field in the mutation.
  2884. func (m *ContactMutation) Account() (r string, exists bool) {
  2885. v := m.account
  2886. if v == nil {
  2887. return
  2888. }
  2889. return *v, true
  2890. }
  2891. // OldAccount returns the old "account" field's value of the Contact entity.
  2892. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2894. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  2895. if !m.op.Is(OpUpdateOne) {
  2896. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  2897. }
  2898. if m.id == nil || m.oldValue == nil {
  2899. return v, errors.New("OldAccount requires an ID field in the mutation")
  2900. }
  2901. oldValue, err := m.oldValue(ctx)
  2902. if err != nil {
  2903. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  2904. }
  2905. return oldValue.Account, nil
  2906. }
  2907. // ResetAccount resets all changes to the "account" field.
  2908. func (m *ContactMutation) ResetAccount() {
  2909. m.account = nil
  2910. }
  2911. // SetNickname sets the "nickname" field.
  2912. func (m *ContactMutation) SetNickname(s string) {
  2913. m.nickname = &s
  2914. }
  2915. // Nickname returns the value of the "nickname" field in the mutation.
  2916. func (m *ContactMutation) Nickname() (r string, exists bool) {
  2917. v := m.nickname
  2918. if v == nil {
  2919. return
  2920. }
  2921. return *v, true
  2922. }
  2923. // OldNickname returns the old "nickname" field's value of the Contact entity.
  2924. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2925. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2926. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  2927. if !m.op.Is(OpUpdateOne) {
  2928. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  2929. }
  2930. if m.id == nil || m.oldValue == nil {
  2931. return v, errors.New("OldNickname requires an ID field in the mutation")
  2932. }
  2933. oldValue, err := m.oldValue(ctx)
  2934. if err != nil {
  2935. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  2936. }
  2937. return oldValue.Nickname, nil
  2938. }
  2939. // ResetNickname resets all changes to the "nickname" field.
  2940. func (m *ContactMutation) ResetNickname() {
  2941. m.nickname = nil
  2942. }
  2943. // SetMarkname sets the "markname" field.
  2944. func (m *ContactMutation) SetMarkname(s string) {
  2945. m.markname = &s
  2946. }
  2947. // Markname returns the value of the "markname" field in the mutation.
  2948. func (m *ContactMutation) Markname() (r string, exists bool) {
  2949. v := m.markname
  2950. if v == nil {
  2951. return
  2952. }
  2953. return *v, true
  2954. }
  2955. // OldMarkname returns the old "markname" field's value of the Contact entity.
  2956. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2958. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  2959. if !m.op.Is(OpUpdateOne) {
  2960. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  2961. }
  2962. if m.id == nil || m.oldValue == nil {
  2963. return v, errors.New("OldMarkname requires an ID field in the mutation")
  2964. }
  2965. oldValue, err := m.oldValue(ctx)
  2966. if err != nil {
  2967. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  2968. }
  2969. return oldValue.Markname, nil
  2970. }
  2971. // ResetMarkname resets all changes to the "markname" field.
  2972. func (m *ContactMutation) ResetMarkname() {
  2973. m.markname = nil
  2974. }
  2975. // SetHeadimg sets the "headimg" field.
  2976. func (m *ContactMutation) SetHeadimg(s string) {
  2977. m.headimg = &s
  2978. }
  2979. // Headimg returns the value of the "headimg" field in the mutation.
  2980. func (m *ContactMutation) Headimg() (r string, exists bool) {
  2981. v := m.headimg
  2982. if v == nil {
  2983. return
  2984. }
  2985. return *v, true
  2986. }
  2987. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  2988. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2990. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  2991. if !m.op.Is(OpUpdateOne) {
  2992. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  2993. }
  2994. if m.id == nil || m.oldValue == nil {
  2995. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  2996. }
  2997. oldValue, err := m.oldValue(ctx)
  2998. if err != nil {
  2999. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  3000. }
  3001. return oldValue.Headimg, nil
  3002. }
  3003. // ResetHeadimg resets all changes to the "headimg" field.
  3004. func (m *ContactMutation) ResetHeadimg() {
  3005. m.headimg = nil
  3006. }
  3007. // SetSex sets the "sex" field.
  3008. func (m *ContactMutation) SetSex(i int) {
  3009. m.sex = &i
  3010. m.addsex = nil
  3011. }
  3012. // Sex returns the value of the "sex" field in the mutation.
  3013. func (m *ContactMutation) Sex() (r int, exists bool) {
  3014. v := m.sex
  3015. if v == nil {
  3016. return
  3017. }
  3018. return *v, true
  3019. }
  3020. // OldSex returns the old "sex" field's value of the Contact entity.
  3021. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3023. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  3024. if !m.op.Is(OpUpdateOne) {
  3025. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  3026. }
  3027. if m.id == nil || m.oldValue == nil {
  3028. return v, errors.New("OldSex requires an ID field in the mutation")
  3029. }
  3030. oldValue, err := m.oldValue(ctx)
  3031. if err != nil {
  3032. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  3033. }
  3034. return oldValue.Sex, nil
  3035. }
  3036. // AddSex adds i to the "sex" field.
  3037. func (m *ContactMutation) AddSex(i int) {
  3038. if m.addsex != nil {
  3039. *m.addsex += i
  3040. } else {
  3041. m.addsex = &i
  3042. }
  3043. }
  3044. // AddedSex returns the value that was added to the "sex" field in this mutation.
  3045. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  3046. v := m.addsex
  3047. if v == nil {
  3048. return
  3049. }
  3050. return *v, true
  3051. }
  3052. // ResetSex resets all changes to the "sex" field.
  3053. func (m *ContactMutation) ResetSex() {
  3054. m.sex = nil
  3055. m.addsex = nil
  3056. }
  3057. // SetStarrole sets the "starrole" field.
  3058. func (m *ContactMutation) SetStarrole(s string) {
  3059. m.starrole = &s
  3060. }
  3061. // Starrole returns the value of the "starrole" field in the mutation.
  3062. func (m *ContactMutation) Starrole() (r string, exists bool) {
  3063. v := m.starrole
  3064. if v == nil {
  3065. return
  3066. }
  3067. return *v, true
  3068. }
  3069. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  3070. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3072. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  3073. if !m.op.Is(OpUpdateOne) {
  3074. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  3075. }
  3076. if m.id == nil || m.oldValue == nil {
  3077. return v, errors.New("OldStarrole requires an ID field in the mutation")
  3078. }
  3079. oldValue, err := m.oldValue(ctx)
  3080. if err != nil {
  3081. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  3082. }
  3083. return oldValue.Starrole, nil
  3084. }
  3085. // ResetStarrole resets all changes to the "starrole" field.
  3086. func (m *ContactMutation) ResetStarrole() {
  3087. m.starrole = nil
  3088. }
  3089. // SetDontseeit sets the "dontseeit" field.
  3090. func (m *ContactMutation) SetDontseeit(i int) {
  3091. m.dontseeit = &i
  3092. m.adddontseeit = nil
  3093. }
  3094. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  3095. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  3096. v := m.dontseeit
  3097. if v == nil {
  3098. return
  3099. }
  3100. return *v, true
  3101. }
  3102. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  3103. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3105. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  3106. if !m.op.Is(OpUpdateOne) {
  3107. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  3108. }
  3109. if m.id == nil || m.oldValue == nil {
  3110. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  3111. }
  3112. oldValue, err := m.oldValue(ctx)
  3113. if err != nil {
  3114. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  3115. }
  3116. return oldValue.Dontseeit, nil
  3117. }
  3118. // AddDontseeit adds i to the "dontseeit" field.
  3119. func (m *ContactMutation) AddDontseeit(i int) {
  3120. if m.adddontseeit != nil {
  3121. *m.adddontseeit += i
  3122. } else {
  3123. m.adddontseeit = &i
  3124. }
  3125. }
  3126. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  3127. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  3128. v := m.adddontseeit
  3129. if v == nil {
  3130. return
  3131. }
  3132. return *v, true
  3133. }
  3134. // ResetDontseeit resets all changes to the "dontseeit" field.
  3135. func (m *ContactMutation) ResetDontseeit() {
  3136. m.dontseeit = nil
  3137. m.adddontseeit = nil
  3138. }
  3139. // SetDontseeme sets the "dontseeme" field.
  3140. func (m *ContactMutation) SetDontseeme(i int) {
  3141. m.dontseeme = &i
  3142. m.adddontseeme = nil
  3143. }
  3144. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  3145. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  3146. v := m.dontseeme
  3147. if v == nil {
  3148. return
  3149. }
  3150. return *v, true
  3151. }
  3152. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  3153. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3155. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  3156. if !m.op.Is(OpUpdateOne) {
  3157. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  3158. }
  3159. if m.id == nil || m.oldValue == nil {
  3160. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  3161. }
  3162. oldValue, err := m.oldValue(ctx)
  3163. if err != nil {
  3164. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  3165. }
  3166. return oldValue.Dontseeme, nil
  3167. }
  3168. // AddDontseeme adds i to the "dontseeme" field.
  3169. func (m *ContactMutation) AddDontseeme(i int) {
  3170. if m.adddontseeme != nil {
  3171. *m.adddontseeme += i
  3172. } else {
  3173. m.adddontseeme = &i
  3174. }
  3175. }
  3176. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  3177. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  3178. v := m.adddontseeme
  3179. if v == nil {
  3180. return
  3181. }
  3182. return *v, true
  3183. }
  3184. // ResetDontseeme resets all changes to the "dontseeme" field.
  3185. func (m *ContactMutation) ResetDontseeme() {
  3186. m.dontseeme = nil
  3187. m.adddontseeme = nil
  3188. }
  3189. // SetLag sets the "lag" field.
  3190. func (m *ContactMutation) SetLag(s string) {
  3191. m.lag = &s
  3192. }
  3193. // Lag returns the value of the "lag" field in the mutation.
  3194. func (m *ContactMutation) Lag() (r string, exists bool) {
  3195. v := m.lag
  3196. if v == nil {
  3197. return
  3198. }
  3199. return *v, true
  3200. }
  3201. // OldLag returns the old "lag" field's value of the Contact entity.
  3202. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3204. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  3205. if !m.op.Is(OpUpdateOne) {
  3206. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  3207. }
  3208. if m.id == nil || m.oldValue == nil {
  3209. return v, errors.New("OldLag requires an ID field in the mutation")
  3210. }
  3211. oldValue, err := m.oldValue(ctx)
  3212. if err != nil {
  3213. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  3214. }
  3215. return oldValue.Lag, nil
  3216. }
  3217. // ResetLag resets all changes to the "lag" field.
  3218. func (m *ContactMutation) ResetLag() {
  3219. m.lag = nil
  3220. }
  3221. // SetGid sets the "gid" field.
  3222. func (m *ContactMutation) SetGid(s string) {
  3223. m.gid = &s
  3224. }
  3225. // Gid returns the value of the "gid" field in the mutation.
  3226. func (m *ContactMutation) Gid() (r string, exists bool) {
  3227. v := m.gid
  3228. if v == nil {
  3229. return
  3230. }
  3231. return *v, true
  3232. }
  3233. // OldGid returns the old "gid" field's value of the Contact entity.
  3234. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3236. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  3237. if !m.op.Is(OpUpdateOne) {
  3238. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  3239. }
  3240. if m.id == nil || m.oldValue == nil {
  3241. return v, errors.New("OldGid requires an ID field in the mutation")
  3242. }
  3243. oldValue, err := m.oldValue(ctx)
  3244. if err != nil {
  3245. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  3246. }
  3247. return oldValue.Gid, nil
  3248. }
  3249. // ResetGid resets all changes to the "gid" field.
  3250. func (m *ContactMutation) ResetGid() {
  3251. m.gid = nil
  3252. }
  3253. // SetGname sets the "gname" field.
  3254. func (m *ContactMutation) SetGname(s string) {
  3255. m.gname = &s
  3256. }
  3257. // Gname returns the value of the "gname" field in the mutation.
  3258. func (m *ContactMutation) Gname() (r string, exists bool) {
  3259. v := m.gname
  3260. if v == nil {
  3261. return
  3262. }
  3263. return *v, true
  3264. }
  3265. // OldGname returns the old "gname" field's value of the Contact entity.
  3266. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3268. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  3269. if !m.op.Is(OpUpdateOne) {
  3270. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  3271. }
  3272. if m.id == nil || m.oldValue == nil {
  3273. return v, errors.New("OldGname requires an ID field in the mutation")
  3274. }
  3275. oldValue, err := m.oldValue(ctx)
  3276. if err != nil {
  3277. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  3278. }
  3279. return oldValue.Gname, nil
  3280. }
  3281. // ResetGname resets all changes to the "gname" field.
  3282. func (m *ContactMutation) ResetGname() {
  3283. m.gname = nil
  3284. }
  3285. // SetV3 sets the "v3" field.
  3286. func (m *ContactMutation) SetV3(s string) {
  3287. m.v3 = &s
  3288. }
  3289. // V3 returns the value of the "v3" field in the mutation.
  3290. func (m *ContactMutation) V3() (r string, exists bool) {
  3291. v := m.v3
  3292. if v == nil {
  3293. return
  3294. }
  3295. return *v, true
  3296. }
  3297. // OldV3 returns the old "v3" field's value of the Contact entity.
  3298. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3300. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  3301. if !m.op.Is(OpUpdateOne) {
  3302. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  3303. }
  3304. if m.id == nil || m.oldValue == nil {
  3305. return v, errors.New("OldV3 requires an ID field in the mutation")
  3306. }
  3307. oldValue, err := m.oldValue(ctx)
  3308. if err != nil {
  3309. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  3310. }
  3311. return oldValue.V3, nil
  3312. }
  3313. // ResetV3 resets all changes to the "v3" field.
  3314. func (m *ContactMutation) ResetV3() {
  3315. m.v3 = nil
  3316. }
  3317. // SetOrganizationID sets the "organization_id" field.
  3318. func (m *ContactMutation) SetOrganizationID(u uint64) {
  3319. m.organization_id = &u
  3320. m.addorganization_id = nil
  3321. }
  3322. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3323. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  3324. v := m.organization_id
  3325. if v == nil {
  3326. return
  3327. }
  3328. return *v, true
  3329. }
  3330. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  3331. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3333. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3334. if !m.op.Is(OpUpdateOne) {
  3335. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3336. }
  3337. if m.id == nil || m.oldValue == nil {
  3338. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3339. }
  3340. oldValue, err := m.oldValue(ctx)
  3341. if err != nil {
  3342. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3343. }
  3344. return oldValue.OrganizationID, nil
  3345. }
  3346. // AddOrganizationID adds u to the "organization_id" field.
  3347. func (m *ContactMutation) AddOrganizationID(u int64) {
  3348. if m.addorganization_id != nil {
  3349. *m.addorganization_id += u
  3350. } else {
  3351. m.addorganization_id = &u
  3352. }
  3353. }
  3354. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3355. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  3356. v := m.addorganization_id
  3357. if v == nil {
  3358. return
  3359. }
  3360. return *v, true
  3361. }
  3362. // ClearOrganizationID clears the value of the "organization_id" field.
  3363. func (m *ContactMutation) ClearOrganizationID() {
  3364. m.organization_id = nil
  3365. m.addorganization_id = nil
  3366. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  3367. }
  3368. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3369. func (m *ContactMutation) OrganizationIDCleared() bool {
  3370. _, ok := m.clearedFields[contact.FieldOrganizationID]
  3371. return ok
  3372. }
  3373. // ResetOrganizationID resets all changes to the "organization_id" field.
  3374. func (m *ContactMutation) ResetOrganizationID() {
  3375. m.organization_id = nil
  3376. m.addorganization_id = nil
  3377. delete(m.clearedFields, contact.FieldOrganizationID)
  3378. }
  3379. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  3380. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  3381. if m.contact_relationships == nil {
  3382. m.contact_relationships = make(map[uint64]struct{})
  3383. }
  3384. for i := range ids {
  3385. m.contact_relationships[ids[i]] = struct{}{}
  3386. }
  3387. }
  3388. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  3389. func (m *ContactMutation) ClearContactRelationships() {
  3390. m.clearedcontact_relationships = true
  3391. }
  3392. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  3393. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  3394. return m.clearedcontact_relationships
  3395. }
  3396. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  3397. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  3398. if m.removedcontact_relationships == nil {
  3399. m.removedcontact_relationships = make(map[uint64]struct{})
  3400. }
  3401. for i := range ids {
  3402. delete(m.contact_relationships, ids[i])
  3403. m.removedcontact_relationships[ids[i]] = struct{}{}
  3404. }
  3405. }
  3406. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  3407. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  3408. for id := range m.removedcontact_relationships {
  3409. ids = append(ids, id)
  3410. }
  3411. return
  3412. }
  3413. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  3414. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  3415. for id := range m.contact_relationships {
  3416. ids = append(ids, id)
  3417. }
  3418. return
  3419. }
  3420. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  3421. func (m *ContactMutation) ResetContactRelationships() {
  3422. m.contact_relationships = nil
  3423. m.clearedcontact_relationships = false
  3424. m.removedcontact_relationships = nil
  3425. }
  3426. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  3427. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  3428. if m.contact_messages == nil {
  3429. m.contact_messages = make(map[uint64]struct{})
  3430. }
  3431. for i := range ids {
  3432. m.contact_messages[ids[i]] = struct{}{}
  3433. }
  3434. }
  3435. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  3436. func (m *ContactMutation) ClearContactMessages() {
  3437. m.clearedcontact_messages = true
  3438. }
  3439. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  3440. func (m *ContactMutation) ContactMessagesCleared() bool {
  3441. return m.clearedcontact_messages
  3442. }
  3443. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  3444. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  3445. if m.removedcontact_messages == nil {
  3446. m.removedcontact_messages = make(map[uint64]struct{})
  3447. }
  3448. for i := range ids {
  3449. delete(m.contact_messages, ids[i])
  3450. m.removedcontact_messages[ids[i]] = struct{}{}
  3451. }
  3452. }
  3453. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  3454. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  3455. for id := range m.removedcontact_messages {
  3456. ids = append(ids, id)
  3457. }
  3458. return
  3459. }
  3460. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  3461. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  3462. for id := range m.contact_messages {
  3463. ids = append(ids, id)
  3464. }
  3465. return
  3466. }
  3467. // ResetContactMessages resets all changes to the "contact_messages" edge.
  3468. func (m *ContactMutation) ResetContactMessages() {
  3469. m.contact_messages = nil
  3470. m.clearedcontact_messages = false
  3471. m.removedcontact_messages = nil
  3472. }
  3473. // Where appends a list predicates to the ContactMutation builder.
  3474. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  3475. m.predicates = append(m.predicates, ps...)
  3476. }
  3477. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  3478. // users can use type-assertion to append predicates that do not depend on any generated package.
  3479. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  3480. p := make([]predicate.Contact, len(ps))
  3481. for i := range ps {
  3482. p[i] = ps[i]
  3483. }
  3484. m.Where(p...)
  3485. }
  3486. // Op returns the operation name.
  3487. func (m *ContactMutation) Op() Op {
  3488. return m.op
  3489. }
  3490. // SetOp allows setting the mutation operation.
  3491. func (m *ContactMutation) SetOp(op Op) {
  3492. m.op = op
  3493. }
  3494. // Type returns the node type of this mutation (Contact).
  3495. func (m *ContactMutation) Type() string {
  3496. return m.typ
  3497. }
  3498. // Fields returns all fields that were changed during this mutation. Note that in
  3499. // order to get all numeric fields that were incremented/decremented, call
  3500. // AddedFields().
  3501. func (m *ContactMutation) Fields() []string {
  3502. fields := make([]string, 0, 20)
  3503. if m.created_at != nil {
  3504. fields = append(fields, contact.FieldCreatedAt)
  3505. }
  3506. if m.updated_at != nil {
  3507. fields = append(fields, contact.FieldUpdatedAt)
  3508. }
  3509. if m.status != nil {
  3510. fields = append(fields, contact.FieldStatus)
  3511. }
  3512. if m.deleted_at != nil {
  3513. fields = append(fields, contact.FieldDeletedAt)
  3514. }
  3515. if m.wx_wxid != nil {
  3516. fields = append(fields, contact.FieldWxWxid)
  3517. }
  3518. if m._type != nil {
  3519. fields = append(fields, contact.FieldType)
  3520. }
  3521. if m.wxid != nil {
  3522. fields = append(fields, contact.FieldWxid)
  3523. }
  3524. if m.account != nil {
  3525. fields = append(fields, contact.FieldAccount)
  3526. }
  3527. if m.nickname != nil {
  3528. fields = append(fields, contact.FieldNickname)
  3529. }
  3530. if m.markname != nil {
  3531. fields = append(fields, contact.FieldMarkname)
  3532. }
  3533. if m.headimg != nil {
  3534. fields = append(fields, contact.FieldHeadimg)
  3535. }
  3536. if m.sex != nil {
  3537. fields = append(fields, contact.FieldSex)
  3538. }
  3539. if m.starrole != nil {
  3540. fields = append(fields, contact.FieldStarrole)
  3541. }
  3542. if m.dontseeit != nil {
  3543. fields = append(fields, contact.FieldDontseeit)
  3544. }
  3545. if m.dontseeme != nil {
  3546. fields = append(fields, contact.FieldDontseeme)
  3547. }
  3548. if m.lag != nil {
  3549. fields = append(fields, contact.FieldLag)
  3550. }
  3551. if m.gid != nil {
  3552. fields = append(fields, contact.FieldGid)
  3553. }
  3554. if m.gname != nil {
  3555. fields = append(fields, contact.FieldGname)
  3556. }
  3557. if m.v3 != nil {
  3558. fields = append(fields, contact.FieldV3)
  3559. }
  3560. if m.organization_id != nil {
  3561. fields = append(fields, contact.FieldOrganizationID)
  3562. }
  3563. return fields
  3564. }
  3565. // Field returns the value of a field with the given name. The second boolean
  3566. // return value indicates that this field was not set, or was not defined in the
  3567. // schema.
  3568. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  3569. switch name {
  3570. case contact.FieldCreatedAt:
  3571. return m.CreatedAt()
  3572. case contact.FieldUpdatedAt:
  3573. return m.UpdatedAt()
  3574. case contact.FieldStatus:
  3575. return m.Status()
  3576. case contact.FieldDeletedAt:
  3577. return m.DeletedAt()
  3578. case contact.FieldWxWxid:
  3579. return m.WxWxid()
  3580. case contact.FieldType:
  3581. return m.GetType()
  3582. case contact.FieldWxid:
  3583. return m.Wxid()
  3584. case contact.FieldAccount:
  3585. return m.Account()
  3586. case contact.FieldNickname:
  3587. return m.Nickname()
  3588. case contact.FieldMarkname:
  3589. return m.Markname()
  3590. case contact.FieldHeadimg:
  3591. return m.Headimg()
  3592. case contact.FieldSex:
  3593. return m.Sex()
  3594. case contact.FieldStarrole:
  3595. return m.Starrole()
  3596. case contact.FieldDontseeit:
  3597. return m.Dontseeit()
  3598. case contact.FieldDontseeme:
  3599. return m.Dontseeme()
  3600. case contact.FieldLag:
  3601. return m.Lag()
  3602. case contact.FieldGid:
  3603. return m.Gid()
  3604. case contact.FieldGname:
  3605. return m.Gname()
  3606. case contact.FieldV3:
  3607. return m.V3()
  3608. case contact.FieldOrganizationID:
  3609. return m.OrganizationID()
  3610. }
  3611. return nil, false
  3612. }
  3613. // OldField returns the old value of the field from the database. An error is
  3614. // returned if the mutation operation is not UpdateOne, or the query to the
  3615. // database failed.
  3616. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3617. switch name {
  3618. case contact.FieldCreatedAt:
  3619. return m.OldCreatedAt(ctx)
  3620. case contact.FieldUpdatedAt:
  3621. return m.OldUpdatedAt(ctx)
  3622. case contact.FieldStatus:
  3623. return m.OldStatus(ctx)
  3624. case contact.FieldDeletedAt:
  3625. return m.OldDeletedAt(ctx)
  3626. case contact.FieldWxWxid:
  3627. return m.OldWxWxid(ctx)
  3628. case contact.FieldType:
  3629. return m.OldType(ctx)
  3630. case contact.FieldWxid:
  3631. return m.OldWxid(ctx)
  3632. case contact.FieldAccount:
  3633. return m.OldAccount(ctx)
  3634. case contact.FieldNickname:
  3635. return m.OldNickname(ctx)
  3636. case contact.FieldMarkname:
  3637. return m.OldMarkname(ctx)
  3638. case contact.FieldHeadimg:
  3639. return m.OldHeadimg(ctx)
  3640. case contact.FieldSex:
  3641. return m.OldSex(ctx)
  3642. case contact.FieldStarrole:
  3643. return m.OldStarrole(ctx)
  3644. case contact.FieldDontseeit:
  3645. return m.OldDontseeit(ctx)
  3646. case contact.FieldDontseeme:
  3647. return m.OldDontseeme(ctx)
  3648. case contact.FieldLag:
  3649. return m.OldLag(ctx)
  3650. case contact.FieldGid:
  3651. return m.OldGid(ctx)
  3652. case contact.FieldGname:
  3653. return m.OldGname(ctx)
  3654. case contact.FieldV3:
  3655. return m.OldV3(ctx)
  3656. case contact.FieldOrganizationID:
  3657. return m.OldOrganizationID(ctx)
  3658. }
  3659. return nil, fmt.Errorf("unknown Contact field %s", name)
  3660. }
  3661. // SetField sets the value of a field with the given name. It returns an error if
  3662. // the field is not defined in the schema, or if the type mismatched the field
  3663. // type.
  3664. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  3665. switch name {
  3666. case contact.FieldCreatedAt:
  3667. v, ok := value.(time.Time)
  3668. if !ok {
  3669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3670. }
  3671. m.SetCreatedAt(v)
  3672. return nil
  3673. case contact.FieldUpdatedAt:
  3674. v, ok := value.(time.Time)
  3675. if !ok {
  3676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3677. }
  3678. m.SetUpdatedAt(v)
  3679. return nil
  3680. case contact.FieldStatus:
  3681. v, ok := value.(uint8)
  3682. if !ok {
  3683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3684. }
  3685. m.SetStatus(v)
  3686. return nil
  3687. case contact.FieldDeletedAt:
  3688. v, ok := value.(time.Time)
  3689. if !ok {
  3690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3691. }
  3692. m.SetDeletedAt(v)
  3693. return nil
  3694. case contact.FieldWxWxid:
  3695. v, ok := value.(string)
  3696. if !ok {
  3697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3698. }
  3699. m.SetWxWxid(v)
  3700. return nil
  3701. case contact.FieldType:
  3702. v, ok := value.(int)
  3703. if !ok {
  3704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3705. }
  3706. m.SetType(v)
  3707. return nil
  3708. case contact.FieldWxid:
  3709. v, ok := value.(string)
  3710. if !ok {
  3711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3712. }
  3713. m.SetWxid(v)
  3714. return nil
  3715. case contact.FieldAccount:
  3716. v, ok := value.(string)
  3717. if !ok {
  3718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3719. }
  3720. m.SetAccount(v)
  3721. return nil
  3722. case contact.FieldNickname:
  3723. v, ok := value.(string)
  3724. if !ok {
  3725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3726. }
  3727. m.SetNickname(v)
  3728. return nil
  3729. case contact.FieldMarkname:
  3730. v, ok := value.(string)
  3731. if !ok {
  3732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3733. }
  3734. m.SetMarkname(v)
  3735. return nil
  3736. case contact.FieldHeadimg:
  3737. v, ok := value.(string)
  3738. if !ok {
  3739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3740. }
  3741. m.SetHeadimg(v)
  3742. return nil
  3743. case contact.FieldSex:
  3744. v, ok := value.(int)
  3745. if !ok {
  3746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3747. }
  3748. m.SetSex(v)
  3749. return nil
  3750. case contact.FieldStarrole:
  3751. v, ok := value.(string)
  3752. if !ok {
  3753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3754. }
  3755. m.SetStarrole(v)
  3756. return nil
  3757. case contact.FieldDontseeit:
  3758. v, ok := value.(int)
  3759. if !ok {
  3760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3761. }
  3762. m.SetDontseeit(v)
  3763. return nil
  3764. case contact.FieldDontseeme:
  3765. v, ok := value.(int)
  3766. if !ok {
  3767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3768. }
  3769. m.SetDontseeme(v)
  3770. return nil
  3771. case contact.FieldLag:
  3772. v, ok := value.(string)
  3773. if !ok {
  3774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3775. }
  3776. m.SetLag(v)
  3777. return nil
  3778. case contact.FieldGid:
  3779. v, ok := value.(string)
  3780. if !ok {
  3781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3782. }
  3783. m.SetGid(v)
  3784. return nil
  3785. case contact.FieldGname:
  3786. v, ok := value.(string)
  3787. if !ok {
  3788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3789. }
  3790. m.SetGname(v)
  3791. return nil
  3792. case contact.FieldV3:
  3793. v, ok := value.(string)
  3794. if !ok {
  3795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3796. }
  3797. m.SetV3(v)
  3798. return nil
  3799. case contact.FieldOrganizationID:
  3800. v, ok := value.(uint64)
  3801. if !ok {
  3802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3803. }
  3804. m.SetOrganizationID(v)
  3805. return nil
  3806. }
  3807. return fmt.Errorf("unknown Contact field %s", name)
  3808. }
  3809. // AddedFields returns all numeric fields that were incremented/decremented during
  3810. // this mutation.
  3811. func (m *ContactMutation) AddedFields() []string {
  3812. var fields []string
  3813. if m.addstatus != nil {
  3814. fields = append(fields, contact.FieldStatus)
  3815. }
  3816. if m.add_type != nil {
  3817. fields = append(fields, contact.FieldType)
  3818. }
  3819. if m.addsex != nil {
  3820. fields = append(fields, contact.FieldSex)
  3821. }
  3822. if m.adddontseeit != nil {
  3823. fields = append(fields, contact.FieldDontseeit)
  3824. }
  3825. if m.adddontseeme != nil {
  3826. fields = append(fields, contact.FieldDontseeme)
  3827. }
  3828. if m.addorganization_id != nil {
  3829. fields = append(fields, contact.FieldOrganizationID)
  3830. }
  3831. return fields
  3832. }
  3833. // AddedField returns the numeric value that was incremented/decremented on a field
  3834. // with the given name. The second boolean return value indicates that this field
  3835. // was not set, or was not defined in the schema.
  3836. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  3837. switch name {
  3838. case contact.FieldStatus:
  3839. return m.AddedStatus()
  3840. case contact.FieldType:
  3841. return m.AddedType()
  3842. case contact.FieldSex:
  3843. return m.AddedSex()
  3844. case contact.FieldDontseeit:
  3845. return m.AddedDontseeit()
  3846. case contact.FieldDontseeme:
  3847. return m.AddedDontseeme()
  3848. case contact.FieldOrganizationID:
  3849. return m.AddedOrganizationID()
  3850. }
  3851. return nil, false
  3852. }
  3853. // AddField adds the value to the field with the given name. It returns an error if
  3854. // the field is not defined in the schema, or if the type mismatched the field
  3855. // type.
  3856. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  3857. switch name {
  3858. case contact.FieldStatus:
  3859. v, ok := value.(int8)
  3860. if !ok {
  3861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3862. }
  3863. m.AddStatus(v)
  3864. return nil
  3865. case contact.FieldType:
  3866. v, ok := value.(int)
  3867. if !ok {
  3868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3869. }
  3870. m.AddType(v)
  3871. return nil
  3872. case contact.FieldSex:
  3873. v, ok := value.(int)
  3874. if !ok {
  3875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3876. }
  3877. m.AddSex(v)
  3878. return nil
  3879. case contact.FieldDontseeit:
  3880. v, ok := value.(int)
  3881. if !ok {
  3882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3883. }
  3884. m.AddDontseeit(v)
  3885. return nil
  3886. case contact.FieldDontseeme:
  3887. v, ok := value.(int)
  3888. if !ok {
  3889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3890. }
  3891. m.AddDontseeme(v)
  3892. return nil
  3893. case contact.FieldOrganizationID:
  3894. v, ok := value.(int64)
  3895. if !ok {
  3896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3897. }
  3898. m.AddOrganizationID(v)
  3899. return nil
  3900. }
  3901. return fmt.Errorf("unknown Contact numeric field %s", name)
  3902. }
  3903. // ClearedFields returns all nullable fields that were cleared during this
  3904. // mutation.
  3905. func (m *ContactMutation) ClearedFields() []string {
  3906. var fields []string
  3907. if m.FieldCleared(contact.FieldStatus) {
  3908. fields = append(fields, contact.FieldStatus)
  3909. }
  3910. if m.FieldCleared(contact.FieldDeletedAt) {
  3911. fields = append(fields, contact.FieldDeletedAt)
  3912. }
  3913. if m.FieldCleared(contact.FieldWxWxid) {
  3914. fields = append(fields, contact.FieldWxWxid)
  3915. }
  3916. if m.FieldCleared(contact.FieldType) {
  3917. fields = append(fields, contact.FieldType)
  3918. }
  3919. if m.FieldCleared(contact.FieldOrganizationID) {
  3920. fields = append(fields, contact.FieldOrganizationID)
  3921. }
  3922. return fields
  3923. }
  3924. // FieldCleared returns a boolean indicating if a field with the given name was
  3925. // cleared in this mutation.
  3926. func (m *ContactMutation) FieldCleared(name string) bool {
  3927. _, ok := m.clearedFields[name]
  3928. return ok
  3929. }
  3930. // ClearField clears the value of the field with the given name. It returns an
  3931. // error if the field is not defined in the schema.
  3932. func (m *ContactMutation) ClearField(name string) error {
  3933. switch name {
  3934. case contact.FieldStatus:
  3935. m.ClearStatus()
  3936. return nil
  3937. case contact.FieldDeletedAt:
  3938. m.ClearDeletedAt()
  3939. return nil
  3940. case contact.FieldWxWxid:
  3941. m.ClearWxWxid()
  3942. return nil
  3943. case contact.FieldType:
  3944. m.ClearType()
  3945. return nil
  3946. case contact.FieldOrganizationID:
  3947. m.ClearOrganizationID()
  3948. return nil
  3949. }
  3950. return fmt.Errorf("unknown Contact nullable field %s", name)
  3951. }
  3952. // ResetField resets all changes in the mutation for the field with the given name.
  3953. // It returns an error if the field is not defined in the schema.
  3954. func (m *ContactMutation) ResetField(name string) error {
  3955. switch name {
  3956. case contact.FieldCreatedAt:
  3957. m.ResetCreatedAt()
  3958. return nil
  3959. case contact.FieldUpdatedAt:
  3960. m.ResetUpdatedAt()
  3961. return nil
  3962. case contact.FieldStatus:
  3963. m.ResetStatus()
  3964. return nil
  3965. case contact.FieldDeletedAt:
  3966. m.ResetDeletedAt()
  3967. return nil
  3968. case contact.FieldWxWxid:
  3969. m.ResetWxWxid()
  3970. return nil
  3971. case contact.FieldType:
  3972. m.ResetType()
  3973. return nil
  3974. case contact.FieldWxid:
  3975. m.ResetWxid()
  3976. return nil
  3977. case contact.FieldAccount:
  3978. m.ResetAccount()
  3979. return nil
  3980. case contact.FieldNickname:
  3981. m.ResetNickname()
  3982. return nil
  3983. case contact.FieldMarkname:
  3984. m.ResetMarkname()
  3985. return nil
  3986. case contact.FieldHeadimg:
  3987. m.ResetHeadimg()
  3988. return nil
  3989. case contact.FieldSex:
  3990. m.ResetSex()
  3991. return nil
  3992. case contact.FieldStarrole:
  3993. m.ResetStarrole()
  3994. return nil
  3995. case contact.FieldDontseeit:
  3996. m.ResetDontseeit()
  3997. return nil
  3998. case contact.FieldDontseeme:
  3999. m.ResetDontseeme()
  4000. return nil
  4001. case contact.FieldLag:
  4002. m.ResetLag()
  4003. return nil
  4004. case contact.FieldGid:
  4005. m.ResetGid()
  4006. return nil
  4007. case contact.FieldGname:
  4008. m.ResetGname()
  4009. return nil
  4010. case contact.FieldV3:
  4011. m.ResetV3()
  4012. return nil
  4013. case contact.FieldOrganizationID:
  4014. m.ResetOrganizationID()
  4015. return nil
  4016. }
  4017. return fmt.Errorf("unknown Contact field %s", name)
  4018. }
  4019. // AddedEdges returns all edge names that were set/added in this mutation.
  4020. func (m *ContactMutation) AddedEdges() []string {
  4021. edges := make([]string, 0, 2)
  4022. if m.contact_relationships != nil {
  4023. edges = append(edges, contact.EdgeContactRelationships)
  4024. }
  4025. if m.contact_messages != nil {
  4026. edges = append(edges, contact.EdgeContactMessages)
  4027. }
  4028. return edges
  4029. }
  4030. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4031. // name in this mutation.
  4032. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  4033. switch name {
  4034. case contact.EdgeContactRelationships:
  4035. ids := make([]ent.Value, 0, len(m.contact_relationships))
  4036. for id := range m.contact_relationships {
  4037. ids = append(ids, id)
  4038. }
  4039. return ids
  4040. case contact.EdgeContactMessages:
  4041. ids := make([]ent.Value, 0, len(m.contact_messages))
  4042. for id := range m.contact_messages {
  4043. ids = append(ids, id)
  4044. }
  4045. return ids
  4046. }
  4047. return nil
  4048. }
  4049. // RemovedEdges returns all edge names that were removed in this mutation.
  4050. func (m *ContactMutation) RemovedEdges() []string {
  4051. edges := make([]string, 0, 2)
  4052. if m.removedcontact_relationships != nil {
  4053. edges = append(edges, contact.EdgeContactRelationships)
  4054. }
  4055. if m.removedcontact_messages != nil {
  4056. edges = append(edges, contact.EdgeContactMessages)
  4057. }
  4058. return edges
  4059. }
  4060. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4061. // the given name in this mutation.
  4062. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  4063. switch name {
  4064. case contact.EdgeContactRelationships:
  4065. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  4066. for id := range m.removedcontact_relationships {
  4067. ids = append(ids, id)
  4068. }
  4069. return ids
  4070. case contact.EdgeContactMessages:
  4071. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  4072. for id := range m.removedcontact_messages {
  4073. ids = append(ids, id)
  4074. }
  4075. return ids
  4076. }
  4077. return nil
  4078. }
  4079. // ClearedEdges returns all edge names that were cleared in this mutation.
  4080. func (m *ContactMutation) ClearedEdges() []string {
  4081. edges := make([]string, 0, 2)
  4082. if m.clearedcontact_relationships {
  4083. edges = append(edges, contact.EdgeContactRelationships)
  4084. }
  4085. if m.clearedcontact_messages {
  4086. edges = append(edges, contact.EdgeContactMessages)
  4087. }
  4088. return edges
  4089. }
  4090. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4091. // was cleared in this mutation.
  4092. func (m *ContactMutation) EdgeCleared(name string) bool {
  4093. switch name {
  4094. case contact.EdgeContactRelationships:
  4095. return m.clearedcontact_relationships
  4096. case contact.EdgeContactMessages:
  4097. return m.clearedcontact_messages
  4098. }
  4099. return false
  4100. }
  4101. // ClearEdge clears the value of the edge with the given name. It returns an error
  4102. // if that edge is not defined in the schema.
  4103. func (m *ContactMutation) ClearEdge(name string) error {
  4104. switch name {
  4105. }
  4106. return fmt.Errorf("unknown Contact unique edge %s", name)
  4107. }
  4108. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4109. // It returns an error if the edge is not defined in the schema.
  4110. func (m *ContactMutation) ResetEdge(name string) error {
  4111. switch name {
  4112. case contact.EdgeContactRelationships:
  4113. m.ResetContactRelationships()
  4114. return nil
  4115. case contact.EdgeContactMessages:
  4116. m.ResetContactMessages()
  4117. return nil
  4118. }
  4119. return fmt.Errorf("unknown Contact edge %s", name)
  4120. }
  4121. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  4122. type EmployeeMutation struct {
  4123. config
  4124. op Op
  4125. typ string
  4126. id *uint64
  4127. created_at *time.Time
  4128. updated_at *time.Time
  4129. deleted_at *time.Time
  4130. title *string
  4131. avatar *string
  4132. tags *string
  4133. hire_count *int
  4134. addhire_count *int
  4135. service_count *int
  4136. addservice_count *int
  4137. achievement_count *int
  4138. addachievement_count *int
  4139. intro *string
  4140. estimate *string
  4141. skill *string
  4142. ability_type *string
  4143. scene *string
  4144. switch_in *string
  4145. video_url *string
  4146. organization_id *uint64
  4147. addorganization_id *int64
  4148. clearedFields map[string]struct{}
  4149. em_work_experiences map[uint64]struct{}
  4150. removedem_work_experiences map[uint64]struct{}
  4151. clearedem_work_experiences bool
  4152. em_tutorial map[uint64]struct{}
  4153. removedem_tutorial map[uint64]struct{}
  4154. clearedem_tutorial bool
  4155. done bool
  4156. oldValue func(context.Context) (*Employee, error)
  4157. predicates []predicate.Employee
  4158. }
  4159. var _ ent.Mutation = (*EmployeeMutation)(nil)
  4160. // employeeOption allows management of the mutation configuration using functional options.
  4161. type employeeOption func(*EmployeeMutation)
  4162. // newEmployeeMutation creates new mutation for the Employee entity.
  4163. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  4164. m := &EmployeeMutation{
  4165. config: c,
  4166. op: op,
  4167. typ: TypeEmployee,
  4168. clearedFields: make(map[string]struct{}),
  4169. }
  4170. for _, opt := range opts {
  4171. opt(m)
  4172. }
  4173. return m
  4174. }
  4175. // withEmployeeID sets the ID field of the mutation.
  4176. func withEmployeeID(id uint64) employeeOption {
  4177. return func(m *EmployeeMutation) {
  4178. var (
  4179. err error
  4180. once sync.Once
  4181. value *Employee
  4182. )
  4183. m.oldValue = func(ctx context.Context) (*Employee, error) {
  4184. once.Do(func() {
  4185. if m.done {
  4186. err = errors.New("querying old values post mutation is not allowed")
  4187. } else {
  4188. value, err = m.Client().Employee.Get(ctx, id)
  4189. }
  4190. })
  4191. return value, err
  4192. }
  4193. m.id = &id
  4194. }
  4195. }
  4196. // withEmployee sets the old Employee of the mutation.
  4197. func withEmployee(node *Employee) employeeOption {
  4198. return func(m *EmployeeMutation) {
  4199. m.oldValue = func(context.Context) (*Employee, error) {
  4200. return node, nil
  4201. }
  4202. m.id = &node.ID
  4203. }
  4204. }
  4205. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4206. // executed in a transaction (ent.Tx), a transactional client is returned.
  4207. func (m EmployeeMutation) Client() *Client {
  4208. client := &Client{config: m.config}
  4209. client.init()
  4210. return client
  4211. }
  4212. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4213. // it returns an error otherwise.
  4214. func (m EmployeeMutation) Tx() (*Tx, error) {
  4215. if _, ok := m.driver.(*txDriver); !ok {
  4216. return nil, errors.New("ent: mutation is not running in a transaction")
  4217. }
  4218. tx := &Tx{config: m.config}
  4219. tx.init()
  4220. return tx, nil
  4221. }
  4222. // SetID sets the value of the id field. Note that this
  4223. // operation is only accepted on creation of Employee entities.
  4224. func (m *EmployeeMutation) SetID(id uint64) {
  4225. m.id = &id
  4226. }
  4227. // ID returns the ID value in the mutation. Note that the ID is only available
  4228. // if it was provided to the builder or after it was returned from the database.
  4229. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  4230. if m.id == nil {
  4231. return
  4232. }
  4233. return *m.id, true
  4234. }
  4235. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4236. // That means, if the mutation is applied within a transaction with an isolation level such
  4237. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4238. // or updated by the mutation.
  4239. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  4240. switch {
  4241. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4242. id, exists := m.ID()
  4243. if exists {
  4244. return []uint64{id}, nil
  4245. }
  4246. fallthrough
  4247. case m.op.Is(OpUpdate | OpDelete):
  4248. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  4249. default:
  4250. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4251. }
  4252. }
  4253. // SetCreatedAt sets the "created_at" field.
  4254. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  4255. m.created_at = &t
  4256. }
  4257. // CreatedAt returns the value of the "created_at" field in the mutation.
  4258. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  4259. v := m.created_at
  4260. if v == nil {
  4261. return
  4262. }
  4263. return *v, true
  4264. }
  4265. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  4266. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4268. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4269. if !m.op.Is(OpUpdateOne) {
  4270. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4271. }
  4272. if m.id == nil || m.oldValue == nil {
  4273. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4274. }
  4275. oldValue, err := m.oldValue(ctx)
  4276. if err != nil {
  4277. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4278. }
  4279. return oldValue.CreatedAt, nil
  4280. }
  4281. // ResetCreatedAt resets all changes to the "created_at" field.
  4282. func (m *EmployeeMutation) ResetCreatedAt() {
  4283. m.created_at = nil
  4284. }
  4285. // SetUpdatedAt sets the "updated_at" field.
  4286. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  4287. m.updated_at = &t
  4288. }
  4289. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4290. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  4291. v := m.updated_at
  4292. if v == nil {
  4293. return
  4294. }
  4295. return *v, true
  4296. }
  4297. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  4298. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4300. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4301. if !m.op.Is(OpUpdateOne) {
  4302. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4303. }
  4304. if m.id == nil || m.oldValue == nil {
  4305. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4306. }
  4307. oldValue, err := m.oldValue(ctx)
  4308. if err != nil {
  4309. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4310. }
  4311. return oldValue.UpdatedAt, nil
  4312. }
  4313. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4314. func (m *EmployeeMutation) ResetUpdatedAt() {
  4315. m.updated_at = nil
  4316. }
  4317. // SetDeletedAt sets the "deleted_at" field.
  4318. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  4319. m.deleted_at = &t
  4320. }
  4321. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4322. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  4323. v := m.deleted_at
  4324. if v == nil {
  4325. return
  4326. }
  4327. return *v, true
  4328. }
  4329. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  4330. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4332. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4333. if !m.op.Is(OpUpdateOne) {
  4334. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4335. }
  4336. if m.id == nil || m.oldValue == nil {
  4337. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4338. }
  4339. oldValue, err := m.oldValue(ctx)
  4340. if err != nil {
  4341. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4342. }
  4343. return oldValue.DeletedAt, nil
  4344. }
  4345. // ClearDeletedAt clears the value of the "deleted_at" field.
  4346. func (m *EmployeeMutation) ClearDeletedAt() {
  4347. m.deleted_at = nil
  4348. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  4349. }
  4350. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4351. func (m *EmployeeMutation) DeletedAtCleared() bool {
  4352. _, ok := m.clearedFields[employee.FieldDeletedAt]
  4353. return ok
  4354. }
  4355. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4356. func (m *EmployeeMutation) ResetDeletedAt() {
  4357. m.deleted_at = nil
  4358. delete(m.clearedFields, employee.FieldDeletedAt)
  4359. }
  4360. // SetTitle sets the "title" field.
  4361. func (m *EmployeeMutation) SetTitle(s string) {
  4362. m.title = &s
  4363. }
  4364. // Title returns the value of the "title" field in the mutation.
  4365. func (m *EmployeeMutation) Title() (r string, exists bool) {
  4366. v := m.title
  4367. if v == nil {
  4368. return
  4369. }
  4370. return *v, true
  4371. }
  4372. // OldTitle returns the old "title" field's value of the Employee entity.
  4373. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4375. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  4376. if !m.op.Is(OpUpdateOne) {
  4377. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4378. }
  4379. if m.id == nil || m.oldValue == nil {
  4380. return v, errors.New("OldTitle requires an ID field in the mutation")
  4381. }
  4382. oldValue, err := m.oldValue(ctx)
  4383. if err != nil {
  4384. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4385. }
  4386. return oldValue.Title, nil
  4387. }
  4388. // ResetTitle resets all changes to the "title" field.
  4389. func (m *EmployeeMutation) ResetTitle() {
  4390. m.title = nil
  4391. }
  4392. // SetAvatar sets the "avatar" field.
  4393. func (m *EmployeeMutation) SetAvatar(s string) {
  4394. m.avatar = &s
  4395. }
  4396. // Avatar returns the value of the "avatar" field in the mutation.
  4397. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  4398. v := m.avatar
  4399. if v == nil {
  4400. return
  4401. }
  4402. return *v, true
  4403. }
  4404. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  4405. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4407. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  4408. if !m.op.Is(OpUpdateOne) {
  4409. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  4410. }
  4411. if m.id == nil || m.oldValue == nil {
  4412. return v, errors.New("OldAvatar requires an ID field in the mutation")
  4413. }
  4414. oldValue, err := m.oldValue(ctx)
  4415. if err != nil {
  4416. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  4417. }
  4418. return oldValue.Avatar, nil
  4419. }
  4420. // ResetAvatar resets all changes to the "avatar" field.
  4421. func (m *EmployeeMutation) ResetAvatar() {
  4422. m.avatar = nil
  4423. }
  4424. // SetTags sets the "tags" field.
  4425. func (m *EmployeeMutation) SetTags(s string) {
  4426. m.tags = &s
  4427. }
  4428. // Tags returns the value of the "tags" field in the mutation.
  4429. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  4430. v := m.tags
  4431. if v == nil {
  4432. return
  4433. }
  4434. return *v, true
  4435. }
  4436. // OldTags returns the old "tags" field's value of the Employee entity.
  4437. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4439. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  4440. if !m.op.Is(OpUpdateOne) {
  4441. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  4442. }
  4443. if m.id == nil || m.oldValue == nil {
  4444. return v, errors.New("OldTags requires an ID field in the mutation")
  4445. }
  4446. oldValue, err := m.oldValue(ctx)
  4447. if err != nil {
  4448. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  4449. }
  4450. return oldValue.Tags, nil
  4451. }
  4452. // ResetTags resets all changes to the "tags" field.
  4453. func (m *EmployeeMutation) ResetTags() {
  4454. m.tags = nil
  4455. }
  4456. // SetHireCount sets the "hire_count" field.
  4457. func (m *EmployeeMutation) SetHireCount(i int) {
  4458. m.hire_count = &i
  4459. m.addhire_count = nil
  4460. }
  4461. // HireCount returns the value of the "hire_count" field in the mutation.
  4462. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  4463. v := m.hire_count
  4464. if v == nil {
  4465. return
  4466. }
  4467. return *v, true
  4468. }
  4469. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  4470. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4472. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  4473. if !m.op.Is(OpUpdateOne) {
  4474. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  4475. }
  4476. if m.id == nil || m.oldValue == nil {
  4477. return v, errors.New("OldHireCount requires an ID field in the mutation")
  4478. }
  4479. oldValue, err := m.oldValue(ctx)
  4480. if err != nil {
  4481. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  4482. }
  4483. return oldValue.HireCount, nil
  4484. }
  4485. // AddHireCount adds i to the "hire_count" field.
  4486. func (m *EmployeeMutation) AddHireCount(i int) {
  4487. if m.addhire_count != nil {
  4488. *m.addhire_count += i
  4489. } else {
  4490. m.addhire_count = &i
  4491. }
  4492. }
  4493. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  4494. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  4495. v := m.addhire_count
  4496. if v == nil {
  4497. return
  4498. }
  4499. return *v, true
  4500. }
  4501. // ResetHireCount resets all changes to the "hire_count" field.
  4502. func (m *EmployeeMutation) ResetHireCount() {
  4503. m.hire_count = nil
  4504. m.addhire_count = nil
  4505. }
  4506. // SetServiceCount sets the "service_count" field.
  4507. func (m *EmployeeMutation) SetServiceCount(i int) {
  4508. m.service_count = &i
  4509. m.addservice_count = nil
  4510. }
  4511. // ServiceCount returns the value of the "service_count" field in the mutation.
  4512. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  4513. v := m.service_count
  4514. if v == nil {
  4515. return
  4516. }
  4517. return *v, true
  4518. }
  4519. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  4520. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4522. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  4523. if !m.op.Is(OpUpdateOne) {
  4524. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  4525. }
  4526. if m.id == nil || m.oldValue == nil {
  4527. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  4528. }
  4529. oldValue, err := m.oldValue(ctx)
  4530. if err != nil {
  4531. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  4532. }
  4533. return oldValue.ServiceCount, nil
  4534. }
  4535. // AddServiceCount adds i to the "service_count" field.
  4536. func (m *EmployeeMutation) AddServiceCount(i int) {
  4537. if m.addservice_count != nil {
  4538. *m.addservice_count += i
  4539. } else {
  4540. m.addservice_count = &i
  4541. }
  4542. }
  4543. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  4544. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  4545. v := m.addservice_count
  4546. if v == nil {
  4547. return
  4548. }
  4549. return *v, true
  4550. }
  4551. // ResetServiceCount resets all changes to the "service_count" field.
  4552. func (m *EmployeeMutation) ResetServiceCount() {
  4553. m.service_count = nil
  4554. m.addservice_count = nil
  4555. }
  4556. // SetAchievementCount sets the "achievement_count" field.
  4557. func (m *EmployeeMutation) SetAchievementCount(i int) {
  4558. m.achievement_count = &i
  4559. m.addachievement_count = nil
  4560. }
  4561. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  4562. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  4563. v := m.achievement_count
  4564. if v == nil {
  4565. return
  4566. }
  4567. return *v, true
  4568. }
  4569. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  4570. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4572. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  4573. if !m.op.Is(OpUpdateOne) {
  4574. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  4575. }
  4576. if m.id == nil || m.oldValue == nil {
  4577. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  4578. }
  4579. oldValue, err := m.oldValue(ctx)
  4580. if err != nil {
  4581. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  4582. }
  4583. return oldValue.AchievementCount, nil
  4584. }
  4585. // AddAchievementCount adds i to the "achievement_count" field.
  4586. func (m *EmployeeMutation) AddAchievementCount(i int) {
  4587. if m.addachievement_count != nil {
  4588. *m.addachievement_count += i
  4589. } else {
  4590. m.addachievement_count = &i
  4591. }
  4592. }
  4593. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  4594. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  4595. v := m.addachievement_count
  4596. if v == nil {
  4597. return
  4598. }
  4599. return *v, true
  4600. }
  4601. // ResetAchievementCount resets all changes to the "achievement_count" field.
  4602. func (m *EmployeeMutation) ResetAchievementCount() {
  4603. m.achievement_count = nil
  4604. m.addachievement_count = nil
  4605. }
  4606. // SetIntro sets the "intro" field.
  4607. func (m *EmployeeMutation) SetIntro(s string) {
  4608. m.intro = &s
  4609. }
  4610. // Intro returns the value of the "intro" field in the mutation.
  4611. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  4612. v := m.intro
  4613. if v == nil {
  4614. return
  4615. }
  4616. return *v, true
  4617. }
  4618. // OldIntro returns the old "intro" field's value of the Employee entity.
  4619. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4621. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  4622. if !m.op.Is(OpUpdateOne) {
  4623. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  4624. }
  4625. if m.id == nil || m.oldValue == nil {
  4626. return v, errors.New("OldIntro requires an ID field in the mutation")
  4627. }
  4628. oldValue, err := m.oldValue(ctx)
  4629. if err != nil {
  4630. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  4631. }
  4632. return oldValue.Intro, nil
  4633. }
  4634. // ResetIntro resets all changes to the "intro" field.
  4635. func (m *EmployeeMutation) ResetIntro() {
  4636. m.intro = nil
  4637. }
  4638. // SetEstimate sets the "estimate" field.
  4639. func (m *EmployeeMutation) SetEstimate(s string) {
  4640. m.estimate = &s
  4641. }
  4642. // Estimate returns the value of the "estimate" field in the mutation.
  4643. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  4644. v := m.estimate
  4645. if v == nil {
  4646. return
  4647. }
  4648. return *v, true
  4649. }
  4650. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  4651. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4653. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  4654. if !m.op.Is(OpUpdateOne) {
  4655. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  4656. }
  4657. if m.id == nil || m.oldValue == nil {
  4658. return v, errors.New("OldEstimate requires an ID field in the mutation")
  4659. }
  4660. oldValue, err := m.oldValue(ctx)
  4661. if err != nil {
  4662. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  4663. }
  4664. return oldValue.Estimate, nil
  4665. }
  4666. // ResetEstimate resets all changes to the "estimate" field.
  4667. func (m *EmployeeMutation) ResetEstimate() {
  4668. m.estimate = nil
  4669. }
  4670. // SetSkill sets the "skill" field.
  4671. func (m *EmployeeMutation) SetSkill(s string) {
  4672. m.skill = &s
  4673. }
  4674. // Skill returns the value of the "skill" field in the mutation.
  4675. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  4676. v := m.skill
  4677. if v == nil {
  4678. return
  4679. }
  4680. return *v, true
  4681. }
  4682. // OldSkill returns the old "skill" field's value of the Employee entity.
  4683. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4685. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  4686. if !m.op.Is(OpUpdateOne) {
  4687. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  4688. }
  4689. if m.id == nil || m.oldValue == nil {
  4690. return v, errors.New("OldSkill requires an ID field in the mutation")
  4691. }
  4692. oldValue, err := m.oldValue(ctx)
  4693. if err != nil {
  4694. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  4695. }
  4696. return oldValue.Skill, nil
  4697. }
  4698. // ResetSkill resets all changes to the "skill" field.
  4699. func (m *EmployeeMutation) ResetSkill() {
  4700. m.skill = nil
  4701. }
  4702. // SetAbilityType sets the "ability_type" field.
  4703. func (m *EmployeeMutation) SetAbilityType(s string) {
  4704. m.ability_type = &s
  4705. }
  4706. // AbilityType returns the value of the "ability_type" field in the mutation.
  4707. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  4708. v := m.ability_type
  4709. if v == nil {
  4710. return
  4711. }
  4712. return *v, true
  4713. }
  4714. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  4715. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4717. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  4718. if !m.op.Is(OpUpdateOne) {
  4719. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  4720. }
  4721. if m.id == nil || m.oldValue == nil {
  4722. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  4723. }
  4724. oldValue, err := m.oldValue(ctx)
  4725. if err != nil {
  4726. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  4727. }
  4728. return oldValue.AbilityType, nil
  4729. }
  4730. // ResetAbilityType resets all changes to the "ability_type" field.
  4731. func (m *EmployeeMutation) ResetAbilityType() {
  4732. m.ability_type = nil
  4733. }
  4734. // SetScene sets the "scene" field.
  4735. func (m *EmployeeMutation) SetScene(s string) {
  4736. m.scene = &s
  4737. }
  4738. // Scene returns the value of the "scene" field in the mutation.
  4739. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  4740. v := m.scene
  4741. if v == nil {
  4742. return
  4743. }
  4744. return *v, true
  4745. }
  4746. // OldScene returns the old "scene" field's value of the Employee entity.
  4747. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4749. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  4750. if !m.op.Is(OpUpdateOne) {
  4751. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  4752. }
  4753. if m.id == nil || m.oldValue == nil {
  4754. return v, errors.New("OldScene requires an ID field in the mutation")
  4755. }
  4756. oldValue, err := m.oldValue(ctx)
  4757. if err != nil {
  4758. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  4759. }
  4760. return oldValue.Scene, nil
  4761. }
  4762. // ResetScene resets all changes to the "scene" field.
  4763. func (m *EmployeeMutation) ResetScene() {
  4764. m.scene = nil
  4765. }
  4766. // SetSwitchIn sets the "switch_in" field.
  4767. func (m *EmployeeMutation) SetSwitchIn(s string) {
  4768. m.switch_in = &s
  4769. }
  4770. // SwitchIn returns the value of the "switch_in" field in the mutation.
  4771. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  4772. v := m.switch_in
  4773. if v == nil {
  4774. return
  4775. }
  4776. return *v, true
  4777. }
  4778. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  4779. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4781. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  4782. if !m.op.Is(OpUpdateOne) {
  4783. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  4784. }
  4785. if m.id == nil || m.oldValue == nil {
  4786. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  4787. }
  4788. oldValue, err := m.oldValue(ctx)
  4789. if err != nil {
  4790. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  4791. }
  4792. return oldValue.SwitchIn, nil
  4793. }
  4794. // ResetSwitchIn resets all changes to the "switch_in" field.
  4795. func (m *EmployeeMutation) ResetSwitchIn() {
  4796. m.switch_in = nil
  4797. }
  4798. // SetVideoURL sets the "video_url" field.
  4799. func (m *EmployeeMutation) SetVideoURL(s string) {
  4800. m.video_url = &s
  4801. }
  4802. // VideoURL returns the value of the "video_url" field in the mutation.
  4803. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  4804. v := m.video_url
  4805. if v == nil {
  4806. return
  4807. }
  4808. return *v, true
  4809. }
  4810. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  4811. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4813. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  4814. if !m.op.Is(OpUpdateOne) {
  4815. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  4816. }
  4817. if m.id == nil || m.oldValue == nil {
  4818. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  4819. }
  4820. oldValue, err := m.oldValue(ctx)
  4821. if err != nil {
  4822. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  4823. }
  4824. return oldValue.VideoURL, nil
  4825. }
  4826. // ResetVideoURL resets all changes to the "video_url" field.
  4827. func (m *EmployeeMutation) ResetVideoURL() {
  4828. m.video_url = nil
  4829. }
  4830. // SetOrganizationID sets the "organization_id" field.
  4831. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  4832. m.organization_id = &u
  4833. m.addorganization_id = nil
  4834. }
  4835. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4836. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  4837. v := m.organization_id
  4838. if v == nil {
  4839. return
  4840. }
  4841. return *v, true
  4842. }
  4843. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  4844. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4846. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4847. if !m.op.Is(OpUpdateOne) {
  4848. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4849. }
  4850. if m.id == nil || m.oldValue == nil {
  4851. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4852. }
  4853. oldValue, err := m.oldValue(ctx)
  4854. if err != nil {
  4855. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4856. }
  4857. return oldValue.OrganizationID, nil
  4858. }
  4859. // AddOrganizationID adds u to the "organization_id" field.
  4860. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  4861. if m.addorganization_id != nil {
  4862. *m.addorganization_id += u
  4863. } else {
  4864. m.addorganization_id = &u
  4865. }
  4866. }
  4867. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4868. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  4869. v := m.addorganization_id
  4870. if v == nil {
  4871. return
  4872. }
  4873. return *v, true
  4874. }
  4875. // ResetOrganizationID resets all changes to the "organization_id" field.
  4876. func (m *EmployeeMutation) ResetOrganizationID() {
  4877. m.organization_id = nil
  4878. m.addorganization_id = nil
  4879. }
  4880. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  4881. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  4882. if m.em_work_experiences == nil {
  4883. m.em_work_experiences = make(map[uint64]struct{})
  4884. }
  4885. for i := range ids {
  4886. m.em_work_experiences[ids[i]] = struct{}{}
  4887. }
  4888. }
  4889. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  4890. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  4891. m.clearedem_work_experiences = true
  4892. }
  4893. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  4894. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  4895. return m.clearedem_work_experiences
  4896. }
  4897. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  4898. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  4899. if m.removedem_work_experiences == nil {
  4900. m.removedem_work_experiences = make(map[uint64]struct{})
  4901. }
  4902. for i := range ids {
  4903. delete(m.em_work_experiences, ids[i])
  4904. m.removedem_work_experiences[ids[i]] = struct{}{}
  4905. }
  4906. }
  4907. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  4908. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  4909. for id := range m.removedem_work_experiences {
  4910. ids = append(ids, id)
  4911. }
  4912. return
  4913. }
  4914. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  4915. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  4916. for id := range m.em_work_experiences {
  4917. ids = append(ids, id)
  4918. }
  4919. return
  4920. }
  4921. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  4922. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  4923. m.em_work_experiences = nil
  4924. m.clearedem_work_experiences = false
  4925. m.removedem_work_experiences = nil
  4926. }
  4927. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  4928. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  4929. if m.em_tutorial == nil {
  4930. m.em_tutorial = make(map[uint64]struct{})
  4931. }
  4932. for i := range ids {
  4933. m.em_tutorial[ids[i]] = struct{}{}
  4934. }
  4935. }
  4936. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  4937. func (m *EmployeeMutation) ClearEmTutorial() {
  4938. m.clearedem_tutorial = true
  4939. }
  4940. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  4941. func (m *EmployeeMutation) EmTutorialCleared() bool {
  4942. return m.clearedem_tutorial
  4943. }
  4944. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  4945. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  4946. if m.removedem_tutorial == nil {
  4947. m.removedem_tutorial = make(map[uint64]struct{})
  4948. }
  4949. for i := range ids {
  4950. delete(m.em_tutorial, ids[i])
  4951. m.removedem_tutorial[ids[i]] = struct{}{}
  4952. }
  4953. }
  4954. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  4955. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  4956. for id := range m.removedem_tutorial {
  4957. ids = append(ids, id)
  4958. }
  4959. return
  4960. }
  4961. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  4962. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  4963. for id := range m.em_tutorial {
  4964. ids = append(ids, id)
  4965. }
  4966. return
  4967. }
  4968. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  4969. func (m *EmployeeMutation) ResetEmTutorial() {
  4970. m.em_tutorial = nil
  4971. m.clearedem_tutorial = false
  4972. m.removedem_tutorial = nil
  4973. }
  4974. // Where appends a list predicates to the EmployeeMutation builder.
  4975. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  4976. m.predicates = append(m.predicates, ps...)
  4977. }
  4978. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  4979. // users can use type-assertion to append predicates that do not depend on any generated package.
  4980. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  4981. p := make([]predicate.Employee, len(ps))
  4982. for i := range ps {
  4983. p[i] = ps[i]
  4984. }
  4985. m.Where(p...)
  4986. }
  4987. // Op returns the operation name.
  4988. func (m *EmployeeMutation) Op() Op {
  4989. return m.op
  4990. }
  4991. // SetOp allows setting the mutation operation.
  4992. func (m *EmployeeMutation) SetOp(op Op) {
  4993. m.op = op
  4994. }
  4995. // Type returns the node type of this mutation (Employee).
  4996. func (m *EmployeeMutation) Type() string {
  4997. return m.typ
  4998. }
  4999. // Fields returns all fields that were changed during this mutation. Note that in
  5000. // order to get all numeric fields that were incremented/decremented, call
  5001. // AddedFields().
  5002. func (m *EmployeeMutation) Fields() []string {
  5003. fields := make([]string, 0, 17)
  5004. if m.created_at != nil {
  5005. fields = append(fields, employee.FieldCreatedAt)
  5006. }
  5007. if m.updated_at != nil {
  5008. fields = append(fields, employee.FieldUpdatedAt)
  5009. }
  5010. if m.deleted_at != nil {
  5011. fields = append(fields, employee.FieldDeletedAt)
  5012. }
  5013. if m.title != nil {
  5014. fields = append(fields, employee.FieldTitle)
  5015. }
  5016. if m.avatar != nil {
  5017. fields = append(fields, employee.FieldAvatar)
  5018. }
  5019. if m.tags != nil {
  5020. fields = append(fields, employee.FieldTags)
  5021. }
  5022. if m.hire_count != nil {
  5023. fields = append(fields, employee.FieldHireCount)
  5024. }
  5025. if m.service_count != nil {
  5026. fields = append(fields, employee.FieldServiceCount)
  5027. }
  5028. if m.achievement_count != nil {
  5029. fields = append(fields, employee.FieldAchievementCount)
  5030. }
  5031. if m.intro != nil {
  5032. fields = append(fields, employee.FieldIntro)
  5033. }
  5034. if m.estimate != nil {
  5035. fields = append(fields, employee.FieldEstimate)
  5036. }
  5037. if m.skill != nil {
  5038. fields = append(fields, employee.FieldSkill)
  5039. }
  5040. if m.ability_type != nil {
  5041. fields = append(fields, employee.FieldAbilityType)
  5042. }
  5043. if m.scene != nil {
  5044. fields = append(fields, employee.FieldScene)
  5045. }
  5046. if m.switch_in != nil {
  5047. fields = append(fields, employee.FieldSwitchIn)
  5048. }
  5049. if m.video_url != nil {
  5050. fields = append(fields, employee.FieldVideoURL)
  5051. }
  5052. if m.organization_id != nil {
  5053. fields = append(fields, employee.FieldOrganizationID)
  5054. }
  5055. return fields
  5056. }
  5057. // Field returns the value of a field with the given name. The second boolean
  5058. // return value indicates that this field was not set, or was not defined in the
  5059. // schema.
  5060. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  5061. switch name {
  5062. case employee.FieldCreatedAt:
  5063. return m.CreatedAt()
  5064. case employee.FieldUpdatedAt:
  5065. return m.UpdatedAt()
  5066. case employee.FieldDeletedAt:
  5067. return m.DeletedAt()
  5068. case employee.FieldTitle:
  5069. return m.Title()
  5070. case employee.FieldAvatar:
  5071. return m.Avatar()
  5072. case employee.FieldTags:
  5073. return m.Tags()
  5074. case employee.FieldHireCount:
  5075. return m.HireCount()
  5076. case employee.FieldServiceCount:
  5077. return m.ServiceCount()
  5078. case employee.FieldAchievementCount:
  5079. return m.AchievementCount()
  5080. case employee.FieldIntro:
  5081. return m.Intro()
  5082. case employee.FieldEstimate:
  5083. return m.Estimate()
  5084. case employee.FieldSkill:
  5085. return m.Skill()
  5086. case employee.FieldAbilityType:
  5087. return m.AbilityType()
  5088. case employee.FieldScene:
  5089. return m.Scene()
  5090. case employee.FieldSwitchIn:
  5091. return m.SwitchIn()
  5092. case employee.FieldVideoURL:
  5093. return m.VideoURL()
  5094. case employee.FieldOrganizationID:
  5095. return m.OrganizationID()
  5096. }
  5097. return nil, false
  5098. }
  5099. // OldField returns the old value of the field from the database. An error is
  5100. // returned if the mutation operation is not UpdateOne, or the query to the
  5101. // database failed.
  5102. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5103. switch name {
  5104. case employee.FieldCreatedAt:
  5105. return m.OldCreatedAt(ctx)
  5106. case employee.FieldUpdatedAt:
  5107. return m.OldUpdatedAt(ctx)
  5108. case employee.FieldDeletedAt:
  5109. return m.OldDeletedAt(ctx)
  5110. case employee.FieldTitle:
  5111. return m.OldTitle(ctx)
  5112. case employee.FieldAvatar:
  5113. return m.OldAvatar(ctx)
  5114. case employee.FieldTags:
  5115. return m.OldTags(ctx)
  5116. case employee.FieldHireCount:
  5117. return m.OldHireCount(ctx)
  5118. case employee.FieldServiceCount:
  5119. return m.OldServiceCount(ctx)
  5120. case employee.FieldAchievementCount:
  5121. return m.OldAchievementCount(ctx)
  5122. case employee.FieldIntro:
  5123. return m.OldIntro(ctx)
  5124. case employee.FieldEstimate:
  5125. return m.OldEstimate(ctx)
  5126. case employee.FieldSkill:
  5127. return m.OldSkill(ctx)
  5128. case employee.FieldAbilityType:
  5129. return m.OldAbilityType(ctx)
  5130. case employee.FieldScene:
  5131. return m.OldScene(ctx)
  5132. case employee.FieldSwitchIn:
  5133. return m.OldSwitchIn(ctx)
  5134. case employee.FieldVideoURL:
  5135. return m.OldVideoURL(ctx)
  5136. case employee.FieldOrganizationID:
  5137. return m.OldOrganizationID(ctx)
  5138. }
  5139. return nil, fmt.Errorf("unknown Employee field %s", name)
  5140. }
  5141. // SetField sets the value of a field with the given name. It returns an error if
  5142. // the field is not defined in the schema, or if the type mismatched the field
  5143. // type.
  5144. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  5145. switch name {
  5146. case employee.FieldCreatedAt:
  5147. v, ok := value.(time.Time)
  5148. if !ok {
  5149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5150. }
  5151. m.SetCreatedAt(v)
  5152. return nil
  5153. case employee.FieldUpdatedAt:
  5154. v, ok := value.(time.Time)
  5155. if !ok {
  5156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5157. }
  5158. m.SetUpdatedAt(v)
  5159. return nil
  5160. case employee.FieldDeletedAt:
  5161. v, ok := value.(time.Time)
  5162. if !ok {
  5163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5164. }
  5165. m.SetDeletedAt(v)
  5166. return nil
  5167. case employee.FieldTitle:
  5168. v, ok := value.(string)
  5169. if !ok {
  5170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5171. }
  5172. m.SetTitle(v)
  5173. return nil
  5174. case employee.FieldAvatar:
  5175. v, ok := value.(string)
  5176. if !ok {
  5177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5178. }
  5179. m.SetAvatar(v)
  5180. return nil
  5181. case employee.FieldTags:
  5182. v, ok := value.(string)
  5183. if !ok {
  5184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5185. }
  5186. m.SetTags(v)
  5187. return nil
  5188. case employee.FieldHireCount:
  5189. v, ok := value.(int)
  5190. if !ok {
  5191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5192. }
  5193. m.SetHireCount(v)
  5194. return nil
  5195. case employee.FieldServiceCount:
  5196. v, ok := value.(int)
  5197. if !ok {
  5198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5199. }
  5200. m.SetServiceCount(v)
  5201. return nil
  5202. case employee.FieldAchievementCount:
  5203. v, ok := value.(int)
  5204. if !ok {
  5205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5206. }
  5207. m.SetAchievementCount(v)
  5208. return nil
  5209. case employee.FieldIntro:
  5210. v, ok := value.(string)
  5211. if !ok {
  5212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5213. }
  5214. m.SetIntro(v)
  5215. return nil
  5216. case employee.FieldEstimate:
  5217. v, ok := value.(string)
  5218. if !ok {
  5219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5220. }
  5221. m.SetEstimate(v)
  5222. return nil
  5223. case employee.FieldSkill:
  5224. v, ok := value.(string)
  5225. if !ok {
  5226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5227. }
  5228. m.SetSkill(v)
  5229. return nil
  5230. case employee.FieldAbilityType:
  5231. v, ok := value.(string)
  5232. if !ok {
  5233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5234. }
  5235. m.SetAbilityType(v)
  5236. return nil
  5237. case employee.FieldScene:
  5238. v, ok := value.(string)
  5239. if !ok {
  5240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5241. }
  5242. m.SetScene(v)
  5243. return nil
  5244. case employee.FieldSwitchIn:
  5245. v, ok := value.(string)
  5246. if !ok {
  5247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5248. }
  5249. m.SetSwitchIn(v)
  5250. return nil
  5251. case employee.FieldVideoURL:
  5252. v, ok := value.(string)
  5253. if !ok {
  5254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5255. }
  5256. m.SetVideoURL(v)
  5257. return nil
  5258. case employee.FieldOrganizationID:
  5259. v, ok := value.(uint64)
  5260. if !ok {
  5261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5262. }
  5263. m.SetOrganizationID(v)
  5264. return nil
  5265. }
  5266. return fmt.Errorf("unknown Employee field %s", name)
  5267. }
  5268. // AddedFields returns all numeric fields that were incremented/decremented during
  5269. // this mutation.
  5270. func (m *EmployeeMutation) AddedFields() []string {
  5271. var fields []string
  5272. if m.addhire_count != nil {
  5273. fields = append(fields, employee.FieldHireCount)
  5274. }
  5275. if m.addservice_count != nil {
  5276. fields = append(fields, employee.FieldServiceCount)
  5277. }
  5278. if m.addachievement_count != nil {
  5279. fields = append(fields, employee.FieldAchievementCount)
  5280. }
  5281. if m.addorganization_id != nil {
  5282. fields = append(fields, employee.FieldOrganizationID)
  5283. }
  5284. return fields
  5285. }
  5286. // AddedField returns the numeric value that was incremented/decremented on a field
  5287. // with the given name. The second boolean return value indicates that this field
  5288. // was not set, or was not defined in the schema.
  5289. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  5290. switch name {
  5291. case employee.FieldHireCount:
  5292. return m.AddedHireCount()
  5293. case employee.FieldServiceCount:
  5294. return m.AddedServiceCount()
  5295. case employee.FieldAchievementCount:
  5296. return m.AddedAchievementCount()
  5297. case employee.FieldOrganizationID:
  5298. return m.AddedOrganizationID()
  5299. }
  5300. return nil, false
  5301. }
  5302. // AddField adds the value to the field with the given name. It returns an error if
  5303. // the field is not defined in the schema, or if the type mismatched the field
  5304. // type.
  5305. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  5306. switch name {
  5307. case employee.FieldHireCount:
  5308. v, ok := value.(int)
  5309. if !ok {
  5310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5311. }
  5312. m.AddHireCount(v)
  5313. return nil
  5314. case employee.FieldServiceCount:
  5315. v, ok := value.(int)
  5316. if !ok {
  5317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5318. }
  5319. m.AddServiceCount(v)
  5320. return nil
  5321. case employee.FieldAchievementCount:
  5322. v, ok := value.(int)
  5323. if !ok {
  5324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5325. }
  5326. m.AddAchievementCount(v)
  5327. return nil
  5328. case employee.FieldOrganizationID:
  5329. v, ok := value.(int64)
  5330. if !ok {
  5331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5332. }
  5333. m.AddOrganizationID(v)
  5334. return nil
  5335. }
  5336. return fmt.Errorf("unknown Employee numeric field %s", name)
  5337. }
  5338. // ClearedFields returns all nullable fields that were cleared during this
  5339. // mutation.
  5340. func (m *EmployeeMutation) ClearedFields() []string {
  5341. var fields []string
  5342. if m.FieldCleared(employee.FieldDeletedAt) {
  5343. fields = append(fields, employee.FieldDeletedAt)
  5344. }
  5345. return fields
  5346. }
  5347. // FieldCleared returns a boolean indicating if a field with the given name was
  5348. // cleared in this mutation.
  5349. func (m *EmployeeMutation) FieldCleared(name string) bool {
  5350. _, ok := m.clearedFields[name]
  5351. return ok
  5352. }
  5353. // ClearField clears the value of the field with the given name. It returns an
  5354. // error if the field is not defined in the schema.
  5355. func (m *EmployeeMutation) ClearField(name string) error {
  5356. switch name {
  5357. case employee.FieldDeletedAt:
  5358. m.ClearDeletedAt()
  5359. return nil
  5360. }
  5361. return fmt.Errorf("unknown Employee nullable field %s", name)
  5362. }
  5363. // ResetField resets all changes in the mutation for the field with the given name.
  5364. // It returns an error if the field is not defined in the schema.
  5365. func (m *EmployeeMutation) ResetField(name string) error {
  5366. switch name {
  5367. case employee.FieldCreatedAt:
  5368. m.ResetCreatedAt()
  5369. return nil
  5370. case employee.FieldUpdatedAt:
  5371. m.ResetUpdatedAt()
  5372. return nil
  5373. case employee.FieldDeletedAt:
  5374. m.ResetDeletedAt()
  5375. return nil
  5376. case employee.FieldTitle:
  5377. m.ResetTitle()
  5378. return nil
  5379. case employee.FieldAvatar:
  5380. m.ResetAvatar()
  5381. return nil
  5382. case employee.FieldTags:
  5383. m.ResetTags()
  5384. return nil
  5385. case employee.FieldHireCount:
  5386. m.ResetHireCount()
  5387. return nil
  5388. case employee.FieldServiceCount:
  5389. m.ResetServiceCount()
  5390. return nil
  5391. case employee.FieldAchievementCount:
  5392. m.ResetAchievementCount()
  5393. return nil
  5394. case employee.FieldIntro:
  5395. m.ResetIntro()
  5396. return nil
  5397. case employee.FieldEstimate:
  5398. m.ResetEstimate()
  5399. return nil
  5400. case employee.FieldSkill:
  5401. m.ResetSkill()
  5402. return nil
  5403. case employee.FieldAbilityType:
  5404. m.ResetAbilityType()
  5405. return nil
  5406. case employee.FieldScene:
  5407. m.ResetScene()
  5408. return nil
  5409. case employee.FieldSwitchIn:
  5410. m.ResetSwitchIn()
  5411. return nil
  5412. case employee.FieldVideoURL:
  5413. m.ResetVideoURL()
  5414. return nil
  5415. case employee.FieldOrganizationID:
  5416. m.ResetOrganizationID()
  5417. return nil
  5418. }
  5419. return fmt.Errorf("unknown Employee field %s", name)
  5420. }
  5421. // AddedEdges returns all edge names that were set/added in this mutation.
  5422. func (m *EmployeeMutation) AddedEdges() []string {
  5423. edges := make([]string, 0, 2)
  5424. if m.em_work_experiences != nil {
  5425. edges = append(edges, employee.EdgeEmWorkExperiences)
  5426. }
  5427. if m.em_tutorial != nil {
  5428. edges = append(edges, employee.EdgeEmTutorial)
  5429. }
  5430. return edges
  5431. }
  5432. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5433. // name in this mutation.
  5434. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  5435. switch name {
  5436. case employee.EdgeEmWorkExperiences:
  5437. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  5438. for id := range m.em_work_experiences {
  5439. ids = append(ids, id)
  5440. }
  5441. return ids
  5442. case employee.EdgeEmTutorial:
  5443. ids := make([]ent.Value, 0, len(m.em_tutorial))
  5444. for id := range m.em_tutorial {
  5445. ids = append(ids, id)
  5446. }
  5447. return ids
  5448. }
  5449. return nil
  5450. }
  5451. // RemovedEdges returns all edge names that were removed in this mutation.
  5452. func (m *EmployeeMutation) RemovedEdges() []string {
  5453. edges := make([]string, 0, 2)
  5454. if m.removedem_work_experiences != nil {
  5455. edges = append(edges, employee.EdgeEmWorkExperiences)
  5456. }
  5457. if m.removedem_tutorial != nil {
  5458. edges = append(edges, employee.EdgeEmTutorial)
  5459. }
  5460. return edges
  5461. }
  5462. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5463. // the given name in this mutation.
  5464. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  5465. switch name {
  5466. case employee.EdgeEmWorkExperiences:
  5467. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  5468. for id := range m.removedem_work_experiences {
  5469. ids = append(ids, id)
  5470. }
  5471. return ids
  5472. case employee.EdgeEmTutorial:
  5473. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  5474. for id := range m.removedem_tutorial {
  5475. ids = append(ids, id)
  5476. }
  5477. return ids
  5478. }
  5479. return nil
  5480. }
  5481. // ClearedEdges returns all edge names that were cleared in this mutation.
  5482. func (m *EmployeeMutation) ClearedEdges() []string {
  5483. edges := make([]string, 0, 2)
  5484. if m.clearedem_work_experiences {
  5485. edges = append(edges, employee.EdgeEmWorkExperiences)
  5486. }
  5487. if m.clearedem_tutorial {
  5488. edges = append(edges, employee.EdgeEmTutorial)
  5489. }
  5490. return edges
  5491. }
  5492. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5493. // was cleared in this mutation.
  5494. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  5495. switch name {
  5496. case employee.EdgeEmWorkExperiences:
  5497. return m.clearedem_work_experiences
  5498. case employee.EdgeEmTutorial:
  5499. return m.clearedem_tutorial
  5500. }
  5501. return false
  5502. }
  5503. // ClearEdge clears the value of the edge with the given name. It returns an error
  5504. // if that edge is not defined in the schema.
  5505. func (m *EmployeeMutation) ClearEdge(name string) error {
  5506. switch name {
  5507. }
  5508. return fmt.Errorf("unknown Employee unique edge %s", name)
  5509. }
  5510. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5511. // It returns an error if the edge is not defined in the schema.
  5512. func (m *EmployeeMutation) ResetEdge(name string) error {
  5513. switch name {
  5514. case employee.EdgeEmWorkExperiences:
  5515. m.ResetEmWorkExperiences()
  5516. return nil
  5517. case employee.EdgeEmTutorial:
  5518. m.ResetEmTutorial()
  5519. return nil
  5520. }
  5521. return fmt.Errorf("unknown Employee edge %s", name)
  5522. }
  5523. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  5524. type EmployeeConfigMutation struct {
  5525. config
  5526. op Op
  5527. typ string
  5528. id *uint64
  5529. created_at *time.Time
  5530. updated_at *time.Time
  5531. deleted_at *time.Time
  5532. stype *string
  5533. title *string
  5534. photo *string
  5535. organization_id *uint64
  5536. addorganization_id *int64
  5537. clearedFields map[string]struct{}
  5538. done bool
  5539. oldValue func(context.Context) (*EmployeeConfig, error)
  5540. predicates []predicate.EmployeeConfig
  5541. }
  5542. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  5543. // employeeconfigOption allows management of the mutation configuration using functional options.
  5544. type employeeconfigOption func(*EmployeeConfigMutation)
  5545. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  5546. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  5547. m := &EmployeeConfigMutation{
  5548. config: c,
  5549. op: op,
  5550. typ: TypeEmployeeConfig,
  5551. clearedFields: make(map[string]struct{}),
  5552. }
  5553. for _, opt := range opts {
  5554. opt(m)
  5555. }
  5556. return m
  5557. }
  5558. // withEmployeeConfigID sets the ID field of the mutation.
  5559. func withEmployeeConfigID(id uint64) employeeconfigOption {
  5560. return func(m *EmployeeConfigMutation) {
  5561. var (
  5562. err error
  5563. once sync.Once
  5564. value *EmployeeConfig
  5565. )
  5566. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  5567. once.Do(func() {
  5568. if m.done {
  5569. err = errors.New("querying old values post mutation is not allowed")
  5570. } else {
  5571. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  5572. }
  5573. })
  5574. return value, err
  5575. }
  5576. m.id = &id
  5577. }
  5578. }
  5579. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  5580. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  5581. return func(m *EmployeeConfigMutation) {
  5582. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  5583. return node, nil
  5584. }
  5585. m.id = &node.ID
  5586. }
  5587. }
  5588. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5589. // executed in a transaction (ent.Tx), a transactional client is returned.
  5590. func (m EmployeeConfigMutation) Client() *Client {
  5591. client := &Client{config: m.config}
  5592. client.init()
  5593. return client
  5594. }
  5595. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5596. // it returns an error otherwise.
  5597. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  5598. if _, ok := m.driver.(*txDriver); !ok {
  5599. return nil, errors.New("ent: mutation is not running in a transaction")
  5600. }
  5601. tx := &Tx{config: m.config}
  5602. tx.init()
  5603. return tx, nil
  5604. }
  5605. // SetID sets the value of the id field. Note that this
  5606. // operation is only accepted on creation of EmployeeConfig entities.
  5607. func (m *EmployeeConfigMutation) SetID(id uint64) {
  5608. m.id = &id
  5609. }
  5610. // ID returns the ID value in the mutation. Note that the ID is only available
  5611. // if it was provided to the builder or after it was returned from the database.
  5612. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  5613. if m.id == nil {
  5614. return
  5615. }
  5616. return *m.id, true
  5617. }
  5618. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5619. // That means, if the mutation is applied within a transaction with an isolation level such
  5620. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5621. // or updated by the mutation.
  5622. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  5623. switch {
  5624. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5625. id, exists := m.ID()
  5626. if exists {
  5627. return []uint64{id}, nil
  5628. }
  5629. fallthrough
  5630. case m.op.Is(OpUpdate | OpDelete):
  5631. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  5632. default:
  5633. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5634. }
  5635. }
  5636. // SetCreatedAt sets the "created_at" field.
  5637. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  5638. m.created_at = &t
  5639. }
  5640. // CreatedAt returns the value of the "created_at" field in the mutation.
  5641. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  5642. v := m.created_at
  5643. if v == nil {
  5644. return
  5645. }
  5646. return *v, true
  5647. }
  5648. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  5649. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  5650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5651. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5652. if !m.op.Is(OpUpdateOne) {
  5653. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5654. }
  5655. if m.id == nil || m.oldValue == nil {
  5656. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5657. }
  5658. oldValue, err := m.oldValue(ctx)
  5659. if err != nil {
  5660. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5661. }
  5662. return oldValue.CreatedAt, nil
  5663. }
  5664. // ResetCreatedAt resets all changes to the "created_at" field.
  5665. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  5666. m.created_at = nil
  5667. }
  5668. // SetUpdatedAt sets the "updated_at" field.
  5669. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  5670. m.updated_at = &t
  5671. }
  5672. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5673. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  5674. v := m.updated_at
  5675. if v == nil {
  5676. return
  5677. }
  5678. return *v, true
  5679. }
  5680. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  5681. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  5682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5683. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5684. if !m.op.Is(OpUpdateOne) {
  5685. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5686. }
  5687. if m.id == nil || m.oldValue == nil {
  5688. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5689. }
  5690. oldValue, err := m.oldValue(ctx)
  5691. if err != nil {
  5692. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5693. }
  5694. return oldValue.UpdatedAt, nil
  5695. }
  5696. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5697. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  5698. m.updated_at = nil
  5699. }
  5700. // SetDeletedAt sets the "deleted_at" field.
  5701. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  5702. m.deleted_at = &t
  5703. }
  5704. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5705. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  5706. v := m.deleted_at
  5707. if v == nil {
  5708. return
  5709. }
  5710. return *v, true
  5711. }
  5712. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  5713. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  5714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5715. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5716. if !m.op.Is(OpUpdateOne) {
  5717. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5718. }
  5719. if m.id == nil || m.oldValue == nil {
  5720. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5721. }
  5722. oldValue, err := m.oldValue(ctx)
  5723. if err != nil {
  5724. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5725. }
  5726. return oldValue.DeletedAt, nil
  5727. }
  5728. // ClearDeletedAt clears the value of the "deleted_at" field.
  5729. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  5730. m.deleted_at = nil
  5731. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  5732. }
  5733. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5734. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  5735. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  5736. return ok
  5737. }
  5738. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5739. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  5740. m.deleted_at = nil
  5741. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  5742. }
  5743. // SetStype sets the "stype" field.
  5744. func (m *EmployeeConfigMutation) SetStype(s string) {
  5745. m.stype = &s
  5746. }
  5747. // Stype returns the value of the "stype" field in the mutation.
  5748. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  5749. v := m.stype
  5750. if v == nil {
  5751. return
  5752. }
  5753. return *v, true
  5754. }
  5755. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  5756. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  5757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5758. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  5759. if !m.op.Is(OpUpdateOne) {
  5760. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  5761. }
  5762. if m.id == nil || m.oldValue == nil {
  5763. return v, errors.New("OldStype requires an ID field in the mutation")
  5764. }
  5765. oldValue, err := m.oldValue(ctx)
  5766. if err != nil {
  5767. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  5768. }
  5769. return oldValue.Stype, nil
  5770. }
  5771. // ResetStype resets all changes to the "stype" field.
  5772. func (m *EmployeeConfigMutation) ResetStype() {
  5773. m.stype = nil
  5774. }
  5775. // SetTitle sets the "title" field.
  5776. func (m *EmployeeConfigMutation) SetTitle(s string) {
  5777. m.title = &s
  5778. }
  5779. // Title returns the value of the "title" field in the mutation.
  5780. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  5781. v := m.title
  5782. if v == nil {
  5783. return
  5784. }
  5785. return *v, true
  5786. }
  5787. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  5788. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  5789. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5790. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  5791. if !m.op.Is(OpUpdateOne) {
  5792. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  5793. }
  5794. if m.id == nil || m.oldValue == nil {
  5795. return v, errors.New("OldTitle requires an ID field in the mutation")
  5796. }
  5797. oldValue, err := m.oldValue(ctx)
  5798. if err != nil {
  5799. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  5800. }
  5801. return oldValue.Title, nil
  5802. }
  5803. // ResetTitle resets all changes to the "title" field.
  5804. func (m *EmployeeConfigMutation) ResetTitle() {
  5805. m.title = nil
  5806. }
  5807. // SetPhoto sets the "photo" field.
  5808. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  5809. m.photo = &s
  5810. }
  5811. // Photo returns the value of the "photo" field in the mutation.
  5812. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  5813. v := m.photo
  5814. if v == nil {
  5815. return
  5816. }
  5817. return *v, true
  5818. }
  5819. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  5820. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  5821. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5822. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  5823. if !m.op.Is(OpUpdateOne) {
  5824. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  5825. }
  5826. if m.id == nil || m.oldValue == nil {
  5827. return v, errors.New("OldPhoto requires an ID field in the mutation")
  5828. }
  5829. oldValue, err := m.oldValue(ctx)
  5830. if err != nil {
  5831. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  5832. }
  5833. return oldValue.Photo, nil
  5834. }
  5835. // ResetPhoto resets all changes to the "photo" field.
  5836. func (m *EmployeeConfigMutation) ResetPhoto() {
  5837. m.photo = nil
  5838. }
  5839. // SetOrganizationID sets the "organization_id" field.
  5840. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  5841. m.organization_id = &u
  5842. m.addorganization_id = nil
  5843. }
  5844. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5845. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  5846. v := m.organization_id
  5847. if v == nil {
  5848. return
  5849. }
  5850. return *v, true
  5851. }
  5852. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  5853. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  5854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5855. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5856. if !m.op.Is(OpUpdateOne) {
  5857. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5858. }
  5859. if m.id == nil || m.oldValue == nil {
  5860. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5861. }
  5862. oldValue, err := m.oldValue(ctx)
  5863. if err != nil {
  5864. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5865. }
  5866. return oldValue.OrganizationID, nil
  5867. }
  5868. // AddOrganizationID adds u to the "organization_id" field.
  5869. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  5870. if m.addorganization_id != nil {
  5871. *m.addorganization_id += u
  5872. } else {
  5873. m.addorganization_id = &u
  5874. }
  5875. }
  5876. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5877. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  5878. v := m.addorganization_id
  5879. if v == nil {
  5880. return
  5881. }
  5882. return *v, true
  5883. }
  5884. // ClearOrganizationID clears the value of the "organization_id" field.
  5885. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  5886. m.organization_id = nil
  5887. m.addorganization_id = nil
  5888. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  5889. }
  5890. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  5891. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  5892. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  5893. return ok
  5894. }
  5895. // ResetOrganizationID resets all changes to the "organization_id" field.
  5896. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  5897. m.organization_id = nil
  5898. m.addorganization_id = nil
  5899. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  5900. }
  5901. // Where appends a list predicates to the EmployeeConfigMutation builder.
  5902. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  5903. m.predicates = append(m.predicates, ps...)
  5904. }
  5905. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  5906. // users can use type-assertion to append predicates that do not depend on any generated package.
  5907. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  5908. p := make([]predicate.EmployeeConfig, len(ps))
  5909. for i := range ps {
  5910. p[i] = ps[i]
  5911. }
  5912. m.Where(p...)
  5913. }
  5914. // Op returns the operation name.
  5915. func (m *EmployeeConfigMutation) Op() Op {
  5916. return m.op
  5917. }
  5918. // SetOp allows setting the mutation operation.
  5919. func (m *EmployeeConfigMutation) SetOp(op Op) {
  5920. m.op = op
  5921. }
  5922. // Type returns the node type of this mutation (EmployeeConfig).
  5923. func (m *EmployeeConfigMutation) Type() string {
  5924. return m.typ
  5925. }
  5926. // Fields returns all fields that were changed during this mutation. Note that in
  5927. // order to get all numeric fields that were incremented/decremented, call
  5928. // AddedFields().
  5929. func (m *EmployeeConfigMutation) Fields() []string {
  5930. fields := make([]string, 0, 7)
  5931. if m.created_at != nil {
  5932. fields = append(fields, employeeconfig.FieldCreatedAt)
  5933. }
  5934. if m.updated_at != nil {
  5935. fields = append(fields, employeeconfig.FieldUpdatedAt)
  5936. }
  5937. if m.deleted_at != nil {
  5938. fields = append(fields, employeeconfig.FieldDeletedAt)
  5939. }
  5940. if m.stype != nil {
  5941. fields = append(fields, employeeconfig.FieldStype)
  5942. }
  5943. if m.title != nil {
  5944. fields = append(fields, employeeconfig.FieldTitle)
  5945. }
  5946. if m.photo != nil {
  5947. fields = append(fields, employeeconfig.FieldPhoto)
  5948. }
  5949. if m.organization_id != nil {
  5950. fields = append(fields, employeeconfig.FieldOrganizationID)
  5951. }
  5952. return fields
  5953. }
  5954. // Field returns the value of a field with the given name. The second boolean
  5955. // return value indicates that this field was not set, or was not defined in the
  5956. // schema.
  5957. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  5958. switch name {
  5959. case employeeconfig.FieldCreatedAt:
  5960. return m.CreatedAt()
  5961. case employeeconfig.FieldUpdatedAt:
  5962. return m.UpdatedAt()
  5963. case employeeconfig.FieldDeletedAt:
  5964. return m.DeletedAt()
  5965. case employeeconfig.FieldStype:
  5966. return m.Stype()
  5967. case employeeconfig.FieldTitle:
  5968. return m.Title()
  5969. case employeeconfig.FieldPhoto:
  5970. return m.Photo()
  5971. case employeeconfig.FieldOrganizationID:
  5972. return m.OrganizationID()
  5973. }
  5974. return nil, false
  5975. }
  5976. // OldField returns the old value of the field from the database. An error is
  5977. // returned if the mutation operation is not UpdateOne, or the query to the
  5978. // database failed.
  5979. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5980. switch name {
  5981. case employeeconfig.FieldCreatedAt:
  5982. return m.OldCreatedAt(ctx)
  5983. case employeeconfig.FieldUpdatedAt:
  5984. return m.OldUpdatedAt(ctx)
  5985. case employeeconfig.FieldDeletedAt:
  5986. return m.OldDeletedAt(ctx)
  5987. case employeeconfig.FieldStype:
  5988. return m.OldStype(ctx)
  5989. case employeeconfig.FieldTitle:
  5990. return m.OldTitle(ctx)
  5991. case employeeconfig.FieldPhoto:
  5992. return m.OldPhoto(ctx)
  5993. case employeeconfig.FieldOrganizationID:
  5994. return m.OldOrganizationID(ctx)
  5995. }
  5996. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  5997. }
  5998. // SetField sets the value of a field with the given name. It returns an error if
  5999. // the field is not defined in the schema, or if the type mismatched the field
  6000. // type.
  6001. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  6002. switch name {
  6003. case employeeconfig.FieldCreatedAt:
  6004. v, ok := value.(time.Time)
  6005. if !ok {
  6006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6007. }
  6008. m.SetCreatedAt(v)
  6009. return nil
  6010. case employeeconfig.FieldUpdatedAt:
  6011. v, ok := value.(time.Time)
  6012. if !ok {
  6013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6014. }
  6015. m.SetUpdatedAt(v)
  6016. return nil
  6017. case employeeconfig.FieldDeletedAt:
  6018. v, ok := value.(time.Time)
  6019. if !ok {
  6020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6021. }
  6022. m.SetDeletedAt(v)
  6023. return nil
  6024. case employeeconfig.FieldStype:
  6025. v, ok := value.(string)
  6026. if !ok {
  6027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6028. }
  6029. m.SetStype(v)
  6030. return nil
  6031. case employeeconfig.FieldTitle:
  6032. v, ok := value.(string)
  6033. if !ok {
  6034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6035. }
  6036. m.SetTitle(v)
  6037. return nil
  6038. case employeeconfig.FieldPhoto:
  6039. v, ok := value.(string)
  6040. if !ok {
  6041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6042. }
  6043. m.SetPhoto(v)
  6044. return nil
  6045. case employeeconfig.FieldOrganizationID:
  6046. v, ok := value.(uint64)
  6047. if !ok {
  6048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6049. }
  6050. m.SetOrganizationID(v)
  6051. return nil
  6052. }
  6053. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  6054. }
  6055. // AddedFields returns all numeric fields that were incremented/decremented during
  6056. // this mutation.
  6057. func (m *EmployeeConfigMutation) AddedFields() []string {
  6058. var fields []string
  6059. if m.addorganization_id != nil {
  6060. fields = append(fields, employeeconfig.FieldOrganizationID)
  6061. }
  6062. return fields
  6063. }
  6064. // AddedField returns the numeric value that was incremented/decremented on a field
  6065. // with the given name. The second boolean return value indicates that this field
  6066. // was not set, or was not defined in the schema.
  6067. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  6068. switch name {
  6069. case employeeconfig.FieldOrganizationID:
  6070. return m.AddedOrganizationID()
  6071. }
  6072. return nil, false
  6073. }
  6074. // AddField adds the value to the field with the given name. It returns an error if
  6075. // the field is not defined in the schema, or if the type mismatched the field
  6076. // type.
  6077. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  6078. switch name {
  6079. case employeeconfig.FieldOrganizationID:
  6080. v, ok := value.(int64)
  6081. if !ok {
  6082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6083. }
  6084. m.AddOrganizationID(v)
  6085. return nil
  6086. }
  6087. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  6088. }
  6089. // ClearedFields returns all nullable fields that were cleared during this
  6090. // mutation.
  6091. func (m *EmployeeConfigMutation) ClearedFields() []string {
  6092. var fields []string
  6093. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  6094. fields = append(fields, employeeconfig.FieldDeletedAt)
  6095. }
  6096. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  6097. fields = append(fields, employeeconfig.FieldOrganizationID)
  6098. }
  6099. return fields
  6100. }
  6101. // FieldCleared returns a boolean indicating if a field with the given name was
  6102. // cleared in this mutation.
  6103. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  6104. _, ok := m.clearedFields[name]
  6105. return ok
  6106. }
  6107. // ClearField clears the value of the field with the given name. It returns an
  6108. // error if the field is not defined in the schema.
  6109. func (m *EmployeeConfigMutation) ClearField(name string) error {
  6110. switch name {
  6111. case employeeconfig.FieldDeletedAt:
  6112. m.ClearDeletedAt()
  6113. return nil
  6114. case employeeconfig.FieldOrganizationID:
  6115. m.ClearOrganizationID()
  6116. return nil
  6117. }
  6118. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  6119. }
  6120. // ResetField resets all changes in the mutation for the field with the given name.
  6121. // It returns an error if the field is not defined in the schema.
  6122. func (m *EmployeeConfigMutation) ResetField(name string) error {
  6123. switch name {
  6124. case employeeconfig.FieldCreatedAt:
  6125. m.ResetCreatedAt()
  6126. return nil
  6127. case employeeconfig.FieldUpdatedAt:
  6128. m.ResetUpdatedAt()
  6129. return nil
  6130. case employeeconfig.FieldDeletedAt:
  6131. m.ResetDeletedAt()
  6132. return nil
  6133. case employeeconfig.FieldStype:
  6134. m.ResetStype()
  6135. return nil
  6136. case employeeconfig.FieldTitle:
  6137. m.ResetTitle()
  6138. return nil
  6139. case employeeconfig.FieldPhoto:
  6140. m.ResetPhoto()
  6141. return nil
  6142. case employeeconfig.FieldOrganizationID:
  6143. m.ResetOrganizationID()
  6144. return nil
  6145. }
  6146. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  6147. }
  6148. // AddedEdges returns all edge names that were set/added in this mutation.
  6149. func (m *EmployeeConfigMutation) AddedEdges() []string {
  6150. edges := make([]string, 0, 0)
  6151. return edges
  6152. }
  6153. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6154. // name in this mutation.
  6155. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  6156. return nil
  6157. }
  6158. // RemovedEdges returns all edge names that were removed in this mutation.
  6159. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  6160. edges := make([]string, 0, 0)
  6161. return edges
  6162. }
  6163. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6164. // the given name in this mutation.
  6165. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  6166. return nil
  6167. }
  6168. // ClearedEdges returns all edge names that were cleared in this mutation.
  6169. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  6170. edges := make([]string, 0, 0)
  6171. return edges
  6172. }
  6173. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6174. // was cleared in this mutation.
  6175. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  6176. return false
  6177. }
  6178. // ClearEdge clears the value of the edge with the given name. It returns an error
  6179. // if that edge is not defined in the schema.
  6180. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  6181. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  6182. }
  6183. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6184. // It returns an error if the edge is not defined in the schema.
  6185. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  6186. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  6187. }
  6188. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  6189. type LabelMutation struct {
  6190. config
  6191. op Op
  6192. typ string
  6193. id *uint64
  6194. created_at *time.Time
  6195. updated_at *time.Time
  6196. status *uint8
  6197. addstatus *int8
  6198. _type *int
  6199. add_type *int
  6200. name *string
  6201. from *int
  6202. addfrom *int
  6203. mode *int
  6204. addmode *int
  6205. conditions *string
  6206. organization_id *uint64
  6207. addorganization_id *int64
  6208. clearedFields map[string]struct{}
  6209. label_relationships map[uint64]struct{}
  6210. removedlabel_relationships map[uint64]struct{}
  6211. clearedlabel_relationships bool
  6212. done bool
  6213. oldValue func(context.Context) (*Label, error)
  6214. predicates []predicate.Label
  6215. }
  6216. var _ ent.Mutation = (*LabelMutation)(nil)
  6217. // labelOption allows management of the mutation configuration using functional options.
  6218. type labelOption func(*LabelMutation)
  6219. // newLabelMutation creates new mutation for the Label entity.
  6220. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  6221. m := &LabelMutation{
  6222. config: c,
  6223. op: op,
  6224. typ: TypeLabel,
  6225. clearedFields: make(map[string]struct{}),
  6226. }
  6227. for _, opt := range opts {
  6228. opt(m)
  6229. }
  6230. return m
  6231. }
  6232. // withLabelID sets the ID field of the mutation.
  6233. func withLabelID(id uint64) labelOption {
  6234. return func(m *LabelMutation) {
  6235. var (
  6236. err error
  6237. once sync.Once
  6238. value *Label
  6239. )
  6240. m.oldValue = func(ctx context.Context) (*Label, error) {
  6241. once.Do(func() {
  6242. if m.done {
  6243. err = errors.New("querying old values post mutation is not allowed")
  6244. } else {
  6245. value, err = m.Client().Label.Get(ctx, id)
  6246. }
  6247. })
  6248. return value, err
  6249. }
  6250. m.id = &id
  6251. }
  6252. }
  6253. // withLabel sets the old Label of the mutation.
  6254. func withLabel(node *Label) labelOption {
  6255. return func(m *LabelMutation) {
  6256. m.oldValue = func(context.Context) (*Label, error) {
  6257. return node, nil
  6258. }
  6259. m.id = &node.ID
  6260. }
  6261. }
  6262. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6263. // executed in a transaction (ent.Tx), a transactional client is returned.
  6264. func (m LabelMutation) Client() *Client {
  6265. client := &Client{config: m.config}
  6266. client.init()
  6267. return client
  6268. }
  6269. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6270. // it returns an error otherwise.
  6271. func (m LabelMutation) Tx() (*Tx, error) {
  6272. if _, ok := m.driver.(*txDriver); !ok {
  6273. return nil, errors.New("ent: mutation is not running in a transaction")
  6274. }
  6275. tx := &Tx{config: m.config}
  6276. tx.init()
  6277. return tx, nil
  6278. }
  6279. // SetID sets the value of the id field. Note that this
  6280. // operation is only accepted on creation of Label entities.
  6281. func (m *LabelMutation) SetID(id uint64) {
  6282. m.id = &id
  6283. }
  6284. // ID returns the ID value in the mutation. Note that the ID is only available
  6285. // if it was provided to the builder or after it was returned from the database.
  6286. func (m *LabelMutation) ID() (id uint64, exists bool) {
  6287. if m.id == nil {
  6288. return
  6289. }
  6290. return *m.id, true
  6291. }
  6292. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6293. // That means, if the mutation is applied within a transaction with an isolation level such
  6294. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6295. // or updated by the mutation.
  6296. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  6297. switch {
  6298. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6299. id, exists := m.ID()
  6300. if exists {
  6301. return []uint64{id}, nil
  6302. }
  6303. fallthrough
  6304. case m.op.Is(OpUpdate | OpDelete):
  6305. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  6306. default:
  6307. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6308. }
  6309. }
  6310. // SetCreatedAt sets the "created_at" field.
  6311. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  6312. m.created_at = &t
  6313. }
  6314. // CreatedAt returns the value of the "created_at" field in the mutation.
  6315. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  6316. v := m.created_at
  6317. if v == nil {
  6318. return
  6319. }
  6320. return *v, true
  6321. }
  6322. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  6323. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  6324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6325. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6326. if !m.op.Is(OpUpdateOne) {
  6327. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6328. }
  6329. if m.id == nil || m.oldValue == nil {
  6330. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6331. }
  6332. oldValue, err := m.oldValue(ctx)
  6333. if err != nil {
  6334. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6335. }
  6336. return oldValue.CreatedAt, nil
  6337. }
  6338. // ResetCreatedAt resets all changes to the "created_at" field.
  6339. func (m *LabelMutation) ResetCreatedAt() {
  6340. m.created_at = nil
  6341. }
  6342. // SetUpdatedAt sets the "updated_at" field.
  6343. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  6344. m.updated_at = &t
  6345. }
  6346. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6347. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  6348. v := m.updated_at
  6349. if v == nil {
  6350. return
  6351. }
  6352. return *v, true
  6353. }
  6354. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  6355. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  6356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6357. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6358. if !m.op.Is(OpUpdateOne) {
  6359. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6360. }
  6361. if m.id == nil || m.oldValue == nil {
  6362. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6363. }
  6364. oldValue, err := m.oldValue(ctx)
  6365. if err != nil {
  6366. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6367. }
  6368. return oldValue.UpdatedAt, nil
  6369. }
  6370. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6371. func (m *LabelMutation) ResetUpdatedAt() {
  6372. m.updated_at = nil
  6373. }
  6374. // SetStatus sets the "status" field.
  6375. func (m *LabelMutation) SetStatus(u uint8) {
  6376. m.status = &u
  6377. m.addstatus = nil
  6378. }
  6379. // Status returns the value of the "status" field in the mutation.
  6380. func (m *LabelMutation) Status() (r uint8, exists bool) {
  6381. v := m.status
  6382. if v == nil {
  6383. return
  6384. }
  6385. return *v, true
  6386. }
  6387. // OldStatus returns the old "status" field's value of the Label entity.
  6388. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  6389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6390. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  6391. if !m.op.Is(OpUpdateOne) {
  6392. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  6393. }
  6394. if m.id == nil || m.oldValue == nil {
  6395. return v, errors.New("OldStatus requires an ID field in the mutation")
  6396. }
  6397. oldValue, err := m.oldValue(ctx)
  6398. if err != nil {
  6399. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  6400. }
  6401. return oldValue.Status, nil
  6402. }
  6403. // AddStatus adds u to the "status" field.
  6404. func (m *LabelMutation) AddStatus(u int8) {
  6405. if m.addstatus != nil {
  6406. *m.addstatus += u
  6407. } else {
  6408. m.addstatus = &u
  6409. }
  6410. }
  6411. // AddedStatus returns the value that was added to the "status" field in this mutation.
  6412. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  6413. v := m.addstatus
  6414. if v == nil {
  6415. return
  6416. }
  6417. return *v, true
  6418. }
  6419. // ClearStatus clears the value of the "status" field.
  6420. func (m *LabelMutation) ClearStatus() {
  6421. m.status = nil
  6422. m.addstatus = nil
  6423. m.clearedFields[label.FieldStatus] = struct{}{}
  6424. }
  6425. // StatusCleared returns if the "status" field was cleared in this mutation.
  6426. func (m *LabelMutation) StatusCleared() bool {
  6427. _, ok := m.clearedFields[label.FieldStatus]
  6428. return ok
  6429. }
  6430. // ResetStatus resets all changes to the "status" field.
  6431. func (m *LabelMutation) ResetStatus() {
  6432. m.status = nil
  6433. m.addstatus = nil
  6434. delete(m.clearedFields, label.FieldStatus)
  6435. }
  6436. // SetType sets the "type" field.
  6437. func (m *LabelMutation) SetType(i int) {
  6438. m._type = &i
  6439. m.add_type = nil
  6440. }
  6441. // GetType returns the value of the "type" field in the mutation.
  6442. func (m *LabelMutation) GetType() (r int, exists bool) {
  6443. v := m._type
  6444. if v == nil {
  6445. return
  6446. }
  6447. return *v, true
  6448. }
  6449. // OldType returns the old "type" field's value of the Label entity.
  6450. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  6451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6452. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  6453. if !m.op.Is(OpUpdateOne) {
  6454. return v, errors.New("OldType is only allowed on UpdateOne operations")
  6455. }
  6456. if m.id == nil || m.oldValue == nil {
  6457. return v, errors.New("OldType requires an ID field in the mutation")
  6458. }
  6459. oldValue, err := m.oldValue(ctx)
  6460. if err != nil {
  6461. return v, fmt.Errorf("querying old value for OldType: %w", err)
  6462. }
  6463. return oldValue.Type, nil
  6464. }
  6465. // AddType adds i to the "type" field.
  6466. func (m *LabelMutation) AddType(i int) {
  6467. if m.add_type != nil {
  6468. *m.add_type += i
  6469. } else {
  6470. m.add_type = &i
  6471. }
  6472. }
  6473. // AddedType returns the value that was added to the "type" field in this mutation.
  6474. func (m *LabelMutation) AddedType() (r int, exists bool) {
  6475. v := m.add_type
  6476. if v == nil {
  6477. return
  6478. }
  6479. return *v, true
  6480. }
  6481. // ResetType resets all changes to the "type" field.
  6482. func (m *LabelMutation) ResetType() {
  6483. m._type = nil
  6484. m.add_type = nil
  6485. }
  6486. // SetName sets the "name" field.
  6487. func (m *LabelMutation) SetName(s string) {
  6488. m.name = &s
  6489. }
  6490. // Name returns the value of the "name" field in the mutation.
  6491. func (m *LabelMutation) Name() (r string, exists bool) {
  6492. v := m.name
  6493. if v == nil {
  6494. return
  6495. }
  6496. return *v, true
  6497. }
  6498. // OldName returns the old "name" field's value of the Label entity.
  6499. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  6500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6501. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  6502. if !m.op.Is(OpUpdateOne) {
  6503. return v, errors.New("OldName is only allowed on UpdateOne operations")
  6504. }
  6505. if m.id == nil || m.oldValue == nil {
  6506. return v, errors.New("OldName requires an ID field in the mutation")
  6507. }
  6508. oldValue, err := m.oldValue(ctx)
  6509. if err != nil {
  6510. return v, fmt.Errorf("querying old value for OldName: %w", err)
  6511. }
  6512. return oldValue.Name, nil
  6513. }
  6514. // ResetName resets all changes to the "name" field.
  6515. func (m *LabelMutation) ResetName() {
  6516. m.name = nil
  6517. }
  6518. // SetFrom sets the "from" field.
  6519. func (m *LabelMutation) SetFrom(i int) {
  6520. m.from = &i
  6521. m.addfrom = nil
  6522. }
  6523. // From returns the value of the "from" field in the mutation.
  6524. func (m *LabelMutation) From() (r int, exists bool) {
  6525. v := m.from
  6526. if v == nil {
  6527. return
  6528. }
  6529. return *v, true
  6530. }
  6531. // OldFrom returns the old "from" field's value of the Label entity.
  6532. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  6533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6534. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  6535. if !m.op.Is(OpUpdateOne) {
  6536. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  6537. }
  6538. if m.id == nil || m.oldValue == nil {
  6539. return v, errors.New("OldFrom requires an ID field in the mutation")
  6540. }
  6541. oldValue, err := m.oldValue(ctx)
  6542. if err != nil {
  6543. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  6544. }
  6545. return oldValue.From, nil
  6546. }
  6547. // AddFrom adds i to the "from" field.
  6548. func (m *LabelMutation) AddFrom(i int) {
  6549. if m.addfrom != nil {
  6550. *m.addfrom += i
  6551. } else {
  6552. m.addfrom = &i
  6553. }
  6554. }
  6555. // AddedFrom returns the value that was added to the "from" field in this mutation.
  6556. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  6557. v := m.addfrom
  6558. if v == nil {
  6559. return
  6560. }
  6561. return *v, true
  6562. }
  6563. // ResetFrom resets all changes to the "from" field.
  6564. func (m *LabelMutation) ResetFrom() {
  6565. m.from = nil
  6566. m.addfrom = nil
  6567. }
  6568. // SetMode sets the "mode" field.
  6569. func (m *LabelMutation) SetMode(i int) {
  6570. m.mode = &i
  6571. m.addmode = nil
  6572. }
  6573. // Mode returns the value of the "mode" field in the mutation.
  6574. func (m *LabelMutation) Mode() (r int, exists bool) {
  6575. v := m.mode
  6576. if v == nil {
  6577. return
  6578. }
  6579. return *v, true
  6580. }
  6581. // OldMode returns the old "mode" field's value of the Label entity.
  6582. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  6583. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6584. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  6585. if !m.op.Is(OpUpdateOne) {
  6586. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  6587. }
  6588. if m.id == nil || m.oldValue == nil {
  6589. return v, errors.New("OldMode requires an ID field in the mutation")
  6590. }
  6591. oldValue, err := m.oldValue(ctx)
  6592. if err != nil {
  6593. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  6594. }
  6595. return oldValue.Mode, nil
  6596. }
  6597. // AddMode adds i to the "mode" field.
  6598. func (m *LabelMutation) AddMode(i int) {
  6599. if m.addmode != nil {
  6600. *m.addmode += i
  6601. } else {
  6602. m.addmode = &i
  6603. }
  6604. }
  6605. // AddedMode returns the value that was added to the "mode" field in this mutation.
  6606. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  6607. v := m.addmode
  6608. if v == nil {
  6609. return
  6610. }
  6611. return *v, true
  6612. }
  6613. // ResetMode resets all changes to the "mode" field.
  6614. func (m *LabelMutation) ResetMode() {
  6615. m.mode = nil
  6616. m.addmode = nil
  6617. }
  6618. // SetConditions sets the "conditions" field.
  6619. func (m *LabelMutation) SetConditions(s string) {
  6620. m.conditions = &s
  6621. }
  6622. // Conditions returns the value of the "conditions" field in the mutation.
  6623. func (m *LabelMutation) Conditions() (r string, exists bool) {
  6624. v := m.conditions
  6625. if v == nil {
  6626. return
  6627. }
  6628. return *v, true
  6629. }
  6630. // OldConditions returns the old "conditions" field's value of the Label entity.
  6631. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  6632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6633. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  6634. if !m.op.Is(OpUpdateOne) {
  6635. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  6636. }
  6637. if m.id == nil || m.oldValue == nil {
  6638. return v, errors.New("OldConditions requires an ID field in the mutation")
  6639. }
  6640. oldValue, err := m.oldValue(ctx)
  6641. if err != nil {
  6642. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  6643. }
  6644. return oldValue.Conditions, nil
  6645. }
  6646. // ClearConditions clears the value of the "conditions" field.
  6647. func (m *LabelMutation) ClearConditions() {
  6648. m.conditions = nil
  6649. m.clearedFields[label.FieldConditions] = struct{}{}
  6650. }
  6651. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  6652. func (m *LabelMutation) ConditionsCleared() bool {
  6653. _, ok := m.clearedFields[label.FieldConditions]
  6654. return ok
  6655. }
  6656. // ResetConditions resets all changes to the "conditions" field.
  6657. func (m *LabelMutation) ResetConditions() {
  6658. m.conditions = nil
  6659. delete(m.clearedFields, label.FieldConditions)
  6660. }
  6661. // SetOrganizationID sets the "organization_id" field.
  6662. func (m *LabelMutation) SetOrganizationID(u uint64) {
  6663. m.organization_id = &u
  6664. m.addorganization_id = nil
  6665. }
  6666. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6667. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  6668. v := m.organization_id
  6669. if v == nil {
  6670. return
  6671. }
  6672. return *v, true
  6673. }
  6674. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  6675. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  6676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6677. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6678. if !m.op.Is(OpUpdateOne) {
  6679. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6680. }
  6681. if m.id == nil || m.oldValue == nil {
  6682. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6683. }
  6684. oldValue, err := m.oldValue(ctx)
  6685. if err != nil {
  6686. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6687. }
  6688. return oldValue.OrganizationID, nil
  6689. }
  6690. // AddOrganizationID adds u to the "organization_id" field.
  6691. func (m *LabelMutation) AddOrganizationID(u int64) {
  6692. if m.addorganization_id != nil {
  6693. *m.addorganization_id += u
  6694. } else {
  6695. m.addorganization_id = &u
  6696. }
  6697. }
  6698. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6699. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  6700. v := m.addorganization_id
  6701. if v == nil {
  6702. return
  6703. }
  6704. return *v, true
  6705. }
  6706. // ClearOrganizationID clears the value of the "organization_id" field.
  6707. func (m *LabelMutation) ClearOrganizationID() {
  6708. m.organization_id = nil
  6709. m.addorganization_id = nil
  6710. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  6711. }
  6712. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  6713. func (m *LabelMutation) OrganizationIDCleared() bool {
  6714. _, ok := m.clearedFields[label.FieldOrganizationID]
  6715. return ok
  6716. }
  6717. // ResetOrganizationID resets all changes to the "organization_id" field.
  6718. func (m *LabelMutation) ResetOrganizationID() {
  6719. m.organization_id = nil
  6720. m.addorganization_id = nil
  6721. delete(m.clearedFields, label.FieldOrganizationID)
  6722. }
  6723. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  6724. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  6725. if m.label_relationships == nil {
  6726. m.label_relationships = make(map[uint64]struct{})
  6727. }
  6728. for i := range ids {
  6729. m.label_relationships[ids[i]] = struct{}{}
  6730. }
  6731. }
  6732. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  6733. func (m *LabelMutation) ClearLabelRelationships() {
  6734. m.clearedlabel_relationships = true
  6735. }
  6736. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  6737. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  6738. return m.clearedlabel_relationships
  6739. }
  6740. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  6741. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  6742. if m.removedlabel_relationships == nil {
  6743. m.removedlabel_relationships = make(map[uint64]struct{})
  6744. }
  6745. for i := range ids {
  6746. delete(m.label_relationships, ids[i])
  6747. m.removedlabel_relationships[ids[i]] = struct{}{}
  6748. }
  6749. }
  6750. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  6751. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  6752. for id := range m.removedlabel_relationships {
  6753. ids = append(ids, id)
  6754. }
  6755. return
  6756. }
  6757. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  6758. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  6759. for id := range m.label_relationships {
  6760. ids = append(ids, id)
  6761. }
  6762. return
  6763. }
  6764. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  6765. func (m *LabelMutation) ResetLabelRelationships() {
  6766. m.label_relationships = nil
  6767. m.clearedlabel_relationships = false
  6768. m.removedlabel_relationships = nil
  6769. }
  6770. // Where appends a list predicates to the LabelMutation builder.
  6771. func (m *LabelMutation) Where(ps ...predicate.Label) {
  6772. m.predicates = append(m.predicates, ps...)
  6773. }
  6774. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  6775. // users can use type-assertion to append predicates that do not depend on any generated package.
  6776. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  6777. p := make([]predicate.Label, len(ps))
  6778. for i := range ps {
  6779. p[i] = ps[i]
  6780. }
  6781. m.Where(p...)
  6782. }
  6783. // Op returns the operation name.
  6784. func (m *LabelMutation) Op() Op {
  6785. return m.op
  6786. }
  6787. // SetOp allows setting the mutation operation.
  6788. func (m *LabelMutation) SetOp(op Op) {
  6789. m.op = op
  6790. }
  6791. // Type returns the node type of this mutation (Label).
  6792. func (m *LabelMutation) Type() string {
  6793. return m.typ
  6794. }
  6795. // Fields returns all fields that were changed during this mutation. Note that in
  6796. // order to get all numeric fields that were incremented/decremented, call
  6797. // AddedFields().
  6798. func (m *LabelMutation) Fields() []string {
  6799. fields := make([]string, 0, 9)
  6800. if m.created_at != nil {
  6801. fields = append(fields, label.FieldCreatedAt)
  6802. }
  6803. if m.updated_at != nil {
  6804. fields = append(fields, label.FieldUpdatedAt)
  6805. }
  6806. if m.status != nil {
  6807. fields = append(fields, label.FieldStatus)
  6808. }
  6809. if m._type != nil {
  6810. fields = append(fields, label.FieldType)
  6811. }
  6812. if m.name != nil {
  6813. fields = append(fields, label.FieldName)
  6814. }
  6815. if m.from != nil {
  6816. fields = append(fields, label.FieldFrom)
  6817. }
  6818. if m.mode != nil {
  6819. fields = append(fields, label.FieldMode)
  6820. }
  6821. if m.conditions != nil {
  6822. fields = append(fields, label.FieldConditions)
  6823. }
  6824. if m.organization_id != nil {
  6825. fields = append(fields, label.FieldOrganizationID)
  6826. }
  6827. return fields
  6828. }
  6829. // Field returns the value of a field with the given name. The second boolean
  6830. // return value indicates that this field was not set, or was not defined in the
  6831. // schema.
  6832. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  6833. switch name {
  6834. case label.FieldCreatedAt:
  6835. return m.CreatedAt()
  6836. case label.FieldUpdatedAt:
  6837. return m.UpdatedAt()
  6838. case label.FieldStatus:
  6839. return m.Status()
  6840. case label.FieldType:
  6841. return m.GetType()
  6842. case label.FieldName:
  6843. return m.Name()
  6844. case label.FieldFrom:
  6845. return m.From()
  6846. case label.FieldMode:
  6847. return m.Mode()
  6848. case label.FieldConditions:
  6849. return m.Conditions()
  6850. case label.FieldOrganizationID:
  6851. return m.OrganizationID()
  6852. }
  6853. return nil, false
  6854. }
  6855. // OldField returns the old value of the field from the database. An error is
  6856. // returned if the mutation operation is not UpdateOne, or the query to the
  6857. // database failed.
  6858. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6859. switch name {
  6860. case label.FieldCreatedAt:
  6861. return m.OldCreatedAt(ctx)
  6862. case label.FieldUpdatedAt:
  6863. return m.OldUpdatedAt(ctx)
  6864. case label.FieldStatus:
  6865. return m.OldStatus(ctx)
  6866. case label.FieldType:
  6867. return m.OldType(ctx)
  6868. case label.FieldName:
  6869. return m.OldName(ctx)
  6870. case label.FieldFrom:
  6871. return m.OldFrom(ctx)
  6872. case label.FieldMode:
  6873. return m.OldMode(ctx)
  6874. case label.FieldConditions:
  6875. return m.OldConditions(ctx)
  6876. case label.FieldOrganizationID:
  6877. return m.OldOrganizationID(ctx)
  6878. }
  6879. return nil, fmt.Errorf("unknown Label field %s", name)
  6880. }
  6881. // SetField sets the value of a field with the given name. It returns an error if
  6882. // the field is not defined in the schema, or if the type mismatched the field
  6883. // type.
  6884. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  6885. switch name {
  6886. case label.FieldCreatedAt:
  6887. v, ok := value.(time.Time)
  6888. if !ok {
  6889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6890. }
  6891. m.SetCreatedAt(v)
  6892. return nil
  6893. case label.FieldUpdatedAt:
  6894. v, ok := value.(time.Time)
  6895. if !ok {
  6896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6897. }
  6898. m.SetUpdatedAt(v)
  6899. return nil
  6900. case label.FieldStatus:
  6901. v, ok := value.(uint8)
  6902. if !ok {
  6903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6904. }
  6905. m.SetStatus(v)
  6906. return nil
  6907. case label.FieldType:
  6908. v, ok := value.(int)
  6909. if !ok {
  6910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6911. }
  6912. m.SetType(v)
  6913. return nil
  6914. case label.FieldName:
  6915. v, ok := value.(string)
  6916. if !ok {
  6917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6918. }
  6919. m.SetName(v)
  6920. return nil
  6921. case label.FieldFrom:
  6922. v, ok := value.(int)
  6923. if !ok {
  6924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6925. }
  6926. m.SetFrom(v)
  6927. return nil
  6928. case label.FieldMode:
  6929. v, ok := value.(int)
  6930. if !ok {
  6931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6932. }
  6933. m.SetMode(v)
  6934. return nil
  6935. case label.FieldConditions:
  6936. v, ok := value.(string)
  6937. if !ok {
  6938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6939. }
  6940. m.SetConditions(v)
  6941. return nil
  6942. case label.FieldOrganizationID:
  6943. v, ok := value.(uint64)
  6944. if !ok {
  6945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6946. }
  6947. m.SetOrganizationID(v)
  6948. return nil
  6949. }
  6950. return fmt.Errorf("unknown Label field %s", name)
  6951. }
  6952. // AddedFields returns all numeric fields that were incremented/decremented during
  6953. // this mutation.
  6954. func (m *LabelMutation) AddedFields() []string {
  6955. var fields []string
  6956. if m.addstatus != nil {
  6957. fields = append(fields, label.FieldStatus)
  6958. }
  6959. if m.add_type != nil {
  6960. fields = append(fields, label.FieldType)
  6961. }
  6962. if m.addfrom != nil {
  6963. fields = append(fields, label.FieldFrom)
  6964. }
  6965. if m.addmode != nil {
  6966. fields = append(fields, label.FieldMode)
  6967. }
  6968. if m.addorganization_id != nil {
  6969. fields = append(fields, label.FieldOrganizationID)
  6970. }
  6971. return fields
  6972. }
  6973. // AddedField returns the numeric value that was incremented/decremented on a field
  6974. // with the given name. The second boolean return value indicates that this field
  6975. // was not set, or was not defined in the schema.
  6976. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  6977. switch name {
  6978. case label.FieldStatus:
  6979. return m.AddedStatus()
  6980. case label.FieldType:
  6981. return m.AddedType()
  6982. case label.FieldFrom:
  6983. return m.AddedFrom()
  6984. case label.FieldMode:
  6985. return m.AddedMode()
  6986. case label.FieldOrganizationID:
  6987. return m.AddedOrganizationID()
  6988. }
  6989. return nil, false
  6990. }
  6991. // AddField adds the value to the field with the given name. It returns an error if
  6992. // the field is not defined in the schema, or if the type mismatched the field
  6993. // type.
  6994. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  6995. switch name {
  6996. case label.FieldStatus:
  6997. v, ok := value.(int8)
  6998. if !ok {
  6999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7000. }
  7001. m.AddStatus(v)
  7002. return nil
  7003. case label.FieldType:
  7004. v, ok := value.(int)
  7005. if !ok {
  7006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7007. }
  7008. m.AddType(v)
  7009. return nil
  7010. case label.FieldFrom:
  7011. v, ok := value.(int)
  7012. if !ok {
  7013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7014. }
  7015. m.AddFrom(v)
  7016. return nil
  7017. case label.FieldMode:
  7018. v, ok := value.(int)
  7019. if !ok {
  7020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7021. }
  7022. m.AddMode(v)
  7023. return nil
  7024. case label.FieldOrganizationID:
  7025. v, ok := value.(int64)
  7026. if !ok {
  7027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7028. }
  7029. m.AddOrganizationID(v)
  7030. return nil
  7031. }
  7032. return fmt.Errorf("unknown Label numeric field %s", name)
  7033. }
  7034. // ClearedFields returns all nullable fields that were cleared during this
  7035. // mutation.
  7036. func (m *LabelMutation) ClearedFields() []string {
  7037. var fields []string
  7038. if m.FieldCleared(label.FieldStatus) {
  7039. fields = append(fields, label.FieldStatus)
  7040. }
  7041. if m.FieldCleared(label.FieldConditions) {
  7042. fields = append(fields, label.FieldConditions)
  7043. }
  7044. if m.FieldCleared(label.FieldOrganizationID) {
  7045. fields = append(fields, label.FieldOrganizationID)
  7046. }
  7047. return fields
  7048. }
  7049. // FieldCleared returns a boolean indicating if a field with the given name was
  7050. // cleared in this mutation.
  7051. func (m *LabelMutation) FieldCleared(name string) bool {
  7052. _, ok := m.clearedFields[name]
  7053. return ok
  7054. }
  7055. // ClearField clears the value of the field with the given name. It returns an
  7056. // error if the field is not defined in the schema.
  7057. func (m *LabelMutation) ClearField(name string) error {
  7058. switch name {
  7059. case label.FieldStatus:
  7060. m.ClearStatus()
  7061. return nil
  7062. case label.FieldConditions:
  7063. m.ClearConditions()
  7064. return nil
  7065. case label.FieldOrganizationID:
  7066. m.ClearOrganizationID()
  7067. return nil
  7068. }
  7069. return fmt.Errorf("unknown Label nullable field %s", name)
  7070. }
  7071. // ResetField resets all changes in the mutation for the field with the given name.
  7072. // It returns an error if the field is not defined in the schema.
  7073. func (m *LabelMutation) ResetField(name string) error {
  7074. switch name {
  7075. case label.FieldCreatedAt:
  7076. m.ResetCreatedAt()
  7077. return nil
  7078. case label.FieldUpdatedAt:
  7079. m.ResetUpdatedAt()
  7080. return nil
  7081. case label.FieldStatus:
  7082. m.ResetStatus()
  7083. return nil
  7084. case label.FieldType:
  7085. m.ResetType()
  7086. return nil
  7087. case label.FieldName:
  7088. m.ResetName()
  7089. return nil
  7090. case label.FieldFrom:
  7091. m.ResetFrom()
  7092. return nil
  7093. case label.FieldMode:
  7094. m.ResetMode()
  7095. return nil
  7096. case label.FieldConditions:
  7097. m.ResetConditions()
  7098. return nil
  7099. case label.FieldOrganizationID:
  7100. m.ResetOrganizationID()
  7101. return nil
  7102. }
  7103. return fmt.Errorf("unknown Label field %s", name)
  7104. }
  7105. // AddedEdges returns all edge names that were set/added in this mutation.
  7106. func (m *LabelMutation) AddedEdges() []string {
  7107. edges := make([]string, 0, 1)
  7108. if m.label_relationships != nil {
  7109. edges = append(edges, label.EdgeLabelRelationships)
  7110. }
  7111. return edges
  7112. }
  7113. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7114. // name in this mutation.
  7115. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  7116. switch name {
  7117. case label.EdgeLabelRelationships:
  7118. ids := make([]ent.Value, 0, len(m.label_relationships))
  7119. for id := range m.label_relationships {
  7120. ids = append(ids, id)
  7121. }
  7122. return ids
  7123. }
  7124. return nil
  7125. }
  7126. // RemovedEdges returns all edge names that were removed in this mutation.
  7127. func (m *LabelMutation) RemovedEdges() []string {
  7128. edges := make([]string, 0, 1)
  7129. if m.removedlabel_relationships != nil {
  7130. edges = append(edges, label.EdgeLabelRelationships)
  7131. }
  7132. return edges
  7133. }
  7134. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7135. // the given name in this mutation.
  7136. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  7137. switch name {
  7138. case label.EdgeLabelRelationships:
  7139. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  7140. for id := range m.removedlabel_relationships {
  7141. ids = append(ids, id)
  7142. }
  7143. return ids
  7144. }
  7145. return nil
  7146. }
  7147. // ClearedEdges returns all edge names that were cleared in this mutation.
  7148. func (m *LabelMutation) ClearedEdges() []string {
  7149. edges := make([]string, 0, 1)
  7150. if m.clearedlabel_relationships {
  7151. edges = append(edges, label.EdgeLabelRelationships)
  7152. }
  7153. return edges
  7154. }
  7155. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7156. // was cleared in this mutation.
  7157. func (m *LabelMutation) EdgeCleared(name string) bool {
  7158. switch name {
  7159. case label.EdgeLabelRelationships:
  7160. return m.clearedlabel_relationships
  7161. }
  7162. return false
  7163. }
  7164. // ClearEdge clears the value of the edge with the given name. It returns an error
  7165. // if that edge is not defined in the schema.
  7166. func (m *LabelMutation) ClearEdge(name string) error {
  7167. switch name {
  7168. }
  7169. return fmt.Errorf("unknown Label unique edge %s", name)
  7170. }
  7171. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7172. // It returns an error if the edge is not defined in the schema.
  7173. func (m *LabelMutation) ResetEdge(name string) error {
  7174. switch name {
  7175. case label.EdgeLabelRelationships:
  7176. m.ResetLabelRelationships()
  7177. return nil
  7178. }
  7179. return fmt.Errorf("unknown Label edge %s", name)
  7180. }
  7181. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  7182. type LabelRelationshipMutation struct {
  7183. config
  7184. op Op
  7185. typ string
  7186. id *uint64
  7187. created_at *time.Time
  7188. updated_at *time.Time
  7189. status *uint8
  7190. addstatus *int8
  7191. deleted_at *time.Time
  7192. organization_id *uint64
  7193. addorganization_id *int64
  7194. clearedFields map[string]struct{}
  7195. contacts *uint64
  7196. clearedcontacts bool
  7197. labels *uint64
  7198. clearedlabels bool
  7199. done bool
  7200. oldValue func(context.Context) (*LabelRelationship, error)
  7201. predicates []predicate.LabelRelationship
  7202. }
  7203. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  7204. // labelrelationshipOption allows management of the mutation configuration using functional options.
  7205. type labelrelationshipOption func(*LabelRelationshipMutation)
  7206. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  7207. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  7208. m := &LabelRelationshipMutation{
  7209. config: c,
  7210. op: op,
  7211. typ: TypeLabelRelationship,
  7212. clearedFields: make(map[string]struct{}),
  7213. }
  7214. for _, opt := range opts {
  7215. opt(m)
  7216. }
  7217. return m
  7218. }
  7219. // withLabelRelationshipID sets the ID field of the mutation.
  7220. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  7221. return func(m *LabelRelationshipMutation) {
  7222. var (
  7223. err error
  7224. once sync.Once
  7225. value *LabelRelationship
  7226. )
  7227. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  7228. once.Do(func() {
  7229. if m.done {
  7230. err = errors.New("querying old values post mutation is not allowed")
  7231. } else {
  7232. value, err = m.Client().LabelRelationship.Get(ctx, id)
  7233. }
  7234. })
  7235. return value, err
  7236. }
  7237. m.id = &id
  7238. }
  7239. }
  7240. // withLabelRelationship sets the old LabelRelationship of the mutation.
  7241. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  7242. return func(m *LabelRelationshipMutation) {
  7243. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  7244. return node, nil
  7245. }
  7246. m.id = &node.ID
  7247. }
  7248. }
  7249. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7250. // executed in a transaction (ent.Tx), a transactional client is returned.
  7251. func (m LabelRelationshipMutation) Client() *Client {
  7252. client := &Client{config: m.config}
  7253. client.init()
  7254. return client
  7255. }
  7256. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7257. // it returns an error otherwise.
  7258. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  7259. if _, ok := m.driver.(*txDriver); !ok {
  7260. return nil, errors.New("ent: mutation is not running in a transaction")
  7261. }
  7262. tx := &Tx{config: m.config}
  7263. tx.init()
  7264. return tx, nil
  7265. }
  7266. // SetID sets the value of the id field. Note that this
  7267. // operation is only accepted on creation of LabelRelationship entities.
  7268. func (m *LabelRelationshipMutation) SetID(id uint64) {
  7269. m.id = &id
  7270. }
  7271. // ID returns the ID value in the mutation. Note that the ID is only available
  7272. // if it was provided to the builder or after it was returned from the database.
  7273. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  7274. if m.id == nil {
  7275. return
  7276. }
  7277. return *m.id, true
  7278. }
  7279. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7280. // That means, if the mutation is applied within a transaction with an isolation level such
  7281. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7282. // or updated by the mutation.
  7283. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  7284. switch {
  7285. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7286. id, exists := m.ID()
  7287. if exists {
  7288. return []uint64{id}, nil
  7289. }
  7290. fallthrough
  7291. case m.op.Is(OpUpdate | OpDelete):
  7292. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  7293. default:
  7294. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7295. }
  7296. }
  7297. // SetCreatedAt sets the "created_at" field.
  7298. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  7299. m.created_at = &t
  7300. }
  7301. // CreatedAt returns the value of the "created_at" field in the mutation.
  7302. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  7303. v := m.created_at
  7304. if v == nil {
  7305. return
  7306. }
  7307. return *v, true
  7308. }
  7309. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  7310. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  7311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7312. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7313. if !m.op.Is(OpUpdateOne) {
  7314. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7315. }
  7316. if m.id == nil || m.oldValue == nil {
  7317. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7318. }
  7319. oldValue, err := m.oldValue(ctx)
  7320. if err != nil {
  7321. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7322. }
  7323. return oldValue.CreatedAt, nil
  7324. }
  7325. // ResetCreatedAt resets all changes to the "created_at" field.
  7326. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  7327. m.created_at = nil
  7328. }
  7329. // SetUpdatedAt sets the "updated_at" field.
  7330. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  7331. m.updated_at = &t
  7332. }
  7333. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7334. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  7335. v := m.updated_at
  7336. if v == nil {
  7337. return
  7338. }
  7339. return *v, true
  7340. }
  7341. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  7342. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  7343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7344. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7345. if !m.op.Is(OpUpdateOne) {
  7346. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7347. }
  7348. if m.id == nil || m.oldValue == nil {
  7349. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7350. }
  7351. oldValue, err := m.oldValue(ctx)
  7352. if err != nil {
  7353. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7354. }
  7355. return oldValue.UpdatedAt, nil
  7356. }
  7357. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7358. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  7359. m.updated_at = nil
  7360. }
  7361. // SetStatus sets the "status" field.
  7362. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  7363. m.status = &u
  7364. m.addstatus = nil
  7365. }
  7366. // Status returns the value of the "status" field in the mutation.
  7367. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  7368. v := m.status
  7369. if v == nil {
  7370. return
  7371. }
  7372. return *v, true
  7373. }
  7374. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  7375. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  7376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7377. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7378. if !m.op.Is(OpUpdateOne) {
  7379. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7380. }
  7381. if m.id == nil || m.oldValue == nil {
  7382. return v, errors.New("OldStatus requires an ID field in the mutation")
  7383. }
  7384. oldValue, err := m.oldValue(ctx)
  7385. if err != nil {
  7386. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7387. }
  7388. return oldValue.Status, nil
  7389. }
  7390. // AddStatus adds u to the "status" field.
  7391. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  7392. if m.addstatus != nil {
  7393. *m.addstatus += u
  7394. } else {
  7395. m.addstatus = &u
  7396. }
  7397. }
  7398. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7399. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  7400. v := m.addstatus
  7401. if v == nil {
  7402. return
  7403. }
  7404. return *v, true
  7405. }
  7406. // ClearStatus clears the value of the "status" field.
  7407. func (m *LabelRelationshipMutation) ClearStatus() {
  7408. m.status = nil
  7409. m.addstatus = nil
  7410. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  7411. }
  7412. // StatusCleared returns if the "status" field was cleared in this mutation.
  7413. func (m *LabelRelationshipMutation) StatusCleared() bool {
  7414. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  7415. return ok
  7416. }
  7417. // ResetStatus resets all changes to the "status" field.
  7418. func (m *LabelRelationshipMutation) ResetStatus() {
  7419. m.status = nil
  7420. m.addstatus = nil
  7421. delete(m.clearedFields, labelrelationship.FieldStatus)
  7422. }
  7423. // SetDeletedAt sets the "deleted_at" field.
  7424. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  7425. m.deleted_at = &t
  7426. }
  7427. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7428. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  7429. v := m.deleted_at
  7430. if v == nil {
  7431. return
  7432. }
  7433. return *v, true
  7434. }
  7435. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  7436. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  7437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7438. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7439. if !m.op.Is(OpUpdateOne) {
  7440. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7441. }
  7442. if m.id == nil || m.oldValue == nil {
  7443. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7444. }
  7445. oldValue, err := m.oldValue(ctx)
  7446. if err != nil {
  7447. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7448. }
  7449. return oldValue.DeletedAt, nil
  7450. }
  7451. // ClearDeletedAt clears the value of the "deleted_at" field.
  7452. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  7453. m.deleted_at = nil
  7454. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  7455. }
  7456. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7457. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  7458. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  7459. return ok
  7460. }
  7461. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7462. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  7463. m.deleted_at = nil
  7464. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  7465. }
  7466. // SetLabelID sets the "label_id" field.
  7467. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  7468. m.labels = &u
  7469. }
  7470. // LabelID returns the value of the "label_id" field in the mutation.
  7471. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  7472. v := m.labels
  7473. if v == nil {
  7474. return
  7475. }
  7476. return *v, true
  7477. }
  7478. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  7479. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  7480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7481. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  7482. if !m.op.Is(OpUpdateOne) {
  7483. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  7484. }
  7485. if m.id == nil || m.oldValue == nil {
  7486. return v, errors.New("OldLabelID requires an ID field in the mutation")
  7487. }
  7488. oldValue, err := m.oldValue(ctx)
  7489. if err != nil {
  7490. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  7491. }
  7492. return oldValue.LabelID, nil
  7493. }
  7494. // ResetLabelID resets all changes to the "label_id" field.
  7495. func (m *LabelRelationshipMutation) ResetLabelID() {
  7496. m.labels = nil
  7497. }
  7498. // SetContactID sets the "contact_id" field.
  7499. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  7500. m.contacts = &u
  7501. }
  7502. // ContactID returns the value of the "contact_id" field in the mutation.
  7503. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  7504. v := m.contacts
  7505. if v == nil {
  7506. return
  7507. }
  7508. return *v, true
  7509. }
  7510. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  7511. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  7512. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7513. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  7514. if !m.op.Is(OpUpdateOne) {
  7515. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  7516. }
  7517. if m.id == nil || m.oldValue == nil {
  7518. return v, errors.New("OldContactID requires an ID field in the mutation")
  7519. }
  7520. oldValue, err := m.oldValue(ctx)
  7521. if err != nil {
  7522. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  7523. }
  7524. return oldValue.ContactID, nil
  7525. }
  7526. // ResetContactID resets all changes to the "contact_id" field.
  7527. func (m *LabelRelationshipMutation) ResetContactID() {
  7528. m.contacts = nil
  7529. }
  7530. // SetOrganizationID sets the "organization_id" field.
  7531. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  7532. m.organization_id = &u
  7533. m.addorganization_id = nil
  7534. }
  7535. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7536. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  7537. v := m.organization_id
  7538. if v == nil {
  7539. return
  7540. }
  7541. return *v, true
  7542. }
  7543. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  7544. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  7545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7546. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7547. if !m.op.Is(OpUpdateOne) {
  7548. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7549. }
  7550. if m.id == nil || m.oldValue == nil {
  7551. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7552. }
  7553. oldValue, err := m.oldValue(ctx)
  7554. if err != nil {
  7555. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7556. }
  7557. return oldValue.OrganizationID, nil
  7558. }
  7559. // AddOrganizationID adds u to the "organization_id" field.
  7560. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  7561. if m.addorganization_id != nil {
  7562. *m.addorganization_id += u
  7563. } else {
  7564. m.addorganization_id = &u
  7565. }
  7566. }
  7567. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7568. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  7569. v := m.addorganization_id
  7570. if v == nil {
  7571. return
  7572. }
  7573. return *v, true
  7574. }
  7575. // ClearOrganizationID clears the value of the "organization_id" field.
  7576. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  7577. m.organization_id = nil
  7578. m.addorganization_id = nil
  7579. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  7580. }
  7581. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  7582. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  7583. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  7584. return ok
  7585. }
  7586. // ResetOrganizationID resets all changes to the "organization_id" field.
  7587. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  7588. m.organization_id = nil
  7589. m.addorganization_id = nil
  7590. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  7591. }
  7592. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  7593. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  7594. m.contacts = &id
  7595. }
  7596. // ClearContacts clears the "contacts" edge to the Contact entity.
  7597. func (m *LabelRelationshipMutation) ClearContacts() {
  7598. m.clearedcontacts = true
  7599. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  7600. }
  7601. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  7602. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  7603. return m.clearedcontacts
  7604. }
  7605. // ContactsID returns the "contacts" edge ID in the mutation.
  7606. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  7607. if m.contacts != nil {
  7608. return *m.contacts, true
  7609. }
  7610. return
  7611. }
  7612. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  7613. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  7614. // ContactsID instead. It exists only for internal usage by the builders.
  7615. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  7616. if id := m.contacts; id != nil {
  7617. ids = append(ids, *id)
  7618. }
  7619. return
  7620. }
  7621. // ResetContacts resets all changes to the "contacts" edge.
  7622. func (m *LabelRelationshipMutation) ResetContacts() {
  7623. m.contacts = nil
  7624. m.clearedcontacts = false
  7625. }
  7626. // SetLabelsID sets the "labels" edge to the Label entity by id.
  7627. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  7628. m.labels = &id
  7629. }
  7630. // ClearLabels clears the "labels" edge to the Label entity.
  7631. func (m *LabelRelationshipMutation) ClearLabels() {
  7632. m.clearedlabels = true
  7633. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  7634. }
  7635. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  7636. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  7637. return m.clearedlabels
  7638. }
  7639. // LabelsID returns the "labels" edge ID in the mutation.
  7640. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  7641. if m.labels != nil {
  7642. return *m.labels, true
  7643. }
  7644. return
  7645. }
  7646. // LabelsIDs returns the "labels" edge IDs in the mutation.
  7647. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  7648. // LabelsID instead. It exists only for internal usage by the builders.
  7649. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  7650. if id := m.labels; id != nil {
  7651. ids = append(ids, *id)
  7652. }
  7653. return
  7654. }
  7655. // ResetLabels resets all changes to the "labels" edge.
  7656. func (m *LabelRelationshipMutation) ResetLabels() {
  7657. m.labels = nil
  7658. m.clearedlabels = false
  7659. }
  7660. // Where appends a list predicates to the LabelRelationshipMutation builder.
  7661. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  7662. m.predicates = append(m.predicates, ps...)
  7663. }
  7664. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  7665. // users can use type-assertion to append predicates that do not depend on any generated package.
  7666. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  7667. p := make([]predicate.LabelRelationship, len(ps))
  7668. for i := range ps {
  7669. p[i] = ps[i]
  7670. }
  7671. m.Where(p...)
  7672. }
  7673. // Op returns the operation name.
  7674. func (m *LabelRelationshipMutation) Op() Op {
  7675. return m.op
  7676. }
  7677. // SetOp allows setting the mutation operation.
  7678. func (m *LabelRelationshipMutation) SetOp(op Op) {
  7679. m.op = op
  7680. }
  7681. // Type returns the node type of this mutation (LabelRelationship).
  7682. func (m *LabelRelationshipMutation) Type() string {
  7683. return m.typ
  7684. }
  7685. // Fields returns all fields that were changed during this mutation. Note that in
  7686. // order to get all numeric fields that were incremented/decremented, call
  7687. // AddedFields().
  7688. func (m *LabelRelationshipMutation) Fields() []string {
  7689. fields := make([]string, 0, 7)
  7690. if m.created_at != nil {
  7691. fields = append(fields, labelrelationship.FieldCreatedAt)
  7692. }
  7693. if m.updated_at != nil {
  7694. fields = append(fields, labelrelationship.FieldUpdatedAt)
  7695. }
  7696. if m.status != nil {
  7697. fields = append(fields, labelrelationship.FieldStatus)
  7698. }
  7699. if m.deleted_at != nil {
  7700. fields = append(fields, labelrelationship.FieldDeletedAt)
  7701. }
  7702. if m.labels != nil {
  7703. fields = append(fields, labelrelationship.FieldLabelID)
  7704. }
  7705. if m.contacts != nil {
  7706. fields = append(fields, labelrelationship.FieldContactID)
  7707. }
  7708. if m.organization_id != nil {
  7709. fields = append(fields, labelrelationship.FieldOrganizationID)
  7710. }
  7711. return fields
  7712. }
  7713. // Field returns the value of a field with the given name. The second boolean
  7714. // return value indicates that this field was not set, or was not defined in the
  7715. // schema.
  7716. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  7717. switch name {
  7718. case labelrelationship.FieldCreatedAt:
  7719. return m.CreatedAt()
  7720. case labelrelationship.FieldUpdatedAt:
  7721. return m.UpdatedAt()
  7722. case labelrelationship.FieldStatus:
  7723. return m.Status()
  7724. case labelrelationship.FieldDeletedAt:
  7725. return m.DeletedAt()
  7726. case labelrelationship.FieldLabelID:
  7727. return m.LabelID()
  7728. case labelrelationship.FieldContactID:
  7729. return m.ContactID()
  7730. case labelrelationship.FieldOrganizationID:
  7731. return m.OrganizationID()
  7732. }
  7733. return nil, false
  7734. }
  7735. // OldField returns the old value of the field from the database. An error is
  7736. // returned if the mutation operation is not UpdateOne, or the query to the
  7737. // database failed.
  7738. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7739. switch name {
  7740. case labelrelationship.FieldCreatedAt:
  7741. return m.OldCreatedAt(ctx)
  7742. case labelrelationship.FieldUpdatedAt:
  7743. return m.OldUpdatedAt(ctx)
  7744. case labelrelationship.FieldStatus:
  7745. return m.OldStatus(ctx)
  7746. case labelrelationship.FieldDeletedAt:
  7747. return m.OldDeletedAt(ctx)
  7748. case labelrelationship.FieldLabelID:
  7749. return m.OldLabelID(ctx)
  7750. case labelrelationship.FieldContactID:
  7751. return m.OldContactID(ctx)
  7752. case labelrelationship.FieldOrganizationID:
  7753. return m.OldOrganizationID(ctx)
  7754. }
  7755. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  7756. }
  7757. // SetField sets the value of a field with the given name. It returns an error if
  7758. // the field is not defined in the schema, or if the type mismatched the field
  7759. // type.
  7760. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  7761. switch name {
  7762. case labelrelationship.FieldCreatedAt:
  7763. v, ok := value.(time.Time)
  7764. if !ok {
  7765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7766. }
  7767. m.SetCreatedAt(v)
  7768. return nil
  7769. case labelrelationship.FieldUpdatedAt:
  7770. v, ok := value.(time.Time)
  7771. if !ok {
  7772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7773. }
  7774. m.SetUpdatedAt(v)
  7775. return nil
  7776. case labelrelationship.FieldStatus:
  7777. v, ok := value.(uint8)
  7778. if !ok {
  7779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7780. }
  7781. m.SetStatus(v)
  7782. return nil
  7783. case labelrelationship.FieldDeletedAt:
  7784. v, ok := value.(time.Time)
  7785. if !ok {
  7786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7787. }
  7788. m.SetDeletedAt(v)
  7789. return nil
  7790. case labelrelationship.FieldLabelID:
  7791. v, ok := value.(uint64)
  7792. if !ok {
  7793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7794. }
  7795. m.SetLabelID(v)
  7796. return nil
  7797. case labelrelationship.FieldContactID:
  7798. v, ok := value.(uint64)
  7799. if !ok {
  7800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7801. }
  7802. m.SetContactID(v)
  7803. return nil
  7804. case labelrelationship.FieldOrganizationID:
  7805. v, ok := value.(uint64)
  7806. if !ok {
  7807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7808. }
  7809. m.SetOrganizationID(v)
  7810. return nil
  7811. }
  7812. return fmt.Errorf("unknown LabelRelationship field %s", name)
  7813. }
  7814. // AddedFields returns all numeric fields that were incremented/decremented during
  7815. // this mutation.
  7816. func (m *LabelRelationshipMutation) AddedFields() []string {
  7817. var fields []string
  7818. if m.addstatus != nil {
  7819. fields = append(fields, labelrelationship.FieldStatus)
  7820. }
  7821. if m.addorganization_id != nil {
  7822. fields = append(fields, labelrelationship.FieldOrganizationID)
  7823. }
  7824. return fields
  7825. }
  7826. // AddedField returns the numeric value that was incremented/decremented on a field
  7827. // with the given name. The second boolean return value indicates that this field
  7828. // was not set, or was not defined in the schema.
  7829. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  7830. switch name {
  7831. case labelrelationship.FieldStatus:
  7832. return m.AddedStatus()
  7833. case labelrelationship.FieldOrganizationID:
  7834. return m.AddedOrganizationID()
  7835. }
  7836. return nil, false
  7837. }
  7838. // AddField adds the value to the field with the given name. It returns an error if
  7839. // the field is not defined in the schema, or if the type mismatched the field
  7840. // type.
  7841. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  7842. switch name {
  7843. case labelrelationship.FieldStatus:
  7844. v, ok := value.(int8)
  7845. if !ok {
  7846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7847. }
  7848. m.AddStatus(v)
  7849. return nil
  7850. case labelrelationship.FieldOrganizationID:
  7851. v, ok := value.(int64)
  7852. if !ok {
  7853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7854. }
  7855. m.AddOrganizationID(v)
  7856. return nil
  7857. }
  7858. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  7859. }
  7860. // ClearedFields returns all nullable fields that were cleared during this
  7861. // mutation.
  7862. func (m *LabelRelationshipMutation) ClearedFields() []string {
  7863. var fields []string
  7864. if m.FieldCleared(labelrelationship.FieldStatus) {
  7865. fields = append(fields, labelrelationship.FieldStatus)
  7866. }
  7867. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  7868. fields = append(fields, labelrelationship.FieldDeletedAt)
  7869. }
  7870. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  7871. fields = append(fields, labelrelationship.FieldOrganizationID)
  7872. }
  7873. return fields
  7874. }
  7875. // FieldCleared returns a boolean indicating if a field with the given name was
  7876. // cleared in this mutation.
  7877. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  7878. _, ok := m.clearedFields[name]
  7879. return ok
  7880. }
  7881. // ClearField clears the value of the field with the given name. It returns an
  7882. // error if the field is not defined in the schema.
  7883. func (m *LabelRelationshipMutation) ClearField(name string) error {
  7884. switch name {
  7885. case labelrelationship.FieldStatus:
  7886. m.ClearStatus()
  7887. return nil
  7888. case labelrelationship.FieldDeletedAt:
  7889. m.ClearDeletedAt()
  7890. return nil
  7891. case labelrelationship.FieldOrganizationID:
  7892. m.ClearOrganizationID()
  7893. return nil
  7894. }
  7895. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  7896. }
  7897. // ResetField resets all changes in the mutation for the field with the given name.
  7898. // It returns an error if the field is not defined in the schema.
  7899. func (m *LabelRelationshipMutation) ResetField(name string) error {
  7900. switch name {
  7901. case labelrelationship.FieldCreatedAt:
  7902. m.ResetCreatedAt()
  7903. return nil
  7904. case labelrelationship.FieldUpdatedAt:
  7905. m.ResetUpdatedAt()
  7906. return nil
  7907. case labelrelationship.FieldStatus:
  7908. m.ResetStatus()
  7909. return nil
  7910. case labelrelationship.FieldDeletedAt:
  7911. m.ResetDeletedAt()
  7912. return nil
  7913. case labelrelationship.FieldLabelID:
  7914. m.ResetLabelID()
  7915. return nil
  7916. case labelrelationship.FieldContactID:
  7917. m.ResetContactID()
  7918. return nil
  7919. case labelrelationship.FieldOrganizationID:
  7920. m.ResetOrganizationID()
  7921. return nil
  7922. }
  7923. return fmt.Errorf("unknown LabelRelationship field %s", name)
  7924. }
  7925. // AddedEdges returns all edge names that were set/added in this mutation.
  7926. func (m *LabelRelationshipMutation) AddedEdges() []string {
  7927. edges := make([]string, 0, 2)
  7928. if m.contacts != nil {
  7929. edges = append(edges, labelrelationship.EdgeContacts)
  7930. }
  7931. if m.labels != nil {
  7932. edges = append(edges, labelrelationship.EdgeLabels)
  7933. }
  7934. return edges
  7935. }
  7936. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7937. // name in this mutation.
  7938. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  7939. switch name {
  7940. case labelrelationship.EdgeContacts:
  7941. if id := m.contacts; id != nil {
  7942. return []ent.Value{*id}
  7943. }
  7944. case labelrelationship.EdgeLabels:
  7945. if id := m.labels; id != nil {
  7946. return []ent.Value{*id}
  7947. }
  7948. }
  7949. return nil
  7950. }
  7951. // RemovedEdges returns all edge names that were removed in this mutation.
  7952. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  7953. edges := make([]string, 0, 2)
  7954. return edges
  7955. }
  7956. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7957. // the given name in this mutation.
  7958. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  7959. return nil
  7960. }
  7961. // ClearedEdges returns all edge names that were cleared in this mutation.
  7962. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  7963. edges := make([]string, 0, 2)
  7964. if m.clearedcontacts {
  7965. edges = append(edges, labelrelationship.EdgeContacts)
  7966. }
  7967. if m.clearedlabels {
  7968. edges = append(edges, labelrelationship.EdgeLabels)
  7969. }
  7970. return edges
  7971. }
  7972. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7973. // was cleared in this mutation.
  7974. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  7975. switch name {
  7976. case labelrelationship.EdgeContacts:
  7977. return m.clearedcontacts
  7978. case labelrelationship.EdgeLabels:
  7979. return m.clearedlabels
  7980. }
  7981. return false
  7982. }
  7983. // ClearEdge clears the value of the edge with the given name. It returns an error
  7984. // if that edge is not defined in the schema.
  7985. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  7986. switch name {
  7987. case labelrelationship.EdgeContacts:
  7988. m.ClearContacts()
  7989. return nil
  7990. case labelrelationship.EdgeLabels:
  7991. m.ClearLabels()
  7992. return nil
  7993. }
  7994. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  7995. }
  7996. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7997. // It returns an error if the edge is not defined in the schema.
  7998. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  7999. switch name {
  8000. case labelrelationship.EdgeContacts:
  8001. m.ResetContacts()
  8002. return nil
  8003. case labelrelationship.EdgeLabels:
  8004. m.ResetLabels()
  8005. return nil
  8006. }
  8007. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  8008. }
  8009. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  8010. type MessageMutation struct {
  8011. config
  8012. op Op
  8013. typ string
  8014. id *int
  8015. wx_wxid *string
  8016. wxid *string
  8017. content *string
  8018. clearedFields map[string]struct{}
  8019. done bool
  8020. oldValue func(context.Context) (*Message, error)
  8021. predicates []predicate.Message
  8022. }
  8023. var _ ent.Mutation = (*MessageMutation)(nil)
  8024. // messageOption allows management of the mutation configuration using functional options.
  8025. type messageOption func(*MessageMutation)
  8026. // newMessageMutation creates new mutation for the Message entity.
  8027. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  8028. m := &MessageMutation{
  8029. config: c,
  8030. op: op,
  8031. typ: TypeMessage,
  8032. clearedFields: make(map[string]struct{}),
  8033. }
  8034. for _, opt := range opts {
  8035. opt(m)
  8036. }
  8037. return m
  8038. }
  8039. // withMessageID sets the ID field of the mutation.
  8040. func withMessageID(id int) messageOption {
  8041. return func(m *MessageMutation) {
  8042. var (
  8043. err error
  8044. once sync.Once
  8045. value *Message
  8046. )
  8047. m.oldValue = func(ctx context.Context) (*Message, error) {
  8048. once.Do(func() {
  8049. if m.done {
  8050. err = errors.New("querying old values post mutation is not allowed")
  8051. } else {
  8052. value, err = m.Client().Message.Get(ctx, id)
  8053. }
  8054. })
  8055. return value, err
  8056. }
  8057. m.id = &id
  8058. }
  8059. }
  8060. // withMessage sets the old Message of the mutation.
  8061. func withMessage(node *Message) messageOption {
  8062. return func(m *MessageMutation) {
  8063. m.oldValue = func(context.Context) (*Message, error) {
  8064. return node, nil
  8065. }
  8066. m.id = &node.ID
  8067. }
  8068. }
  8069. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8070. // executed in a transaction (ent.Tx), a transactional client is returned.
  8071. func (m MessageMutation) Client() *Client {
  8072. client := &Client{config: m.config}
  8073. client.init()
  8074. return client
  8075. }
  8076. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8077. // it returns an error otherwise.
  8078. func (m MessageMutation) Tx() (*Tx, error) {
  8079. if _, ok := m.driver.(*txDriver); !ok {
  8080. return nil, errors.New("ent: mutation is not running in a transaction")
  8081. }
  8082. tx := &Tx{config: m.config}
  8083. tx.init()
  8084. return tx, nil
  8085. }
  8086. // ID returns the ID value in the mutation. Note that the ID is only available
  8087. // if it was provided to the builder or after it was returned from the database.
  8088. func (m *MessageMutation) ID() (id int, exists bool) {
  8089. if m.id == nil {
  8090. return
  8091. }
  8092. return *m.id, true
  8093. }
  8094. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8095. // That means, if the mutation is applied within a transaction with an isolation level such
  8096. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8097. // or updated by the mutation.
  8098. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  8099. switch {
  8100. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8101. id, exists := m.ID()
  8102. if exists {
  8103. return []int{id}, nil
  8104. }
  8105. fallthrough
  8106. case m.op.Is(OpUpdate | OpDelete):
  8107. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  8108. default:
  8109. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8110. }
  8111. }
  8112. // SetWxWxid sets the "wx_wxid" field.
  8113. func (m *MessageMutation) SetWxWxid(s string) {
  8114. m.wx_wxid = &s
  8115. }
  8116. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  8117. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  8118. v := m.wx_wxid
  8119. if v == nil {
  8120. return
  8121. }
  8122. return *v, true
  8123. }
  8124. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  8125. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  8126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8127. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  8128. if !m.op.Is(OpUpdateOne) {
  8129. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  8130. }
  8131. if m.id == nil || m.oldValue == nil {
  8132. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  8133. }
  8134. oldValue, err := m.oldValue(ctx)
  8135. if err != nil {
  8136. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  8137. }
  8138. return oldValue.WxWxid, nil
  8139. }
  8140. // ClearWxWxid clears the value of the "wx_wxid" field.
  8141. func (m *MessageMutation) ClearWxWxid() {
  8142. m.wx_wxid = nil
  8143. m.clearedFields[message.FieldWxWxid] = struct{}{}
  8144. }
  8145. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  8146. func (m *MessageMutation) WxWxidCleared() bool {
  8147. _, ok := m.clearedFields[message.FieldWxWxid]
  8148. return ok
  8149. }
  8150. // ResetWxWxid resets all changes to the "wx_wxid" field.
  8151. func (m *MessageMutation) ResetWxWxid() {
  8152. m.wx_wxid = nil
  8153. delete(m.clearedFields, message.FieldWxWxid)
  8154. }
  8155. // SetWxid sets the "wxid" field.
  8156. func (m *MessageMutation) SetWxid(s string) {
  8157. m.wxid = &s
  8158. }
  8159. // Wxid returns the value of the "wxid" field in the mutation.
  8160. func (m *MessageMutation) Wxid() (r string, exists bool) {
  8161. v := m.wxid
  8162. if v == nil {
  8163. return
  8164. }
  8165. return *v, true
  8166. }
  8167. // OldWxid returns the old "wxid" field's value of the Message entity.
  8168. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  8169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8170. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  8171. if !m.op.Is(OpUpdateOne) {
  8172. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  8173. }
  8174. if m.id == nil || m.oldValue == nil {
  8175. return v, errors.New("OldWxid requires an ID field in the mutation")
  8176. }
  8177. oldValue, err := m.oldValue(ctx)
  8178. if err != nil {
  8179. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  8180. }
  8181. return oldValue.Wxid, nil
  8182. }
  8183. // ResetWxid resets all changes to the "wxid" field.
  8184. func (m *MessageMutation) ResetWxid() {
  8185. m.wxid = nil
  8186. }
  8187. // SetContent sets the "content" field.
  8188. func (m *MessageMutation) SetContent(s string) {
  8189. m.content = &s
  8190. }
  8191. // Content returns the value of the "content" field in the mutation.
  8192. func (m *MessageMutation) Content() (r string, exists bool) {
  8193. v := m.content
  8194. if v == nil {
  8195. return
  8196. }
  8197. return *v, true
  8198. }
  8199. // OldContent returns the old "content" field's value of the Message entity.
  8200. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  8201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8202. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  8203. if !m.op.Is(OpUpdateOne) {
  8204. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  8205. }
  8206. if m.id == nil || m.oldValue == nil {
  8207. return v, errors.New("OldContent requires an ID field in the mutation")
  8208. }
  8209. oldValue, err := m.oldValue(ctx)
  8210. if err != nil {
  8211. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  8212. }
  8213. return oldValue.Content, nil
  8214. }
  8215. // ResetContent resets all changes to the "content" field.
  8216. func (m *MessageMutation) ResetContent() {
  8217. m.content = nil
  8218. }
  8219. // Where appends a list predicates to the MessageMutation builder.
  8220. func (m *MessageMutation) Where(ps ...predicate.Message) {
  8221. m.predicates = append(m.predicates, ps...)
  8222. }
  8223. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  8224. // users can use type-assertion to append predicates that do not depend on any generated package.
  8225. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  8226. p := make([]predicate.Message, len(ps))
  8227. for i := range ps {
  8228. p[i] = ps[i]
  8229. }
  8230. m.Where(p...)
  8231. }
  8232. // Op returns the operation name.
  8233. func (m *MessageMutation) Op() Op {
  8234. return m.op
  8235. }
  8236. // SetOp allows setting the mutation operation.
  8237. func (m *MessageMutation) SetOp(op Op) {
  8238. m.op = op
  8239. }
  8240. // Type returns the node type of this mutation (Message).
  8241. func (m *MessageMutation) Type() string {
  8242. return m.typ
  8243. }
  8244. // Fields returns all fields that were changed during this mutation. Note that in
  8245. // order to get all numeric fields that were incremented/decremented, call
  8246. // AddedFields().
  8247. func (m *MessageMutation) Fields() []string {
  8248. fields := make([]string, 0, 3)
  8249. if m.wx_wxid != nil {
  8250. fields = append(fields, message.FieldWxWxid)
  8251. }
  8252. if m.wxid != nil {
  8253. fields = append(fields, message.FieldWxid)
  8254. }
  8255. if m.content != nil {
  8256. fields = append(fields, message.FieldContent)
  8257. }
  8258. return fields
  8259. }
  8260. // Field returns the value of a field with the given name. The second boolean
  8261. // return value indicates that this field was not set, or was not defined in the
  8262. // schema.
  8263. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  8264. switch name {
  8265. case message.FieldWxWxid:
  8266. return m.WxWxid()
  8267. case message.FieldWxid:
  8268. return m.Wxid()
  8269. case message.FieldContent:
  8270. return m.Content()
  8271. }
  8272. return nil, false
  8273. }
  8274. // OldField returns the old value of the field from the database. An error is
  8275. // returned if the mutation operation is not UpdateOne, or the query to the
  8276. // database failed.
  8277. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8278. switch name {
  8279. case message.FieldWxWxid:
  8280. return m.OldWxWxid(ctx)
  8281. case message.FieldWxid:
  8282. return m.OldWxid(ctx)
  8283. case message.FieldContent:
  8284. return m.OldContent(ctx)
  8285. }
  8286. return nil, fmt.Errorf("unknown Message field %s", name)
  8287. }
  8288. // SetField sets the value of a field with the given name. It returns an error if
  8289. // the field is not defined in the schema, or if the type mismatched the field
  8290. // type.
  8291. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  8292. switch name {
  8293. case message.FieldWxWxid:
  8294. v, ok := value.(string)
  8295. if !ok {
  8296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8297. }
  8298. m.SetWxWxid(v)
  8299. return nil
  8300. case message.FieldWxid:
  8301. v, ok := value.(string)
  8302. if !ok {
  8303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8304. }
  8305. m.SetWxid(v)
  8306. return nil
  8307. case message.FieldContent:
  8308. v, ok := value.(string)
  8309. if !ok {
  8310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8311. }
  8312. m.SetContent(v)
  8313. return nil
  8314. }
  8315. return fmt.Errorf("unknown Message field %s", name)
  8316. }
  8317. // AddedFields returns all numeric fields that were incremented/decremented during
  8318. // this mutation.
  8319. func (m *MessageMutation) AddedFields() []string {
  8320. return nil
  8321. }
  8322. // AddedField returns the numeric value that was incremented/decremented on a field
  8323. // with the given name. The second boolean return value indicates that this field
  8324. // was not set, or was not defined in the schema.
  8325. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  8326. return nil, false
  8327. }
  8328. // AddField adds the value to the field with the given name. It returns an error if
  8329. // the field is not defined in the schema, or if the type mismatched the field
  8330. // type.
  8331. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  8332. switch name {
  8333. }
  8334. return fmt.Errorf("unknown Message numeric field %s", name)
  8335. }
  8336. // ClearedFields returns all nullable fields that were cleared during this
  8337. // mutation.
  8338. func (m *MessageMutation) ClearedFields() []string {
  8339. var fields []string
  8340. if m.FieldCleared(message.FieldWxWxid) {
  8341. fields = append(fields, message.FieldWxWxid)
  8342. }
  8343. return fields
  8344. }
  8345. // FieldCleared returns a boolean indicating if a field with the given name was
  8346. // cleared in this mutation.
  8347. func (m *MessageMutation) FieldCleared(name string) bool {
  8348. _, ok := m.clearedFields[name]
  8349. return ok
  8350. }
  8351. // ClearField clears the value of the field with the given name. It returns an
  8352. // error if the field is not defined in the schema.
  8353. func (m *MessageMutation) ClearField(name string) error {
  8354. switch name {
  8355. case message.FieldWxWxid:
  8356. m.ClearWxWxid()
  8357. return nil
  8358. }
  8359. return fmt.Errorf("unknown Message nullable field %s", name)
  8360. }
  8361. // ResetField resets all changes in the mutation for the field with the given name.
  8362. // It returns an error if the field is not defined in the schema.
  8363. func (m *MessageMutation) ResetField(name string) error {
  8364. switch name {
  8365. case message.FieldWxWxid:
  8366. m.ResetWxWxid()
  8367. return nil
  8368. case message.FieldWxid:
  8369. m.ResetWxid()
  8370. return nil
  8371. case message.FieldContent:
  8372. m.ResetContent()
  8373. return nil
  8374. }
  8375. return fmt.Errorf("unknown Message field %s", name)
  8376. }
  8377. // AddedEdges returns all edge names that were set/added in this mutation.
  8378. func (m *MessageMutation) AddedEdges() []string {
  8379. edges := make([]string, 0, 0)
  8380. return edges
  8381. }
  8382. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8383. // name in this mutation.
  8384. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  8385. return nil
  8386. }
  8387. // RemovedEdges returns all edge names that were removed in this mutation.
  8388. func (m *MessageMutation) RemovedEdges() []string {
  8389. edges := make([]string, 0, 0)
  8390. return edges
  8391. }
  8392. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8393. // the given name in this mutation.
  8394. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  8395. return nil
  8396. }
  8397. // ClearedEdges returns all edge names that were cleared in this mutation.
  8398. func (m *MessageMutation) ClearedEdges() []string {
  8399. edges := make([]string, 0, 0)
  8400. return edges
  8401. }
  8402. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8403. // was cleared in this mutation.
  8404. func (m *MessageMutation) EdgeCleared(name string) bool {
  8405. return false
  8406. }
  8407. // ClearEdge clears the value of the edge with the given name. It returns an error
  8408. // if that edge is not defined in the schema.
  8409. func (m *MessageMutation) ClearEdge(name string) error {
  8410. return fmt.Errorf("unknown Message unique edge %s", name)
  8411. }
  8412. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8413. // It returns an error if the edge is not defined in the schema.
  8414. func (m *MessageMutation) ResetEdge(name string) error {
  8415. return fmt.Errorf("unknown Message edge %s", name)
  8416. }
  8417. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  8418. type MessageRecordsMutation struct {
  8419. config
  8420. op Op
  8421. typ string
  8422. id *uint64
  8423. created_at *time.Time
  8424. updated_at *time.Time
  8425. status *uint8
  8426. addstatus *int8
  8427. deleted_at *time.Time
  8428. bot_wxid *string
  8429. contact_type *int
  8430. addcontact_type *int
  8431. contact_wxid *string
  8432. content_type *int
  8433. addcontent_type *int
  8434. content *string
  8435. meta *custom_types.Meta
  8436. error_detail *string
  8437. send_time *time.Time
  8438. source_type *int
  8439. addsource_type *int
  8440. organization_id *uint64
  8441. addorganization_id *int64
  8442. clearedFields map[string]struct{}
  8443. sop_stage *uint64
  8444. clearedsop_stage bool
  8445. sop_node *uint64
  8446. clearedsop_node bool
  8447. message_contact *uint64
  8448. clearedmessage_contact bool
  8449. done bool
  8450. oldValue func(context.Context) (*MessageRecords, error)
  8451. predicates []predicate.MessageRecords
  8452. }
  8453. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  8454. // messagerecordsOption allows management of the mutation configuration using functional options.
  8455. type messagerecordsOption func(*MessageRecordsMutation)
  8456. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  8457. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  8458. m := &MessageRecordsMutation{
  8459. config: c,
  8460. op: op,
  8461. typ: TypeMessageRecords,
  8462. clearedFields: make(map[string]struct{}),
  8463. }
  8464. for _, opt := range opts {
  8465. opt(m)
  8466. }
  8467. return m
  8468. }
  8469. // withMessageRecordsID sets the ID field of the mutation.
  8470. func withMessageRecordsID(id uint64) messagerecordsOption {
  8471. return func(m *MessageRecordsMutation) {
  8472. var (
  8473. err error
  8474. once sync.Once
  8475. value *MessageRecords
  8476. )
  8477. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  8478. once.Do(func() {
  8479. if m.done {
  8480. err = errors.New("querying old values post mutation is not allowed")
  8481. } else {
  8482. value, err = m.Client().MessageRecords.Get(ctx, id)
  8483. }
  8484. })
  8485. return value, err
  8486. }
  8487. m.id = &id
  8488. }
  8489. }
  8490. // withMessageRecords sets the old MessageRecords of the mutation.
  8491. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  8492. return func(m *MessageRecordsMutation) {
  8493. m.oldValue = func(context.Context) (*MessageRecords, error) {
  8494. return node, nil
  8495. }
  8496. m.id = &node.ID
  8497. }
  8498. }
  8499. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8500. // executed in a transaction (ent.Tx), a transactional client is returned.
  8501. func (m MessageRecordsMutation) Client() *Client {
  8502. client := &Client{config: m.config}
  8503. client.init()
  8504. return client
  8505. }
  8506. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8507. // it returns an error otherwise.
  8508. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  8509. if _, ok := m.driver.(*txDriver); !ok {
  8510. return nil, errors.New("ent: mutation is not running in a transaction")
  8511. }
  8512. tx := &Tx{config: m.config}
  8513. tx.init()
  8514. return tx, nil
  8515. }
  8516. // SetID sets the value of the id field. Note that this
  8517. // operation is only accepted on creation of MessageRecords entities.
  8518. func (m *MessageRecordsMutation) SetID(id uint64) {
  8519. m.id = &id
  8520. }
  8521. // ID returns the ID value in the mutation. Note that the ID is only available
  8522. // if it was provided to the builder or after it was returned from the database.
  8523. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  8524. if m.id == nil {
  8525. return
  8526. }
  8527. return *m.id, true
  8528. }
  8529. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8530. // That means, if the mutation is applied within a transaction with an isolation level such
  8531. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8532. // or updated by the mutation.
  8533. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  8534. switch {
  8535. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8536. id, exists := m.ID()
  8537. if exists {
  8538. return []uint64{id}, nil
  8539. }
  8540. fallthrough
  8541. case m.op.Is(OpUpdate | OpDelete):
  8542. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  8543. default:
  8544. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8545. }
  8546. }
  8547. // SetCreatedAt sets the "created_at" field.
  8548. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  8549. m.created_at = &t
  8550. }
  8551. // CreatedAt returns the value of the "created_at" field in the mutation.
  8552. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  8553. v := m.created_at
  8554. if v == nil {
  8555. return
  8556. }
  8557. return *v, true
  8558. }
  8559. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  8560. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8562. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8563. if !m.op.Is(OpUpdateOne) {
  8564. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8565. }
  8566. if m.id == nil || m.oldValue == nil {
  8567. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8568. }
  8569. oldValue, err := m.oldValue(ctx)
  8570. if err != nil {
  8571. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8572. }
  8573. return oldValue.CreatedAt, nil
  8574. }
  8575. // ResetCreatedAt resets all changes to the "created_at" field.
  8576. func (m *MessageRecordsMutation) ResetCreatedAt() {
  8577. m.created_at = nil
  8578. }
  8579. // SetUpdatedAt sets the "updated_at" field.
  8580. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  8581. m.updated_at = &t
  8582. }
  8583. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8584. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  8585. v := m.updated_at
  8586. if v == nil {
  8587. return
  8588. }
  8589. return *v, true
  8590. }
  8591. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  8592. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8593. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8594. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8595. if !m.op.Is(OpUpdateOne) {
  8596. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8597. }
  8598. if m.id == nil || m.oldValue == nil {
  8599. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8600. }
  8601. oldValue, err := m.oldValue(ctx)
  8602. if err != nil {
  8603. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8604. }
  8605. return oldValue.UpdatedAt, nil
  8606. }
  8607. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8608. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  8609. m.updated_at = nil
  8610. }
  8611. // SetStatus sets the "status" field.
  8612. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  8613. m.status = &u
  8614. m.addstatus = nil
  8615. }
  8616. // Status returns the value of the "status" field in the mutation.
  8617. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  8618. v := m.status
  8619. if v == nil {
  8620. return
  8621. }
  8622. return *v, true
  8623. }
  8624. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  8625. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8627. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  8628. if !m.op.Is(OpUpdateOne) {
  8629. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  8630. }
  8631. if m.id == nil || m.oldValue == nil {
  8632. return v, errors.New("OldStatus requires an ID field in the mutation")
  8633. }
  8634. oldValue, err := m.oldValue(ctx)
  8635. if err != nil {
  8636. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  8637. }
  8638. return oldValue.Status, nil
  8639. }
  8640. // AddStatus adds u to the "status" field.
  8641. func (m *MessageRecordsMutation) AddStatus(u int8) {
  8642. if m.addstatus != nil {
  8643. *m.addstatus += u
  8644. } else {
  8645. m.addstatus = &u
  8646. }
  8647. }
  8648. // AddedStatus returns the value that was added to the "status" field in this mutation.
  8649. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  8650. v := m.addstatus
  8651. if v == nil {
  8652. return
  8653. }
  8654. return *v, true
  8655. }
  8656. // ClearStatus clears the value of the "status" field.
  8657. func (m *MessageRecordsMutation) ClearStatus() {
  8658. m.status = nil
  8659. m.addstatus = nil
  8660. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  8661. }
  8662. // StatusCleared returns if the "status" field was cleared in this mutation.
  8663. func (m *MessageRecordsMutation) StatusCleared() bool {
  8664. _, ok := m.clearedFields[messagerecords.FieldStatus]
  8665. return ok
  8666. }
  8667. // ResetStatus resets all changes to the "status" field.
  8668. func (m *MessageRecordsMutation) ResetStatus() {
  8669. m.status = nil
  8670. m.addstatus = nil
  8671. delete(m.clearedFields, messagerecords.FieldStatus)
  8672. }
  8673. // SetDeletedAt sets the "deleted_at" field.
  8674. func (m *MessageRecordsMutation) SetDeletedAt(t time.Time) {
  8675. m.deleted_at = &t
  8676. }
  8677. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8678. func (m *MessageRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  8679. v := m.deleted_at
  8680. if v == nil {
  8681. return
  8682. }
  8683. return *v, true
  8684. }
  8685. // OldDeletedAt returns the old "deleted_at" field's value of the MessageRecords entity.
  8686. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8687. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8688. func (m *MessageRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8689. if !m.op.Is(OpUpdateOne) {
  8690. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8691. }
  8692. if m.id == nil || m.oldValue == nil {
  8693. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8694. }
  8695. oldValue, err := m.oldValue(ctx)
  8696. if err != nil {
  8697. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8698. }
  8699. return oldValue.DeletedAt, nil
  8700. }
  8701. // ClearDeletedAt clears the value of the "deleted_at" field.
  8702. func (m *MessageRecordsMutation) ClearDeletedAt() {
  8703. m.deleted_at = nil
  8704. m.clearedFields[messagerecords.FieldDeletedAt] = struct{}{}
  8705. }
  8706. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8707. func (m *MessageRecordsMutation) DeletedAtCleared() bool {
  8708. _, ok := m.clearedFields[messagerecords.FieldDeletedAt]
  8709. return ok
  8710. }
  8711. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8712. func (m *MessageRecordsMutation) ResetDeletedAt() {
  8713. m.deleted_at = nil
  8714. delete(m.clearedFields, messagerecords.FieldDeletedAt)
  8715. }
  8716. // SetBotWxid sets the "bot_wxid" field.
  8717. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  8718. m.bot_wxid = &s
  8719. }
  8720. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  8721. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  8722. v := m.bot_wxid
  8723. if v == nil {
  8724. return
  8725. }
  8726. return *v, true
  8727. }
  8728. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  8729. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8731. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  8732. if !m.op.Is(OpUpdateOne) {
  8733. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  8734. }
  8735. if m.id == nil || m.oldValue == nil {
  8736. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  8737. }
  8738. oldValue, err := m.oldValue(ctx)
  8739. if err != nil {
  8740. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  8741. }
  8742. return oldValue.BotWxid, nil
  8743. }
  8744. // ResetBotWxid resets all changes to the "bot_wxid" field.
  8745. func (m *MessageRecordsMutation) ResetBotWxid() {
  8746. m.bot_wxid = nil
  8747. }
  8748. // SetContactID sets the "contact_id" field.
  8749. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  8750. m.message_contact = &u
  8751. }
  8752. // ContactID returns the value of the "contact_id" field in the mutation.
  8753. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  8754. v := m.message_contact
  8755. if v == nil {
  8756. return
  8757. }
  8758. return *v, true
  8759. }
  8760. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  8761. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8763. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  8764. if !m.op.Is(OpUpdateOne) {
  8765. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  8766. }
  8767. if m.id == nil || m.oldValue == nil {
  8768. return v, errors.New("OldContactID requires an ID field in the mutation")
  8769. }
  8770. oldValue, err := m.oldValue(ctx)
  8771. if err != nil {
  8772. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  8773. }
  8774. return oldValue.ContactID, nil
  8775. }
  8776. // ClearContactID clears the value of the "contact_id" field.
  8777. func (m *MessageRecordsMutation) ClearContactID() {
  8778. m.message_contact = nil
  8779. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  8780. }
  8781. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  8782. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  8783. _, ok := m.clearedFields[messagerecords.FieldContactID]
  8784. return ok
  8785. }
  8786. // ResetContactID resets all changes to the "contact_id" field.
  8787. func (m *MessageRecordsMutation) ResetContactID() {
  8788. m.message_contact = nil
  8789. delete(m.clearedFields, messagerecords.FieldContactID)
  8790. }
  8791. // SetContactType sets the "contact_type" field.
  8792. func (m *MessageRecordsMutation) SetContactType(i int) {
  8793. m.contact_type = &i
  8794. m.addcontact_type = nil
  8795. }
  8796. // ContactType returns the value of the "contact_type" field in the mutation.
  8797. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  8798. v := m.contact_type
  8799. if v == nil {
  8800. return
  8801. }
  8802. return *v, true
  8803. }
  8804. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  8805. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8807. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  8808. if !m.op.Is(OpUpdateOne) {
  8809. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  8810. }
  8811. if m.id == nil || m.oldValue == nil {
  8812. return v, errors.New("OldContactType requires an ID field in the mutation")
  8813. }
  8814. oldValue, err := m.oldValue(ctx)
  8815. if err != nil {
  8816. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  8817. }
  8818. return oldValue.ContactType, nil
  8819. }
  8820. // AddContactType adds i to the "contact_type" field.
  8821. func (m *MessageRecordsMutation) AddContactType(i int) {
  8822. if m.addcontact_type != nil {
  8823. *m.addcontact_type += i
  8824. } else {
  8825. m.addcontact_type = &i
  8826. }
  8827. }
  8828. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  8829. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  8830. v := m.addcontact_type
  8831. if v == nil {
  8832. return
  8833. }
  8834. return *v, true
  8835. }
  8836. // ResetContactType resets all changes to the "contact_type" field.
  8837. func (m *MessageRecordsMutation) ResetContactType() {
  8838. m.contact_type = nil
  8839. m.addcontact_type = nil
  8840. }
  8841. // SetContactWxid sets the "contact_wxid" field.
  8842. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  8843. m.contact_wxid = &s
  8844. }
  8845. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  8846. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  8847. v := m.contact_wxid
  8848. if v == nil {
  8849. return
  8850. }
  8851. return *v, true
  8852. }
  8853. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  8854. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8856. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  8857. if !m.op.Is(OpUpdateOne) {
  8858. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  8859. }
  8860. if m.id == nil || m.oldValue == nil {
  8861. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  8862. }
  8863. oldValue, err := m.oldValue(ctx)
  8864. if err != nil {
  8865. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  8866. }
  8867. return oldValue.ContactWxid, nil
  8868. }
  8869. // ResetContactWxid resets all changes to the "contact_wxid" field.
  8870. func (m *MessageRecordsMutation) ResetContactWxid() {
  8871. m.contact_wxid = nil
  8872. }
  8873. // SetContentType sets the "content_type" field.
  8874. func (m *MessageRecordsMutation) SetContentType(i int) {
  8875. m.content_type = &i
  8876. m.addcontent_type = nil
  8877. }
  8878. // ContentType returns the value of the "content_type" field in the mutation.
  8879. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  8880. v := m.content_type
  8881. if v == nil {
  8882. return
  8883. }
  8884. return *v, true
  8885. }
  8886. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  8887. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8889. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  8890. if !m.op.Is(OpUpdateOne) {
  8891. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  8892. }
  8893. if m.id == nil || m.oldValue == nil {
  8894. return v, errors.New("OldContentType requires an ID field in the mutation")
  8895. }
  8896. oldValue, err := m.oldValue(ctx)
  8897. if err != nil {
  8898. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  8899. }
  8900. return oldValue.ContentType, nil
  8901. }
  8902. // AddContentType adds i to the "content_type" field.
  8903. func (m *MessageRecordsMutation) AddContentType(i int) {
  8904. if m.addcontent_type != nil {
  8905. *m.addcontent_type += i
  8906. } else {
  8907. m.addcontent_type = &i
  8908. }
  8909. }
  8910. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  8911. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  8912. v := m.addcontent_type
  8913. if v == nil {
  8914. return
  8915. }
  8916. return *v, true
  8917. }
  8918. // ResetContentType resets all changes to the "content_type" field.
  8919. func (m *MessageRecordsMutation) ResetContentType() {
  8920. m.content_type = nil
  8921. m.addcontent_type = nil
  8922. }
  8923. // SetContent sets the "content" field.
  8924. func (m *MessageRecordsMutation) SetContent(s string) {
  8925. m.content = &s
  8926. }
  8927. // Content returns the value of the "content" field in the mutation.
  8928. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  8929. v := m.content
  8930. if v == nil {
  8931. return
  8932. }
  8933. return *v, true
  8934. }
  8935. // OldContent returns the old "content" field's value of the MessageRecords entity.
  8936. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8938. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  8939. if !m.op.Is(OpUpdateOne) {
  8940. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  8941. }
  8942. if m.id == nil || m.oldValue == nil {
  8943. return v, errors.New("OldContent requires an ID field in the mutation")
  8944. }
  8945. oldValue, err := m.oldValue(ctx)
  8946. if err != nil {
  8947. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  8948. }
  8949. return oldValue.Content, nil
  8950. }
  8951. // ResetContent resets all changes to the "content" field.
  8952. func (m *MessageRecordsMutation) ResetContent() {
  8953. m.content = nil
  8954. }
  8955. // SetMeta sets the "meta" field.
  8956. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  8957. m.meta = &ct
  8958. }
  8959. // Meta returns the value of the "meta" field in the mutation.
  8960. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  8961. v := m.meta
  8962. if v == nil {
  8963. return
  8964. }
  8965. return *v, true
  8966. }
  8967. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  8968. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8970. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  8971. if !m.op.Is(OpUpdateOne) {
  8972. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  8973. }
  8974. if m.id == nil || m.oldValue == nil {
  8975. return v, errors.New("OldMeta requires an ID field in the mutation")
  8976. }
  8977. oldValue, err := m.oldValue(ctx)
  8978. if err != nil {
  8979. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  8980. }
  8981. return oldValue.Meta, nil
  8982. }
  8983. // ClearMeta clears the value of the "meta" field.
  8984. func (m *MessageRecordsMutation) ClearMeta() {
  8985. m.meta = nil
  8986. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  8987. }
  8988. // MetaCleared returns if the "meta" field was cleared in this mutation.
  8989. func (m *MessageRecordsMutation) MetaCleared() bool {
  8990. _, ok := m.clearedFields[messagerecords.FieldMeta]
  8991. return ok
  8992. }
  8993. // ResetMeta resets all changes to the "meta" field.
  8994. func (m *MessageRecordsMutation) ResetMeta() {
  8995. m.meta = nil
  8996. delete(m.clearedFields, messagerecords.FieldMeta)
  8997. }
  8998. // SetErrorDetail sets the "error_detail" field.
  8999. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  9000. m.error_detail = &s
  9001. }
  9002. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  9003. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  9004. v := m.error_detail
  9005. if v == nil {
  9006. return
  9007. }
  9008. return *v, true
  9009. }
  9010. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  9011. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9013. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  9014. if !m.op.Is(OpUpdateOne) {
  9015. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  9016. }
  9017. if m.id == nil || m.oldValue == nil {
  9018. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  9019. }
  9020. oldValue, err := m.oldValue(ctx)
  9021. if err != nil {
  9022. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  9023. }
  9024. return oldValue.ErrorDetail, nil
  9025. }
  9026. // ResetErrorDetail resets all changes to the "error_detail" field.
  9027. func (m *MessageRecordsMutation) ResetErrorDetail() {
  9028. m.error_detail = nil
  9029. }
  9030. // SetSendTime sets the "send_time" field.
  9031. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  9032. m.send_time = &t
  9033. }
  9034. // SendTime returns the value of the "send_time" field in the mutation.
  9035. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  9036. v := m.send_time
  9037. if v == nil {
  9038. return
  9039. }
  9040. return *v, true
  9041. }
  9042. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  9043. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9045. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  9046. if !m.op.Is(OpUpdateOne) {
  9047. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  9048. }
  9049. if m.id == nil || m.oldValue == nil {
  9050. return v, errors.New("OldSendTime requires an ID field in the mutation")
  9051. }
  9052. oldValue, err := m.oldValue(ctx)
  9053. if err != nil {
  9054. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  9055. }
  9056. return oldValue.SendTime, nil
  9057. }
  9058. // ClearSendTime clears the value of the "send_time" field.
  9059. func (m *MessageRecordsMutation) ClearSendTime() {
  9060. m.send_time = nil
  9061. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  9062. }
  9063. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  9064. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  9065. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  9066. return ok
  9067. }
  9068. // ResetSendTime resets all changes to the "send_time" field.
  9069. func (m *MessageRecordsMutation) ResetSendTime() {
  9070. m.send_time = nil
  9071. delete(m.clearedFields, messagerecords.FieldSendTime)
  9072. }
  9073. // SetSourceType sets the "source_type" field.
  9074. func (m *MessageRecordsMutation) SetSourceType(i int) {
  9075. m.source_type = &i
  9076. m.addsource_type = nil
  9077. }
  9078. // SourceType returns the value of the "source_type" field in the mutation.
  9079. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  9080. v := m.source_type
  9081. if v == nil {
  9082. return
  9083. }
  9084. return *v, true
  9085. }
  9086. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  9087. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9089. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  9090. if !m.op.Is(OpUpdateOne) {
  9091. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  9092. }
  9093. if m.id == nil || m.oldValue == nil {
  9094. return v, errors.New("OldSourceType requires an ID field in the mutation")
  9095. }
  9096. oldValue, err := m.oldValue(ctx)
  9097. if err != nil {
  9098. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  9099. }
  9100. return oldValue.SourceType, nil
  9101. }
  9102. // AddSourceType adds i to the "source_type" field.
  9103. func (m *MessageRecordsMutation) AddSourceType(i int) {
  9104. if m.addsource_type != nil {
  9105. *m.addsource_type += i
  9106. } else {
  9107. m.addsource_type = &i
  9108. }
  9109. }
  9110. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  9111. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  9112. v := m.addsource_type
  9113. if v == nil {
  9114. return
  9115. }
  9116. return *v, true
  9117. }
  9118. // ResetSourceType resets all changes to the "source_type" field.
  9119. func (m *MessageRecordsMutation) ResetSourceType() {
  9120. m.source_type = nil
  9121. m.addsource_type = nil
  9122. }
  9123. // SetSourceID sets the "source_id" field.
  9124. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  9125. m.sop_stage = &u
  9126. }
  9127. // SourceID returns the value of the "source_id" field in the mutation.
  9128. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  9129. v := m.sop_stage
  9130. if v == nil {
  9131. return
  9132. }
  9133. return *v, true
  9134. }
  9135. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  9136. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9138. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  9139. if !m.op.Is(OpUpdateOne) {
  9140. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  9141. }
  9142. if m.id == nil || m.oldValue == nil {
  9143. return v, errors.New("OldSourceID requires an ID field in the mutation")
  9144. }
  9145. oldValue, err := m.oldValue(ctx)
  9146. if err != nil {
  9147. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  9148. }
  9149. return oldValue.SourceID, nil
  9150. }
  9151. // ClearSourceID clears the value of the "source_id" field.
  9152. func (m *MessageRecordsMutation) ClearSourceID() {
  9153. m.sop_stage = nil
  9154. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  9155. }
  9156. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  9157. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  9158. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  9159. return ok
  9160. }
  9161. // ResetSourceID resets all changes to the "source_id" field.
  9162. func (m *MessageRecordsMutation) ResetSourceID() {
  9163. m.sop_stage = nil
  9164. delete(m.clearedFields, messagerecords.FieldSourceID)
  9165. }
  9166. // SetSubSourceID sets the "sub_source_id" field.
  9167. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  9168. m.sop_node = &u
  9169. }
  9170. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  9171. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  9172. v := m.sop_node
  9173. if v == nil {
  9174. return
  9175. }
  9176. return *v, true
  9177. }
  9178. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  9179. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9181. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  9182. if !m.op.Is(OpUpdateOne) {
  9183. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  9184. }
  9185. if m.id == nil || m.oldValue == nil {
  9186. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  9187. }
  9188. oldValue, err := m.oldValue(ctx)
  9189. if err != nil {
  9190. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  9191. }
  9192. return oldValue.SubSourceID, nil
  9193. }
  9194. // ClearSubSourceID clears the value of the "sub_source_id" field.
  9195. func (m *MessageRecordsMutation) ClearSubSourceID() {
  9196. m.sop_node = nil
  9197. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  9198. }
  9199. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  9200. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  9201. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  9202. return ok
  9203. }
  9204. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  9205. func (m *MessageRecordsMutation) ResetSubSourceID() {
  9206. m.sop_node = nil
  9207. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  9208. }
  9209. // SetOrganizationID sets the "organization_id" field.
  9210. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  9211. m.organization_id = &u
  9212. m.addorganization_id = nil
  9213. }
  9214. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9215. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  9216. v := m.organization_id
  9217. if v == nil {
  9218. return
  9219. }
  9220. return *v, true
  9221. }
  9222. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  9223. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9225. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9226. if !m.op.Is(OpUpdateOne) {
  9227. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9228. }
  9229. if m.id == nil || m.oldValue == nil {
  9230. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9231. }
  9232. oldValue, err := m.oldValue(ctx)
  9233. if err != nil {
  9234. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9235. }
  9236. return oldValue.OrganizationID, nil
  9237. }
  9238. // AddOrganizationID adds u to the "organization_id" field.
  9239. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  9240. if m.addorganization_id != nil {
  9241. *m.addorganization_id += u
  9242. } else {
  9243. m.addorganization_id = &u
  9244. }
  9245. }
  9246. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9247. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  9248. v := m.addorganization_id
  9249. if v == nil {
  9250. return
  9251. }
  9252. return *v, true
  9253. }
  9254. // ClearOrganizationID clears the value of the "organization_id" field.
  9255. func (m *MessageRecordsMutation) ClearOrganizationID() {
  9256. m.organization_id = nil
  9257. m.addorganization_id = nil
  9258. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  9259. }
  9260. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  9261. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  9262. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  9263. return ok
  9264. }
  9265. // ResetOrganizationID resets all changes to the "organization_id" field.
  9266. func (m *MessageRecordsMutation) ResetOrganizationID() {
  9267. m.organization_id = nil
  9268. m.addorganization_id = nil
  9269. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  9270. }
  9271. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  9272. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  9273. m.sop_stage = &id
  9274. }
  9275. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  9276. func (m *MessageRecordsMutation) ClearSopStage() {
  9277. m.clearedsop_stage = true
  9278. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  9279. }
  9280. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  9281. func (m *MessageRecordsMutation) SopStageCleared() bool {
  9282. return m.SourceIDCleared() || m.clearedsop_stage
  9283. }
  9284. // SopStageID returns the "sop_stage" edge ID in the mutation.
  9285. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  9286. if m.sop_stage != nil {
  9287. return *m.sop_stage, true
  9288. }
  9289. return
  9290. }
  9291. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  9292. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  9293. // SopStageID instead. It exists only for internal usage by the builders.
  9294. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  9295. if id := m.sop_stage; id != nil {
  9296. ids = append(ids, *id)
  9297. }
  9298. return
  9299. }
  9300. // ResetSopStage resets all changes to the "sop_stage" edge.
  9301. func (m *MessageRecordsMutation) ResetSopStage() {
  9302. m.sop_stage = nil
  9303. m.clearedsop_stage = false
  9304. }
  9305. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  9306. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  9307. m.sop_node = &id
  9308. }
  9309. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  9310. func (m *MessageRecordsMutation) ClearSopNode() {
  9311. m.clearedsop_node = true
  9312. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  9313. }
  9314. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  9315. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  9316. return m.SubSourceIDCleared() || m.clearedsop_node
  9317. }
  9318. // SopNodeID returns the "sop_node" edge ID in the mutation.
  9319. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  9320. if m.sop_node != nil {
  9321. return *m.sop_node, true
  9322. }
  9323. return
  9324. }
  9325. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  9326. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  9327. // SopNodeID instead. It exists only for internal usage by the builders.
  9328. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  9329. if id := m.sop_node; id != nil {
  9330. ids = append(ids, *id)
  9331. }
  9332. return
  9333. }
  9334. // ResetSopNode resets all changes to the "sop_node" edge.
  9335. func (m *MessageRecordsMutation) ResetSopNode() {
  9336. m.sop_node = nil
  9337. m.clearedsop_node = false
  9338. }
  9339. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  9340. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  9341. m.message_contact = &id
  9342. }
  9343. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  9344. func (m *MessageRecordsMutation) ClearMessageContact() {
  9345. m.clearedmessage_contact = true
  9346. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  9347. }
  9348. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  9349. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  9350. return m.ContactIDCleared() || m.clearedmessage_contact
  9351. }
  9352. // MessageContactID returns the "message_contact" edge ID in the mutation.
  9353. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  9354. if m.message_contact != nil {
  9355. return *m.message_contact, true
  9356. }
  9357. return
  9358. }
  9359. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  9360. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  9361. // MessageContactID instead. It exists only for internal usage by the builders.
  9362. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  9363. if id := m.message_contact; id != nil {
  9364. ids = append(ids, *id)
  9365. }
  9366. return
  9367. }
  9368. // ResetMessageContact resets all changes to the "message_contact" edge.
  9369. func (m *MessageRecordsMutation) ResetMessageContact() {
  9370. m.message_contact = nil
  9371. m.clearedmessage_contact = false
  9372. }
  9373. // Where appends a list predicates to the MessageRecordsMutation builder.
  9374. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  9375. m.predicates = append(m.predicates, ps...)
  9376. }
  9377. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  9378. // users can use type-assertion to append predicates that do not depend on any generated package.
  9379. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  9380. p := make([]predicate.MessageRecords, len(ps))
  9381. for i := range ps {
  9382. p[i] = ps[i]
  9383. }
  9384. m.Where(p...)
  9385. }
  9386. // Op returns the operation name.
  9387. func (m *MessageRecordsMutation) Op() Op {
  9388. return m.op
  9389. }
  9390. // SetOp allows setting the mutation operation.
  9391. func (m *MessageRecordsMutation) SetOp(op Op) {
  9392. m.op = op
  9393. }
  9394. // Type returns the node type of this mutation (MessageRecords).
  9395. func (m *MessageRecordsMutation) Type() string {
  9396. return m.typ
  9397. }
  9398. // Fields returns all fields that were changed during this mutation. Note that in
  9399. // order to get all numeric fields that were incremented/decremented, call
  9400. // AddedFields().
  9401. func (m *MessageRecordsMutation) Fields() []string {
  9402. fields := make([]string, 0, 17)
  9403. if m.created_at != nil {
  9404. fields = append(fields, messagerecords.FieldCreatedAt)
  9405. }
  9406. if m.updated_at != nil {
  9407. fields = append(fields, messagerecords.FieldUpdatedAt)
  9408. }
  9409. if m.status != nil {
  9410. fields = append(fields, messagerecords.FieldStatus)
  9411. }
  9412. if m.deleted_at != nil {
  9413. fields = append(fields, messagerecords.FieldDeletedAt)
  9414. }
  9415. if m.bot_wxid != nil {
  9416. fields = append(fields, messagerecords.FieldBotWxid)
  9417. }
  9418. if m.message_contact != nil {
  9419. fields = append(fields, messagerecords.FieldContactID)
  9420. }
  9421. if m.contact_type != nil {
  9422. fields = append(fields, messagerecords.FieldContactType)
  9423. }
  9424. if m.contact_wxid != nil {
  9425. fields = append(fields, messagerecords.FieldContactWxid)
  9426. }
  9427. if m.content_type != nil {
  9428. fields = append(fields, messagerecords.FieldContentType)
  9429. }
  9430. if m.content != nil {
  9431. fields = append(fields, messagerecords.FieldContent)
  9432. }
  9433. if m.meta != nil {
  9434. fields = append(fields, messagerecords.FieldMeta)
  9435. }
  9436. if m.error_detail != nil {
  9437. fields = append(fields, messagerecords.FieldErrorDetail)
  9438. }
  9439. if m.send_time != nil {
  9440. fields = append(fields, messagerecords.FieldSendTime)
  9441. }
  9442. if m.source_type != nil {
  9443. fields = append(fields, messagerecords.FieldSourceType)
  9444. }
  9445. if m.sop_stage != nil {
  9446. fields = append(fields, messagerecords.FieldSourceID)
  9447. }
  9448. if m.sop_node != nil {
  9449. fields = append(fields, messagerecords.FieldSubSourceID)
  9450. }
  9451. if m.organization_id != nil {
  9452. fields = append(fields, messagerecords.FieldOrganizationID)
  9453. }
  9454. return fields
  9455. }
  9456. // Field returns the value of a field with the given name. The second boolean
  9457. // return value indicates that this field was not set, or was not defined in the
  9458. // schema.
  9459. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  9460. switch name {
  9461. case messagerecords.FieldCreatedAt:
  9462. return m.CreatedAt()
  9463. case messagerecords.FieldUpdatedAt:
  9464. return m.UpdatedAt()
  9465. case messagerecords.FieldStatus:
  9466. return m.Status()
  9467. case messagerecords.FieldDeletedAt:
  9468. return m.DeletedAt()
  9469. case messagerecords.FieldBotWxid:
  9470. return m.BotWxid()
  9471. case messagerecords.FieldContactID:
  9472. return m.ContactID()
  9473. case messagerecords.FieldContactType:
  9474. return m.ContactType()
  9475. case messagerecords.FieldContactWxid:
  9476. return m.ContactWxid()
  9477. case messagerecords.FieldContentType:
  9478. return m.ContentType()
  9479. case messagerecords.FieldContent:
  9480. return m.Content()
  9481. case messagerecords.FieldMeta:
  9482. return m.Meta()
  9483. case messagerecords.FieldErrorDetail:
  9484. return m.ErrorDetail()
  9485. case messagerecords.FieldSendTime:
  9486. return m.SendTime()
  9487. case messagerecords.FieldSourceType:
  9488. return m.SourceType()
  9489. case messagerecords.FieldSourceID:
  9490. return m.SourceID()
  9491. case messagerecords.FieldSubSourceID:
  9492. return m.SubSourceID()
  9493. case messagerecords.FieldOrganizationID:
  9494. return m.OrganizationID()
  9495. }
  9496. return nil, false
  9497. }
  9498. // OldField returns the old value of the field from the database. An error is
  9499. // returned if the mutation operation is not UpdateOne, or the query to the
  9500. // database failed.
  9501. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9502. switch name {
  9503. case messagerecords.FieldCreatedAt:
  9504. return m.OldCreatedAt(ctx)
  9505. case messagerecords.FieldUpdatedAt:
  9506. return m.OldUpdatedAt(ctx)
  9507. case messagerecords.FieldStatus:
  9508. return m.OldStatus(ctx)
  9509. case messagerecords.FieldDeletedAt:
  9510. return m.OldDeletedAt(ctx)
  9511. case messagerecords.FieldBotWxid:
  9512. return m.OldBotWxid(ctx)
  9513. case messagerecords.FieldContactID:
  9514. return m.OldContactID(ctx)
  9515. case messagerecords.FieldContactType:
  9516. return m.OldContactType(ctx)
  9517. case messagerecords.FieldContactWxid:
  9518. return m.OldContactWxid(ctx)
  9519. case messagerecords.FieldContentType:
  9520. return m.OldContentType(ctx)
  9521. case messagerecords.FieldContent:
  9522. return m.OldContent(ctx)
  9523. case messagerecords.FieldMeta:
  9524. return m.OldMeta(ctx)
  9525. case messagerecords.FieldErrorDetail:
  9526. return m.OldErrorDetail(ctx)
  9527. case messagerecords.FieldSendTime:
  9528. return m.OldSendTime(ctx)
  9529. case messagerecords.FieldSourceType:
  9530. return m.OldSourceType(ctx)
  9531. case messagerecords.FieldSourceID:
  9532. return m.OldSourceID(ctx)
  9533. case messagerecords.FieldSubSourceID:
  9534. return m.OldSubSourceID(ctx)
  9535. case messagerecords.FieldOrganizationID:
  9536. return m.OldOrganizationID(ctx)
  9537. }
  9538. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  9539. }
  9540. // SetField sets the value of a field with the given name. It returns an error if
  9541. // the field is not defined in the schema, or if the type mismatched the field
  9542. // type.
  9543. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  9544. switch name {
  9545. case messagerecords.FieldCreatedAt:
  9546. v, ok := value.(time.Time)
  9547. if !ok {
  9548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9549. }
  9550. m.SetCreatedAt(v)
  9551. return nil
  9552. case messagerecords.FieldUpdatedAt:
  9553. v, ok := value.(time.Time)
  9554. if !ok {
  9555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9556. }
  9557. m.SetUpdatedAt(v)
  9558. return nil
  9559. case messagerecords.FieldStatus:
  9560. v, ok := value.(uint8)
  9561. if !ok {
  9562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9563. }
  9564. m.SetStatus(v)
  9565. return nil
  9566. case messagerecords.FieldDeletedAt:
  9567. v, ok := value.(time.Time)
  9568. if !ok {
  9569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9570. }
  9571. m.SetDeletedAt(v)
  9572. return nil
  9573. case messagerecords.FieldBotWxid:
  9574. v, ok := value.(string)
  9575. if !ok {
  9576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9577. }
  9578. m.SetBotWxid(v)
  9579. return nil
  9580. case messagerecords.FieldContactID:
  9581. v, ok := value.(uint64)
  9582. if !ok {
  9583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9584. }
  9585. m.SetContactID(v)
  9586. return nil
  9587. case messagerecords.FieldContactType:
  9588. v, ok := value.(int)
  9589. if !ok {
  9590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9591. }
  9592. m.SetContactType(v)
  9593. return nil
  9594. case messagerecords.FieldContactWxid:
  9595. v, ok := value.(string)
  9596. if !ok {
  9597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9598. }
  9599. m.SetContactWxid(v)
  9600. return nil
  9601. case messagerecords.FieldContentType:
  9602. v, ok := value.(int)
  9603. if !ok {
  9604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9605. }
  9606. m.SetContentType(v)
  9607. return nil
  9608. case messagerecords.FieldContent:
  9609. v, ok := value.(string)
  9610. if !ok {
  9611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9612. }
  9613. m.SetContent(v)
  9614. return nil
  9615. case messagerecords.FieldMeta:
  9616. v, ok := value.(custom_types.Meta)
  9617. if !ok {
  9618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9619. }
  9620. m.SetMeta(v)
  9621. return nil
  9622. case messagerecords.FieldErrorDetail:
  9623. v, ok := value.(string)
  9624. if !ok {
  9625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9626. }
  9627. m.SetErrorDetail(v)
  9628. return nil
  9629. case messagerecords.FieldSendTime:
  9630. v, ok := value.(time.Time)
  9631. if !ok {
  9632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9633. }
  9634. m.SetSendTime(v)
  9635. return nil
  9636. case messagerecords.FieldSourceType:
  9637. v, ok := value.(int)
  9638. if !ok {
  9639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9640. }
  9641. m.SetSourceType(v)
  9642. return nil
  9643. case messagerecords.FieldSourceID:
  9644. v, ok := value.(uint64)
  9645. if !ok {
  9646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9647. }
  9648. m.SetSourceID(v)
  9649. return nil
  9650. case messagerecords.FieldSubSourceID:
  9651. v, ok := value.(uint64)
  9652. if !ok {
  9653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9654. }
  9655. m.SetSubSourceID(v)
  9656. return nil
  9657. case messagerecords.FieldOrganizationID:
  9658. v, ok := value.(uint64)
  9659. if !ok {
  9660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9661. }
  9662. m.SetOrganizationID(v)
  9663. return nil
  9664. }
  9665. return fmt.Errorf("unknown MessageRecords field %s", name)
  9666. }
  9667. // AddedFields returns all numeric fields that were incremented/decremented during
  9668. // this mutation.
  9669. func (m *MessageRecordsMutation) AddedFields() []string {
  9670. var fields []string
  9671. if m.addstatus != nil {
  9672. fields = append(fields, messagerecords.FieldStatus)
  9673. }
  9674. if m.addcontact_type != nil {
  9675. fields = append(fields, messagerecords.FieldContactType)
  9676. }
  9677. if m.addcontent_type != nil {
  9678. fields = append(fields, messagerecords.FieldContentType)
  9679. }
  9680. if m.addsource_type != nil {
  9681. fields = append(fields, messagerecords.FieldSourceType)
  9682. }
  9683. if m.addorganization_id != nil {
  9684. fields = append(fields, messagerecords.FieldOrganizationID)
  9685. }
  9686. return fields
  9687. }
  9688. // AddedField returns the numeric value that was incremented/decremented on a field
  9689. // with the given name. The second boolean return value indicates that this field
  9690. // was not set, or was not defined in the schema.
  9691. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  9692. switch name {
  9693. case messagerecords.FieldStatus:
  9694. return m.AddedStatus()
  9695. case messagerecords.FieldContactType:
  9696. return m.AddedContactType()
  9697. case messagerecords.FieldContentType:
  9698. return m.AddedContentType()
  9699. case messagerecords.FieldSourceType:
  9700. return m.AddedSourceType()
  9701. case messagerecords.FieldOrganizationID:
  9702. return m.AddedOrganizationID()
  9703. }
  9704. return nil, false
  9705. }
  9706. // AddField adds the value to the field with the given name. It returns an error if
  9707. // the field is not defined in the schema, or if the type mismatched the field
  9708. // type.
  9709. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  9710. switch name {
  9711. case messagerecords.FieldStatus:
  9712. v, ok := value.(int8)
  9713. if !ok {
  9714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9715. }
  9716. m.AddStatus(v)
  9717. return nil
  9718. case messagerecords.FieldContactType:
  9719. v, ok := value.(int)
  9720. if !ok {
  9721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9722. }
  9723. m.AddContactType(v)
  9724. return nil
  9725. case messagerecords.FieldContentType:
  9726. v, ok := value.(int)
  9727. if !ok {
  9728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9729. }
  9730. m.AddContentType(v)
  9731. return nil
  9732. case messagerecords.FieldSourceType:
  9733. v, ok := value.(int)
  9734. if !ok {
  9735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9736. }
  9737. m.AddSourceType(v)
  9738. return nil
  9739. case messagerecords.FieldOrganizationID:
  9740. v, ok := value.(int64)
  9741. if !ok {
  9742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9743. }
  9744. m.AddOrganizationID(v)
  9745. return nil
  9746. }
  9747. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  9748. }
  9749. // ClearedFields returns all nullable fields that were cleared during this
  9750. // mutation.
  9751. func (m *MessageRecordsMutation) ClearedFields() []string {
  9752. var fields []string
  9753. if m.FieldCleared(messagerecords.FieldStatus) {
  9754. fields = append(fields, messagerecords.FieldStatus)
  9755. }
  9756. if m.FieldCleared(messagerecords.FieldDeletedAt) {
  9757. fields = append(fields, messagerecords.FieldDeletedAt)
  9758. }
  9759. if m.FieldCleared(messagerecords.FieldContactID) {
  9760. fields = append(fields, messagerecords.FieldContactID)
  9761. }
  9762. if m.FieldCleared(messagerecords.FieldMeta) {
  9763. fields = append(fields, messagerecords.FieldMeta)
  9764. }
  9765. if m.FieldCleared(messagerecords.FieldSendTime) {
  9766. fields = append(fields, messagerecords.FieldSendTime)
  9767. }
  9768. if m.FieldCleared(messagerecords.FieldSourceID) {
  9769. fields = append(fields, messagerecords.FieldSourceID)
  9770. }
  9771. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  9772. fields = append(fields, messagerecords.FieldSubSourceID)
  9773. }
  9774. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  9775. fields = append(fields, messagerecords.FieldOrganizationID)
  9776. }
  9777. return fields
  9778. }
  9779. // FieldCleared returns a boolean indicating if a field with the given name was
  9780. // cleared in this mutation.
  9781. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  9782. _, ok := m.clearedFields[name]
  9783. return ok
  9784. }
  9785. // ClearField clears the value of the field with the given name. It returns an
  9786. // error if the field is not defined in the schema.
  9787. func (m *MessageRecordsMutation) ClearField(name string) error {
  9788. switch name {
  9789. case messagerecords.FieldStatus:
  9790. m.ClearStatus()
  9791. return nil
  9792. case messagerecords.FieldDeletedAt:
  9793. m.ClearDeletedAt()
  9794. return nil
  9795. case messagerecords.FieldContactID:
  9796. m.ClearContactID()
  9797. return nil
  9798. case messagerecords.FieldMeta:
  9799. m.ClearMeta()
  9800. return nil
  9801. case messagerecords.FieldSendTime:
  9802. m.ClearSendTime()
  9803. return nil
  9804. case messagerecords.FieldSourceID:
  9805. m.ClearSourceID()
  9806. return nil
  9807. case messagerecords.FieldSubSourceID:
  9808. m.ClearSubSourceID()
  9809. return nil
  9810. case messagerecords.FieldOrganizationID:
  9811. m.ClearOrganizationID()
  9812. return nil
  9813. }
  9814. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  9815. }
  9816. // ResetField resets all changes in the mutation for the field with the given name.
  9817. // It returns an error if the field is not defined in the schema.
  9818. func (m *MessageRecordsMutation) ResetField(name string) error {
  9819. switch name {
  9820. case messagerecords.FieldCreatedAt:
  9821. m.ResetCreatedAt()
  9822. return nil
  9823. case messagerecords.FieldUpdatedAt:
  9824. m.ResetUpdatedAt()
  9825. return nil
  9826. case messagerecords.FieldStatus:
  9827. m.ResetStatus()
  9828. return nil
  9829. case messagerecords.FieldDeletedAt:
  9830. m.ResetDeletedAt()
  9831. return nil
  9832. case messagerecords.FieldBotWxid:
  9833. m.ResetBotWxid()
  9834. return nil
  9835. case messagerecords.FieldContactID:
  9836. m.ResetContactID()
  9837. return nil
  9838. case messagerecords.FieldContactType:
  9839. m.ResetContactType()
  9840. return nil
  9841. case messagerecords.FieldContactWxid:
  9842. m.ResetContactWxid()
  9843. return nil
  9844. case messagerecords.FieldContentType:
  9845. m.ResetContentType()
  9846. return nil
  9847. case messagerecords.FieldContent:
  9848. m.ResetContent()
  9849. return nil
  9850. case messagerecords.FieldMeta:
  9851. m.ResetMeta()
  9852. return nil
  9853. case messagerecords.FieldErrorDetail:
  9854. m.ResetErrorDetail()
  9855. return nil
  9856. case messagerecords.FieldSendTime:
  9857. m.ResetSendTime()
  9858. return nil
  9859. case messagerecords.FieldSourceType:
  9860. m.ResetSourceType()
  9861. return nil
  9862. case messagerecords.FieldSourceID:
  9863. m.ResetSourceID()
  9864. return nil
  9865. case messagerecords.FieldSubSourceID:
  9866. m.ResetSubSourceID()
  9867. return nil
  9868. case messagerecords.FieldOrganizationID:
  9869. m.ResetOrganizationID()
  9870. return nil
  9871. }
  9872. return fmt.Errorf("unknown MessageRecords field %s", name)
  9873. }
  9874. // AddedEdges returns all edge names that were set/added in this mutation.
  9875. func (m *MessageRecordsMutation) AddedEdges() []string {
  9876. edges := make([]string, 0, 3)
  9877. if m.sop_stage != nil {
  9878. edges = append(edges, messagerecords.EdgeSopStage)
  9879. }
  9880. if m.sop_node != nil {
  9881. edges = append(edges, messagerecords.EdgeSopNode)
  9882. }
  9883. if m.message_contact != nil {
  9884. edges = append(edges, messagerecords.EdgeMessageContact)
  9885. }
  9886. return edges
  9887. }
  9888. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9889. // name in this mutation.
  9890. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  9891. switch name {
  9892. case messagerecords.EdgeSopStage:
  9893. if id := m.sop_stage; id != nil {
  9894. return []ent.Value{*id}
  9895. }
  9896. case messagerecords.EdgeSopNode:
  9897. if id := m.sop_node; id != nil {
  9898. return []ent.Value{*id}
  9899. }
  9900. case messagerecords.EdgeMessageContact:
  9901. if id := m.message_contact; id != nil {
  9902. return []ent.Value{*id}
  9903. }
  9904. }
  9905. return nil
  9906. }
  9907. // RemovedEdges returns all edge names that were removed in this mutation.
  9908. func (m *MessageRecordsMutation) RemovedEdges() []string {
  9909. edges := make([]string, 0, 3)
  9910. return edges
  9911. }
  9912. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9913. // the given name in this mutation.
  9914. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  9915. return nil
  9916. }
  9917. // ClearedEdges returns all edge names that were cleared in this mutation.
  9918. func (m *MessageRecordsMutation) ClearedEdges() []string {
  9919. edges := make([]string, 0, 3)
  9920. if m.clearedsop_stage {
  9921. edges = append(edges, messagerecords.EdgeSopStage)
  9922. }
  9923. if m.clearedsop_node {
  9924. edges = append(edges, messagerecords.EdgeSopNode)
  9925. }
  9926. if m.clearedmessage_contact {
  9927. edges = append(edges, messagerecords.EdgeMessageContact)
  9928. }
  9929. return edges
  9930. }
  9931. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9932. // was cleared in this mutation.
  9933. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  9934. switch name {
  9935. case messagerecords.EdgeSopStage:
  9936. return m.clearedsop_stage
  9937. case messagerecords.EdgeSopNode:
  9938. return m.clearedsop_node
  9939. case messagerecords.EdgeMessageContact:
  9940. return m.clearedmessage_contact
  9941. }
  9942. return false
  9943. }
  9944. // ClearEdge clears the value of the edge with the given name. It returns an error
  9945. // if that edge is not defined in the schema.
  9946. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  9947. switch name {
  9948. case messagerecords.EdgeSopStage:
  9949. m.ClearSopStage()
  9950. return nil
  9951. case messagerecords.EdgeSopNode:
  9952. m.ClearSopNode()
  9953. return nil
  9954. case messagerecords.EdgeMessageContact:
  9955. m.ClearMessageContact()
  9956. return nil
  9957. }
  9958. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  9959. }
  9960. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9961. // It returns an error if the edge is not defined in the schema.
  9962. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  9963. switch name {
  9964. case messagerecords.EdgeSopStage:
  9965. m.ResetSopStage()
  9966. return nil
  9967. case messagerecords.EdgeSopNode:
  9968. m.ResetSopNode()
  9969. return nil
  9970. case messagerecords.EdgeMessageContact:
  9971. m.ResetMessageContact()
  9972. return nil
  9973. }
  9974. return fmt.Errorf("unknown MessageRecords edge %s", name)
  9975. }
  9976. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  9977. type MsgMutation struct {
  9978. config
  9979. op Op
  9980. typ string
  9981. id *uint64
  9982. created_at *time.Time
  9983. updated_at *time.Time
  9984. deleted_at *time.Time
  9985. status *uint8
  9986. addstatus *int8
  9987. fromwxid *string
  9988. toid *string
  9989. msgtype *int32
  9990. addmsgtype *int32
  9991. msg *string
  9992. batch_no *string
  9993. clearedFields map[string]struct{}
  9994. done bool
  9995. oldValue func(context.Context) (*Msg, error)
  9996. predicates []predicate.Msg
  9997. }
  9998. var _ ent.Mutation = (*MsgMutation)(nil)
  9999. // msgOption allows management of the mutation configuration using functional options.
  10000. type msgOption func(*MsgMutation)
  10001. // newMsgMutation creates new mutation for the Msg entity.
  10002. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  10003. m := &MsgMutation{
  10004. config: c,
  10005. op: op,
  10006. typ: TypeMsg,
  10007. clearedFields: make(map[string]struct{}),
  10008. }
  10009. for _, opt := range opts {
  10010. opt(m)
  10011. }
  10012. return m
  10013. }
  10014. // withMsgID sets the ID field of the mutation.
  10015. func withMsgID(id uint64) msgOption {
  10016. return func(m *MsgMutation) {
  10017. var (
  10018. err error
  10019. once sync.Once
  10020. value *Msg
  10021. )
  10022. m.oldValue = func(ctx context.Context) (*Msg, error) {
  10023. once.Do(func() {
  10024. if m.done {
  10025. err = errors.New("querying old values post mutation is not allowed")
  10026. } else {
  10027. value, err = m.Client().Msg.Get(ctx, id)
  10028. }
  10029. })
  10030. return value, err
  10031. }
  10032. m.id = &id
  10033. }
  10034. }
  10035. // withMsg sets the old Msg of the mutation.
  10036. func withMsg(node *Msg) msgOption {
  10037. return func(m *MsgMutation) {
  10038. m.oldValue = func(context.Context) (*Msg, error) {
  10039. return node, nil
  10040. }
  10041. m.id = &node.ID
  10042. }
  10043. }
  10044. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10045. // executed in a transaction (ent.Tx), a transactional client is returned.
  10046. func (m MsgMutation) Client() *Client {
  10047. client := &Client{config: m.config}
  10048. client.init()
  10049. return client
  10050. }
  10051. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10052. // it returns an error otherwise.
  10053. func (m MsgMutation) Tx() (*Tx, error) {
  10054. if _, ok := m.driver.(*txDriver); !ok {
  10055. return nil, errors.New("ent: mutation is not running in a transaction")
  10056. }
  10057. tx := &Tx{config: m.config}
  10058. tx.init()
  10059. return tx, nil
  10060. }
  10061. // SetID sets the value of the id field. Note that this
  10062. // operation is only accepted on creation of Msg entities.
  10063. func (m *MsgMutation) SetID(id uint64) {
  10064. m.id = &id
  10065. }
  10066. // ID returns the ID value in the mutation. Note that the ID is only available
  10067. // if it was provided to the builder or after it was returned from the database.
  10068. func (m *MsgMutation) ID() (id uint64, exists bool) {
  10069. if m.id == nil {
  10070. return
  10071. }
  10072. return *m.id, true
  10073. }
  10074. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10075. // That means, if the mutation is applied within a transaction with an isolation level such
  10076. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10077. // or updated by the mutation.
  10078. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  10079. switch {
  10080. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10081. id, exists := m.ID()
  10082. if exists {
  10083. return []uint64{id}, nil
  10084. }
  10085. fallthrough
  10086. case m.op.Is(OpUpdate | OpDelete):
  10087. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  10088. default:
  10089. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10090. }
  10091. }
  10092. // SetCreatedAt sets the "created_at" field.
  10093. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  10094. m.created_at = &t
  10095. }
  10096. // CreatedAt returns the value of the "created_at" field in the mutation.
  10097. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  10098. v := m.created_at
  10099. if v == nil {
  10100. return
  10101. }
  10102. return *v, true
  10103. }
  10104. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  10105. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10107. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10108. if !m.op.Is(OpUpdateOne) {
  10109. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10110. }
  10111. if m.id == nil || m.oldValue == nil {
  10112. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10113. }
  10114. oldValue, err := m.oldValue(ctx)
  10115. if err != nil {
  10116. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10117. }
  10118. return oldValue.CreatedAt, nil
  10119. }
  10120. // ResetCreatedAt resets all changes to the "created_at" field.
  10121. func (m *MsgMutation) ResetCreatedAt() {
  10122. m.created_at = nil
  10123. }
  10124. // SetUpdatedAt sets the "updated_at" field.
  10125. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  10126. m.updated_at = &t
  10127. }
  10128. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10129. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  10130. v := m.updated_at
  10131. if v == nil {
  10132. return
  10133. }
  10134. return *v, true
  10135. }
  10136. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  10137. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10139. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10140. if !m.op.Is(OpUpdateOne) {
  10141. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10142. }
  10143. if m.id == nil || m.oldValue == nil {
  10144. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10145. }
  10146. oldValue, err := m.oldValue(ctx)
  10147. if err != nil {
  10148. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10149. }
  10150. return oldValue.UpdatedAt, nil
  10151. }
  10152. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10153. func (m *MsgMutation) ResetUpdatedAt() {
  10154. m.updated_at = nil
  10155. }
  10156. // SetDeletedAt sets the "deleted_at" field.
  10157. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  10158. m.deleted_at = &t
  10159. }
  10160. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10161. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  10162. v := m.deleted_at
  10163. if v == nil {
  10164. return
  10165. }
  10166. return *v, true
  10167. }
  10168. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  10169. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10171. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10172. if !m.op.Is(OpUpdateOne) {
  10173. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10174. }
  10175. if m.id == nil || m.oldValue == nil {
  10176. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10177. }
  10178. oldValue, err := m.oldValue(ctx)
  10179. if err != nil {
  10180. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10181. }
  10182. return oldValue.DeletedAt, nil
  10183. }
  10184. // ClearDeletedAt clears the value of the "deleted_at" field.
  10185. func (m *MsgMutation) ClearDeletedAt() {
  10186. m.deleted_at = nil
  10187. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  10188. }
  10189. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10190. func (m *MsgMutation) DeletedAtCleared() bool {
  10191. _, ok := m.clearedFields[msg.FieldDeletedAt]
  10192. return ok
  10193. }
  10194. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10195. func (m *MsgMutation) ResetDeletedAt() {
  10196. m.deleted_at = nil
  10197. delete(m.clearedFields, msg.FieldDeletedAt)
  10198. }
  10199. // SetStatus sets the "status" field.
  10200. func (m *MsgMutation) SetStatus(u uint8) {
  10201. m.status = &u
  10202. m.addstatus = nil
  10203. }
  10204. // Status returns the value of the "status" field in the mutation.
  10205. func (m *MsgMutation) Status() (r uint8, exists bool) {
  10206. v := m.status
  10207. if v == nil {
  10208. return
  10209. }
  10210. return *v, true
  10211. }
  10212. // OldStatus returns the old "status" field's value of the Msg entity.
  10213. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10215. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  10216. if !m.op.Is(OpUpdateOne) {
  10217. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10218. }
  10219. if m.id == nil || m.oldValue == nil {
  10220. return v, errors.New("OldStatus requires an ID field in the mutation")
  10221. }
  10222. oldValue, err := m.oldValue(ctx)
  10223. if err != nil {
  10224. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10225. }
  10226. return oldValue.Status, nil
  10227. }
  10228. // AddStatus adds u to the "status" field.
  10229. func (m *MsgMutation) AddStatus(u int8) {
  10230. if m.addstatus != nil {
  10231. *m.addstatus += u
  10232. } else {
  10233. m.addstatus = &u
  10234. }
  10235. }
  10236. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10237. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  10238. v := m.addstatus
  10239. if v == nil {
  10240. return
  10241. }
  10242. return *v, true
  10243. }
  10244. // ClearStatus clears the value of the "status" field.
  10245. func (m *MsgMutation) ClearStatus() {
  10246. m.status = nil
  10247. m.addstatus = nil
  10248. m.clearedFields[msg.FieldStatus] = struct{}{}
  10249. }
  10250. // StatusCleared returns if the "status" field was cleared in this mutation.
  10251. func (m *MsgMutation) StatusCleared() bool {
  10252. _, ok := m.clearedFields[msg.FieldStatus]
  10253. return ok
  10254. }
  10255. // ResetStatus resets all changes to the "status" field.
  10256. func (m *MsgMutation) ResetStatus() {
  10257. m.status = nil
  10258. m.addstatus = nil
  10259. delete(m.clearedFields, msg.FieldStatus)
  10260. }
  10261. // SetFromwxid sets the "fromwxid" field.
  10262. func (m *MsgMutation) SetFromwxid(s string) {
  10263. m.fromwxid = &s
  10264. }
  10265. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  10266. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  10267. v := m.fromwxid
  10268. if v == nil {
  10269. return
  10270. }
  10271. return *v, true
  10272. }
  10273. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  10274. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10276. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  10277. if !m.op.Is(OpUpdateOne) {
  10278. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  10279. }
  10280. if m.id == nil || m.oldValue == nil {
  10281. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  10282. }
  10283. oldValue, err := m.oldValue(ctx)
  10284. if err != nil {
  10285. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  10286. }
  10287. return oldValue.Fromwxid, nil
  10288. }
  10289. // ClearFromwxid clears the value of the "fromwxid" field.
  10290. func (m *MsgMutation) ClearFromwxid() {
  10291. m.fromwxid = nil
  10292. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  10293. }
  10294. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  10295. func (m *MsgMutation) FromwxidCleared() bool {
  10296. _, ok := m.clearedFields[msg.FieldFromwxid]
  10297. return ok
  10298. }
  10299. // ResetFromwxid resets all changes to the "fromwxid" field.
  10300. func (m *MsgMutation) ResetFromwxid() {
  10301. m.fromwxid = nil
  10302. delete(m.clearedFields, msg.FieldFromwxid)
  10303. }
  10304. // SetToid sets the "toid" field.
  10305. func (m *MsgMutation) SetToid(s string) {
  10306. m.toid = &s
  10307. }
  10308. // Toid returns the value of the "toid" field in the mutation.
  10309. func (m *MsgMutation) Toid() (r string, exists bool) {
  10310. v := m.toid
  10311. if v == nil {
  10312. return
  10313. }
  10314. return *v, true
  10315. }
  10316. // OldToid returns the old "toid" field's value of the Msg entity.
  10317. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10319. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  10320. if !m.op.Is(OpUpdateOne) {
  10321. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  10322. }
  10323. if m.id == nil || m.oldValue == nil {
  10324. return v, errors.New("OldToid requires an ID field in the mutation")
  10325. }
  10326. oldValue, err := m.oldValue(ctx)
  10327. if err != nil {
  10328. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  10329. }
  10330. return oldValue.Toid, nil
  10331. }
  10332. // ClearToid clears the value of the "toid" field.
  10333. func (m *MsgMutation) ClearToid() {
  10334. m.toid = nil
  10335. m.clearedFields[msg.FieldToid] = struct{}{}
  10336. }
  10337. // ToidCleared returns if the "toid" field was cleared in this mutation.
  10338. func (m *MsgMutation) ToidCleared() bool {
  10339. _, ok := m.clearedFields[msg.FieldToid]
  10340. return ok
  10341. }
  10342. // ResetToid resets all changes to the "toid" field.
  10343. func (m *MsgMutation) ResetToid() {
  10344. m.toid = nil
  10345. delete(m.clearedFields, msg.FieldToid)
  10346. }
  10347. // SetMsgtype sets the "msgtype" field.
  10348. func (m *MsgMutation) SetMsgtype(i int32) {
  10349. m.msgtype = &i
  10350. m.addmsgtype = nil
  10351. }
  10352. // Msgtype returns the value of the "msgtype" field in the mutation.
  10353. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  10354. v := m.msgtype
  10355. if v == nil {
  10356. return
  10357. }
  10358. return *v, true
  10359. }
  10360. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  10361. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10363. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  10364. if !m.op.Is(OpUpdateOne) {
  10365. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  10366. }
  10367. if m.id == nil || m.oldValue == nil {
  10368. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  10369. }
  10370. oldValue, err := m.oldValue(ctx)
  10371. if err != nil {
  10372. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  10373. }
  10374. return oldValue.Msgtype, nil
  10375. }
  10376. // AddMsgtype adds i to the "msgtype" field.
  10377. func (m *MsgMutation) AddMsgtype(i int32) {
  10378. if m.addmsgtype != nil {
  10379. *m.addmsgtype += i
  10380. } else {
  10381. m.addmsgtype = &i
  10382. }
  10383. }
  10384. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  10385. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  10386. v := m.addmsgtype
  10387. if v == nil {
  10388. return
  10389. }
  10390. return *v, true
  10391. }
  10392. // ClearMsgtype clears the value of the "msgtype" field.
  10393. func (m *MsgMutation) ClearMsgtype() {
  10394. m.msgtype = nil
  10395. m.addmsgtype = nil
  10396. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  10397. }
  10398. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  10399. func (m *MsgMutation) MsgtypeCleared() bool {
  10400. _, ok := m.clearedFields[msg.FieldMsgtype]
  10401. return ok
  10402. }
  10403. // ResetMsgtype resets all changes to the "msgtype" field.
  10404. func (m *MsgMutation) ResetMsgtype() {
  10405. m.msgtype = nil
  10406. m.addmsgtype = nil
  10407. delete(m.clearedFields, msg.FieldMsgtype)
  10408. }
  10409. // SetMsg sets the "msg" field.
  10410. func (m *MsgMutation) SetMsg(s string) {
  10411. m.msg = &s
  10412. }
  10413. // Msg returns the value of the "msg" field in the mutation.
  10414. func (m *MsgMutation) Msg() (r string, exists bool) {
  10415. v := m.msg
  10416. if v == nil {
  10417. return
  10418. }
  10419. return *v, true
  10420. }
  10421. // OldMsg returns the old "msg" field's value of the Msg entity.
  10422. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10424. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  10425. if !m.op.Is(OpUpdateOne) {
  10426. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  10427. }
  10428. if m.id == nil || m.oldValue == nil {
  10429. return v, errors.New("OldMsg requires an ID field in the mutation")
  10430. }
  10431. oldValue, err := m.oldValue(ctx)
  10432. if err != nil {
  10433. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  10434. }
  10435. return oldValue.Msg, nil
  10436. }
  10437. // ClearMsg clears the value of the "msg" field.
  10438. func (m *MsgMutation) ClearMsg() {
  10439. m.msg = nil
  10440. m.clearedFields[msg.FieldMsg] = struct{}{}
  10441. }
  10442. // MsgCleared returns if the "msg" field was cleared in this mutation.
  10443. func (m *MsgMutation) MsgCleared() bool {
  10444. _, ok := m.clearedFields[msg.FieldMsg]
  10445. return ok
  10446. }
  10447. // ResetMsg resets all changes to the "msg" field.
  10448. func (m *MsgMutation) ResetMsg() {
  10449. m.msg = nil
  10450. delete(m.clearedFields, msg.FieldMsg)
  10451. }
  10452. // SetBatchNo sets the "batch_no" field.
  10453. func (m *MsgMutation) SetBatchNo(s string) {
  10454. m.batch_no = &s
  10455. }
  10456. // BatchNo returns the value of the "batch_no" field in the mutation.
  10457. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  10458. v := m.batch_no
  10459. if v == nil {
  10460. return
  10461. }
  10462. return *v, true
  10463. }
  10464. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  10465. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10466. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10467. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  10468. if !m.op.Is(OpUpdateOne) {
  10469. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  10470. }
  10471. if m.id == nil || m.oldValue == nil {
  10472. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  10473. }
  10474. oldValue, err := m.oldValue(ctx)
  10475. if err != nil {
  10476. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  10477. }
  10478. return oldValue.BatchNo, nil
  10479. }
  10480. // ClearBatchNo clears the value of the "batch_no" field.
  10481. func (m *MsgMutation) ClearBatchNo() {
  10482. m.batch_no = nil
  10483. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  10484. }
  10485. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  10486. func (m *MsgMutation) BatchNoCleared() bool {
  10487. _, ok := m.clearedFields[msg.FieldBatchNo]
  10488. return ok
  10489. }
  10490. // ResetBatchNo resets all changes to the "batch_no" field.
  10491. func (m *MsgMutation) ResetBatchNo() {
  10492. m.batch_no = nil
  10493. delete(m.clearedFields, msg.FieldBatchNo)
  10494. }
  10495. // Where appends a list predicates to the MsgMutation builder.
  10496. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  10497. m.predicates = append(m.predicates, ps...)
  10498. }
  10499. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  10500. // users can use type-assertion to append predicates that do not depend on any generated package.
  10501. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  10502. p := make([]predicate.Msg, len(ps))
  10503. for i := range ps {
  10504. p[i] = ps[i]
  10505. }
  10506. m.Where(p...)
  10507. }
  10508. // Op returns the operation name.
  10509. func (m *MsgMutation) Op() Op {
  10510. return m.op
  10511. }
  10512. // SetOp allows setting the mutation operation.
  10513. func (m *MsgMutation) SetOp(op Op) {
  10514. m.op = op
  10515. }
  10516. // Type returns the node type of this mutation (Msg).
  10517. func (m *MsgMutation) Type() string {
  10518. return m.typ
  10519. }
  10520. // Fields returns all fields that were changed during this mutation. Note that in
  10521. // order to get all numeric fields that were incremented/decremented, call
  10522. // AddedFields().
  10523. func (m *MsgMutation) Fields() []string {
  10524. fields := make([]string, 0, 9)
  10525. if m.created_at != nil {
  10526. fields = append(fields, msg.FieldCreatedAt)
  10527. }
  10528. if m.updated_at != nil {
  10529. fields = append(fields, msg.FieldUpdatedAt)
  10530. }
  10531. if m.deleted_at != nil {
  10532. fields = append(fields, msg.FieldDeletedAt)
  10533. }
  10534. if m.status != nil {
  10535. fields = append(fields, msg.FieldStatus)
  10536. }
  10537. if m.fromwxid != nil {
  10538. fields = append(fields, msg.FieldFromwxid)
  10539. }
  10540. if m.toid != nil {
  10541. fields = append(fields, msg.FieldToid)
  10542. }
  10543. if m.msgtype != nil {
  10544. fields = append(fields, msg.FieldMsgtype)
  10545. }
  10546. if m.msg != nil {
  10547. fields = append(fields, msg.FieldMsg)
  10548. }
  10549. if m.batch_no != nil {
  10550. fields = append(fields, msg.FieldBatchNo)
  10551. }
  10552. return fields
  10553. }
  10554. // Field returns the value of a field with the given name. The second boolean
  10555. // return value indicates that this field was not set, or was not defined in the
  10556. // schema.
  10557. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  10558. switch name {
  10559. case msg.FieldCreatedAt:
  10560. return m.CreatedAt()
  10561. case msg.FieldUpdatedAt:
  10562. return m.UpdatedAt()
  10563. case msg.FieldDeletedAt:
  10564. return m.DeletedAt()
  10565. case msg.FieldStatus:
  10566. return m.Status()
  10567. case msg.FieldFromwxid:
  10568. return m.Fromwxid()
  10569. case msg.FieldToid:
  10570. return m.Toid()
  10571. case msg.FieldMsgtype:
  10572. return m.Msgtype()
  10573. case msg.FieldMsg:
  10574. return m.Msg()
  10575. case msg.FieldBatchNo:
  10576. return m.BatchNo()
  10577. }
  10578. return nil, false
  10579. }
  10580. // OldField returns the old value of the field from the database. An error is
  10581. // returned if the mutation operation is not UpdateOne, or the query to the
  10582. // database failed.
  10583. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10584. switch name {
  10585. case msg.FieldCreatedAt:
  10586. return m.OldCreatedAt(ctx)
  10587. case msg.FieldUpdatedAt:
  10588. return m.OldUpdatedAt(ctx)
  10589. case msg.FieldDeletedAt:
  10590. return m.OldDeletedAt(ctx)
  10591. case msg.FieldStatus:
  10592. return m.OldStatus(ctx)
  10593. case msg.FieldFromwxid:
  10594. return m.OldFromwxid(ctx)
  10595. case msg.FieldToid:
  10596. return m.OldToid(ctx)
  10597. case msg.FieldMsgtype:
  10598. return m.OldMsgtype(ctx)
  10599. case msg.FieldMsg:
  10600. return m.OldMsg(ctx)
  10601. case msg.FieldBatchNo:
  10602. return m.OldBatchNo(ctx)
  10603. }
  10604. return nil, fmt.Errorf("unknown Msg field %s", name)
  10605. }
  10606. // SetField sets the value of a field with the given name. It returns an error if
  10607. // the field is not defined in the schema, or if the type mismatched the field
  10608. // type.
  10609. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  10610. switch name {
  10611. case msg.FieldCreatedAt:
  10612. v, ok := value.(time.Time)
  10613. if !ok {
  10614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10615. }
  10616. m.SetCreatedAt(v)
  10617. return nil
  10618. case msg.FieldUpdatedAt:
  10619. v, ok := value.(time.Time)
  10620. if !ok {
  10621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10622. }
  10623. m.SetUpdatedAt(v)
  10624. return nil
  10625. case msg.FieldDeletedAt:
  10626. v, ok := value.(time.Time)
  10627. if !ok {
  10628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10629. }
  10630. m.SetDeletedAt(v)
  10631. return nil
  10632. case msg.FieldStatus:
  10633. v, ok := value.(uint8)
  10634. if !ok {
  10635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10636. }
  10637. m.SetStatus(v)
  10638. return nil
  10639. case msg.FieldFromwxid:
  10640. v, ok := value.(string)
  10641. if !ok {
  10642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10643. }
  10644. m.SetFromwxid(v)
  10645. return nil
  10646. case msg.FieldToid:
  10647. v, ok := value.(string)
  10648. if !ok {
  10649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10650. }
  10651. m.SetToid(v)
  10652. return nil
  10653. case msg.FieldMsgtype:
  10654. v, ok := value.(int32)
  10655. if !ok {
  10656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10657. }
  10658. m.SetMsgtype(v)
  10659. return nil
  10660. case msg.FieldMsg:
  10661. v, ok := value.(string)
  10662. if !ok {
  10663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10664. }
  10665. m.SetMsg(v)
  10666. return nil
  10667. case msg.FieldBatchNo:
  10668. v, ok := value.(string)
  10669. if !ok {
  10670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10671. }
  10672. m.SetBatchNo(v)
  10673. return nil
  10674. }
  10675. return fmt.Errorf("unknown Msg field %s", name)
  10676. }
  10677. // AddedFields returns all numeric fields that were incremented/decremented during
  10678. // this mutation.
  10679. func (m *MsgMutation) AddedFields() []string {
  10680. var fields []string
  10681. if m.addstatus != nil {
  10682. fields = append(fields, msg.FieldStatus)
  10683. }
  10684. if m.addmsgtype != nil {
  10685. fields = append(fields, msg.FieldMsgtype)
  10686. }
  10687. return fields
  10688. }
  10689. // AddedField returns the numeric value that was incremented/decremented on a field
  10690. // with the given name. The second boolean return value indicates that this field
  10691. // was not set, or was not defined in the schema.
  10692. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  10693. switch name {
  10694. case msg.FieldStatus:
  10695. return m.AddedStatus()
  10696. case msg.FieldMsgtype:
  10697. return m.AddedMsgtype()
  10698. }
  10699. return nil, false
  10700. }
  10701. // AddField adds the value to the field with the given name. It returns an error if
  10702. // the field is not defined in the schema, or if the type mismatched the field
  10703. // type.
  10704. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  10705. switch name {
  10706. case msg.FieldStatus:
  10707. v, ok := value.(int8)
  10708. if !ok {
  10709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10710. }
  10711. m.AddStatus(v)
  10712. return nil
  10713. case msg.FieldMsgtype:
  10714. v, ok := value.(int32)
  10715. if !ok {
  10716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10717. }
  10718. m.AddMsgtype(v)
  10719. return nil
  10720. }
  10721. return fmt.Errorf("unknown Msg numeric field %s", name)
  10722. }
  10723. // ClearedFields returns all nullable fields that were cleared during this
  10724. // mutation.
  10725. func (m *MsgMutation) ClearedFields() []string {
  10726. var fields []string
  10727. if m.FieldCleared(msg.FieldDeletedAt) {
  10728. fields = append(fields, msg.FieldDeletedAt)
  10729. }
  10730. if m.FieldCleared(msg.FieldStatus) {
  10731. fields = append(fields, msg.FieldStatus)
  10732. }
  10733. if m.FieldCleared(msg.FieldFromwxid) {
  10734. fields = append(fields, msg.FieldFromwxid)
  10735. }
  10736. if m.FieldCleared(msg.FieldToid) {
  10737. fields = append(fields, msg.FieldToid)
  10738. }
  10739. if m.FieldCleared(msg.FieldMsgtype) {
  10740. fields = append(fields, msg.FieldMsgtype)
  10741. }
  10742. if m.FieldCleared(msg.FieldMsg) {
  10743. fields = append(fields, msg.FieldMsg)
  10744. }
  10745. if m.FieldCleared(msg.FieldBatchNo) {
  10746. fields = append(fields, msg.FieldBatchNo)
  10747. }
  10748. return fields
  10749. }
  10750. // FieldCleared returns a boolean indicating if a field with the given name was
  10751. // cleared in this mutation.
  10752. func (m *MsgMutation) FieldCleared(name string) bool {
  10753. _, ok := m.clearedFields[name]
  10754. return ok
  10755. }
  10756. // ClearField clears the value of the field with the given name. It returns an
  10757. // error if the field is not defined in the schema.
  10758. func (m *MsgMutation) ClearField(name string) error {
  10759. switch name {
  10760. case msg.FieldDeletedAt:
  10761. m.ClearDeletedAt()
  10762. return nil
  10763. case msg.FieldStatus:
  10764. m.ClearStatus()
  10765. return nil
  10766. case msg.FieldFromwxid:
  10767. m.ClearFromwxid()
  10768. return nil
  10769. case msg.FieldToid:
  10770. m.ClearToid()
  10771. return nil
  10772. case msg.FieldMsgtype:
  10773. m.ClearMsgtype()
  10774. return nil
  10775. case msg.FieldMsg:
  10776. m.ClearMsg()
  10777. return nil
  10778. case msg.FieldBatchNo:
  10779. m.ClearBatchNo()
  10780. return nil
  10781. }
  10782. return fmt.Errorf("unknown Msg nullable field %s", name)
  10783. }
  10784. // ResetField resets all changes in the mutation for the field with the given name.
  10785. // It returns an error if the field is not defined in the schema.
  10786. func (m *MsgMutation) ResetField(name string) error {
  10787. switch name {
  10788. case msg.FieldCreatedAt:
  10789. m.ResetCreatedAt()
  10790. return nil
  10791. case msg.FieldUpdatedAt:
  10792. m.ResetUpdatedAt()
  10793. return nil
  10794. case msg.FieldDeletedAt:
  10795. m.ResetDeletedAt()
  10796. return nil
  10797. case msg.FieldStatus:
  10798. m.ResetStatus()
  10799. return nil
  10800. case msg.FieldFromwxid:
  10801. m.ResetFromwxid()
  10802. return nil
  10803. case msg.FieldToid:
  10804. m.ResetToid()
  10805. return nil
  10806. case msg.FieldMsgtype:
  10807. m.ResetMsgtype()
  10808. return nil
  10809. case msg.FieldMsg:
  10810. m.ResetMsg()
  10811. return nil
  10812. case msg.FieldBatchNo:
  10813. m.ResetBatchNo()
  10814. return nil
  10815. }
  10816. return fmt.Errorf("unknown Msg field %s", name)
  10817. }
  10818. // AddedEdges returns all edge names that were set/added in this mutation.
  10819. func (m *MsgMutation) AddedEdges() []string {
  10820. edges := make([]string, 0, 0)
  10821. return edges
  10822. }
  10823. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10824. // name in this mutation.
  10825. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  10826. return nil
  10827. }
  10828. // RemovedEdges returns all edge names that were removed in this mutation.
  10829. func (m *MsgMutation) RemovedEdges() []string {
  10830. edges := make([]string, 0, 0)
  10831. return edges
  10832. }
  10833. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10834. // the given name in this mutation.
  10835. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  10836. return nil
  10837. }
  10838. // ClearedEdges returns all edge names that were cleared in this mutation.
  10839. func (m *MsgMutation) ClearedEdges() []string {
  10840. edges := make([]string, 0, 0)
  10841. return edges
  10842. }
  10843. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10844. // was cleared in this mutation.
  10845. func (m *MsgMutation) EdgeCleared(name string) bool {
  10846. return false
  10847. }
  10848. // ClearEdge clears the value of the edge with the given name. It returns an error
  10849. // if that edge is not defined in the schema.
  10850. func (m *MsgMutation) ClearEdge(name string) error {
  10851. return fmt.Errorf("unknown Msg unique edge %s", name)
  10852. }
  10853. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10854. // It returns an error if the edge is not defined in the schema.
  10855. func (m *MsgMutation) ResetEdge(name string) error {
  10856. return fmt.Errorf("unknown Msg edge %s", name)
  10857. }
  10858. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  10859. type ServerMutation struct {
  10860. config
  10861. op Op
  10862. typ string
  10863. id *uint64
  10864. created_at *time.Time
  10865. updated_at *time.Time
  10866. status *uint8
  10867. addstatus *int8
  10868. deleted_at *time.Time
  10869. name *string
  10870. public_ip *string
  10871. private_ip *string
  10872. admin_port *string
  10873. clearedFields map[string]struct{}
  10874. wxs map[uint64]struct{}
  10875. removedwxs map[uint64]struct{}
  10876. clearedwxs bool
  10877. done bool
  10878. oldValue func(context.Context) (*Server, error)
  10879. predicates []predicate.Server
  10880. }
  10881. var _ ent.Mutation = (*ServerMutation)(nil)
  10882. // serverOption allows management of the mutation configuration using functional options.
  10883. type serverOption func(*ServerMutation)
  10884. // newServerMutation creates new mutation for the Server entity.
  10885. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  10886. m := &ServerMutation{
  10887. config: c,
  10888. op: op,
  10889. typ: TypeServer,
  10890. clearedFields: make(map[string]struct{}),
  10891. }
  10892. for _, opt := range opts {
  10893. opt(m)
  10894. }
  10895. return m
  10896. }
  10897. // withServerID sets the ID field of the mutation.
  10898. func withServerID(id uint64) serverOption {
  10899. return func(m *ServerMutation) {
  10900. var (
  10901. err error
  10902. once sync.Once
  10903. value *Server
  10904. )
  10905. m.oldValue = func(ctx context.Context) (*Server, error) {
  10906. once.Do(func() {
  10907. if m.done {
  10908. err = errors.New("querying old values post mutation is not allowed")
  10909. } else {
  10910. value, err = m.Client().Server.Get(ctx, id)
  10911. }
  10912. })
  10913. return value, err
  10914. }
  10915. m.id = &id
  10916. }
  10917. }
  10918. // withServer sets the old Server of the mutation.
  10919. func withServer(node *Server) serverOption {
  10920. return func(m *ServerMutation) {
  10921. m.oldValue = func(context.Context) (*Server, error) {
  10922. return node, nil
  10923. }
  10924. m.id = &node.ID
  10925. }
  10926. }
  10927. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10928. // executed in a transaction (ent.Tx), a transactional client is returned.
  10929. func (m ServerMutation) Client() *Client {
  10930. client := &Client{config: m.config}
  10931. client.init()
  10932. return client
  10933. }
  10934. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10935. // it returns an error otherwise.
  10936. func (m ServerMutation) Tx() (*Tx, error) {
  10937. if _, ok := m.driver.(*txDriver); !ok {
  10938. return nil, errors.New("ent: mutation is not running in a transaction")
  10939. }
  10940. tx := &Tx{config: m.config}
  10941. tx.init()
  10942. return tx, nil
  10943. }
  10944. // SetID sets the value of the id field. Note that this
  10945. // operation is only accepted on creation of Server entities.
  10946. func (m *ServerMutation) SetID(id uint64) {
  10947. m.id = &id
  10948. }
  10949. // ID returns the ID value in the mutation. Note that the ID is only available
  10950. // if it was provided to the builder or after it was returned from the database.
  10951. func (m *ServerMutation) ID() (id uint64, exists bool) {
  10952. if m.id == nil {
  10953. return
  10954. }
  10955. return *m.id, true
  10956. }
  10957. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10958. // That means, if the mutation is applied within a transaction with an isolation level such
  10959. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10960. // or updated by the mutation.
  10961. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  10962. switch {
  10963. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10964. id, exists := m.ID()
  10965. if exists {
  10966. return []uint64{id}, nil
  10967. }
  10968. fallthrough
  10969. case m.op.Is(OpUpdate | OpDelete):
  10970. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  10971. default:
  10972. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10973. }
  10974. }
  10975. // SetCreatedAt sets the "created_at" field.
  10976. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  10977. m.created_at = &t
  10978. }
  10979. // CreatedAt returns the value of the "created_at" field in the mutation.
  10980. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  10981. v := m.created_at
  10982. if v == nil {
  10983. return
  10984. }
  10985. return *v, true
  10986. }
  10987. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  10988. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  10989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10990. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10991. if !m.op.Is(OpUpdateOne) {
  10992. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10993. }
  10994. if m.id == nil || m.oldValue == nil {
  10995. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10996. }
  10997. oldValue, err := m.oldValue(ctx)
  10998. if err != nil {
  10999. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11000. }
  11001. return oldValue.CreatedAt, nil
  11002. }
  11003. // ResetCreatedAt resets all changes to the "created_at" field.
  11004. func (m *ServerMutation) ResetCreatedAt() {
  11005. m.created_at = nil
  11006. }
  11007. // SetUpdatedAt sets the "updated_at" field.
  11008. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  11009. m.updated_at = &t
  11010. }
  11011. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11012. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  11013. v := m.updated_at
  11014. if v == nil {
  11015. return
  11016. }
  11017. return *v, true
  11018. }
  11019. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  11020. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11021. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11022. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11023. if !m.op.Is(OpUpdateOne) {
  11024. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11025. }
  11026. if m.id == nil || m.oldValue == nil {
  11027. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11028. }
  11029. oldValue, err := m.oldValue(ctx)
  11030. if err != nil {
  11031. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11032. }
  11033. return oldValue.UpdatedAt, nil
  11034. }
  11035. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11036. func (m *ServerMutation) ResetUpdatedAt() {
  11037. m.updated_at = nil
  11038. }
  11039. // SetStatus sets the "status" field.
  11040. func (m *ServerMutation) SetStatus(u uint8) {
  11041. m.status = &u
  11042. m.addstatus = nil
  11043. }
  11044. // Status returns the value of the "status" field in the mutation.
  11045. func (m *ServerMutation) Status() (r uint8, exists bool) {
  11046. v := m.status
  11047. if v == nil {
  11048. return
  11049. }
  11050. return *v, true
  11051. }
  11052. // OldStatus returns the old "status" field's value of the Server entity.
  11053. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11055. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11056. if !m.op.Is(OpUpdateOne) {
  11057. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11058. }
  11059. if m.id == nil || m.oldValue == nil {
  11060. return v, errors.New("OldStatus requires an ID field in the mutation")
  11061. }
  11062. oldValue, err := m.oldValue(ctx)
  11063. if err != nil {
  11064. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11065. }
  11066. return oldValue.Status, nil
  11067. }
  11068. // AddStatus adds u to the "status" field.
  11069. func (m *ServerMutation) AddStatus(u int8) {
  11070. if m.addstatus != nil {
  11071. *m.addstatus += u
  11072. } else {
  11073. m.addstatus = &u
  11074. }
  11075. }
  11076. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11077. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  11078. v := m.addstatus
  11079. if v == nil {
  11080. return
  11081. }
  11082. return *v, true
  11083. }
  11084. // ClearStatus clears the value of the "status" field.
  11085. func (m *ServerMutation) ClearStatus() {
  11086. m.status = nil
  11087. m.addstatus = nil
  11088. m.clearedFields[server.FieldStatus] = struct{}{}
  11089. }
  11090. // StatusCleared returns if the "status" field was cleared in this mutation.
  11091. func (m *ServerMutation) StatusCleared() bool {
  11092. _, ok := m.clearedFields[server.FieldStatus]
  11093. return ok
  11094. }
  11095. // ResetStatus resets all changes to the "status" field.
  11096. func (m *ServerMutation) ResetStatus() {
  11097. m.status = nil
  11098. m.addstatus = nil
  11099. delete(m.clearedFields, server.FieldStatus)
  11100. }
  11101. // SetDeletedAt sets the "deleted_at" field.
  11102. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  11103. m.deleted_at = &t
  11104. }
  11105. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11106. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  11107. v := m.deleted_at
  11108. if v == nil {
  11109. return
  11110. }
  11111. return *v, true
  11112. }
  11113. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  11114. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11116. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11117. if !m.op.Is(OpUpdateOne) {
  11118. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11119. }
  11120. if m.id == nil || m.oldValue == nil {
  11121. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11122. }
  11123. oldValue, err := m.oldValue(ctx)
  11124. if err != nil {
  11125. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11126. }
  11127. return oldValue.DeletedAt, nil
  11128. }
  11129. // ClearDeletedAt clears the value of the "deleted_at" field.
  11130. func (m *ServerMutation) ClearDeletedAt() {
  11131. m.deleted_at = nil
  11132. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  11133. }
  11134. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11135. func (m *ServerMutation) DeletedAtCleared() bool {
  11136. _, ok := m.clearedFields[server.FieldDeletedAt]
  11137. return ok
  11138. }
  11139. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11140. func (m *ServerMutation) ResetDeletedAt() {
  11141. m.deleted_at = nil
  11142. delete(m.clearedFields, server.FieldDeletedAt)
  11143. }
  11144. // SetName sets the "name" field.
  11145. func (m *ServerMutation) SetName(s string) {
  11146. m.name = &s
  11147. }
  11148. // Name returns the value of the "name" field in the mutation.
  11149. func (m *ServerMutation) Name() (r string, exists bool) {
  11150. v := m.name
  11151. if v == nil {
  11152. return
  11153. }
  11154. return *v, true
  11155. }
  11156. // OldName returns the old "name" field's value of the Server entity.
  11157. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11159. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  11160. if !m.op.Is(OpUpdateOne) {
  11161. return v, errors.New("OldName is only allowed on UpdateOne operations")
  11162. }
  11163. if m.id == nil || m.oldValue == nil {
  11164. return v, errors.New("OldName requires an ID field in the mutation")
  11165. }
  11166. oldValue, err := m.oldValue(ctx)
  11167. if err != nil {
  11168. return v, fmt.Errorf("querying old value for OldName: %w", err)
  11169. }
  11170. return oldValue.Name, nil
  11171. }
  11172. // ResetName resets all changes to the "name" field.
  11173. func (m *ServerMutation) ResetName() {
  11174. m.name = nil
  11175. }
  11176. // SetPublicIP sets the "public_ip" field.
  11177. func (m *ServerMutation) SetPublicIP(s string) {
  11178. m.public_ip = &s
  11179. }
  11180. // PublicIP returns the value of the "public_ip" field in the mutation.
  11181. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  11182. v := m.public_ip
  11183. if v == nil {
  11184. return
  11185. }
  11186. return *v, true
  11187. }
  11188. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  11189. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11191. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  11192. if !m.op.Is(OpUpdateOne) {
  11193. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  11194. }
  11195. if m.id == nil || m.oldValue == nil {
  11196. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  11197. }
  11198. oldValue, err := m.oldValue(ctx)
  11199. if err != nil {
  11200. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  11201. }
  11202. return oldValue.PublicIP, nil
  11203. }
  11204. // ResetPublicIP resets all changes to the "public_ip" field.
  11205. func (m *ServerMutation) ResetPublicIP() {
  11206. m.public_ip = nil
  11207. }
  11208. // SetPrivateIP sets the "private_ip" field.
  11209. func (m *ServerMutation) SetPrivateIP(s string) {
  11210. m.private_ip = &s
  11211. }
  11212. // PrivateIP returns the value of the "private_ip" field in the mutation.
  11213. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  11214. v := m.private_ip
  11215. if v == nil {
  11216. return
  11217. }
  11218. return *v, true
  11219. }
  11220. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  11221. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11223. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  11224. if !m.op.Is(OpUpdateOne) {
  11225. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  11226. }
  11227. if m.id == nil || m.oldValue == nil {
  11228. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  11229. }
  11230. oldValue, err := m.oldValue(ctx)
  11231. if err != nil {
  11232. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  11233. }
  11234. return oldValue.PrivateIP, nil
  11235. }
  11236. // ResetPrivateIP resets all changes to the "private_ip" field.
  11237. func (m *ServerMutation) ResetPrivateIP() {
  11238. m.private_ip = nil
  11239. }
  11240. // SetAdminPort sets the "admin_port" field.
  11241. func (m *ServerMutation) SetAdminPort(s string) {
  11242. m.admin_port = &s
  11243. }
  11244. // AdminPort returns the value of the "admin_port" field in the mutation.
  11245. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  11246. v := m.admin_port
  11247. if v == nil {
  11248. return
  11249. }
  11250. return *v, true
  11251. }
  11252. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  11253. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11255. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  11256. if !m.op.Is(OpUpdateOne) {
  11257. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  11258. }
  11259. if m.id == nil || m.oldValue == nil {
  11260. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  11261. }
  11262. oldValue, err := m.oldValue(ctx)
  11263. if err != nil {
  11264. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  11265. }
  11266. return oldValue.AdminPort, nil
  11267. }
  11268. // ResetAdminPort resets all changes to the "admin_port" field.
  11269. func (m *ServerMutation) ResetAdminPort() {
  11270. m.admin_port = nil
  11271. }
  11272. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  11273. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  11274. if m.wxs == nil {
  11275. m.wxs = make(map[uint64]struct{})
  11276. }
  11277. for i := range ids {
  11278. m.wxs[ids[i]] = struct{}{}
  11279. }
  11280. }
  11281. // ClearWxs clears the "wxs" edge to the Wx entity.
  11282. func (m *ServerMutation) ClearWxs() {
  11283. m.clearedwxs = true
  11284. }
  11285. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  11286. func (m *ServerMutation) WxsCleared() bool {
  11287. return m.clearedwxs
  11288. }
  11289. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  11290. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  11291. if m.removedwxs == nil {
  11292. m.removedwxs = make(map[uint64]struct{})
  11293. }
  11294. for i := range ids {
  11295. delete(m.wxs, ids[i])
  11296. m.removedwxs[ids[i]] = struct{}{}
  11297. }
  11298. }
  11299. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  11300. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  11301. for id := range m.removedwxs {
  11302. ids = append(ids, id)
  11303. }
  11304. return
  11305. }
  11306. // WxsIDs returns the "wxs" edge IDs in the mutation.
  11307. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  11308. for id := range m.wxs {
  11309. ids = append(ids, id)
  11310. }
  11311. return
  11312. }
  11313. // ResetWxs resets all changes to the "wxs" edge.
  11314. func (m *ServerMutation) ResetWxs() {
  11315. m.wxs = nil
  11316. m.clearedwxs = false
  11317. m.removedwxs = nil
  11318. }
  11319. // Where appends a list predicates to the ServerMutation builder.
  11320. func (m *ServerMutation) Where(ps ...predicate.Server) {
  11321. m.predicates = append(m.predicates, ps...)
  11322. }
  11323. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  11324. // users can use type-assertion to append predicates that do not depend on any generated package.
  11325. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  11326. p := make([]predicate.Server, len(ps))
  11327. for i := range ps {
  11328. p[i] = ps[i]
  11329. }
  11330. m.Where(p...)
  11331. }
  11332. // Op returns the operation name.
  11333. func (m *ServerMutation) Op() Op {
  11334. return m.op
  11335. }
  11336. // SetOp allows setting the mutation operation.
  11337. func (m *ServerMutation) SetOp(op Op) {
  11338. m.op = op
  11339. }
  11340. // Type returns the node type of this mutation (Server).
  11341. func (m *ServerMutation) Type() string {
  11342. return m.typ
  11343. }
  11344. // Fields returns all fields that were changed during this mutation. Note that in
  11345. // order to get all numeric fields that were incremented/decremented, call
  11346. // AddedFields().
  11347. func (m *ServerMutation) Fields() []string {
  11348. fields := make([]string, 0, 8)
  11349. if m.created_at != nil {
  11350. fields = append(fields, server.FieldCreatedAt)
  11351. }
  11352. if m.updated_at != nil {
  11353. fields = append(fields, server.FieldUpdatedAt)
  11354. }
  11355. if m.status != nil {
  11356. fields = append(fields, server.FieldStatus)
  11357. }
  11358. if m.deleted_at != nil {
  11359. fields = append(fields, server.FieldDeletedAt)
  11360. }
  11361. if m.name != nil {
  11362. fields = append(fields, server.FieldName)
  11363. }
  11364. if m.public_ip != nil {
  11365. fields = append(fields, server.FieldPublicIP)
  11366. }
  11367. if m.private_ip != nil {
  11368. fields = append(fields, server.FieldPrivateIP)
  11369. }
  11370. if m.admin_port != nil {
  11371. fields = append(fields, server.FieldAdminPort)
  11372. }
  11373. return fields
  11374. }
  11375. // Field returns the value of a field with the given name. The second boolean
  11376. // return value indicates that this field was not set, or was not defined in the
  11377. // schema.
  11378. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  11379. switch name {
  11380. case server.FieldCreatedAt:
  11381. return m.CreatedAt()
  11382. case server.FieldUpdatedAt:
  11383. return m.UpdatedAt()
  11384. case server.FieldStatus:
  11385. return m.Status()
  11386. case server.FieldDeletedAt:
  11387. return m.DeletedAt()
  11388. case server.FieldName:
  11389. return m.Name()
  11390. case server.FieldPublicIP:
  11391. return m.PublicIP()
  11392. case server.FieldPrivateIP:
  11393. return m.PrivateIP()
  11394. case server.FieldAdminPort:
  11395. return m.AdminPort()
  11396. }
  11397. return nil, false
  11398. }
  11399. // OldField returns the old value of the field from the database. An error is
  11400. // returned if the mutation operation is not UpdateOne, or the query to the
  11401. // database failed.
  11402. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11403. switch name {
  11404. case server.FieldCreatedAt:
  11405. return m.OldCreatedAt(ctx)
  11406. case server.FieldUpdatedAt:
  11407. return m.OldUpdatedAt(ctx)
  11408. case server.FieldStatus:
  11409. return m.OldStatus(ctx)
  11410. case server.FieldDeletedAt:
  11411. return m.OldDeletedAt(ctx)
  11412. case server.FieldName:
  11413. return m.OldName(ctx)
  11414. case server.FieldPublicIP:
  11415. return m.OldPublicIP(ctx)
  11416. case server.FieldPrivateIP:
  11417. return m.OldPrivateIP(ctx)
  11418. case server.FieldAdminPort:
  11419. return m.OldAdminPort(ctx)
  11420. }
  11421. return nil, fmt.Errorf("unknown Server field %s", name)
  11422. }
  11423. // SetField sets the value of a field with the given name. It returns an error if
  11424. // the field is not defined in the schema, or if the type mismatched the field
  11425. // type.
  11426. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  11427. switch name {
  11428. case server.FieldCreatedAt:
  11429. v, ok := value.(time.Time)
  11430. if !ok {
  11431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11432. }
  11433. m.SetCreatedAt(v)
  11434. return nil
  11435. case server.FieldUpdatedAt:
  11436. v, ok := value.(time.Time)
  11437. if !ok {
  11438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11439. }
  11440. m.SetUpdatedAt(v)
  11441. return nil
  11442. case server.FieldStatus:
  11443. v, ok := value.(uint8)
  11444. if !ok {
  11445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11446. }
  11447. m.SetStatus(v)
  11448. return nil
  11449. case server.FieldDeletedAt:
  11450. v, ok := value.(time.Time)
  11451. if !ok {
  11452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11453. }
  11454. m.SetDeletedAt(v)
  11455. return nil
  11456. case server.FieldName:
  11457. v, ok := value.(string)
  11458. if !ok {
  11459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11460. }
  11461. m.SetName(v)
  11462. return nil
  11463. case server.FieldPublicIP:
  11464. v, ok := value.(string)
  11465. if !ok {
  11466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11467. }
  11468. m.SetPublicIP(v)
  11469. return nil
  11470. case server.FieldPrivateIP:
  11471. v, ok := value.(string)
  11472. if !ok {
  11473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11474. }
  11475. m.SetPrivateIP(v)
  11476. return nil
  11477. case server.FieldAdminPort:
  11478. v, ok := value.(string)
  11479. if !ok {
  11480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11481. }
  11482. m.SetAdminPort(v)
  11483. return nil
  11484. }
  11485. return fmt.Errorf("unknown Server field %s", name)
  11486. }
  11487. // AddedFields returns all numeric fields that were incremented/decremented during
  11488. // this mutation.
  11489. func (m *ServerMutation) AddedFields() []string {
  11490. var fields []string
  11491. if m.addstatus != nil {
  11492. fields = append(fields, server.FieldStatus)
  11493. }
  11494. return fields
  11495. }
  11496. // AddedField returns the numeric value that was incremented/decremented on a field
  11497. // with the given name. The second boolean return value indicates that this field
  11498. // was not set, or was not defined in the schema.
  11499. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  11500. switch name {
  11501. case server.FieldStatus:
  11502. return m.AddedStatus()
  11503. }
  11504. return nil, false
  11505. }
  11506. // AddField adds the value to the field with the given name. It returns an error if
  11507. // the field is not defined in the schema, or if the type mismatched the field
  11508. // type.
  11509. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  11510. switch name {
  11511. case server.FieldStatus:
  11512. v, ok := value.(int8)
  11513. if !ok {
  11514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11515. }
  11516. m.AddStatus(v)
  11517. return nil
  11518. }
  11519. return fmt.Errorf("unknown Server numeric field %s", name)
  11520. }
  11521. // ClearedFields returns all nullable fields that were cleared during this
  11522. // mutation.
  11523. func (m *ServerMutation) ClearedFields() []string {
  11524. var fields []string
  11525. if m.FieldCleared(server.FieldStatus) {
  11526. fields = append(fields, server.FieldStatus)
  11527. }
  11528. if m.FieldCleared(server.FieldDeletedAt) {
  11529. fields = append(fields, server.FieldDeletedAt)
  11530. }
  11531. return fields
  11532. }
  11533. // FieldCleared returns a boolean indicating if a field with the given name was
  11534. // cleared in this mutation.
  11535. func (m *ServerMutation) FieldCleared(name string) bool {
  11536. _, ok := m.clearedFields[name]
  11537. return ok
  11538. }
  11539. // ClearField clears the value of the field with the given name. It returns an
  11540. // error if the field is not defined in the schema.
  11541. func (m *ServerMutation) ClearField(name string) error {
  11542. switch name {
  11543. case server.FieldStatus:
  11544. m.ClearStatus()
  11545. return nil
  11546. case server.FieldDeletedAt:
  11547. m.ClearDeletedAt()
  11548. return nil
  11549. }
  11550. return fmt.Errorf("unknown Server nullable field %s", name)
  11551. }
  11552. // ResetField resets all changes in the mutation for the field with the given name.
  11553. // It returns an error if the field is not defined in the schema.
  11554. func (m *ServerMutation) ResetField(name string) error {
  11555. switch name {
  11556. case server.FieldCreatedAt:
  11557. m.ResetCreatedAt()
  11558. return nil
  11559. case server.FieldUpdatedAt:
  11560. m.ResetUpdatedAt()
  11561. return nil
  11562. case server.FieldStatus:
  11563. m.ResetStatus()
  11564. return nil
  11565. case server.FieldDeletedAt:
  11566. m.ResetDeletedAt()
  11567. return nil
  11568. case server.FieldName:
  11569. m.ResetName()
  11570. return nil
  11571. case server.FieldPublicIP:
  11572. m.ResetPublicIP()
  11573. return nil
  11574. case server.FieldPrivateIP:
  11575. m.ResetPrivateIP()
  11576. return nil
  11577. case server.FieldAdminPort:
  11578. m.ResetAdminPort()
  11579. return nil
  11580. }
  11581. return fmt.Errorf("unknown Server field %s", name)
  11582. }
  11583. // AddedEdges returns all edge names that were set/added in this mutation.
  11584. func (m *ServerMutation) AddedEdges() []string {
  11585. edges := make([]string, 0, 1)
  11586. if m.wxs != nil {
  11587. edges = append(edges, server.EdgeWxs)
  11588. }
  11589. return edges
  11590. }
  11591. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11592. // name in this mutation.
  11593. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  11594. switch name {
  11595. case server.EdgeWxs:
  11596. ids := make([]ent.Value, 0, len(m.wxs))
  11597. for id := range m.wxs {
  11598. ids = append(ids, id)
  11599. }
  11600. return ids
  11601. }
  11602. return nil
  11603. }
  11604. // RemovedEdges returns all edge names that were removed in this mutation.
  11605. func (m *ServerMutation) RemovedEdges() []string {
  11606. edges := make([]string, 0, 1)
  11607. if m.removedwxs != nil {
  11608. edges = append(edges, server.EdgeWxs)
  11609. }
  11610. return edges
  11611. }
  11612. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11613. // the given name in this mutation.
  11614. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  11615. switch name {
  11616. case server.EdgeWxs:
  11617. ids := make([]ent.Value, 0, len(m.removedwxs))
  11618. for id := range m.removedwxs {
  11619. ids = append(ids, id)
  11620. }
  11621. return ids
  11622. }
  11623. return nil
  11624. }
  11625. // ClearedEdges returns all edge names that were cleared in this mutation.
  11626. func (m *ServerMutation) ClearedEdges() []string {
  11627. edges := make([]string, 0, 1)
  11628. if m.clearedwxs {
  11629. edges = append(edges, server.EdgeWxs)
  11630. }
  11631. return edges
  11632. }
  11633. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11634. // was cleared in this mutation.
  11635. func (m *ServerMutation) EdgeCleared(name string) bool {
  11636. switch name {
  11637. case server.EdgeWxs:
  11638. return m.clearedwxs
  11639. }
  11640. return false
  11641. }
  11642. // ClearEdge clears the value of the edge with the given name. It returns an error
  11643. // if that edge is not defined in the schema.
  11644. func (m *ServerMutation) ClearEdge(name string) error {
  11645. switch name {
  11646. }
  11647. return fmt.Errorf("unknown Server unique edge %s", name)
  11648. }
  11649. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11650. // It returns an error if the edge is not defined in the schema.
  11651. func (m *ServerMutation) ResetEdge(name string) error {
  11652. switch name {
  11653. case server.EdgeWxs:
  11654. m.ResetWxs()
  11655. return nil
  11656. }
  11657. return fmt.Errorf("unknown Server edge %s", name)
  11658. }
  11659. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  11660. type SopNodeMutation struct {
  11661. config
  11662. op Op
  11663. typ string
  11664. id *uint64
  11665. created_at *time.Time
  11666. updated_at *time.Time
  11667. status *uint8
  11668. addstatus *int8
  11669. deleted_at *time.Time
  11670. parent_id *uint64
  11671. addparent_id *int64
  11672. name *string
  11673. condition_type *int
  11674. addcondition_type *int
  11675. condition_list *[]string
  11676. appendcondition_list []string
  11677. no_reply_condition *uint64
  11678. addno_reply_condition *int64
  11679. action_message *[]custom_types.Action
  11680. appendaction_message []custom_types.Action
  11681. action_label *[]uint64
  11682. appendaction_label []uint64
  11683. clearedFields map[string]struct{}
  11684. sop_stage *uint64
  11685. clearedsop_stage bool
  11686. node_messages map[uint64]struct{}
  11687. removednode_messages map[uint64]struct{}
  11688. clearednode_messages bool
  11689. done bool
  11690. oldValue func(context.Context) (*SopNode, error)
  11691. predicates []predicate.SopNode
  11692. }
  11693. var _ ent.Mutation = (*SopNodeMutation)(nil)
  11694. // sopnodeOption allows management of the mutation configuration using functional options.
  11695. type sopnodeOption func(*SopNodeMutation)
  11696. // newSopNodeMutation creates new mutation for the SopNode entity.
  11697. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  11698. m := &SopNodeMutation{
  11699. config: c,
  11700. op: op,
  11701. typ: TypeSopNode,
  11702. clearedFields: make(map[string]struct{}),
  11703. }
  11704. for _, opt := range opts {
  11705. opt(m)
  11706. }
  11707. return m
  11708. }
  11709. // withSopNodeID sets the ID field of the mutation.
  11710. func withSopNodeID(id uint64) sopnodeOption {
  11711. return func(m *SopNodeMutation) {
  11712. var (
  11713. err error
  11714. once sync.Once
  11715. value *SopNode
  11716. )
  11717. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  11718. once.Do(func() {
  11719. if m.done {
  11720. err = errors.New("querying old values post mutation is not allowed")
  11721. } else {
  11722. value, err = m.Client().SopNode.Get(ctx, id)
  11723. }
  11724. })
  11725. return value, err
  11726. }
  11727. m.id = &id
  11728. }
  11729. }
  11730. // withSopNode sets the old SopNode of the mutation.
  11731. func withSopNode(node *SopNode) sopnodeOption {
  11732. return func(m *SopNodeMutation) {
  11733. m.oldValue = func(context.Context) (*SopNode, error) {
  11734. return node, nil
  11735. }
  11736. m.id = &node.ID
  11737. }
  11738. }
  11739. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11740. // executed in a transaction (ent.Tx), a transactional client is returned.
  11741. func (m SopNodeMutation) Client() *Client {
  11742. client := &Client{config: m.config}
  11743. client.init()
  11744. return client
  11745. }
  11746. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11747. // it returns an error otherwise.
  11748. func (m SopNodeMutation) Tx() (*Tx, error) {
  11749. if _, ok := m.driver.(*txDriver); !ok {
  11750. return nil, errors.New("ent: mutation is not running in a transaction")
  11751. }
  11752. tx := &Tx{config: m.config}
  11753. tx.init()
  11754. return tx, nil
  11755. }
  11756. // SetID sets the value of the id field. Note that this
  11757. // operation is only accepted on creation of SopNode entities.
  11758. func (m *SopNodeMutation) SetID(id uint64) {
  11759. m.id = &id
  11760. }
  11761. // ID returns the ID value in the mutation. Note that the ID is only available
  11762. // if it was provided to the builder or after it was returned from the database.
  11763. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  11764. if m.id == nil {
  11765. return
  11766. }
  11767. return *m.id, true
  11768. }
  11769. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11770. // That means, if the mutation is applied within a transaction with an isolation level such
  11771. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11772. // or updated by the mutation.
  11773. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  11774. switch {
  11775. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11776. id, exists := m.ID()
  11777. if exists {
  11778. return []uint64{id}, nil
  11779. }
  11780. fallthrough
  11781. case m.op.Is(OpUpdate | OpDelete):
  11782. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  11783. default:
  11784. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11785. }
  11786. }
  11787. // SetCreatedAt sets the "created_at" field.
  11788. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  11789. m.created_at = &t
  11790. }
  11791. // CreatedAt returns the value of the "created_at" field in the mutation.
  11792. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  11793. v := m.created_at
  11794. if v == nil {
  11795. return
  11796. }
  11797. return *v, true
  11798. }
  11799. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  11800. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11802. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11803. if !m.op.Is(OpUpdateOne) {
  11804. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11805. }
  11806. if m.id == nil || m.oldValue == nil {
  11807. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11808. }
  11809. oldValue, err := m.oldValue(ctx)
  11810. if err != nil {
  11811. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11812. }
  11813. return oldValue.CreatedAt, nil
  11814. }
  11815. // ResetCreatedAt resets all changes to the "created_at" field.
  11816. func (m *SopNodeMutation) ResetCreatedAt() {
  11817. m.created_at = nil
  11818. }
  11819. // SetUpdatedAt sets the "updated_at" field.
  11820. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  11821. m.updated_at = &t
  11822. }
  11823. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11824. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  11825. v := m.updated_at
  11826. if v == nil {
  11827. return
  11828. }
  11829. return *v, true
  11830. }
  11831. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  11832. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11834. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11835. if !m.op.Is(OpUpdateOne) {
  11836. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11837. }
  11838. if m.id == nil || m.oldValue == nil {
  11839. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11840. }
  11841. oldValue, err := m.oldValue(ctx)
  11842. if err != nil {
  11843. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11844. }
  11845. return oldValue.UpdatedAt, nil
  11846. }
  11847. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11848. func (m *SopNodeMutation) ResetUpdatedAt() {
  11849. m.updated_at = nil
  11850. }
  11851. // SetStatus sets the "status" field.
  11852. func (m *SopNodeMutation) SetStatus(u uint8) {
  11853. m.status = &u
  11854. m.addstatus = nil
  11855. }
  11856. // Status returns the value of the "status" field in the mutation.
  11857. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  11858. v := m.status
  11859. if v == nil {
  11860. return
  11861. }
  11862. return *v, true
  11863. }
  11864. // OldStatus returns the old "status" field's value of the SopNode entity.
  11865. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11867. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11868. if !m.op.Is(OpUpdateOne) {
  11869. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11870. }
  11871. if m.id == nil || m.oldValue == nil {
  11872. return v, errors.New("OldStatus requires an ID field in the mutation")
  11873. }
  11874. oldValue, err := m.oldValue(ctx)
  11875. if err != nil {
  11876. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11877. }
  11878. return oldValue.Status, nil
  11879. }
  11880. // AddStatus adds u to the "status" field.
  11881. func (m *SopNodeMutation) AddStatus(u int8) {
  11882. if m.addstatus != nil {
  11883. *m.addstatus += u
  11884. } else {
  11885. m.addstatus = &u
  11886. }
  11887. }
  11888. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11889. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  11890. v := m.addstatus
  11891. if v == nil {
  11892. return
  11893. }
  11894. return *v, true
  11895. }
  11896. // ClearStatus clears the value of the "status" field.
  11897. func (m *SopNodeMutation) ClearStatus() {
  11898. m.status = nil
  11899. m.addstatus = nil
  11900. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  11901. }
  11902. // StatusCleared returns if the "status" field was cleared in this mutation.
  11903. func (m *SopNodeMutation) StatusCleared() bool {
  11904. _, ok := m.clearedFields[sopnode.FieldStatus]
  11905. return ok
  11906. }
  11907. // ResetStatus resets all changes to the "status" field.
  11908. func (m *SopNodeMutation) ResetStatus() {
  11909. m.status = nil
  11910. m.addstatus = nil
  11911. delete(m.clearedFields, sopnode.FieldStatus)
  11912. }
  11913. // SetDeletedAt sets the "deleted_at" field.
  11914. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  11915. m.deleted_at = &t
  11916. }
  11917. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11918. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  11919. v := m.deleted_at
  11920. if v == nil {
  11921. return
  11922. }
  11923. return *v, true
  11924. }
  11925. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  11926. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11927. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11928. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11929. if !m.op.Is(OpUpdateOne) {
  11930. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11931. }
  11932. if m.id == nil || m.oldValue == nil {
  11933. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11934. }
  11935. oldValue, err := m.oldValue(ctx)
  11936. if err != nil {
  11937. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11938. }
  11939. return oldValue.DeletedAt, nil
  11940. }
  11941. // ClearDeletedAt clears the value of the "deleted_at" field.
  11942. func (m *SopNodeMutation) ClearDeletedAt() {
  11943. m.deleted_at = nil
  11944. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  11945. }
  11946. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11947. func (m *SopNodeMutation) DeletedAtCleared() bool {
  11948. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  11949. return ok
  11950. }
  11951. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11952. func (m *SopNodeMutation) ResetDeletedAt() {
  11953. m.deleted_at = nil
  11954. delete(m.clearedFields, sopnode.FieldDeletedAt)
  11955. }
  11956. // SetStageID sets the "stage_id" field.
  11957. func (m *SopNodeMutation) SetStageID(u uint64) {
  11958. m.sop_stage = &u
  11959. }
  11960. // StageID returns the value of the "stage_id" field in the mutation.
  11961. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  11962. v := m.sop_stage
  11963. if v == nil {
  11964. return
  11965. }
  11966. return *v, true
  11967. }
  11968. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  11969. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11971. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  11972. if !m.op.Is(OpUpdateOne) {
  11973. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  11974. }
  11975. if m.id == nil || m.oldValue == nil {
  11976. return v, errors.New("OldStageID requires an ID field in the mutation")
  11977. }
  11978. oldValue, err := m.oldValue(ctx)
  11979. if err != nil {
  11980. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  11981. }
  11982. return oldValue.StageID, nil
  11983. }
  11984. // ResetStageID resets all changes to the "stage_id" field.
  11985. func (m *SopNodeMutation) ResetStageID() {
  11986. m.sop_stage = nil
  11987. }
  11988. // SetParentID sets the "parent_id" field.
  11989. func (m *SopNodeMutation) SetParentID(u uint64) {
  11990. m.parent_id = &u
  11991. m.addparent_id = nil
  11992. }
  11993. // ParentID returns the value of the "parent_id" field in the mutation.
  11994. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  11995. v := m.parent_id
  11996. if v == nil {
  11997. return
  11998. }
  11999. return *v, true
  12000. }
  12001. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  12002. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12004. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  12005. if !m.op.Is(OpUpdateOne) {
  12006. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  12007. }
  12008. if m.id == nil || m.oldValue == nil {
  12009. return v, errors.New("OldParentID requires an ID field in the mutation")
  12010. }
  12011. oldValue, err := m.oldValue(ctx)
  12012. if err != nil {
  12013. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  12014. }
  12015. return oldValue.ParentID, nil
  12016. }
  12017. // AddParentID adds u to the "parent_id" field.
  12018. func (m *SopNodeMutation) AddParentID(u int64) {
  12019. if m.addparent_id != nil {
  12020. *m.addparent_id += u
  12021. } else {
  12022. m.addparent_id = &u
  12023. }
  12024. }
  12025. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  12026. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  12027. v := m.addparent_id
  12028. if v == nil {
  12029. return
  12030. }
  12031. return *v, true
  12032. }
  12033. // ResetParentID resets all changes to the "parent_id" field.
  12034. func (m *SopNodeMutation) ResetParentID() {
  12035. m.parent_id = nil
  12036. m.addparent_id = nil
  12037. }
  12038. // SetName sets the "name" field.
  12039. func (m *SopNodeMutation) SetName(s string) {
  12040. m.name = &s
  12041. }
  12042. // Name returns the value of the "name" field in the mutation.
  12043. func (m *SopNodeMutation) Name() (r string, exists bool) {
  12044. v := m.name
  12045. if v == nil {
  12046. return
  12047. }
  12048. return *v, true
  12049. }
  12050. // OldName returns the old "name" field's value of the SopNode entity.
  12051. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12053. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  12054. if !m.op.Is(OpUpdateOne) {
  12055. return v, errors.New("OldName is only allowed on UpdateOne operations")
  12056. }
  12057. if m.id == nil || m.oldValue == nil {
  12058. return v, errors.New("OldName requires an ID field in the mutation")
  12059. }
  12060. oldValue, err := m.oldValue(ctx)
  12061. if err != nil {
  12062. return v, fmt.Errorf("querying old value for OldName: %w", err)
  12063. }
  12064. return oldValue.Name, nil
  12065. }
  12066. // ResetName resets all changes to the "name" field.
  12067. func (m *SopNodeMutation) ResetName() {
  12068. m.name = nil
  12069. }
  12070. // SetConditionType sets the "condition_type" field.
  12071. func (m *SopNodeMutation) SetConditionType(i int) {
  12072. m.condition_type = &i
  12073. m.addcondition_type = nil
  12074. }
  12075. // ConditionType returns the value of the "condition_type" field in the mutation.
  12076. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  12077. v := m.condition_type
  12078. if v == nil {
  12079. return
  12080. }
  12081. return *v, true
  12082. }
  12083. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  12084. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12086. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  12087. if !m.op.Is(OpUpdateOne) {
  12088. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  12089. }
  12090. if m.id == nil || m.oldValue == nil {
  12091. return v, errors.New("OldConditionType requires an ID field in the mutation")
  12092. }
  12093. oldValue, err := m.oldValue(ctx)
  12094. if err != nil {
  12095. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  12096. }
  12097. return oldValue.ConditionType, nil
  12098. }
  12099. // AddConditionType adds i to the "condition_type" field.
  12100. func (m *SopNodeMutation) AddConditionType(i int) {
  12101. if m.addcondition_type != nil {
  12102. *m.addcondition_type += i
  12103. } else {
  12104. m.addcondition_type = &i
  12105. }
  12106. }
  12107. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  12108. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  12109. v := m.addcondition_type
  12110. if v == nil {
  12111. return
  12112. }
  12113. return *v, true
  12114. }
  12115. // ResetConditionType resets all changes to the "condition_type" field.
  12116. func (m *SopNodeMutation) ResetConditionType() {
  12117. m.condition_type = nil
  12118. m.addcondition_type = nil
  12119. }
  12120. // SetConditionList sets the "condition_list" field.
  12121. func (m *SopNodeMutation) SetConditionList(s []string) {
  12122. m.condition_list = &s
  12123. m.appendcondition_list = nil
  12124. }
  12125. // ConditionList returns the value of the "condition_list" field in the mutation.
  12126. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  12127. v := m.condition_list
  12128. if v == nil {
  12129. return
  12130. }
  12131. return *v, true
  12132. }
  12133. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  12134. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12136. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  12137. if !m.op.Is(OpUpdateOne) {
  12138. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  12139. }
  12140. if m.id == nil || m.oldValue == nil {
  12141. return v, errors.New("OldConditionList requires an ID field in the mutation")
  12142. }
  12143. oldValue, err := m.oldValue(ctx)
  12144. if err != nil {
  12145. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  12146. }
  12147. return oldValue.ConditionList, nil
  12148. }
  12149. // AppendConditionList adds s to the "condition_list" field.
  12150. func (m *SopNodeMutation) AppendConditionList(s []string) {
  12151. m.appendcondition_list = append(m.appendcondition_list, s...)
  12152. }
  12153. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  12154. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  12155. if len(m.appendcondition_list) == 0 {
  12156. return nil, false
  12157. }
  12158. return m.appendcondition_list, true
  12159. }
  12160. // ClearConditionList clears the value of the "condition_list" field.
  12161. func (m *SopNodeMutation) ClearConditionList() {
  12162. m.condition_list = nil
  12163. m.appendcondition_list = nil
  12164. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  12165. }
  12166. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  12167. func (m *SopNodeMutation) ConditionListCleared() bool {
  12168. _, ok := m.clearedFields[sopnode.FieldConditionList]
  12169. return ok
  12170. }
  12171. // ResetConditionList resets all changes to the "condition_list" field.
  12172. func (m *SopNodeMutation) ResetConditionList() {
  12173. m.condition_list = nil
  12174. m.appendcondition_list = nil
  12175. delete(m.clearedFields, sopnode.FieldConditionList)
  12176. }
  12177. // SetNoReplyCondition sets the "no_reply_condition" field.
  12178. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  12179. m.no_reply_condition = &u
  12180. m.addno_reply_condition = nil
  12181. }
  12182. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  12183. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  12184. v := m.no_reply_condition
  12185. if v == nil {
  12186. return
  12187. }
  12188. return *v, true
  12189. }
  12190. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  12191. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12193. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  12194. if !m.op.Is(OpUpdateOne) {
  12195. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  12196. }
  12197. if m.id == nil || m.oldValue == nil {
  12198. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  12199. }
  12200. oldValue, err := m.oldValue(ctx)
  12201. if err != nil {
  12202. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  12203. }
  12204. return oldValue.NoReplyCondition, nil
  12205. }
  12206. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  12207. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  12208. if m.addno_reply_condition != nil {
  12209. *m.addno_reply_condition += u
  12210. } else {
  12211. m.addno_reply_condition = &u
  12212. }
  12213. }
  12214. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  12215. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  12216. v := m.addno_reply_condition
  12217. if v == nil {
  12218. return
  12219. }
  12220. return *v, true
  12221. }
  12222. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  12223. func (m *SopNodeMutation) ResetNoReplyCondition() {
  12224. m.no_reply_condition = nil
  12225. m.addno_reply_condition = nil
  12226. }
  12227. // SetActionMessage sets the "action_message" field.
  12228. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  12229. m.action_message = &ct
  12230. m.appendaction_message = nil
  12231. }
  12232. // ActionMessage returns the value of the "action_message" field in the mutation.
  12233. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  12234. v := m.action_message
  12235. if v == nil {
  12236. return
  12237. }
  12238. return *v, true
  12239. }
  12240. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  12241. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12243. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  12244. if !m.op.Is(OpUpdateOne) {
  12245. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  12246. }
  12247. if m.id == nil || m.oldValue == nil {
  12248. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  12249. }
  12250. oldValue, err := m.oldValue(ctx)
  12251. if err != nil {
  12252. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  12253. }
  12254. return oldValue.ActionMessage, nil
  12255. }
  12256. // AppendActionMessage adds ct to the "action_message" field.
  12257. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  12258. m.appendaction_message = append(m.appendaction_message, ct...)
  12259. }
  12260. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  12261. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  12262. if len(m.appendaction_message) == 0 {
  12263. return nil, false
  12264. }
  12265. return m.appendaction_message, true
  12266. }
  12267. // ClearActionMessage clears the value of the "action_message" field.
  12268. func (m *SopNodeMutation) ClearActionMessage() {
  12269. m.action_message = nil
  12270. m.appendaction_message = nil
  12271. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  12272. }
  12273. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  12274. func (m *SopNodeMutation) ActionMessageCleared() bool {
  12275. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  12276. return ok
  12277. }
  12278. // ResetActionMessage resets all changes to the "action_message" field.
  12279. func (m *SopNodeMutation) ResetActionMessage() {
  12280. m.action_message = nil
  12281. m.appendaction_message = nil
  12282. delete(m.clearedFields, sopnode.FieldActionMessage)
  12283. }
  12284. // SetActionLabel sets the "action_label" field.
  12285. func (m *SopNodeMutation) SetActionLabel(u []uint64) {
  12286. m.action_label = &u
  12287. m.appendaction_label = nil
  12288. }
  12289. // ActionLabel returns the value of the "action_label" field in the mutation.
  12290. func (m *SopNodeMutation) ActionLabel() (r []uint64, exists bool) {
  12291. v := m.action_label
  12292. if v == nil {
  12293. return
  12294. }
  12295. return *v, true
  12296. }
  12297. // OldActionLabel returns the old "action_label" field's value of the SopNode entity.
  12298. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12300. func (m *SopNodeMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  12301. if !m.op.Is(OpUpdateOne) {
  12302. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  12303. }
  12304. if m.id == nil || m.oldValue == nil {
  12305. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  12306. }
  12307. oldValue, err := m.oldValue(ctx)
  12308. if err != nil {
  12309. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  12310. }
  12311. return oldValue.ActionLabel, nil
  12312. }
  12313. // AppendActionLabel adds u to the "action_label" field.
  12314. func (m *SopNodeMutation) AppendActionLabel(u []uint64) {
  12315. m.appendaction_label = append(m.appendaction_label, u...)
  12316. }
  12317. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  12318. func (m *SopNodeMutation) AppendedActionLabel() ([]uint64, bool) {
  12319. if len(m.appendaction_label) == 0 {
  12320. return nil, false
  12321. }
  12322. return m.appendaction_label, true
  12323. }
  12324. // ClearActionLabel clears the value of the "action_label" field.
  12325. func (m *SopNodeMutation) ClearActionLabel() {
  12326. m.action_label = nil
  12327. m.appendaction_label = nil
  12328. m.clearedFields[sopnode.FieldActionLabel] = struct{}{}
  12329. }
  12330. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  12331. func (m *SopNodeMutation) ActionLabelCleared() bool {
  12332. _, ok := m.clearedFields[sopnode.FieldActionLabel]
  12333. return ok
  12334. }
  12335. // ResetActionLabel resets all changes to the "action_label" field.
  12336. func (m *SopNodeMutation) ResetActionLabel() {
  12337. m.action_label = nil
  12338. m.appendaction_label = nil
  12339. delete(m.clearedFields, sopnode.FieldActionLabel)
  12340. }
  12341. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  12342. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  12343. m.sop_stage = &id
  12344. }
  12345. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  12346. func (m *SopNodeMutation) ClearSopStage() {
  12347. m.clearedsop_stage = true
  12348. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  12349. }
  12350. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  12351. func (m *SopNodeMutation) SopStageCleared() bool {
  12352. return m.clearedsop_stage
  12353. }
  12354. // SopStageID returns the "sop_stage" edge ID in the mutation.
  12355. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  12356. if m.sop_stage != nil {
  12357. return *m.sop_stage, true
  12358. }
  12359. return
  12360. }
  12361. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  12362. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12363. // SopStageID instead. It exists only for internal usage by the builders.
  12364. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  12365. if id := m.sop_stage; id != nil {
  12366. ids = append(ids, *id)
  12367. }
  12368. return
  12369. }
  12370. // ResetSopStage resets all changes to the "sop_stage" edge.
  12371. func (m *SopNodeMutation) ResetSopStage() {
  12372. m.sop_stage = nil
  12373. m.clearedsop_stage = false
  12374. }
  12375. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  12376. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  12377. if m.node_messages == nil {
  12378. m.node_messages = make(map[uint64]struct{})
  12379. }
  12380. for i := range ids {
  12381. m.node_messages[ids[i]] = struct{}{}
  12382. }
  12383. }
  12384. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  12385. func (m *SopNodeMutation) ClearNodeMessages() {
  12386. m.clearednode_messages = true
  12387. }
  12388. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  12389. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  12390. return m.clearednode_messages
  12391. }
  12392. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  12393. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  12394. if m.removednode_messages == nil {
  12395. m.removednode_messages = make(map[uint64]struct{})
  12396. }
  12397. for i := range ids {
  12398. delete(m.node_messages, ids[i])
  12399. m.removednode_messages[ids[i]] = struct{}{}
  12400. }
  12401. }
  12402. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  12403. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  12404. for id := range m.removednode_messages {
  12405. ids = append(ids, id)
  12406. }
  12407. return
  12408. }
  12409. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  12410. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  12411. for id := range m.node_messages {
  12412. ids = append(ids, id)
  12413. }
  12414. return
  12415. }
  12416. // ResetNodeMessages resets all changes to the "node_messages" edge.
  12417. func (m *SopNodeMutation) ResetNodeMessages() {
  12418. m.node_messages = nil
  12419. m.clearednode_messages = false
  12420. m.removednode_messages = nil
  12421. }
  12422. // Where appends a list predicates to the SopNodeMutation builder.
  12423. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  12424. m.predicates = append(m.predicates, ps...)
  12425. }
  12426. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  12427. // users can use type-assertion to append predicates that do not depend on any generated package.
  12428. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  12429. p := make([]predicate.SopNode, len(ps))
  12430. for i := range ps {
  12431. p[i] = ps[i]
  12432. }
  12433. m.Where(p...)
  12434. }
  12435. // Op returns the operation name.
  12436. func (m *SopNodeMutation) Op() Op {
  12437. return m.op
  12438. }
  12439. // SetOp allows setting the mutation operation.
  12440. func (m *SopNodeMutation) SetOp(op Op) {
  12441. m.op = op
  12442. }
  12443. // Type returns the node type of this mutation (SopNode).
  12444. func (m *SopNodeMutation) Type() string {
  12445. return m.typ
  12446. }
  12447. // Fields returns all fields that were changed during this mutation. Note that in
  12448. // order to get all numeric fields that were incremented/decremented, call
  12449. // AddedFields().
  12450. func (m *SopNodeMutation) Fields() []string {
  12451. fields := make([]string, 0, 12)
  12452. if m.created_at != nil {
  12453. fields = append(fields, sopnode.FieldCreatedAt)
  12454. }
  12455. if m.updated_at != nil {
  12456. fields = append(fields, sopnode.FieldUpdatedAt)
  12457. }
  12458. if m.status != nil {
  12459. fields = append(fields, sopnode.FieldStatus)
  12460. }
  12461. if m.deleted_at != nil {
  12462. fields = append(fields, sopnode.FieldDeletedAt)
  12463. }
  12464. if m.sop_stage != nil {
  12465. fields = append(fields, sopnode.FieldStageID)
  12466. }
  12467. if m.parent_id != nil {
  12468. fields = append(fields, sopnode.FieldParentID)
  12469. }
  12470. if m.name != nil {
  12471. fields = append(fields, sopnode.FieldName)
  12472. }
  12473. if m.condition_type != nil {
  12474. fields = append(fields, sopnode.FieldConditionType)
  12475. }
  12476. if m.condition_list != nil {
  12477. fields = append(fields, sopnode.FieldConditionList)
  12478. }
  12479. if m.no_reply_condition != nil {
  12480. fields = append(fields, sopnode.FieldNoReplyCondition)
  12481. }
  12482. if m.action_message != nil {
  12483. fields = append(fields, sopnode.FieldActionMessage)
  12484. }
  12485. if m.action_label != nil {
  12486. fields = append(fields, sopnode.FieldActionLabel)
  12487. }
  12488. return fields
  12489. }
  12490. // Field returns the value of a field with the given name. The second boolean
  12491. // return value indicates that this field was not set, or was not defined in the
  12492. // schema.
  12493. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  12494. switch name {
  12495. case sopnode.FieldCreatedAt:
  12496. return m.CreatedAt()
  12497. case sopnode.FieldUpdatedAt:
  12498. return m.UpdatedAt()
  12499. case sopnode.FieldStatus:
  12500. return m.Status()
  12501. case sopnode.FieldDeletedAt:
  12502. return m.DeletedAt()
  12503. case sopnode.FieldStageID:
  12504. return m.StageID()
  12505. case sopnode.FieldParentID:
  12506. return m.ParentID()
  12507. case sopnode.FieldName:
  12508. return m.Name()
  12509. case sopnode.FieldConditionType:
  12510. return m.ConditionType()
  12511. case sopnode.FieldConditionList:
  12512. return m.ConditionList()
  12513. case sopnode.FieldNoReplyCondition:
  12514. return m.NoReplyCondition()
  12515. case sopnode.FieldActionMessage:
  12516. return m.ActionMessage()
  12517. case sopnode.FieldActionLabel:
  12518. return m.ActionLabel()
  12519. }
  12520. return nil, false
  12521. }
  12522. // OldField returns the old value of the field from the database. An error is
  12523. // returned if the mutation operation is not UpdateOne, or the query to the
  12524. // database failed.
  12525. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12526. switch name {
  12527. case sopnode.FieldCreatedAt:
  12528. return m.OldCreatedAt(ctx)
  12529. case sopnode.FieldUpdatedAt:
  12530. return m.OldUpdatedAt(ctx)
  12531. case sopnode.FieldStatus:
  12532. return m.OldStatus(ctx)
  12533. case sopnode.FieldDeletedAt:
  12534. return m.OldDeletedAt(ctx)
  12535. case sopnode.FieldStageID:
  12536. return m.OldStageID(ctx)
  12537. case sopnode.FieldParentID:
  12538. return m.OldParentID(ctx)
  12539. case sopnode.FieldName:
  12540. return m.OldName(ctx)
  12541. case sopnode.FieldConditionType:
  12542. return m.OldConditionType(ctx)
  12543. case sopnode.FieldConditionList:
  12544. return m.OldConditionList(ctx)
  12545. case sopnode.FieldNoReplyCondition:
  12546. return m.OldNoReplyCondition(ctx)
  12547. case sopnode.FieldActionMessage:
  12548. return m.OldActionMessage(ctx)
  12549. case sopnode.FieldActionLabel:
  12550. return m.OldActionLabel(ctx)
  12551. }
  12552. return nil, fmt.Errorf("unknown SopNode field %s", name)
  12553. }
  12554. // SetField sets the value of a field with the given name. It returns an error if
  12555. // the field is not defined in the schema, or if the type mismatched the field
  12556. // type.
  12557. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  12558. switch name {
  12559. case sopnode.FieldCreatedAt:
  12560. v, ok := value.(time.Time)
  12561. if !ok {
  12562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12563. }
  12564. m.SetCreatedAt(v)
  12565. return nil
  12566. case sopnode.FieldUpdatedAt:
  12567. v, ok := value.(time.Time)
  12568. if !ok {
  12569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12570. }
  12571. m.SetUpdatedAt(v)
  12572. return nil
  12573. case sopnode.FieldStatus:
  12574. v, ok := value.(uint8)
  12575. if !ok {
  12576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12577. }
  12578. m.SetStatus(v)
  12579. return nil
  12580. case sopnode.FieldDeletedAt:
  12581. v, ok := value.(time.Time)
  12582. if !ok {
  12583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12584. }
  12585. m.SetDeletedAt(v)
  12586. return nil
  12587. case sopnode.FieldStageID:
  12588. v, ok := value.(uint64)
  12589. if !ok {
  12590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12591. }
  12592. m.SetStageID(v)
  12593. return nil
  12594. case sopnode.FieldParentID:
  12595. v, ok := value.(uint64)
  12596. if !ok {
  12597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12598. }
  12599. m.SetParentID(v)
  12600. return nil
  12601. case sopnode.FieldName:
  12602. v, ok := value.(string)
  12603. if !ok {
  12604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12605. }
  12606. m.SetName(v)
  12607. return nil
  12608. case sopnode.FieldConditionType:
  12609. v, ok := value.(int)
  12610. if !ok {
  12611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12612. }
  12613. m.SetConditionType(v)
  12614. return nil
  12615. case sopnode.FieldConditionList:
  12616. v, ok := value.([]string)
  12617. if !ok {
  12618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12619. }
  12620. m.SetConditionList(v)
  12621. return nil
  12622. case sopnode.FieldNoReplyCondition:
  12623. v, ok := value.(uint64)
  12624. if !ok {
  12625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12626. }
  12627. m.SetNoReplyCondition(v)
  12628. return nil
  12629. case sopnode.FieldActionMessage:
  12630. v, ok := value.([]custom_types.Action)
  12631. if !ok {
  12632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12633. }
  12634. m.SetActionMessage(v)
  12635. return nil
  12636. case sopnode.FieldActionLabel:
  12637. v, ok := value.([]uint64)
  12638. if !ok {
  12639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12640. }
  12641. m.SetActionLabel(v)
  12642. return nil
  12643. }
  12644. return fmt.Errorf("unknown SopNode field %s", name)
  12645. }
  12646. // AddedFields returns all numeric fields that were incremented/decremented during
  12647. // this mutation.
  12648. func (m *SopNodeMutation) AddedFields() []string {
  12649. var fields []string
  12650. if m.addstatus != nil {
  12651. fields = append(fields, sopnode.FieldStatus)
  12652. }
  12653. if m.addparent_id != nil {
  12654. fields = append(fields, sopnode.FieldParentID)
  12655. }
  12656. if m.addcondition_type != nil {
  12657. fields = append(fields, sopnode.FieldConditionType)
  12658. }
  12659. if m.addno_reply_condition != nil {
  12660. fields = append(fields, sopnode.FieldNoReplyCondition)
  12661. }
  12662. return fields
  12663. }
  12664. // AddedField returns the numeric value that was incremented/decremented on a field
  12665. // with the given name. The second boolean return value indicates that this field
  12666. // was not set, or was not defined in the schema.
  12667. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  12668. switch name {
  12669. case sopnode.FieldStatus:
  12670. return m.AddedStatus()
  12671. case sopnode.FieldParentID:
  12672. return m.AddedParentID()
  12673. case sopnode.FieldConditionType:
  12674. return m.AddedConditionType()
  12675. case sopnode.FieldNoReplyCondition:
  12676. return m.AddedNoReplyCondition()
  12677. }
  12678. return nil, false
  12679. }
  12680. // AddField adds the value to the field with the given name. It returns an error if
  12681. // the field is not defined in the schema, or if the type mismatched the field
  12682. // type.
  12683. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  12684. switch name {
  12685. case sopnode.FieldStatus:
  12686. v, ok := value.(int8)
  12687. if !ok {
  12688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12689. }
  12690. m.AddStatus(v)
  12691. return nil
  12692. case sopnode.FieldParentID:
  12693. v, ok := value.(int64)
  12694. if !ok {
  12695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12696. }
  12697. m.AddParentID(v)
  12698. return nil
  12699. case sopnode.FieldConditionType:
  12700. v, ok := value.(int)
  12701. if !ok {
  12702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12703. }
  12704. m.AddConditionType(v)
  12705. return nil
  12706. case sopnode.FieldNoReplyCondition:
  12707. v, ok := value.(int64)
  12708. if !ok {
  12709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12710. }
  12711. m.AddNoReplyCondition(v)
  12712. return nil
  12713. }
  12714. return fmt.Errorf("unknown SopNode numeric field %s", name)
  12715. }
  12716. // ClearedFields returns all nullable fields that were cleared during this
  12717. // mutation.
  12718. func (m *SopNodeMutation) ClearedFields() []string {
  12719. var fields []string
  12720. if m.FieldCleared(sopnode.FieldStatus) {
  12721. fields = append(fields, sopnode.FieldStatus)
  12722. }
  12723. if m.FieldCleared(sopnode.FieldDeletedAt) {
  12724. fields = append(fields, sopnode.FieldDeletedAt)
  12725. }
  12726. if m.FieldCleared(sopnode.FieldConditionList) {
  12727. fields = append(fields, sopnode.FieldConditionList)
  12728. }
  12729. if m.FieldCleared(sopnode.FieldActionMessage) {
  12730. fields = append(fields, sopnode.FieldActionMessage)
  12731. }
  12732. if m.FieldCleared(sopnode.FieldActionLabel) {
  12733. fields = append(fields, sopnode.FieldActionLabel)
  12734. }
  12735. return fields
  12736. }
  12737. // FieldCleared returns a boolean indicating if a field with the given name was
  12738. // cleared in this mutation.
  12739. func (m *SopNodeMutation) FieldCleared(name string) bool {
  12740. _, ok := m.clearedFields[name]
  12741. return ok
  12742. }
  12743. // ClearField clears the value of the field with the given name. It returns an
  12744. // error if the field is not defined in the schema.
  12745. func (m *SopNodeMutation) ClearField(name string) error {
  12746. switch name {
  12747. case sopnode.FieldStatus:
  12748. m.ClearStatus()
  12749. return nil
  12750. case sopnode.FieldDeletedAt:
  12751. m.ClearDeletedAt()
  12752. return nil
  12753. case sopnode.FieldConditionList:
  12754. m.ClearConditionList()
  12755. return nil
  12756. case sopnode.FieldActionMessage:
  12757. m.ClearActionMessage()
  12758. return nil
  12759. case sopnode.FieldActionLabel:
  12760. m.ClearActionLabel()
  12761. return nil
  12762. }
  12763. return fmt.Errorf("unknown SopNode nullable field %s", name)
  12764. }
  12765. // ResetField resets all changes in the mutation for the field with the given name.
  12766. // It returns an error if the field is not defined in the schema.
  12767. func (m *SopNodeMutation) ResetField(name string) error {
  12768. switch name {
  12769. case sopnode.FieldCreatedAt:
  12770. m.ResetCreatedAt()
  12771. return nil
  12772. case sopnode.FieldUpdatedAt:
  12773. m.ResetUpdatedAt()
  12774. return nil
  12775. case sopnode.FieldStatus:
  12776. m.ResetStatus()
  12777. return nil
  12778. case sopnode.FieldDeletedAt:
  12779. m.ResetDeletedAt()
  12780. return nil
  12781. case sopnode.FieldStageID:
  12782. m.ResetStageID()
  12783. return nil
  12784. case sopnode.FieldParentID:
  12785. m.ResetParentID()
  12786. return nil
  12787. case sopnode.FieldName:
  12788. m.ResetName()
  12789. return nil
  12790. case sopnode.FieldConditionType:
  12791. m.ResetConditionType()
  12792. return nil
  12793. case sopnode.FieldConditionList:
  12794. m.ResetConditionList()
  12795. return nil
  12796. case sopnode.FieldNoReplyCondition:
  12797. m.ResetNoReplyCondition()
  12798. return nil
  12799. case sopnode.FieldActionMessage:
  12800. m.ResetActionMessage()
  12801. return nil
  12802. case sopnode.FieldActionLabel:
  12803. m.ResetActionLabel()
  12804. return nil
  12805. }
  12806. return fmt.Errorf("unknown SopNode field %s", name)
  12807. }
  12808. // AddedEdges returns all edge names that were set/added in this mutation.
  12809. func (m *SopNodeMutation) AddedEdges() []string {
  12810. edges := make([]string, 0, 2)
  12811. if m.sop_stage != nil {
  12812. edges = append(edges, sopnode.EdgeSopStage)
  12813. }
  12814. if m.node_messages != nil {
  12815. edges = append(edges, sopnode.EdgeNodeMessages)
  12816. }
  12817. return edges
  12818. }
  12819. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12820. // name in this mutation.
  12821. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  12822. switch name {
  12823. case sopnode.EdgeSopStage:
  12824. if id := m.sop_stage; id != nil {
  12825. return []ent.Value{*id}
  12826. }
  12827. case sopnode.EdgeNodeMessages:
  12828. ids := make([]ent.Value, 0, len(m.node_messages))
  12829. for id := range m.node_messages {
  12830. ids = append(ids, id)
  12831. }
  12832. return ids
  12833. }
  12834. return nil
  12835. }
  12836. // RemovedEdges returns all edge names that were removed in this mutation.
  12837. func (m *SopNodeMutation) RemovedEdges() []string {
  12838. edges := make([]string, 0, 2)
  12839. if m.removednode_messages != nil {
  12840. edges = append(edges, sopnode.EdgeNodeMessages)
  12841. }
  12842. return edges
  12843. }
  12844. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12845. // the given name in this mutation.
  12846. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  12847. switch name {
  12848. case sopnode.EdgeNodeMessages:
  12849. ids := make([]ent.Value, 0, len(m.removednode_messages))
  12850. for id := range m.removednode_messages {
  12851. ids = append(ids, id)
  12852. }
  12853. return ids
  12854. }
  12855. return nil
  12856. }
  12857. // ClearedEdges returns all edge names that were cleared in this mutation.
  12858. func (m *SopNodeMutation) ClearedEdges() []string {
  12859. edges := make([]string, 0, 2)
  12860. if m.clearedsop_stage {
  12861. edges = append(edges, sopnode.EdgeSopStage)
  12862. }
  12863. if m.clearednode_messages {
  12864. edges = append(edges, sopnode.EdgeNodeMessages)
  12865. }
  12866. return edges
  12867. }
  12868. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12869. // was cleared in this mutation.
  12870. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  12871. switch name {
  12872. case sopnode.EdgeSopStage:
  12873. return m.clearedsop_stage
  12874. case sopnode.EdgeNodeMessages:
  12875. return m.clearednode_messages
  12876. }
  12877. return false
  12878. }
  12879. // ClearEdge clears the value of the edge with the given name. It returns an error
  12880. // if that edge is not defined in the schema.
  12881. func (m *SopNodeMutation) ClearEdge(name string) error {
  12882. switch name {
  12883. case sopnode.EdgeSopStage:
  12884. m.ClearSopStage()
  12885. return nil
  12886. }
  12887. return fmt.Errorf("unknown SopNode unique edge %s", name)
  12888. }
  12889. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12890. // It returns an error if the edge is not defined in the schema.
  12891. func (m *SopNodeMutation) ResetEdge(name string) error {
  12892. switch name {
  12893. case sopnode.EdgeSopStage:
  12894. m.ResetSopStage()
  12895. return nil
  12896. case sopnode.EdgeNodeMessages:
  12897. m.ResetNodeMessages()
  12898. return nil
  12899. }
  12900. return fmt.Errorf("unknown SopNode edge %s", name)
  12901. }
  12902. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  12903. type SopStageMutation struct {
  12904. config
  12905. op Op
  12906. typ string
  12907. id *uint64
  12908. created_at *time.Time
  12909. updated_at *time.Time
  12910. status *uint8
  12911. addstatus *int8
  12912. deleted_at *time.Time
  12913. name *string
  12914. condition_type *int
  12915. addcondition_type *int
  12916. condition_operator *int
  12917. addcondition_operator *int
  12918. condition_list *[]custom_types.Condition
  12919. appendcondition_list []custom_types.Condition
  12920. action_message *[]custom_types.Action
  12921. appendaction_message []custom_types.Action
  12922. action_label *[]uint64
  12923. appendaction_label []uint64
  12924. index_sort *int
  12925. addindex_sort *int
  12926. clearedFields map[string]struct{}
  12927. sop_task *uint64
  12928. clearedsop_task bool
  12929. stage_nodes map[uint64]struct{}
  12930. removedstage_nodes map[uint64]struct{}
  12931. clearedstage_nodes bool
  12932. stage_messages map[uint64]struct{}
  12933. removedstage_messages map[uint64]struct{}
  12934. clearedstage_messages bool
  12935. done bool
  12936. oldValue func(context.Context) (*SopStage, error)
  12937. predicates []predicate.SopStage
  12938. }
  12939. var _ ent.Mutation = (*SopStageMutation)(nil)
  12940. // sopstageOption allows management of the mutation configuration using functional options.
  12941. type sopstageOption func(*SopStageMutation)
  12942. // newSopStageMutation creates new mutation for the SopStage entity.
  12943. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  12944. m := &SopStageMutation{
  12945. config: c,
  12946. op: op,
  12947. typ: TypeSopStage,
  12948. clearedFields: make(map[string]struct{}),
  12949. }
  12950. for _, opt := range opts {
  12951. opt(m)
  12952. }
  12953. return m
  12954. }
  12955. // withSopStageID sets the ID field of the mutation.
  12956. func withSopStageID(id uint64) sopstageOption {
  12957. return func(m *SopStageMutation) {
  12958. var (
  12959. err error
  12960. once sync.Once
  12961. value *SopStage
  12962. )
  12963. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  12964. once.Do(func() {
  12965. if m.done {
  12966. err = errors.New("querying old values post mutation is not allowed")
  12967. } else {
  12968. value, err = m.Client().SopStage.Get(ctx, id)
  12969. }
  12970. })
  12971. return value, err
  12972. }
  12973. m.id = &id
  12974. }
  12975. }
  12976. // withSopStage sets the old SopStage of the mutation.
  12977. func withSopStage(node *SopStage) sopstageOption {
  12978. return func(m *SopStageMutation) {
  12979. m.oldValue = func(context.Context) (*SopStage, error) {
  12980. return node, nil
  12981. }
  12982. m.id = &node.ID
  12983. }
  12984. }
  12985. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12986. // executed in a transaction (ent.Tx), a transactional client is returned.
  12987. func (m SopStageMutation) Client() *Client {
  12988. client := &Client{config: m.config}
  12989. client.init()
  12990. return client
  12991. }
  12992. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12993. // it returns an error otherwise.
  12994. func (m SopStageMutation) Tx() (*Tx, error) {
  12995. if _, ok := m.driver.(*txDriver); !ok {
  12996. return nil, errors.New("ent: mutation is not running in a transaction")
  12997. }
  12998. tx := &Tx{config: m.config}
  12999. tx.init()
  13000. return tx, nil
  13001. }
  13002. // SetID sets the value of the id field. Note that this
  13003. // operation is only accepted on creation of SopStage entities.
  13004. func (m *SopStageMutation) SetID(id uint64) {
  13005. m.id = &id
  13006. }
  13007. // ID returns the ID value in the mutation. Note that the ID is only available
  13008. // if it was provided to the builder or after it was returned from the database.
  13009. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  13010. if m.id == nil {
  13011. return
  13012. }
  13013. return *m.id, true
  13014. }
  13015. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13016. // That means, if the mutation is applied within a transaction with an isolation level such
  13017. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13018. // or updated by the mutation.
  13019. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  13020. switch {
  13021. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13022. id, exists := m.ID()
  13023. if exists {
  13024. return []uint64{id}, nil
  13025. }
  13026. fallthrough
  13027. case m.op.Is(OpUpdate | OpDelete):
  13028. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  13029. default:
  13030. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13031. }
  13032. }
  13033. // SetCreatedAt sets the "created_at" field.
  13034. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  13035. m.created_at = &t
  13036. }
  13037. // CreatedAt returns the value of the "created_at" field in the mutation.
  13038. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  13039. v := m.created_at
  13040. if v == nil {
  13041. return
  13042. }
  13043. return *v, true
  13044. }
  13045. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  13046. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13048. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13049. if !m.op.Is(OpUpdateOne) {
  13050. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13051. }
  13052. if m.id == nil || m.oldValue == nil {
  13053. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13054. }
  13055. oldValue, err := m.oldValue(ctx)
  13056. if err != nil {
  13057. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13058. }
  13059. return oldValue.CreatedAt, nil
  13060. }
  13061. // ResetCreatedAt resets all changes to the "created_at" field.
  13062. func (m *SopStageMutation) ResetCreatedAt() {
  13063. m.created_at = nil
  13064. }
  13065. // SetUpdatedAt sets the "updated_at" field.
  13066. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  13067. m.updated_at = &t
  13068. }
  13069. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13070. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  13071. v := m.updated_at
  13072. if v == nil {
  13073. return
  13074. }
  13075. return *v, true
  13076. }
  13077. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  13078. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13080. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13081. if !m.op.Is(OpUpdateOne) {
  13082. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13083. }
  13084. if m.id == nil || m.oldValue == nil {
  13085. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13086. }
  13087. oldValue, err := m.oldValue(ctx)
  13088. if err != nil {
  13089. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13090. }
  13091. return oldValue.UpdatedAt, nil
  13092. }
  13093. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13094. func (m *SopStageMutation) ResetUpdatedAt() {
  13095. m.updated_at = nil
  13096. }
  13097. // SetStatus sets the "status" field.
  13098. func (m *SopStageMutation) SetStatus(u uint8) {
  13099. m.status = &u
  13100. m.addstatus = nil
  13101. }
  13102. // Status returns the value of the "status" field in the mutation.
  13103. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  13104. v := m.status
  13105. if v == nil {
  13106. return
  13107. }
  13108. return *v, true
  13109. }
  13110. // OldStatus returns the old "status" field's value of the SopStage entity.
  13111. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13113. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13114. if !m.op.Is(OpUpdateOne) {
  13115. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13116. }
  13117. if m.id == nil || m.oldValue == nil {
  13118. return v, errors.New("OldStatus requires an ID field in the mutation")
  13119. }
  13120. oldValue, err := m.oldValue(ctx)
  13121. if err != nil {
  13122. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13123. }
  13124. return oldValue.Status, nil
  13125. }
  13126. // AddStatus adds u to the "status" field.
  13127. func (m *SopStageMutation) AddStatus(u int8) {
  13128. if m.addstatus != nil {
  13129. *m.addstatus += u
  13130. } else {
  13131. m.addstatus = &u
  13132. }
  13133. }
  13134. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13135. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  13136. v := m.addstatus
  13137. if v == nil {
  13138. return
  13139. }
  13140. return *v, true
  13141. }
  13142. // ClearStatus clears the value of the "status" field.
  13143. func (m *SopStageMutation) ClearStatus() {
  13144. m.status = nil
  13145. m.addstatus = nil
  13146. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  13147. }
  13148. // StatusCleared returns if the "status" field was cleared in this mutation.
  13149. func (m *SopStageMutation) StatusCleared() bool {
  13150. _, ok := m.clearedFields[sopstage.FieldStatus]
  13151. return ok
  13152. }
  13153. // ResetStatus resets all changes to the "status" field.
  13154. func (m *SopStageMutation) ResetStatus() {
  13155. m.status = nil
  13156. m.addstatus = nil
  13157. delete(m.clearedFields, sopstage.FieldStatus)
  13158. }
  13159. // SetDeletedAt sets the "deleted_at" field.
  13160. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  13161. m.deleted_at = &t
  13162. }
  13163. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13164. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  13165. v := m.deleted_at
  13166. if v == nil {
  13167. return
  13168. }
  13169. return *v, true
  13170. }
  13171. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  13172. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13174. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13175. if !m.op.Is(OpUpdateOne) {
  13176. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13177. }
  13178. if m.id == nil || m.oldValue == nil {
  13179. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13180. }
  13181. oldValue, err := m.oldValue(ctx)
  13182. if err != nil {
  13183. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13184. }
  13185. return oldValue.DeletedAt, nil
  13186. }
  13187. // ClearDeletedAt clears the value of the "deleted_at" field.
  13188. func (m *SopStageMutation) ClearDeletedAt() {
  13189. m.deleted_at = nil
  13190. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  13191. }
  13192. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13193. func (m *SopStageMutation) DeletedAtCleared() bool {
  13194. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  13195. return ok
  13196. }
  13197. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13198. func (m *SopStageMutation) ResetDeletedAt() {
  13199. m.deleted_at = nil
  13200. delete(m.clearedFields, sopstage.FieldDeletedAt)
  13201. }
  13202. // SetTaskID sets the "task_id" field.
  13203. func (m *SopStageMutation) SetTaskID(u uint64) {
  13204. m.sop_task = &u
  13205. }
  13206. // TaskID returns the value of the "task_id" field in the mutation.
  13207. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  13208. v := m.sop_task
  13209. if v == nil {
  13210. return
  13211. }
  13212. return *v, true
  13213. }
  13214. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  13215. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13216. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13217. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  13218. if !m.op.Is(OpUpdateOne) {
  13219. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  13220. }
  13221. if m.id == nil || m.oldValue == nil {
  13222. return v, errors.New("OldTaskID requires an ID field in the mutation")
  13223. }
  13224. oldValue, err := m.oldValue(ctx)
  13225. if err != nil {
  13226. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  13227. }
  13228. return oldValue.TaskID, nil
  13229. }
  13230. // ResetTaskID resets all changes to the "task_id" field.
  13231. func (m *SopStageMutation) ResetTaskID() {
  13232. m.sop_task = nil
  13233. }
  13234. // SetName sets the "name" field.
  13235. func (m *SopStageMutation) SetName(s string) {
  13236. m.name = &s
  13237. }
  13238. // Name returns the value of the "name" field in the mutation.
  13239. func (m *SopStageMutation) Name() (r string, exists bool) {
  13240. v := m.name
  13241. if v == nil {
  13242. return
  13243. }
  13244. return *v, true
  13245. }
  13246. // OldName returns the old "name" field's value of the SopStage entity.
  13247. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13248. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13249. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  13250. if !m.op.Is(OpUpdateOne) {
  13251. return v, errors.New("OldName is only allowed on UpdateOne operations")
  13252. }
  13253. if m.id == nil || m.oldValue == nil {
  13254. return v, errors.New("OldName requires an ID field in the mutation")
  13255. }
  13256. oldValue, err := m.oldValue(ctx)
  13257. if err != nil {
  13258. return v, fmt.Errorf("querying old value for OldName: %w", err)
  13259. }
  13260. return oldValue.Name, nil
  13261. }
  13262. // ResetName resets all changes to the "name" field.
  13263. func (m *SopStageMutation) ResetName() {
  13264. m.name = nil
  13265. }
  13266. // SetConditionType sets the "condition_type" field.
  13267. func (m *SopStageMutation) SetConditionType(i int) {
  13268. m.condition_type = &i
  13269. m.addcondition_type = nil
  13270. }
  13271. // ConditionType returns the value of the "condition_type" field in the mutation.
  13272. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  13273. v := m.condition_type
  13274. if v == nil {
  13275. return
  13276. }
  13277. return *v, true
  13278. }
  13279. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  13280. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13282. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  13283. if !m.op.Is(OpUpdateOne) {
  13284. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  13285. }
  13286. if m.id == nil || m.oldValue == nil {
  13287. return v, errors.New("OldConditionType requires an ID field in the mutation")
  13288. }
  13289. oldValue, err := m.oldValue(ctx)
  13290. if err != nil {
  13291. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  13292. }
  13293. return oldValue.ConditionType, nil
  13294. }
  13295. // AddConditionType adds i to the "condition_type" field.
  13296. func (m *SopStageMutation) AddConditionType(i int) {
  13297. if m.addcondition_type != nil {
  13298. *m.addcondition_type += i
  13299. } else {
  13300. m.addcondition_type = &i
  13301. }
  13302. }
  13303. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  13304. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  13305. v := m.addcondition_type
  13306. if v == nil {
  13307. return
  13308. }
  13309. return *v, true
  13310. }
  13311. // ResetConditionType resets all changes to the "condition_type" field.
  13312. func (m *SopStageMutation) ResetConditionType() {
  13313. m.condition_type = nil
  13314. m.addcondition_type = nil
  13315. }
  13316. // SetConditionOperator sets the "condition_operator" field.
  13317. func (m *SopStageMutation) SetConditionOperator(i int) {
  13318. m.condition_operator = &i
  13319. m.addcondition_operator = nil
  13320. }
  13321. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  13322. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  13323. v := m.condition_operator
  13324. if v == nil {
  13325. return
  13326. }
  13327. return *v, true
  13328. }
  13329. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  13330. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13332. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  13333. if !m.op.Is(OpUpdateOne) {
  13334. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  13335. }
  13336. if m.id == nil || m.oldValue == nil {
  13337. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  13338. }
  13339. oldValue, err := m.oldValue(ctx)
  13340. if err != nil {
  13341. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  13342. }
  13343. return oldValue.ConditionOperator, nil
  13344. }
  13345. // AddConditionOperator adds i to the "condition_operator" field.
  13346. func (m *SopStageMutation) AddConditionOperator(i int) {
  13347. if m.addcondition_operator != nil {
  13348. *m.addcondition_operator += i
  13349. } else {
  13350. m.addcondition_operator = &i
  13351. }
  13352. }
  13353. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  13354. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  13355. v := m.addcondition_operator
  13356. if v == nil {
  13357. return
  13358. }
  13359. return *v, true
  13360. }
  13361. // ResetConditionOperator resets all changes to the "condition_operator" field.
  13362. func (m *SopStageMutation) ResetConditionOperator() {
  13363. m.condition_operator = nil
  13364. m.addcondition_operator = nil
  13365. }
  13366. // SetConditionList sets the "condition_list" field.
  13367. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  13368. m.condition_list = &ct
  13369. m.appendcondition_list = nil
  13370. }
  13371. // ConditionList returns the value of the "condition_list" field in the mutation.
  13372. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  13373. v := m.condition_list
  13374. if v == nil {
  13375. return
  13376. }
  13377. return *v, true
  13378. }
  13379. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  13380. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13382. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  13383. if !m.op.Is(OpUpdateOne) {
  13384. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  13385. }
  13386. if m.id == nil || m.oldValue == nil {
  13387. return v, errors.New("OldConditionList requires an ID field in the mutation")
  13388. }
  13389. oldValue, err := m.oldValue(ctx)
  13390. if err != nil {
  13391. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  13392. }
  13393. return oldValue.ConditionList, nil
  13394. }
  13395. // AppendConditionList adds ct to the "condition_list" field.
  13396. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  13397. m.appendcondition_list = append(m.appendcondition_list, ct...)
  13398. }
  13399. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  13400. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  13401. if len(m.appendcondition_list) == 0 {
  13402. return nil, false
  13403. }
  13404. return m.appendcondition_list, true
  13405. }
  13406. // ResetConditionList resets all changes to the "condition_list" field.
  13407. func (m *SopStageMutation) ResetConditionList() {
  13408. m.condition_list = nil
  13409. m.appendcondition_list = nil
  13410. }
  13411. // SetActionMessage sets the "action_message" field.
  13412. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  13413. m.action_message = &ct
  13414. m.appendaction_message = nil
  13415. }
  13416. // ActionMessage returns the value of the "action_message" field in the mutation.
  13417. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  13418. v := m.action_message
  13419. if v == nil {
  13420. return
  13421. }
  13422. return *v, true
  13423. }
  13424. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  13425. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13427. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  13428. if !m.op.Is(OpUpdateOne) {
  13429. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  13430. }
  13431. if m.id == nil || m.oldValue == nil {
  13432. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  13433. }
  13434. oldValue, err := m.oldValue(ctx)
  13435. if err != nil {
  13436. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  13437. }
  13438. return oldValue.ActionMessage, nil
  13439. }
  13440. // AppendActionMessage adds ct to the "action_message" field.
  13441. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  13442. m.appendaction_message = append(m.appendaction_message, ct...)
  13443. }
  13444. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  13445. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  13446. if len(m.appendaction_message) == 0 {
  13447. return nil, false
  13448. }
  13449. return m.appendaction_message, true
  13450. }
  13451. // ClearActionMessage clears the value of the "action_message" field.
  13452. func (m *SopStageMutation) ClearActionMessage() {
  13453. m.action_message = nil
  13454. m.appendaction_message = nil
  13455. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  13456. }
  13457. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  13458. func (m *SopStageMutation) ActionMessageCleared() bool {
  13459. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  13460. return ok
  13461. }
  13462. // ResetActionMessage resets all changes to the "action_message" field.
  13463. func (m *SopStageMutation) ResetActionMessage() {
  13464. m.action_message = nil
  13465. m.appendaction_message = nil
  13466. delete(m.clearedFields, sopstage.FieldActionMessage)
  13467. }
  13468. // SetActionLabel sets the "action_label" field.
  13469. func (m *SopStageMutation) SetActionLabel(u []uint64) {
  13470. m.action_label = &u
  13471. m.appendaction_label = nil
  13472. }
  13473. // ActionLabel returns the value of the "action_label" field in the mutation.
  13474. func (m *SopStageMutation) ActionLabel() (r []uint64, exists bool) {
  13475. v := m.action_label
  13476. if v == nil {
  13477. return
  13478. }
  13479. return *v, true
  13480. }
  13481. // OldActionLabel returns the old "action_label" field's value of the SopStage entity.
  13482. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13483. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13484. func (m *SopStageMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  13485. if !m.op.Is(OpUpdateOne) {
  13486. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  13487. }
  13488. if m.id == nil || m.oldValue == nil {
  13489. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  13490. }
  13491. oldValue, err := m.oldValue(ctx)
  13492. if err != nil {
  13493. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  13494. }
  13495. return oldValue.ActionLabel, nil
  13496. }
  13497. // AppendActionLabel adds u to the "action_label" field.
  13498. func (m *SopStageMutation) AppendActionLabel(u []uint64) {
  13499. m.appendaction_label = append(m.appendaction_label, u...)
  13500. }
  13501. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  13502. func (m *SopStageMutation) AppendedActionLabel() ([]uint64, bool) {
  13503. if len(m.appendaction_label) == 0 {
  13504. return nil, false
  13505. }
  13506. return m.appendaction_label, true
  13507. }
  13508. // ClearActionLabel clears the value of the "action_label" field.
  13509. func (m *SopStageMutation) ClearActionLabel() {
  13510. m.action_label = nil
  13511. m.appendaction_label = nil
  13512. m.clearedFields[sopstage.FieldActionLabel] = struct{}{}
  13513. }
  13514. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  13515. func (m *SopStageMutation) ActionLabelCleared() bool {
  13516. _, ok := m.clearedFields[sopstage.FieldActionLabel]
  13517. return ok
  13518. }
  13519. // ResetActionLabel resets all changes to the "action_label" field.
  13520. func (m *SopStageMutation) ResetActionLabel() {
  13521. m.action_label = nil
  13522. m.appendaction_label = nil
  13523. delete(m.clearedFields, sopstage.FieldActionLabel)
  13524. }
  13525. // SetIndexSort sets the "index_sort" field.
  13526. func (m *SopStageMutation) SetIndexSort(i int) {
  13527. m.index_sort = &i
  13528. m.addindex_sort = nil
  13529. }
  13530. // IndexSort returns the value of the "index_sort" field in the mutation.
  13531. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  13532. v := m.index_sort
  13533. if v == nil {
  13534. return
  13535. }
  13536. return *v, true
  13537. }
  13538. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  13539. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13541. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  13542. if !m.op.Is(OpUpdateOne) {
  13543. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  13544. }
  13545. if m.id == nil || m.oldValue == nil {
  13546. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  13547. }
  13548. oldValue, err := m.oldValue(ctx)
  13549. if err != nil {
  13550. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  13551. }
  13552. return oldValue.IndexSort, nil
  13553. }
  13554. // AddIndexSort adds i to the "index_sort" field.
  13555. func (m *SopStageMutation) AddIndexSort(i int) {
  13556. if m.addindex_sort != nil {
  13557. *m.addindex_sort += i
  13558. } else {
  13559. m.addindex_sort = &i
  13560. }
  13561. }
  13562. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  13563. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  13564. v := m.addindex_sort
  13565. if v == nil {
  13566. return
  13567. }
  13568. return *v, true
  13569. }
  13570. // ClearIndexSort clears the value of the "index_sort" field.
  13571. func (m *SopStageMutation) ClearIndexSort() {
  13572. m.index_sort = nil
  13573. m.addindex_sort = nil
  13574. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  13575. }
  13576. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  13577. func (m *SopStageMutation) IndexSortCleared() bool {
  13578. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  13579. return ok
  13580. }
  13581. // ResetIndexSort resets all changes to the "index_sort" field.
  13582. func (m *SopStageMutation) ResetIndexSort() {
  13583. m.index_sort = nil
  13584. m.addindex_sort = nil
  13585. delete(m.clearedFields, sopstage.FieldIndexSort)
  13586. }
  13587. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  13588. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  13589. m.sop_task = &id
  13590. }
  13591. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  13592. func (m *SopStageMutation) ClearSopTask() {
  13593. m.clearedsop_task = true
  13594. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  13595. }
  13596. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  13597. func (m *SopStageMutation) SopTaskCleared() bool {
  13598. return m.clearedsop_task
  13599. }
  13600. // SopTaskID returns the "sop_task" edge ID in the mutation.
  13601. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  13602. if m.sop_task != nil {
  13603. return *m.sop_task, true
  13604. }
  13605. return
  13606. }
  13607. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  13608. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13609. // SopTaskID instead. It exists only for internal usage by the builders.
  13610. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  13611. if id := m.sop_task; id != nil {
  13612. ids = append(ids, *id)
  13613. }
  13614. return
  13615. }
  13616. // ResetSopTask resets all changes to the "sop_task" edge.
  13617. func (m *SopStageMutation) ResetSopTask() {
  13618. m.sop_task = nil
  13619. m.clearedsop_task = false
  13620. }
  13621. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  13622. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  13623. if m.stage_nodes == nil {
  13624. m.stage_nodes = make(map[uint64]struct{})
  13625. }
  13626. for i := range ids {
  13627. m.stage_nodes[ids[i]] = struct{}{}
  13628. }
  13629. }
  13630. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  13631. func (m *SopStageMutation) ClearStageNodes() {
  13632. m.clearedstage_nodes = true
  13633. }
  13634. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  13635. func (m *SopStageMutation) StageNodesCleared() bool {
  13636. return m.clearedstage_nodes
  13637. }
  13638. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  13639. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  13640. if m.removedstage_nodes == nil {
  13641. m.removedstage_nodes = make(map[uint64]struct{})
  13642. }
  13643. for i := range ids {
  13644. delete(m.stage_nodes, ids[i])
  13645. m.removedstage_nodes[ids[i]] = struct{}{}
  13646. }
  13647. }
  13648. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  13649. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  13650. for id := range m.removedstage_nodes {
  13651. ids = append(ids, id)
  13652. }
  13653. return
  13654. }
  13655. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  13656. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  13657. for id := range m.stage_nodes {
  13658. ids = append(ids, id)
  13659. }
  13660. return
  13661. }
  13662. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  13663. func (m *SopStageMutation) ResetStageNodes() {
  13664. m.stage_nodes = nil
  13665. m.clearedstage_nodes = false
  13666. m.removedstage_nodes = nil
  13667. }
  13668. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  13669. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  13670. if m.stage_messages == nil {
  13671. m.stage_messages = make(map[uint64]struct{})
  13672. }
  13673. for i := range ids {
  13674. m.stage_messages[ids[i]] = struct{}{}
  13675. }
  13676. }
  13677. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  13678. func (m *SopStageMutation) ClearStageMessages() {
  13679. m.clearedstage_messages = true
  13680. }
  13681. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  13682. func (m *SopStageMutation) StageMessagesCleared() bool {
  13683. return m.clearedstage_messages
  13684. }
  13685. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  13686. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  13687. if m.removedstage_messages == nil {
  13688. m.removedstage_messages = make(map[uint64]struct{})
  13689. }
  13690. for i := range ids {
  13691. delete(m.stage_messages, ids[i])
  13692. m.removedstage_messages[ids[i]] = struct{}{}
  13693. }
  13694. }
  13695. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  13696. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  13697. for id := range m.removedstage_messages {
  13698. ids = append(ids, id)
  13699. }
  13700. return
  13701. }
  13702. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  13703. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  13704. for id := range m.stage_messages {
  13705. ids = append(ids, id)
  13706. }
  13707. return
  13708. }
  13709. // ResetStageMessages resets all changes to the "stage_messages" edge.
  13710. func (m *SopStageMutation) ResetStageMessages() {
  13711. m.stage_messages = nil
  13712. m.clearedstage_messages = false
  13713. m.removedstage_messages = nil
  13714. }
  13715. // Where appends a list predicates to the SopStageMutation builder.
  13716. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  13717. m.predicates = append(m.predicates, ps...)
  13718. }
  13719. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  13720. // users can use type-assertion to append predicates that do not depend on any generated package.
  13721. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  13722. p := make([]predicate.SopStage, len(ps))
  13723. for i := range ps {
  13724. p[i] = ps[i]
  13725. }
  13726. m.Where(p...)
  13727. }
  13728. // Op returns the operation name.
  13729. func (m *SopStageMutation) Op() Op {
  13730. return m.op
  13731. }
  13732. // SetOp allows setting the mutation operation.
  13733. func (m *SopStageMutation) SetOp(op Op) {
  13734. m.op = op
  13735. }
  13736. // Type returns the node type of this mutation (SopStage).
  13737. func (m *SopStageMutation) Type() string {
  13738. return m.typ
  13739. }
  13740. // Fields returns all fields that were changed during this mutation. Note that in
  13741. // order to get all numeric fields that were incremented/decremented, call
  13742. // AddedFields().
  13743. func (m *SopStageMutation) Fields() []string {
  13744. fields := make([]string, 0, 12)
  13745. if m.created_at != nil {
  13746. fields = append(fields, sopstage.FieldCreatedAt)
  13747. }
  13748. if m.updated_at != nil {
  13749. fields = append(fields, sopstage.FieldUpdatedAt)
  13750. }
  13751. if m.status != nil {
  13752. fields = append(fields, sopstage.FieldStatus)
  13753. }
  13754. if m.deleted_at != nil {
  13755. fields = append(fields, sopstage.FieldDeletedAt)
  13756. }
  13757. if m.sop_task != nil {
  13758. fields = append(fields, sopstage.FieldTaskID)
  13759. }
  13760. if m.name != nil {
  13761. fields = append(fields, sopstage.FieldName)
  13762. }
  13763. if m.condition_type != nil {
  13764. fields = append(fields, sopstage.FieldConditionType)
  13765. }
  13766. if m.condition_operator != nil {
  13767. fields = append(fields, sopstage.FieldConditionOperator)
  13768. }
  13769. if m.condition_list != nil {
  13770. fields = append(fields, sopstage.FieldConditionList)
  13771. }
  13772. if m.action_message != nil {
  13773. fields = append(fields, sopstage.FieldActionMessage)
  13774. }
  13775. if m.action_label != nil {
  13776. fields = append(fields, sopstage.FieldActionLabel)
  13777. }
  13778. if m.index_sort != nil {
  13779. fields = append(fields, sopstage.FieldIndexSort)
  13780. }
  13781. return fields
  13782. }
  13783. // Field returns the value of a field with the given name. The second boolean
  13784. // return value indicates that this field was not set, or was not defined in the
  13785. // schema.
  13786. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  13787. switch name {
  13788. case sopstage.FieldCreatedAt:
  13789. return m.CreatedAt()
  13790. case sopstage.FieldUpdatedAt:
  13791. return m.UpdatedAt()
  13792. case sopstage.FieldStatus:
  13793. return m.Status()
  13794. case sopstage.FieldDeletedAt:
  13795. return m.DeletedAt()
  13796. case sopstage.FieldTaskID:
  13797. return m.TaskID()
  13798. case sopstage.FieldName:
  13799. return m.Name()
  13800. case sopstage.FieldConditionType:
  13801. return m.ConditionType()
  13802. case sopstage.FieldConditionOperator:
  13803. return m.ConditionOperator()
  13804. case sopstage.FieldConditionList:
  13805. return m.ConditionList()
  13806. case sopstage.FieldActionMessage:
  13807. return m.ActionMessage()
  13808. case sopstage.FieldActionLabel:
  13809. return m.ActionLabel()
  13810. case sopstage.FieldIndexSort:
  13811. return m.IndexSort()
  13812. }
  13813. return nil, false
  13814. }
  13815. // OldField returns the old value of the field from the database. An error is
  13816. // returned if the mutation operation is not UpdateOne, or the query to the
  13817. // database failed.
  13818. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13819. switch name {
  13820. case sopstage.FieldCreatedAt:
  13821. return m.OldCreatedAt(ctx)
  13822. case sopstage.FieldUpdatedAt:
  13823. return m.OldUpdatedAt(ctx)
  13824. case sopstage.FieldStatus:
  13825. return m.OldStatus(ctx)
  13826. case sopstage.FieldDeletedAt:
  13827. return m.OldDeletedAt(ctx)
  13828. case sopstage.FieldTaskID:
  13829. return m.OldTaskID(ctx)
  13830. case sopstage.FieldName:
  13831. return m.OldName(ctx)
  13832. case sopstage.FieldConditionType:
  13833. return m.OldConditionType(ctx)
  13834. case sopstage.FieldConditionOperator:
  13835. return m.OldConditionOperator(ctx)
  13836. case sopstage.FieldConditionList:
  13837. return m.OldConditionList(ctx)
  13838. case sopstage.FieldActionMessage:
  13839. return m.OldActionMessage(ctx)
  13840. case sopstage.FieldActionLabel:
  13841. return m.OldActionLabel(ctx)
  13842. case sopstage.FieldIndexSort:
  13843. return m.OldIndexSort(ctx)
  13844. }
  13845. return nil, fmt.Errorf("unknown SopStage field %s", name)
  13846. }
  13847. // SetField sets the value of a field with the given name. It returns an error if
  13848. // the field is not defined in the schema, or if the type mismatched the field
  13849. // type.
  13850. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  13851. switch name {
  13852. case sopstage.FieldCreatedAt:
  13853. v, ok := value.(time.Time)
  13854. if !ok {
  13855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13856. }
  13857. m.SetCreatedAt(v)
  13858. return nil
  13859. case sopstage.FieldUpdatedAt:
  13860. v, ok := value.(time.Time)
  13861. if !ok {
  13862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13863. }
  13864. m.SetUpdatedAt(v)
  13865. return nil
  13866. case sopstage.FieldStatus:
  13867. v, ok := value.(uint8)
  13868. if !ok {
  13869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13870. }
  13871. m.SetStatus(v)
  13872. return nil
  13873. case sopstage.FieldDeletedAt:
  13874. v, ok := value.(time.Time)
  13875. if !ok {
  13876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13877. }
  13878. m.SetDeletedAt(v)
  13879. return nil
  13880. case sopstage.FieldTaskID:
  13881. v, ok := value.(uint64)
  13882. if !ok {
  13883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13884. }
  13885. m.SetTaskID(v)
  13886. return nil
  13887. case sopstage.FieldName:
  13888. v, ok := value.(string)
  13889. if !ok {
  13890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13891. }
  13892. m.SetName(v)
  13893. return nil
  13894. case sopstage.FieldConditionType:
  13895. v, ok := value.(int)
  13896. if !ok {
  13897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13898. }
  13899. m.SetConditionType(v)
  13900. return nil
  13901. case sopstage.FieldConditionOperator:
  13902. v, ok := value.(int)
  13903. if !ok {
  13904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13905. }
  13906. m.SetConditionOperator(v)
  13907. return nil
  13908. case sopstage.FieldConditionList:
  13909. v, ok := value.([]custom_types.Condition)
  13910. if !ok {
  13911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13912. }
  13913. m.SetConditionList(v)
  13914. return nil
  13915. case sopstage.FieldActionMessage:
  13916. v, ok := value.([]custom_types.Action)
  13917. if !ok {
  13918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13919. }
  13920. m.SetActionMessage(v)
  13921. return nil
  13922. case sopstage.FieldActionLabel:
  13923. v, ok := value.([]uint64)
  13924. if !ok {
  13925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13926. }
  13927. m.SetActionLabel(v)
  13928. return nil
  13929. case sopstage.FieldIndexSort:
  13930. v, ok := value.(int)
  13931. if !ok {
  13932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13933. }
  13934. m.SetIndexSort(v)
  13935. return nil
  13936. }
  13937. return fmt.Errorf("unknown SopStage field %s", name)
  13938. }
  13939. // AddedFields returns all numeric fields that were incremented/decremented during
  13940. // this mutation.
  13941. func (m *SopStageMutation) AddedFields() []string {
  13942. var fields []string
  13943. if m.addstatus != nil {
  13944. fields = append(fields, sopstage.FieldStatus)
  13945. }
  13946. if m.addcondition_type != nil {
  13947. fields = append(fields, sopstage.FieldConditionType)
  13948. }
  13949. if m.addcondition_operator != nil {
  13950. fields = append(fields, sopstage.FieldConditionOperator)
  13951. }
  13952. if m.addindex_sort != nil {
  13953. fields = append(fields, sopstage.FieldIndexSort)
  13954. }
  13955. return fields
  13956. }
  13957. // AddedField returns the numeric value that was incremented/decremented on a field
  13958. // with the given name. The second boolean return value indicates that this field
  13959. // was not set, or was not defined in the schema.
  13960. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  13961. switch name {
  13962. case sopstage.FieldStatus:
  13963. return m.AddedStatus()
  13964. case sopstage.FieldConditionType:
  13965. return m.AddedConditionType()
  13966. case sopstage.FieldConditionOperator:
  13967. return m.AddedConditionOperator()
  13968. case sopstage.FieldIndexSort:
  13969. return m.AddedIndexSort()
  13970. }
  13971. return nil, false
  13972. }
  13973. // AddField adds the value to the field with the given name. It returns an error if
  13974. // the field is not defined in the schema, or if the type mismatched the field
  13975. // type.
  13976. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  13977. switch name {
  13978. case sopstage.FieldStatus:
  13979. v, ok := value.(int8)
  13980. if !ok {
  13981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13982. }
  13983. m.AddStatus(v)
  13984. return nil
  13985. case sopstage.FieldConditionType:
  13986. v, ok := value.(int)
  13987. if !ok {
  13988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13989. }
  13990. m.AddConditionType(v)
  13991. return nil
  13992. case sopstage.FieldConditionOperator:
  13993. v, ok := value.(int)
  13994. if !ok {
  13995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13996. }
  13997. m.AddConditionOperator(v)
  13998. return nil
  13999. case sopstage.FieldIndexSort:
  14000. v, ok := value.(int)
  14001. if !ok {
  14002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14003. }
  14004. m.AddIndexSort(v)
  14005. return nil
  14006. }
  14007. return fmt.Errorf("unknown SopStage numeric field %s", name)
  14008. }
  14009. // ClearedFields returns all nullable fields that were cleared during this
  14010. // mutation.
  14011. func (m *SopStageMutation) ClearedFields() []string {
  14012. var fields []string
  14013. if m.FieldCleared(sopstage.FieldStatus) {
  14014. fields = append(fields, sopstage.FieldStatus)
  14015. }
  14016. if m.FieldCleared(sopstage.FieldDeletedAt) {
  14017. fields = append(fields, sopstage.FieldDeletedAt)
  14018. }
  14019. if m.FieldCleared(sopstage.FieldActionMessage) {
  14020. fields = append(fields, sopstage.FieldActionMessage)
  14021. }
  14022. if m.FieldCleared(sopstage.FieldActionLabel) {
  14023. fields = append(fields, sopstage.FieldActionLabel)
  14024. }
  14025. if m.FieldCleared(sopstage.FieldIndexSort) {
  14026. fields = append(fields, sopstage.FieldIndexSort)
  14027. }
  14028. return fields
  14029. }
  14030. // FieldCleared returns a boolean indicating if a field with the given name was
  14031. // cleared in this mutation.
  14032. func (m *SopStageMutation) FieldCleared(name string) bool {
  14033. _, ok := m.clearedFields[name]
  14034. return ok
  14035. }
  14036. // ClearField clears the value of the field with the given name. It returns an
  14037. // error if the field is not defined in the schema.
  14038. func (m *SopStageMutation) ClearField(name string) error {
  14039. switch name {
  14040. case sopstage.FieldStatus:
  14041. m.ClearStatus()
  14042. return nil
  14043. case sopstage.FieldDeletedAt:
  14044. m.ClearDeletedAt()
  14045. return nil
  14046. case sopstage.FieldActionMessage:
  14047. m.ClearActionMessage()
  14048. return nil
  14049. case sopstage.FieldActionLabel:
  14050. m.ClearActionLabel()
  14051. return nil
  14052. case sopstage.FieldIndexSort:
  14053. m.ClearIndexSort()
  14054. return nil
  14055. }
  14056. return fmt.Errorf("unknown SopStage nullable field %s", name)
  14057. }
  14058. // ResetField resets all changes in the mutation for the field with the given name.
  14059. // It returns an error if the field is not defined in the schema.
  14060. func (m *SopStageMutation) ResetField(name string) error {
  14061. switch name {
  14062. case sopstage.FieldCreatedAt:
  14063. m.ResetCreatedAt()
  14064. return nil
  14065. case sopstage.FieldUpdatedAt:
  14066. m.ResetUpdatedAt()
  14067. return nil
  14068. case sopstage.FieldStatus:
  14069. m.ResetStatus()
  14070. return nil
  14071. case sopstage.FieldDeletedAt:
  14072. m.ResetDeletedAt()
  14073. return nil
  14074. case sopstage.FieldTaskID:
  14075. m.ResetTaskID()
  14076. return nil
  14077. case sopstage.FieldName:
  14078. m.ResetName()
  14079. return nil
  14080. case sopstage.FieldConditionType:
  14081. m.ResetConditionType()
  14082. return nil
  14083. case sopstage.FieldConditionOperator:
  14084. m.ResetConditionOperator()
  14085. return nil
  14086. case sopstage.FieldConditionList:
  14087. m.ResetConditionList()
  14088. return nil
  14089. case sopstage.FieldActionMessage:
  14090. m.ResetActionMessage()
  14091. return nil
  14092. case sopstage.FieldActionLabel:
  14093. m.ResetActionLabel()
  14094. return nil
  14095. case sopstage.FieldIndexSort:
  14096. m.ResetIndexSort()
  14097. return nil
  14098. }
  14099. return fmt.Errorf("unknown SopStage field %s", name)
  14100. }
  14101. // AddedEdges returns all edge names that were set/added in this mutation.
  14102. func (m *SopStageMutation) AddedEdges() []string {
  14103. edges := make([]string, 0, 3)
  14104. if m.sop_task != nil {
  14105. edges = append(edges, sopstage.EdgeSopTask)
  14106. }
  14107. if m.stage_nodes != nil {
  14108. edges = append(edges, sopstage.EdgeStageNodes)
  14109. }
  14110. if m.stage_messages != nil {
  14111. edges = append(edges, sopstage.EdgeStageMessages)
  14112. }
  14113. return edges
  14114. }
  14115. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14116. // name in this mutation.
  14117. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  14118. switch name {
  14119. case sopstage.EdgeSopTask:
  14120. if id := m.sop_task; id != nil {
  14121. return []ent.Value{*id}
  14122. }
  14123. case sopstage.EdgeStageNodes:
  14124. ids := make([]ent.Value, 0, len(m.stage_nodes))
  14125. for id := range m.stage_nodes {
  14126. ids = append(ids, id)
  14127. }
  14128. return ids
  14129. case sopstage.EdgeStageMessages:
  14130. ids := make([]ent.Value, 0, len(m.stage_messages))
  14131. for id := range m.stage_messages {
  14132. ids = append(ids, id)
  14133. }
  14134. return ids
  14135. }
  14136. return nil
  14137. }
  14138. // RemovedEdges returns all edge names that were removed in this mutation.
  14139. func (m *SopStageMutation) RemovedEdges() []string {
  14140. edges := make([]string, 0, 3)
  14141. if m.removedstage_nodes != nil {
  14142. edges = append(edges, sopstage.EdgeStageNodes)
  14143. }
  14144. if m.removedstage_messages != nil {
  14145. edges = append(edges, sopstage.EdgeStageMessages)
  14146. }
  14147. return edges
  14148. }
  14149. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14150. // the given name in this mutation.
  14151. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  14152. switch name {
  14153. case sopstage.EdgeStageNodes:
  14154. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  14155. for id := range m.removedstage_nodes {
  14156. ids = append(ids, id)
  14157. }
  14158. return ids
  14159. case sopstage.EdgeStageMessages:
  14160. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  14161. for id := range m.removedstage_messages {
  14162. ids = append(ids, id)
  14163. }
  14164. return ids
  14165. }
  14166. return nil
  14167. }
  14168. // ClearedEdges returns all edge names that were cleared in this mutation.
  14169. func (m *SopStageMutation) ClearedEdges() []string {
  14170. edges := make([]string, 0, 3)
  14171. if m.clearedsop_task {
  14172. edges = append(edges, sopstage.EdgeSopTask)
  14173. }
  14174. if m.clearedstage_nodes {
  14175. edges = append(edges, sopstage.EdgeStageNodes)
  14176. }
  14177. if m.clearedstage_messages {
  14178. edges = append(edges, sopstage.EdgeStageMessages)
  14179. }
  14180. return edges
  14181. }
  14182. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14183. // was cleared in this mutation.
  14184. func (m *SopStageMutation) EdgeCleared(name string) bool {
  14185. switch name {
  14186. case sopstage.EdgeSopTask:
  14187. return m.clearedsop_task
  14188. case sopstage.EdgeStageNodes:
  14189. return m.clearedstage_nodes
  14190. case sopstage.EdgeStageMessages:
  14191. return m.clearedstage_messages
  14192. }
  14193. return false
  14194. }
  14195. // ClearEdge clears the value of the edge with the given name. It returns an error
  14196. // if that edge is not defined in the schema.
  14197. func (m *SopStageMutation) ClearEdge(name string) error {
  14198. switch name {
  14199. case sopstage.EdgeSopTask:
  14200. m.ClearSopTask()
  14201. return nil
  14202. }
  14203. return fmt.Errorf("unknown SopStage unique edge %s", name)
  14204. }
  14205. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14206. // It returns an error if the edge is not defined in the schema.
  14207. func (m *SopStageMutation) ResetEdge(name string) error {
  14208. switch name {
  14209. case sopstage.EdgeSopTask:
  14210. m.ResetSopTask()
  14211. return nil
  14212. case sopstage.EdgeStageNodes:
  14213. m.ResetStageNodes()
  14214. return nil
  14215. case sopstage.EdgeStageMessages:
  14216. m.ResetStageMessages()
  14217. return nil
  14218. }
  14219. return fmt.Errorf("unknown SopStage edge %s", name)
  14220. }
  14221. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  14222. type SopTaskMutation struct {
  14223. config
  14224. op Op
  14225. typ string
  14226. id *uint64
  14227. created_at *time.Time
  14228. updated_at *time.Time
  14229. status *uint8
  14230. addstatus *int8
  14231. deleted_at *time.Time
  14232. name *string
  14233. bot_wxid_list *[]string
  14234. appendbot_wxid_list []string
  14235. _type *int
  14236. add_type *int
  14237. plan_start_time *time.Time
  14238. plan_end_time *time.Time
  14239. creator_id *string
  14240. organization_id *uint64
  14241. addorganization_id *int64
  14242. clearedFields map[string]struct{}
  14243. task_stages map[uint64]struct{}
  14244. removedtask_stages map[uint64]struct{}
  14245. clearedtask_stages bool
  14246. done bool
  14247. oldValue func(context.Context) (*SopTask, error)
  14248. predicates []predicate.SopTask
  14249. }
  14250. var _ ent.Mutation = (*SopTaskMutation)(nil)
  14251. // soptaskOption allows management of the mutation configuration using functional options.
  14252. type soptaskOption func(*SopTaskMutation)
  14253. // newSopTaskMutation creates new mutation for the SopTask entity.
  14254. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  14255. m := &SopTaskMutation{
  14256. config: c,
  14257. op: op,
  14258. typ: TypeSopTask,
  14259. clearedFields: make(map[string]struct{}),
  14260. }
  14261. for _, opt := range opts {
  14262. opt(m)
  14263. }
  14264. return m
  14265. }
  14266. // withSopTaskID sets the ID field of the mutation.
  14267. func withSopTaskID(id uint64) soptaskOption {
  14268. return func(m *SopTaskMutation) {
  14269. var (
  14270. err error
  14271. once sync.Once
  14272. value *SopTask
  14273. )
  14274. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  14275. once.Do(func() {
  14276. if m.done {
  14277. err = errors.New("querying old values post mutation is not allowed")
  14278. } else {
  14279. value, err = m.Client().SopTask.Get(ctx, id)
  14280. }
  14281. })
  14282. return value, err
  14283. }
  14284. m.id = &id
  14285. }
  14286. }
  14287. // withSopTask sets the old SopTask of the mutation.
  14288. func withSopTask(node *SopTask) soptaskOption {
  14289. return func(m *SopTaskMutation) {
  14290. m.oldValue = func(context.Context) (*SopTask, error) {
  14291. return node, nil
  14292. }
  14293. m.id = &node.ID
  14294. }
  14295. }
  14296. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14297. // executed in a transaction (ent.Tx), a transactional client is returned.
  14298. func (m SopTaskMutation) Client() *Client {
  14299. client := &Client{config: m.config}
  14300. client.init()
  14301. return client
  14302. }
  14303. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14304. // it returns an error otherwise.
  14305. func (m SopTaskMutation) Tx() (*Tx, error) {
  14306. if _, ok := m.driver.(*txDriver); !ok {
  14307. return nil, errors.New("ent: mutation is not running in a transaction")
  14308. }
  14309. tx := &Tx{config: m.config}
  14310. tx.init()
  14311. return tx, nil
  14312. }
  14313. // SetID sets the value of the id field. Note that this
  14314. // operation is only accepted on creation of SopTask entities.
  14315. func (m *SopTaskMutation) SetID(id uint64) {
  14316. m.id = &id
  14317. }
  14318. // ID returns the ID value in the mutation. Note that the ID is only available
  14319. // if it was provided to the builder or after it was returned from the database.
  14320. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  14321. if m.id == nil {
  14322. return
  14323. }
  14324. return *m.id, true
  14325. }
  14326. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14327. // That means, if the mutation is applied within a transaction with an isolation level such
  14328. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14329. // or updated by the mutation.
  14330. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  14331. switch {
  14332. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14333. id, exists := m.ID()
  14334. if exists {
  14335. return []uint64{id}, nil
  14336. }
  14337. fallthrough
  14338. case m.op.Is(OpUpdate | OpDelete):
  14339. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  14340. default:
  14341. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14342. }
  14343. }
  14344. // SetCreatedAt sets the "created_at" field.
  14345. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  14346. m.created_at = &t
  14347. }
  14348. // CreatedAt returns the value of the "created_at" field in the mutation.
  14349. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  14350. v := m.created_at
  14351. if v == nil {
  14352. return
  14353. }
  14354. return *v, true
  14355. }
  14356. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  14357. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14359. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14360. if !m.op.Is(OpUpdateOne) {
  14361. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14362. }
  14363. if m.id == nil || m.oldValue == nil {
  14364. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14365. }
  14366. oldValue, err := m.oldValue(ctx)
  14367. if err != nil {
  14368. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14369. }
  14370. return oldValue.CreatedAt, nil
  14371. }
  14372. // ResetCreatedAt resets all changes to the "created_at" field.
  14373. func (m *SopTaskMutation) ResetCreatedAt() {
  14374. m.created_at = nil
  14375. }
  14376. // SetUpdatedAt sets the "updated_at" field.
  14377. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  14378. m.updated_at = &t
  14379. }
  14380. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14381. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  14382. v := m.updated_at
  14383. if v == nil {
  14384. return
  14385. }
  14386. return *v, true
  14387. }
  14388. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  14389. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14391. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14392. if !m.op.Is(OpUpdateOne) {
  14393. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14394. }
  14395. if m.id == nil || m.oldValue == nil {
  14396. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14397. }
  14398. oldValue, err := m.oldValue(ctx)
  14399. if err != nil {
  14400. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14401. }
  14402. return oldValue.UpdatedAt, nil
  14403. }
  14404. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14405. func (m *SopTaskMutation) ResetUpdatedAt() {
  14406. m.updated_at = nil
  14407. }
  14408. // SetStatus sets the "status" field.
  14409. func (m *SopTaskMutation) SetStatus(u uint8) {
  14410. m.status = &u
  14411. m.addstatus = nil
  14412. }
  14413. // Status returns the value of the "status" field in the mutation.
  14414. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  14415. v := m.status
  14416. if v == nil {
  14417. return
  14418. }
  14419. return *v, true
  14420. }
  14421. // OldStatus returns the old "status" field's value of the SopTask entity.
  14422. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14424. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14425. if !m.op.Is(OpUpdateOne) {
  14426. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14427. }
  14428. if m.id == nil || m.oldValue == nil {
  14429. return v, errors.New("OldStatus requires an ID field in the mutation")
  14430. }
  14431. oldValue, err := m.oldValue(ctx)
  14432. if err != nil {
  14433. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14434. }
  14435. return oldValue.Status, nil
  14436. }
  14437. // AddStatus adds u to the "status" field.
  14438. func (m *SopTaskMutation) AddStatus(u int8) {
  14439. if m.addstatus != nil {
  14440. *m.addstatus += u
  14441. } else {
  14442. m.addstatus = &u
  14443. }
  14444. }
  14445. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14446. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  14447. v := m.addstatus
  14448. if v == nil {
  14449. return
  14450. }
  14451. return *v, true
  14452. }
  14453. // ClearStatus clears the value of the "status" field.
  14454. func (m *SopTaskMutation) ClearStatus() {
  14455. m.status = nil
  14456. m.addstatus = nil
  14457. m.clearedFields[soptask.FieldStatus] = struct{}{}
  14458. }
  14459. // StatusCleared returns if the "status" field was cleared in this mutation.
  14460. func (m *SopTaskMutation) StatusCleared() bool {
  14461. _, ok := m.clearedFields[soptask.FieldStatus]
  14462. return ok
  14463. }
  14464. // ResetStatus resets all changes to the "status" field.
  14465. func (m *SopTaskMutation) ResetStatus() {
  14466. m.status = nil
  14467. m.addstatus = nil
  14468. delete(m.clearedFields, soptask.FieldStatus)
  14469. }
  14470. // SetDeletedAt sets the "deleted_at" field.
  14471. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  14472. m.deleted_at = &t
  14473. }
  14474. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14475. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  14476. v := m.deleted_at
  14477. if v == nil {
  14478. return
  14479. }
  14480. return *v, true
  14481. }
  14482. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  14483. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14485. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14486. if !m.op.Is(OpUpdateOne) {
  14487. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14488. }
  14489. if m.id == nil || m.oldValue == nil {
  14490. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14491. }
  14492. oldValue, err := m.oldValue(ctx)
  14493. if err != nil {
  14494. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14495. }
  14496. return oldValue.DeletedAt, nil
  14497. }
  14498. // ClearDeletedAt clears the value of the "deleted_at" field.
  14499. func (m *SopTaskMutation) ClearDeletedAt() {
  14500. m.deleted_at = nil
  14501. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  14502. }
  14503. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14504. func (m *SopTaskMutation) DeletedAtCleared() bool {
  14505. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  14506. return ok
  14507. }
  14508. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14509. func (m *SopTaskMutation) ResetDeletedAt() {
  14510. m.deleted_at = nil
  14511. delete(m.clearedFields, soptask.FieldDeletedAt)
  14512. }
  14513. // SetName sets the "name" field.
  14514. func (m *SopTaskMutation) SetName(s string) {
  14515. m.name = &s
  14516. }
  14517. // Name returns the value of the "name" field in the mutation.
  14518. func (m *SopTaskMutation) Name() (r string, exists bool) {
  14519. v := m.name
  14520. if v == nil {
  14521. return
  14522. }
  14523. return *v, true
  14524. }
  14525. // OldName returns the old "name" field's value of the SopTask entity.
  14526. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14528. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  14529. if !m.op.Is(OpUpdateOne) {
  14530. return v, errors.New("OldName is only allowed on UpdateOne operations")
  14531. }
  14532. if m.id == nil || m.oldValue == nil {
  14533. return v, errors.New("OldName requires an ID field in the mutation")
  14534. }
  14535. oldValue, err := m.oldValue(ctx)
  14536. if err != nil {
  14537. return v, fmt.Errorf("querying old value for OldName: %w", err)
  14538. }
  14539. return oldValue.Name, nil
  14540. }
  14541. // ResetName resets all changes to the "name" field.
  14542. func (m *SopTaskMutation) ResetName() {
  14543. m.name = nil
  14544. }
  14545. // SetBotWxidList sets the "bot_wxid_list" field.
  14546. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  14547. m.bot_wxid_list = &s
  14548. m.appendbot_wxid_list = nil
  14549. }
  14550. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  14551. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  14552. v := m.bot_wxid_list
  14553. if v == nil {
  14554. return
  14555. }
  14556. return *v, true
  14557. }
  14558. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  14559. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14561. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  14562. if !m.op.Is(OpUpdateOne) {
  14563. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  14564. }
  14565. if m.id == nil || m.oldValue == nil {
  14566. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  14567. }
  14568. oldValue, err := m.oldValue(ctx)
  14569. if err != nil {
  14570. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  14571. }
  14572. return oldValue.BotWxidList, nil
  14573. }
  14574. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  14575. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  14576. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  14577. }
  14578. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  14579. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  14580. if len(m.appendbot_wxid_list) == 0 {
  14581. return nil, false
  14582. }
  14583. return m.appendbot_wxid_list, true
  14584. }
  14585. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  14586. func (m *SopTaskMutation) ClearBotWxidList() {
  14587. m.bot_wxid_list = nil
  14588. m.appendbot_wxid_list = nil
  14589. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  14590. }
  14591. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  14592. func (m *SopTaskMutation) BotWxidListCleared() bool {
  14593. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  14594. return ok
  14595. }
  14596. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  14597. func (m *SopTaskMutation) ResetBotWxidList() {
  14598. m.bot_wxid_list = nil
  14599. m.appendbot_wxid_list = nil
  14600. delete(m.clearedFields, soptask.FieldBotWxidList)
  14601. }
  14602. // SetType sets the "type" field.
  14603. func (m *SopTaskMutation) SetType(i int) {
  14604. m._type = &i
  14605. m.add_type = nil
  14606. }
  14607. // GetType returns the value of the "type" field in the mutation.
  14608. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  14609. v := m._type
  14610. if v == nil {
  14611. return
  14612. }
  14613. return *v, true
  14614. }
  14615. // OldType returns the old "type" field's value of the SopTask entity.
  14616. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14617. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14618. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  14619. if !m.op.Is(OpUpdateOne) {
  14620. return v, errors.New("OldType is only allowed on UpdateOne operations")
  14621. }
  14622. if m.id == nil || m.oldValue == nil {
  14623. return v, errors.New("OldType requires an ID field in the mutation")
  14624. }
  14625. oldValue, err := m.oldValue(ctx)
  14626. if err != nil {
  14627. return v, fmt.Errorf("querying old value for OldType: %w", err)
  14628. }
  14629. return oldValue.Type, nil
  14630. }
  14631. // AddType adds i to the "type" field.
  14632. func (m *SopTaskMutation) AddType(i int) {
  14633. if m.add_type != nil {
  14634. *m.add_type += i
  14635. } else {
  14636. m.add_type = &i
  14637. }
  14638. }
  14639. // AddedType returns the value that was added to the "type" field in this mutation.
  14640. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  14641. v := m.add_type
  14642. if v == nil {
  14643. return
  14644. }
  14645. return *v, true
  14646. }
  14647. // ResetType resets all changes to the "type" field.
  14648. func (m *SopTaskMutation) ResetType() {
  14649. m._type = nil
  14650. m.add_type = nil
  14651. }
  14652. // SetPlanStartTime sets the "plan_start_time" field.
  14653. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  14654. m.plan_start_time = &t
  14655. }
  14656. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  14657. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  14658. v := m.plan_start_time
  14659. if v == nil {
  14660. return
  14661. }
  14662. return *v, true
  14663. }
  14664. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  14665. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14667. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  14668. if !m.op.Is(OpUpdateOne) {
  14669. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  14670. }
  14671. if m.id == nil || m.oldValue == nil {
  14672. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  14673. }
  14674. oldValue, err := m.oldValue(ctx)
  14675. if err != nil {
  14676. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  14677. }
  14678. return oldValue.PlanStartTime, nil
  14679. }
  14680. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  14681. func (m *SopTaskMutation) ClearPlanStartTime() {
  14682. m.plan_start_time = nil
  14683. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  14684. }
  14685. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  14686. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  14687. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  14688. return ok
  14689. }
  14690. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  14691. func (m *SopTaskMutation) ResetPlanStartTime() {
  14692. m.plan_start_time = nil
  14693. delete(m.clearedFields, soptask.FieldPlanStartTime)
  14694. }
  14695. // SetPlanEndTime sets the "plan_end_time" field.
  14696. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  14697. m.plan_end_time = &t
  14698. }
  14699. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  14700. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  14701. v := m.plan_end_time
  14702. if v == nil {
  14703. return
  14704. }
  14705. return *v, true
  14706. }
  14707. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  14708. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14710. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  14711. if !m.op.Is(OpUpdateOne) {
  14712. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  14713. }
  14714. if m.id == nil || m.oldValue == nil {
  14715. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  14716. }
  14717. oldValue, err := m.oldValue(ctx)
  14718. if err != nil {
  14719. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  14720. }
  14721. return oldValue.PlanEndTime, nil
  14722. }
  14723. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  14724. func (m *SopTaskMutation) ClearPlanEndTime() {
  14725. m.plan_end_time = nil
  14726. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  14727. }
  14728. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  14729. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  14730. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  14731. return ok
  14732. }
  14733. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  14734. func (m *SopTaskMutation) ResetPlanEndTime() {
  14735. m.plan_end_time = nil
  14736. delete(m.clearedFields, soptask.FieldPlanEndTime)
  14737. }
  14738. // SetCreatorID sets the "creator_id" field.
  14739. func (m *SopTaskMutation) SetCreatorID(s string) {
  14740. m.creator_id = &s
  14741. }
  14742. // CreatorID returns the value of the "creator_id" field in the mutation.
  14743. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  14744. v := m.creator_id
  14745. if v == nil {
  14746. return
  14747. }
  14748. return *v, true
  14749. }
  14750. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  14751. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14753. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  14754. if !m.op.Is(OpUpdateOne) {
  14755. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  14756. }
  14757. if m.id == nil || m.oldValue == nil {
  14758. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  14759. }
  14760. oldValue, err := m.oldValue(ctx)
  14761. if err != nil {
  14762. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  14763. }
  14764. return oldValue.CreatorID, nil
  14765. }
  14766. // ClearCreatorID clears the value of the "creator_id" field.
  14767. func (m *SopTaskMutation) ClearCreatorID() {
  14768. m.creator_id = nil
  14769. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  14770. }
  14771. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  14772. func (m *SopTaskMutation) CreatorIDCleared() bool {
  14773. _, ok := m.clearedFields[soptask.FieldCreatorID]
  14774. return ok
  14775. }
  14776. // ResetCreatorID resets all changes to the "creator_id" field.
  14777. func (m *SopTaskMutation) ResetCreatorID() {
  14778. m.creator_id = nil
  14779. delete(m.clearedFields, soptask.FieldCreatorID)
  14780. }
  14781. // SetOrganizationID sets the "organization_id" field.
  14782. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  14783. m.organization_id = &u
  14784. m.addorganization_id = nil
  14785. }
  14786. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14787. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  14788. v := m.organization_id
  14789. if v == nil {
  14790. return
  14791. }
  14792. return *v, true
  14793. }
  14794. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  14795. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14797. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14798. if !m.op.Is(OpUpdateOne) {
  14799. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14800. }
  14801. if m.id == nil || m.oldValue == nil {
  14802. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14803. }
  14804. oldValue, err := m.oldValue(ctx)
  14805. if err != nil {
  14806. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14807. }
  14808. return oldValue.OrganizationID, nil
  14809. }
  14810. // AddOrganizationID adds u to the "organization_id" field.
  14811. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  14812. if m.addorganization_id != nil {
  14813. *m.addorganization_id += u
  14814. } else {
  14815. m.addorganization_id = &u
  14816. }
  14817. }
  14818. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14819. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  14820. v := m.addorganization_id
  14821. if v == nil {
  14822. return
  14823. }
  14824. return *v, true
  14825. }
  14826. // ClearOrganizationID clears the value of the "organization_id" field.
  14827. func (m *SopTaskMutation) ClearOrganizationID() {
  14828. m.organization_id = nil
  14829. m.addorganization_id = nil
  14830. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  14831. }
  14832. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14833. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  14834. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  14835. return ok
  14836. }
  14837. // ResetOrganizationID resets all changes to the "organization_id" field.
  14838. func (m *SopTaskMutation) ResetOrganizationID() {
  14839. m.organization_id = nil
  14840. m.addorganization_id = nil
  14841. delete(m.clearedFields, soptask.FieldOrganizationID)
  14842. }
  14843. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  14844. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  14845. if m.task_stages == nil {
  14846. m.task_stages = make(map[uint64]struct{})
  14847. }
  14848. for i := range ids {
  14849. m.task_stages[ids[i]] = struct{}{}
  14850. }
  14851. }
  14852. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  14853. func (m *SopTaskMutation) ClearTaskStages() {
  14854. m.clearedtask_stages = true
  14855. }
  14856. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  14857. func (m *SopTaskMutation) TaskStagesCleared() bool {
  14858. return m.clearedtask_stages
  14859. }
  14860. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  14861. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  14862. if m.removedtask_stages == nil {
  14863. m.removedtask_stages = make(map[uint64]struct{})
  14864. }
  14865. for i := range ids {
  14866. delete(m.task_stages, ids[i])
  14867. m.removedtask_stages[ids[i]] = struct{}{}
  14868. }
  14869. }
  14870. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  14871. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  14872. for id := range m.removedtask_stages {
  14873. ids = append(ids, id)
  14874. }
  14875. return
  14876. }
  14877. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  14878. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  14879. for id := range m.task_stages {
  14880. ids = append(ids, id)
  14881. }
  14882. return
  14883. }
  14884. // ResetTaskStages resets all changes to the "task_stages" edge.
  14885. func (m *SopTaskMutation) ResetTaskStages() {
  14886. m.task_stages = nil
  14887. m.clearedtask_stages = false
  14888. m.removedtask_stages = nil
  14889. }
  14890. // Where appends a list predicates to the SopTaskMutation builder.
  14891. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  14892. m.predicates = append(m.predicates, ps...)
  14893. }
  14894. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  14895. // users can use type-assertion to append predicates that do not depend on any generated package.
  14896. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  14897. p := make([]predicate.SopTask, len(ps))
  14898. for i := range ps {
  14899. p[i] = ps[i]
  14900. }
  14901. m.Where(p...)
  14902. }
  14903. // Op returns the operation name.
  14904. func (m *SopTaskMutation) Op() Op {
  14905. return m.op
  14906. }
  14907. // SetOp allows setting the mutation operation.
  14908. func (m *SopTaskMutation) SetOp(op Op) {
  14909. m.op = op
  14910. }
  14911. // Type returns the node type of this mutation (SopTask).
  14912. func (m *SopTaskMutation) Type() string {
  14913. return m.typ
  14914. }
  14915. // Fields returns all fields that were changed during this mutation. Note that in
  14916. // order to get all numeric fields that were incremented/decremented, call
  14917. // AddedFields().
  14918. func (m *SopTaskMutation) Fields() []string {
  14919. fields := make([]string, 0, 11)
  14920. if m.created_at != nil {
  14921. fields = append(fields, soptask.FieldCreatedAt)
  14922. }
  14923. if m.updated_at != nil {
  14924. fields = append(fields, soptask.FieldUpdatedAt)
  14925. }
  14926. if m.status != nil {
  14927. fields = append(fields, soptask.FieldStatus)
  14928. }
  14929. if m.deleted_at != nil {
  14930. fields = append(fields, soptask.FieldDeletedAt)
  14931. }
  14932. if m.name != nil {
  14933. fields = append(fields, soptask.FieldName)
  14934. }
  14935. if m.bot_wxid_list != nil {
  14936. fields = append(fields, soptask.FieldBotWxidList)
  14937. }
  14938. if m._type != nil {
  14939. fields = append(fields, soptask.FieldType)
  14940. }
  14941. if m.plan_start_time != nil {
  14942. fields = append(fields, soptask.FieldPlanStartTime)
  14943. }
  14944. if m.plan_end_time != nil {
  14945. fields = append(fields, soptask.FieldPlanEndTime)
  14946. }
  14947. if m.creator_id != nil {
  14948. fields = append(fields, soptask.FieldCreatorID)
  14949. }
  14950. if m.organization_id != nil {
  14951. fields = append(fields, soptask.FieldOrganizationID)
  14952. }
  14953. return fields
  14954. }
  14955. // Field returns the value of a field with the given name. The second boolean
  14956. // return value indicates that this field was not set, or was not defined in the
  14957. // schema.
  14958. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  14959. switch name {
  14960. case soptask.FieldCreatedAt:
  14961. return m.CreatedAt()
  14962. case soptask.FieldUpdatedAt:
  14963. return m.UpdatedAt()
  14964. case soptask.FieldStatus:
  14965. return m.Status()
  14966. case soptask.FieldDeletedAt:
  14967. return m.DeletedAt()
  14968. case soptask.FieldName:
  14969. return m.Name()
  14970. case soptask.FieldBotWxidList:
  14971. return m.BotWxidList()
  14972. case soptask.FieldType:
  14973. return m.GetType()
  14974. case soptask.FieldPlanStartTime:
  14975. return m.PlanStartTime()
  14976. case soptask.FieldPlanEndTime:
  14977. return m.PlanEndTime()
  14978. case soptask.FieldCreatorID:
  14979. return m.CreatorID()
  14980. case soptask.FieldOrganizationID:
  14981. return m.OrganizationID()
  14982. }
  14983. return nil, false
  14984. }
  14985. // OldField returns the old value of the field from the database. An error is
  14986. // returned if the mutation operation is not UpdateOne, or the query to the
  14987. // database failed.
  14988. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14989. switch name {
  14990. case soptask.FieldCreatedAt:
  14991. return m.OldCreatedAt(ctx)
  14992. case soptask.FieldUpdatedAt:
  14993. return m.OldUpdatedAt(ctx)
  14994. case soptask.FieldStatus:
  14995. return m.OldStatus(ctx)
  14996. case soptask.FieldDeletedAt:
  14997. return m.OldDeletedAt(ctx)
  14998. case soptask.FieldName:
  14999. return m.OldName(ctx)
  15000. case soptask.FieldBotWxidList:
  15001. return m.OldBotWxidList(ctx)
  15002. case soptask.FieldType:
  15003. return m.OldType(ctx)
  15004. case soptask.FieldPlanStartTime:
  15005. return m.OldPlanStartTime(ctx)
  15006. case soptask.FieldPlanEndTime:
  15007. return m.OldPlanEndTime(ctx)
  15008. case soptask.FieldCreatorID:
  15009. return m.OldCreatorID(ctx)
  15010. case soptask.FieldOrganizationID:
  15011. return m.OldOrganizationID(ctx)
  15012. }
  15013. return nil, fmt.Errorf("unknown SopTask field %s", name)
  15014. }
  15015. // SetField sets the value of a field with the given name. It returns an error if
  15016. // the field is not defined in the schema, or if the type mismatched the field
  15017. // type.
  15018. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  15019. switch name {
  15020. case soptask.FieldCreatedAt:
  15021. v, ok := value.(time.Time)
  15022. if !ok {
  15023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15024. }
  15025. m.SetCreatedAt(v)
  15026. return nil
  15027. case soptask.FieldUpdatedAt:
  15028. v, ok := value.(time.Time)
  15029. if !ok {
  15030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15031. }
  15032. m.SetUpdatedAt(v)
  15033. return nil
  15034. case soptask.FieldStatus:
  15035. v, ok := value.(uint8)
  15036. if !ok {
  15037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15038. }
  15039. m.SetStatus(v)
  15040. return nil
  15041. case soptask.FieldDeletedAt:
  15042. v, ok := value.(time.Time)
  15043. if !ok {
  15044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15045. }
  15046. m.SetDeletedAt(v)
  15047. return nil
  15048. case soptask.FieldName:
  15049. v, ok := value.(string)
  15050. if !ok {
  15051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15052. }
  15053. m.SetName(v)
  15054. return nil
  15055. case soptask.FieldBotWxidList:
  15056. v, ok := value.([]string)
  15057. if !ok {
  15058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15059. }
  15060. m.SetBotWxidList(v)
  15061. return nil
  15062. case soptask.FieldType:
  15063. v, ok := value.(int)
  15064. if !ok {
  15065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15066. }
  15067. m.SetType(v)
  15068. return nil
  15069. case soptask.FieldPlanStartTime:
  15070. v, ok := value.(time.Time)
  15071. if !ok {
  15072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15073. }
  15074. m.SetPlanStartTime(v)
  15075. return nil
  15076. case soptask.FieldPlanEndTime:
  15077. v, ok := value.(time.Time)
  15078. if !ok {
  15079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15080. }
  15081. m.SetPlanEndTime(v)
  15082. return nil
  15083. case soptask.FieldCreatorID:
  15084. v, ok := value.(string)
  15085. if !ok {
  15086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15087. }
  15088. m.SetCreatorID(v)
  15089. return nil
  15090. case soptask.FieldOrganizationID:
  15091. v, ok := value.(uint64)
  15092. if !ok {
  15093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15094. }
  15095. m.SetOrganizationID(v)
  15096. return nil
  15097. }
  15098. return fmt.Errorf("unknown SopTask field %s", name)
  15099. }
  15100. // AddedFields returns all numeric fields that were incremented/decremented during
  15101. // this mutation.
  15102. func (m *SopTaskMutation) AddedFields() []string {
  15103. var fields []string
  15104. if m.addstatus != nil {
  15105. fields = append(fields, soptask.FieldStatus)
  15106. }
  15107. if m.add_type != nil {
  15108. fields = append(fields, soptask.FieldType)
  15109. }
  15110. if m.addorganization_id != nil {
  15111. fields = append(fields, soptask.FieldOrganizationID)
  15112. }
  15113. return fields
  15114. }
  15115. // AddedField returns the numeric value that was incremented/decremented on a field
  15116. // with the given name. The second boolean return value indicates that this field
  15117. // was not set, or was not defined in the schema.
  15118. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  15119. switch name {
  15120. case soptask.FieldStatus:
  15121. return m.AddedStatus()
  15122. case soptask.FieldType:
  15123. return m.AddedType()
  15124. case soptask.FieldOrganizationID:
  15125. return m.AddedOrganizationID()
  15126. }
  15127. return nil, false
  15128. }
  15129. // AddField adds the value to the field with the given name. It returns an error if
  15130. // the field is not defined in the schema, or if the type mismatched the field
  15131. // type.
  15132. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  15133. switch name {
  15134. case soptask.FieldStatus:
  15135. v, ok := value.(int8)
  15136. if !ok {
  15137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15138. }
  15139. m.AddStatus(v)
  15140. return nil
  15141. case soptask.FieldType:
  15142. v, ok := value.(int)
  15143. if !ok {
  15144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15145. }
  15146. m.AddType(v)
  15147. return nil
  15148. case soptask.FieldOrganizationID:
  15149. v, ok := value.(int64)
  15150. if !ok {
  15151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15152. }
  15153. m.AddOrganizationID(v)
  15154. return nil
  15155. }
  15156. return fmt.Errorf("unknown SopTask numeric field %s", name)
  15157. }
  15158. // ClearedFields returns all nullable fields that were cleared during this
  15159. // mutation.
  15160. func (m *SopTaskMutation) ClearedFields() []string {
  15161. var fields []string
  15162. if m.FieldCleared(soptask.FieldStatus) {
  15163. fields = append(fields, soptask.FieldStatus)
  15164. }
  15165. if m.FieldCleared(soptask.FieldDeletedAt) {
  15166. fields = append(fields, soptask.FieldDeletedAt)
  15167. }
  15168. if m.FieldCleared(soptask.FieldBotWxidList) {
  15169. fields = append(fields, soptask.FieldBotWxidList)
  15170. }
  15171. if m.FieldCleared(soptask.FieldPlanStartTime) {
  15172. fields = append(fields, soptask.FieldPlanStartTime)
  15173. }
  15174. if m.FieldCleared(soptask.FieldPlanEndTime) {
  15175. fields = append(fields, soptask.FieldPlanEndTime)
  15176. }
  15177. if m.FieldCleared(soptask.FieldCreatorID) {
  15178. fields = append(fields, soptask.FieldCreatorID)
  15179. }
  15180. if m.FieldCleared(soptask.FieldOrganizationID) {
  15181. fields = append(fields, soptask.FieldOrganizationID)
  15182. }
  15183. return fields
  15184. }
  15185. // FieldCleared returns a boolean indicating if a field with the given name was
  15186. // cleared in this mutation.
  15187. func (m *SopTaskMutation) FieldCleared(name string) bool {
  15188. _, ok := m.clearedFields[name]
  15189. return ok
  15190. }
  15191. // ClearField clears the value of the field with the given name. It returns an
  15192. // error if the field is not defined in the schema.
  15193. func (m *SopTaskMutation) ClearField(name string) error {
  15194. switch name {
  15195. case soptask.FieldStatus:
  15196. m.ClearStatus()
  15197. return nil
  15198. case soptask.FieldDeletedAt:
  15199. m.ClearDeletedAt()
  15200. return nil
  15201. case soptask.FieldBotWxidList:
  15202. m.ClearBotWxidList()
  15203. return nil
  15204. case soptask.FieldPlanStartTime:
  15205. m.ClearPlanStartTime()
  15206. return nil
  15207. case soptask.FieldPlanEndTime:
  15208. m.ClearPlanEndTime()
  15209. return nil
  15210. case soptask.FieldCreatorID:
  15211. m.ClearCreatorID()
  15212. return nil
  15213. case soptask.FieldOrganizationID:
  15214. m.ClearOrganizationID()
  15215. return nil
  15216. }
  15217. return fmt.Errorf("unknown SopTask nullable field %s", name)
  15218. }
  15219. // ResetField resets all changes in the mutation for the field with the given name.
  15220. // It returns an error if the field is not defined in the schema.
  15221. func (m *SopTaskMutation) ResetField(name string) error {
  15222. switch name {
  15223. case soptask.FieldCreatedAt:
  15224. m.ResetCreatedAt()
  15225. return nil
  15226. case soptask.FieldUpdatedAt:
  15227. m.ResetUpdatedAt()
  15228. return nil
  15229. case soptask.FieldStatus:
  15230. m.ResetStatus()
  15231. return nil
  15232. case soptask.FieldDeletedAt:
  15233. m.ResetDeletedAt()
  15234. return nil
  15235. case soptask.FieldName:
  15236. m.ResetName()
  15237. return nil
  15238. case soptask.FieldBotWxidList:
  15239. m.ResetBotWxidList()
  15240. return nil
  15241. case soptask.FieldType:
  15242. m.ResetType()
  15243. return nil
  15244. case soptask.FieldPlanStartTime:
  15245. m.ResetPlanStartTime()
  15246. return nil
  15247. case soptask.FieldPlanEndTime:
  15248. m.ResetPlanEndTime()
  15249. return nil
  15250. case soptask.FieldCreatorID:
  15251. m.ResetCreatorID()
  15252. return nil
  15253. case soptask.FieldOrganizationID:
  15254. m.ResetOrganizationID()
  15255. return nil
  15256. }
  15257. return fmt.Errorf("unknown SopTask field %s", name)
  15258. }
  15259. // AddedEdges returns all edge names that were set/added in this mutation.
  15260. func (m *SopTaskMutation) AddedEdges() []string {
  15261. edges := make([]string, 0, 1)
  15262. if m.task_stages != nil {
  15263. edges = append(edges, soptask.EdgeTaskStages)
  15264. }
  15265. return edges
  15266. }
  15267. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15268. // name in this mutation.
  15269. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  15270. switch name {
  15271. case soptask.EdgeTaskStages:
  15272. ids := make([]ent.Value, 0, len(m.task_stages))
  15273. for id := range m.task_stages {
  15274. ids = append(ids, id)
  15275. }
  15276. return ids
  15277. }
  15278. return nil
  15279. }
  15280. // RemovedEdges returns all edge names that were removed in this mutation.
  15281. func (m *SopTaskMutation) RemovedEdges() []string {
  15282. edges := make([]string, 0, 1)
  15283. if m.removedtask_stages != nil {
  15284. edges = append(edges, soptask.EdgeTaskStages)
  15285. }
  15286. return edges
  15287. }
  15288. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15289. // the given name in this mutation.
  15290. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  15291. switch name {
  15292. case soptask.EdgeTaskStages:
  15293. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  15294. for id := range m.removedtask_stages {
  15295. ids = append(ids, id)
  15296. }
  15297. return ids
  15298. }
  15299. return nil
  15300. }
  15301. // ClearedEdges returns all edge names that were cleared in this mutation.
  15302. func (m *SopTaskMutation) ClearedEdges() []string {
  15303. edges := make([]string, 0, 1)
  15304. if m.clearedtask_stages {
  15305. edges = append(edges, soptask.EdgeTaskStages)
  15306. }
  15307. return edges
  15308. }
  15309. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15310. // was cleared in this mutation.
  15311. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  15312. switch name {
  15313. case soptask.EdgeTaskStages:
  15314. return m.clearedtask_stages
  15315. }
  15316. return false
  15317. }
  15318. // ClearEdge clears the value of the edge with the given name. It returns an error
  15319. // if that edge is not defined in the schema.
  15320. func (m *SopTaskMutation) ClearEdge(name string) error {
  15321. switch name {
  15322. }
  15323. return fmt.Errorf("unknown SopTask unique edge %s", name)
  15324. }
  15325. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15326. // It returns an error if the edge is not defined in the schema.
  15327. func (m *SopTaskMutation) ResetEdge(name string) error {
  15328. switch name {
  15329. case soptask.EdgeTaskStages:
  15330. m.ResetTaskStages()
  15331. return nil
  15332. }
  15333. return fmt.Errorf("unknown SopTask edge %s", name)
  15334. }
  15335. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  15336. type TokenMutation struct {
  15337. config
  15338. op Op
  15339. typ string
  15340. id *uint64
  15341. created_at *time.Time
  15342. updated_at *time.Time
  15343. deleted_at *time.Time
  15344. expire_at *time.Time
  15345. token *string
  15346. mac *string
  15347. clearedFields map[string]struct{}
  15348. done bool
  15349. oldValue func(context.Context) (*Token, error)
  15350. predicates []predicate.Token
  15351. }
  15352. var _ ent.Mutation = (*TokenMutation)(nil)
  15353. // tokenOption allows management of the mutation configuration using functional options.
  15354. type tokenOption func(*TokenMutation)
  15355. // newTokenMutation creates new mutation for the Token entity.
  15356. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  15357. m := &TokenMutation{
  15358. config: c,
  15359. op: op,
  15360. typ: TypeToken,
  15361. clearedFields: make(map[string]struct{}),
  15362. }
  15363. for _, opt := range opts {
  15364. opt(m)
  15365. }
  15366. return m
  15367. }
  15368. // withTokenID sets the ID field of the mutation.
  15369. func withTokenID(id uint64) tokenOption {
  15370. return func(m *TokenMutation) {
  15371. var (
  15372. err error
  15373. once sync.Once
  15374. value *Token
  15375. )
  15376. m.oldValue = func(ctx context.Context) (*Token, error) {
  15377. once.Do(func() {
  15378. if m.done {
  15379. err = errors.New("querying old values post mutation is not allowed")
  15380. } else {
  15381. value, err = m.Client().Token.Get(ctx, id)
  15382. }
  15383. })
  15384. return value, err
  15385. }
  15386. m.id = &id
  15387. }
  15388. }
  15389. // withToken sets the old Token of the mutation.
  15390. func withToken(node *Token) tokenOption {
  15391. return func(m *TokenMutation) {
  15392. m.oldValue = func(context.Context) (*Token, error) {
  15393. return node, nil
  15394. }
  15395. m.id = &node.ID
  15396. }
  15397. }
  15398. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15399. // executed in a transaction (ent.Tx), a transactional client is returned.
  15400. func (m TokenMutation) Client() *Client {
  15401. client := &Client{config: m.config}
  15402. client.init()
  15403. return client
  15404. }
  15405. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15406. // it returns an error otherwise.
  15407. func (m TokenMutation) Tx() (*Tx, error) {
  15408. if _, ok := m.driver.(*txDriver); !ok {
  15409. return nil, errors.New("ent: mutation is not running in a transaction")
  15410. }
  15411. tx := &Tx{config: m.config}
  15412. tx.init()
  15413. return tx, nil
  15414. }
  15415. // SetID sets the value of the id field. Note that this
  15416. // operation is only accepted on creation of Token entities.
  15417. func (m *TokenMutation) SetID(id uint64) {
  15418. m.id = &id
  15419. }
  15420. // ID returns the ID value in the mutation. Note that the ID is only available
  15421. // if it was provided to the builder or after it was returned from the database.
  15422. func (m *TokenMutation) ID() (id uint64, exists bool) {
  15423. if m.id == nil {
  15424. return
  15425. }
  15426. return *m.id, true
  15427. }
  15428. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15429. // That means, if the mutation is applied within a transaction with an isolation level such
  15430. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15431. // or updated by the mutation.
  15432. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  15433. switch {
  15434. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15435. id, exists := m.ID()
  15436. if exists {
  15437. return []uint64{id}, nil
  15438. }
  15439. fallthrough
  15440. case m.op.Is(OpUpdate | OpDelete):
  15441. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  15442. default:
  15443. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15444. }
  15445. }
  15446. // SetCreatedAt sets the "created_at" field.
  15447. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  15448. m.created_at = &t
  15449. }
  15450. // CreatedAt returns the value of the "created_at" field in the mutation.
  15451. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  15452. v := m.created_at
  15453. if v == nil {
  15454. return
  15455. }
  15456. return *v, true
  15457. }
  15458. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  15459. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  15460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15461. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15462. if !m.op.Is(OpUpdateOne) {
  15463. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15464. }
  15465. if m.id == nil || m.oldValue == nil {
  15466. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15467. }
  15468. oldValue, err := m.oldValue(ctx)
  15469. if err != nil {
  15470. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15471. }
  15472. return oldValue.CreatedAt, nil
  15473. }
  15474. // ResetCreatedAt resets all changes to the "created_at" field.
  15475. func (m *TokenMutation) ResetCreatedAt() {
  15476. m.created_at = nil
  15477. }
  15478. // SetUpdatedAt sets the "updated_at" field.
  15479. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  15480. m.updated_at = &t
  15481. }
  15482. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15483. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  15484. v := m.updated_at
  15485. if v == nil {
  15486. return
  15487. }
  15488. return *v, true
  15489. }
  15490. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  15491. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  15492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15493. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15494. if !m.op.Is(OpUpdateOne) {
  15495. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15496. }
  15497. if m.id == nil || m.oldValue == nil {
  15498. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15499. }
  15500. oldValue, err := m.oldValue(ctx)
  15501. if err != nil {
  15502. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15503. }
  15504. return oldValue.UpdatedAt, nil
  15505. }
  15506. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15507. func (m *TokenMutation) ResetUpdatedAt() {
  15508. m.updated_at = nil
  15509. }
  15510. // SetDeletedAt sets the "deleted_at" field.
  15511. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  15512. m.deleted_at = &t
  15513. }
  15514. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15515. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  15516. v := m.deleted_at
  15517. if v == nil {
  15518. return
  15519. }
  15520. return *v, true
  15521. }
  15522. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  15523. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  15524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15525. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15526. if !m.op.Is(OpUpdateOne) {
  15527. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15528. }
  15529. if m.id == nil || m.oldValue == nil {
  15530. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15531. }
  15532. oldValue, err := m.oldValue(ctx)
  15533. if err != nil {
  15534. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15535. }
  15536. return oldValue.DeletedAt, nil
  15537. }
  15538. // ClearDeletedAt clears the value of the "deleted_at" field.
  15539. func (m *TokenMutation) ClearDeletedAt() {
  15540. m.deleted_at = nil
  15541. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  15542. }
  15543. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15544. func (m *TokenMutation) DeletedAtCleared() bool {
  15545. _, ok := m.clearedFields[token.FieldDeletedAt]
  15546. return ok
  15547. }
  15548. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15549. func (m *TokenMutation) ResetDeletedAt() {
  15550. m.deleted_at = nil
  15551. delete(m.clearedFields, token.FieldDeletedAt)
  15552. }
  15553. // SetExpireAt sets the "expire_at" field.
  15554. func (m *TokenMutation) SetExpireAt(t time.Time) {
  15555. m.expire_at = &t
  15556. }
  15557. // ExpireAt returns the value of the "expire_at" field in the mutation.
  15558. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  15559. v := m.expire_at
  15560. if v == nil {
  15561. return
  15562. }
  15563. return *v, true
  15564. }
  15565. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  15566. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  15567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15568. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  15569. if !m.op.Is(OpUpdateOne) {
  15570. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  15571. }
  15572. if m.id == nil || m.oldValue == nil {
  15573. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  15574. }
  15575. oldValue, err := m.oldValue(ctx)
  15576. if err != nil {
  15577. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  15578. }
  15579. return oldValue.ExpireAt, nil
  15580. }
  15581. // ClearExpireAt clears the value of the "expire_at" field.
  15582. func (m *TokenMutation) ClearExpireAt() {
  15583. m.expire_at = nil
  15584. m.clearedFields[token.FieldExpireAt] = struct{}{}
  15585. }
  15586. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  15587. func (m *TokenMutation) ExpireAtCleared() bool {
  15588. _, ok := m.clearedFields[token.FieldExpireAt]
  15589. return ok
  15590. }
  15591. // ResetExpireAt resets all changes to the "expire_at" field.
  15592. func (m *TokenMutation) ResetExpireAt() {
  15593. m.expire_at = nil
  15594. delete(m.clearedFields, token.FieldExpireAt)
  15595. }
  15596. // SetToken sets the "token" field.
  15597. func (m *TokenMutation) SetToken(s string) {
  15598. m.token = &s
  15599. }
  15600. // Token returns the value of the "token" field in the mutation.
  15601. func (m *TokenMutation) Token() (r string, exists bool) {
  15602. v := m.token
  15603. if v == nil {
  15604. return
  15605. }
  15606. return *v, true
  15607. }
  15608. // OldToken returns the old "token" field's value of the Token entity.
  15609. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  15610. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15611. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  15612. if !m.op.Is(OpUpdateOne) {
  15613. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  15614. }
  15615. if m.id == nil || m.oldValue == nil {
  15616. return v, errors.New("OldToken requires an ID field in the mutation")
  15617. }
  15618. oldValue, err := m.oldValue(ctx)
  15619. if err != nil {
  15620. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  15621. }
  15622. return oldValue.Token, nil
  15623. }
  15624. // ClearToken clears the value of the "token" field.
  15625. func (m *TokenMutation) ClearToken() {
  15626. m.token = nil
  15627. m.clearedFields[token.FieldToken] = struct{}{}
  15628. }
  15629. // TokenCleared returns if the "token" field was cleared in this mutation.
  15630. func (m *TokenMutation) TokenCleared() bool {
  15631. _, ok := m.clearedFields[token.FieldToken]
  15632. return ok
  15633. }
  15634. // ResetToken resets all changes to the "token" field.
  15635. func (m *TokenMutation) ResetToken() {
  15636. m.token = nil
  15637. delete(m.clearedFields, token.FieldToken)
  15638. }
  15639. // SetMAC sets the "mac" field.
  15640. func (m *TokenMutation) SetMAC(s string) {
  15641. m.mac = &s
  15642. }
  15643. // MAC returns the value of the "mac" field in the mutation.
  15644. func (m *TokenMutation) MAC() (r string, exists bool) {
  15645. v := m.mac
  15646. if v == nil {
  15647. return
  15648. }
  15649. return *v, true
  15650. }
  15651. // OldMAC returns the old "mac" field's value of the Token entity.
  15652. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  15653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15654. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  15655. if !m.op.Is(OpUpdateOne) {
  15656. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  15657. }
  15658. if m.id == nil || m.oldValue == nil {
  15659. return v, errors.New("OldMAC requires an ID field in the mutation")
  15660. }
  15661. oldValue, err := m.oldValue(ctx)
  15662. if err != nil {
  15663. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  15664. }
  15665. return oldValue.MAC, nil
  15666. }
  15667. // ResetMAC resets all changes to the "mac" field.
  15668. func (m *TokenMutation) ResetMAC() {
  15669. m.mac = nil
  15670. }
  15671. // Where appends a list predicates to the TokenMutation builder.
  15672. func (m *TokenMutation) Where(ps ...predicate.Token) {
  15673. m.predicates = append(m.predicates, ps...)
  15674. }
  15675. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  15676. // users can use type-assertion to append predicates that do not depend on any generated package.
  15677. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  15678. p := make([]predicate.Token, len(ps))
  15679. for i := range ps {
  15680. p[i] = ps[i]
  15681. }
  15682. m.Where(p...)
  15683. }
  15684. // Op returns the operation name.
  15685. func (m *TokenMutation) Op() Op {
  15686. return m.op
  15687. }
  15688. // SetOp allows setting the mutation operation.
  15689. func (m *TokenMutation) SetOp(op Op) {
  15690. m.op = op
  15691. }
  15692. // Type returns the node type of this mutation (Token).
  15693. func (m *TokenMutation) Type() string {
  15694. return m.typ
  15695. }
  15696. // Fields returns all fields that were changed during this mutation. Note that in
  15697. // order to get all numeric fields that were incremented/decremented, call
  15698. // AddedFields().
  15699. func (m *TokenMutation) Fields() []string {
  15700. fields := make([]string, 0, 6)
  15701. if m.created_at != nil {
  15702. fields = append(fields, token.FieldCreatedAt)
  15703. }
  15704. if m.updated_at != nil {
  15705. fields = append(fields, token.FieldUpdatedAt)
  15706. }
  15707. if m.deleted_at != nil {
  15708. fields = append(fields, token.FieldDeletedAt)
  15709. }
  15710. if m.expire_at != nil {
  15711. fields = append(fields, token.FieldExpireAt)
  15712. }
  15713. if m.token != nil {
  15714. fields = append(fields, token.FieldToken)
  15715. }
  15716. if m.mac != nil {
  15717. fields = append(fields, token.FieldMAC)
  15718. }
  15719. return fields
  15720. }
  15721. // Field returns the value of a field with the given name. The second boolean
  15722. // return value indicates that this field was not set, or was not defined in the
  15723. // schema.
  15724. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  15725. switch name {
  15726. case token.FieldCreatedAt:
  15727. return m.CreatedAt()
  15728. case token.FieldUpdatedAt:
  15729. return m.UpdatedAt()
  15730. case token.FieldDeletedAt:
  15731. return m.DeletedAt()
  15732. case token.FieldExpireAt:
  15733. return m.ExpireAt()
  15734. case token.FieldToken:
  15735. return m.Token()
  15736. case token.FieldMAC:
  15737. return m.MAC()
  15738. }
  15739. return nil, false
  15740. }
  15741. // OldField returns the old value of the field from the database. An error is
  15742. // returned if the mutation operation is not UpdateOne, or the query to the
  15743. // database failed.
  15744. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15745. switch name {
  15746. case token.FieldCreatedAt:
  15747. return m.OldCreatedAt(ctx)
  15748. case token.FieldUpdatedAt:
  15749. return m.OldUpdatedAt(ctx)
  15750. case token.FieldDeletedAt:
  15751. return m.OldDeletedAt(ctx)
  15752. case token.FieldExpireAt:
  15753. return m.OldExpireAt(ctx)
  15754. case token.FieldToken:
  15755. return m.OldToken(ctx)
  15756. case token.FieldMAC:
  15757. return m.OldMAC(ctx)
  15758. }
  15759. return nil, fmt.Errorf("unknown Token field %s", name)
  15760. }
  15761. // SetField sets the value of a field with the given name. It returns an error if
  15762. // the field is not defined in the schema, or if the type mismatched the field
  15763. // type.
  15764. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  15765. switch name {
  15766. case token.FieldCreatedAt:
  15767. v, ok := value.(time.Time)
  15768. if !ok {
  15769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15770. }
  15771. m.SetCreatedAt(v)
  15772. return nil
  15773. case token.FieldUpdatedAt:
  15774. v, ok := value.(time.Time)
  15775. if !ok {
  15776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15777. }
  15778. m.SetUpdatedAt(v)
  15779. return nil
  15780. case token.FieldDeletedAt:
  15781. v, ok := value.(time.Time)
  15782. if !ok {
  15783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15784. }
  15785. m.SetDeletedAt(v)
  15786. return nil
  15787. case token.FieldExpireAt:
  15788. v, ok := value.(time.Time)
  15789. if !ok {
  15790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15791. }
  15792. m.SetExpireAt(v)
  15793. return nil
  15794. case token.FieldToken:
  15795. v, ok := value.(string)
  15796. if !ok {
  15797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15798. }
  15799. m.SetToken(v)
  15800. return nil
  15801. case token.FieldMAC:
  15802. v, ok := value.(string)
  15803. if !ok {
  15804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15805. }
  15806. m.SetMAC(v)
  15807. return nil
  15808. }
  15809. return fmt.Errorf("unknown Token field %s", name)
  15810. }
  15811. // AddedFields returns all numeric fields that were incremented/decremented during
  15812. // this mutation.
  15813. func (m *TokenMutation) AddedFields() []string {
  15814. return nil
  15815. }
  15816. // AddedField returns the numeric value that was incremented/decremented on a field
  15817. // with the given name. The second boolean return value indicates that this field
  15818. // was not set, or was not defined in the schema.
  15819. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  15820. return nil, false
  15821. }
  15822. // AddField adds the value to the field with the given name. It returns an error if
  15823. // the field is not defined in the schema, or if the type mismatched the field
  15824. // type.
  15825. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  15826. switch name {
  15827. }
  15828. return fmt.Errorf("unknown Token numeric field %s", name)
  15829. }
  15830. // ClearedFields returns all nullable fields that were cleared during this
  15831. // mutation.
  15832. func (m *TokenMutation) ClearedFields() []string {
  15833. var fields []string
  15834. if m.FieldCleared(token.FieldDeletedAt) {
  15835. fields = append(fields, token.FieldDeletedAt)
  15836. }
  15837. if m.FieldCleared(token.FieldExpireAt) {
  15838. fields = append(fields, token.FieldExpireAt)
  15839. }
  15840. if m.FieldCleared(token.FieldToken) {
  15841. fields = append(fields, token.FieldToken)
  15842. }
  15843. return fields
  15844. }
  15845. // FieldCleared returns a boolean indicating if a field with the given name was
  15846. // cleared in this mutation.
  15847. func (m *TokenMutation) FieldCleared(name string) bool {
  15848. _, ok := m.clearedFields[name]
  15849. return ok
  15850. }
  15851. // ClearField clears the value of the field with the given name. It returns an
  15852. // error if the field is not defined in the schema.
  15853. func (m *TokenMutation) ClearField(name string) error {
  15854. switch name {
  15855. case token.FieldDeletedAt:
  15856. m.ClearDeletedAt()
  15857. return nil
  15858. case token.FieldExpireAt:
  15859. m.ClearExpireAt()
  15860. return nil
  15861. case token.FieldToken:
  15862. m.ClearToken()
  15863. return nil
  15864. }
  15865. return fmt.Errorf("unknown Token nullable field %s", name)
  15866. }
  15867. // ResetField resets all changes in the mutation for the field with the given name.
  15868. // It returns an error if the field is not defined in the schema.
  15869. func (m *TokenMutation) ResetField(name string) error {
  15870. switch name {
  15871. case token.FieldCreatedAt:
  15872. m.ResetCreatedAt()
  15873. return nil
  15874. case token.FieldUpdatedAt:
  15875. m.ResetUpdatedAt()
  15876. return nil
  15877. case token.FieldDeletedAt:
  15878. m.ResetDeletedAt()
  15879. return nil
  15880. case token.FieldExpireAt:
  15881. m.ResetExpireAt()
  15882. return nil
  15883. case token.FieldToken:
  15884. m.ResetToken()
  15885. return nil
  15886. case token.FieldMAC:
  15887. m.ResetMAC()
  15888. return nil
  15889. }
  15890. return fmt.Errorf("unknown Token field %s", name)
  15891. }
  15892. // AddedEdges returns all edge names that were set/added in this mutation.
  15893. func (m *TokenMutation) AddedEdges() []string {
  15894. edges := make([]string, 0, 0)
  15895. return edges
  15896. }
  15897. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15898. // name in this mutation.
  15899. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  15900. return nil
  15901. }
  15902. // RemovedEdges returns all edge names that were removed in this mutation.
  15903. func (m *TokenMutation) RemovedEdges() []string {
  15904. edges := make([]string, 0, 0)
  15905. return edges
  15906. }
  15907. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15908. // the given name in this mutation.
  15909. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  15910. return nil
  15911. }
  15912. // ClearedEdges returns all edge names that were cleared in this mutation.
  15913. func (m *TokenMutation) ClearedEdges() []string {
  15914. edges := make([]string, 0, 0)
  15915. return edges
  15916. }
  15917. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15918. // was cleared in this mutation.
  15919. func (m *TokenMutation) EdgeCleared(name string) bool {
  15920. return false
  15921. }
  15922. // ClearEdge clears the value of the edge with the given name. It returns an error
  15923. // if that edge is not defined in the schema.
  15924. func (m *TokenMutation) ClearEdge(name string) error {
  15925. return fmt.Errorf("unknown Token unique edge %s", name)
  15926. }
  15927. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15928. // It returns an error if the edge is not defined in the schema.
  15929. func (m *TokenMutation) ResetEdge(name string) error {
  15930. return fmt.Errorf("unknown Token edge %s", name)
  15931. }
  15932. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  15933. type TutorialMutation struct {
  15934. config
  15935. op Op
  15936. typ string
  15937. id *uint64
  15938. created_at *time.Time
  15939. updated_at *time.Time
  15940. deleted_at *time.Time
  15941. index *int
  15942. addindex *int
  15943. title *string
  15944. content *string
  15945. organization_id *uint64
  15946. addorganization_id *int64
  15947. clearedFields map[string]struct{}
  15948. employee *uint64
  15949. clearedemployee bool
  15950. done bool
  15951. oldValue func(context.Context) (*Tutorial, error)
  15952. predicates []predicate.Tutorial
  15953. }
  15954. var _ ent.Mutation = (*TutorialMutation)(nil)
  15955. // tutorialOption allows management of the mutation configuration using functional options.
  15956. type tutorialOption func(*TutorialMutation)
  15957. // newTutorialMutation creates new mutation for the Tutorial entity.
  15958. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  15959. m := &TutorialMutation{
  15960. config: c,
  15961. op: op,
  15962. typ: TypeTutorial,
  15963. clearedFields: make(map[string]struct{}),
  15964. }
  15965. for _, opt := range opts {
  15966. opt(m)
  15967. }
  15968. return m
  15969. }
  15970. // withTutorialID sets the ID field of the mutation.
  15971. func withTutorialID(id uint64) tutorialOption {
  15972. return func(m *TutorialMutation) {
  15973. var (
  15974. err error
  15975. once sync.Once
  15976. value *Tutorial
  15977. )
  15978. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  15979. once.Do(func() {
  15980. if m.done {
  15981. err = errors.New("querying old values post mutation is not allowed")
  15982. } else {
  15983. value, err = m.Client().Tutorial.Get(ctx, id)
  15984. }
  15985. })
  15986. return value, err
  15987. }
  15988. m.id = &id
  15989. }
  15990. }
  15991. // withTutorial sets the old Tutorial of the mutation.
  15992. func withTutorial(node *Tutorial) tutorialOption {
  15993. return func(m *TutorialMutation) {
  15994. m.oldValue = func(context.Context) (*Tutorial, error) {
  15995. return node, nil
  15996. }
  15997. m.id = &node.ID
  15998. }
  15999. }
  16000. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16001. // executed in a transaction (ent.Tx), a transactional client is returned.
  16002. func (m TutorialMutation) Client() *Client {
  16003. client := &Client{config: m.config}
  16004. client.init()
  16005. return client
  16006. }
  16007. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16008. // it returns an error otherwise.
  16009. func (m TutorialMutation) Tx() (*Tx, error) {
  16010. if _, ok := m.driver.(*txDriver); !ok {
  16011. return nil, errors.New("ent: mutation is not running in a transaction")
  16012. }
  16013. tx := &Tx{config: m.config}
  16014. tx.init()
  16015. return tx, nil
  16016. }
  16017. // SetID sets the value of the id field. Note that this
  16018. // operation is only accepted on creation of Tutorial entities.
  16019. func (m *TutorialMutation) SetID(id uint64) {
  16020. m.id = &id
  16021. }
  16022. // ID returns the ID value in the mutation. Note that the ID is only available
  16023. // if it was provided to the builder or after it was returned from the database.
  16024. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  16025. if m.id == nil {
  16026. return
  16027. }
  16028. return *m.id, true
  16029. }
  16030. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16031. // That means, if the mutation is applied within a transaction with an isolation level such
  16032. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16033. // or updated by the mutation.
  16034. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  16035. switch {
  16036. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16037. id, exists := m.ID()
  16038. if exists {
  16039. return []uint64{id}, nil
  16040. }
  16041. fallthrough
  16042. case m.op.Is(OpUpdate | OpDelete):
  16043. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  16044. default:
  16045. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16046. }
  16047. }
  16048. // SetCreatedAt sets the "created_at" field.
  16049. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  16050. m.created_at = &t
  16051. }
  16052. // CreatedAt returns the value of the "created_at" field in the mutation.
  16053. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  16054. v := m.created_at
  16055. if v == nil {
  16056. return
  16057. }
  16058. return *v, true
  16059. }
  16060. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  16061. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16063. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16064. if !m.op.Is(OpUpdateOne) {
  16065. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16066. }
  16067. if m.id == nil || m.oldValue == nil {
  16068. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16069. }
  16070. oldValue, err := m.oldValue(ctx)
  16071. if err != nil {
  16072. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16073. }
  16074. return oldValue.CreatedAt, nil
  16075. }
  16076. // ResetCreatedAt resets all changes to the "created_at" field.
  16077. func (m *TutorialMutation) ResetCreatedAt() {
  16078. m.created_at = nil
  16079. }
  16080. // SetUpdatedAt sets the "updated_at" field.
  16081. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  16082. m.updated_at = &t
  16083. }
  16084. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16085. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  16086. v := m.updated_at
  16087. if v == nil {
  16088. return
  16089. }
  16090. return *v, true
  16091. }
  16092. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  16093. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16095. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16096. if !m.op.Is(OpUpdateOne) {
  16097. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16098. }
  16099. if m.id == nil || m.oldValue == nil {
  16100. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16101. }
  16102. oldValue, err := m.oldValue(ctx)
  16103. if err != nil {
  16104. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16105. }
  16106. return oldValue.UpdatedAt, nil
  16107. }
  16108. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16109. func (m *TutorialMutation) ResetUpdatedAt() {
  16110. m.updated_at = nil
  16111. }
  16112. // SetDeletedAt sets the "deleted_at" field.
  16113. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  16114. m.deleted_at = &t
  16115. }
  16116. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16117. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  16118. v := m.deleted_at
  16119. if v == nil {
  16120. return
  16121. }
  16122. return *v, true
  16123. }
  16124. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  16125. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16127. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16128. if !m.op.Is(OpUpdateOne) {
  16129. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16130. }
  16131. if m.id == nil || m.oldValue == nil {
  16132. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16133. }
  16134. oldValue, err := m.oldValue(ctx)
  16135. if err != nil {
  16136. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16137. }
  16138. return oldValue.DeletedAt, nil
  16139. }
  16140. // ClearDeletedAt clears the value of the "deleted_at" field.
  16141. func (m *TutorialMutation) ClearDeletedAt() {
  16142. m.deleted_at = nil
  16143. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  16144. }
  16145. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16146. func (m *TutorialMutation) DeletedAtCleared() bool {
  16147. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  16148. return ok
  16149. }
  16150. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16151. func (m *TutorialMutation) ResetDeletedAt() {
  16152. m.deleted_at = nil
  16153. delete(m.clearedFields, tutorial.FieldDeletedAt)
  16154. }
  16155. // SetEmployeeID sets the "employee_id" field.
  16156. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  16157. m.employee = &u
  16158. }
  16159. // EmployeeID returns the value of the "employee_id" field in the mutation.
  16160. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  16161. v := m.employee
  16162. if v == nil {
  16163. return
  16164. }
  16165. return *v, true
  16166. }
  16167. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  16168. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16170. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  16171. if !m.op.Is(OpUpdateOne) {
  16172. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  16173. }
  16174. if m.id == nil || m.oldValue == nil {
  16175. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  16176. }
  16177. oldValue, err := m.oldValue(ctx)
  16178. if err != nil {
  16179. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  16180. }
  16181. return oldValue.EmployeeID, nil
  16182. }
  16183. // ResetEmployeeID resets all changes to the "employee_id" field.
  16184. func (m *TutorialMutation) ResetEmployeeID() {
  16185. m.employee = nil
  16186. }
  16187. // SetIndex sets the "index" field.
  16188. func (m *TutorialMutation) SetIndex(i int) {
  16189. m.index = &i
  16190. m.addindex = nil
  16191. }
  16192. // Index returns the value of the "index" field in the mutation.
  16193. func (m *TutorialMutation) Index() (r int, exists bool) {
  16194. v := m.index
  16195. if v == nil {
  16196. return
  16197. }
  16198. return *v, true
  16199. }
  16200. // OldIndex returns the old "index" field's value of the Tutorial entity.
  16201. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16203. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  16204. if !m.op.Is(OpUpdateOne) {
  16205. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  16206. }
  16207. if m.id == nil || m.oldValue == nil {
  16208. return v, errors.New("OldIndex requires an ID field in the mutation")
  16209. }
  16210. oldValue, err := m.oldValue(ctx)
  16211. if err != nil {
  16212. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  16213. }
  16214. return oldValue.Index, nil
  16215. }
  16216. // AddIndex adds i to the "index" field.
  16217. func (m *TutorialMutation) AddIndex(i int) {
  16218. if m.addindex != nil {
  16219. *m.addindex += i
  16220. } else {
  16221. m.addindex = &i
  16222. }
  16223. }
  16224. // AddedIndex returns the value that was added to the "index" field in this mutation.
  16225. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  16226. v := m.addindex
  16227. if v == nil {
  16228. return
  16229. }
  16230. return *v, true
  16231. }
  16232. // ResetIndex resets all changes to the "index" field.
  16233. func (m *TutorialMutation) ResetIndex() {
  16234. m.index = nil
  16235. m.addindex = nil
  16236. }
  16237. // SetTitle sets the "title" field.
  16238. func (m *TutorialMutation) SetTitle(s string) {
  16239. m.title = &s
  16240. }
  16241. // Title returns the value of the "title" field in the mutation.
  16242. func (m *TutorialMutation) Title() (r string, exists bool) {
  16243. v := m.title
  16244. if v == nil {
  16245. return
  16246. }
  16247. return *v, true
  16248. }
  16249. // OldTitle returns the old "title" field's value of the Tutorial entity.
  16250. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16252. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  16253. if !m.op.Is(OpUpdateOne) {
  16254. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  16255. }
  16256. if m.id == nil || m.oldValue == nil {
  16257. return v, errors.New("OldTitle requires an ID field in the mutation")
  16258. }
  16259. oldValue, err := m.oldValue(ctx)
  16260. if err != nil {
  16261. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  16262. }
  16263. return oldValue.Title, nil
  16264. }
  16265. // ResetTitle resets all changes to the "title" field.
  16266. func (m *TutorialMutation) ResetTitle() {
  16267. m.title = nil
  16268. }
  16269. // SetContent sets the "content" field.
  16270. func (m *TutorialMutation) SetContent(s string) {
  16271. m.content = &s
  16272. }
  16273. // Content returns the value of the "content" field in the mutation.
  16274. func (m *TutorialMutation) Content() (r string, exists bool) {
  16275. v := m.content
  16276. if v == nil {
  16277. return
  16278. }
  16279. return *v, true
  16280. }
  16281. // OldContent returns the old "content" field's value of the Tutorial entity.
  16282. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16284. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  16285. if !m.op.Is(OpUpdateOne) {
  16286. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  16287. }
  16288. if m.id == nil || m.oldValue == nil {
  16289. return v, errors.New("OldContent requires an ID field in the mutation")
  16290. }
  16291. oldValue, err := m.oldValue(ctx)
  16292. if err != nil {
  16293. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  16294. }
  16295. return oldValue.Content, nil
  16296. }
  16297. // ResetContent resets all changes to the "content" field.
  16298. func (m *TutorialMutation) ResetContent() {
  16299. m.content = nil
  16300. }
  16301. // SetOrganizationID sets the "organization_id" field.
  16302. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  16303. m.organization_id = &u
  16304. m.addorganization_id = nil
  16305. }
  16306. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16307. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  16308. v := m.organization_id
  16309. if v == nil {
  16310. return
  16311. }
  16312. return *v, true
  16313. }
  16314. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  16315. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16317. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16318. if !m.op.Is(OpUpdateOne) {
  16319. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16320. }
  16321. if m.id == nil || m.oldValue == nil {
  16322. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16323. }
  16324. oldValue, err := m.oldValue(ctx)
  16325. if err != nil {
  16326. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16327. }
  16328. return oldValue.OrganizationID, nil
  16329. }
  16330. // AddOrganizationID adds u to the "organization_id" field.
  16331. func (m *TutorialMutation) AddOrganizationID(u int64) {
  16332. if m.addorganization_id != nil {
  16333. *m.addorganization_id += u
  16334. } else {
  16335. m.addorganization_id = &u
  16336. }
  16337. }
  16338. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16339. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  16340. v := m.addorganization_id
  16341. if v == nil {
  16342. return
  16343. }
  16344. return *v, true
  16345. }
  16346. // ResetOrganizationID resets all changes to the "organization_id" field.
  16347. func (m *TutorialMutation) ResetOrganizationID() {
  16348. m.organization_id = nil
  16349. m.addorganization_id = nil
  16350. }
  16351. // ClearEmployee clears the "employee" edge to the Employee entity.
  16352. func (m *TutorialMutation) ClearEmployee() {
  16353. m.clearedemployee = true
  16354. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  16355. }
  16356. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  16357. func (m *TutorialMutation) EmployeeCleared() bool {
  16358. return m.clearedemployee
  16359. }
  16360. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  16361. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  16362. // EmployeeID instead. It exists only for internal usage by the builders.
  16363. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  16364. if id := m.employee; id != nil {
  16365. ids = append(ids, *id)
  16366. }
  16367. return
  16368. }
  16369. // ResetEmployee resets all changes to the "employee" edge.
  16370. func (m *TutorialMutation) ResetEmployee() {
  16371. m.employee = nil
  16372. m.clearedemployee = false
  16373. }
  16374. // Where appends a list predicates to the TutorialMutation builder.
  16375. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  16376. m.predicates = append(m.predicates, ps...)
  16377. }
  16378. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  16379. // users can use type-assertion to append predicates that do not depend on any generated package.
  16380. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  16381. p := make([]predicate.Tutorial, len(ps))
  16382. for i := range ps {
  16383. p[i] = ps[i]
  16384. }
  16385. m.Where(p...)
  16386. }
  16387. // Op returns the operation name.
  16388. func (m *TutorialMutation) Op() Op {
  16389. return m.op
  16390. }
  16391. // SetOp allows setting the mutation operation.
  16392. func (m *TutorialMutation) SetOp(op Op) {
  16393. m.op = op
  16394. }
  16395. // Type returns the node type of this mutation (Tutorial).
  16396. func (m *TutorialMutation) Type() string {
  16397. return m.typ
  16398. }
  16399. // Fields returns all fields that were changed during this mutation. Note that in
  16400. // order to get all numeric fields that were incremented/decremented, call
  16401. // AddedFields().
  16402. func (m *TutorialMutation) Fields() []string {
  16403. fields := make([]string, 0, 8)
  16404. if m.created_at != nil {
  16405. fields = append(fields, tutorial.FieldCreatedAt)
  16406. }
  16407. if m.updated_at != nil {
  16408. fields = append(fields, tutorial.FieldUpdatedAt)
  16409. }
  16410. if m.deleted_at != nil {
  16411. fields = append(fields, tutorial.FieldDeletedAt)
  16412. }
  16413. if m.employee != nil {
  16414. fields = append(fields, tutorial.FieldEmployeeID)
  16415. }
  16416. if m.index != nil {
  16417. fields = append(fields, tutorial.FieldIndex)
  16418. }
  16419. if m.title != nil {
  16420. fields = append(fields, tutorial.FieldTitle)
  16421. }
  16422. if m.content != nil {
  16423. fields = append(fields, tutorial.FieldContent)
  16424. }
  16425. if m.organization_id != nil {
  16426. fields = append(fields, tutorial.FieldOrganizationID)
  16427. }
  16428. return fields
  16429. }
  16430. // Field returns the value of a field with the given name. The second boolean
  16431. // return value indicates that this field was not set, or was not defined in the
  16432. // schema.
  16433. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  16434. switch name {
  16435. case tutorial.FieldCreatedAt:
  16436. return m.CreatedAt()
  16437. case tutorial.FieldUpdatedAt:
  16438. return m.UpdatedAt()
  16439. case tutorial.FieldDeletedAt:
  16440. return m.DeletedAt()
  16441. case tutorial.FieldEmployeeID:
  16442. return m.EmployeeID()
  16443. case tutorial.FieldIndex:
  16444. return m.Index()
  16445. case tutorial.FieldTitle:
  16446. return m.Title()
  16447. case tutorial.FieldContent:
  16448. return m.Content()
  16449. case tutorial.FieldOrganizationID:
  16450. return m.OrganizationID()
  16451. }
  16452. return nil, false
  16453. }
  16454. // OldField returns the old value of the field from the database. An error is
  16455. // returned if the mutation operation is not UpdateOne, or the query to the
  16456. // database failed.
  16457. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16458. switch name {
  16459. case tutorial.FieldCreatedAt:
  16460. return m.OldCreatedAt(ctx)
  16461. case tutorial.FieldUpdatedAt:
  16462. return m.OldUpdatedAt(ctx)
  16463. case tutorial.FieldDeletedAt:
  16464. return m.OldDeletedAt(ctx)
  16465. case tutorial.FieldEmployeeID:
  16466. return m.OldEmployeeID(ctx)
  16467. case tutorial.FieldIndex:
  16468. return m.OldIndex(ctx)
  16469. case tutorial.FieldTitle:
  16470. return m.OldTitle(ctx)
  16471. case tutorial.FieldContent:
  16472. return m.OldContent(ctx)
  16473. case tutorial.FieldOrganizationID:
  16474. return m.OldOrganizationID(ctx)
  16475. }
  16476. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  16477. }
  16478. // SetField sets the value of a field with the given name. It returns an error if
  16479. // the field is not defined in the schema, or if the type mismatched the field
  16480. // type.
  16481. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  16482. switch name {
  16483. case tutorial.FieldCreatedAt:
  16484. v, ok := value.(time.Time)
  16485. if !ok {
  16486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16487. }
  16488. m.SetCreatedAt(v)
  16489. return nil
  16490. case tutorial.FieldUpdatedAt:
  16491. v, ok := value.(time.Time)
  16492. if !ok {
  16493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16494. }
  16495. m.SetUpdatedAt(v)
  16496. return nil
  16497. case tutorial.FieldDeletedAt:
  16498. v, ok := value.(time.Time)
  16499. if !ok {
  16500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16501. }
  16502. m.SetDeletedAt(v)
  16503. return nil
  16504. case tutorial.FieldEmployeeID:
  16505. v, ok := value.(uint64)
  16506. if !ok {
  16507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16508. }
  16509. m.SetEmployeeID(v)
  16510. return nil
  16511. case tutorial.FieldIndex:
  16512. v, ok := value.(int)
  16513. if !ok {
  16514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16515. }
  16516. m.SetIndex(v)
  16517. return nil
  16518. case tutorial.FieldTitle:
  16519. v, ok := value.(string)
  16520. if !ok {
  16521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16522. }
  16523. m.SetTitle(v)
  16524. return nil
  16525. case tutorial.FieldContent:
  16526. v, ok := value.(string)
  16527. if !ok {
  16528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16529. }
  16530. m.SetContent(v)
  16531. return nil
  16532. case tutorial.FieldOrganizationID:
  16533. v, ok := value.(uint64)
  16534. if !ok {
  16535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16536. }
  16537. m.SetOrganizationID(v)
  16538. return nil
  16539. }
  16540. return fmt.Errorf("unknown Tutorial field %s", name)
  16541. }
  16542. // AddedFields returns all numeric fields that were incremented/decremented during
  16543. // this mutation.
  16544. func (m *TutorialMutation) AddedFields() []string {
  16545. var fields []string
  16546. if m.addindex != nil {
  16547. fields = append(fields, tutorial.FieldIndex)
  16548. }
  16549. if m.addorganization_id != nil {
  16550. fields = append(fields, tutorial.FieldOrganizationID)
  16551. }
  16552. return fields
  16553. }
  16554. // AddedField returns the numeric value that was incremented/decremented on a field
  16555. // with the given name. The second boolean return value indicates that this field
  16556. // was not set, or was not defined in the schema.
  16557. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  16558. switch name {
  16559. case tutorial.FieldIndex:
  16560. return m.AddedIndex()
  16561. case tutorial.FieldOrganizationID:
  16562. return m.AddedOrganizationID()
  16563. }
  16564. return nil, false
  16565. }
  16566. // AddField adds the value to the field with the given name. It returns an error if
  16567. // the field is not defined in the schema, or if the type mismatched the field
  16568. // type.
  16569. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  16570. switch name {
  16571. case tutorial.FieldIndex:
  16572. v, ok := value.(int)
  16573. if !ok {
  16574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16575. }
  16576. m.AddIndex(v)
  16577. return nil
  16578. case tutorial.FieldOrganizationID:
  16579. v, ok := value.(int64)
  16580. if !ok {
  16581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16582. }
  16583. m.AddOrganizationID(v)
  16584. return nil
  16585. }
  16586. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  16587. }
  16588. // ClearedFields returns all nullable fields that were cleared during this
  16589. // mutation.
  16590. func (m *TutorialMutation) ClearedFields() []string {
  16591. var fields []string
  16592. if m.FieldCleared(tutorial.FieldDeletedAt) {
  16593. fields = append(fields, tutorial.FieldDeletedAt)
  16594. }
  16595. return fields
  16596. }
  16597. // FieldCleared returns a boolean indicating if a field with the given name was
  16598. // cleared in this mutation.
  16599. func (m *TutorialMutation) FieldCleared(name string) bool {
  16600. _, ok := m.clearedFields[name]
  16601. return ok
  16602. }
  16603. // ClearField clears the value of the field with the given name. It returns an
  16604. // error if the field is not defined in the schema.
  16605. func (m *TutorialMutation) ClearField(name string) error {
  16606. switch name {
  16607. case tutorial.FieldDeletedAt:
  16608. m.ClearDeletedAt()
  16609. return nil
  16610. }
  16611. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  16612. }
  16613. // ResetField resets all changes in the mutation for the field with the given name.
  16614. // It returns an error if the field is not defined in the schema.
  16615. func (m *TutorialMutation) ResetField(name string) error {
  16616. switch name {
  16617. case tutorial.FieldCreatedAt:
  16618. m.ResetCreatedAt()
  16619. return nil
  16620. case tutorial.FieldUpdatedAt:
  16621. m.ResetUpdatedAt()
  16622. return nil
  16623. case tutorial.FieldDeletedAt:
  16624. m.ResetDeletedAt()
  16625. return nil
  16626. case tutorial.FieldEmployeeID:
  16627. m.ResetEmployeeID()
  16628. return nil
  16629. case tutorial.FieldIndex:
  16630. m.ResetIndex()
  16631. return nil
  16632. case tutorial.FieldTitle:
  16633. m.ResetTitle()
  16634. return nil
  16635. case tutorial.FieldContent:
  16636. m.ResetContent()
  16637. return nil
  16638. case tutorial.FieldOrganizationID:
  16639. m.ResetOrganizationID()
  16640. return nil
  16641. }
  16642. return fmt.Errorf("unknown Tutorial field %s", name)
  16643. }
  16644. // AddedEdges returns all edge names that were set/added in this mutation.
  16645. func (m *TutorialMutation) AddedEdges() []string {
  16646. edges := make([]string, 0, 1)
  16647. if m.employee != nil {
  16648. edges = append(edges, tutorial.EdgeEmployee)
  16649. }
  16650. return edges
  16651. }
  16652. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16653. // name in this mutation.
  16654. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  16655. switch name {
  16656. case tutorial.EdgeEmployee:
  16657. if id := m.employee; id != nil {
  16658. return []ent.Value{*id}
  16659. }
  16660. }
  16661. return nil
  16662. }
  16663. // RemovedEdges returns all edge names that were removed in this mutation.
  16664. func (m *TutorialMutation) RemovedEdges() []string {
  16665. edges := make([]string, 0, 1)
  16666. return edges
  16667. }
  16668. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16669. // the given name in this mutation.
  16670. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  16671. return nil
  16672. }
  16673. // ClearedEdges returns all edge names that were cleared in this mutation.
  16674. func (m *TutorialMutation) ClearedEdges() []string {
  16675. edges := make([]string, 0, 1)
  16676. if m.clearedemployee {
  16677. edges = append(edges, tutorial.EdgeEmployee)
  16678. }
  16679. return edges
  16680. }
  16681. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16682. // was cleared in this mutation.
  16683. func (m *TutorialMutation) EdgeCleared(name string) bool {
  16684. switch name {
  16685. case tutorial.EdgeEmployee:
  16686. return m.clearedemployee
  16687. }
  16688. return false
  16689. }
  16690. // ClearEdge clears the value of the edge with the given name. It returns an error
  16691. // if that edge is not defined in the schema.
  16692. func (m *TutorialMutation) ClearEdge(name string) error {
  16693. switch name {
  16694. case tutorial.EdgeEmployee:
  16695. m.ClearEmployee()
  16696. return nil
  16697. }
  16698. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  16699. }
  16700. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16701. // It returns an error if the edge is not defined in the schema.
  16702. func (m *TutorialMutation) ResetEdge(name string) error {
  16703. switch name {
  16704. case tutorial.EdgeEmployee:
  16705. m.ResetEmployee()
  16706. return nil
  16707. }
  16708. return fmt.Errorf("unknown Tutorial edge %s", name)
  16709. }
  16710. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  16711. type WorkExperienceMutation struct {
  16712. config
  16713. op Op
  16714. typ string
  16715. id *uint64
  16716. created_at *time.Time
  16717. updated_at *time.Time
  16718. deleted_at *time.Time
  16719. start_date *time.Time
  16720. end_date *time.Time
  16721. company *string
  16722. experience *string
  16723. organization_id *uint64
  16724. addorganization_id *int64
  16725. clearedFields map[string]struct{}
  16726. employee *uint64
  16727. clearedemployee bool
  16728. done bool
  16729. oldValue func(context.Context) (*WorkExperience, error)
  16730. predicates []predicate.WorkExperience
  16731. }
  16732. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  16733. // workexperienceOption allows management of the mutation configuration using functional options.
  16734. type workexperienceOption func(*WorkExperienceMutation)
  16735. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  16736. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  16737. m := &WorkExperienceMutation{
  16738. config: c,
  16739. op: op,
  16740. typ: TypeWorkExperience,
  16741. clearedFields: make(map[string]struct{}),
  16742. }
  16743. for _, opt := range opts {
  16744. opt(m)
  16745. }
  16746. return m
  16747. }
  16748. // withWorkExperienceID sets the ID field of the mutation.
  16749. func withWorkExperienceID(id uint64) workexperienceOption {
  16750. return func(m *WorkExperienceMutation) {
  16751. var (
  16752. err error
  16753. once sync.Once
  16754. value *WorkExperience
  16755. )
  16756. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  16757. once.Do(func() {
  16758. if m.done {
  16759. err = errors.New("querying old values post mutation is not allowed")
  16760. } else {
  16761. value, err = m.Client().WorkExperience.Get(ctx, id)
  16762. }
  16763. })
  16764. return value, err
  16765. }
  16766. m.id = &id
  16767. }
  16768. }
  16769. // withWorkExperience sets the old WorkExperience of the mutation.
  16770. func withWorkExperience(node *WorkExperience) workexperienceOption {
  16771. return func(m *WorkExperienceMutation) {
  16772. m.oldValue = func(context.Context) (*WorkExperience, error) {
  16773. return node, nil
  16774. }
  16775. m.id = &node.ID
  16776. }
  16777. }
  16778. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16779. // executed in a transaction (ent.Tx), a transactional client is returned.
  16780. func (m WorkExperienceMutation) Client() *Client {
  16781. client := &Client{config: m.config}
  16782. client.init()
  16783. return client
  16784. }
  16785. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16786. // it returns an error otherwise.
  16787. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  16788. if _, ok := m.driver.(*txDriver); !ok {
  16789. return nil, errors.New("ent: mutation is not running in a transaction")
  16790. }
  16791. tx := &Tx{config: m.config}
  16792. tx.init()
  16793. return tx, nil
  16794. }
  16795. // SetID sets the value of the id field. Note that this
  16796. // operation is only accepted on creation of WorkExperience entities.
  16797. func (m *WorkExperienceMutation) SetID(id uint64) {
  16798. m.id = &id
  16799. }
  16800. // ID returns the ID value in the mutation. Note that the ID is only available
  16801. // if it was provided to the builder or after it was returned from the database.
  16802. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  16803. if m.id == nil {
  16804. return
  16805. }
  16806. return *m.id, true
  16807. }
  16808. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16809. // That means, if the mutation is applied within a transaction with an isolation level such
  16810. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16811. // or updated by the mutation.
  16812. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  16813. switch {
  16814. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16815. id, exists := m.ID()
  16816. if exists {
  16817. return []uint64{id}, nil
  16818. }
  16819. fallthrough
  16820. case m.op.Is(OpUpdate | OpDelete):
  16821. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  16822. default:
  16823. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16824. }
  16825. }
  16826. // SetCreatedAt sets the "created_at" field.
  16827. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  16828. m.created_at = &t
  16829. }
  16830. // CreatedAt returns the value of the "created_at" field in the mutation.
  16831. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  16832. v := m.created_at
  16833. if v == nil {
  16834. return
  16835. }
  16836. return *v, true
  16837. }
  16838. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  16839. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16841. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16842. if !m.op.Is(OpUpdateOne) {
  16843. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16844. }
  16845. if m.id == nil || m.oldValue == nil {
  16846. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16847. }
  16848. oldValue, err := m.oldValue(ctx)
  16849. if err != nil {
  16850. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16851. }
  16852. return oldValue.CreatedAt, nil
  16853. }
  16854. // ResetCreatedAt resets all changes to the "created_at" field.
  16855. func (m *WorkExperienceMutation) ResetCreatedAt() {
  16856. m.created_at = nil
  16857. }
  16858. // SetUpdatedAt sets the "updated_at" field.
  16859. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  16860. m.updated_at = &t
  16861. }
  16862. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16863. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  16864. v := m.updated_at
  16865. if v == nil {
  16866. return
  16867. }
  16868. return *v, true
  16869. }
  16870. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  16871. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16873. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16874. if !m.op.Is(OpUpdateOne) {
  16875. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16876. }
  16877. if m.id == nil || m.oldValue == nil {
  16878. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16879. }
  16880. oldValue, err := m.oldValue(ctx)
  16881. if err != nil {
  16882. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16883. }
  16884. return oldValue.UpdatedAt, nil
  16885. }
  16886. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16887. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  16888. m.updated_at = nil
  16889. }
  16890. // SetDeletedAt sets the "deleted_at" field.
  16891. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  16892. m.deleted_at = &t
  16893. }
  16894. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16895. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  16896. v := m.deleted_at
  16897. if v == nil {
  16898. return
  16899. }
  16900. return *v, true
  16901. }
  16902. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  16903. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16905. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16906. if !m.op.Is(OpUpdateOne) {
  16907. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16908. }
  16909. if m.id == nil || m.oldValue == nil {
  16910. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16911. }
  16912. oldValue, err := m.oldValue(ctx)
  16913. if err != nil {
  16914. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16915. }
  16916. return oldValue.DeletedAt, nil
  16917. }
  16918. // ClearDeletedAt clears the value of the "deleted_at" field.
  16919. func (m *WorkExperienceMutation) ClearDeletedAt() {
  16920. m.deleted_at = nil
  16921. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  16922. }
  16923. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16924. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  16925. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  16926. return ok
  16927. }
  16928. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16929. func (m *WorkExperienceMutation) ResetDeletedAt() {
  16930. m.deleted_at = nil
  16931. delete(m.clearedFields, workexperience.FieldDeletedAt)
  16932. }
  16933. // SetEmployeeID sets the "employee_id" field.
  16934. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  16935. m.employee = &u
  16936. }
  16937. // EmployeeID returns the value of the "employee_id" field in the mutation.
  16938. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  16939. v := m.employee
  16940. if v == nil {
  16941. return
  16942. }
  16943. return *v, true
  16944. }
  16945. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  16946. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16947. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16948. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  16949. if !m.op.Is(OpUpdateOne) {
  16950. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  16951. }
  16952. if m.id == nil || m.oldValue == nil {
  16953. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  16954. }
  16955. oldValue, err := m.oldValue(ctx)
  16956. if err != nil {
  16957. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  16958. }
  16959. return oldValue.EmployeeID, nil
  16960. }
  16961. // ResetEmployeeID resets all changes to the "employee_id" field.
  16962. func (m *WorkExperienceMutation) ResetEmployeeID() {
  16963. m.employee = nil
  16964. }
  16965. // SetStartDate sets the "start_date" field.
  16966. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  16967. m.start_date = &t
  16968. }
  16969. // StartDate returns the value of the "start_date" field in the mutation.
  16970. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  16971. v := m.start_date
  16972. if v == nil {
  16973. return
  16974. }
  16975. return *v, true
  16976. }
  16977. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  16978. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16980. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  16981. if !m.op.Is(OpUpdateOne) {
  16982. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  16983. }
  16984. if m.id == nil || m.oldValue == nil {
  16985. return v, errors.New("OldStartDate requires an ID field in the mutation")
  16986. }
  16987. oldValue, err := m.oldValue(ctx)
  16988. if err != nil {
  16989. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  16990. }
  16991. return oldValue.StartDate, nil
  16992. }
  16993. // ResetStartDate resets all changes to the "start_date" field.
  16994. func (m *WorkExperienceMutation) ResetStartDate() {
  16995. m.start_date = nil
  16996. }
  16997. // SetEndDate sets the "end_date" field.
  16998. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  16999. m.end_date = &t
  17000. }
  17001. // EndDate returns the value of the "end_date" field in the mutation.
  17002. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  17003. v := m.end_date
  17004. if v == nil {
  17005. return
  17006. }
  17007. return *v, true
  17008. }
  17009. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  17010. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17012. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  17013. if !m.op.Is(OpUpdateOne) {
  17014. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  17015. }
  17016. if m.id == nil || m.oldValue == nil {
  17017. return v, errors.New("OldEndDate requires an ID field in the mutation")
  17018. }
  17019. oldValue, err := m.oldValue(ctx)
  17020. if err != nil {
  17021. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  17022. }
  17023. return oldValue.EndDate, nil
  17024. }
  17025. // ResetEndDate resets all changes to the "end_date" field.
  17026. func (m *WorkExperienceMutation) ResetEndDate() {
  17027. m.end_date = nil
  17028. }
  17029. // SetCompany sets the "company" field.
  17030. func (m *WorkExperienceMutation) SetCompany(s string) {
  17031. m.company = &s
  17032. }
  17033. // Company returns the value of the "company" field in the mutation.
  17034. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  17035. v := m.company
  17036. if v == nil {
  17037. return
  17038. }
  17039. return *v, true
  17040. }
  17041. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  17042. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17044. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  17045. if !m.op.Is(OpUpdateOne) {
  17046. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  17047. }
  17048. if m.id == nil || m.oldValue == nil {
  17049. return v, errors.New("OldCompany requires an ID field in the mutation")
  17050. }
  17051. oldValue, err := m.oldValue(ctx)
  17052. if err != nil {
  17053. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  17054. }
  17055. return oldValue.Company, nil
  17056. }
  17057. // ResetCompany resets all changes to the "company" field.
  17058. func (m *WorkExperienceMutation) ResetCompany() {
  17059. m.company = nil
  17060. }
  17061. // SetExperience sets the "experience" field.
  17062. func (m *WorkExperienceMutation) SetExperience(s string) {
  17063. m.experience = &s
  17064. }
  17065. // Experience returns the value of the "experience" field in the mutation.
  17066. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  17067. v := m.experience
  17068. if v == nil {
  17069. return
  17070. }
  17071. return *v, true
  17072. }
  17073. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  17074. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17076. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  17077. if !m.op.Is(OpUpdateOne) {
  17078. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  17079. }
  17080. if m.id == nil || m.oldValue == nil {
  17081. return v, errors.New("OldExperience requires an ID field in the mutation")
  17082. }
  17083. oldValue, err := m.oldValue(ctx)
  17084. if err != nil {
  17085. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  17086. }
  17087. return oldValue.Experience, nil
  17088. }
  17089. // ResetExperience resets all changes to the "experience" field.
  17090. func (m *WorkExperienceMutation) ResetExperience() {
  17091. m.experience = nil
  17092. }
  17093. // SetOrganizationID sets the "organization_id" field.
  17094. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  17095. m.organization_id = &u
  17096. m.addorganization_id = nil
  17097. }
  17098. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17099. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  17100. v := m.organization_id
  17101. if v == nil {
  17102. return
  17103. }
  17104. return *v, true
  17105. }
  17106. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  17107. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17109. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17110. if !m.op.Is(OpUpdateOne) {
  17111. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17112. }
  17113. if m.id == nil || m.oldValue == nil {
  17114. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17115. }
  17116. oldValue, err := m.oldValue(ctx)
  17117. if err != nil {
  17118. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17119. }
  17120. return oldValue.OrganizationID, nil
  17121. }
  17122. // AddOrganizationID adds u to the "organization_id" field.
  17123. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  17124. if m.addorganization_id != nil {
  17125. *m.addorganization_id += u
  17126. } else {
  17127. m.addorganization_id = &u
  17128. }
  17129. }
  17130. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17131. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  17132. v := m.addorganization_id
  17133. if v == nil {
  17134. return
  17135. }
  17136. return *v, true
  17137. }
  17138. // ResetOrganizationID resets all changes to the "organization_id" field.
  17139. func (m *WorkExperienceMutation) ResetOrganizationID() {
  17140. m.organization_id = nil
  17141. m.addorganization_id = nil
  17142. }
  17143. // ClearEmployee clears the "employee" edge to the Employee entity.
  17144. func (m *WorkExperienceMutation) ClearEmployee() {
  17145. m.clearedemployee = true
  17146. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  17147. }
  17148. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  17149. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  17150. return m.clearedemployee
  17151. }
  17152. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  17153. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17154. // EmployeeID instead. It exists only for internal usage by the builders.
  17155. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  17156. if id := m.employee; id != nil {
  17157. ids = append(ids, *id)
  17158. }
  17159. return
  17160. }
  17161. // ResetEmployee resets all changes to the "employee" edge.
  17162. func (m *WorkExperienceMutation) ResetEmployee() {
  17163. m.employee = nil
  17164. m.clearedemployee = false
  17165. }
  17166. // Where appends a list predicates to the WorkExperienceMutation builder.
  17167. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  17168. m.predicates = append(m.predicates, ps...)
  17169. }
  17170. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  17171. // users can use type-assertion to append predicates that do not depend on any generated package.
  17172. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  17173. p := make([]predicate.WorkExperience, len(ps))
  17174. for i := range ps {
  17175. p[i] = ps[i]
  17176. }
  17177. m.Where(p...)
  17178. }
  17179. // Op returns the operation name.
  17180. func (m *WorkExperienceMutation) Op() Op {
  17181. return m.op
  17182. }
  17183. // SetOp allows setting the mutation operation.
  17184. func (m *WorkExperienceMutation) SetOp(op Op) {
  17185. m.op = op
  17186. }
  17187. // Type returns the node type of this mutation (WorkExperience).
  17188. func (m *WorkExperienceMutation) Type() string {
  17189. return m.typ
  17190. }
  17191. // Fields returns all fields that were changed during this mutation. Note that in
  17192. // order to get all numeric fields that were incremented/decremented, call
  17193. // AddedFields().
  17194. func (m *WorkExperienceMutation) Fields() []string {
  17195. fields := make([]string, 0, 9)
  17196. if m.created_at != nil {
  17197. fields = append(fields, workexperience.FieldCreatedAt)
  17198. }
  17199. if m.updated_at != nil {
  17200. fields = append(fields, workexperience.FieldUpdatedAt)
  17201. }
  17202. if m.deleted_at != nil {
  17203. fields = append(fields, workexperience.FieldDeletedAt)
  17204. }
  17205. if m.employee != nil {
  17206. fields = append(fields, workexperience.FieldEmployeeID)
  17207. }
  17208. if m.start_date != nil {
  17209. fields = append(fields, workexperience.FieldStartDate)
  17210. }
  17211. if m.end_date != nil {
  17212. fields = append(fields, workexperience.FieldEndDate)
  17213. }
  17214. if m.company != nil {
  17215. fields = append(fields, workexperience.FieldCompany)
  17216. }
  17217. if m.experience != nil {
  17218. fields = append(fields, workexperience.FieldExperience)
  17219. }
  17220. if m.organization_id != nil {
  17221. fields = append(fields, workexperience.FieldOrganizationID)
  17222. }
  17223. return fields
  17224. }
  17225. // Field returns the value of a field with the given name. The second boolean
  17226. // return value indicates that this field was not set, or was not defined in the
  17227. // schema.
  17228. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  17229. switch name {
  17230. case workexperience.FieldCreatedAt:
  17231. return m.CreatedAt()
  17232. case workexperience.FieldUpdatedAt:
  17233. return m.UpdatedAt()
  17234. case workexperience.FieldDeletedAt:
  17235. return m.DeletedAt()
  17236. case workexperience.FieldEmployeeID:
  17237. return m.EmployeeID()
  17238. case workexperience.FieldStartDate:
  17239. return m.StartDate()
  17240. case workexperience.FieldEndDate:
  17241. return m.EndDate()
  17242. case workexperience.FieldCompany:
  17243. return m.Company()
  17244. case workexperience.FieldExperience:
  17245. return m.Experience()
  17246. case workexperience.FieldOrganizationID:
  17247. return m.OrganizationID()
  17248. }
  17249. return nil, false
  17250. }
  17251. // OldField returns the old value of the field from the database. An error is
  17252. // returned if the mutation operation is not UpdateOne, or the query to the
  17253. // database failed.
  17254. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17255. switch name {
  17256. case workexperience.FieldCreatedAt:
  17257. return m.OldCreatedAt(ctx)
  17258. case workexperience.FieldUpdatedAt:
  17259. return m.OldUpdatedAt(ctx)
  17260. case workexperience.FieldDeletedAt:
  17261. return m.OldDeletedAt(ctx)
  17262. case workexperience.FieldEmployeeID:
  17263. return m.OldEmployeeID(ctx)
  17264. case workexperience.FieldStartDate:
  17265. return m.OldStartDate(ctx)
  17266. case workexperience.FieldEndDate:
  17267. return m.OldEndDate(ctx)
  17268. case workexperience.FieldCompany:
  17269. return m.OldCompany(ctx)
  17270. case workexperience.FieldExperience:
  17271. return m.OldExperience(ctx)
  17272. case workexperience.FieldOrganizationID:
  17273. return m.OldOrganizationID(ctx)
  17274. }
  17275. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  17276. }
  17277. // SetField sets the value of a field with the given name. It returns an error if
  17278. // the field is not defined in the schema, or if the type mismatched the field
  17279. // type.
  17280. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  17281. switch name {
  17282. case workexperience.FieldCreatedAt:
  17283. v, ok := value.(time.Time)
  17284. if !ok {
  17285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17286. }
  17287. m.SetCreatedAt(v)
  17288. return nil
  17289. case workexperience.FieldUpdatedAt:
  17290. v, ok := value.(time.Time)
  17291. if !ok {
  17292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17293. }
  17294. m.SetUpdatedAt(v)
  17295. return nil
  17296. case workexperience.FieldDeletedAt:
  17297. v, ok := value.(time.Time)
  17298. if !ok {
  17299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17300. }
  17301. m.SetDeletedAt(v)
  17302. return nil
  17303. case workexperience.FieldEmployeeID:
  17304. v, ok := value.(uint64)
  17305. if !ok {
  17306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17307. }
  17308. m.SetEmployeeID(v)
  17309. return nil
  17310. case workexperience.FieldStartDate:
  17311. v, ok := value.(time.Time)
  17312. if !ok {
  17313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17314. }
  17315. m.SetStartDate(v)
  17316. return nil
  17317. case workexperience.FieldEndDate:
  17318. v, ok := value.(time.Time)
  17319. if !ok {
  17320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17321. }
  17322. m.SetEndDate(v)
  17323. return nil
  17324. case workexperience.FieldCompany:
  17325. v, ok := value.(string)
  17326. if !ok {
  17327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17328. }
  17329. m.SetCompany(v)
  17330. return nil
  17331. case workexperience.FieldExperience:
  17332. v, ok := value.(string)
  17333. if !ok {
  17334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17335. }
  17336. m.SetExperience(v)
  17337. return nil
  17338. case workexperience.FieldOrganizationID:
  17339. v, ok := value.(uint64)
  17340. if !ok {
  17341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17342. }
  17343. m.SetOrganizationID(v)
  17344. return nil
  17345. }
  17346. return fmt.Errorf("unknown WorkExperience field %s", name)
  17347. }
  17348. // AddedFields returns all numeric fields that were incremented/decremented during
  17349. // this mutation.
  17350. func (m *WorkExperienceMutation) AddedFields() []string {
  17351. var fields []string
  17352. if m.addorganization_id != nil {
  17353. fields = append(fields, workexperience.FieldOrganizationID)
  17354. }
  17355. return fields
  17356. }
  17357. // AddedField returns the numeric value that was incremented/decremented on a field
  17358. // with the given name. The second boolean return value indicates that this field
  17359. // was not set, or was not defined in the schema.
  17360. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  17361. switch name {
  17362. case workexperience.FieldOrganizationID:
  17363. return m.AddedOrganizationID()
  17364. }
  17365. return nil, false
  17366. }
  17367. // AddField adds the value to the field with the given name. It returns an error if
  17368. // the field is not defined in the schema, or if the type mismatched the field
  17369. // type.
  17370. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  17371. switch name {
  17372. case workexperience.FieldOrganizationID:
  17373. v, ok := value.(int64)
  17374. if !ok {
  17375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17376. }
  17377. m.AddOrganizationID(v)
  17378. return nil
  17379. }
  17380. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  17381. }
  17382. // ClearedFields returns all nullable fields that were cleared during this
  17383. // mutation.
  17384. func (m *WorkExperienceMutation) ClearedFields() []string {
  17385. var fields []string
  17386. if m.FieldCleared(workexperience.FieldDeletedAt) {
  17387. fields = append(fields, workexperience.FieldDeletedAt)
  17388. }
  17389. return fields
  17390. }
  17391. // FieldCleared returns a boolean indicating if a field with the given name was
  17392. // cleared in this mutation.
  17393. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  17394. _, ok := m.clearedFields[name]
  17395. return ok
  17396. }
  17397. // ClearField clears the value of the field with the given name. It returns an
  17398. // error if the field is not defined in the schema.
  17399. func (m *WorkExperienceMutation) ClearField(name string) error {
  17400. switch name {
  17401. case workexperience.FieldDeletedAt:
  17402. m.ClearDeletedAt()
  17403. return nil
  17404. }
  17405. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  17406. }
  17407. // ResetField resets all changes in the mutation for the field with the given name.
  17408. // It returns an error if the field is not defined in the schema.
  17409. func (m *WorkExperienceMutation) ResetField(name string) error {
  17410. switch name {
  17411. case workexperience.FieldCreatedAt:
  17412. m.ResetCreatedAt()
  17413. return nil
  17414. case workexperience.FieldUpdatedAt:
  17415. m.ResetUpdatedAt()
  17416. return nil
  17417. case workexperience.FieldDeletedAt:
  17418. m.ResetDeletedAt()
  17419. return nil
  17420. case workexperience.FieldEmployeeID:
  17421. m.ResetEmployeeID()
  17422. return nil
  17423. case workexperience.FieldStartDate:
  17424. m.ResetStartDate()
  17425. return nil
  17426. case workexperience.FieldEndDate:
  17427. m.ResetEndDate()
  17428. return nil
  17429. case workexperience.FieldCompany:
  17430. m.ResetCompany()
  17431. return nil
  17432. case workexperience.FieldExperience:
  17433. m.ResetExperience()
  17434. return nil
  17435. case workexperience.FieldOrganizationID:
  17436. m.ResetOrganizationID()
  17437. return nil
  17438. }
  17439. return fmt.Errorf("unknown WorkExperience field %s", name)
  17440. }
  17441. // AddedEdges returns all edge names that were set/added in this mutation.
  17442. func (m *WorkExperienceMutation) AddedEdges() []string {
  17443. edges := make([]string, 0, 1)
  17444. if m.employee != nil {
  17445. edges = append(edges, workexperience.EdgeEmployee)
  17446. }
  17447. return edges
  17448. }
  17449. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17450. // name in this mutation.
  17451. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  17452. switch name {
  17453. case workexperience.EdgeEmployee:
  17454. if id := m.employee; id != nil {
  17455. return []ent.Value{*id}
  17456. }
  17457. }
  17458. return nil
  17459. }
  17460. // RemovedEdges returns all edge names that were removed in this mutation.
  17461. func (m *WorkExperienceMutation) RemovedEdges() []string {
  17462. edges := make([]string, 0, 1)
  17463. return edges
  17464. }
  17465. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17466. // the given name in this mutation.
  17467. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  17468. return nil
  17469. }
  17470. // ClearedEdges returns all edge names that were cleared in this mutation.
  17471. func (m *WorkExperienceMutation) ClearedEdges() []string {
  17472. edges := make([]string, 0, 1)
  17473. if m.clearedemployee {
  17474. edges = append(edges, workexperience.EdgeEmployee)
  17475. }
  17476. return edges
  17477. }
  17478. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17479. // was cleared in this mutation.
  17480. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  17481. switch name {
  17482. case workexperience.EdgeEmployee:
  17483. return m.clearedemployee
  17484. }
  17485. return false
  17486. }
  17487. // ClearEdge clears the value of the edge with the given name. It returns an error
  17488. // if that edge is not defined in the schema.
  17489. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  17490. switch name {
  17491. case workexperience.EdgeEmployee:
  17492. m.ClearEmployee()
  17493. return nil
  17494. }
  17495. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  17496. }
  17497. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17498. // It returns an error if the edge is not defined in the schema.
  17499. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  17500. switch name {
  17501. case workexperience.EdgeEmployee:
  17502. m.ResetEmployee()
  17503. return nil
  17504. }
  17505. return fmt.Errorf("unknown WorkExperience edge %s", name)
  17506. }
  17507. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  17508. type WxMutation struct {
  17509. config
  17510. op Op
  17511. typ string
  17512. id *uint64
  17513. created_at *time.Time
  17514. updated_at *time.Time
  17515. status *uint8
  17516. addstatus *int8
  17517. deleted_at *time.Time
  17518. port *string
  17519. process_id *string
  17520. callback *string
  17521. wxid *string
  17522. account *string
  17523. nickname *string
  17524. tel *string
  17525. head_big *string
  17526. organization_id *uint64
  17527. addorganization_id *int64
  17528. api_base *string
  17529. api_key *string
  17530. clearedFields map[string]struct{}
  17531. server *uint64
  17532. clearedserver bool
  17533. agent *uint64
  17534. clearedagent bool
  17535. done bool
  17536. oldValue func(context.Context) (*Wx, error)
  17537. predicates []predicate.Wx
  17538. }
  17539. var _ ent.Mutation = (*WxMutation)(nil)
  17540. // wxOption allows management of the mutation configuration using functional options.
  17541. type wxOption func(*WxMutation)
  17542. // newWxMutation creates new mutation for the Wx entity.
  17543. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  17544. m := &WxMutation{
  17545. config: c,
  17546. op: op,
  17547. typ: TypeWx,
  17548. clearedFields: make(map[string]struct{}),
  17549. }
  17550. for _, opt := range opts {
  17551. opt(m)
  17552. }
  17553. return m
  17554. }
  17555. // withWxID sets the ID field of the mutation.
  17556. func withWxID(id uint64) wxOption {
  17557. return func(m *WxMutation) {
  17558. var (
  17559. err error
  17560. once sync.Once
  17561. value *Wx
  17562. )
  17563. m.oldValue = func(ctx context.Context) (*Wx, error) {
  17564. once.Do(func() {
  17565. if m.done {
  17566. err = errors.New("querying old values post mutation is not allowed")
  17567. } else {
  17568. value, err = m.Client().Wx.Get(ctx, id)
  17569. }
  17570. })
  17571. return value, err
  17572. }
  17573. m.id = &id
  17574. }
  17575. }
  17576. // withWx sets the old Wx of the mutation.
  17577. func withWx(node *Wx) wxOption {
  17578. return func(m *WxMutation) {
  17579. m.oldValue = func(context.Context) (*Wx, error) {
  17580. return node, nil
  17581. }
  17582. m.id = &node.ID
  17583. }
  17584. }
  17585. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17586. // executed in a transaction (ent.Tx), a transactional client is returned.
  17587. func (m WxMutation) Client() *Client {
  17588. client := &Client{config: m.config}
  17589. client.init()
  17590. return client
  17591. }
  17592. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17593. // it returns an error otherwise.
  17594. func (m WxMutation) Tx() (*Tx, error) {
  17595. if _, ok := m.driver.(*txDriver); !ok {
  17596. return nil, errors.New("ent: mutation is not running in a transaction")
  17597. }
  17598. tx := &Tx{config: m.config}
  17599. tx.init()
  17600. return tx, nil
  17601. }
  17602. // SetID sets the value of the id field. Note that this
  17603. // operation is only accepted on creation of Wx entities.
  17604. func (m *WxMutation) SetID(id uint64) {
  17605. m.id = &id
  17606. }
  17607. // ID returns the ID value in the mutation. Note that the ID is only available
  17608. // if it was provided to the builder or after it was returned from the database.
  17609. func (m *WxMutation) ID() (id uint64, exists bool) {
  17610. if m.id == nil {
  17611. return
  17612. }
  17613. return *m.id, true
  17614. }
  17615. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17616. // That means, if the mutation is applied within a transaction with an isolation level such
  17617. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17618. // or updated by the mutation.
  17619. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  17620. switch {
  17621. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17622. id, exists := m.ID()
  17623. if exists {
  17624. return []uint64{id}, nil
  17625. }
  17626. fallthrough
  17627. case m.op.Is(OpUpdate | OpDelete):
  17628. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  17629. default:
  17630. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17631. }
  17632. }
  17633. // SetCreatedAt sets the "created_at" field.
  17634. func (m *WxMutation) SetCreatedAt(t time.Time) {
  17635. m.created_at = &t
  17636. }
  17637. // CreatedAt returns the value of the "created_at" field in the mutation.
  17638. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  17639. v := m.created_at
  17640. if v == nil {
  17641. return
  17642. }
  17643. return *v, true
  17644. }
  17645. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  17646. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17648. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17649. if !m.op.Is(OpUpdateOne) {
  17650. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17651. }
  17652. if m.id == nil || m.oldValue == nil {
  17653. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17654. }
  17655. oldValue, err := m.oldValue(ctx)
  17656. if err != nil {
  17657. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17658. }
  17659. return oldValue.CreatedAt, nil
  17660. }
  17661. // ResetCreatedAt resets all changes to the "created_at" field.
  17662. func (m *WxMutation) ResetCreatedAt() {
  17663. m.created_at = nil
  17664. }
  17665. // SetUpdatedAt sets the "updated_at" field.
  17666. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  17667. m.updated_at = &t
  17668. }
  17669. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17670. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  17671. v := m.updated_at
  17672. if v == nil {
  17673. return
  17674. }
  17675. return *v, true
  17676. }
  17677. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  17678. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17680. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17681. if !m.op.Is(OpUpdateOne) {
  17682. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17683. }
  17684. if m.id == nil || m.oldValue == nil {
  17685. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17686. }
  17687. oldValue, err := m.oldValue(ctx)
  17688. if err != nil {
  17689. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17690. }
  17691. return oldValue.UpdatedAt, nil
  17692. }
  17693. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17694. func (m *WxMutation) ResetUpdatedAt() {
  17695. m.updated_at = nil
  17696. }
  17697. // SetStatus sets the "status" field.
  17698. func (m *WxMutation) SetStatus(u uint8) {
  17699. m.status = &u
  17700. m.addstatus = nil
  17701. }
  17702. // Status returns the value of the "status" field in the mutation.
  17703. func (m *WxMutation) Status() (r uint8, exists bool) {
  17704. v := m.status
  17705. if v == nil {
  17706. return
  17707. }
  17708. return *v, true
  17709. }
  17710. // OldStatus returns the old "status" field's value of the Wx entity.
  17711. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17713. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17714. if !m.op.Is(OpUpdateOne) {
  17715. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17716. }
  17717. if m.id == nil || m.oldValue == nil {
  17718. return v, errors.New("OldStatus requires an ID field in the mutation")
  17719. }
  17720. oldValue, err := m.oldValue(ctx)
  17721. if err != nil {
  17722. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17723. }
  17724. return oldValue.Status, nil
  17725. }
  17726. // AddStatus adds u to the "status" field.
  17727. func (m *WxMutation) AddStatus(u int8) {
  17728. if m.addstatus != nil {
  17729. *m.addstatus += u
  17730. } else {
  17731. m.addstatus = &u
  17732. }
  17733. }
  17734. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17735. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  17736. v := m.addstatus
  17737. if v == nil {
  17738. return
  17739. }
  17740. return *v, true
  17741. }
  17742. // ClearStatus clears the value of the "status" field.
  17743. func (m *WxMutation) ClearStatus() {
  17744. m.status = nil
  17745. m.addstatus = nil
  17746. m.clearedFields[wx.FieldStatus] = struct{}{}
  17747. }
  17748. // StatusCleared returns if the "status" field was cleared in this mutation.
  17749. func (m *WxMutation) StatusCleared() bool {
  17750. _, ok := m.clearedFields[wx.FieldStatus]
  17751. return ok
  17752. }
  17753. // ResetStatus resets all changes to the "status" field.
  17754. func (m *WxMutation) ResetStatus() {
  17755. m.status = nil
  17756. m.addstatus = nil
  17757. delete(m.clearedFields, wx.FieldStatus)
  17758. }
  17759. // SetDeletedAt sets the "deleted_at" field.
  17760. func (m *WxMutation) SetDeletedAt(t time.Time) {
  17761. m.deleted_at = &t
  17762. }
  17763. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17764. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  17765. v := m.deleted_at
  17766. if v == nil {
  17767. return
  17768. }
  17769. return *v, true
  17770. }
  17771. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  17772. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17774. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17775. if !m.op.Is(OpUpdateOne) {
  17776. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17777. }
  17778. if m.id == nil || m.oldValue == nil {
  17779. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17780. }
  17781. oldValue, err := m.oldValue(ctx)
  17782. if err != nil {
  17783. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17784. }
  17785. return oldValue.DeletedAt, nil
  17786. }
  17787. // ClearDeletedAt clears the value of the "deleted_at" field.
  17788. func (m *WxMutation) ClearDeletedAt() {
  17789. m.deleted_at = nil
  17790. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  17791. }
  17792. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17793. func (m *WxMutation) DeletedAtCleared() bool {
  17794. _, ok := m.clearedFields[wx.FieldDeletedAt]
  17795. return ok
  17796. }
  17797. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17798. func (m *WxMutation) ResetDeletedAt() {
  17799. m.deleted_at = nil
  17800. delete(m.clearedFields, wx.FieldDeletedAt)
  17801. }
  17802. // SetServerID sets the "server_id" field.
  17803. func (m *WxMutation) SetServerID(u uint64) {
  17804. m.server = &u
  17805. }
  17806. // ServerID returns the value of the "server_id" field in the mutation.
  17807. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  17808. v := m.server
  17809. if v == nil {
  17810. return
  17811. }
  17812. return *v, true
  17813. }
  17814. // OldServerID returns the old "server_id" field's value of the Wx entity.
  17815. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17817. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  17818. if !m.op.Is(OpUpdateOne) {
  17819. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  17820. }
  17821. if m.id == nil || m.oldValue == nil {
  17822. return v, errors.New("OldServerID requires an ID field in the mutation")
  17823. }
  17824. oldValue, err := m.oldValue(ctx)
  17825. if err != nil {
  17826. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  17827. }
  17828. return oldValue.ServerID, nil
  17829. }
  17830. // ClearServerID clears the value of the "server_id" field.
  17831. func (m *WxMutation) ClearServerID() {
  17832. m.server = nil
  17833. m.clearedFields[wx.FieldServerID] = struct{}{}
  17834. }
  17835. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  17836. func (m *WxMutation) ServerIDCleared() bool {
  17837. _, ok := m.clearedFields[wx.FieldServerID]
  17838. return ok
  17839. }
  17840. // ResetServerID resets all changes to the "server_id" field.
  17841. func (m *WxMutation) ResetServerID() {
  17842. m.server = nil
  17843. delete(m.clearedFields, wx.FieldServerID)
  17844. }
  17845. // SetPort sets the "port" field.
  17846. func (m *WxMutation) SetPort(s string) {
  17847. m.port = &s
  17848. }
  17849. // Port returns the value of the "port" field in the mutation.
  17850. func (m *WxMutation) Port() (r string, exists bool) {
  17851. v := m.port
  17852. if v == nil {
  17853. return
  17854. }
  17855. return *v, true
  17856. }
  17857. // OldPort returns the old "port" field's value of the Wx entity.
  17858. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17860. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  17861. if !m.op.Is(OpUpdateOne) {
  17862. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  17863. }
  17864. if m.id == nil || m.oldValue == nil {
  17865. return v, errors.New("OldPort requires an ID field in the mutation")
  17866. }
  17867. oldValue, err := m.oldValue(ctx)
  17868. if err != nil {
  17869. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  17870. }
  17871. return oldValue.Port, nil
  17872. }
  17873. // ResetPort resets all changes to the "port" field.
  17874. func (m *WxMutation) ResetPort() {
  17875. m.port = nil
  17876. }
  17877. // SetProcessID sets the "process_id" field.
  17878. func (m *WxMutation) SetProcessID(s string) {
  17879. m.process_id = &s
  17880. }
  17881. // ProcessID returns the value of the "process_id" field in the mutation.
  17882. func (m *WxMutation) ProcessID() (r string, exists bool) {
  17883. v := m.process_id
  17884. if v == nil {
  17885. return
  17886. }
  17887. return *v, true
  17888. }
  17889. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  17890. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17892. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  17893. if !m.op.Is(OpUpdateOne) {
  17894. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  17895. }
  17896. if m.id == nil || m.oldValue == nil {
  17897. return v, errors.New("OldProcessID requires an ID field in the mutation")
  17898. }
  17899. oldValue, err := m.oldValue(ctx)
  17900. if err != nil {
  17901. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  17902. }
  17903. return oldValue.ProcessID, nil
  17904. }
  17905. // ResetProcessID resets all changes to the "process_id" field.
  17906. func (m *WxMutation) ResetProcessID() {
  17907. m.process_id = nil
  17908. }
  17909. // SetCallback sets the "callback" field.
  17910. func (m *WxMutation) SetCallback(s string) {
  17911. m.callback = &s
  17912. }
  17913. // Callback returns the value of the "callback" field in the mutation.
  17914. func (m *WxMutation) Callback() (r string, exists bool) {
  17915. v := m.callback
  17916. if v == nil {
  17917. return
  17918. }
  17919. return *v, true
  17920. }
  17921. // OldCallback returns the old "callback" field's value of the Wx entity.
  17922. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17924. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  17925. if !m.op.Is(OpUpdateOne) {
  17926. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  17927. }
  17928. if m.id == nil || m.oldValue == nil {
  17929. return v, errors.New("OldCallback requires an ID field in the mutation")
  17930. }
  17931. oldValue, err := m.oldValue(ctx)
  17932. if err != nil {
  17933. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  17934. }
  17935. return oldValue.Callback, nil
  17936. }
  17937. // ResetCallback resets all changes to the "callback" field.
  17938. func (m *WxMutation) ResetCallback() {
  17939. m.callback = nil
  17940. }
  17941. // SetWxid sets the "wxid" field.
  17942. func (m *WxMutation) SetWxid(s string) {
  17943. m.wxid = &s
  17944. }
  17945. // Wxid returns the value of the "wxid" field in the mutation.
  17946. func (m *WxMutation) Wxid() (r string, exists bool) {
  17947. v := m.wxid
  17948. if v == nil {
  17949. return
  17950. }
  17951. return *v, true
  17952. }
  17953. // OldWxid returns the old "wxid" field's value of the Wx entity.
  17954. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17956. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  17957. if !m.op.Is(OpUpdateOne) {
  17958. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  17959. }
  17960. if m.id == nil || m.oldValue == nil {
  17961. return v, errors.New("OldWxid requires an ID field in the mutation")
  17962. }
  17963. oldValue, err := m.oldValue(ctx)
  17964. if err != nil {
  17965. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  17966. }
  17967. return oldValue.Wxid, nil
  17968. }
  17969. // ResetWxid resets all changes to the "wxid" field.
  17970. func (m *WxMutation) ResetWxid() {
  17971. m.wxid = nil
  17972. }
  17973. // SetAccount sets the "account" field.
  17974. func (m *WxMutation) SetAccount(s string) {
  17975. m.account = &s
  17976. }
  17977. // Account returns the value of the "account" field in the mutation.
  17978. func (m *WxMutation) Account() (r string, exists bool) {
  17979. v := m.account
  17980. if v == nil {
  17981. return
  17982. }
  17983. return *v, true
  17984. }
  17985. // OldAccount returns the old "account" field's value of the Wx entity.
  17986. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17988. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  17989. if !m.op.Is(OpUpdateOne) {
  17990. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  17991. }
  17992. if m.id == nil || m.oldValue == nil {
  17993. return v, errors.New("OldAccount requires an ID field in the mutation")
  17994. }
  17995. oldValue, err := m.oldValue(ctx)
  17996. if err != nil {
  17997. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  17998. }
  17999. return oldValue.Account, nil
  18000. }
  18001. // ResetAccount resets all changes to the "account" field.
  18002. func (m *WxMutation) ResetAccount() {
  18003. m.account = nil
  18004. }
  18005. // SetNickname sets the "nickname" field.
  18006. func (m *WxMutation) SetNickname(s string) {
  18007. m.nickname = &s
  18008. }
  18009. // Nickname returns the value of the "nickname" field in the mutation.
  18010. func (m *WxMutation) Nickname() (r string, exists bool) {
  18011. v := m.nickname
  18012. if v == nil {
  18013. return
  18014. }
  18015. return *v, true
  18016. }
  18017. // OldNickname returns the old "nickname" field's value of the Wx entity.
  18018. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18020. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  18021. if !m.op.Is(OpUpdateOne) {
  18022. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  18023. }
  18024. if m.id == nil || m.oldValue == nil {
  18025. return v, errors.New("OldNickname requires an ID field in the mutation")
  18026. }
  18027. oldValue, err := m.oldValue(ctx)
  18028. if err != nil {
  18029. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  18030. }
  18031. return oldValue.Nickname, nil
  18032. }
  18033. // ResetNickname resets all changes to the "nickname" field.
  18034. func (m *WxMutation) ResetNickname() {
  18035. m.nickname = nil
  18036. }
  18037. // SetTel sets the "tel" field.
  18038. func (m *WxMutation) SetTel(s string) {
  18039. m.tel = &s
  18040. }
  18041. // Tel returns the value of the "tel" field in the mutation.
  18042. func (m *WxMutation) Tel() (r string, exists bool) {
  18043. v := m.tel
  18044. if v == nil {
  18045. return
  18046. }
  18047. return *v, true
  18048. }
  18049. // OldTel returns the old "tel" field's value of the Wx entity.
  18050. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18052. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  18053. if !m.op.Is(OpUpdateOne) {
  18054. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  18055. }
  18056. if m.id == nil || m.oldValue == nil {
  18057. return v, errors.New("OldTel requires an ID field in the mutation")
  18058. }
  18059. oldValue, err := m.oldValue(ctx)
  18060. if err != nil {
  18061. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  18062. }
  18063. return oldValue.Tel, nil
  18064. }
  18065. // ResetTel resets all changes to the "tel" field.
  18066. func (m *WxMutation) ResetTel() {
  18067. m.tel = nil
  18068. }
  18069. // SetHeadBig sets the "head_big" field.
  18070. func (m *WxMutation) SetHeadBig(s string) {
  18071. m.head_big = &s
  18072. }
  18073. // HeadBig returns the value of the "head_big" field in the mutation.
  18074. func (m *WxMutation) HeadBig() (r string, exists bool) {
  18075. v := m.head_big
  18076. if v == nil {
  18077. return
  18078. }
  18079. return *v, true
  18080. }
  18081. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  18082. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18084. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  18085. if !m.op.Is(OpUpdateOne) {
  18086. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  18087. }
  18088. if m.id == nil || m.oldValue == nil {
  18089. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  18090. }
  18091. oldValue, err := m.oldValue(ctx)
  18092. if err != nil {
  18093. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  18094. }
  18095. return oldValue.HeadBig, nil
  18096. }
  18097. // ResetHeadBig resets all changes to the "head_big" field.
  18098. func (m *WxMutation) ResetHeadBig() {
  18099. m.head_big = nil
  18100. }
  18101. // SetOrganizationID sets the "organization_id" field.
  18102. func (m *WxMutation) SetOrganizationID(u uint64) {
  18103. m.organization_id = &u
  18104. m.addorganization_id = nil
  18105. }
  18106. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18107. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  18108. v := m.organization_id
  18109. if v == nil {
  18110. return
  18111. }
  18112. return *v, true
  18113. }
  18114. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  18115. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18116. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18117. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18118. if !m.op.Is(OpUpdateOne) {
  18119. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18120. }
  18121. if m.id == nil || m.oldValue == nil {
  18122. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18123. }
  18124. oldValue, err := m.oldValue(ctx)
  18125. if err != nil {
  18126. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18127. }
  18128. return oldValue.OrganizationID, nil
  18129. }
  18130. // AddOrganizationID adds u to the "organization_id" field.
  18131. func (m *WxMutation) AddOrganizationID(u int64) {
  18132. if m.addorganization_id != nil {
  18133. *m.addorganization_id += u
  18134. } else {
  18135. m.addorganization_id = &u
  18136. }
  18137. }
  18138. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18139. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  18140. v := m.addorganization_id
  18141. if v == nil {
  18142. return
  18143. }
  18144. return *v, true
  18145. }
  18146. // ClearOrganizationID clears the value of the "organization_id" field.
  18147. func (m *WxMutation) ClearOrganizationID() {
  18148. m.organization_id = nil
  18149. m.addorganization_id = nil
  18150. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  18151. }
  18152. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18153. func (m *WxMutation) OrganizationIDCleared() bool {
  18154. _, ok := m.clearedFields[wx.FieldOrganizationID]
  18155. return ok
  18156. }
  18157. // ResetOrganizationID resets all changes to the "organization_id" field.
  18158. func (m *WxMutation) ResetOrganizationID() {
  18159. m.organization_id = nil
  18160. m.addorganization_id = nil
  18161. delete(m.clearedFields, wx.FieldOrganizationID)
  18162. }
  18163. // SetAgentID sets the "agent_id" field.
  18164. func (m *WxMutation) SetAgentID(u uint64) {
  18165. m.agent = &u
  18166. }
  18167. // AgentID returns the value of the "agent_id" field in the mutation.
  18168. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  18169. v := m.agent
  18170. if v == nil {
  18171. return
  18172. }
  18173. return *v, true
  18174. }
  18175. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  18176. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18178. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  18179. if !m.op.Is(OpUpdateOne) {
  18180. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  18181. }
  18182. if m.id == nil || m.oldValue == nil {
  18183. return v, errors.New("OldAgentID requires an ID field in the mutation")
  18184. }
  18185. oldValue, err := m.oldValue(ctx)
  18186. if err != nil {
  18187. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  18188. }
  18189. return oldValue.AgentID, nil
  18190. }
  18191. // ResetAgentID resets all changes to the "agent_id" field.
  18192. func (m *WxMutation) ResetAgentID() {
  18193. m.agent = nil
  18194. }
  18195. // SetAPIBase sets the "api_base" field.
  18196. func (m *WxMutation) SetAPIBase(s string) {
  18197. m.api_base = &s
  18198. }
  18199. // APIBase returns the value of the "api_base" field in the mutation.
  18200. func (m *WxMutation) APIBase() (r string, exists bool) {
  18201. v := m.api_base
  18202. if v == nil {
  18203. return
  18204. }
  18205. return *v, true
  18206. }
  18207. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  18208. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18210. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  18211. if !m.op.Is(OpUpdateOne) {
  18212. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  18213. }
  18214. if m.id == nil || m.oldValue == nil {
  18215. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  18216. }
  18217. oldValue, err := m.oldValue(ctx)
  18218. if err != nil {
  18219. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  18220. }
  18221. return oldValue.APIBase, nil
  18222. }
  18223. // ClearAPIBase clears the value of the "api_base" field.
  18224. func (m *WxMutation) ClearAPIBase() {
  18225. m.api_base = nil
  18226. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  18227. }
  18228. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  18229. func (m *WxMutation) APIBaseCleared() bool {
  18230. _, ok := m.clearedFields[wx.FieldAPIBase]
  18231. return ok
  18232. }
  18233. // ResetAPIBase resets all changes to the "api_base" field.
  18234. func (m *WxMutation) ResetAPIBase() {
  18235. m.api_base = nil
  18236. delete(m.clearedFields, wx.FieldAPIBase)
  18237. }
  18238. // SetAPIKey sets the "api_key" field.
  18239. func (m *WxMutation) SetAPIKey(s string) {
  18240. m.api_key = &s
  18241. }
  18242. // APIKey returns the value of the "api_key" field in the mutation.
  18243. func (m *WxMutation) APIKey() (r string, exists bool) {
  18244. v := m.api_key
  18245. if v == nil {
  18246. return
  18247. }
  18248. return *v, true
  18249. }
  18250. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  18251. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18253. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  18254. if !m.op.Is(OpUpdateOne) {
  18255. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  18256. }
  18257. if m.id == nil || m.oldValue == nil {
  18258. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  18259. }
  18260. oldValue, err := m.oldValue(ctx)
  18261. if err != nil {
  18262. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  18263. }
  18264. return oldValue.APIKey, nil
  18265. }
  18266. // ClearAPIKey clears the value of the "api_key" field.
  18267. func (m *WxMutation) ClearAPIKey() {
  18268. m.api_key = nil
  18269. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  18270. }
  18271. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  18272. func (m *WxMutation) APIKeyCleared() bool {
  18273. _, ok := m.clearedFields[wx.FieldAPIKey]
  18274. return ok
  18275. }
  18276. // ResetAPIKey resets all changes to the "api_key" field.
  18277. func (m *WxMutation) ResetAPIKey() {
  18278. m.api_key = nil
  18279. delete(m.clearedFields, wx.FieldAPIKey)
  18280. }
  18281. // ClearServer clears the "server" edge to the Server entity.
  18282. func (m *WxMutation) ClearServer() {
  18283. m.clearedserver = true
  18284. m.clearedFields[wx.FieldServerID] = struct{}{}
  18285. }
  18286. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  18287. func (m *WxMutation) ServerCleared() bool {
  18288. return m.ServerIDCleared() || m.clearedserver
  18289. }
  18290. // ServerIDs returns the "server" edge IDs in the mutation.
  18291. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18292. // ServerID instead. It exists only for internal usage by the builders.
  18293. func (m *WxMutation) ServerIDs() (ids []uint64) {
  18294. if id := m.server; id != nil {
  18295. ids = append(ids, *id)
  18296. }
  18297. return
  18298. }
  18299. // ResetServer resets all changes to the "server" edge.
  18300. func (m *WxMutation) ResetServer() {
  18301. m.server = nil
  18302. m.clearedserver = false
  18303. }
  18304. // ClearAgent clears the "agent" edge to the Agent entity.
  18305. func (m *WxMutation) ClearAgent() {
  18306. m.clearedagent = true
  18307. m.clearedFields[wx.FieldAgentID] = struct{}{}
  18308. }
  18309. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  18310. func (m *WxMutation) AgentCleared() bool {
  18311. return m.clearedagent
  18312. }
  18313. // AgentIDs returns the "agent" edge IDs in the mutation.
  18314. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18315. // AgentID instead. It exists only for internal usage by the builders.
  18316. func (m *WxMutation) AgentIDs() (ids []uint64) {
  18317. if id := m.agent; id != nil {
  18318. ids = append(ids, *id)
  18319. }
  18320. return
  18321. }
  18322. // ResetAgent resets all changes to the "agent" edge.
  18323. func (m *WxMutation) ResetAgent() {
  18324. m.agent = nil
  18325. m.clearedagent = false
  18326. }
  18327. // Where appends a list predicates to the WxMutation builder.
  18328. func (m *WxMutation) Where(ps ...predicate.Wx) {
  18329. m.predicates = append(m.predicates, ps...)
  18330. }
  18331. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  18332. // users can use type-assertion to append predicates that do not depend on any generated package.
  18333. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  18334. p := make([]predicate.Wx, len(ps))
  18335. for i := range ps {
  18336. p[i] = ps[i]
  18337. }
  18338. m.Where(p...)
  18339. }
  18340. // Op returns the operation name.
  18341. func (m *WxMutation) Op() Op {
  18342. return m.op
  18343. }
  18344. // SetOp allows setting the mutation operation.
  18345. func (m *WxMutation) SetOp(op Op) {
  18346. m.op = op
  18347. }
  18348. // Type returns the node type of this mutation (Wx).
  18349. func (m *WxMutation) Type() string {
  18350. return m.typ
  18351. }
  18352. // Fields returns all fields that were changed during this mutation. Note that in
  18353. // order to get all numeric fields that were incremented/decremented, call
  18354. // AddedFields().
  18355. func (m *WxMutation) Fields() []string {
  18356. fields := make([]string, 0, 17)
  18357. if m.created_at != nil {
  18358. fields = append(fields, wx.FieldCreatedAt)
  18359. }
  18360. if m.updated_at != nil {
  18361. fields = append(fields, wx.FieldUpdatedAt)
  18362. }
  18363. if m.status != nil {
  18364. fields = append(fields, wx.FieldStatus)
  18365. }
  18366. if m.deleted_at != nil {
  18367. fields = append(fields, wx.FieldDeletedAt)
  18368. }
  18369. if m.server != nil {
  18370. fields = append(fields, wx.FieldServerID)
  18371. }
  18372. if m.port != nil {
  18373. fields = append(fields, wx.FieldPort)
  18374. }
  18375. if m.process_id != nil {
  18376. fields = append(fields, wx.FieldProcessID)
  18377. }
  18378. if m.callback != nil {
  18379. fields = append(fields, wx.FieldCallback)
  18380. }
  18381. if m.wxid != nil {
  18382. fields = append(fields, wx.FieldWxid)
  18383. }
  18384. if m.account != nil {
  18385. fields = append(fields, wx.FieldAccount)
  18386. }
  18387. if m.nickname != nil {
  18388. fields = append(fields, wx.FieldNickname)
  18389. }
  18390. if m.tel != nil {
  18391. fields = append(fields, wx.FieldTel)
  18392. }
  18393. if m.head_big != nil {
  18394. fields = append(fields, wx.FieldHeadBig)
  18395. }
  18396. if m.organization_id != nil {
  18397. fields = append(fields, wx.FieldOrganizationID)
  18398. }
  18399. if m.agent != nil {
  18400. fields = append(fields, wx.FieldAgentID)
  18401. }
  18402. if m.api_base != nil {
  18403. fields = append(fields, wx.FieldAPIBase)
  18404. }
  18405. if m.api_key != nil {
  18406. fields = append(fields, wx.FieldAPIKey)
  18407. }
  18408. return fields
  18409. }
  18410. // Field returns the value of a field with the given name. The second boolean
  18411. // return value indicates that this field was not set, or was not defined in the
  18412. // schema.
  18413. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  18414. switch name {
  18415. case wx.FieldCreatedAt:
  18416. return m.CreatedAt()
  18417. case wx.FieldUpdatedAt:
  18418. return m.UpdatedAt()
  18419. case wx.FieldStatus:
  18420. return m.Status()
  18421. case wx.FieldDeletedAt:
  18422. return m.DeletedAt()
  18423. case wx.FieldServerID:
  18424. return m.ServerID()
  18425. case wx.FieldPort:
  18426. return m.Port()
  18427. case wx.FieldProcessID:
  18428. return m.ProcessID()
  18429. case wx.FieldCallback:
  18430. return m.Callback()
  18431. case wx.FieldWxid:
  18432. return m.Wxid()
  18433. case wx.FieldAccount:
  18434. return m.Account()
  18435. case wx.FieldNickname:
  18436. return m.Nickname()
  18437. case wx.FieldTel:
  18438. return m.Tel()
  18439. case wx.FieldHeadBig:
  18440. return m.HeadBig()
  18441. case wx.FieldOrganizationID:
  18442. return m.OrganizationID()
  18443. case wx.FieldAgentID:
  18444. return m.AgentID()
  18445. case wx.FieldAPIBase:
  18446. return m.APIBase()
  18447. case wx.FieldAPIKey:
  18448. return m.APIKey()
  18449. }
  18450. return nil, false
  18451. }
  18452. // OldField returns the old value of the field from the database. An error is
  18453. // returned if the mutation operation is not UpdateOne, or the query to the
  18454. // database failed.
  18455. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18456. switch name {
  18457. case wx.FieldCreatedAt:
  18458. return m.OldCreatedAt(ctx)
  18459. case wx.FieldUpdatedAt:
  18460. return m.OldUpdatedAt(ctx)
  18461. case wx.FieldStatus:
  18462. return m.OldStatus(ctx)
  18463. case wx.FieldDeletedAt:
  18464. return m.OldDeletedAt(ctx)
  18465. case wx.FieldServerID:
  18466. return m.OldServerID(ctx)
  18467. case wx.FieldPort:
  18468. return m.OldPort(ctx)
  18469. case wx.FieldProcessID:
  18470. return m.OldProcessID(ctx)
  18471. case wx.FieldCallback:
  18472. return m.OldCallback(ctx)
  18473. case wx.FieldWxid:
  18474. return m.OldWxid(ctx)
  18475. case wx.FieldAccount:
  18476. return m.OldAccount(ctx)
  18477. case wx.FieldNickname:
  18478. return m.OldNickname(ctx)
  18479. case wx.FieldTel:
  18480. return m.OldTel(ctx)
  18481. case wx.FieldHeadBig:
  18482. return m.OldHeadBig(ctx)
  18483. case wx.FieldOrganizationID:
  18484. return m.OldOrganizationID(ctx)
  18485. case wx.FieldAgentID:
  18486. return m.OldAgentID(ctx)
  18487. case wx.FieldAPIBase:
  18488. return m.OldAPIBase(ctx)
  18489. case wx.FieldAPIKey:
  18490. return m.OldAPIKey(ctx)
  18491. }
  18492. return nil, fmt.Errorf("unknown Wx field %s", name)
  18493. }
  18494. // SetField sets the value of a field with the given name. It returns an error if
  18495. // the field is not defined in the schema, or if the type mismatched the field
  18496. // type.
  18497. func (m *WxMutation) SetField(name string, value ent.Value) error {
  18498. switch name {
  18499. case wx.FieldCreatedAt:
  18500. v, ok := value.(time.Time)
  18501. if !ok {
  18502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18503. }
  18504. m.SetCreatedAt(v)
  18505. return nil
  18506. case wx.FieldUpdatedAt:
  18507. v, ok := value.(time.Time)
  18508. if !ok {
  18509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18510. }
  18511. m.SetUpdatedAt(v)
  18512. return nil
  18513. case wx.FieldStatus:
  18514. v, ok := value.(uint8)
  18515. if !ok {
  18516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18517. }
  18518. m.SetStatus(v)
  18519. return nil
  18520. case wx.FieldDeletedAt:
  18521. v, ok := value.(time.Time)
  18522. if !ok {
  18523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18524. }
  18525. m.SetDeletedAt(v)
  18526. return nil
  18527. case wx.FieldServerID:
  18528. v, ok := value.(uint64)
  18529. if !ok {
  18530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18531. }
  18532. m.SetServerID(v)
  18533. return nil
  18534. case wx.FieldPort:
  18535. v, ok := value.(string)
  18536. if !ok {
  18537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18538. }
  18539. m.SetPort(v)
  18540. return nil
  18541. case wx.FieldProcessID:
  18542. v, ok := value.(string)
  18543. if !ok {
  18544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18545. }
  18546. m.SetProcessID(v)
  18547. return nil
  18548. case wx.FieldCallback:
  18549. v, ok := value.(string)
  18550. if !ok {
  18551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18552. }
  18553. m.SetCallback(v)
  18554. return nil
  18555. case wx.FieldWxid:
  18556. v, ok := value.(string)
  18557. if !ok {
  18558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18559. }
  18560. m.SetWxid(v)
  18561. return nil
  18562. case wx.FieldAccount:
  18563. v, ok := value.(string)
  18564. if !ok {
  18565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18566. }
  18567. m.SetAccount(v)
  18568. return nil
  18569. case wx.FieldNickname:
  18570. v, ok := value.(string)
  18571. if !ok {
  18572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18573. }
  18574. m.SetNickname(v)
  18575. return nil
  18576. case wx.FieldTel:
  18577. v, ok := value.(string)
  18578. if !ok {
  18579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18580. }
  18581. m.SetTel(v)
  18582. return nil
  18583. case wx.FieldHeadBig:
  18584. v, ok := value.(string)
  18585. if !ok {
  18586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18587. }
  18588. m.SetHeadBig(v)
  18589. return nil
  18590. case wx.FieldOrganizationID:
  18591. v, ok := value.(uint64)
  18592. if !ok {
  18593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18594. }
  18595. m.SetOrganizationID(v)
  18596. return nil
  18597. case wx.FieldAgentID:
  18598. v, ok := value.(uint64)
  18599. if !ok {
  18600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18601. }
  18602. m.SetAgentID(v)
  18603. return nil
  18604. case wx.FieldAPIBase:
  18605. v, ok := value.(string)
  18606. if !ok {
  18607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18608. }
  18609. m.SetAPIBase(v)
  18610. return nil
  18611. case wx.FieldAPIKey:
  18612. v, ok := value.(string)
  18613. if !ok {
  18614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18615. }
  18616. m.SetAPIKey(v)
  18617. return nil
  18618. }
  18619. return fmt.Errorf("unknown Wx field %s", name)
  18620. }
  18621. // AddedFields returns all numeric fields that were incremented/decremented during
  18622. // this mutation.
  18623. func (m *WxMutation) AddedFields() []string {
  18624. var fields []string
  18625. if m.addstatus != nil {
  18626. fields = append(fields, wx.FieldStatus)
  18627. }
  18628. if m.addorganization_id != nil {
  18629. fields = append(fields, wx.FieldOrganizationID)
  18630. }
  18631. return fields
  18632. }
  18633. // AddedField returns the numeric value that was incremented/decremented on a field
  18634. // with the given name. The second boolean return value indicates that this field
  18635. // was not set, or was not defined in the schema.
  18636. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  18637. switch name {
  18638. case wx.FieldStatus:
  18639. return m.AddedStatus()
  18640. case wx.FieldOrganizationID:
  18641. return m.AddedOrganizationID()
  18642. }
  18643. return nil, false
  18644. }
  18645. // AddField adds the value to the field with the given name. It returns an error if
  18646. // the field is not defined in the schema, or if the type mismatched the field
  18647. // type.
  18648. func (m *WxMutation) AddField(name string, value ent.Value) error {
  18649. switch name {
  18650. case wx.FieldStatus:
  18651. v, ok := value.(int8)
  18652. if !ok {
  18653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18654. }
  18655. m.AddStatus(v)
  18656. return nil
  18657. case wx.FieldOrganizationID:
  18658. v, ok := value.(int64)
  18659. if !ok {
  18660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18661. }
  18662. m.AddOrganizationID(v)
  18663. return nil
  18664. }
  18665. return fmt.Errorf("unknown Wx numeric field %s", name)
  18666. }
  18667. // ClearedFields returns all nullable fields that were cleared during this
  18668. // mutation.
  18669. func (m *WxMutation) ClearedFields() []string {
  18670. var fields []string
  18671. if m.FieldCleared(wx.FieldStatus) {
  18672. fields = append(fields, wx.FieldStatus)
  18673. }
  18674. if m.FieldCleared(wx.FieldDeletedAt) {
  18675. fields = append(fields, wx.FieldDeletedAt)
  18676. }
  18677. if m.FieldCleared(wx.FieldServerID) {
  18678. fields = append(fields, wx.FieldServerID)
  18679. }
  18680. if m.FieldCleared(wx.FieldOrganizationID) {
  18681. fields = append(fields, wx.FieldOrganizationID)
  18682. }
  18683. if m.FieldCleared(wx.FieldAPIBase) {
  18684. fields = append(fields, wx.FieldAPIBase)
  18685. }
  18686. if m.FieldCleared(wx.FieldAPIKey) {
  18687. fields = append(fields, wx.FieldAPIKey)
  18688. }
  18689. return fields
  18690. }
  18691. // FieldCleared returns a boolean indicating if a field with the given name was
  18692. // cleared in this mutation.
  18693. func (m *WxMutation) FieldCleared(name string) bool {
  18694. _, ok := m.clearedFields[name]
  18695. return ok
  18696. }
  18697. // ClearField clears the value of the field with the given name. It returns an
  18698. // error if the field is not defined in the schema.
  18699. func (m *WxMutation) ClearField(name string) error {
  18700. switch name {
  18701. case wx.FieldStatus:
  18702. m.ClearStatus()
  18703. return nil
  18704. case wx.FieldDeletedAt:
  18705. m.ClearDeletedAt()
  18706. return nil
  18707. case wx.FieldServerID:
  18708. m.ClearServerID()
  18709. return nil
  18710. case wx.FieldOrganizationID:
  18711. m.ClearOrganizationID()
  18712. return nil
  18713. case wx.FieldAPIBase:
  18714. m.ClearAPIBase()
  18715. return nil
  18716. case wx.FieldAPIKey:
  18717. m.ClearAPIKey()
  18718. return nil
  18719. }
  18720. return fmt.Errorf("unknown Wx nullable field %s", name)
  18721. }
  18722. // ResetField resets all changes in the mutation for the field with the given name.
  18723. // It returns an error if the field is not defined in the schema.
  18724. func (m *WxMutation) ResetField(name string) error {
  18725. switch name {
  18726. case wx.FieldCreatedAt:
  18727. m.ResetCreatedAt()
  18728. return nil
  18729. case wx.FieldUpdatedAt:
  18730. m.ResetUpdatedAt()
  18731. return nil
  18732. case wx.FieldStatus:
  18733. m.ResetStatus()
  18734. return nil
  18735. case wx.FieldDeletedAt:
  18736. m.ResetDeletedAt()
  18737. return nil
  18738. case wx.FieldServerID:
  18739. m.ResetServerID()
  18740. return nil
  18741. case wx.FieldPort:
  18742. m.ResetPort()
  18743. return nil
  18744. case wx.FieldProcessID:
  18745. m.ResetProcessID()
  18746. return nil
  18747. case wx.FieldCallback:
  18748. m.ResetCallback()
  18749. return nil
  18750. case wx.FieldWxid:
  18751. m.ResetWxid()
  18752. return nil
  18753. case wx.FieldAccount:
  18754. m.ResetAccount()
  18755. return nil
  18756. case wx.FieldNickname:
  18757. m.ResetNickname()
  18758. return nil
  18759. case wx.FieldTel:
  18760. m.ResetTel()
  18761. return nil
  18762. case wx.FieldHeadBig:
  18763. m.ResetHeadBig()
  18764. return nil
  18765. case wx.FieldOrganizationID:
  18766. m.ResetOrganizationID()
  18767. return nil
  18768. case wx.FieldAgentID:
  18769. m.ResetAgentID()
  18770. return nil
  18771. case wx.FieldAPIBase:
  18772. m.ResetAPIBase()
  18773. return nil
  18774. case wx.FieldAPIKey:
  18775. m.ResetAPIKey()
  18776. return nil
  18777. }
  18778. return fmt.Errorf("unknown Wx field %s", name)
  18779. }
  18780. // AddedEdges returns all edge names that were set/added in this mutation.
  18781. func (m *WxMutation) AddedEdges() []string {
  18782. edges := make([]string, 0, 2)
  18783. if m.server != nil {
  18784. edges = append(edges, wx.EdgeServer)
  18785. }
  18786. if m.agent != nil {
  18787. edges = append(edges, wx.EdgeAgent)
  18788. }
  18789. return edges
  18790. }
  18791. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18792. // name in this mutation.
  18793. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  18794. switch name {
  18795. case wx.EdgeServer:
  18796. if id := m.server; id != nil {
  18797. return []ent.Value{*id}
  18798. }
  18799. case wx.EdgeAgent:
  18800. if id := m.agent; id != nil {
  18801. return []ent.Value{*id}
  18802. }
  18803. }
  18804. return nil
  18805. }
  18806. // RemovedEdges returns all edge names that were removed in this mutation.
  18807. func (m *WxMutation) RemovedEdges() []string {
  18808. edges := make([]string, 0, 2)
  18809. return edges
  18810. }
  18811. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18812. // the given name in this mutation.
  18813. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  18814. return nil
  18815. }
  18816. // ClearedEdges returns all edge names that were cleared in this mutation.
  18817. func (m *WxMutation) ClearedEdges() []string {
  18818. edges := make([]string, 0, 2)
  18819. if m.clearedserver {
  18820. edges = append(edges, wx.EdgeServer)
  18821. }
  18822. if m.clearedagent {
  18823. edges = append(edges, wx.EdgeAgent)
  18824. }
  18825. return edges
  18826. }
  18827. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18828. // was cleared in this mutation.
  18829. func (m *WxMutation) EdgeCleared(name string) bool {
  18830. switch name {
  18831. case wx.EdgeServer:
  18832. return m.clearedserver
  18833. case wx.EdgeAgent:
  18834. return m.clearedagent
  18835. }
  18836. return false
  18837. }
  18838. // ClearEdge clears the value of the edge with the given name. It returns an error
  18839. // if that edge is not defined in the schema.
  18840. func (m *WxMutation) ClearEdge(name string) error {
  18841. switch name {
  18842. case wx.EdgeServer:
  18843. m.ClearServer()
  18844. return nil
  18845. case wx.EdgeAgent:
  18846. m.ClearAgent()
  18847. return nil
  18848. }
  18849. return fmt.Errorf("unknown Wx unique edge %s", name)
  18850. }
  18851. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18852. // It returns an error if the edge is not defined in the schema.
  18853. func (m *WxMutation) ResetEdge(name string) error {
  18854. switch name {
  18855. case wx.EdgeServer:
  18856. m.ResetServer()
  18857. return nil
  18858. case wx.EdgeAgent:
  18859. m.ResetAgent()
  18860. return nil
  18861. }
  18862. return fmt.Errorf("unknown Wx edge %s", name)
  18863. }