mutation.go 632 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/batchmsg"
  11. "wechat-api/ent/category"
  12. "wechat-api/ent/contact"
  13. "wechat-api/ent/custom_types"
  14. "wechat-api/ent/employee"
  15. "wechat-api/ent/employeeconfig"
  16. "wechat-api/ent/label"
  17. "wechat-api/ent/labelrelationship"
  18. "wechat-api/ent/message"
  19. "wechat-api/ent/messagerecords"
  20. "wechat-api/ent/msg"
  21. "wechat-api/ent/predicate"
  22. "wechat-api/ent/server"
  23. "wechat-api/ent/sopnode"
  24. "wechat-api/ent/sopstage"
  25. "wechat-api/ent/soptask"
  26. "wechat-api/ent/token"
  27. "wechat-api/ent/tutorial"
  28. "wechat-api/ent/workexperience"
  29. "wechat-api/ent/wx"
  30. "entgo.io/ent"
  31. "entgo.io/ent/dialect/sql"
  32. )
  33. const (
  34. // Operation types.
  35. OpCreate = ent.OpCreate
  36. OpDelete = ent.OpDelete
  37. OpDeleteOne = ent.OpDeleteOne
  38. OpUpdate = ent.OpUpdate
  39. OpUpdateOne = ent.OpUpdateOne
  40. // Node types.
  41. TypeAgent = "Agent"
  42. TypeBatchMsg = "BatchMsg"
  43. TypeCategory = "Category"
  44. TypeContact = "Contact"
  45. TypeEmployee = "Employee"
  46. TypeEmployeeConfig = "EmployeeConfig"
  47. TypeLabel = "Label"
  48. TypeLabelRelationship = "LabelRelationship"
  49. TypeMessage = "Message"
  50. TypeMessageRecords = "MessageRecords"
  51. TypeMsg = "Msg"
  52. TypeServer = "Server"
  53. TypeSopNode = "SopNode"
  54. TypeSopStage = "SopStage"
  55. TypeSopTask = "SopTask"
  56. TypeToken = "Token"
  57. TypeTutorial = "Tutorial"
  58. TypeWorkExperience = "WorkExperience"
  59. TypeWx = "Wx"
  60. )
  61. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  62. type AgentMutation struct {
  63. config
  64. op Op
  65. typ string
  66. id *uint64
  67. created_at *time.Time
  68. updated_at *time.Time
  69. deleted_at *time.Time
  70. name *string
  71. role *string
  72. status *int
  73. addstatus *int
  74. background *string
  75. examples *string
  76. organization_id *uint64
  77. addorganization_id *int64
  78. dataset_id *string
  79. collection_id *string
  80. clearedFields map[string]struct{}
  81. wx_agent map[uint64]struct{}
  82. removedwx_agent map[uint64]struct{}
  83. clearedwx_agent bool
  84. done bool
  85. oldValue func(context.Context) (*Agent, error)
  86. predicates []predicate.Agent
  87. }
  88. var _ ent.Mutation = (*AgentMutation)(nil)
  89. // agentOption allows management of the mutation configuration using functional options.
  90. type agentOption func(*AgentMutation)
  91. // newAgentMutation creates new mutation for the Agent entity.
  92. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  93. m := &AgentMutation{
  94. config: c,
  95. op: op,
  96. typ: TypeAgent,
  97. clearedFields: make(map[string]struct{}),
  98. }
  99. for _, opt := range opts {
  100. opt(m)
  101. }
  102. return m
  103. }
  104. // withAgentID sets the ID field of the mutation.
  105. func withAgentID(id uint64) agentOption {
  106. return func(m *AgentMutation) {
  107. var (
  108. err error
  109. once sync.Once
  110. value *Agent
  111. )
  112. m.oldValue = func(ctx context.Context) (*Agent, error) {
  113. once.Do(func() {
  114. if m.done {
  115. err = errors.New("querying old values post mutation is not allowed")
  116. } else {
  117. value, err = m.Client().Agent.Get(ctx, id)
  118. }
  119. })
  120. return value, err
  121. }
  122. m.id = &id
  123. }
  124. }
  125. // withAgent sets the old Agent of the mutation.
  126. func withAgent(node *Agent) agentOption {
  127. return func(m *AgentMutation) {
  128. m.oldValue = func(context.Context) (*Agent, error) {
  129. return node, nil
  130. }
  131. m.id = &node.ID
  132. }
  133. }
  134. // Client returns a new `ent.Client` from the mutation. If the mutation was
  135. // executed in a transaction (ent.Tx), a transactional client is returned.
  136. func (m AgentMutation) Client() *Client {
  137. client := &Client{config: m.config}
  138. client.init()
  139. return client
  140. }
  141. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  142. // it returns an error otherwise.
  143. func (m AgentMutation) Tx() (*Tx, error) {
  144. if _, ok := m.driver.(*txDriver); !ok {
  145. return nil, errors.New("ent: mutation is not running in a transaction")
  146. }
  147. tx := &Tx{config: m.config}
  148. tx.init()
  149. return tx, nil
  150. }
  151. // SetID sets the value of the id field. Note that this
  152. // operation is only accepted on creation of Agent entities.
  153. func (m *AgentMutation) SetID(id uint64) {
  154. m.id = &id
  155. }
  156. // ID returns the ID value in the mutation. Note that the ID is only available
  157. // if it was provided to the builder or after it was returned from the database.
  158. func (m *AgentMutation) ID() (id uint64, exists bool) {
  159. if m.id == nil {
  160. return
  161. }
  162. return *m.id, true
  163. }
  164. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  165. // That means, if the mutation is applied within a transaction with an isolation level such
  166. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  167. // or updated by the mutation.
  168. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  169. switch {
  170. case m.op.Is(OpUpdateOne | OpDeleteOne):
  171. id, exists := m.ID()
  172. if exists {
  173. return []uint64{id}, nil
  174. }
  175. fallthrough
  176. case m.op.Is(OpUpdate | OpDelete):
  177. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  178. default:
  179. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  180. }
  181. }
  182. // SetCreatedAt sets the "created_at" field.
  183. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  184. m.created_at = &t
  185. }
  186. // CreatedAt returns the value of the "created_at" field in the mutation.
  187. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  188. v := m.created_at
  189. if v == nil {
  190. return
  191. }
  192. return *v, true
  193. }
  194. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  195. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  197. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  198. if !m.op.Is(OpUpdateOne) {
  199. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  200. }
  201. if m.id == nil || m.oldValue == nil {
  202. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  203. }
  204. oldValue, err := m.oldValue(ctx)
  205. if err != nil {
  206. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  207. }
  208. return oldValue.CreatedAt, nil
  209. }
  210. // ResetCreatedAt resets all changes to the "created_at" field.
  211. func (m *AgentMutation) ResetCreatedAt() {
  212. m.created_at = nil
  213. }
  214. // SetUpdatedAt sets the "updated_at" field.
  215. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  216. m.updated_at = &t
  217. }
  218. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  219. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  220. v := m.updated_at
  221. if v == nil {
  222. return
  223. }
  224. return *v, true
  225. }
  226. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  227. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  229. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  230. if !m.op.Is(OpUpdateOne) {
  231. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  232. }
  233. if m.id == nil || m.oldValue == nil {
  234. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  235. }
  236. oldValue, err := m.oldValue(ctx)
  237. if err != nil {
  238. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  239. }
  240. return oldValue.UpdatedAt, nil
  241. }
  242. // ResetUpdatedAt resets all changes to the "updated_at" field.
  243. func (m *AgentMutation) ResetUpdatedAt() {
  244. m.updated_at = nil
  245. }
  246. // SetDeletedAt sets the "deleted_at" field.
  247. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  248. m.deleted_at = &t
  249. }
  250. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  251. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  252. v := m.deleted_at
  253. if v == nil {
  254. return
  255. }
  256. return *v, true
  257. }
  258. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  259. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  261. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  262. if !m.op.Is(OpUpdateOne) {
  263. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  264. }
  265. if m.id == nil || m.oldValue == nil {
  266. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  267. }
  268. oldValue, err := m.oldValue(ctx)
  269. if err != nil {
  270. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  271. }
  272. return oldValue.DeletedAt, nil
  273. }
  274. // ClearDeletedAt clears the value of the "deleted_at" field.
  275. func (m *AgentMutation) ClearDeletedAt() {
  276. m.deleted_at = nil
  277. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  278. }
  279. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  280. func (m *AgentMutation) DeletedAtCleared() bool {
  281. _, ok := m.clearedFields[agent.FieldDeletedAt]
  282. return ok
  283. }
  284. // ResetDeletedAt resets all changes to the "deleted_at" field.
  285. func (m *AgentMutation) ResetDeletedAt() {
  286. m.deleted_at = nil
  287. delete(m.clearedFields, agent.FieldDeletedAt)
  288. }
  289. // SetName sets the "name" field.
  290. func (m *AgentMutation) SetName(s string) {
  291. m.name = &s
  292. }
  293. // Name returns the value of the "name" field in the mutation.
  294. func (m *AgentMutation) Name() (r string, exists bool) {
  295. v := m.name
  296. if v == nil {
  297. return
  298. }
  299. return *v, true
  300. }
  301. // OldName returns the old "name" field's value of the Agent entity.
  302. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  304. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  305. if !m.op.Is(OpUpdateOne) {
  306. return v, errors.New("OldName is only allowed on UpdateOne operations")
  307. }
  308. if m.id == nil || m.oldValue == nil {
  309. return v, errors.New("OldName requires an ID field in the mutation")
  310. }
  311. oldValue, err := m.oldValue(ctx)
  312. if err != nil {
  313. return v, fmt.Errorf("querying old value for OldName: %w", err)
  314. }
  315. return oldValue.Name, nil
  316. }
  317. // ResetName resets all changes to the "name" field.
  318. func (m *AgentMutation) ResetName() {
  319. m.name = nil
  320. }
  321. // SetRole sets the "role" field.
  322. func (m *AgentMutation) SetRole(s string) {
  323. m.role = &s
  324. }
  325. // Role returns the value of the "role" field in the mutation.
  326. func (m *AgentMutation) Role() (r string, exists bool) {
  327. v := m.role
  328. if v == nil {
  329. return
  330. }
  331. return *v, true
  332. }
  333. // OldRole returns the old "role" field's value of the Agent entity.
  334. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  336. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  337. if !m.op.Is(OpUpdateOne) {
  338. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  339. }
  340. if m.id == nil || m.oldValue == nil {
  341. return v, errors.New("OldRole requires an ID field in the mutation")
  342. }
  343. oldValue, err := m.oldValue(ctx)
  344. if err != nil {
  345. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  346. }
  347. return oldValue.Role, nil
  348. }
  349. // ResetRole resets all changes to the "role" field.
  350. func (m *AgentMutation) ResetRole() {
  351. m.role = nil
  352. }
  353. // SetStatus sets the "status" field.
  354. func (m *AgentMutation) SetStatus(i int) {
  355. m.status = &i
  356. m.addstatus = nil
  357. }
  358. // Status returns the value of the "status" field in the mutation.
  359. func (m *AgentMutation) Status() (r int, exists bool) {
  360. v := m.status
  361. if v == nil {
  362. return
  363. }
  364. return *v, true
  365. }
  366. // OldStatus returns the old "status" field's value of the Agent entity.
  367. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  369. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  370. if !m.op.Is(OpUpdateOne) {
  371. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  372. }
  373. if m.id == nil || m.oldValue == nil {
  374. return v, errors.New("OldStatus requires an ID field in the mutation")
  375. }
  376. oldValue, err := m.oldValue(ctx)
  377. if err != nil {
  378. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  379. }
  380. return oldValue.Status, nil
  381. }
  382. // AddStatus adds i to the "status" field.
  383. func (m *AgentMutation) AddStatus(i int) {
  384. if m.addstatus != nil {
  385. *m.addstatus += i
  386. } else {
  387. m.addstatus = &i
  388. }
  389. }
  390. // AddedStatus returns the value that was added to the "status" field in this mutation.
  391. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  392. v := m.addstatus
  393. if v == nil {
  394. return
  395. }
  396. return *v, true
  397. }
  398. // ClearStatus clears the value of the "status" field.
  399. func (m *AgentMutation) ClearStatus() {
  400. m.status = nil
  401. m.addstatus = nil
  402. m.clearedFields[agent.FieldStatus] = struct{}{}
  403. }
  404. // StatusCleared returns if the "status" field was cleared in this mutation.
  405. func (m *AgentMutation) StatusCleared() bool {
  406. _, ok := m.clearedFields[agent.FieldStatus]
  407. return ok
  408. }
  409. // ResetStatus resets all changes to the "status" field.
  410. func (m *AgentMutation) ResetStatus() {
  411. m.status = nil
  412. m.addstatus = nil
  413. delete(m.clearedFields, agent.FieldStatus)
  414. }
  415. // SetBackground sets the "background" field.
  416. func (m *AgentMutation) SetBackground(s string) {
  417. m.background = &s
  418. }
  419. // Background returns the value of the "background" field in the mutation.
  420. func (m *AgentMutation) Background() (r string, exists bool) {
  421. v := m.background
  422. if v == nil {
  423. return
  424. }
  425. return *v, true
  426. }
  427. // OldBackground returns the old "background" field's value of the Agent entity.
  428. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  430. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  431. if !m.op.Is(OpUpdateOne) {
  432. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  433. }
  434. if m.id == nil || m.oldValue == nil {
  435. return v, errors.New("OldBackground requires an ID field in the mutation")
  436. }
  437. oldValue, err := m.oldValue(ctx)
  438. if err != nil {
  439. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  440. }
  441. return oldValue.Background, nil
  442. }
  443. // ClearBackground clears the value of the "background" field.
  444. func (m *AgentMutation) ClearBackground() {
  445. m.background = nil
  446. m.clearedFields[agent.FieldBackground] = struct{}{}
  447. }
  448. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  449. func (m *AgentMutation) BackgroundCleared() bool {
  450. _, ok := m.clearedFields[agent.FieldBackground]
  451. return ok
  452. }
  453. // ResetBackground resets all changes to the "background" field.
  454. func (m *AgentMutation) ResetBackground() {
  455. m.background = nil
  456. delete(m.clearedFields, agent.FieldBackground)
  457. }
  458. // SetExamples sets the "examples" field.
  459. func (m *AgentMutation) SetExamples(s string) {
  460. m.examples = &s
  461. }
  462. // Examples returns the value of the "examples" field in the mutation.
  463. func (m *AgentMutation) Examples() (r string, exists bool) {
  464. v := m.examples
  465. if v == nil {
  466. return
  467. }
  468. return *v, true
  469. }
  470. // OldExamples returns the old "examples" field's value of the Agent entity.
  471. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  473. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  474. if !m.op.Is(OpUpdateOne) {
  475. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  476. }
  477. if m.id == nil || m.oldValue == nil {
  478. return v, errors.New("OldExamples requires an ID field in the mutation")
  479. }
  480. oldValue, err := m.oldValue(ctx)
  481. if err != nil {
  482. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  483. }
  484. return oldValue.Examples, nil
  485. }
  486. // ClearExamples clears the value of the "examples" field.
  487. func (m *AgentMutation) ClearExamples() {
  488. m.examples = nil
  489. m.clearedFields[agent.FieldExamples] = struct{}{}
  490. }
  491. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  492. func (m *AgentMutation) ExamplesCleared() bool {
  493. _, ok := m.clearedFields[agent.FieldExamples]
  494. return ok
  495. }
  496. // ResetExamples resets all changes to the "examples" field.
  497. func (m *AgentMutation) ResetExamples() {
  498. m.examples = nil
  499. delete(m.clearedFields, agent.FieldExamples)
  500. }
  501. // SetOrganizationID sets the "organization_id" field.
  502. func (m *AgentMutation) SetOrganizationID(u uint64) {
  503. m.organization_id = &u
  504. m.addorganization_id = nil
  505. }
  506. // OrganizationID returns the value of the "organization_id" field in the mutation.
  507. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  508. v := m.organization_id
  509. if v == nil {
  510. return
  511. }
  512. return *v, true
  513. }
  514. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  515. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  516. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  517. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  518. if !m.op.Is(OpUpdateOne) {
  519. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  520. }
  521. if m.id == nil || m.oldValue == nil {
  522. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  523. }
  524. oldValue, err := m.oldValue(ctx)
  525. if err != nil {
  526. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  527. }
  528. return oldValue.OrganizationID, nil
  529. }
  530. // AddOrganizationID adds u to the "organization_id" field.
  531. func (m *AgentMutation) AddOrganizationID(u int64) {
  532. if m.addorganization_id != nil {
  533. *m.addorganization_id += u
  534. } else {
  535. m.addorganization_id = &u
  536. }
  537. }
  538. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  539. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  540. v := m.addorganization_id
  541. if v == nil {
  542. return
  543. }
  544. return *v, true
  545. }
  546. // ResetOrganizationID resets all changes to the "organization_id" field.
  547. func (m *AgentMutation) ResetOrganizationID() {
  548. m.organization_id = nil
  549. m.addorganization_id = nil
  550. }
  551. // SetDatasetID sets the "dataset_id" field.
  552. func (m *AgentMutation) SetDatasetID(s string) {
  553. m.dataset_id = &s
  554. }
  555. // DatasetID returns the value of the "dataset_id" field in the mutation.
  556. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  557. v := m.dataset_id
  558. if v == nil {
  559. return
  560. }
  561. return *v, true
  562. }
  563. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  564. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  566. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  567. if !m.op.Is(OpUpdateOne) {
  568. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  569. }
  570. if m.id == nil || m.oldValue == nil {
  571. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  572. }
  573. oldValue, err := m.oldValue(ctx)
  574. if err != nil {
  575. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  576. }
  577. return oldValue.DatasetID, nil
  578. }
  579. // ResetDatasetID resets all changes to the "dataset_id" field.
  580. func (m *AgentMutation) ResetDatasetID() {
  581. m.dataset_id = nil
  582. }
  583. // SetCollectionID sets the "collection_id" field.
  584. func (m *AgentMutation) SetCollectionID(s string) {
  585. m.collection_id = &s
  586. }
  587. // CollectionID returns the value of the "collection_id" field in the mutation.
  588. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  589. v := m.collection_id
  590. if v == nil {
  591. return
  592. }
  593. return *v, true
  594. }
  595. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  596. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  598. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  599. if !m.op.Is(OpUpdateOne) {
  600. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  601. }
  602. if m.id == nil || m.oldValue == nil {
  603. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  604. }
  605. oldValue, err := m.oldValue(ctx)
  606. if err != nil {
  607. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  608. }
  609. return oldValue.CollectionID, nil
  610. }
  611. // ResetCollectionID resets all changes to the "collection_id" field.
  612. func (m *AgentMutation) ResetCollectionID() {
  613. m.collection_id = nil
  614. }
  615. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  616. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  617. if m.wx_agent == nil {
  618. m.wx_agent = make(map[uint64]struct{})
  619. }
  620. for i := range ids {
  621. m.wx_agent[ids[i]] = struct{}{}
  622. }
  623. }
  624. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  625. func (m *AgentMutation) ClearWxAgent() {
  626. m.clearedwx_agent = true
  627. }
  628. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  629. func (m *AgentMutation) WxAgentCleared() bool {
  630. return m.clearedwx_agent
  631. }
  632. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  633. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  634. if m.removedwx_agent == nil {
  635. m.removedwx_agent = make(map[uint64]struct{})
  636. }
  637. for i := range ids {
  638. delete(m.wx_agent, ids[i])
  639. m.removedwx_agent[ids[i]] = struct{}{}
  640. }
  641. }
  642. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  643. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  644. for id := range m.removedwx_agent {
  645. ids = append(ids, id)
  646. }
  647. return
  648. }
  649. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  650. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  651. for id := range m.wx_agent {
  652. ids = append(ids, id)
  653. }
  654. return
  655. }
  656. // ResetWxAgent resets all changes to the "wx_agent" edge.
  657. func (m *AgentMutation) ResetWxAgent() {
  658. m.wx_agent = nil
  659. m.clearedwx_agent = false
  660. m.removedwx_agent = nil
  661. }
  662. // Where appends a list predicates to the AgentMutation builder.
  663. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  664. m.predicates = append(m.predicates, ps...)
  665. }
  666. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  667. // users can use type-assertion to append predicates that do not depend on any generated package.
  668. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  669. p := make([]predicate.Agent, len(ps))
  670. for i := range ps {
  671. p[i] = ps[i]
  672. }
  673. m.Where(p...)
  674. }
  675. // Op returns the operation name.
  676. func (m *AgentMutation) Op() Op {
  677. return m.op
  678. }
  679. // SetOp allows setting the mutation operation.
  680. func (m *AgentMutation) SetOp(op Op) {
  681. m.op = op
  682. }
  683. // Type returns the node type of this mutation (Agent).
  684. func (m *AgentMutation) Type() string {
  685. return m.typ
  686. }
  687. // Fields returns all fields that were changed during this mutation. Note that in
  688. // order to get all numeric fields that were incremented/decremented, call
  689. // AddedFields().
  690. func (m *AgentMutation) Fields() []string {
  691. fields := make([]string, 0, 11)
  692. if m.created_at != nil {
  693. fields = append(fields, agent.FieldCreatedAt)
  694. }
  695. if m.updated_at != nil {
  696. fields = append(fields, agent.FieldUpdatedAt)
  697. }
  698. if m.deleted_at != nil {
  699. fields = append(fields, agent.FieldDeletedAt)
  700. }
  701. if m.name != nil {
  702. fields = append(fields, agent.FieldName)
  703. }
  704. if m.role != nil {
  705. fields = append(fields, agent.FieldRole)
  706. }
  707. if m.status != nil {
  708. fields = append(fields, agent.FieldStatus)
  709. }
  710. if m.background != nil {
  711. fields = append(fields, agent.FieldBackground)
  712. }
  713. if m.examples != nil {
  714. fields = append(fields, agent.FieldExamples)
  715. }
  716. if m.organization_id != nil {
  717. fields = append(fields, agent.FieldOrganizationID)
  718. }
  719. if m.dataset_id != nil {
  720. fields = append(fields, agent.FieldDatasetID)
  721. }
  722. if m.collection_id != nil {
  723. fields = append(fields, agent.FieldCollectionID)
  724. }
  725. return fields
  726. }
  727. // Field returns the value of a field with the given name. The second boolean
  728. // return value indicates that this field was not set, or was not defined in the
  729. // schema.
  730. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  731. switch name {
  732. case agent.FieldCreatedAt:
  733. return m.CreatedAt()
  734. case agent.FieldUpdatedAt:
  735. return m.UpdatedAt()
  736. case agent.FieldDeletedAt:
  737. return m.DeletedAt()
  738. case agent.FieldName:
  739. return m.Name()
  740. case agent.FieldRole:
  741. return m.Role()
  742. case agent.FieldStatus:
  743. return m.Status()
  744. case agent.FieldBackground:
  745. return m.Background()
  746. case agent.FieldExamples:
  747. return m.Examples()
  748. case agent.FieldOrganizationID:
  749. return m.OrganizationID()
  750. case agent.FieldDatasetID:
  751. return m.DatasetID()
  752. case agent.FieldCollectionID:
  753. return m.CollectionID()
  754. }
  755. return nil, false
  756. }
  757. // OldField returns the old value of the field from the database. An error is
  758. // returned if the mutation operation is not UpdateOne, or the query to the
  759. // database failed.
  760. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  761. switch name {
  762. case agent.FieldCreatedAt:
  763. return m.OldCreatedAt(ctx)
  764. case agent.FieldUpdatedAt:
  765. return m.OldUpdatedAt(ctx)
  766. case agent.FieldDeletedAt:
  767. return m.OldDeletedAt(ctx)
  768. case agent.FieldName:
  769. return m.OldName(ctx)
  770. case agent.FieldRole:
  771. return m.OldRole(ctx)
  772. case agent.FieldStatus:
  773. return m.OldStatus(ctx)
  774. case agent.FieldBackground:
  775. return m.OldBackground(ctx)
  776. case agent.FieldExamples:
  777. return m.OldExamples(ctx)
  778. case agent.FieldOrganizationID:
  779. return m.OldOrganizationID(ctx)
  780. case agent.FieldDatasetID:
  781. return m.OldDatasetID(ctx)
  782. case agent.FieldCollectionID:
  783. return m.OldCollectionID(ctx)
  784. }
  785. return nil, fmt.Errorf("unknown Agent field %s", name)
  786. }
  787. // SetField sets the value of a field with the given name. It returns an error if
  788. // the field is not defined in the schema, or if the type mismatched the field
  789. // type.
  790. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  791. switch name {
  792. case agent.FieldCreatedAt:
  793. v, ok := value.(time.Time)
  794. if !ok {
  795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  796. }
  797. m.SetCreatedAt(v)
  798. return nil
  799. case agent.FieldUpdatedAt:
  800. v, ok := value.(time.Time)
  801. if !ok {
  802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  803. }
  804. m.SetUpdatedAt(v)
  805. return nil
  806. case agent.FieldDeletedAt:
  807. v, ok := value.(time.Time)
  808. if !ok {
  809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  810. }
  811. m.SetDeletedAt(v)
  812. return nil
  813. case agent.FieldName:
  814. v, ok := value.(string)
  815. if !ok {
  816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  817. }
  818. m.SetName(v)
  819. return nil
  820. case agent.FieldRole:
  821. v, ok := value.(string)
  822. if !ok {
  823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  824. }
  825. m.SetRole(v)
  826. return nil
  827. case agent.FieldStatus:
  828. v, ok := value.(int)
  829. if !ok {
  830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  831. }
  832. m.SetStatus(v)
  833. return nil
  834. case agent.FieldBackground:
  835. v, ok := value.(string)
  836. if !ok {
  837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  838. }
  839. m.SetBackground(v)
  840. return nil
  841. case agent.FieldExamples:
  842. v, ok := value.(string)
  843. if !ok {
  844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  845. }
  846. m.SetExamples(v)
  847. return nil
  848. case agent.FieldOrganizationID:
  849. v, ok := value.(uint64)
  850. if !ok {
  851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  852. }
  853. m.SetOrganizationID(v)
  854. return nil
  855. case agent.FieldDatasetID:
  856. v, ok := value.(string)
  857. if !ok {
  858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  859. }
  860. m.SetDatasetID(v)
  861. return nil
  862. case agent.FieldCollectionID:
  863. v, ok := value.(string)
  864. if !ok {
  865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  866. }
  867. m.SetCollectionID(v)
  868. return nil
  869. }
  870. return fmt.Errorf("unknown Agent field %s", name)
  871. }
  872. // AddedFields returns all numeric fields that were incremented/decremented during
  873. // this mutation.
  874. func (m *AgentMutation) AddedFields() []string {
  875. var fields []string
  876. if m.addstatus != nil {
  877. fields = append(fields, agent.FieldStatus)
  878. }
  879. if m.addorganization_id != nil {
  880. fields = append(fields, agent.FieldOrganizationID)
  881. }
  882. return fields
  883. }
  884. // AddedField returns the numeric value that was incremented/decremented on a field
  885. // with the given name. The second boolean return value indicates that this field
  886. // was not set, or was not defined in the schema.
  887. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  888. switch name {
  889. case agent.FieldStatus:
  890. return m.AddedStatus()
  891. case agent.FieldOrganizationID:
  892. return m.AddedOrganizationID()
  893. }
  894. return nil, false
  895. }
  896. // AddField adds the value to the field with the given name. It returns an error if
  897. // the field is not defined in the schema, or if the type mismatched the field
  898. // type.
  899. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  900. switch name {
  901. case agent.FieldStatus:
  902. v, ok := value.(int)
  903. if !ok {
  904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  905. }
  906. m.AddStatus(v)
  907. return nil
  908. case agent.FieldOrganizationID:
  909. v, ok := value.(int64)
  910. if !ok {
  911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  912. }
  913. m.AddOrganizationID(v)
  914. return nil
  915. }
  916. return fmt.Errorf("unknown Agent numeric field %s", name)
  917. }
  918. // ClearedFields returns all nullable fields that were cleared during this
  919. // mutation.
  920. func (m *AgentMutation) ClearedFields() []string {
  921. var fields []string
  922. if m.FieldCleared(agent.FieldDeletedAt) {
  923. fields = append(fields, agent.FieldDeletedAt)
  924. }
  925. if m.FieldCleared(agent.FieldStatus) {
  926. fields = append(fields, agent.FieldStatus)
  927. }
  928. if m.FieldCleared(agent.FieldBackground) {
  929. fields = append(fields, agent.FieldBackground)
  930. }
  931. if m.FieldCleared(agent.FieldExamples) {
  932. fields = append(fields, agent.FieldExamples)
  933. }
  934. return fields
  935. }
  936. // FieldCleared returns a boolean indicating if a field with the given name was
  937. // cleared in this mutation.
  938. func (m *AgentMutation) FieldCleared(name string) bool {
  939. _, ok := m.clearedFields[name]
  940. return ok
  941. }
  942. // ClearField clears the value of the field with the given name. It returns an
  943. // error if the field is not defined in the schema.
  944. func (m *AgentMutation) ClearField(name string) error {
  945. switch name {
  946. case agent.FieldDeletedAt:
  947. m.ClearDeletedAt()
  948. return nil
  949. case agent.FieldStatus:
  950. m.ClearStatus()
  951. return nil
  952. case agent.FieldBackground:
  953. m.ClearBackground()
  954. return nil
  955. case agent.FieldExamples:
  956. m.ClearExamples()
  957. return nil
  958. }
  959. return fmt.Errorf("unknown Agent nullable field %s", name)
  960. }
  961. // ResetField resets all changes in the mutation for the field with the given name.
  962. // It returns an error if the field is not defined in the schema.
  963. func (m *AgentMutation) ResetField(name string) error {
  964. switch name {
  965. case agent.FieldCreatedAt:
  966. m.ResetCreatedAt()
  967. return nil
  968. case agent.FieldUpdatedAt:
  969. m.ResetUpdatedAt()
  970. return nil
  971. case agent.FieldDeletedAt:
  972. m.ResetDeletedAt()
  973. return nil
  974. case agent.FieldName:
  975. m.ResetName()
  976. return nil
  977. case agent.FieldRole:
  978. m.ResetRole()
  979. return nil
  980. case agent.FieldStatus:
  981. m.ResetStatus()
  982. return nil
  983. case agent.FieldBackground:
  984. m.ResetBackground()
  985. return nil
  986. case agent.FieldExamples:
  987. m.ResetExamples()
  988. return nil
  989. case agent.FieldOrganizationID:
  990. m.ResetOrganizationID()
  991. return nil
  992. case agent.FieldDatasetID:
  993. m.ResetDatasetID()
  994. return nil
  995. case agent.FieldCollectionID:
  996. m.ResetCollectionID()
  997. return nil
  998. }
  999. return fmt.Errorf("unknown Agent field %s", name)
  1000. }
  1001. // AddedEdges returns all edge names that were set/added in this mutation.
  1002. func (m *AgentMutation) AddedEdges() []string {
  1003. edges := make([]string, 0, 1)
  1004. if m.wx_agent != nil {
  1005. edges = append(edges, agent.EdgeWxAgent)
  1006. }
  1007. return edges
  1008. }
  1009. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1010. // name in this mutation.
  1011. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1012. switch name {
  1013. case agent.EdgeWxAgent:
  1014. ids := make([]ent.Value, 0, len(m.wx_agent))
  1015. for id := range m.wx_agent {
  1016. ids = append(ids, id)
  1017. }
  1018. return ids
  1019. }
  1020. return nil
  1021. }
  1022. // RemovedEdges returns all edge names that were removed in this mutation.
  1023. func (m *AgentMutation) RemovedEdges() []string {
  1024. edges := make([]string, 0, 1)
  1025. if m.removedwx_agent != nil {
  1026. edges = append(edges, agent.EdgeWxAgent)
  1027. }
  1028. return edges
  1029. }
  1030. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1031. // the given name in this mutation.
  1032. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1033. switch name {
  1034. case agent.EdgeWxAgent:
  1035. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1036. for id := range m.removedwx_agent {
  1037. ids = append(ids, id)
  1038. }
  1039. return ids
  1040. }
  1041. return nil
  1042. }
  1043. // ClearedEdges returns all edge names that were cleared in this mutation.
  1044. func (m *AgentMutation) ClearedEdges() []string {
  1045. edges := make([]string, 0, 1)
  1046. if m.clearedwx_agent {
  1047. edges = append(edges, agent.EdgeWxAgent)
  1048. }
  1049. return edges
  1050. }
  1051. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1052. // was cleared in this mutation.
  1053. func (m *AgentMutation) EdgeCleared(name string) bool {
  1054. switch name {
  1055. case agent.EdgeWxAgent:
  1056. return m.clearedwx_agent
  1057. }
  1058. return false
  1059. }
  1060. // ClearEdge clears the value of the edge with the given name. It returns an error
  1061. // if that edge is not defined in the schema.
  1062. func (m *AgentMutation) ClearEdge(name string) error {
  1063. switch name {
  1064. }
  1065. return fmt.Errorf("unknown Agent unique edge %s", name)
  1066. }
  1067. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1068. // It returns an error if the edge is not defined in the schema.
  1069. func (m *AgentMutation) ResetEdge(name string) error {
  1070. switch name {
  1071. case agent.EdgeWxAgent:
  1072. m.ResetWxAgent()
  1073. return nil
  1074. }
  1075. return fmt.Errorf("unknown Agent edge %s", name)
  1076. }
  1077. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  1078. type BatchMsgMutation struct {
  1079. config
  1080. op Op
  1081. typ string
  1082. id *uint64
  1083. created_at *time.Time
  1084. updated_at *time.Time
  1085. deleted_at *time.Time
  1086. status *uint8
  1087. addstatus *int8
  1088. batch_no *string
  1089. task_name *string
  1090. fromwxid *string
  1091. msg *string
  1092. tag *string
  1093. total *int32
  1094. addtotal *int32
  1095. success *int32
  1096. addsuccess *int32
  1097. fail *int32
  1098. addfail *int32
  1099. start_time *time.Time
  1100. stop_time *time.Time
  1101. _type *int32
  1102. add_type *int32
  1103. organization_id *uint64
  1104. addorganization_id *int64
  1105. clearedFields map[string]struct{}
  1106. done bool
  1107. oldValue func(context.Context) (*BatchMsg, error)
  1108. predicates []predicate.BatchMsg
  1109. }
  1110. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  1111. // batchmsgOption allows management of the mutation configuration using functional options.
  1112. type batchmsgOption func(*BatchMsgMutation)
  1113. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  1114. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  1115. m := &BatchMsgMutation{
  1116. config: c,
  1117. op: op,
  1118. typ: TypeBatchMsg,
  1119. clearedFields: make(map[string]struct{}),
  1120. }
  1121. for _, opt := range opts {
  1122. opt(m)
  1123. }
  1124. return m
  1125. }
  1126. // withBatchMsgID sets the ID field of the mutation.
  1127. func withBatchMsgID(id uint64) batchmsgOption {
  1128. return func(m *BatchMsgMutation) {
  1129. var (
  1130. err error
  1131. once sync.Once
  1132. value *BatchMsg
  1133. )
  1134. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  1135. once.Do(func() {
  1136. if m.done {
  1137. err = errors.New("querying old values post mutation is not allowed")
  1138. } else {
  1139. value, err = m.Client().BatchMsg.Get(ctx, id)
  1140. }
  1141. })
  1142. return value, err
  1143. }
  1144. m.id = &id
  1145. }
  1146. }
  1147. // withBatchMsg sets the old BatchMsg of the mutation.
  1148. func withBatchMsg(node *BatchMsg) batchmsgOption {
  1149. return func(m *BatchMsgMutation) {
  1150. m.oldValue = func(context.Context) (*BatchMsg, error) {
  1151. return node, nil
  1152. }
  1153. m.id = &node.ID
  1154. }
  1155. }
  1156. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1157. // executed in a transaction (ent.Tx), a transactional client is returned.
  1158. func (m BatchMsgMutation) Client() *Client {
  1159. client := &Client{config: m.config}
  1160. client.init()
  1161. return client
  1162. }
  1163. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1164. // it returns an error otherwise.
  1165. func (m BatchMsgMutation) Tx() (*Tx, error) {
  1166. if _, ok := m.driver.(*txDriver); !ok {
  1167. return nil, errors.New("ent: mutation is not running in a transaction")
  1168. }
  1169. tx := &Tx{config: m.config}
  1170. tx.init()
  1171. return tx, nil
  1172. }
  1173. // SetID sets the value of the id field. Note that this
  1174. // operation is only accepted on creation of BatchMsg entities.
  1175. func (m *BatchMsgMutation) SetID(id uint64) {
  1176. m.id = &id
  1177. }
  1178. // ID returns the ID value in the mutation. Note that the ID is only available
  1179. // if it was provided to the builder or after it was returned from the database.
  1180. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  1181. if m.id == nil {
  1182. return
  1183. }
  1184. return *m.id, true
  1185. }
  1186. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1187. // That means, if the mutation is applied within a transaction with an isolation level such
  1188. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1189. // or updated by the mutation.
  1190. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  1191. switch {
  1192. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1193. id, exists := m.ID()
  1194. if exists {
  1195. return []uint64{id}, nil
  1196. }
  1197. fallthrough
  1198. case m.op.Is(OpUpdate | OpDelete):
  1199. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  1200. default:
  1201. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1202. }
  1203. }
  1204. // SetCreatedAt sets the "created_at" field.
  1205. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  1206. m.created_at = &t
  1207. }
  1208. // CreatedAt returns the value of the "created_at" field in the mutation.
  1209. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  1210. v := m.created_at
  1211. if v == nil {
  1212. return
  1213. }
  1214. return *v, true
  1215. }
  1216. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  1217. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1219. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  1220. if !m.op.Is(OpUpdateOne) {
  1221. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  1222. }
  1223. if m.id == nil || m.oldValue == nil {
  1224. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  1225. }
  1226. oldValue, err := m.oldValue(ctx)
  1227. if err != nil {
  1228. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  1229. }
  1230. return oldValue.CreatedAt, nil
  1231. }
  1232. // ResetCreatedAt resets all changes to the "created_at" field.
  1233. func (m *BatchMsgMutation) ResetCreatedAt() {
  1234. m.created_at = nil
  1235. }
  1236. // SetUpdatedAt sets the "updated_at" field.
  1237. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  1238. m.updated_at = &t
  1239. }
  1240. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  1241. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  1242. v := m.updated_at
  1243. if v == nil {
  1244. return
  1245. }
  1246. return *v, true
  1247. }
  1248. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  1249. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1251. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  1252. if !m.op.Is(OpUpdateOne) {
  1253. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  1254. }
  1255. if m.id == nil || m.oldValue == nil {
  1256. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  1257. }
  1258. oldValue, err := m.oldValue(ctx)
  1259. if err != nil {
  1260. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  1261. }
  1262. return oldValue.UpdatedAt, nil
  1263. }
  1264. // ResetUpdatedAt resets all changes to the "updated_at" field.
  1265. func (m *BatchMsgMutation) ResetUpdatedAt() {
  1266. m.updated_at = nil
  1267. }
  1268. // SetDeletedAt sets the "deleted_at" field.
  1269. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  1270. m.deleted_at = &t
  1271. }
  1272. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  1273. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  1274. v := m.deleted_at
  1275. if v == nil {
  1276. return
  1277. }
  1278. return *v, true
  1279. }
  1280. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  1281. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1282. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1283. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  1284. if !m.op.Is(OpUpdateOne) {
  1285. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  1286. }
  1287. if m.id == nil || m.oldValue == nil {
  1288. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  1289. }
  1290. oldValue, err := m.oldValue(ctx)
  1291. if err != nil {
  1292. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  1293. }
  1294. return oldValue.DeletedAt, nil
  1295. }
  1296. // ClearDeletedAt clears the value of the "deleted_at" field.
  1297. func (m *BatchMsgMutation) ClearDeletedAt() {
  1298. m.deleted_at = nil
  1299. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  1300. }
  1301. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  1302. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  1303. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  1304. return ok
  1305. }
  1306. // ResetDeletedAt resets all changes to the "deleted_at" field.
  1307. func (m *BatchMsgMutation) ResetDeletedAt() {
  1308. m.deleted_at = nil
  1309. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  1310. }
  1311. // SetStatus sets the "status" field.
  1312. func (m *BatchMsgMutation) SetStatus(u uint8) {
  1313. m.status = &u
  1314. m.addstatus = nil
  1315. }
  1316. // Status returns the value of the "status" field in the mutation.
  1317. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  1318. v := m.status
  1319. if v == nil {
  1320. return
  1321. }
  1322. return *v, true
  1323. }
  1324. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  1325. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1327. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  1328. if !m.op.Is(OpUpdateOne) {
  1329. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  1330. }
  1331. if m.id == nil || m.oldValue == nil {
  1332. return v, errors.New("OldStatus requires an ID field in the mutation")
  1333. }
  1334. oldValue, err := m.oldValue(ctx)
  1335. if err != nil {
  1336. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  1337. }
  1338. return oldValue.Status, nil
  1339. }
  1340. // AddStatus adds u to the "status" field.
  1341. func (m *BatchMsgMutation) AddStatus(u int8) {
  1342. if m.addstatus != nil {
  1343. *m.addstatus += u
  1344. } else {
  1345. m.addstatus = &u
  1346. }
  1347. }
  1348. // AddedStatus returns the value that was added to the "status" field in this mutation.
  1349. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  1350. v := m.addstatus
  1351. if v == nil {
  1352. return
  1353. }
  1354. return *v, true
  1355. }
  1356. // ClearStatus clears the value of the "status" field.
  1357. func (m *BatchMsgMutation) ClearStatus() {
  1358. m.status = nil
  1359. m.addstatus = nil
  1360. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  1361. }
  1362. // StatusCleared returns if the "status" field was cleared in this mutation.
  1363. func (m *BatchMsgMutation) StatusCleared() bool {
  1364. _, ok := m.clearedFields[batchmsg.FieldStatus]
  1365. return ok
  1366. }
  1367. // ResetStatus resets all changes to the "status" field.
  1368. func (m *BatchMsgMutation) ResetStatus() {
  1369. m.status = nil
  1370. m.addstatus = nil
  1371. delete(m.clearedFields, batchmsg.FieldStatus)
  1372. }
  1373. // SetBatchNo sets the "batch_no" field.
  1374. func (m *BatchMsgMutation) SetBatchNo(s string) {
  1375. m.batch_no = &s
  1376. }
  1377. // BatchNo returns the value of the "batch_no" field in the mutation.
  1378. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  1379. v := m.batch_no
  1380. if v == nil {
  1381. return
  1382. }
  1383. return *v, true
  1384. }
  1385. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  1386. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1388. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  1389. if !m.op.Is(OpUpdateOne) {
  1390. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  1391. }
  1392. if m.id == nil || m.oldValue == nil {
  1393. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  1394. }
  1395. oldValue, err := m.oldValue(ctx)
  1396. if err != nil {
  1397. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  1398. }
  1399. return oldValue.BatchNo, nil
  1400. }
  1401. // ClearBatchNo clears the value of the "batch_no" field.
  1402. func (m *BatchMsgMutation) ClearBatchNo() {
  1403. m.batch_no = nil
  1404. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  1405. }
  1406. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  1407. func (m *BatchMsgMutation) BatchNoCleared() bool {
  1408. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  1409. return ok
  1410. }
  1411. // ResetBatchNo resets all changes to the "batch_no" field.
  1412. func (m *BatchMsgMutation) ResetBatchNo() {
  1413. m.batch_no = nil
  1414. delete(m.clearedFields, batchmsg.FieldBatchNo)
  1415. }
  1416. // SetTaskName sets the "task_name" field.
  1417. func (m *BatchMsgMutation) SetTaskName(s string) {
  1418. m.task_name = &s
  1419. }
  1420. // TaskName returns the value of the "task_name" field in the mutation.
  1421. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  1422. v := m.task_name
  1423. if v == nil {
  1424. return
  1425. }
  1426. return *v, true
  1427. }
  1428. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  1429. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1430. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1431. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  1432. if !m.op.Is(OpUpdateOne) {
  1433. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  1434. }
  1435. if m.id == nil || m.oldValue == nil {
  1436. return v, errors.New("OldTaskName requires an ID field in the mutation")
  1437. }
  1438. oldValue, err := m.oldValue(ctx)
  1439. if err != nil {
  1440. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  1441. }
  1442. return oldValue.TaskName, nil
  1443. }
  1444. // ClearTaskName clears the value of the "task_name" field.
  1445. func (m *BatchMsgMutation) ClearTaskName() {
  1446. m.task_name = nil
  1447. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  1448. }
  1449. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  1450. func (m *BatchMsgMutation) TaskNameCleared() bool {
  1451. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  1452. return ok
  1453. }
  1454. // ResetTaskName resets all changes to the "task_name" field.
  1455. func (m *BatchMsgMutation) ResetTaskName() {
  1456. m.task_name = nil
  1457. delete(m.clearedFields, batchmsg.FieldTaskName)
  1458. }
  1459. // SetFromwxid sets the "fromwxid" field.
  1460. func (m *BatchMsgMutation) SetFromwxid(s string) {
  1461. m.fromwxid = &s
  1462. }
  1463. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  1464. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  1465. v := m.fromwxid
  1466. if v == nil {
  1467. return
  1468. }
  1469. return *v, true
  1470. }
  1471. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  1472. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1474. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  1475. if !m.op.Is(OpUpdateOne) {
  1476. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  1477. }
  1478. if m.id == nil || m.oldValue == nil {
  1479. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  1480. }
  1481. oldValue, err := m.oldValue(ctx)
  1482. if err != nil {
  1483. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  1484. }
  1485. return oldValue.Fromwxid, nil
  1486. }
  1487. // ClearFromwxid clears the value of the "fromwxid" field.
  1488. func (m *BatchMsgMutation) ClearFromwxid() {
  1489. m.fromwxid = nil
  1490. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  1491. }
  1492. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  1493. func (m *BatchMsgMutation) FromwxidCleared() bool {
  1494. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  1495. return ok
  1496. }
  1497. // ResetFromwxid resets all changes to the "fromwxid" field.
  1498. func (m *BatchMsgMutation) ResetFromwxid() {
  1499. m.fromwxid = nil
  1500. delete(m.clearedFields, batchmsg.FieldFromwxid)
  1501. }
  1502. // SetMsg sets the "msg" field.
  1503. func (m *BatchMsgMutation) SetMsg(s string) {
  1504. m.msg = &s
  1505. }
  1506. // Msg returns the value of the "msg" field in the mutation.
  1507. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  1508. v := m.msg
  1509. if v == nil {
  1510. return
  1511. }
  1512. return *v, true
  1513. }
  1514. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  1515. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1516. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1517. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  1518. if !m.op.Is(OpUpdateOne) {
  1519. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  1520. }
  1521. if m.id == nil || m.oldValue == nil {
  1522. return v, errors.New("OldMsg requires an ID field in the mutation")
  1523. }
  1524. oldValue, err := m.oldValue(ctx)
  1525. if err != nil {
  1526. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  1527. }
  1528. return oldValue.Msg, nil
  1529. }
  1530. // ClearMsg clears the value of the "msg" field.
  1531. func (m *BatchMsgMutation) ClearMsg() {
  1532. m.msg = nil
  1533. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  1534. }
  1535. // MsgCleared returns if the "msg" field was cleared in this mutation.
  1536. func (m *BatchMsgMutation) MsgCleared() bool {
  1537. _, ok := m.clearedFields[batchmsg.FieldMsg]
  1538. return ok
  1539. }
  1540. // ResetMsg resets all changes to the "msg" field.
  1541. func (m *BatchMsgMutation) ResetMsg() {
  1542. m.msg = nil
  1543. delete(m.clearedFields, batchmsg.FieldMsg)
  1544. }
  1545. // SetTag sets the "tag" field.
  1546. func (m *BatchMsgMutation) SetTag(s string) {
  1547. m.tag = &s
  1548. }
  1549. // Tag returns the value of the "tag" field in the mutation.
  1550. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  1551. v := m.tag
  1552. if v == nil {
  1553. return
  1554. }
  1555. return *v, true
  1556. }
  1557. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  1558. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1560. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  1561. if !m.op.Is(OpUpdateOne) {
  1562. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  1563. }
  1564. if m.id == nil || m.oldValue == nil {
  1565. return v, errors.New("OldTag requires an ID field in the mutation")
  1566. }
  1567. oldValue, err := m.oldValue(ctx)
  1568. if err != nil {
  1569. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  1570. }
  1571. return oldValue.Tag, nil
  1572. }
  1573. // ClearTag clears the value of the "tag" field.
  1574. func (m *BatchMsgMutation) ClearTag() {
  1575. m.tag = nil
  1576. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  1577. }
  1578. // TagCleared returns if the "tag" field was cleared in this mutation.
  1579. func (m *BatchMsgMutation) TagCleared() bool {
  1580. _, ok := m.clearedFields[batchmsg.FieldTag]
  1581. return ok
  1582. }
  1583. // ResetTag resets all changes to the "tag" field.
  1584. func (m *BatchMsgMutation) ResetTag() {
  1585. m.tag = nil
  1586. delete(m.clearedFields, batchmsg.FieldTag)
  1587. }
  1588. // SetTotal sets the "total" field.
  1589. func (m *BatchMsgMutation) SetTotal(i int32) {
  1590. m.total = &i
  1591. m.addtotal = nil
  1592. }
  1593. // Total returns the value of the "total" field in the mutation.
  1594. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  1595. v := m.total
  1596. if v == nil {
  1597. return
  1598. }
  1599. return *v, true
  1600. }
  1601. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  1602. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1604. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  1605. if !m.op.Is(OpUpdateOne) {
  1606. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  1607. }
  1608. if m.id == nil || m.oldValue == nil {
  1609. return v, errors.New("OldTotal requires an ID field in the mutation")
  1610. }
  1611. oldValue, err := m.oldValue(ctx)
  1612. if err != nil {
  1613. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  1614. }
  1615. return oldValue.Total, nil
  1616. }
  1617. // AddTotal adds i to the "total" field.
  1618. func (m *BatchMsgMutation) AddTotal(i int32) {
  1619. if m.addtotal != nil {
  1620. *m.addtotal += i
  1621. } else {
  1622. m.addtotal = &i
  1623. }
  1624. }
  1625. // AddedTotal returns the value that was added to the "total" field in this mutation.
  1626. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  1627. v := m.addtotal
  1628. if v == nil {
  1629. return
  1630. }
  1631. return *v, true
  1632. }
  1633. // ClearTotal clears the value of the "total" field.
  1634. func (m *BatchMsgMutation) ClearTotal() {
  1635. m.total = nil
  1636. m.addtotal = nil
  1637. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  1638. }
  1639. // TotalCleared returns if the "total" field was cleared in this mutation.
  1640. func (m *BatchMsgMutation) TotalCleared() bool {
  1641. _, ok := m.clearedFields[batchmsg.FieldTotal]
  1642. return ok
  1643. }
  1644. // ResetTotal resets all changes to the "total" field.
  1645. func (m *BatchMsgMutation) ResetTotal() {
  1646. m.total = nil
  1647. m.addtotal = nil
  1648. delete(m.clearedFields, batchmsg.FieldTotal)
  1649. }
  1650. // SetSuccess sets the "success" field.
  1651. func (m *BatchMsgMutation) SetSuccess(i int32) {
  1652. m.success = &i
  1653. m.addsuccess = nil
  1654. }
  1655. // Success returns the value of the "success" field in the mutation.
  1656. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  1657. v := m.success
  1658. if v == nil {
  1659. return
  1660. }
  1661. return *v, true
  1662. }
  1663. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  1664. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1666. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  1667. if !m.op.Is(OpUpdateOne) {
  1668. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  1669. }
  1670. if m.id == nil || m.oldValue == nil {
  1671. return v, errors.New("OldSuccess requires an ID field in the mutation")
  1672. }
  1673. oldValue, err := m.oldValue(ctx)
  1674. if err != nil {
  1675. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  1676. }
  1677. return oldValue.Success, nil
  1678. }
  1679. // AddSuccess adds i to the "success" field.
  1680. func (m *BatchMsgMutation) AddSuccess(i int32) {
  1681. if m.addsuccess != nil {
  1682. *m.addsuccess += i
  1683. } else {
  1684. m.addsuccess = &i
  1685. }
  1686. }
  1687. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  1688. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  1689. v := m.addsuccess
  1690. if v == nil {
  1691. return
  1692. }
  1693. return *v, true
  1694. }
  1695. // ClearSuccess clears the value of the "success" field.
  1696. func (m *BatchMsgMutation) ClearSuccess() {
  1697. m.success = nil
  1698. m.addsuccess = nil
  1699. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  1700. }
  1701. // SuccessCleared returns if the "success" field was cleared in this mutation.
  1702. func (m *BatchMsgMutation) SuccessCleared() bool {
  1703. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  1704. return ok
  1705. }
  1706. // ResetSuccess resets all changes to the "success" field.
  1707. func (m *BatchMsgMutation) ResetSuccess() {
  1708. m.success = nil
  1709. m.addsuccess = nil
  1710. delete(m.clearedFields, batchmsg.FieldSuccess)
  1711. }
  1712. // SetFail sets the "fail" field.
  1713. func (m *BatchMsgMutation) SetFail(i int32) {
  1714. m.fail = &i
  1715. m.addfail = nil
  1716. }
  1717. // Fail returns the value of the "fail" field in the mutation.
  1718. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  1719. v := m.fail
  1720. if v == nil {
  1721. return
  1722. }
  1723. return *v, true
  1724. }
  1725. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  1726. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1728. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  1729. if !m.op.Is(OpUpdateOne) {
  1730. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  1731. }
  1732. if m.id == nil || m.oldValue == nil {
  1733. return v, errors.New("OldFail requires an ID field in the mutation")
  1734. }
  1735. oldValue, err := m.oldValue(ctx)
  1736. if err != nil {
  1737. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  1738. }
  1739. return oldValue.Fail, nil
  1740. }
  1741. // AddFail adds i to the "fail" field.
  1742. func (m *BatchMsgMutation) AddFail(i int32) {
  1743. if m.addfail != nil {
  1744. *m.addfail += i
  1745. } else {
  1746. m.addfail = &i
  1747. }
  1748. }
  1749. // AddedFail returns the value that was added to the "fail" field in this mutation.
  1750. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  1751. v := m.addfail
  1752. if v == nil {
  1753. return
  1754. }
  1755. return *v, true
  1756. }
  1757. // ClearFail clears the value of the "fail" field.
  1758. func (m *BatchMsgMutation) ClearFail() {
  1759. m.fail = nil
  1760. m.addfail = nil
  1761. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  1762. }
  1763. // FailCleared returns if the "fail" field was cleared in this mutation.
  1764. func (m *BatchMsgMutation) FailCleared() bool {
  1765. _, ok := m.clearedFields[batchmsg.FieldFail]
  1766. return ok
  1767. }
  1768. // ResetFail resets all changes to the "fail" field.
  1769. func (m *BatchMsgMutation) ResetFail() {
  1770. m.fail = nil
  1771. m.addfail = nil
  1772. delete(m.clearedFields, batchmsg.FieldFail)
  1773. }
  1774. // SetStartTime sets the "start_time" field.
  1775. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  1776. m.start_time = &t
  1777. }
  1778. // StartTime returns the value of the "start_time" field in the mutation.
  1779. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  1780. v := m.start_time
  1781. if v == nil {
  1782. return
  1783. }
  1784. return *v, true
  1785. }
  1786. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  1787. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1789. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  1790. if !m.op.Is(OpUpdateOne) {
  1791. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  1792. }
  1793. if m.id == nil || m.oldValue == nil {
  1794. return v, errors.New("OldStartTime requires an ID field in the mutation")
  1795. }
  1796. oldValue, err := m.oldValue(ctx)
  1797. if err != nil {
  1798. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  1799. }
  1800. return oldValue.StartTime, nil
  1801. }
  1802. // ClearStartTime clears the value of the "start_time" field.
  1803. func (m *BatchMsgMutation) ClearStartTime() {
  1804. m.start_time = nil
  1805. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  1806. }
  1807. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  1808. func (m *BatchMsgMutation) StartTimeCleared() bool {
  1809. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  1810. return ok
  1811. }
  1812. // ResetStartTime resets all changes to the "start_time" field.
  1813. func (m *BatchMsgMutation) ResetStartTime() {
  1814. m.start_time = nil
  1815. delete(m.clearedFields, batchmsg.FieldStartTime)
  1816. }
  1817. // SetStopTime sets the "stop_time" field.
  1818. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  1819. m.stop_time = &t
  1820. }
  1821. // StopTime returns the value of the "stop_time" field in the mutation.
  1822. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  1823. v := m.stop_time
  1824. if v == nil {
  1825. return
  1826. }
  1827. return *v, true
  1828. }
  1829. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  1830. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1832. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  1833. if !m.op.Is(OpUpdateOne) {
  1834. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  1835. }
  1836. if m.id == nil || m.oldValue == nil {
  1837. return v, errors.New("OldStopTime requires an ID field in the mutation")
  1838. }
  1839. oldValue, err := m.oldValue(ctx)
  1840. if err != nil {
  1841. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  1842. }
  1843. return oldValue.StopTime, nil
  1844. }
  1845. // ClearStopTime clears the value of the "stop_time" field.
  1846. func (m *BatchMsgMutation) ClearStopTime() {
  1847. m.stop_time = nil
  1848. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  1849. }
  1850. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  1851. func (m *BatchMsgMutation) StopTimeCleared() bool {
  1852. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  1853. return ok
  1854. }
  1855. // ResetStopTime resets all changes to the "stop_time" field.
  1856. func (m *BatchMsgMutation) ResetStopTime() {
  1857. m.stop_time = nil
  1858. delete(m.clearedFields, batchmsg.FieldStopTime)
  1859. }
  1860. // SetType sets the "type" field.
  1861. func (m *BatchMsgMutation) SetType(i int32) {
  1862. m._type = &i
  1863. m.add_type = nil
  1864. }
  1865. // GetType returns the value of the "type" field in the mutation.
  1866. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  1867. v := m._type
  1868. if v == nil {
  1869. return
  1870. }
  1871. return *v, true
  1872. }
  1873. // OldType returns the old "type" field's value of the BatchMsg entity.
  1874. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1876. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  1877. if !m.op.Is(OpUpdateOne) {
  1878. return v, errors.New("OldType is only allowed on UpdateOne operations")
  1879. }
  1880. if m.id == nil || m.oldValue == nil {
  1881. return v, errors.New("OldType requires an ID field in the mutation")
  1882. }
  1883. oldValue, err := m.oldValue(ctx)
  1884. if err != nil {
  1885. return v, fmt.Errorf("querying old value for OldType: %w", err)
  1886. }
  1887. return oldValue.Type, nil
  1888. }
  1889. // AddType adds i to the "type" field.
  1890. func (m *BatchMsgMutation) AddType(i int32) {
  1891. if m.add_type != nil {
  1892. *m.add_type += i
  1893. } else {
  1894. m.add_type = &i
  1895. }
  1896. }
  1897. // AddedType returns the value that was added to the "type" field in this mutation.
  1898. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  1899. v := m.add_type
  1900. if v == nil {
  1901. return
  1902. }
  1903. return *v, true
  1904. }
  1905. // ClearType clears the value of the "type" field.
  1906. func (m *BatchMsgMutation) ClearType() {
  1907. m._type = nil
  1908. m.add_type = nil
  1909. m.clearedFields[batchmsg.FieldType] = struct{}{}
  1910. }
  1911. // TypeCleared returns if the "type" field was cleared in this mutation.
  1912. func (m *BatchMsgMutation) TypeCleared() bool {
  1913. _, ok := m.clearedFields[batchmsg.FieldType]
  1914. return ok
  1915. }
  1916. // ResetType resets all changes to the "type" field.
  1917. func (m *BatchMsgMutation) ResetType() {
  1918. m._type = nil
  1919. m.add_type = nil
  1920. delete(m.clearedFields, batchmsg.FieldType)
  1921. }
  1922. // SetOrganizationID sets the "organization_id" field.
  1923. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  1924. m.organization_id = &u
  1925. m.addorganization_id = nil
  1926. }
  1927. // OrganizationID returns the value of the "organization_id" field in the mutation.
  1928. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  1929. v := m.organization_id
  1930. if v == nil {
  1931. return
  1932. }
  1933. return *v, true
  1934. }
  1935. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  1936. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1938. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  1939. if !m.op.Is(OpUpdateOne) {
  1940. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  1941. }
  1942. if m.id == nil || m.oldValue == nil {
  1943. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  1944. }
  1945. oldValue, err := m.oldValue(ctx)
  1946. if err != nil {
  1947. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  1948. }
  1949. return oldValue.OrganizationID, nil
  1950. }
  1951. // AddOrganizationID adds u to the "organization_id" field.
  1952. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  1953. if m.addorganization_id != nil {
  1954. *m.addorganization_id += u
  1955. } else {
  1956. m.addorganization_id = &u
  1957. }
  1958. }
  1959. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  1960. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  1961. v := m.addorganization_id
  1962. if v == nil {
  1963. return
  1964. }
  1965. return *v, true
  1966. }
  1967. // ResetOrganizationID resets all changes to the "organization_id" field.
  1968. func (m *BatchMsgMutation) ResetOrganizationID() {
  1969. m.organization_id = nil
  1970. m.addorganization_id = nil
  1971. }
  1972. // Where appends a list predicates to the BatchMsgMutation builder.
  1973. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  1974. m.predicates = append(m.predicates, ps...)
  1975. }
  1976. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  1977. // users can use type-assertion to append predicates that do not depend on any generated package.
  1978. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  1979. p := make([]predicate.BatchMsg, len(ps))
  1980. for i := range ps {
  1981. p[i] = ps[i]
  1982. }
  1983. m.Where(p...)
  1984. }
  1985. // Op returns the operation name.
  1986. func (m *BatchMsgMutation) Op() Op {
  1987. return m.op
  1988. }
  1989. // SetOp allows setting the mutation operation.
  1990. func (m *BatchMsgMutation) SetOp(op Op) {
  1991. m.op = op
  1992. }
  1993. // Type returns the node type of this mutation (BatchMsg).
  1994. func (m *BatchMsgMutation) Type() string {
  1995. return m.typ
  1996. }
  1997. // Fields returns all fields that were changed during this mutation. Note that in
  1998. // order to get all numeric fields that were incremented/decremented, call
  1999. // AddedFields().
  2000. func (m *BatchMsgMutation) Fields() []string {
  2001. fields := make([]string, 0, 16)
  2002. if m.created_at != nil {
  2003. fields = append(fields, batchmsg.FieldCreatedAt)
  2004. }
  2005. if m.updated_at != nil {
  2006. fields = append(fields, batchmsg.FieldUpdatedAt)
  2007. }
  2008. if m.deleted_at != nil {
  2009. fields = append(fields, batchmsg.FieldDeletedAt)
  2010. }
  2011. if m.status != nil {
  2012. fields = append(fields, batchmsg.FieldStatus)
  2013. }
  2014. if m.batch_no != nil {
  2015. fields = append(fields, batchmsg.FieldBatchNo)
  2016. }
  2017. if m.task_name != nil {
  2018. fields = append(fields, batchmsg.FieldTaskName)
  2019. }
  2020. if m.fromwxid != nil {
  2021. fields = append(fields, batchmsg.FieldFromwxid)
  2022. }
  2023. if m.msg != nil {
  2024. fields = append(fields, batchmsg.FieldMsg)
  2025. }
  2026. if m.tag != nil {
  2027. fields = append(fields, batchmsg.FieldTag)
  2028. }
  2029. if m.total != nil {
  2030. fields = append(fields, batchmsg.FieldTotal)
  2031. }
  2032. if m.success != nil {
  2033. fields = append(fields, batchmsg.FieldSuccess)
  2034. }
  2035. if m.fail != nil {
  2036. fields = append(fields, batchmsg.FieldFail)
  2037. }
  2038. if m.start_time != nil {
  2039. fields = append(fields, batchmsg.FieldStartTime)
  2040. }
  2041. if m.stop_time != nil {
  2042. fields = append(fields, batchmsg.FieldStopTime)
  2043. }
  2044. if m._type != nil {
  2045. fields = append(fields, batchmsg.FieldType)
  2046. }
  2047. if m.organization_id != nil {
  2048. fields = append(fields, batchmsg.FieldOrganizationID)
  2049. }
  2050. return fields
  2051. }
  2052. // Field returns the value of a field with the given name. The second boolean
  2053. // return value indicates that this field was not set, or was not defined in the
  2054. // schema.
  2055. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  2056. switch name {
  2057. case batchmsg.FieldCreatedAt:
  2058. return m.CreatedAt()
  2059. case batchmsg.FieldUpdatedAt:
  2060. return m.UpdatedAt()
  2061. case batchmsg.FieldDeletedAt:
  2062. return m.DeletedAt()
  2063. case batchmsg.FieldStatus:
  2064. return m.Status()
  2065. case batchmsg.FieldBatchNo:
  2066. return m.BatchNo()
  2067. case batchmsg.FieldTaskName:
  2068. return m.TaskName()
  2069. case batchmsg.FieldFromwxid:
  2070. return m.Fromwxid()
  2071. case batchmsg.FieldMsg:
  2072. return m.Msg()
  2073. case batchmsg.FieldTag:
  2074. return m.Tag()
  2075. case batchmsg.FieldTotal:
  2076. return m.Total()
  2077. case batchmsg.FieldSuccess:
  2078. return m.Success()
  2079. case batchmsg.FieldFail:
  2080. return m.Fail()
  2081. case batchmsg.FieldStartTime:
  2082. return m.StartTime()
  2083. case batchmsg.FieldStopTime:
  2084. return m.StopTime()
  2085. case batchmsg.FieldType:
  2086. return m.GetType()
  2087. case batchmsg.FieldOrganizationID:
  2088. return m.OrganizationID()
  2089. }
  2090. return nil, false
  2091. }
  2092. // OldField returns the old value of the field from the database. An error is
  2093. // returned if the mutation operation is not UpdateOne, or the query to the
  2094. // database failed.
  2095. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2096. switch name {
  2097. case batchmsg.FieldCreatedAt:
  2098. return m.OldCreatedAt(ctx)
  2099. case batchmsg.FieldUpdatedAt:
  2100. return m.OldUpdatedAt(ctx)
  2101. case batchmsg.FieldDeletedAt:
  2102. return m.OldDeletedAt(ctx)
  2103. case batchmsg.FieldStatus:
  2104. return m.OldStatus(ctx)
  2105. case batchmsg.FieldBatchNo:
  2106. return m.OldBatchNo(ctx)
  2107. case batchmsg.FieldTaskName:
  2108. return m.OldTaskName(ctx)
  2109. case batchmsg.FieldFromwxid:
  2110. return m.OldFromwxid(ctx)
  2111. case batchmsg.FieldMsg:
  2112. return m.OldMsg(ctx)
  2113. case batchmsg.FieldTag:
  2114. return m.OldTag(ctx)
  2115. case batchmsg.FieldTotal:
  2116. return m.OldTotal(ctx)
  2117. case batchmsg.FieldSuccess:
  2118. return m.OldSuccess(ctx)
  2119. case batchmsg.FieldFail:
  2120. return m.OldFail(ctx)
  2121. case batchmsg.FieldStartTime:
  2122. return m.OldStartTime(ctx)
  2123. case batchmsg.FieldStopTime:
  2124. return m.OldStopTime(ctx)
  2125. case batchmsg.FieldType:
  2126. return m.OldType(ctx)
  2127. case batchmsg.FieldOrganizationID:
  2128. return m.OldOrganizationID(ctx)
  2129. }
  2130. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  2131. }
  2132. // SetField sets the value of a field with the given name. It returns an error if
  2133. // the field is not defined in the schema, or if the type mismatched the field
  2134. // type.
  2135. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  2136. switch name {
  2137. case batchmsg.FieldCreatedAt:
  2138. v, ok := value.(time.Time)
  2139. if !ok {
  2140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2141. }
  2142. m.SetCreatedAt(v)
  2143. return nil
  2144. case batchmsg.FieldUpdatedAt:
  2145. v, ok := value.(time.Time)
  2146. if !ok {
  2147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2148. }
  2149. m.SetUpdatedAt(v)
  2150. return nil
  2151. case batchmsg.FieldDeletedAt:
  2152. v, ok := value.(time.Time)
  2153. if !ok {
  2154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2155. }
  2156. m.SetDeletedAt(v)
  2157. return nil
  2158. case batchmsg.FieldStatus:
  2159. v, ok := value.(uint8)
  2160. if !ok {
  2161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2162. }
  2163. m.SetStatus(v)
  2164. return nil
  2165. case batchmsg.FieldBatchNo:
  2166. v, ok := value.(string)
  2167. if !ok {
  2168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2169. }
  2170. m.SetBatchNo(v)
  2171. return nil
  2172. case batchmsg.FieldTaskName:
  2173. v, ok := value.(string)
  2174. if !ok {
  2175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2176. }
  2177. m.SetTaskName(v)
  2178. return nil
  2179. case batchmsg.FieldFromwxid:
  2180. v, ok := value.(string)
  2181. if !ok {
  2182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2183. }
  2184. m.SetFromwxid(v)
  2185. return nil
  2186. case batchmsg.FieldMsg:
  2187. v, ok := value.(string)
  2188. if !ok {
  2189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2190. }
  2191. m.SetMsg(v)
  2192. return nil
  2193. case batchmsg.FieldTag:
  2194. v, ok := value.(string)
  2195. if !ok {
  2196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2197. }
  2198. m.SetTag(v)
  2199. return nil
  2200. case batchmsg.FieldTotal:
  2201. v, ok := value.(int32)
  2202. if !ok {
  2203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2204. }
  2205. m.SetTotal(v)
  2206. return nil
  2207. case batchmsg.FieldSuccess:
  2208. v, ok := value.(int32)
  2209. if !ok {
  2210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2211. }
  2212. m.SetSuccess(v)
  2213. return nil
  2214. case batchmsg.FieldFail:
  2215. v, ok := value.(int32)
  2216. if !ok {
  2217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2218. }
  2219. m.SetFail(v)
  2220. return nil
  2221. case batchmsg.FieldStartTime:
  2222. v, ok := value.(time.Time)
  2223. if !ok {
  2224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2225. }
  2226. m.SetStartTime(v)
  2227. return nil
  2228. case batchmsg.FieldStopTime:
  2229. v, ok := value.(time.Time)
  2230. if !ok {
  2231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2232. }
  2233. m.SetStopTime(v)
  2234. return nil
  2235. case batchmsg.FieldType:
  2236. v, ok := value.(int32)
  2237. if !ok {
  2238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2239. }
  2240. m.SetType(v)
  2241. return nil
  2242. case batchmsg.FieldOrganizationID:
  2243. v, ok := value.(uint64)
  2244. if !ok {
  2245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2246. }
  2247. m.SetOrganizationID(v)
  2248. return nil
  2249. }
  2250. return fmt.Errorf("unknown BatchMsg field %s", name)
  2251. }
  2252. // AddedFields returns all numeric fields that were incremented/decremented during
  2253. // this mutation.
  2254. func (m *BatchMsgMutation) AddedFields() []string {
  2255. var fields []string
  2256. if m.addstatus != nil {
  2257. fields = append(fields, batchmsg.FieldStatus)
  2258. }
  2259. if m.addtotal != nil {
  2260. fields = append(fields, batchmsg.FieldTotal)
  2261. }
  2262. if m.addsuccess != nil {
  2263. fields = append(fields, batchmsg.FieldSuccess)
  2264. }
  2265. if m.addfail != nil {
  2266. fields = append(fields, batchmsg.FieldFail)
  2267. }
  2268. if m.add_type != nil {
  2269. fields = append(fields, batchmsg.FieldType)
  2270. }
  2271. if m.addorganization_id != nil {
  2272. fields = append(fields, batchmsg.FieldOrganizationID)
  2273. }
  2274. return fields
  2275. }
  2276. // AddedField returns the numeric value that was incremented/decremented on a field
  2277. // with the given name. The second boolean return value indicates that this field
  2278. // was not set, or was not defined in the schema.
  2279. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  2280. switch name {
  2281. case batchmsg.FieldStatus:
  2282. return m.AddedStatus()
  2283. case batchmsg.FieldTotal:
  2284. return m.AddedTotal()
  2285. case batchmsg.FieldSuccess:
  2286. return m.AddedSuccess()
  2287. case batchmsg.FieldFail:
  2288. return m.AddedFail()
  2289. case batchmsg.FieldType:
  2290. return m.AddedType()
  2291. case batchmsg.FieldOrganizationID:
  2292. return m.AddedOrganizationID()
  2293. }
  2294. return nil, false
  2295. }
  2296. // AddField adds the value to the field with the given name. It returns an error if
  2297. // the field is not defined in the schema, or if the type mismatched the field
  2298. // type.
  2299. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  2300. switch name {
  2301. case batchmsg.FieldStatus:
  2302. v, ok := value.(int8)
  2303. if !ok {
  2304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2305. }
  2306. m.AddStatus(v)
  2307. return nil
  2308. case batchmsg.FieldTotal:
  2309. v, ok := value.(int32)
  2310. if !ok {
  2311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2312. }
  2313. m.AddTotal(v)
  2314. return nil
  2315. case batchmsg.FieldSuccess:
  2316. v, ok := value.(int32)
  2317. if !ok {
  2318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2319. }
  2320. m.AddSuccess(v)
  2321. return nil
  2322. case batchmsg.FieldFail:
  2323. v, ok := value.(int32)
  2324. if !ok {
  2325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2326. }
  2327. m.AddFail(v)
  2328. return nil
  2329. case batchmsg.FieldType:
  2330. v, ok := value.(int32)
  2331. if !ok {
  2332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2333. }
  2334. m.AddType(v)
  2335. return nil
  2336. case batchmsg.FieldOrganizationID:
  2337. v, ok := value.(int64)
  2338. if !ok {
  2339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2340. }
  2341. m.AddOrganizationID(v)
  2342. return nil
  2343. }
  2344. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  2345. }
  2346. // ClearedFields returns all nullable fields that were cleared during this
  2347. // mutation.
  2348. func (m *BatchMsgMutation) ClearedFields() []string {
  2349. var fields []string
  2350. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  2351. fields = append(fields, batchmsg.FieldDeletedAt)
  2352. }
  2353. if m.FieldCleared(batchmsg.FieldStatus) {
  2354. fields = append(fields, batchmsg.FieldStatus)
  2355. }
  2356. if m.FieldCleared(batchmsg.FieldBatchNo) {
  2357. fields = append(fields, batchmsg.FieldBatchNo)
  2358. }
  2359. if m.FieldCleared(batchmsg.FieldTaskName) {
  2360. fields = append(fields, batchmsg.FieldTaskName)
  2361. }
  2362. if m.FieldCleared(batchmsg.FieldFromwxid) {
  2363. fields = append(fields, batchmsg.FieldFromwxid)
  2364. }
  2365. if m.FieldCleared(batchmsg.FieldMsg) {
  2366. fields = append(fields, batchmsg.FieldMsg)
  2367. }
  2368. if m.FieldCleared(batchmsg.FieldTag) {
  2369. fields = append(fields, batchmsg.FieldTag)
  2370. }
  2371. if m.FieldCleared(batchmsg.FieldTotal) {
  2372. fields = append(fields, batchmsg.FieldTotal)
  2373. }
  2374. if m.FieldCleared(batchmsg.FieldSuccess) {
  2375. fields = append(fields, batchmsg.FieldSuccess)
  2376. }
  2377. if m.FieldCleared(batchmsg.FieldFail) {
  2378. fields = append(fields, batchmsg.FieldFail)
  2379. }
  2380. if m.FieldCleared(batchmsg.FieldStartTime) {
  2381. fields = append(fields, batchmsg.FieldStartTime)
  2382. }
  2383. if m.FieldCleared(batchmsg.FieldStopTime) {
  2384. fields = append(fields, batchmsg.FieldStopTime)
  2385. }
  2386. if m.FieldCleared(batchmsg.FieldType) {
  2387. fields = append(fields, batchmsg.FieldType)
  2388. }
  2389. return fields
  2390. }
  2391. // FieldCleared returns a boolean indicating if a field with the given name was
  2392. // cleared in this mutation.
  2393. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  2394. _, ok := m.clearedFields[name]
  2395. return ok
  2396. }
  2397. // ClearField clears the value of the field with the given name. It returns an
  2398. // error if the field is not defined in the schema.
  2399. func (m *BatchMsgMutation) ClearField(name string) error {
  2400. switch name {
  2401. case batchmsg.FieldDeletedAt:
  2402. m.ClearDeletedAt()
  2403. return nil
  2404. case batchmsg.FieldStatus:
  2405. m.ClearStatus()
  2406. return nil
  2407. case batchmsg.FieldBatchNo:
  2408. m.ClearBatchNo()
  2409. return nil
  2410. case batchmsg.FieldTaskName:
  2411. m.ClearTaskName()
  2412. return nil
  2413. case batchmsg.FieldFromwxid:
  2414. m.ClearFromwxid()
  2415. return nil
  2416. case batchmsg.FieldMsg:
  2417. m.ClearMsg()
  2418. return nil
  2419. case batchmsg.FieldTag:
  2420. m.ClearTag()
  2421. return nil
  2422. case batchmsg.FieldTotal:
  2423. m.ClearTotal()
  2424. return nil
  2425. case batchmsg.FieldSuccess:
  2426. m.ClearSuccess()
  2427. return nil
  2428. case batchmsg.FieldFail:
  2429. m.ClearFail()
  2430. return nil
  2431. case batchmsg.FieldStartTime:
  2432. m.ClearStartTime()
  2433. return nil
  2434. case batchmsg.FieldStopTime:
  2435. m.ClearStopTime()
  2436. return nil
  2437. case batchmsg.FieldType:
  2438. m.ClearType()
  2439. return nil
  2440. }
  2441. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  2442. }
  2443. // ResetField resets all changes in the mutation for the field with the given name.
  2444. // It returns an error if the field is not defined in the schema.
  2445. func (m *BatchMsgMutation) ResetField(name string) error {
  2446. switch name {
  2447. case batchmsg.FieldCreatedAt:
  2448. m.ResetCreatedAt()
  2449. return nil
  2450. case batchmsg.FieldUpdatedAt:
  2451. m.ResetUpdatedAt()
  2452. return nil
  2453. case batchmsg.FieldDeletedAt:
  2454. m.ResetDeletedAt()
  2455. return nil
  2456. case batchmsg.FieldStatus:
  2457. m.ResetStatus()
  2458. return nil
  2459. case batchmsg.FieldBatchNo:
  2460. m.ResetBatchNo()
  2461. return nil
  2462. case batchmsg.FieldTaskName:
  2463. m.ResetTaskName()
  2464. return nil
  2465. case batchmsg.FieldFromwxid:
  2466. m.ResetFromwxid()
  2467. return nil
  2468. case batchmsg.FieldMsg:
  2469. m.ResetMsg()
  2470. return nil
  2471. case batchmsg.FieldTag:
  2472. m.ResetTag()
  2473. return nil
  2474. case batchmsg.FieldTotal:
  2475. m.ResetTotal()
  2476. return nil
  2477. case batchmsg.FieldSuccess:
  2478. m.ResetSuccess()
  2479. return nil
  2480. case batchmsg.FieldFail:
  2481. m.ResetFail()
  2482. return nil
  2483. case batchmsg.FieldStartTime:
  2484. m.ResetStartTime()
  2485. return nil
  2486. case batchmsg.FieldStopTime:
  2487. m.ResetStopTime()
  2488. return nil
  2489. case batchmsg.FieldType:
  2490. m.ResetType()
  2491. return nil
  2492. case batchmsg.FieldOrganizationID:
  2493. m.ResetOrganizationID()
  2494. return nil
  2495. }
  2496. return fmt.Errorf("unknown BatchMsg field %s", name)
  2497. }
  2498. // AddedEdges returns all edge names that were set/added in this mutation.
  2499. func (m *BatchMsgMutation) AddedEdges() []string {
  2500. edges := make([]string, 0, 0)
  2501. return edges
  2502. }
  2503. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2504. // name in this mutation.
  2505. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  2506. return nil
  2507. }
  2508. // RemovedEdges returns all edge names that were removed in this mutation.
  2509. func (m *BatchMsgMutation) RemovedEdges() []string {
  2510. edges := make([]string, 0, 0)
  2511. return edges
  2512. }
  2513. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2514. // the given name in this mutation.
  2515. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  2516. return nil
  2517. }
  2518. // ClearedEdges returns all edge names that were cleared in this mutation.
  2519. func (m *BatchMsgMutation) ClearedEdges() []string {
  2520. edges := make([]string, 0, 0)
  2521. return edges
  2522. }
  2523. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2524. // was cleared in this mutation.
  2525. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  2526. return false
  2527. }
  2528. // ClearEdge clears the value of the edge with the given name. It returns an error
  2529. // if that edge is not defined in the schema.
  2530. func (m *BatchMsgMutation) ClearEdge(name string) error {
  2531. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  2532. }
  2533. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2534. // It returns an error if the edge is not defined in the schema.
  2535. func (m *BatchMsgMutation) ResetEdge(name string) error {
  2536. return fmt.Errorf("unknown BatchMsg edge %s", name)
  2537. }
  2538. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  2539. type CategoryMutation struct {
  2540. config
  2541. op Op
  2542. typ string
  2543. id *uint64
  2544. created_at *time.Time
  2545. updated_at *time.Time
  2546. deleted_at *time.Time
  2547. name *string
  2548. organization_id *uint64
  2549. addorganization_id *int64
  2550. clearedFields map[string]struct{}
  2551. done bool
  2552. oldValue func(context.Context) (*Category, error)
  2553. predicates []predicate.Category
  2554. }
  2555. var _ ent.Mutation = (*CategoryMutation)(nil)
  2556. // categoryOption allows management of the mutation configuration using functional options.
  2557. type categoryOption func(*CategoryMutation)
  2558. // newCategoryMutation creates new mutation for the Category entity.
  2559. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  2560. m := &CategoryMutation{
  2561. config: c,
  2562. op: op,
  2563. typ: TypeCategory,
  2564. clearedFields: make(map[string]struct{}),
  2565. }
  2566. for _, opt := range opts {
  2567. opt(m)
  2568. }
  2569. return m
  2570. }
  2571. // withCategoryID sets the ID field of the mutation.
  2572. func withCategoryID(id uint64) categoryOption {
  2573. return func(m *CategoryMutation) {
  2574. var (
  2575. err error
  2576. once sync.Once
  2577. value *Category
  2578. )
  2579. m.oldValue = func(ctx context.Context) (*Category, error) {
  2580. once.Do(func() {
  2581. if m.done {
  2582. err = errors.New("querying old values post mutation is not allowed")
  2583. } else {
  2584. value, err = m.Client().Category.Get(ctx, id)
  2585. }
  2586. })
  2587. return value, err
  2588. }
  2589. m.id = &id
  2590. }
  2591. }
  2592. // withCategory sets the old Category of the mutation.
  2593. func withCategory(node *Category) categoryOption {
  2594. return func(m *CategoryMutation) {
  2595. m.oldValue = func(context.Context) (*Category, error) {
  2596. return node, nil
  2597. }
  2598. m.id = &node.ID
  2599. }
  2600. }
  2601. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2602. // executed in a transaction (ent.Tx), a transactional client is returned.
  2603. func (m CategoryMutation) Client() *Client {
  2604. client := &Client{config: m.config}
  2605. client.init()
  2606. return client
  2607. }
  2608. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2609. // it returns an error otherwise.
  2610. func (m CategoryMutation) Tx() (*Tx, error) {
  2611. if _, ok := m.driver.(*txDriver); !ok {
  2612. return nil, errors.New("ent: mutation is not running in a transaction")
  2613. }
  2614. tx := &Tx{config: m.config}
  2615. tx.init()
  2616. return tx, nil
  2617. }
  2618. // SetID sets the value of the id field. Note that this
  2619. // operation is only accepted on creation of Category entities.
  2620. func (m *CategoryMutation) SetID(id uint64) {
  2621. m.id = &id
  2622. }
  2623. // ID returns the ID value in the mutation. Note that the ID is only available
  2624. // if it was provided to the builder or after it was returned from the database.
  2625. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  2626. if m.id == nil {
  2627. return
  2628. }
  2629. return *m.id, true
  2630. }
  2631. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2632. // That means, if the mutation is applied within a transaction with an isolation level such
  2633. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2634. // or updated by the mutation.
  2635. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  2636. switch {
  2637. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2638. id, exists := m.ID()
  2639. if exists {
  2640. return []uint64{id}, nil
  2641. }
  2642. fallthrough
  2643. case m.op.Is(OpUpdate | OpDelete):
  2644. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  2645. default:
  2646. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2647. }
  2648. }
  2649. // SetCreatedAt sets the "created_at" field.
  2650. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  2651. m.created_at = &t
  2652. }
  2653. // CreatedAt returns the value of the "created_at" field in the mutation.
  2654. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  2655. v := m.created_at
  2656. if v == nil {
  2657. return
  2658. }
  2659. return *v, true
  2660. }
  2661. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  2662. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  2663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2664. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2665. if !m.op.Is(OpUpdateOne) {
  2666. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2667. }
  2668. if m.id == nil || m.oldValue == nil {
  2669. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2670. }
  2671. oldValue, err := m.oldValue(ctx)
  2672. if err != nil {
  2673. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2674. }
  2675. return oldValue.CreatedAt, nil
  2676. }
  2677. // ResetCreatedAt resets all changes to the "created_at" field.
  2678. func (m *CategoryMutation) ResetCreatedAt() {
  2679. m.created_at = nil
  2680. }
  2681. // SetUpdatedAt sets the "updated_at" field.
  2682. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  2683. m.updated_at = &t
  2684. }
  2685. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2686. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  2687. v := m.updated_at
  2688. if v == nil {
  2689. return
  2690. }
  2691. return *v, true
  2692. }
  2693. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  2694. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  2695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2696. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2697. if !m.op.Is(OpUpdateOne) {
  2698. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2699. }
  2700. if m.id == nil || m.oldValue == nil {
  2701. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2702. }
  2703. oldValue, err := m.oldValue(ctx)
  2704. if err != nil {
  2705. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2706. }
  2707. return oldValue.UpdatedAt, nil
  2708. }
  2709. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2710. func (m *CategoryMutation) ResetUpdatedAt() {
  2711. m.updated_at = nil
  2712. }
  2713. // SetDeletedAt sets the "deleted_at" field.
  2714. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  2715. m.deleted_at = &t
  2716. }
  2717. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2718. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  2719. v := m.deleted_at
  2720. if v == nil {
  2721. return
  2722. }
  2723. return *v, true
  2724. }
  2725. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  2726. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  2727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2728. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2729. if !m.op.Is(OpUpdateOne) {
  2730. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2731. }
  2732. if m.id == nil || m.oldValue == nil {
  2733. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2734. }
  2735. oldValue, err := m.oldValue(ctx)
  2736. if err != nil {
  2737. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2738. }
  2739. return oldValue.DeletedAt, nil
  2740. }
  2741. // ClearDeletedAt clears the value of the "deleted_at" field.
  2742. func (m *CategoryMutation) ClearDeletedAt() {
  2743. m.deleted_at = nil
  2744. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  2745. }
  2746. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2747. func (m *CategoryMutation) DeletedAtCleared() bool {
  2748. _, ok := m.clearedFields[category.FieldDeletedAt]
  2749. return ok
  2750. }
  2751. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2752. func (m *CategoryMutation) ResetDeletedAt() {
  2753. m.deleted_at = nil
  2754. delete(m.clearedFields, category.FieldDeletedAt)
  2755. }
  2756. // SetName sets the "name" field.
  2757. func (m *CategoryMutation) SetName(s string) {
  2758. m.name = &s
  2759. }
  2760. // Name returns the value of the "name" field in the mutation.
  2761. func (m *CategoryMutation) Name() (r string, exists bool) {
  2762. v := m.name
  2763. if v == nil {
  2764. return
  2765. }
  2766. return *v, true
  2767. }
  2768. // OldName returns the old "name" field's value of the Category entity.
  2769. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  2770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2771. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  2772. if !m.op.Is(OpUpdateOne) {
  2773. return v, errors.New("OldName is only allowed on UpdateOne operations")
  2774. }
  2775. if m.id == nil || m.oldValue == nil {
  2776. return v, errors.New("OldName requires an ID field in the mutation")
  2777. }
  2778. oldValue, err := m.oldValue(ctx)
  2779. if err != nil {
  2780. return v, fmt.Errorf("querying old value for OldName: %w", err)
  2781. }
  2782. return oldValue.Name, nil
  2783. }
  2784. // ResetName resets all changes to the "name" field.
  2785. func (m *CategoryMutation) ResetName() {
  2786. m.name = nil
  2787. }
  2788. // SetOrganizationID sets the "organization_id" field.
  2789. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  2790. m.organization_id = &u
  2791. m.addorganization_id = nil
  2792. }
  2793. // OrganizationID returns the value of the "organization_id" field in the mutation.
  2794. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  2795. v := m.organization_id
  2796. if v == nil {
  2797. return
  2798. }
  2799. return *v, true
  2800. }
  2801. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  2802. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  2803. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2804. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  2805. if !m.op.Is(OpUpdateOne) {
  2806. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  2807. }
  2808. if m.id == nil || m.oldValue == nil {
  2809. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  2810. }
  2811. oldValue, err := m.oldValue(ctx)
  2812. if err != nil {
  2813. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  2814. }
  2815. return oldValue.OrganizationID, nil
  2816. }
  2817. // AddOrganizationID adds u to the "organization_id" field.
  2818. func (m *CategoryMutation) AddOrganizationID(u int64) {
  2819. if m.addorganization_id != nil {
  2820. *m.addorganization_id += u
  2821. } else {
  2822. m.addorganization_id = &u
  2823. }
  2824. }
  2825. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  2826. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  2827. v := m.addorganization_id
  2828. if v == nil {
  2829. return
  2830. }
  2831. return *v, true
  2832. }
  2833. // ResetOrganizationID resets all changes to the "organization_id" field.
  2834. func (m *CategoryMutation) ResetOrganizationID() {
  2835. m.organization_id = nil
  2836. m.addorganization_id = nil
  2837. }
  2838. // Where appends a list predicates to the CategoryMutation builder.
  2839. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  2840. m.predicates = append(m.predicates, ps...)
  2841. }
  2842. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  2843. // users can use type-assertion to append predicates that do not depend on any generated package.
  2844. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  2845. p := make([]predicate.Category, len(ps))
  2846. for i := range ps {
  2847. p[i] = ps[i]
  2848. }
  2849. m.Where(p...)
  2850. }
  2851. // Op returns the operation name.
  2852. func (m *CategoryMutation) Op() Op {
  2853. return m.op
  2854. }
  2855. // SetOp allows setting the mutation operation.
  2856. func (m *CategoryMutation) SetOp(op Op) {
  2857. m.op = op
  2858. }
  2859. // Type returns the node type of this mutation (Category).
  2860. func (m *CategoryMutation) Type() string {
  2861. return m.typ
  2862. }
  2863. // Fields returns all fields that were changed during this mutation. Note that in
  2864. // order to get all numeric fields that were incremented/decremented, call
  2865. // AddedFields().
  2866. func (m *CategoryMutation) Fields() []string {
  2867. fields := make([]string, 0, 5)
  2868. if m.created_at != nil {
  2869. fields = append(fields, category.FieldCreatedAt)
  2870. }
  2871. if m.updated_at != nil {
  2872. fields = append(fields, category.FieldUpdatedAt)
  2873. }
  2874. if m.deleted_at != nil {
  2875. fields = append(fields, category.FieldDeletedAt)
  2876. }
  2877. if m.name != nil {
  2878. fields = append(fields, category.FieldName)
  2879. }
  2880. if m.organization_id != nil {
  2881. fields = append(fields, category.FieldOrganizationID)
  2882. }
  2883. return fields
  2884. }
  2885. // Field returns the value of a field with the given name. The second boolean
  2886. // return value indicates that this field was not set, or was not defined in the
  2887. // schema.
  2888. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  2889. switch name {
  2890. case category.FieldCreatedAt:
  2891. return m.CreatedAt()
  2892. case category.FieldUpdatedAt:
  2893. return m.UpdatedAt()
  2894. case category.FieldDeletedAt:
  2895. return m.DeletedAt()
  2896. case category.FieldName:
  2897. return m.Name()
  2898. case category.FieldOrganizationID:
  2899. return m.OrganizationID()
  2900. }
  2901. return nil, false
  2902. }
  2903. // OldField returns the old value of the field from the database. An error is
  2904. // returned if the mutation operation is not UpdateOne, or the query to the
  2905. // database failed.
  2906. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2907. switch name {
  2908. case category.FieldCreatedAt:
  2909. return m.OldCreatedAt(ctx)
  2910. case category.FieldUpdatedAt:
  2911. return m.OldUpdatedAt(ctx)
  2912. case category.FieldDeletedAt:
  2913. return m.OldDeletedAt(ctx)
  2914. case category.FieldName:
  2915. return m.OldName(ctx)
  2916. case category.FieldOrganizationID:
  2917. return m.OldOrganizationID(ctx)
  2918. }
  2919. return nil, fmt.Errorf("unknown Category field %s", name)
  2920. }
  2921. // SetField sets the value of a field with the given name. It returns an error if
  2922. // the field is not defined in the schema, or if the type mismatched the field
  2923. // type.
  2924. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  2925. switch name {
  2926. case category.FieldCreatedAt:
  2927. v, ok := value.(time.Time)
  2928. if !ok {
  2929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2930. }
  2931. m.SetCreatedAt(v)
  2932. return nil
  2933. case category.FieldUpdatedAt:
  2934. v, ok := value.(time.Time)
  2935. if !ok {
  2936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2937. }
  2938. m.SetUpdatedAt(v)
  2939. return nil
  2940. case category.FieldDeletedAt:
  2941. v, ok := value.(time.Time)
  2942. if !ok {
  2943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2944. }
  2945. m.SetDeletedAt(v)
  2946. return nil
  2947. case category.FieldName:
  2948. v, ok := value.(string)
  2949. if !ok {
  2950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2951. }
  2952. m.SetName(v)
  2953. return nil
  2954. case category.FieldOrganizationID:
  2955. v, ok := value.(uint64)
  2956. if !ok {
  2957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2958. }
  2959. m.SetOrganizationID(v)
  2960. return nil
  2961. }
  2962. return fmt.Errorf("unknown Category field %s", name)
  2963. }
  2964. // AddedFields returns all numeric fields that were incremented/decremented during
  2965. // this mutation.
  2966. func (m *CategoryMutation) AddedFields() []string {
  2967. var fields []string
  2968. if m.addorganization_id != nil {
  2969. fields = append(fields, category.FieldOrganizationID)
  2970. }
  2971. return fields
  2972. }
  2973. // AddedField returns the numeric value that was incremented/decremented on a field
  2974. // with the given name. The second boolean return value indicates that this field
  2975. // was not set, or was not defined in the schema.
  2976. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  2977. switch name {
  2978. case category.FieldOrganizationID:
  2979. return m.AddedOrganizationID()
  2980. }
  2981. return nil, false
  2982. }
  2983. // AddField adds the value to the field with the given name. It returns an error if
  2984. // the field is not defined in the schema, or if the type mismatched the field
  2985. // type.
  2986. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  2987. switch name {
  2988. case category.FieldOrganizationID:
  2989. v, ok := value.(int64)
  2990. if !ok {
  2991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2992. }
  2993. m.AddOrganizationID(v)
  2994. return nil
  2995. }
  2996. return fmt.Errorf("unknown Category numeric field %s", name)
  2997. }
  2998. // ClearedFields returns all nullable fields that were cleared during this
  2999. // mutation.
  3000. func (m *CategoryMutation) ClearedFields() []string {
  3001. var fields []string
  3002. if m.FieldCleared(category.FieldDeletedAt) {
  3003. fields = append(fields, category.FieldDeletedAt)
  3004. }
  3005. return fields
  3006. }
  3007. // FieldCleared returns a boolean indicating if a field with the given name was
  3008. // cleared in this mutation.
  3009. func (m *CategoryMutation) FieldCleared(name string) bool {
  3010. _, ok := m.clearedFields[name]
  3011. return ok
  3012. }
  3013. // ClearField clears the value of the field with the given name. It returns an
  3014. // error if the field is not defined in the schema.
  3015. func (m *CategoryMutation) ClearField(name string) error {
  3016. switch name {
  3017. case category.FieldDeletedAt:
  3018. m.ClearDeletedAt()
  3019. return nil
  3020. }
  3021. return fmt.Errorf("unknown Category nullable field %s", name)
  3022. }
  3023. // ResetField resets all changes in the mutation for the field with the given name.
  3024. // It returns an error if the field is not defined in the schema.
  3025. func (m *CategoryMutation) ResetField(name string) error {
  3026. switch name {
  3027. case category.FieldCreatedAt:
  3028. m.ResetCreatedAt()
  3029. return nil
  3030. case category.FieldUpdatedAt:
  3031. m.ResetUpdatedAt()
  3032. return nil
  3033. case category.FieldDeletedAt:
  3034. m.ResetDeletedAt()
  3035. return nil
  3036. case category.FieldName:
  3037. m.ResetName()
  3038. return nil
  3039. case category.FieldOrganizationID:
  3040. m.ResetOrganizationID()
  3041. return nil
  3042. }
  3043. return fmt.Errorf("unknown Category field %s", name)
  3044. }
  3045. // AddedEdges returns all edge names that were set/added in this mutation.
  3046. func (m *CategoryMutation) AddedEdges() []string {
  3047. edges := make([]string, 0, 0)
  3048. return edges
  3049. }
  3050. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3051. // name in this mutation.
  3052. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  3053. return nil
  3054. }
  3055. // RemovedEdges returns all edge names that were removed in this mutation.
  3056. func (m *CategoryMutation) RemovedEdges() []string {
  3057. edges := make([]string, 0, 0)
  3058. return edges
  3059. }
  3060. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3061. // the given name in this mutation.
  3062. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  3063. return nil
  3064. }
  3065. // ClearedEdges returns all edge names that were cleared in this mutation.
  3066. func (m *CategoryMutation) ClearedEdges() []string {
  3067. edges := make([]string, 0, 0)
  3068. return edges
  3069. }
  3070. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3071. // was cleared in this mutation.
  3072. func (m *CategoryMutation) EdgeCleared(name string) bool {
  3073. return false
  3074. }
  3075. // ClearEdge clears the value of the edge with the given name. It returns an error
  3076. // if that edge is not defined in the schema.
  3077. func (m *CategoryMutation) ClearEdge(name string) error {
  3078. return fmt.Errorf("unknown Category unique edge %s", name)
  3079. }
  3080. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3081. // It returns an error if the edge is not defined in the schema.
  3082. func (m *CategoryMutation) ResetEdge(name string) error {
  3083. return fmt.Errorf("unknown Category edge %s", name)
  3084. }
  3085. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  3086. type ContactMutation struct {
  3087. config
  3088. op Op
  3089. typ string
  3090. id *uint64
  3091. created_at *time.Time
  3092. updated_at *time.Time
  3093. status *uint8
  3094. addstatus *int8
  3095. deleted_at *time.Time
  3096. wx_wxid *string
  3097. _type *int
  3098. add_type *int
  3099. wxid *string
  3100. account *string
  3101. nickname *string
  3102. markname *string
  3103. headimg *string
  3104. sex *int
  3105. addsex *int
  3106. starrole *string
  3107. dontseeit *int
  3108. adddontseeit *int
  3109. dontseeme *int
  3110. adddontseeme *int
  3111. lag *string
  3112. gid *string
  3113. gname *string
  3114. v3 *string
  3115. organization_id *uint64
  3116. addorganization_id *int64
  3117. clearedFields map[string]struct{}
  3118. contact_relationships map[uint64]struct{}
  3119. removedcontact_relationships map[uint64]struct{}
  3120. clearedcontact_relationships bool
  3121. contact_messages map[uint64]struct{}
  3122. removedcontact_messages map[uint64]struct{}
  3123. clearedcontact_messages bool
  3124. done bool
  3125. oldValue func(context.Context) (*Contact, error)
  3126. predicates []predicate.Contact
  3127. }
  3128. var _ ent.Mutation = (*ContactMutation)(nil)
  3129. // contactOption allows management of the mutation configuration using functional options.
  3130. type contactOption func(*ContactMutation)
  3131. // newContactMutation creates new mutation for the Contact entity.
  3132. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  3133. m := &ContactMutation{
  3134. config: c,
  3135. op: op,
  3136. typ: TypeContact,
  3137. clearedFields: make(map[string]struct{}),
  3138. }
  3139. for _, opt := range opts {
  3140. opt(m)
  3141. }
  3142. return m
  3143. }
  3144. // withContactID sets the ID field of the mutation.
  3145. func withContactID(id uint64) contactOption {
  3146. return func(m *ContactMutation) {
  3147. var (
  3148. err error
  3149. once sync.Once
  3150. value *Contact
  3151. )
  3152. m.oldValue = func(ctx context.Context) (*Contact, error) {
  3153. once.Do(func() {
  3154. if m.done {
  3155. err = errors.New("querying old values post mutation is not allowed")
  3156. } else {
  3157. value, err = m.Client().Contact.Get(ctx, id)
  3158. }
  3159. })
  3160. return value, err
  3161. }
  3162. m.id = &id
  3163. }
  3164. }
  3165. // withContact sets the old Contact of the mutation.
  3166. func withContact(node *Contact) contactOption {
  3167. return func(m *ContactMutation) {
  3168. m.oldValue = func(context.Context) (*Contact, error) {
  3169. return node, nil
  3170. }
  3171. m.id = &node.ID
  3172. }
  3173. }
  3174. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3175. // executed in a transaction (ent.Tx), a transactional client is returned.
  3176. func (m ContactMutation) Client() *Client {
  3177. client := &Client{config: m.config}
  3178. client.init()
  3179. return client
  3180. }
  3181. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3182. // it returns an error otherwise.
  3183. func (m ContactMutation) Tx() (*Tx, error) {
  3184. if _, ok := m.driver.(*txDriver); !ok {
  3185. return nil, errors.New("ent: mutation is not running in a transaction")
  3186. }
  3187. tx := &Tx{config: m.config}
  3188. tx.init()
  3189. return tx, nil
  3190. }
  3191. // SetID sets the value of the id field. Note that this
  3192. // operation is only accepted on creation of Contact entities.
  3193. func (m *ContactMutation) SetID(id uint64) {
  3194. m.id = &id
  3195. }
  3196. // ID returns the ID value in the mutation. Note that the ID is only available
  3197. // if it was provided to the builder or after it was returned from the database.
  3198. func (m *ContactMutation) ID() (id uint64, exists bool) {
  3199. if m.id == nil {
  3200. return
  3201. }
  3202. return *m.id, true
  3203. }
  3204. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3205. // That means, if the mutation is applied within a transaction with an isolation level such
  3206. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3207. // or updated by the mutation.
  3208. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  3209. switch {
  3210. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3211. id, exists := m.ID()
  3212. if exists {
  3213. return []uint64{id}, nil
  3214. }
  3215. fallthrough
  3216. case m.op.Is(OpUpdate | OpDelete):
  3217. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  3218. default:
  3219. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3220. }
  3221. }
  3222. // SetCreatedAt sets the "created_at" field.
  3223. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  3224. m.created_at = &t
  3225. }
  3226. // CreatedAt returns the value of the "created_at" field in the mutation.
  3227. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  3228. v := m.created_at
  3229. if v == nil {
  3230. return
  3231. }
  3232. return *v, true
  3233. }
  3234. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  3235. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3237. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3238. if !m.op.Is(OpUpdateOne) {
  3239. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3240. }
  3241. if m.id == nil || m.oldValue == nil {
  3242. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3243. }
  3244. oldValue, err := m.oldValue(ctx)
  3245. if err != nil {
  3246. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3247. }
  3248. return oldValue.CreatedAt, nil
  3249. }
  3250. // ResetCreatedAt resets all changes to the "created_at" field.
  3251. func (m *ContactMutation) ResetCreatedAt() {
  3252. m.created_at = nil
  3253. }
  3254. // SetUpdatedAt sets the "updated_at" field.
  3255. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  3256. m.updated_at = &t
  3257. }
  3258. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3259. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  3260. v := m.updated_at
  3261. if v == nil {
  3262. return
  3263. }
  3264. return *v, true
  3265. }
  3266. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  3267. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3269. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3270. if !m.op.Is(OpUpdateOne) {
  3271. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3272. }
  3273. if m.id == nil || m.oldValue == nil {
  3274. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3275. }
  3276. oldValue, err := m.oldValue(ctx)
  3277. if err != nil {
  3278. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3279. }
  3280. return oldValue.UpdatedAt, nil
  3281. }
  3282. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3283. func (m *ContactMutation) ResetUpdatedAt() {
  3284. m.updated_at = nil
  3285. }
  3286. // SetStatus sets the "status" field.
  3287. func (m *ContactMutation) SetStatus(u uint8) {
  3288. m.status = &u
  3289. m.addstatus = nil
  3290. }
  3291. // Status returns the value of the "status" field in the mutation.
  3292. func (m *ContactMutation) Status() (r uint8, exists bool) {
  3293. v := m.status
  3294. if v == nil {
  3295. return
  3296. }
  3297. return *v, true
  3298. }
  3299. // OldStatus returns the old "status" field's value of the Contact entity.
  3300. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3302. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  3303. if !m.op.Is(OpUpdateOne) {
  3304. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3305. }
  3306. if m.id == nil || m.oldValue == nil {
  3307. return v, errors.New("OldStatus requires an ID field in the mutation")
  3308. }
  3309. oldValue, err := m.oldValue(ctx)
  3310. if err != nil {
  3311. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3312. }
  3313. return oldValue.Status, nil
  3314. }
  3315. // AddStatus adds u to the "status" field.
  3316. func (m *ContactMutation) AddStatus(u int8) {
  3317. if m.addstatus != nil {
  3318. *m.addstatus += u
  3319. } else {
  3320. m.addstatus = &u
  3321. }
  3322. }
  3323. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3324. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  3325. v := m.addstatus
  3326. if v == nil {
  3327. return
  3328. }
  3329. return *v, true
  3330. }
  3331. // ClearStatus clears the value of the "status" field.
  3332. func (m *ContactMutation) ClearStatus() {
  3333. m.status = nil
  3334. m.addstatus = nil
  3335. m.clearedFields[contact.FieldStatus] = struct{}{}
  3336. }
  3337. // StatusCleared returns if the "status" field was cleared in this mutation.
  3338. func (m *ContactMutation) StatusCleared() bool {
  3339. _, ok := m.clearedFields[contact.FieldStatus]
  3340. return ok
  3341. }
  3342. // ResetStatus resets all changes to the "status" field.
  3343. func (m *ContactMutation) ResetStatus() {
  3344. m.status = nil
  3345. m.addstatus = nil
  3346. delete(m.clearedFields, contact.FieldStatus)
  3347. }
  3348. // SetDeletedAt sets the "deleted_at" field.
  3349. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  3350. m.deleted_at = &t
  3351. }
  3352. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3353. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  3354. v := m.deleted_at
  3355. if v == nil {
  3356. return
  3357. }
  3358. return *v, true
  3359. }
  3360. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  3361. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3363. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3364. if !m.op.Is(OpUpdateOne) {
  3365. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3366. }
  3367. if m.id == nil || m.oldValue == nil {
  3368. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3369. }
  3370. oldValue, err := m.oldValue(ctx)
  3371. if err != nil {
  3372. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3373. }
  3374. return oldValue.DeletedAt, nil
  3375. }
  3376. // ClearDeletedAt clears the value of the "deleted_at" field.
  3377. func (m *ContactMutation) ClearDeletedAt() {
  3378. m.deleted_at = nil
  3379. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  3380. }
  3381. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3382. func (m *ContactMutation) DeletedAtCleared() bool {
  3383. _, ok := m.clearedFields[contact.FieldDeletedAt]
  3384. return ok
  3385. }
  3386. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3387. func (m *ContactMutation) ResetDeletedAt() {
  3388. m.deleted_at = nil
  3389. delete(m.clearedFields, contact.FieldDeletedAt)
  3390. }
  3391. // SetWxWxid sets the "wx_wxid" field.
  3392. func (m *ContactMutation) SetWxWxid(s string) {
  3393. m.wx_wxid = &s
  3394. }
  3395. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  3396. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  3397. v := m.wx_wxid
  3398. if v == nil {
  3399. return
  3400. }
  3401. return *v, true
  3402. }
  3403. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  3404. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3406. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  3407. if !m.op.Is(OpUpdateOne) {
  3408. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  3409. }
  3410. if m.id == nil || m.oldValue == nil {
  3411. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  3412. }
  3413. oldValue, err := m.oldValue(ctx)
  3414. if err != nil {
  3415. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  3416. }
  3417. return oldValue.WxWxid, nil
  3418. }
  3419. // ClearWxWxid clears the value of the "wx_wxid" field.
  3420. func (m *ContactMutation) ClearWxWxid() {
  3421. m.wx_wxid = nil
  3422. m.clearedFields[contact.FieldWxWxid] = struct{}{}
  3423. }
  3424. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  3425. func (m *ContactMutation) WxWxidCleared() bool {
  3426. _, ok := m.clearedFields[contact.FieldWxWxid]
  3427. return ok
  3428. }
  3429. // ResetWxWxid resets all changes to the "wx_wxid" field.
  3430. func (m *ContactMutation) ResetWxWxid() {
  3431. m.wx_wxid = nil
  3432. delete(m.clearedFields, contact.FieldWxWxid)
  3433. }
  3434. // SetType sets the "type" field.
  3435. func (m *ContactMutation) SetType(i int) {
  3436. m._type = &i
  3437. m.add_type = nil
  3438. }
  3439. // GetType returns the value of the "type" field in the mutation.
  3440. func (m *ContactMutation) GetType() (r int, exists bool) {
  3441. v := m._type
  3442. if v == nil {
  3443. return
  3444. }
  3445. return *v, true
  3446. }
  3447. // OldType returns the old "type" field's value of the Contact entity.
  3448. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3450. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  3451. if !m.op.Is(OpUpdateOne) {
  3452. return v, errors.New("OldType is only allowed on UpdateOne operations")
  3453. }
  3454. if m.id == nil || m.oldValue == nil {
  3455. return v, errors.New("OldType requires an ID field in the mutation")
  3456. }
  3457. oldValue, err := m.oldValue(ctx)
  3458. if err != nil {
  3459. return v, fmt.Errorf("querying old value for OldType: %w", err)
  3460. }
  3461. return oldValue.Type, nil
  3462. }
  3463. // AddType adds i to the "type" field.
  3464. func (m *ContactMutation) AddType(i int) {
  3465. if m.add_type != nil {
  3466. *m.add_type += i
  3467. } else {
  3468. m.add_type = &i
  3469. }
  3470. }
  3471. // AddedType returns the value that was added to the "type" field in this mutation.
  3472. func (m *ContactMutation) AddedType() (r int, exists bool) {
  3473. v := m.add_type
  3474. if v == nil {
  3475. return
  3476. }
  3477. return *v, true
  3478. }
  3479. // ClearType clears the value of the "type" field.
  3480. func (m *ContactMutation) ClearType() {
  3481. m._type = nil
  3482. m.add_type = nil
  3483. m.clearedFields[contact.FieldType] = struct{}{}
  3484. }
  3485. // TypeCleared returns if the "type" field was cleared in this mutation.
  3486. func (m *ContactMutation) TypeCleared() bool {
  3487. _, ok := m.clearedFields[contact.FieldType]
  3488. return ok
  3489. }
  3490. // ResetType resets all changes to the "type" field.
  3491. func (m *ContactMutation) ResetType() {
  3492. m._type = nil
  3493. m.add_type = nil
  3494. delete(m.clearedFields, contact.FieldType)
  3495. }
  3496. // SetWxid sets the "wxid" field.
  3497. func (m *ContactMutation) SetWxid(s string) {
  3498. m.wxid = &s
  3499. }
  3500. // Wxid returns the value of the "wxid" field in the mutation.
  3501. func (m *ContactMutation) Wxid() (r string, exists bool) {
  3502. v := m.wxid
  3503. if v == nil {
  3504. return
  3505. }
  3506. return *v, true
  3507. }
  3508. // OldWxid returns the old "wxid" field's value of the Contact entity.
  3509. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3511. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  3512. if !m.op.Is(OpUpdateOne) {
  3513. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  3514. }
  3515. if m.id == nil || m.oldValue == nil {
  3516. return v, errors.New("OldWxid requires an ID field in the mutation")
  3517. }
  3518. oldValue, err := m.oldValue(ctx)
  3519. if err != nil {
  3520. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  3521. }
  3522. return oldValue.Wxid, nil
  3523. }
  3524. // ResetWxid resets all changes to the "wxid" field.
  3525. func (m *ContactMutation) ResetWxid() {
  3526. m.wxid = nil
  3527. }
  3528. // SetAccount sets the "account" field.
  3529. func (m *ContactMutation) SetAccount(s string) {
  3530. m.account = &s
  3531. }
  3532. // Account returns the value of the "account" field in the mutation.
  3533. func (m *ContactMutation) Account() (r string, exists bool) {
  3534. v := m.account
  3535. if v == nil {
  3536. return
  3537. }
  3538. return *v, true
  3539. }
  3540. // OldAccount returns the old "account" field's value of the Contact entity.
  3541. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3543. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  3544. if !m.op.Is(OpUpdateOne) {
  3545. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  3546. }
  3547. if m.id == nil || m.oldValue == nil {
  3548. return v, errors.New("OldAccount requires an ID field in the mutation")
  3549. }
  3550. oldValue, err := m.oldValue(ctx)
  3551. if err != nil {
  3552. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  3553. }
  3554. return oldValue.Account, nil
  3555. }
  3556. // ResetAccount resets all changes to the "account" field.
  3557. func (m *ContactMutation) ResetAccount() {
  3558. m.account = nil
  3559. }
  3560. // SetNickname sets the "nickname" field.
  3561. func (m *ContactMutation) SetNickname(s string) {
  3562. m.nickname = &s
  3563. }
  3564. // Nickname returns the value of the "nickname" field in the mutation.
  3565. func (m *ContactMutation) Nickname() (r string, exists bool) {
  3566. v := m.nickname
  3567. if v == nil {
  3568. return
  3569. }
  3570. return *v, true
  3571. }
  3572. // OldNickname returns the old "nickname" field's value of the Contact entity.
  3573. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3574. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3575. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  3576. if !m.op.Is(OpUpdateOne) {
  3577. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  3578. }
  3579. if m.id == nil || m.oldValue == nil {
  3580. return v, errors.New("OldNickname requires an ID field in the mutation")
  3581. }
  3582. oldValue, err := m.oldValue(ctx)
  3583. if err != nil {
  3584. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  3585. }
  3586. return oldValue.Nickname, nil
  3587. }
  3588. // ResetNickname resets all changes to the "nickname" field.
  3589. func (m *ContactMutation) ResetNickname() {
  3590. m.nickname = nil
  3591. }
  3592. // SetMarkname sets the "markname" field.
  3593. func (m *ContactMutation) SetMarkname(s string) {
  3594. m.markname = &s
  3595. }
  3596. // Markname returns the value of the "markname" field in the mutation.
  3597. func (m *ContactMutation) Markname() (r string, exists bool) {
  3598. v := m.markname
  3599. if v == nil {
  3600. return
  3601. }
  3602. return *v, true
  3603. }
  3604. // OldMarkname returns the old "markname" field's value of the Contact entity.
  3605. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3607. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  3608. if !m.op.Is(OpUpdateOne) {
  3609. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  3610. }
  3611. if m.id == nil || m.oldValue == nil {
  3612. return v, errors.New("OldMarkname requires an ID field in the mutation")
  3613. }
  3614. oldValue, err := m.oldValue(ctx)
  3615. if err != nil {
  3616. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  3617. }
  3618. return oldValue.Markname, nil
  3619. }
  3620. // ResetMarkname resets all changes to the "markname" field.
  3621. func (m *ContactMutation) ResetMarkname() {
  3622. m.markname = nil
  3623. }
  3624. // SetHeadimg sets the "headimg" field.
  3625. func (m *ContactMutation) SetHeadimg(s string) {
  3626. m.headimg = &s
  3627. }
  3628. // Headimg returns the value of the "headimg" field in the mutation.
  3629. func (m *ContactMutation) Headimg() (r string, exists bool) {
  3630. v := m.headimg
  3631. if v == nil {
  3632. return
  3633. }
  3634. return *v, true
  3635. }
  3636. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  3637. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3639. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  3640. if !m.op.Is(OpUpdateOne) {
  3641. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  3642. }
  3643. if m.id == nil || m.oldValue == nil {
  3644. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  3645. }
  3646. oldValue, err := m.oldValue(ctx)
  3647. if err != nil {
  3648. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  3649. }
  3650. return oldValue.Headimg, nil
  3651. }
  3652. // ResetHeadimg resets all changes to the "headimg" field.
  3653. func (m *ContactMutation) ResetHeadimg() {
  3654. m.headimg = nil
  3655. }
  3656. // SetSex sets the "sex" field.
  3657. func (m *ContactMutation) SetSex(i int) {
  3658. m.sex = &i
  3659. m.addsex = nil
  3660. }
  3661. // Sex returns the value of the "sex" field in the mutation.
  3662. func (m *ContactMutation) Sex() (r int, exists bool) {
  3663. v := m.sex
  3664. if v == nil {
  3665. return
  3666. }
  3667. return *v, true
  3668. }
  3669. // OldSex returns the old "sex" field's value of the Contact entity.
  3670. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3672. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  3673. if !m.op.Is(OpUpdateOne) {
  3674. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  3675. }
  3676. if m.id == nil || m.oldValue == nil {
  3677. return v, errors.New("OldSex requires an ID field in the mutation")
  3678. }
  3679. oldValue, err := m.oldValue(ctx)
  3680. if err != nil {
  3681. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  3682. }
  3683. return oldValue.Sex, nil
  3684. }
  3685. // AddSex adds i to the "sex" field.
  3686. func (m *ContactMutation) AddSex(i int) {
  3687. if m.addsex != nil {
  3688. *m.addsex += i
  3689. } else {
  3690. m.addsex = &i
  3691. }
  3692. }
  3693. // AddedSex returns the value that was added to the "sex" field in this mutation.
  3694. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  3695. v := m.addsex
  3696. if v == nil {
  3697. return
  3698. }
  3699. return *v, true
  3700. }
  3701. // ResetSex resets all changes to the "sex" field.
  3702. func (m *ContactMutation) ResetSex() {
  3703. m.sex = nil
  3704. m.addsex = nil
  3705. }
  3706. // SetStarrole sets the "starrole" field.
  3707. func (m *ContactMutation) SetStarrole(s string) {
  3708. m.starrole = &s
  3709. }
  3710. // Starrole returns the value of the "starrole" field in the mutation.
  3711. func (m *ContactMutation) Starrole() (r string, exists bool) {
  3712. v := m.starrole
  3713. if v == nil {
  3714. return
  3715. }
  3716. return *v, true
  3717. }
  3718. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  3719. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3721. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  3722. if !m.op.Is(OpUpdateOne) {
  3723. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  3724. }
  3725. if m.id == nil || m.oldValue == nil {
  3726. return v, errors.New("OldStarrole requires an ID field in the mutation")
  3727. }
  3728. oldValue, err := m.oldValue(ctx)
  3729. if err != nil {
  3730. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  3731. }
  3732. return oldValue.Starrole, nil
  3733. }
  3734. // ResetStarrole resets all changes to the "starrole" field.
  3735. func (m *ContactMutation) ResetStarrole() {
  3736. m.starrole = nil
  3737. }
  3738. // SetDontseeit sets the "dontseeit" field.
  3739. func (m *ContactMutation) SetDontseeit(i int) {
  3740. m.dontseeit = &i
  3741. m.adddontseeit = nil
  3742. }
  3743. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  3744. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  3745. v := m.dontseeit
  3746. if v == nil {
  3747. return
  3748. }
  3749. return *v, true
  3750. }
  3751. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  3752. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3754. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  3755. if !m.op.Is(OpUpdateOne) {
  3756. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  3757. }
  3758. if m.id == nil || m.oldValue == nil {
  3759. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  3760. }
  3761. oldValue, err := m.oldValue(ctx)
  3762. if err != nil {
  3763. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  3764. }
  3765. return oldValue.Dontseeit, nil
  3766. }
  3767. // AddDontseeit adds i to the "dontseeit" field.
  3768. func (m *ContactMutation) AddDontseeit(i int) {
  3769. if m.adddontseeit != nil {
  3770. *m.adddontseeit += i
  3771. } else {
  3772. m.adddontseeit = &i
  3773. }
  3774. }
  3775. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  3776. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  3777. v := m.adddontseeit
  3778. if v == nil {
  3779. return
  3780. }
  3781. return *v, true
  3782. }
  3783. // ResetDontseeit resets all changes to the "dontseeit" field.
  3784. func (m *ContactMutation) ResetDontseeit() {
  3785. m.dontseeit = nil
  3786. m.adddontseeit = nil
  3787. }
  3788. // SetDontseeme sets the "dontseeme" field.
  3789. func (m *ContactMutation) SetDontseeme(i int) {
  3790. m.dontseeme = &i
  3791. m.adddontseeme = nil
  3792. }
  3793. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  3794. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  3795. v := m.dontseeme
  3796. if v == nil {
  3797. return
  3798. }
  3799. return *v, true
  3800. }
  3801. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  3802. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3803. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3804. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  3805. if !m.op.Is(OpUpdateOne) {
  3806. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  3807. }
  3808. if m.id == nil || m.oldValue == nil {
  3809. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  3810. }
  3811. oldValue, err := m.oldValue(ctx)
  3812. if err != nil {
  3813. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  3814. }
  3815. return oldValue.Dontseeme, nil
  3816. }
  3817. // AddDontseeme adds i to the "dontseeme" field.
  3818. func (m *ContactMutation) AddDontseeme(i int) {
  3819. if m.adddontseeme != nil {
  3820. *m.adddontseeme += i
  3821. } else {
  3822. m.adddontseeme = &i
  3823. }
  3824. }
  3825. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  3826. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  3827. v := m.adddontseeme
  3828. if v == nil {
  3829. return
  3830. }
  3831. return *v, true
  3832. }
  3833. // ResetDontseeme resets all changes to the "dontseeme" field.
  3834. func (m *ContactMutation) ResetDontseeme() {
  3835. m.dontseeme = nil
  3836. m.adddontseeme = nil
  3837. }
  3838. // SetLag sets the "lag" field.
  3839. func (m *ContactMutation) SetLag(s string) {
  3840. m.lag = &s
  3841. }
  3842. // Lag returns the value of the "lag" field in the mutation.
  3843. func (m *ContactMutation) Lag() (r string, exists bool) {
  3844. v := m.lag
  3845. if v == nil {
  3846. return
  3847. }
  3848. return *v, true
  3849. }
  3850. // OldLag returns the old "lag" field's value of the Contact entity.
  3851. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3853. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  3854. if !m.op.Is(OpUpdateOne) {
  3855. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  3856. }
  3857. if m.id == nil || m.oldValue == nil {
  3858. return v, errors.New("OldLag requires an ID field in the mutation")
  3859. }
  3860. oldValue, err := m.oldValue(ctx)
  3861. if err != nil {
  3862. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  3863. }
  3864. return oldValue.Lag, nil
  3865. }
  3866. // ResetLag resets all changes to the "lag" field.
  3867. func (m *ContactMutation) ResetLag() {
  3868. m.lag = nil
  3869. }
  3870. // SetGid sets the "gid" field.
  3871. func (m *ContactMutation) SetGid(s string) {
  3872. m.gid = &s
  3873. }
  3874. // Gid returns the value of the "gid" field in the mutation.
  3875. func (m *ContactMutation) Gid() (r string, exists bool) {
  3876. v := m.gid
  3877. if v == nil {
  3878. return
  3879. }
  3880. return *v, true
  3881. }
  3882. // OldGid returns the old "gid" field's value of the Contact entity.
  3883. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3884. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3885. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  3886. if !m.op.Is(OpUpdateOne) {
  3887. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  3888. }
  3889. if m.id == nil || m.oldValue == nil {
  3890. return v, errors.New("OldGid requires an ID field in the mutation")
  3891. }
  3892. oldValue, err := m.oldValue(ctx)
  3893. if err != nil {
  3894. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  3895. }
  3896. return oldValue.Gid, nil
  3897. }
  3898. // ResetGid resets all changes to the "gid" field.
  3899. func (m *ContactMutation) ResetGid() {
  3900. m.gid = nil
  3901. }
  3902. // SetGname sets the "gname" field.
  3903. func (m *ContactMutation) SetGname(s string) {
  3904. m.gname = &s
  3905. }
  3906. // Gname returns the value of the "gname" field in the mutation.
  3907. func (m *ContactMutation) Gname() (r string, exists bool) {
  3908. v := m.gname
  3909. if v == nil {
  3910. return
  3911. }
  3912. return *v, true
  3913. }
  3914. // OldGname returns the old "gname" field's value of the Contact entity.
  3915. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3917. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  3918. if !m.op.Is(OpUpdateOne) {
  3919. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  3920. }
  3921. if m.id == nil || m.oldValue == nil {
  3922. return v, errors.New("OldGname requires an ID field in the mutation")
  3923. }
  3924. oldValue, err := m.oldValue(ctx)
  3925. if err != nil {
  3926. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  3927. }
  3928. return oldValue.Gname, nil
  3929. }
  3930. // ResetGname resets all changes to the "gname" field.
  3931. func (m *ContactMutation) ResetGname() {
  3932. m.gname = nil
  3933. }
  3934. // SetV3 sets the "v3" field.
  3935. func (m *ContactMutation) SetV3(s string) {
  3936. m.v3 = &s
  3937. }
  3938. // V3 returns the value of the "v3" field in the mutation.
  3939. func (m *ContactMutation) V3() (r string, exists bool) {
  3940. v := m.v3
  3941. if v == nil {
  3942. return
  3943. }
  3944. return *v, true
  3945. }
  3946. // OldV3 returns the old "v3" field's value of the Contact entity.
  3947. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3949. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  3950. if !m.op.Is(OpUpdateOne) {
  3951. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  3952. }
  3953. if m.id == nil || m.oldValue == nil {
  3954. return v, errors.New("OldV3 requires an ID field in the mutation")
  3955. }
  3956. oldValue, err := m.oldValue(ctx)
  3957. if err != nil {
  3958. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  3959. }
  3960. return oldValue.V3, nil
  3961. }
  3962. // ResetV3 resets all changes to the "v3" field.
  3963. func (m *ContactMutation) ResetV3() {
  3964. m.v3 = nil
  3965. }
  3966. // SetOrganizationID sets the "organization_id" field.
  3967. func (m *ContactMutation) SetOrganizationID(u uint64) {
  3968. m.organization_id = &u
  3969. m.addorganization_id = nil
  3970. }
  3971. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3972. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  3973. v := m.organization_id
  3974. if v == nil {
  3975. return
  3976. }
  3977. return *v, true
  3978. }
  3979. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  3980. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3981. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3982. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3983. if !m.op.Is(OpUpdateOne) {
  3984. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3985. }
  3986. if m.id == nil || m.oldValue == nil {
  3987. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3988. }
  3989. oldValue, err := m.oldValue(ctx)
  3990. if err != nil {
  3991. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3992. }
  3993. return oldValue.OrganizationID, nil
  3994. }
  3995. // AddOrganizationID adds u to the "organization_id" field.
  3996. func (m *ContactMutation) AddOrganizationID(u int64) {
  3997. if m.addorganization_id != nil {
  3998. *m.addorganization_id += u
  3999. } else {
  4000. m.addorganization_id = &u
  4001. }
  4002. }
  4003. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4004. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  4005. v := m.addorganization_id
  4006. if v == nil {
  4007. return
  4008. }
  4009. return *v, true
  4010. }
  4011. // ClearOrganizationID clears the value of the "organization_id" field.
  4012. func (m *ContactMutation) ClearOrganizationID() {
  4013. m.organization_id = nil
  4014. m.addorganization_id = nil
  4015. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  4016. }
  4017. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  4018. func (m *ContactMutation) OrganizationIDCleared() bool {
  4019. _, ok := m.clearedFields[contact.FieldOrganizationID]
  4020. return ok
  4021. }
  4022. // ResetOrganizationID resets all changes to the "organization_id" field.
  4023. func (m *ContactMutation) ResetOrganizationID() {
  4024. m.organization_id = nil
  4025. m.addorganization_id = nil
  4026. delete(m.clearedFields, contact.FieldOrganizationID)
  4027. }
  4028. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  4029. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  4030. if m.contact_relationships == nil {
  4031. m.contact_relationships = make(map[uint64]struct{})
  4032. }
  4033. for i := range ids {
  4034. m.contact_relationships[ids[i]] = struct{}{}
  4035. }
  4036. }
  4037. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  4038. func (m *ContactMutation) ClearContactRelationships() {
  4039. m.clearedcontact_relationships = true
  4040. }
  4041. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  4042. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  4043. return m.clearedcontact_relationships
  4044. }
  4045. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  4046. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  4047. if m.removedcontact_relationships == nil {
  4048. m.removedcontact_relationships = make(map[uint64]struct{})
  4049. }
  4050. for i := range ids {
  4051. delete(m.contact_relationships, ids[i])
  4052. m.removedcontact_relationships[ids[i]] = struct{}{}
  4053. }
  4054. }
  4055. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  4056. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  4057. for id := range m.removedcontact_relationships {
  4058. ids = append(ids, id)
  4059. }
  4060. return
  4061. }
  4062. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  4063. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  4064. for id := range m.contact_relationships {
  4065. ids = append(ids, id)
  4066. }
  4067. return
  4068. }
  4069. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  4070. func (m *ContactMutation) ResetContactRelationships() {
  4071. m.contact_relationships = nil
  4072. m.clearedcontact_relationships = false
  4073. m.removedcontact_relationships = nil
  4074. }
  4075. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  4076. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  4077. if m.contact_messages == nil {
  4078. m.contact_messages = make(map[uint64]struct{})
  4079. }
  4080. for i := range ids {
  4081. m.contact_messages[ids[i]] = struct{}{}
  4082. }
  4083. }
  4084. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  4085. func (m *ContactMutation) ClearContactMessages() {
  4086. m.clearedcontact_messages = true
  4087. }
  4088. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  4089. func (m *ContactMutation) ContactMessagesCleared() bool {
  4090. return m.clearedcontact_messages
  4091. }
  4092. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  4093. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  4094. if m.removedcontact_messages == nil {
  4095. m.removedcontact_messages = make(map[uint64]struct{})
  4096. }
  4097. for i := range ids {
  4098. delete(m.contact_messages, ids[i])
  4099. m.removedcontact_messages[ids[i]] = struct{}{}
  4100. }
  4101. }
  4102. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  4103. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  4104. for id := range m.removedcontact_messages {
  4105. ids = append(ids, id)
  4106. }
  4107. return
  4108. }
  4109. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  4110. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  4111. for id := range m.contact_messages {
  4112. ids = append(ids, id)
  4113. }
  4114. return
  4115. }
  4116. // ResetContactMessages resets all changes to the "contact_messages" edge.
  4117. func (m *ContactMutation) ResetContactMessages() {
  4118. m.contact_messages = nil
  4119. m.clearedcontact_messages = false
  4120. m.removedcontact_messages = nil
  4121. }
  4122. // Where appends a list predicates to the ContactMutation builder.
  4123. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  4124. m.predicates = append(m.predicates, ps...)
  4125. }
  4126. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  4127. // users can use type-assertion to append predicates that do not depend on any generated package.
  4128. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  4129. p := make([]predicate.Contact, len(ps))
  4130. for i := range ps {
  4131. p[i] = ps[i]
  4132. }
  4133. m.Where(p...)
  4134. }
  4135. // Op returns the operation name.
  4136. func (m *ContactMutation) Op() Op {
  4137. return m.op
  4138. }
  4139. // SetOp allows setting the mutation operation.
  4140. func (m *ContactMutation) SetOp(op Op) {
  4141. m.op = op
  4142. }
  4143. // Type returns the node type of this mutation (Contact).
  4144. func (m *ContactMutation) Type() string {
  4145. return m.typ
  4146. }
  4147. // Fields returns all fields that were changed during this mutation. Note that in
  4148. // order to get all numeric fields that were incremented/decremented, call
  4149. // AddedFields().
  4150. func (m *ContactMutation) Fields() []string {
  4151. fields := make([]string, 0, 20)
  4152. if m.created_at != nil {
  4153. fields = append(fields, contact.FieldCreatedAt)
  4154. }
  4155. if m.updated_at != nil {
  4156. fields = append(fields, contact.FieldUpdatedAt)
  4157. }
  4158. if m.status != nil {
  4159. fields = append(fields, contact.FieldStatus)
  4160. }
  4161. if m.deleted_at != nil {
  4162. fields = append(fields, contact.FieldDeletedAt)
  4163. }
  4164. if m.wx_wxid != nil {
  4165. fields = append(fields, contact.FieldWxWxid)
  4166. }
  4167. if m._type != nil {
  4168. fields = append(fields, contact.FieldType)
  4169. }
  4170. if m.wxid != nil {
  4171. fields = append(fields, contact.FieldWxid)
  4172. }
  4173. if m.account != nil {
  4174. fields = append(fields, contact.FieldAccount)
  4175. }
  4176. if m.nickname != nil {
  4177. fields = append(fields, contact.FieldNickname)
  4178. }
  4179. if m.markname != nil {
  4180. fields = append(fields, contact.FieldMarkname)
  4181. }
  4182. if m.headimg != nil {
  4183. fields = append(fields, contact.FieldHeadimg)
  4184. }
  4185. if m.sex != nil {
  4186. fields = append(fields, contact.FieldSex)
  4187. }
  4188. if m.starrole != nil {
  4189. fields = append(fields, contact.FieldStarrole)
  4190. }
  4191. if m.dontseeit != nil {
  4192. fields = append(fields, contact.FieldDontseeit)
  4193. }
  4194. if m.dontseeme != nil {
  4195. fields = append(fields, contact.FieldDontseeme)
  4196. }
  4197. if m.lag != nil {
  4198. fields = append(fields, contact.FieldLag)
  4199. }
  4200. if m.gid != nil {
  4201. fields = append(fields, contact.FieldGid)
  4202. }
  4203. if m.gname != nil {
  4204. fields = append(fields, contact.FieldGname)
  4205. }
  4206. if m.v3 != nil {
  4207. fields = append(fields, contact.FieldV3)
  4208. }
  4209. if m.organization_id != nil {
  4210. fields = append(fields, contact.FieldOrganizationID)
  4211. }
  4212. return fields
  4213. }
  4214. // Field returns the value of a field with the given name. The second boolean
  4215. // return value indicates that this field was not set, or was not defined in the
  4216. // schema.
  4217. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  4218. switch name {
  4219. case contact.FieldCreatedAt:
  4220. return m.CreatedAt()
  4221. case contact.FieldUpdatedAt:
  4222. return m.UpdatedAt()
  4223. case contact.FieldStatus:
  4224. return m.Status()
  4225. case contact.FieldDeletedAt:
  4226. return m.DeletedAt()
  4227. case contact.FieldWxWxid:
  4228. return m.WxWxid()
  4229. case contact.FieldType:
  4230. return m.GetType()
  4231. case contact.FieldWxid:
  4232. return m.Wxid()
  4233. case contact.FieldAccount:
  4234. return m.Account()
  4235. case contact.FieldNickname:
  4236. return m.Nickname()
  4237. case contact.FieldMarkname:
  4238. return m.Markname()
  4239. case contact.FieldHeadimg:
  4240. return m.Headimg()
  4241. case contact.FieldSex:
  4242. return m.Sex()
  4243. case contact.FieldStarrole:
  4244. return m.Starrole()
  4245. case contact.FieldDontseeit:
  4246. return m.Dontseeit()
  4247. case contact.FieldDontseeme:
  4248. return m.Dontseeme()
  4249. case contact.FieldLag:
  4250. return m.Lag()
  4251. case contact.FieldGid:
  4252. return m.Gid()
  4253. case contact.FieldGname:
  4254. return m.Gname()
  4255. case contact.FieldV3:
  4256. return m.V3()
  4257. case contact.FieldOrganizationID:
  4258. return m.OrganizationID()
  4259. }
  4260. return nil, false
  4261. }
  4262. // OldField returns the old value of the field from the database. An error is
  4263. // returned if the mutation operation is not UpdateOne, or the query to the
  4264. // database failed.
  4265. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4266. switch name {
  4267. case contact.FieldCreatedAt:
  4268. return m.OldCreatedAt(ctx)
  4269. case contact.FieldUpdatedAt:
  4270. return m.OldUpdatedAt(ctx)
  4271. case contact.FieldStatus:
  4272. return m.OldStatus(ctx)
  4273. case contact.FieldDeletedAt:
  4274. return m.OldDeletedAt(ctx)
  4275. case contact.FieldWxWxid:
  4276. return m.OldWxWxid(ctx)
  4277. case contact.FieldType:
  4278. return m.OldType(ctx)
  4279. case contact.FieldWxid:
  4280. return m.OldWxid(ctx)
  4281. case contact.FieldAccount:
  4282. return m.OldAccount(ctx)
  4283. case contact.FieldNickname:
  4284. return m.OldNickname(ctx)
  4285. case contact.FieldMarkname:
  4286. return m.OldMarkname(ctx)
  4287. case contact.FieldHeadimg:
  4288. return m.OldHeadimg(ctx)
  4289. case contact.FieldSex:
  4290. return m.OldSex(ctx)
  4291. case contact.FieldStarrole:
  4292. return m.OldStarrole(ctx)
  4293. case contact.FieldDontseeit:
  4294. return m.OldDontseeit(ctx)
  4295. case contact.FieldDontseeme:
  4296. return m.OldDontseeme(ctx)
  4297. case contact.FieldLag:
  4298. return m.OldLag(ctx)
  4299. case contact.FieldGid:
  4300. return m.OldGid(ctx)
  4301. case contact.FieldGname:
  4302. return m.OldGname(ctx)
  4303. case contact.FieldV3:
  4304. return m.OldV3(ctx)
  4305. case contact.FieldOrganizationID:
  4306. return m.OldOrganizationID(ctx)
  4307. }
  4308. return nil, fmt.Errorf("unknown Contact field %s", name)
  4309. }
  4310. // SetField sets the value of a field with the given name. It returns an error if
  4311. // the field is not defined in the schema, or if the type mismatched the field
  4312. // type.
  4313. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  4314. switch name {
  4315. case contact.FieldCreatedAt:
  4316. v, ok := value.(time.Time)
  4317. if !ok {
  4318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4319. }
  4320. m.SetCreatedAt(v)
  4321. return nil
  4322. case contact.FieldUpdatedAt:
  4323. v, ok := value.(time.Time)
  4324. if !ok {
  4325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4326. }
  4327. m.SetUpdatedAt(v)
  4328. return nil
  4329. case contact.FieldStatus:
  4330. v, ok := value.(uint8)
  4331. if !ok {
  4332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4333. }
  4334. m.SetStatus(v)
  4335. return nil
  4336. case contact.FieldDeletedAt:
  4337. v, ok := value.(time.Time)
  4338. if !ok {
  4339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4340. }
  4341. m.SetDeletedAt(v)
  4342. return nil
  4343. case contact.FieldWxWxid:
  4344. v, ok := value.(string)
  4345. if !ok {
  4346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4347. }
  4348. m.SetWxWxid(v)
  4349. return nil
  4350. case contact.FieldType:
  4351. v, ok := value.(int)
  4352. if !ok {
  4353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4354. }
  4355. m.SetType(v)
  4356. return nil
  4357. case contact.FieldWxid:
  4358. v, ok := value.(string)
  4359. if !ok {
  4360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4361. }
  4362. m.SetWxid(v)
  4363. return nil
  4364. case contact.FieldAccount:
  4365. v, ok := value.(string)
  4366. if !ok {
  4367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4368. }
  4369. m.SetAccount(v)
  4370. return nil
  4371. case contact.FieldNickname:
  4372. v, ok := value.(string)
  4373. if !ok {
  4374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4375. }
  4376. m.SetNickname(v)
  4377. return nil
  4378. case contact.FieldMarkname:
  4379. v, ok := value.(string)
  4380. if !ok {
  4381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4382. }
  4383. m.SetMarkname(v)
  4384. return nil
  4385. case contact.FieldHeadimg:
  4386. v, ok := value.(string)
  4387. if !ok {
  4388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4389. }
  4390. m.SetHeadimg(v)
  4391. return nil
  4392. case contact.FieldSex:
  4393. v, ok := value.(int)
  4394. if !ok {
  4395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4396. }
  4397. m.SetSex(v)
  4398. return nil
  4399. case contact.FieldStarrole:
  4400. v, ok := value.(string)
  4401. if !ok {
  4402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4403. }
  4404. m.SetStarrole(v)
  4405. return nil
  4406. case contact.FieldDontseeit:
  4407. v, ok := value.(int)
  4408. if !ok {
  4409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4410. }
  4411. m.SetDontseeit(v)
  4412. return nil
  4413. case contact.FieldDontseeme:
  4414. v, ok := value.(int)
  4415. if !ok {
  4416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4417. }
  4418. m.SetDontseeme(v)
  4419. return nil
  4420. case contact.FieldLag:
  4421. v, ok := value.(string)
  4422. if !ok {
  4423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4424. }
  4425. m.SetLag(v)
  4426. return nil
  4427. case contact.FieldGid:
  4428. v, ok := value.(string)
  4429. if !ok {
  4430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4431. }
  4432. m.SetGid(v)
  4433. return nil
  4434. case contact.FieldGname:
  4435. v, ok := value.(string)
  4436. if !ok {
  4437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4438. }
  4439. m.SetGname(v)
  4440. return nil
  4441. case contact.FieldV3:
  4442. v, ok := value.(string)
  4443. if !ok {
  4444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4445. }
  4446. m.SetV3(v)
  4447. return nil
  4448. case contact.FieldOrganizationID:
  4449. v, ok := value.(uint64)
  4450. if !ok {
  4451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4452. }
  4453. m.SetOrganizationID(v)
  4454. return nil
  4455. }
  4456. return fmt.Errorf("unknown Contact field %s", name)
  4457. }
  4458. // AddedFields returns all numeric fields that were incremented/decremented during
  4459. // this mutation.
  4460. func (m *ContactMutation) AddedFields() []string {
  4461. var fields []string
  4462. if m.addstatus != nil {
  4463. fields = append(fields, contact.FieldStatus)
  4464. }
  4465. if m.add_type != nil {
  4466. fields = append(fields, contact.FieldType)
  4467. }
  4468. if m.addsex != nil {
  4469. fields = append(fields, contact.FieldSex)
  4470. }
  4471. if m.adddontseeit != nil {
  4472. fields = append(fields, contact.FieldDontseeit)
  4473. }
  4474. if m.adddontseeme != nil {
  4475. fields = append(fields, contact.FieldDontseeme)
  4476. }
  4477. if m.addorganization_id != nil {
  4478. fields = append(fields, contact.FieldOrganizationID)
  4479. }
  4480. return fields
  4481. }
  4482. // AddedField returns the numeric value that was incremented/decremented on a field
  4483. // with the given name. The second boolean return value indicates that this field
  4484. // was not set, or was not defined in the schema.
  4485. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  4486. switch name {
  4487. case contact.FieldStatus:
  4488. return m.AddedStatus()
  4489. case contact.FieldType:
  4490. return m.AddedType()
  4491. case contact.FieldSex:
  4492. return m.AddedSex()
  4493. case contact.FieldDontseeit:
  4494. return m.AddedDontseeit()
  4495. case contact.FieldDontseeme:
  4496. return m.AddedDontseeme()
  4497. case contact.FieldOrganizationID:
  4498. return m.AddedOrganizationID()
  4499. }
  4500. return nil, false
  4501. }
  4502. // AddField adds the value to the field with the given name. It returns an error if
  4503. // the field is not defined in the schema, or if the type mismatched the field
  4504. // type.
  4505. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  4506. switch name {
  4507. case contact.FieldStatus:
  4508. v, ok := value.(int8)
  4509. if !ok {
  4510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4511. }
  4512. m.AddStatus(v)
  4513. return nil
  4514. case contact.FieldType:
  4515. v, ok := value.(int)
  4516. if !ok {
  4517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4518. }
  4519. m.AddType(v)
  4520. return nil
  4521. case contact.FieldSex:
  4522. v, ok := value.(int)
  4523. if !ok {
  4524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4525. }
  4526. m.AddSex(v)
  4527. return nil
  4528. case contact.FieldDontseeit:
  4529. v, ok := value.(int)
  4530. if !ok {
  4531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4532. }
  4533. m.AddDontseeit(v)
  4534. return nil
  4535. case contact.FieldDontseeme:
  4536. v, ok := value.(int)
  4537. if !ok {
  4538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4539. }
  4540. m.AddDontseeme(v)
  4541. return nil
  4542. case contact.FieldOrganizationID:
  4543. v, ok := value.(int64)
  4544. if !ok {
  4545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4546. }
  4547. m.AddOrganizationID(v)
  4548. return nil
  4549. }
  4550. return fmt.Errorf("unknown Contact numeric field %s", name)
  4551. }
  4552. // ClearedFields returns all nullable fields that were cleared during this
  4553. // mutation.
  4554. func (m *ContactMutation) ClearedFields() []string {
  4555. var fields []string
  4556. if m.FieldCleared(contact.FieldStatus) {
  4557. fields = append(fields, contact.FieldStatus)
  4558. }
  4559. if m.FieldCleared(contact.FieldDeletedAt) {
  4560. fields = append(fields, contact.FieldDeletedAt)
  4561. }
  4562. if m.FieldCleared(contact.FieldWxWxid) {
  4563. fields = append(fields, contact.FieldWxWxid)
  4564. }
  4565. if m.FieldCleared(contact.FieldType) {
  4566. fields = append(fields, contact.FieldType)
  4567. }
  4568. if m.FieldCleared(contact.FieldOrganizationID) {
  4569. fields = append(fields, contact.FieldOrganizationID)
  4570. }
  4571. return fields
  4572. }
  4573. // FieldCleared returns a boolean indicating if a field with the given name was
  4574. // cleared in this mutation.
  4575. func (m *ContactMutation) FieldCleared(name string) bool {
  4576. _, ok := m.clearedFields[name]
  4577. return ok
  4578. }
  4579. // ClearField clears the value of the field with the given name. It returns an
  4580. // error if the field is not defined in the schema.
  4581. func (m *ContactMutation) ClearField(name string) error {
  4582. switch name {
  4583. case contact.FieldStatus:
  4584. m.ClearStatus()
  4585. return nil
  4586. case contact.FieldDeletedAt:
  4587. m.ClearDeletedAt()
  4588. return nil
  4589. case contact.FieldWxWxid:
  4590. m.ClearWxWxid()
  4591. return nil
  4592. case contact.FieldType:
  4593. m.ClearType()
  4594. return nil
  4595. case contact.FieldOrganizationID:
  4596. m.ClearOrganizationID()
  4597. return nil
  4598. }
  4599. return fmt.Errorf("unknown Contact nullable field %s", name)
  4600. }
  4601. // ResetField resets all changes in the mutation for the field with the given name.
  4602. // It returns an error if the field is not defined in the schema.
  4603. func (m *ContactMutation) ResetField(name string) error {
  4604. switch name {
  4605. case contact.FieldCreatedAt:
  4606. m.ResetCreatedAt()
  4607. return nil
  4608. case contact.FieldUpdatedAt:
  4609. m.ResetUpdatedAt()
  4610. return nil
  4611. case contact.FieldStatus:
  4612. m.ResetStatus()
  4613. return nil
  4614. case contact.FieldDeletedAt:
  4615. m.ResetDeletedAt()
  4616. return nil
  4617. case contact.FieldWxWxid:
  4618. m.ResetWxWxid()
  4619. return nil
  4620. case contact.FieldType:
  4621. m.ResetType()
  4622. return nil
  4623. case contact.FieldWxid:
  4624. m.ResetWxid()
  4625. return nil
  4626. case contact.FieldAccount:
  4627. m.ResetAccount()
  4628. return nil
  4629. case contact.FieldNickname:
  4630. m.ResetNickname()
  4631. return nil
  4632. case contact.FieldMarkname:
  4633. m.ResetMarkname()
  4634. return nil
  4635. case contact.FieldHeadimg:
  4636. m.ResetHeadimg()
  4637. return nil
  4638. case contact.FieldSex:
  4639. m.ResetSex()
  4640. return nil
  4641. case contact.FieldStarrole:
  4642. m.ResetStarrole()
  4643. return nil
  4644. case contact.FieldDontseeit:
  4645. m.ResetDontseeit()
  4646. return nil
  4647. case contact.FieldDontseeme:
  4648. m.ResetDontseeme()
  4649. return nil
  4650. case contact.FieldLag:
  4651. m.ResetLag()
  4652. return nil
  4653. case contact.FieldGid:
  4654. m.ResetGid()
  4655. return nil
  4656. case contact.FieldGname:
  4657. m.ResetGname()
  4658. return nil
  4659. case contact.FieldV3:
  4660. m.ResetV3()
  4661. return nil
  4662. case contact.FieldOrganizationID:
  4663. m.ResetOrganizationID()
  4664. return nil
  4665. }
  4666. return fmt.Errorf("unknown Contact field %s", name)
  4667. }
  4668. // AddedEdges returns all edge names that were set/added in this mutation.
  4669. func (m *ContactMutation) AddedEdges() []string {
  4670. edges := make([]string, 0, 2)
  4671. if m.contact_relationships != nil {
  4672. edges = append(edges, contact.EdgeContactRelationships)
  4673. }
  4674. if m.contact_messages != nil {
  4675. edges = append(edges, contact.EdgeContactMessages)
  4676. }
  4677. return edges
  4678. }
  4679. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4680. // name in this mutation.
  4681. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  4682. switch name {
  4683. case contact.EdgeContactRelationships:
  4684. ids := make([]ent.Value, 0, len(m.contact_relationships))
  4685. for id := range m.contact_relationships {
  4686. ids = append(ids, id)
  4687. }
  4688. return ids
  4689. case contact.EdgeContactMessages:
  4690. ids := make([]ent.Value, 0, len(m.contact_messages))
  4691. for id := range m.contact_messages {
  4692. ids = append(ids, id)
  4693. }
  4694. return ids
  4695. }
  4696. return nil
  4697. }
  4698. // RemovedEdges returns all edge names that were removed in this mutation.
  4699. func (m *ContactMutation) RemovedEdges() []string {
  4700. edges := make([]string, 0, 2)
  4701. if m.removedcontact_relationships != nil {
  4702. edges = append(edges, contact.EdgeContactRelationships)
  4703. }
  4704. if m.removedcontact_messages != nil {
  4705. edges = append(edges, contact.EdgeContactMessages)
  4706. }
  4707. return edges
  4708. }
  4709. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4710. // the given name in this mutation.
  4711. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  4712. switch name {
  4713. case contact.EdgeContactRelationships:
  4714. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  4715. for id := range m.removedcontact_relationships {
  4716. ids = append(ids, id)
  4717. }
  4718. return ids
  4719. case contact.EdgeContactMessages:
  4720. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  4721. for id := range m.removedcontact_messages {
  4722. ids = append(ids, id)
  4723. }
  4724. return ids
  4725. }
  4726. return nil
  4727. }
  4728. // ClearedEdges returns all edge names that were cleared in this mutation.
  4729. func (m *ContactMutation) ClearedEdges() []string {
  4730. edges := make([]string, 0, 2)
  4731. if m.clearedcontact_relationships {
  4732. edges = append(edges, contact.EdgeContactRelationships)
  4733. }
  4734. if m.clearedcontact_messages {
  4735. edges = append(edges, contact.EdgeContactMessages)
  4736. }
  4737. return edges
  4738. }
  4739. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4740. // was cleared in this mutation.
  4741. func (m *ContactMutation) EdgeCleared(name string) bool {
  4742. switch name {
  4743. case contact.EdgeContactRelationships:
  4744. return m.clearedcontact_relationships
  4745. case contact.EdgeContactMessages:
  4746. return m.clearedcontact_messages
  4747. }
  4748. return false
  4749. }
  4750. // ClearEdge clears the value of the edge with the given name. It returns an error
  4751. // if that edge is not defined in the schema.
  4752. func (m *ContactMutation) ClearEdge(name string) error {
  4753. switch name {
  4754. }
  4755. return fmt.Errorf("unknown Contact unique edge %s", name)
  4756. }
  4757. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4758. // It returns an error if the edge is not defined in the schema.
  4759. func (m *ContactMutation) ResetEdge(name string) error {
  4760. switch name {
  4761. case contact.EdgeContactRelationships:
  4762. m.ResetContactRelationships()
  4763. return nil
  4764. case contact.EdgeContactMessages:
  4765. m.ResetContactMessages()
  4766. return nil
  4767. }
  4768. return fmt.Errorf("unknown Contact edge %s", name)
  4769. }
  4770. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  4771. type EmployeeMutation struct {
  4772. config
  4773. op Op
  4774. typ string
  4775. id *uint64
  4776. created_at *time.Time
  4777. updated_at *time.Time
  4778. deleted_at *time.Time
  4779. title *string
  4780. avatar *string
  4781. tags *string
  4782. hire_count *int
  4783. addhire_count *int
  4784. service_count *int
  4785. addservice_count *int
  4786. achievement_count *int
  4787. addachievement_count *int
  4788. intro *string
  4789. estimate *string
  4790. skill *string
  4791. ability_type *string
  4792. scene *string
  4793. switch_in *string
  4794. video_url *string
  4795. organization_id *uint64
  4796. addorganization_id *int64
  4797. category_id *uint64
  4798. addcategory_id *int64
  4799. clearedFields map[string]struct{}
  4800. em_work_experiences map[uint64]struct{}
  4801. removedem_work_experiences map[uint64]struct{}
  4802. clearedem_work_experiences bool
  4803. em_tutorial map[uint64]struct{}
  4804. removedem_tutorial map[uint64]struct{}
  4805. clearedem_tutorial bool
  4806. done bool
  4807. oldValue func(context.Context) (*Employee, error)
  4808. predicates []predicate.Employee
  4809. }
  4810. var _ ent.Mutation = (*EmployeeMutation)(nil)
  4811. // employeeOption allows management of the mutation configuration using functional options.
  4812. type employeeOption func(*EmployeeMutation)
  4813. // newEmployeeMutation creates new mutation for the Employee entity.
  4814. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  4815. m := &EmployeeMutation{
  4816. config: c,
  4817. op: op,
  4818. typ: TypeEmployee,
  4819. clearedFields: make(map[string]struct{}),
  4820. }
  4821. for _, opt := range opts {
  4822. opt(m)
  4823. }
  4824. return m
  4825. }
  4826. // withEmployeeID sets the ID field of the mutation.
  4827. func withEmployeeID(id uint64) employeeOption {
  4828. return func(m *EmployeeMutation) {
  4829. var (
  4830. err error
  4831. once sync.Once
  4832. value *Employee
  4833. )
  4834. m.oldValue = func(ctx context.Context) (*Employee, error) {
  4835. once.Do(func() {
  4836. if m.done {
  4837. err = errors.New("querying old values post mutation is not allowed")
  4838. } else {
  4839. value, err = m.Client().Employee.Get(ctx, id)
  4840. }
  4841. })
  4842. return value, err
  4843. }
  4844. m.id = &id
  4845. }
  4846. }
  4847. // withEmployee sets the old Employee of the mutation.
  4848. func withEmployee(node *Employee) employeeOption {
  4849. return func(m *EmployeeMutation) {
  4850. m.oldValue = func(context.Context) (*Employee, error) {
  4851. return node, nil
  4852. }
  4853. m.id = &node.ID
  4854. }
  4855. }
  4856. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4857. // executed in a transaction (ent.Tx), a transactional client is returned.
  4858. func (m EmployeeMutation) Client() *Client {
  4859. client := &Client{config: m.config}
  4860. client.init()
  4861. return client
  4862. }
  4863. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4864. // it returns an error otherwise.
  4865. func (m EmployeeMutation) Tx() (*Tx, error) {
  4866. if _, ok := m.driver.(*txDriver); !ok {
  4867. return nil, errors.New("ent: mutation is not running in a transaction")
  4868. }
  4869. tx := &Tx{config: m.config}
  4870. tx.init()
  4871. return tx, nil
  4872. }
  4873. // SetID sets the value of the id field. Note that this
  4874. // operation is only accepted on creation of Employee entities.
  4875. func (m *EmployeeMutation) SetID(id uint64) {
  4876. m.id = &id
  4877. }
  4878. // ID returns the ID value in the mutation. Note that the ID is only available
  4879. // if it was provided to the builder or after it was returned from the database.
  4880. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  4881. if m.id == nil {
  4882. return
  4883. }
  4884. return *m.id, true
  4885. }
  4886. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4887. // That means, if the mutation is applied within a transaction with an isolation level such
  4888. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4889. // or updated by the mutation.
  4890. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  4891. switch {
  4892. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4893. id, exists := m.ID()
  4894. if exists {
  4895. return []uint64{id}, nil
  4896. }
  4897. fallthrough
  4898. case m.op.Is(OpUpdate | OpDelete):
  4899. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  4900. default:
  4901. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4902. }
  4903. }
  4904. // SetCreatedAt sets the "created_at" field.
  4905. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  4906. m.created_at = &t
  4907. }
  4908. // CreatedAt returns the value of the "created_at" field in the mutation.
  4909. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  4910. v := m.created_at
  4911. if v == nil {
  4912. return
  4913. }
  4914. return *v, true
  4915. }
  4916. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  4917. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4919. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4920. if !m.op.Is(OpUpdateOne) {
  4921. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4922. }
  4923. if m.id == nil || m.oldValue == nil {
  4924. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4925. }
  4926. oldValue, err := m.oldValue(ctx)
  4927. if err != nil {
  4928. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4929. }
  4930. return oldValue.CreatedAt, nil
  4931. }
  4932. // ResetCreatedAt resets all changes to the "created_at" field.
  4933. func (m *EmployeeMutation) ResetCreatedAt() {
  4934. m.created_at = nil
  4935. }
  4936. // SetUpdatedAt sets the "updated_at" field.
  4937. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  4938. m.updated_at = &t
  4939. }
  4940. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4941. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  4942. v := m.updated_at
  4943. if v == nil {
  4944. return
  4945. }
  4946. return *v, true
  4947. }
  4948. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  4949. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4951. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4952. if !m.op.Is(OpUpdateOne) {
  4953. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4954. }
  4955. if m.id == nil || m.oldValue == nil {
  4956. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4957. }
  4958. oldValue, err := m.oldValue(ctx)
  4959. if err != nil {
  4960. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4961. }
  4962. return oldValue.UpdatedAt, nil
  4963. }
  4964. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4965. func (m *EmployeeMutation) ResetUpdatedAt() {
  4966. m.updated_at = nil
  4967. }
  4968. // SetDeletedAt sets the "deleted_at" field.
  4969. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  4970. m.deleted_at = &t
  4971. }
  4972. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4973. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  4974. v := m.deleted_at
  4975. if v == nil {
  4976. return
  4977. }
  4978. return *v, true
  4979. }
  4980. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  4981. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4983. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4984. if !m.op.Is(OpUpdateOne) {
  4985. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4986. }
  4987. if m.id == nil || m.oldValue == nil {
  4988. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4989. }
  4990. oldValue, err := m.oldValue(ctx)
  4991. if err != nil {
  4992. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4993. }
  4994. return oldValue.DeletedAt, nil
  4995. }
  4996. // ClearDeletedAt clears the value of the "deleted_at" field.
  4997. func (m *EmployeeMutation) ClearDeletedAt() {
  4998. m.deleted_at = nil
  4999. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  5000. }
  5001. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5002. func (m *EmployeeMutation) DeletedAtCleared() bool {
  5003. _, ok := m.clearedFields[employee.FieldDeletedAt]
  5004. return ok
  5005. }
  5006. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5007. func (m *EmployeeMutation) ResetDeletedAt() {
  5008. m.deleted_at = nil
  5009. delete(m.clearedFields, employee.FieldDeletedAt)
  5010. }
  5011. // SetTitle sets the "title" field.
  5012. func (m *EmployeeMutation) SetTitle(s string) {
  5013. m.title = &s
  5014. }
  5015. // Title returns the value of the "title" field in the mutation.
  5016. func (m *EmployeeMutation) Title() (r string, exists bool) {
  5017. v := m.title
  5018. if v == nil {
  5019. return
  5020. }
  5021. return *v, true
  5022. }
  5023. // OldTitle returns the old "title" field's value of the Employee entity.
  5024. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5026. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  5027. if !m.op.Is(OpUpdateOne) {
  5028. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  5029. }
  5030. if m.id == nil || m.oldValue == nil {
  5031. return v, errors.New("OldTitle requires an ID field in the mutation")
  5032. }
  5033. oldValue, err := m.oldValue(ctx)
  5034. if err != nil {
  5035. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  5036. }
  5037. return oldValue.Title, nil
  5038. }
  5039. // ResetTitle resets all changes to the "title" field.
  5040. func (m *EmployeeMutation) ResetTitle() {
  5041. m.title = nil
  5042. }
  5043. // SetAvatar sets the "avatar" field.
  5044. func (m *EmployeeMutation) SetAvatar(s string) {
  5045. m.avatar = &s
  5046. }
  5047. // Avatar returns the value of the "avatar" field in the mutation.
  5048. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  5049. v := m.avatar
  5050. if v == nil {
  5051. return
  5052. }
  5053. return *v, true
  5054. }
  5055. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  5056. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5058. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  5059. if !m.op.Is(OpUpdateOne) {
  5060. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  5061. }
  5062. if m.id == nil || m.oldValue == nil {
  5063. return v, errors.New("OldAvatar requires an ID field in the mutation")
  5064. }
  5065. oldValue, err := m.oldValue(ctx)
  5066. if err != nil {
  5067. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  5068. }
  5069. return oldValue.Avatar, nil
  5070. }
  5071. // ResetAvatar resets all changes to the "avatar" field.
  5072. func (m *EmployeeMutation) ResetAvatar() {
  5073. m.avatar = nil
  5074. }
  5075. // SetTags sets the "tags" field.
  5076. func (m *EmployeeMutation) SetTags(s string) {
  5077. m.tags = &s
  5078. }
  5079. // Tags returns the value of the "tags" field in the mutation.
  5080. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  5081. v := m.tags
  5082. if v == nil {
  5083. return
  5084. }
  5085. return *v, true
  5086. }
  5087. // OldTags returns the old "tags" field's value of the Employee entity.
  5088. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5090. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  5091. if !m.op.Is(OpUpdateOne) {
  5092. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  5093. }
  5094. if m.id == nil || m.oldValue == nil {
  5095. return v, errors.New("OldTags requires an ID field in the mutation")
  5096. }
  5097. oldValue, err := m.oldValue(ctx)
  5098. if err != nil {
  5099. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  5100. }
  5101. return oldValue.Tags, nil
  5102. }
  5103. // ResetTags resets all changes to the "tags" field.
  5104. func (m *EmployeeMutation) ResetTags() {
  5105. m.tags = nil
  5106. }
  5107. // SetHireCount sets the "hire_count" field.
  5108. func (m *EmployeeMutation) SetHireCount(i int) {
  5109. m.hire_count = &i
  5110. m.addhire_count = nil
  5111. }
  5112. // HireCount returns the value of the "hire_count" field in the mutation.
  5113. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  5114. v := m.hire_count
  5115. if v == nil {
  5116. return
  5117. }
  5118. return *v, true
  5119. }
  5120. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  5121. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5122. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5123. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  5124. if !m.op.Is(OpUpdateOne) {
  5125. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  5126. }
  5127. if m.id == nil || m.oldValue == nil {
  5128. return v, errors.New("OldHireCount requires an ID field in the mutation")
  5129. }
  5130. oldValue, err := m.oldValue(ctx)
  5131. if err != nil {
  5132. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  5133. }
  5134. return oldValue.HireCount, nil
  5135. }
  5136. // AddHireCount adds i to the "hire_count" field.
  5137. func (m *EmployeeMutation) AddHireCount(i int) {
  5138. if m.addhire_count != nil {
  5139. *m.addhire_count += i
  5140. } else {
  5141. m.addhire_count = &i
  5142. }
  5143. }
  5144. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  5145. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  5146. v := m.addhire_count
  5147. if v == nil {
  5148. return
  5149. }
  5150. return *v, true
  5151. }
  5152. // ResetHireCount resets all changes to the "hire_count" field.
  5153. func (m *EmployeeMutation) ResetHireCount() {
  5154. m.hire_count = nil
  5155. m.addhire_count = nil
  5156. }
  5157. // SetServiceCount sets the "service_count" field.
  5158. func (m *EmployeeMutation) SetServiceCount(i int) {
  5159. m.service_count = &i
  5160. m.addservice_count = nil
  5161. }
  5162. // ServiceCount returns the value of the "service_count" field in the mutation.
  5163. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  5164. v := m.service_count
  5165. if v == nil {
  5166. return
  5167. }
  5168. return *v, true
  5169. }
  5170. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  5171. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5173. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  5174. if !m.op.Is(OpUpdateOne) {
  5175. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  5176. }
  5177. if m.id == nil || m.oldValue == nil {
  5178. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  5179. }
  5180. oldValue, err := m.oldValue(ctx)
  5181. if err != nil {
  5182. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  5183. }
  5184. return oldValue.ServiceCount, nil
  5185. }
  5186. // AddServiceCount adds i to the "service_count" field.
  5187. func (m *EmployeeMutation) AddServiceCount(i int) {
  5188. if m.addservice_count != nil {
  5189. *m.addservice_count += i
  5190. } else {
  5191. m.addservice_count = &i
  5192. }
  5193. }
  5194. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  5195. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  5196. v := m.addservice_count
  5197. if v == nil {
  5198. return
  5199. }
  5200. return *v, true
  5201. }
  5202. // ResetServiceCount resets all changes to the "service_count" field.
  5203. func (m *EmployeeMutation) ResetServiceCount() {
  5204. m.service_count = nil
  5205. m.addservice_count = nil
  5206. }
  5207. // SetAchievementCount sets the "achievement_count" field.
  5208. func (m *EmployeeMutation) SetAchievementCount(i int) {
  5209. m.achievement_count = &i
  5210. m.addachievement_count = nil
  5211. }
  5212. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  5213. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  5214. v := m.achievement_count
  5215. if v == nil {
  5216. return
  5217. }
  5218. return *v, true
  5219. }
  5220. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  5221. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5223. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  5224. if !m.op.Is(OpUpdateOne) {
  5225. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  5226. }
  5227. if m.id == nil || m.oldValue == nil {
  5228. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  5229. }
  5230. oldValue, err := m.oldValue(ctx)
  5231. if err != nil {
  5232. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  5233. }
  5234. return oldValue.AchievementCount, nil
  5235. }
  5236. // AddAchievementCount adds i to the "achievement_count" field.
  5237. func (m *EmployeeMutation) AddAchievementCount(i int) {
  5238. if m.addachievement_count != nil {
  5239. *m.addachievement_count += i
  5240. } else {
  5241. m.addachievement_count = &i
  5242. }
  5243. }
  5244. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  5245. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  5246. v := m.addachievement_count
  5247. if v == nil {
  5248. return
  5249. }
  5250. return *v, true
  5251. }
  5252. // ResetAchievementCount resets all changes to the "achievement_count" field.
  5253. func (m *EmployeeMutation) ResetAchievementCount() {
  5254. m.achievement_count = nil
  5255. m.addachievement_count = nil
  5256. }
  5257. // SetIntro sets the "intro" field.
  5258. func (m *EmployeeMutation) SetIntro(s string) {
  5259. m.intro = &s
  5260. }
  5261. // Intro returns the value of the "intro" field in the mutation.
  5262. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  5263. v := m.intro
  5264. if v == nil {
  5265. return
  5266. }
  5267. return *v, true
  5268. }
  5269. // OldIntro returns the old "intro" field's value of the Employee entity.
  5270. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5272. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  5273. if !m.op.Is(OpUpdateOne) {
  5274. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  5275. }
  5276. if m.id == nil || m.oldValue == nil {
  5277. return v, errors.New("OldIntro requires an ID field in the mutation")
  5278. }
  5279. oldValue, err := m.oldValue(ctx)
  5280. if err != nil {
  5281. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  5282. }
  5283. return oldValue.Intro, nil
  5284. }
  5285. // ResetIntro resets all changes to the "intro" field.
  5286. func (m *EmployeeMutation) ResetIntro() {
  5287. m.intro = nil
  5288. }
  5289. // SetEstimate sets the "estimate" field.
  5290. func (m *EmployeeMutation) SetEstimate(s string) {
  5291. m.estimate = &s
  5292. }
  5293. // Estimate returns the value of the "estimate" field in the mutation.
  5294. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  5295. v := m.estimate
  5296. if v == nil {
  5297. return
  5298. }
  5299. return *v, true
  5300. }
  5301. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  5302. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5304. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  5305. if !m.op.Is(OpUpdateOne) {
  5306. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  5307. }
  5308. if m.id == nil || m.oldValue == nil {
  5309. return v, errors.New("OldEstimate requires an ID field in the mutation")
  5310. }
  5311. oldValue, err := m.oldValue(ctx)
  5312. if err != nil {
  5313. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  5314. }
  5315. return oldValue.Estimate, nil
  5316. }
  5317. // ResetEstimate resets all changes to the "estimate" field.
  5318. func (m *EmployeeMutation) ResetEstimate() {
  5319. m.estimate = nil
  5320. }
  5321. // SetSkill sets the "skill" field.
  5322. func (m *EmployeeMutation) SetSkill(s string) {
  5323. m.skill = &s
  5324. }
  5325. // Skill returns the value of the "skill" field in the mutation.
  5326. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  5327. v := m.skill
  5328. if v == nil {
  5329. return
  5330. }
  5331. return *v, true
  5332. }
  5333. // OldSkill returns the old "skill" field's value of the Employee entity.
  5334. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5336. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  5337. if !m.op.Is(OpUpdateOne) {
  5338. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  5339. }
  5340. if m.id == nil || m.oldValue == nil {
  5341. return v, errors.New("OldSkill requires an ID field in the mutation")
  5342. }
  5343. oldValue, err := m.oldValue(ctx)
  5344. if err != nil {
  5345. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  5346. }
  5347. return oldValue.Skill, nil
  5348. }
  5349. // ResetSkill resets all changes to the "skill" field.
  5350. func (m *EmployeeMutation) ResetSkill() {
  5351. m.skill = nil
  5352. }
  5353. // SetAbilityType sets the "ability_type" field.
  5354. func (m *EmployeeMutation) SetAbilityType(s string) {
  5355. m.ability_type = &s
  5356. }
  5357. // AbilityType returns the value of the "ability_type" field in the mutation.
  5358. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  5359. v := m.ability_type
  5360. if v == nil {
  5361. return
  5362. }
  5363. return *v, true
  5364. }
  5365. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  5366. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5368. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  5369. if !m.op.Is(OpUpdateOne) {
  5370. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  5371. }
  5372. if m.id == nil || m.oldValue == nil {
  5373. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  5374. }
  5375. oldValue, err := m.oldValue(ctx)
  5376. if err != nil {
  5377. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  5378. }
  5379. return oldValue.AbilityType, nil
  5380. }
  5381. // ResetAbilityType resets all changes to the "ability_type" field.
  5382. func (m *EmployeeMutation) ResetAbilityType() {
  5383. m.ability_type = nil
  5384. }
  5385. // SetScene sets the "scene" field.
  5386. func (m *EmployeeMutation) SetScene(s string) {
  5387. m.scene = &s
  5388. }
  5389. // Scene returns the value of the "scene" field in the mutation.
  5390. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  5391. v := m.scene
  5392. if v == nil {
  5393. return
  5394. }
  5395. return *v, true
  5396. }
  5397. // OldScene returns the old "scene" field's value of the Employee entity.
  5398. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5400. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  5401. if !m.op.Is(OpUpdateOne) {
  5402. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  5403. }
  5404. if m.id == nil || m.oldValue == nil {
  5405. return v, errors.New("OldScene requires an ID field in the mutation")
  5406. }
  5407. oldValue, err := m.oldValue(ctx)
  5408. if err != nil {
  5409. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  5410. }
  5411. return oldValue.Scene, nil
  5412. }
  5413. // ResetScene resets all changes to the "scene" field.
  5414. func (m *EmployeeMutation) ResetScene() {
  5415. m.scene = nil
  5416. }
  5417. // SetSwitchIn sets the "switch_in" field.
  5418. func (m *EmployeeMutation) SetSwitchIn(s string) {
  5419. m.switch_in = &s
  5420. }
  5421. // SwitchIn returns the value of the "switch_in" field in the mutation.
  5422. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  5423. v := m.switch_in
  5424. if v == nil {
  5425. return
  5426. }
  5427. return *v, true
  5428. }
  5429. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  5430. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5432. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  5433. if !m.op.Is(OpUpdateOne) {
  5434. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  5435. }
  5436. if m.id == nil || m.oldValue == nil {
  5437. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  5438. }
  5439. oldValue, err := m.oldValue(ctx)
  5440. if err != nil {
  5441. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  5442. }
  5443. return oldValue.SwitchIn, nil
  5444. }
  5445. // ResetSwitchIn resets all changes to the "switch_in" field.
  5446. func (m *EmployeeMutation) ResetSwitchIn() {
  5447. m.switch_in = nil
  5448. }
  5449. // SetVideoURL sets the "video_url" field.
  5450. func (m *EmployeeMutation) SetVideoURL(s string) {
  5451. m.video_url = &s
  5452. }
  5453. // VideoURL returns the value of the "video_url" field in the mutation.
  5454. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  5455. v := m.video_url
  5456. if v == nil {
  5457. return
  5458. }
  5459. return *v, true
  5460. }
  5461. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  5462. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5464. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  5465. if !m.op.Is(OpUpdateOne) {
  5466. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  5467. }
  5468. if m.id == nil || m.oldValue == nil {
  5469. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  5470. }
  5471. oldValue, err := m.oldValue(ctx)
  5472. if err != nil {
  5473. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  5474. }
  5475. return oldValue.VideoURL, nil
  5476. }
  5477. // ResetVideoURL resets all changes to the "video_url" field.
  5478. func (m *EmployeeMutation) ResetVideoURL() {
  5479. m.video_url = nil
  5480. }
  5481. // SetOrganizationID sets the "organization_id" field.
  5482. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  5483. m.organization_id = &u
  5484. m.addorganization_id = nil
  5485. }
  5486. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5487. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  5488. v := m.organization_id
  5489. if v == nil {
  5490. return
  5491. }
  5492. return *v, true
  5493. }
  5494. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  5495. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5497. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5498. if !m.op.Is(OpUpdateOne) {
  5499. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5500. }
  5501. if m.id == nil || m.oldValue == nil {
  5502. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5503. }
  5504. oldValue, err := m.oldValue(ctx)
  5505. if err != nil {
  5506. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5507. }
  5508. return oldValue.OrganizationID, nil
  5509. }
  5510. // AddOrganizationID adds u to the "organization_id" field.
  5511. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  5512. if m.addorganization_id != nil {
  5513. *m.addorganization_id += u
  5514. } else {
  5515. m.addorganization_id = &u
  5516. }
  5517. }
  5518. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5519. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  5520. v := m.addorganization_id
  5521. if v == nil {
  5522. return
  5523. }
  5524. return *v, true
  5525. }
  5526. // ResetOrganizationID resets all changes to the "organization_id" field.
  5527. func (m *EmployeeMutation) ResetOrganizationID() {
  5528. m.organization_id = nil
  5529. m.addorganization_id = nil
  5530. }
  5531. // SetCategoryID sets the "category_id" field.
  5532. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  5533. m.category_id = &u
  5534. m.addcategory_id = nil
  5535. }
  5536. // CategoryID returns the value of the "category_id" field in the mutation.
  5537. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  5538. v := m.category_id
  5539. if v == nil {
  5540. return
  5541. }
  5542. return *v, true
  5543. }
  5544. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  5545. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5546. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5547. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  5548. if !m.op.Is(OpUpdateOne) {
  5549. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  5550. }
  5551. if m.id == nil || m.oldValue == nil {
  5552. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  5553. }
  5554. oldValue, err := m.oldValue(ctx)
  5555. if err != nil {
  5556. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  5557. }
  5558. return oldValue.CategoryID, nil
  5559. }
  5560. // AddCategoryID adds u to the "category_id" field.
  5561. func (m *EmployeeMutation) AddCategoryID(u int64) {
  5562. if m.addcategory_id != nil {
  5563. *m.addcategory_id += u
  5564. } else {
  5565. m.addcategory_id = &u
  5566. }
  5567. }
  5568. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  5569. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  5570. v := m.addcategory_id
  5571. if v == nil {
  5572. return
  5573. }
  5574. return *v, true
  5575. }
  5576. // ResetCategoryID resets all changes to the "category_id" field.
  5577. func (m *EmployeeMutation) ResetCategoryID() {
  5578. m.category_id = nil
  5579. m.addcategory_id = nil
  5580. }
  5581. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  5582. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  5583. if m.em_work_experiences == nil {
  5584. m.em_work_experiences = make(map[uint64]struct{})
  5585. }
  5586. for i := range ids {
  5587. m.em_work_experiences[ids[i]] = struct{}{}
  5588. }
  5589. }
  5590. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  5591. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  5592. m.clearedem_work_experiences = true
  5593. }
  5594. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  5595. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  5596. return m.clearedem_work_experiences
  5597. }
  5598. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  5599. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  5600. if m.removedem_work_experiences == nil {
  5601. m.removedem_work_experiences = make(map[uint64]struct{})
  5602. }
  5603. for i := range ids {
  5604. delete(m.em_work_experiences, ids[i])
  5605. m.removedem_work_experiences[ids[i]] = struct{}{}
  5606. }
  5607. }
  5608. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  5609. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  5610. for id := range m.removedem_work_experiences {
  5611. ids = append(ids, id)
  5612. }
  5613. return
  5614. }
  5615. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  5616. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  5617. for id := range m.em_work_experiences {
  5618. ids = append(ids, id)
  5619. }
  5620. return
  5621. }
  5622. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  5623. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  5624. m.em_work_experiences = nil
  5625. m.clearedem_work_experiences = false
  5626. m.removedem_work_experiences = nil
  5627. }
  5628. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  5629. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  5630. if m.em_tutorial == nil {
  5631. m.em_tutorial = make(map[uint64]struct{})
  5632. }
  5633. for i := range ids {
  5634. m.em_tutorial[ids[i]] = struct{}{}
  5635. }
  5636. }
  5637. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  5638. func (m *EmployeeMutation) ClearEmTutorial() {
  5639. m.clearedem_tutorial = true
  5640. }
  5641. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  5642. func (m *EmployeeMutation) EmTutorialCleared() bool {
  5643. return m.clearedem_tutorial
  5644. }
  5645. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  5646. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  5647. if m.removedem_tutorial == nil {
  5648. m.removedem_tutorial = make(map[uint64]struct{})
  5649. }
  5650. for i := range ids {
  5651. delete(m.em_tutorial, ids[i])
  5652. m.removedem_tutorial[ids[i]] = struct{}{}
  5653. }
  5654. }
  5655. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  5656. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  5657. for id := range m.removedem_tutorial {
  5658. ids = append(ids, id)
  5659. }
  5660. return
  5661. }
  5662. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  5663. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  5664. for id := range m.em_tutorial {
  5665. ids = append(ids, id)
  5666. }
  5667. return
  5668. }
  5669. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  5670. func (m *EmployeeMutation) ResetEmTutorial() {
  5671. m.em_tutorial = nil
  5672. m.clearedem_tutorial = false
  5673. m.removedem_tutorial = nil
  5674. }
  5675. // Where appends a list predicates to the EmployeeMutation builder.
  5676. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  5677. m.predicates = append(m.predicates, ps...)
  5678. }
  5679. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  5680. // users can use type-assertion to append predicates that do not depend on any generated package.
  5681. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  5682. p := make([]predicate.Employee, len(ps))
  5683. for i := range ps {
  5684. p[i] = ps[i]
  5685. }
  5686. m.Where(p...)
  5687. }
  5688. // Op returns the operation name.
  5689. func (m *EmployeeMutation) Op() Op {
  5690. return m.op
  5691. }
  5692. // SetOp allows setting the mutation operation.
  5693. func (m *EmployeeMutation) SetOp(op Op) {
  5694. m.op = op
  5695. }
  5696. // Type returns the node type of this mutation (Employee).
  5697. func (m *EmployeeMutation) Type() string {
  5698. return m.typ
  5699. }
  5700. // Fields returns all fields that were changed during this mutation. Note that in
  5701. // order to get all numeric fields that were incremented/decremented, call
  5702. // AddedFields().
  5703. func (m *EmployeeMutation) Fields() []string {
  5704. fields := make([]string, 0, 18)
  5705. if m.created_at != nil {
  5706. fields = append(fields, employee.FieldCreatedAt)
  5707. }
  5708. if m.updated_at != nil {
  5709. fields = append(fields, employee.FieldUpdatedAt)
  5710. }
  5711. if m.deleted_at != nil {
  5712. fields = append(fields, employee.FieldDeletedAt)
  5713. }
  5714. if m.title != nil {
  5715. fields = append(fields, employee.FieldTitle)
  5716. }
  5717. if m.avatar != nil {
  5718. fields = append(fields, employee.FieldAvatar)
  5719. }
  5720. if m.tags != nil {
  5721. fields = append(fields, employee.FieldTags)
  5722. }
  5723. if m.hire_count != nil {
  5724. fields = append(fields, employee.FieldHireCount)
  5725. }
  5726. if m.service_count != nil {
  5727. fields = append(fields, employee.FieldServiceCount)
  5728. }
  5729. if m.achievement_count != nil {
  5730. fields = append(fields, employee.FieldAchievementCount)
  5731. }
  5732. if m.intro != nil {
  5733. fields = append(fields, employee.FieldIntro)
  5734. }
  5735. if m.estimate != nil {
  5736. fields = append(fields, employee.FieldEstimate)
  5737. }
  5738. if m.skill != nil {
  5739. fields = append(fields, employee.FieldSkill)
  5740. }
  5741. if m.ability_type != nil {
  5742. fields = append(fields, employee.FieldAbilityType)
  5743. }
  5744. if m.scene != nil {
  5745. fields = append(fields, employee.FieldScene)
  5746. }
  5747. if m.switch_in != nil {
  5748. fields = append(fields, employee.FieldSwitchIn)
  5749. }
  5750. if m.video_url != nil {
  5751. fields = append(fields, employee.FieldVideoURL)
  5752. }
  5753. if m.organization_id != nil {
  5754. fields = append(fields, employee.FieldOrganizationID)
  5755. }
  5756. if m.category_id != nil {
  5757. fields = append(fields, employee.FieldCategoryID)
  5758. }
  5759. return fields
  5760. }
  5761. // Field returns the value of a field with the given name. The second boolean
  5762. // return value indicates that this field was not set, or was not defined in the
  5763. // schema.
  5764. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  5765. switch name {
  5766. case employee.FieldCreatedAt:
  5767. return m.CreatedAt()
  5768. case employee.FieldUpdatedAt:
  5769. return m.UpdatedAt()
  5770. case employee.FieldDeletedAt:
  5771. return m.DeletedAt()
  5772. case employee.FieldTitle:
  5773. return m.Title()
  5774. case employee.FieldAvatar:
  5775. return m.Avatar()
  5776. case employee.FieldTags:
  5777. return m.Tags()
  5778. case employee.FieldHireCount:
  5779. return m.HireCount()
  5780. case employee.FieldServiceCount:
  5781. return m.ServiceCount()
  5782. case employee.FieldAchievementCount:
  5783. return m.AchievementCount()
  5784. case employee.FieldIntro:
  5785. return m.Intro()
  5786. case employee.FieldEstimate:
  5787. return m.Estimate()
  5788. case employee.FieldSkill:
  5789. return m.Skill()
  5790. case employee.FieldAbilityType:
  5791. return m.AbilityType()
  5792. case employee.FieldScene:
  5793. return m.Scene()
  5794. case employee.FieldSwitchIn:
  5795. return m.SwitchIn()
  5796. case employee.FieldVideoURL:
  5797. return m.VideoURL()
  5798. case employee.FieldOrganizationID:
  5799. return m.OrganizationID()
  5800. case employee.FieldCategoryID:
  5801. return m.CategoryID()
  5802. }
  5803. return nil, false
  5804. }
  5805. // OldField returns the old value of the field from the database. An error is
  5806. // returned if the mutation operation is not UpdateOne, or the query to the
  5807. // database failed.
  5808. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5809. switch name {
  5810. case employee.FieldCreatedAt:
  5811. return m.OldCreatedAt(ctx)
  5812. case employee.FieldUpdatedAt:
  5813. return m.OldUpdatedAt(ctx)
  5814. case employee.FieldDeletedAt:
  5815. return m.OldDeletedAt(ctx)
  5816. case employee.FieldTitle:
  5817. return m.OldTitle(ctx)
  5818. case employee.FieldAvatar:
  5819. return m.OldAvatar(ctx)
  5820. case employee.FieldTags:
  5821. return m.OldTags(ctx)
  5822. case employee.FieldHireCount:
  5823. return m.OldHireCount(ctx)
  5824. case employee.FieldServiceCount:
  5825. return m.OldServiceCount(ctx)
  5826. case employee.FieldAchievementCount:
  5827. return m.OldAchievementCount(ctx)
  5828. case employee.FieldIntro:
  5829. return m.OldIntro(ctx)
  5830. case employee.FieldEstimate:
  5831. return m.OldEstimate(ctx)
  5832. case employee.FieldSkill:
  5833. return m.OldSkill(ctx)
  5834. case employee.FieldAbilityType:
  5835. return m.OldAbilityType(ctx)
  5836. case employee.FieldScene:
  5837. return m.OldScene(ctx)
  5838. case employee.FieldSwitchIn:
  5839. return m.OldSwitchIn(ctx)
  5840. case employee.FieldVideoURL:
  5841. return m.OldVideoURL(ctx)
  5842. case employee.FieldOrganizationID:
  5843. return m.OldOrganizationID(ctx)
  5844. case employee.FieldCategoryID:
  5845. return m.OldCategoryID(ctx)
  5846. }
  5847. return nil, fmt.Errorf("unknown Employee field %s", name)
  5848. }
  5849. // SetField sets the value of a field with the given name. It returns an error if
  5850. // the field is not defined in the schema, or if the type mismatched the field
  5851. // type.
  5852. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  5853. switch name {
  5854. case employee.FieldCreatedAt:
  5855. v, ok := value.(time.Time)
  5856. if !ok {
  5857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5858. }
  5859. m.SetCreatedAt(v)
  5860. return nil
  5861. case employee.FieldUpdatedAt:
  5862. v, ok := value.(time.Time)
  5863. if !ok {
  5864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5865. }
  5866. m.SetUpdatedAt(v)
  5867. return nil
  5868. case employee.FieldDeletedAt:
  5869. v, ok := value.(time.Time)
  5870. if !ok {
  5871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5872. }
  5873. m.SetDeletedAt(v)
  5874. return nil
  5875. case employee.FieldTitle:
  5876. v, ok := value.(string)
  5877. if !ok {
  5878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5879. }
  5880. m.SetTitle(v)
  5881. return nil
  5882. case employee.FieldAvatar:
  5883. v, ok := value.(string)
  5884. if !ok {
  5885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5886. }
  5887. m.SetAvatar(v)
  5888. return nil
  5889. case employee.FieldTags:
  5890. v, ok := value.(string)
  5891. if !ok {
  5892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5893. }
  5894. m.SetTags(v)
  5895. return nil
  5896. case employee.FieldHireCount:
  5897. v, ok := value.(int)
  5898. if !ok {
  5899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5900. }
  5901. m.SetHireCount(v)
  5902. return nil
  5903. case employee.FieldServiceCount:
  5904. v, ok := value.(int)
  5905. if !ok {
  5906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5907. }
  5908. m.SetServiceCount(v)
  5909. return nil
  5910. case employee.FieldAchievementCount:
  5911. v, ok := value.(int)
  5912. if !ok {
  5913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5914. }
  5915. m.SetAchievementCount(v)
  5916. return nil
  5917. case employee.FieldIntro:
  5918. v, ok := value.(string)
  5919. if !ok {
  5920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5921. }
  5922. m.SetIntro(v)
  5923. return nil
  5924. case employee.FieldEstimate:
  5925. v, ok := value.(string)
  5926. if !ok {
  5927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5928. }
  5929. m.SetEstimate(v)
  5930. return nil
  5931. case employee.FieldSkill:
  5932. v, ok := value.(string)
  5933. if !ok {
  5934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5935. }
  5936. m.SetSkill(v)
  5937. return nil
  5938. case employee.FieldAbilityType:
  5939. v, ok := value.(string)
  5940. if !ok {
  5941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5942. }
  5943. m.SetAbilityType(v)
  5944. return nil
  5945. case employee.FieldScene:
  5946. v, ok := value.(string)
  5947. if !ok {
  5948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5949. }
  5950. m.SetScene(v)
  5951. return nil
  5952. case employee.FieldSwitchIn:
  5953. v, ok := value.(string)
  5954. if !ok {
  5955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5956. }
  5957. m.SetSwitchIn(v)
  5958. return nil
  5959. case employee.FieldVideoURL:
  5960. v, ok := value.(string)
  5961. if !ok {
  5962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5963. }
  5964. m.SetVideoURL(v)
  5965. return nil
  5966. case employee.FieldOrganizationID:
  5967. v, ok := value.(uint64)
  5968. if !ok {
  5969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5970. }
  5971. m.SetOrganizationID(v)
  5972. return nil
  5973. case employee.FieldCategoryID:
  5974. v, ok := value.(uint64)
  5975. if !ok {
  5976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5977. }
  5978. m.SetCategoryID(v)
  5979. return nil
  5980. }
  5981. return fmt.Errorf("unknown Employee field %s", name)
  5982. }
  5983. // AddedFields returns all numeric fields that were incremented/decremented during
  5984. // this mutation.
  5985. func (m *EmployeeMutation) AddedFields() []string {
  5986. var fields []string
  5987. if m.addhire_count != nil {
  5988. fields = append(fields, employee.FieldHireCount)
  5989. }
  5990. if m.addservice_count != nil {
  5991. fields = append(fields, employee.FieldServiceCount)
  5992. }
  5993. if m.addachievement_count != nil {
  5994. fields = append(fields, employee.FieldAchievementCount)
  5995. }
  5996. if m.addorganization_id != nil {
  5997. fields = append(fields, employee.FieldOrganizationID)
  5998. }
  5999. if m.addcategory_id != nil {
  6000. fields = append(fields, employee.FieldCategoryID)
  6001. }
  6002. return fields
  6003. }
  6004. // AddedField returns the numeric value that was incremented/decremented on a field
  6005. // with the given name. The second boolean return value indicates that this field
  6006. // was not set, or was not defined in the schema.
  6007. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  6008. switch name {
  6009. case employee.FieldHireCount:
  6010. return m.AddedHireCount()
  6011. case employee.FieldServiceCount:
  6012. return m.AddedServiceCount()
  6013. case employee.FieldAchievementCount:
  6014. return m.AddedAchievementCount()
  6015. case employee.FieldOrganizationID:
  6016. return m.AddedOrganizationID()
  6017. case employee.FieldCategoryID:
  6018. return m.AddedCategoryID()
  6019. }
  6020. return nil, false
  6021. }
  6022. // AddField adds the value to the field with the given name. It returns an error if
  6023. // the field is not defined in the schema, or if the type mismatched the field
  6024. // type.
  6025. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  6026. switch name {
  6027. case employee.FieldHireCount:
  6028. v, ok := value.(int)
  6029. if !ok {
  6030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6031. }
  6032. m.AddHireCount(v)
  6033. return nil
  6034. case employee.FieldServiceCount:
  6035. v, ok := value.(int)
  6036. if !ok {
  6037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6038. }
  6039. m.AddServiceCount(v)
  6040. return nil
  6041. case employee.FieldAchievementCount:
  6042. v, ok := value.(int)
  6043. if !ok {
  6044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6045. }
  6046. m.AddAchievementCount(v)
  6047. return nil
  6048. case employee.FieldOrganizationID:
  6049. v, ok := value.(int64)
  6050. if !ok {
  6051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6052. }
  6053. m.AddOrganizationID(v)
  6054. return nil
  6055. case employee.FieldCategoryID:
  6056. v, ok := value.(int64)
  6057. if !ok {
  6058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6059. }
  6060. m.AddCategoryID(v)
  6061. return nil
  6062. }
  6063. return fmt.Errorf("unknown Employee numeric field %s", name)
  6064. }
  6065. // ClearedFields returns all nullable fields that were cleared during this
  6066. // mutation.
  6067. func (m *EmployeeMutation) ClearedFields() []string {
  6068. var fields []string
  6069. if m.FieldCleared(employee.FieldDeletedAt) {
  6070. fields = append(fields, employee.FieldDeletedAt)
  6071. }
  6072. return fields
  6073. }
  6074. // FieldCleared returns a boolean indicating if a field with the given name was
  6075. // cleared in this mutation.
  6076. func (m *EmployeeMutation) FieldCleared(name string) bool {
  6077. _, ok := m.clearedFields[name]
  6078. return ok
  6079. }
  6080. // ClearField clears the value of the field with the given name. It returns an
  6081. // error if the field is not defined in the schema.
  6082. func (m *EmployeeMutation) ClearField(name string) error {
  6083. switch name {
  6084. case employee.FieldDeletedAt:
  6085. m.ClearDeletedAt()
  6086. return nil
  6087. }
  6088. return fmt.Errorf("unknown Employee nullable field %s", name)
  6089. }
  6090. // ResetField resets all changes in the mutation for the field with the given name.
  6091. // It returns an error if the field is not defined in the schema.
  6092. func (m *EmployeeMutation) ResetField(name string) error {
  6093. switch name {
  6094. case employee.FieldCreatedAt:
  6095. m.ResetCreatedAt()
  6096. return nil
  6097. case employee.FieldUpdatedAt:
  6098. m.ResetUpdatedAt()
  6099. return nil
  6100. case employee.FieldDeletedAt:
  6101. m.ResetDeletedAt()
  6102. return nil
  6103. case employee.FieldTitle:
  6104. m.ResetTitle()
  6105. return nil
  6106. case employee.FieldAvatar:
  6107. m.ResetAvatar()
  6108. return nil
  6109. case employee.FieldTags:
  6110. m.ResetTags()
  6111. return nil
  6112. case employee.FieldHireCount:
  6113. m.ResetHireCount()
  6114. return nil
  6115. case employee.FieldServiceCount:
  6116. m.ResetServiceCount()
  6117. return nil
  6118. case employee.FieldAchievementCount:
  6119. m.ResetAchievementCount()
  6120. return nil
  6121. case employee.FieldIntro:
  6122. m.ResetIntro()
  6123. return nil
  6124. case employee.FieldEstimate:
  6125. m.ResetEstimate()
  6126. return nil
  6127. case employee.FieldSkill:
  6128. m.ResetSkill()
  6129. return nil
  6130. case employee.FieldAbilityType:
  6131. m.ResetAbilityType()
  6132. return nil
  6133. case employee.FieldScene:
  6134. m.ResetScene()
  6135. return nil
  6136. case employee.FieldSwitchIn:
  6137. m.ResetSwitchIn()
  6138. return nil
  6139. case employee.FieldVideoURL:
  6140. m.ResetVideoURL()
  6141. return nil
  6142. case employee.FieldOrganizationID:
  6143. m.ResetOrganizationID()
  6144. return nil
  6145. case employee.FieldCategoryID:
  6146. m.ResetCategoryID()
  6147. return nil
  6148. }
  6149. return fmt.Errorf("unknown Employee field %s", name)
  6150. }
  6151. // AddedEdges returns all edge names that were set/added in this mutation.
  6152. func (m *EmployeeMutation) AddedEdges() []string {
  6153. edges := make([]string, 0, 2)
  6154. if m.em_work_experiences != nil {
  6155. edges = append(edges, employee.EdgeEmWorkExperiences)
  6156. }
  6157. if m.em_tutorial != nil {
  6158. edges = append(edges, employee.EdgeEmTutorial)
  6159. }
  6160. return edges
  6161. }
  6162. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6163. // name in this mutation.
  6164. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  6165. switch name {
  6166. case employee.EdgeEmWorkExperiences:
  6167. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  6168. for id := range m.em_work_experiences {
  6169. ids = append(ids, id)
  6170. }
  6171. return ids
  6172. case employee.EdgeEmTutorial:
  6173. ids := make([]ent.Value, 0, len(m.em_tutorial))
  6174. for id := range m.em_tutorial {
  6175. ids = append(ids, id)
  6176. }
  6177. return ids
  6178. }
  6179. return nil
  6180. }
  6181. // RemovedEdges returns all edge names that were removed in this mutation.
  6182. func (m *EmployeeMutation) RemovedEdges() []string {
  6183. edges := make([]string, 0, 2)
  6184. if m.removedem_work_experiences != nil {
  6185. edges = append(edges, employee.EdgeEmWorkExperiences)
  6186. }
  6187. if m.removedem_tutorial != nil {
  6188. edges = append(edges, employee.EdgeEmTutorial)
  6189. }
  6190. return edges
  6191. }
  6192. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6193. // the given name in this mutation.
  6194. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  6195. switch name {
  6196. case employee.EdgeEmWorkExperiences:
  6197. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  6198. for id := range m.removedem_work_experiences {
  6199. ids = append(ids, id)
  6200. }
  6201. return ids
  6202. case employee.EdgeEmTutorial:
  6203. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  6204. for id := range m.removedem_tutorial {
  6205. ids = append(ids, id)
  6206. }
  6207. return ids
  6208. }
  6209. return nil
  6210. }
  6211. // ClearedEdges returns all edge names that were cleared in this mutation.
  6212. func (m *EmployeeMutation) ClearedEdges() []string {
  6213. edges := make([]string, 0, 2)
  6214. if m.clearedem_work_experiences {
  6215. edges = append(edges, employee.EdgeEmWorkExperiences)
  6216. }
  6217. if m.clearedem_tutorial {
  6218. edges = append(edges, employee.EdgeEmTutorial)
  6219. }
  6220. return edges
  6221. }
  6222. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6223. // was cleared in this mutation.
  6224. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  6225. switch name {
  6226. case employee.EdgeEmWorkExperiences:
  6227. return m.clearedem_work_experiences
  6228. case employee.EdgeEmTutorial:
  6229. return m.clearedem_tutorial
  6230. }
  6231. return false
  6232. }
  6233. // ClearEdge clears the value of the edge with the given name. It returns an error
  6234. // if that edge is not defined in the schema.
  6235. func (m *EmployeeMutation) ClearEdge(name string) error {
  6236. switch name {
  6237. }
  6238. return fmt.Errorf("unknown Employee unique edge %s", name)
  6239. }
  6240. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6241. // It returns an error if the edge is not defined in the schema.
  6242. func (m *EmployeeMutation) ResetEdge(name string) error {
  6243. switch name {
  6244. case employee.EdgeEmWorkExperiences:
  6245. m.ResetEmWorkExperiences()
  6246. return nil
  6247. case employee.EdgeEmTutorial:
  6248. m.ResetEmTutorial()
  6249. return nil
  6250. }
  6251. return fmt.Errorf("unknown Employee edge %s", name)
  6252. }
  6253. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  6254. type EmployeeConfigMutation struct {
  6255. config
  6256. op Op
  6257. typ string
  6258. id *uint64
  6259. created_at *time.Time
  6260. updated_at *time.Time
  6261. deleted_at *time.Time
  6262. stype *string
  6263. title *string
  6264. photo *string
  6265. organization_id *uint64
  6266. addorganization_id *int64
  6267. clearedFields map[string]struct{}
  6268. done bool
  6269. oldValue func(context.Context) (*EmployeeConfig, error)
  6270. predicates []predicate.EmployeeConfig
  6271. }
  6272. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  6273. // employeeconfigOption allows management of the mutation configuration using functional options.
  6274. type employeeconfigOption func(*EmployeeConfigMutation)
  6275. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  6276. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  6277. m := &EmployeeConfigMutation{
  6278. config: c,
  6279. op: op,
  6280. typ: TypeEmployeeConfig,
  6281. clearedFields: make(map[string]struct{}),
  6282. }
  6283. for _, opt := range opts {
  6284. opt(m)
  6285. }
  6286. return m
  6287. }
  6288. // withEmployeeConfigID sets the ID field of the mutation.
  6289. func withEmployeeConfigID(id uint64) employeeconfigOption {
  6290. return func(m *EmployeeConfigMutation) {
  6291. var (
  6292. err error
  6293. once sync.Once
  6294. value *EmployeeConfig
  6295. )
  6296. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  6297. once.Do(func() {
  6298. if m.done {
  6299. err = errors.New("querying old values post mutation is not allowed")
  6300. } else {
  6301. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  6302. }
  6303. })
  6304. return value, err
  6305. }
  6306. m.id = &id
  6307. }
  6308. }
  6309. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  6310. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  6311. return func(m *EmployeeConfigMutation) {
  6312. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  6313. return node, nil
  6314. }
  6315. m.id = &node.ID
  6316. }
  6317. }
  6318. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6319. // executed in a transaction (ent.Tx), a transactional client is returned.
  6320. func (m EmployeeConfigMutation) Client() *Client {
  6321. client := &Client{config: m.config}
  6322. client.init()
  6323. return client
  6324. }
  6325. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6326. // it returns an error otherwise.
  6327. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  6328. if _, ok := m.driver.(*txDriver); !ok {
  6329. return nil, errors.New("ent: mutation is not running in a transaction")
  6330. }
  6331. tx := &Tx{config: m.config}
  6332. tx.init()
  6333. return tx, nil
  6334. }
  6335. // SetID sets the value of the id field. Note that this
  6336. // operation is only accepted on creation of EmployeeConfig entities.
  6337. func (m *EmployeeConfigMutation) SetID(id uint64) {
  6338. m.id = &id
  6339. }
  6340. // ID returns the ID value in the mutation. Note that the ID is only available
  6341. // if it was provided to the builder or after it was returned from the database.
  6342. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  6343. if m.id == nil {
  6344. return
  6345. }
  6346. return *m.id, true
  6347. }
  6348. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6349. // That means, if the mutation is applied within a transaction with an isolation level such
  6350. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6351. // or updated by the mutation.
  6352. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  6353. switch {
  6354. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6355. id, exists := m.ID()
  6356. if exists {
  6357. return []uint64{id}, nil
  6358. }
  6359. fallthrough
  6360. case m.op.Is(OpUpdate | OpDelete):
  6361. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  6362. default:
  6363. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6364. }
  6365. }
  6366. // SetCreatedAt sets the "created_at" field.
  6367. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  6368. m.created_at = &t
  6369. }
  6370. // CreatedAt returns the value of the "created_at" field in the mutation.
  6371. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  6372. v := m.created_at
  6373. if v == nil {
  6374. return
  6375. }
  6376. return *v, true
  6377. }
  6378. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  6379. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6381. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6382. if !m.op.Is(OpUpdateOne) {
  6383. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6384. }
  6385. if m.id == nil || m.oldValue == nil {
  6386. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6387. }
  6388. oldValue, err := m.oldValue(ctx)
  6389. if err != nil {
  6390. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6391. }
  6392. return oldValue.CreatedAt, nil
  6393. }
  6394. // ResetCreatedAt resets all changes to the "created_at" field.
  6395. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  6396. m.created_at = nil
  6397. }
  6398. // SetUpdatedAt sets the "updated_at" field.
  6399. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  6400. m.updated_at = &t
  6401. }
  6402. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6403. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  6404. v := m.updated_at
  6405. if v == nil {
  6406. return
  6407. }
  6408. return *v, true
  6409. }
  6410. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  6411. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6413. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6414. if !m.op.Is(OpUpdateOne) {
  6415. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6416. }
  6417. if m.id == nil || m.oldValue == nil {
  6418. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6419. }
  6420. oldValue, err := m.oldValue(ctx)
  6421. if err != nil {
  6422. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6423. }
  6424. return oldValue.UpdatedAt, nil
  6425. }
  6426. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6427. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  6428. m.updated_at = nil
  6429. }
  6430. // SetDeletedAt sets the "deleted_at" field.
  6431. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  6432. m.deleted_at = &t
  6433. }
  6434. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6435. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  6436. v := m.deleted_at
  6437. if v == nil {
  6438. return
  6439. }
  6440. return *v, true
  6441. }
  6442. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  6443. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6445. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6446. if !m.op.Is(OpUpdateOne) {
  6447. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6448. }
  6449. if m.id == nil || m.oldValue == nil {
  6450. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6451. }
  6452. oldValue, err := m.oldValue(ctx)
  6453. if err != nil {
  6454. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6455. }
  6456. return oldValue.DeletedAt, nil
  6457. }
  6458. // ClearDeletedAt clears the value of the "deleted_at" field.
  6459. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  6460. m.deleted_at = nil
  6461. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  6462. }
  6463. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6464. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  6465. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  6466. return ok
  6467. }
  6468. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6469. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  6470. m.deleted_at = nil
  6471. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  6472. }
  6473. // SetStype sets the "stype" field.
  6474. func (m *EmployeeConfigMutation) SetStype(s string) {
  6475. m.stype = &s
  6476. }
  6477. // Stype returns the value of the "stype" field in the mutation.
  6478. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  6479. v := m.stype
  6480. if v == nil {
  6481. return
  6482. }
  6483. return *v, true
  6484. }
  6485. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  6486. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6488. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  6489. if !m.op.Is(OpUpdateOne) {
  6490. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  6491. }
  6492. if m.id == nil || m.oldValue == nil {
  6493. return v, errors.New("OldStype requires an ID field in the mutation")
  6494. }
  6495. oldValue, err := m.oldValue(ctx)
  6496. if err != nil {
  6497. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  6498. }
  6499. return oldValue.Stype, nil
  6500. }
  6501. // ResetStype resets all changes to the "stype" field.
  6502. func (m *EmployeeConfigMutation) ResetStype() {
  6503. m.stype = nil
  6504. }
  6505. // SetTitle sets the "title" field.
  6506. func (m *EmployeeConfigMutation) SetTitle(s string) {
  6507. m.title = &s
  6508. }
  6509. // Title returns the value of the "title" field in the mutation.
  6510. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  6511. v := m.title
  6512. if v == nil {
  6513. return
  6514. }
  6515. return *v, true
  6516. }
  6517. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  6518. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6520. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  6521. if !m.op.Is(OpUpdateOne) {
  6522. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  6523. }
  6524. if m.id == nil || m.oldValue == nil {
  6525. return v, errors.New("OldTitle requires an ID field in the mutation")
  6526. }
  6527. oldValue, err := m.oldValue(ctx)
  6528. if err != nil {
  6529. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  6530. }
  6531. return oldValue.Title, nil
  6532. }
  6533. // ResetTitle resets all changes to the "title" field.
  6534. func (m *EmployeeConfigMutation) ResetTitle() {
  6535. m.title = nil
  6536. }
  6537. // SetPhoto sets the "photo" field.
  6538. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  6539. m.photo = &s
  6540. }
  6541. // Photo returns the value of the "photo" field in the mutation.
  6542. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  6543. v := m.photo
  6544. if v == nil {
  6545. return
  6546. }
  6547. return *v, true
  6548. }
  6549. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  6550. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6552. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  6553. if !m.op.Is(OpUpdateOne) {
  6554. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  6555. }
  6556. if m.id == nil || m.oldValue == nil {
  6557. return v, errors.New("OldPhoto requires an ID field in the mutation")
  6558. }
  6559. oldValue, err := m.oldValue(ctx)
  6560. if err != nil {
  6561. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  6562. }
  6563. return oldValue.Photo, nil
  6564. }
  6565. // ResetPhoto resets all changes to the "photo" field.
  6566. func (m *EmployeeConfigMutation) ResetPhoto() {
  6567. m.photo = nil
  6568. }
  6569. // SetOrganizationID sets the "organization_id" field.
  6570. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  6571. m.organization_id = &u
  6572. m.addorganization_id = nil
  6573. }
  6574. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6575. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  6576. v := m.organization_id
  6577. if v == nil {
  6578. return
  6579. }
  6580. return *v, true
  6581. }
  6582. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  6583. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6585. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6586. if !m.op.Is(OpUpdateOne) {
  6587. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6588. }
  6589. if m.id == nil || m.oldValue == nil {
  6590. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6591. }
  6592. oldValue, err := m.oldValue(ctx)
  6593. if err != nil {
  6594. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6595. }
  6596. return oldValue.OrganizationID, nil
  6597. }
  6598. // AddOrganizationID adds u to the "organization_id" field.
  6599. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  6600. if m.addorganization_id != nil {
  6601. *m.addorganization_id += u
  6602. } else {
  6603. m.addorganization_id = &u
  6604. }
  6605. }
  6606. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6607. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  6608. v := m.addorganization_id
  6609. if v == nil {
  6610. return
  6611. }
  6612. return *v, true
  6613. }
  6614. // ClearOrganizationID clears the value of the "organization_id" field.
  6615. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  6616. m.organization_id = nil
  6617. m.addorganization_id = nil
  6618. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  6619. }
  6620. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  6621. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  6622. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  6623. return ok
  6624. }
  6625. // ResetOrganizationID resets all changes to the "organization_id" field.
  6626. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  6627. m.organization_id = nil
  6628. m.addorganization_id = nil
  6629. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  6630. }
  6631. // Where appends a list predicates to the EmployeeConfigMutation builder.
  6632. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  6633. m.predicates = append(m.predicates, ps...)
  6634. }
  6635. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  6636. // users can use type-assertion to append predicates that do not depend on any generated package.
  6637. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  6638. p := make([]predicate.EmployeeConfig, len(ps))
  6639. for i := range ps {
  6640. p[i] = ps[i]
  6641. }
  6642. m.Where(p...)
  6643. }
  6644. // Op returns the operation name.
  6645. func (m *EmployeeConfigMutation) Op() Op {
  6646. return m.op
  6647. }
  6648. // SetOp allows setting the mutation operation.
  6649. func (m *EmployeeConfigMutation) SetOp(op Op) {
  6650. m.op = op
  6651. }
  6652. // Type returns the node type of this mutation (EmployeeConfig).
  6653. func (m *EmployeeConfigMutation) Type() string {
  6654. return m.typ
  6655. }
  6656. // Fields returns all fields that were changed during this mutation. Note that in
  6657. // order to get all numeric fields that were incremented/decremented, call
  6658. // AddedFields().
  6659. func (m *EmployeeConfigMutation) Fields() []string {
  6660. fields := make([]string, 0, 7)
  6661. if m.created_at != nil {
  6662. fields = append(fields, employeeconfig.FieldCreatedAt)
  6663. }
  6664. if m.updated_at != nil {
  6665. fields = append(fields, employeeconfig.FieldUpdatedAt)
  6666. }
  6667. if m.deleted_at != nil {
  6668. fields = append(fields, employeeconfig.FieldDeletedAt)
  6669. }
  6670. if m.stype != nil {
  6671. fields = append(fields, employeeconfig.FieldStype)
  6672. }
  6673. if m.title != nil {
  6674. fields = append(fields, employeeconfig.FieldTitle)
  6675. }
  6676. if m.photo != nil {
  6677. fields = append(fields, employeeconfig.FieldPhoto)
  6678. }
  6679. if m.organization_id != nil {
  6680. fields = append(fields, employeeconfig.FieldOrganizationID)
  6681. }
  6682. return fields
  6683. }
  6684. // Field returns the value of a field with the given name. The second boolean
  6685. // return value indicates that this field was not set, or was not defined in the
  6686. // schema.
  6687. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  6688. switch name {
  6689. case employeeconfig.FieldCreatedAt:
  6690. return m.CreatedAt()
  6691. case employeeconfig.FieldUpdatedAt:
  6692. return m.UpdatedAt()
  6693. case employeeconfig.FieldDeletedAt:
  6694. return m.DeletedAt()
  6695. case employeeconfig.FieldStype:
  6696. return m.Stype()
  6697. case employeeconfig.FieldTitle:
  6698. return m.Title()
  6699. case employeeconfig.FieldPhoto:
  6700. return m.Photo()
  6701. case employeeconfig.FieldOrganizationID:
  6702. return m.OrganizationID()
  6703. }
  6704. return nil, false
  6705. }
  6706. // OldField returns the old value of the field from the database. An error is
  6707. // returned if the mutation operation is not UpdateOne, or the query to the
  6708. // database failed.
  6709. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6710. switch name {
  6711. case employeeconfig.FieldCreatedAt:
  6712. return m.OldCreatedAt(ctx)
  6713. case employeeconfig.FieldUpdatedAt:
  6714. return m.OldUpdatedAt(ctx)
  6715. case employeeconfig.FieldDeletedAt:
  6716. return m.OldDeletedAt(ctx)
  6717. case employeeconfig.FieldStype:
  6718. return m.OldStype(ctx)
  6719. case employeeconfig.FieldTitle:
  6720. return m.OldTitle(ctx)
  6721. case employeeconfig.FieldPhoto:
  6722. return m.OldPhoto(ctx)
  6723. case employeeconfig.FieldOrganizationID:
  6724. return m.OldOrganizationID(ctx)
  6725. }
  6726. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  6727. }
  6728. // SetField sets the value of a field with the given name. It returns an error if
  6729. // the field is not defined in the schema, or if the type mismatched the field
  6730. // type.
  6731. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  6732. switch name {
  6733. case employeeconfig.FieldCreatedAt:
  6734. v, ok := value.(time.Time)
  6735. if !ok {
  6736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6737. }
  6738. m.SetCreatedAt(v)
  6739. return nil
  6740. case employeeconfig.FieldUpdatedAt:
  6741. v, ok := value.(time.Time)
  6742. if !ok {
  6743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6744. }
  6745. m.SetUpdatedAt(v)
  6746. return nil
  6747. case employeeconfig.FieldDeletedAt:
  6748. v, ok := value.(time.Time)
  6749. if !ok {
  6750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6751. }
  6752. m.SetDeletedAt(v)
  6753. return nil
  6754. case employeeconfig.FieldStype:
  6755. v, ok := value.(string)
  6756. if !ok {
  6757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6758. }
  6759. m.SetStype(v)
  6760. return nil
  6761. case employeeconfig.FieldTitle:
  6762. v, ok := value.(string)
  6763. if !ok {
  6764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6765. }
  6766. m.SetTitle(v)
  6767. return nil
  6768. case employeeconfig.FieldPhoto:
  6769. v, ok := value.(string)
  6770. if !ok {
  6771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6772. }
  6773. m.SetPhoto(v)
  6774. return nil
  6775. case employeeconfig.FieldOrganizationID:
  6776. v, ok := value.(uint64)
  6777. if !ok {
  6778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6779. }
  6780. m.SetOrganizationID(v)
  6781. return nil
  6782. }
  6783. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  6784. }
  6785. // AddedFields returns all numeric fields that were incremented/decremented during
  6786. // this mutation.
  6787. func (m *EmployeeConfigMutation) AddedFields() []string {
  6788. var fields []string
  6789. if m.addorganization_id != nil {
  6790. fields = append(fields, employeeconfig.FieldOrganizationID)
  6791. }
  6792. return fields
  6793. }
  6794. // AddedField returns the numeric value that was incremented/decremented on a field
  6795. // with the given name. The second boolean return value indicates that this field
  6796. // was not set, or was not defined in the schema.
  6797. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  6798. switch name {
  6799. case employeeconfig.FieldOrganizationID:
  6800. return m.AddedOrganizationID()
  6801. }
  6802. return nil, false
  6803. }
  6804. // AddField adds the value to the field with the given name. It returns an error if
  6805. // the field is not defined in the schema, or if the type mismatched the field
  6806. // type.
  6807. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  6808. switch name {
  6809. case employeeconfig.FieldOrganizationID:
  6810. v, ok := value.(int64)
  6811. if !ok {
  6812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6813. }
  6814. m.AddOrganizationID(v)
  6815. return nil
  6816. }
  6817. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  6818. }
  6819. // ClearedFields returns all nullable fields that were cleared during this
  6820. // mutation.
  6821. func (m *EmployeeConfigMutation) ClearedFields() []string {
  6822. var fields []string
  6823. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  6824. fields = append(fields, employeeconfig.FieldDeletedAt)
  6825. }
  6826. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  6827. fields = append(fields, employeeconfig.FieldOrganizationID)
  6828. }
  6829. return fields
  6830. }
  6831. // FieldCleared returns a boolean indicating if a field with the given name was
  6832. // cleared in this mutation.
  6833. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  6834. _, ok := m.clearedFields[name]
  6835. return ok
  6836. }
  6837. // ClearField clears the value of the field with the given name. It returns an
  6838. // error if the field is not defined in the schema.
  6839. func (m *EmployeeConfigMutation) ClearField(name string) error {
  6840. switch name {
  6841. case employeeconfig.FieldDeletedAt:
  6842. m.ClearDeletedAt()
  6843. return nil
  6844. case employeeconfig.FieldOrganizationID:
  6845. m.ClearOrganizationID()
  6846. return nil
  6847. }
  6848. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  6849. }
  6850. // ResetField resets all changes in the mutation for the field with the given name.
  6851. // It returns an error if the field is not defined in the schema.
  6852. func (m *EmployeeConfigMutation) ResetField(name string) error {
  6853. switch name {
  6854. case employeeconfig.FieldCreatedAt:
  6855. m.ResetCreatedAt()
  6856. return nil
  6857. case employeeconfig.FieldUpdatedAt:
  6858. m.ResetUpdatedAt()
  6859. return nil
  6860. case employeeconfig.FieldDeletedAt:
  6861. m.ResetDeletedAt()
  6862. return nil
  6863. case employeeconfig.FieldStype:
  6864. m.ResetStype()
  6865. return nil
  6866. case employeeconfig.FieldTitle:
  6867. m.ResetTitle()
  6868. return nil
  6869. case employeeconfig.FieldPhoto:
  6870. m.ResetPhoto()
  6871. return nil
  6872. case employeeconfig.FieldOrganizationID:
  6873. m.ResetOrganizationID()
  6874. return nil
  6875. }
  6876. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  6877. }
  6878. // AddedEdges returns all edge names that were set/added in this mutation.
  6879. func (m *EmployeeConfigMutation) AddedEdges() []string {
  6880. edges := make([]string, 0, 0)
  6881. return edges
  6882. }
  6883. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6884. // name in this mutation.
  6885. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  6886. return nil
  6887. }
  6888. // RemovedEdges returns all edge names that were removed in this mutation.
  6889. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  6890. edges := make([]string, 0, 0)
  6891. return edges
  6892. }
  6893. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6894. // the given name in this mutation.
  6895. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  6896. return nil
  6897. }
  6898. // ClearedEdges returns all edge names that were cleared in this mutation.
  6899. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  6900. edges := make([]string, 0, 0)
  6901. return edges
  6902. }
  6903. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6904. // was cleared in this mutation.
  6905. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  6906. return false
  6907. }
  6908. // ClearEdge clears the value of the edge with the given name. It returns an error
  6909. // if that edge is not defined in the schema.
  6910. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  6911. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  6912. }
  6913. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6914. // It returns an error if the edge is not defined in the schema.
  6915. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  6916. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  6917. }
  6918. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  6919. type LabelMutation struct {
  6920. config
  6921. op Op
  6922. typ string
  6923. id *uint64
  6924. created_at *time.Time
  6925. updated_at *time.Time
  6926. status *uint8
  6927. addstatus *int8
  6928. _type *int
  6929. add_type *int
  6930. name *string
  6931. from *int
  6932. addfrom *int
  6933. mode *int
  6934. addmode *int
  6935. conditions *string
  6936. organization_id *uint64
  6937. addorganization_id *int64
  6938. clearedFields map[string]struct{}
  6939. label_relationships map[uint64]struct{}
  6940. removedlabel_relationships map[uint64]struct{}
  6941. clearedlabel_relationships bool
  6942. done bool
  6943. oldValue func(context.Context) (*Label, error)
  6944. predicates []predicate.Label
  6945. }
  6946. var _ ent.Mutation = (*LabelMutation)(nil)
  6947. // labelOption allows management of the mutation configuration using functional options.
  6948. type labelOption func(*LabelMutation)
  6949. // newLabelMutation creates new mutation for the Label entity.
  6950. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  6951. m := &LabelMutation{
  6952. config: c,
  6953. op: op,
  6954. typ: TypeLabel,
  6955. clearedFields: make(map[string]struct{}),
  6956. }
  6957. for _, opt := range opts {
  6958. opt(m)
  6959. }
  6960. return m
  6961. }
  6962. // withLabelID sets the ID field of the mutation.
  6963. func withLabelID(id uint64) labelOption {
  6964. return func(m *LabelMutation) {
  6965. var (
  6966. err error
  6967. once sync.Once
  6968. value *Label
  6969. )
  6970. m.oldValue = func(ctx context.Context) (*Label, error) {
  6971. once.Do(func() {
  6972. if m.done {
  6973. err = errors.New("querying old values post mutation is not allowed")
  6974. } else {
  6975. value, err = m.Client().Label.Get(ctx, id)
  6976. }
  6977. })
  6978. return value, err
  6979. }
  6980. m.id = &id
  6981. }
  6982. }
  6983. // withLabel sets the old Label of the mutation.
  6984. func withLabel(node *Label) labelOption {
  6985. return func(m *LabelMutation) {
  6986. m.oldValue = func(context.Context) (*Label, error) {
  6987. return node, nil
  6988. }
  6989. m.id = &node.ID
  6990. }
  6991. }
  6992. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6993. // executed in a transaction (ent.Tx), a transactional client is returned.
  6994. func (m LabelMutation) Client() *Client {
  6995. client := &Client{config: m.config}
  6996. client.init()
  6997. return client
  6998. }
  6999. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7000. // it returns an error otherwise.
  7001. func (m LabelMutation) Tx() (*Tx, error) {
  7002. if _, ok := m.driver.(*txDriver); !ok {
  7003. return nil, errors.New("ent: mutation is not running in a transaction")
  7004. }
  7005. tx := &Tx{config: m.config}
  7006. tx.init()
  7007. return tx, nil
  7008. }
  7009. // SetID sets the value of the id field. Note that this
  7010. // operation is only accepted on creation of Label entities.
  7011. func (m *LabelMutation) SetID(id uint64) {
  7012. m.id = &id
  7013. }
  7014. // ID returns the ID value in the mutation. Note that the ID is only available
  7015. // if it was provided to the builder or after it was returned from the database.
  7016. func (m *LabelMutation) ID() (id uint64, exists bool) {
  7017. if m.id == nil {
  7018. return
  7019. }
  7020. return *m.id, true
  7021. }
  7022. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7023. // That means, if the mutation is applied within a transaction with an isolation level such
  7024. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7025. // or updated by the mutation.
  7026. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  7027. switch {
  7028. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7029. id, exists := m.ID()
  7030. if exists {
  7031. return []uint64{id}, nil
  7032. }
  7033. fallthrough
  7034. case m.op.Is(OpUpdate | OpDelete):
  7035. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  7036. default:
  7037. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7038. }
  7039. }
  7040. // SetCreatedAt sets the "created_at" field.
  7041. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  7042. m.created_at = &t
  7043. }
  7044. // CreatedAt returns the value of the "created_at" field in the mutation.
  7045. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  7046. v := m.created_at
  7047. if v == nil {
  7048. return
  7049. }
  7050. return *v, true
  7051. }
  7052. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  7053. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7055. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7056. if !m.op.Is(OpUpdateOne) {
  7057. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7058. }
  7059. if m.id == nil || m.oldValue == nil {
  7060. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7061. }
  7062. oldValue, err := m.oldValue(ctx)
  7063. if err != nil {
  7064. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7065. }
  7066. return oldValue.CreatedAt, nil
  7067. }
  7068. // ResetCreatedAt resets all changes to the "created_at" field.
  7069. func (m *LabelMutation) ResetCreatedAt() {
  7070. m.created_at = nil
  7071. }
  7072. // SetUpdatedAt sets the "updated_at" field.
  7073. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  7074. m.updated_at = &t
  7075. }
  7076. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7077. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  7078. v := m.updated_at
  7079. if v == nil {
  7080. return
  7081. }
  7082. return *v, true
  7083. }
  7084. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  7085. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7087. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7088. if !m.op.Is(OpUpdateOne) {
  7089. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7090. }
  7091. if m.id == nil || m.oldValue == nil {
  7092. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7093. }
  7094. oldValue, err := m.oldValue(ctx)
  7095. if err != nil {
  7096. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7097. }
  7098. return oldValue.UpdatedAt, nil
  7099. }
  7100. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7101. func (m *LabelMutation) ResetUpdatedAt() {
  7102. m.updated_at = nil
  7103. }
  7104. // SetStatus sets the "status" field.
  7105. func (m *LabelMutation) SetStatus(u uint8) {
  7106. m.status = &u
  7107. m.addstatus = nil
  7108. }
  7109. // Status returns the value of the "status" field in the mutation.
  7110. func (m *LabelMutation) Status() (r uint8, exists bool) {
  7111. v := m.status
  7112. if v == nil {
  7113. return
  7114. }
  7115. return *v, true
  7116. }
  7117. // OldStatus returns the old "status" field's value of the Label entity.
  7118. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7120. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7121. if !m.op.Is(OpUpdateOne) {
  7122. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7123. }
  7124. if m.id == nil || m.oldValue == nil {
  7125. return v, errors.New("OldStatus requires an ID field in the mutation")
  7126. }
  7127. oldValue, err := m.oldValue(ctx)
  7128. if err != nil {
  7129. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7130. }
  7131. return oldValue.Status, nil
  7132. }
  7133. // AddStatus adds u to the "status" field.
  7134. func (m *LabelMutation) AddStatus(u int8) {
  7135. if m.addstatus != nil {
  7136. *m.addstatus += u
  7137. } else {
  7138. m.addstatus = &u
  7139. }
  7140. }
  7141. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7142. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  7143. v := m.addstatus
  7144. if v == nil {
  7145. return
  7146. }
  7147. return *v, true
  7148. }
  7149. // ClearStatus clears the value of the "status" field.
  7150. func (m *LabelMutation) ClearStatus() {
  7151. m.status = nil
  7152. m.addstatus = nil
  7153. m.clearedFields[label.FieldStatus] = struct{}{}
  7154. }
  7155. // StatusCleared returns if the "status" field was cleared in this mutation.
  7156. func (m *LabelMutation) StatusCleared() bool {
  7157. _, ok := m.clearedFields[label.FieldStatus]
  7158. return ok
  7159. }
  7160. // ResetStatus resets all changes to the "status" field.
  7161. func (m *LabelMutation) ResetStatus() {
  7162. m.status = nil
  7163. m.addstatus = nil
  7164. delete(m.clearedFields, label.FieldStatus)
  7165. }
  7166. // SetType sets the "type" field.
  7167. func (m *LabelMutation) SetType(i int) {
  7168. m._type = &i
  7169. m.add_type = nil
  7170. }
  7171. // GetType returns the value of the "type" field in the mutation.
  7172. func (m *LabelMutation) GetType() (r int, exists bool) {
  7173. v := m._type
  7174. if v == nil {
  7175. return
  7176. }
  7177. return *v, true
  7178. }
  7179. // OldType returns the old "type" field's value of the Label entity.
  7180. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7182. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  7183. if !m.op.Is(OpUpdateOne) {
  7184. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7185. }
  7186. if m.id == nil || m.oldValue == nil {
  7187. return v, errors.New("OldType requires an ID field in the mutation")
  7188. }
  7189. oldValue, err := m.oldValue(ctx)
  7190. if err != nil {
  7191. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7192. }
  7193. return oldValue.Type, nil
  7194. }
  7195. // AddType adds i to the "type" field.
  7196. func (m *LabelMutation) AddType(i int) {
  7197. if m.add_type != nil {
  7198. *m.add_type += i
  7199. } else {
  7200. m.add_type = &i
  7201. }
  7202. }
  7203. // AddedType returns the value that was added to the "type" field in this mutation.
  7204. func (m *LabelMutation) AddedType() (r int, exists bool) {
  7205. v := m.add_type
  7206. if v == nil {
  7207. return
  7208. }
  7209. return *v, true
  7210. }
  7211. // ResetType resets all changes to the "type" field.
  7212. func (m *LabelMutation) ResetType() {
  7213. m._type = nil
  7214. m.add_type = nil
  7215. }
  7216. // SetName sets the "name" field.
  7217. func (m *LabelMutation) SetName(s string) {
  7218. m.name = &s
  7219. }
  7220. // Name returns the value of the "name" field in the mutation.
  7221. func (m *LabelMutation) Name() (r string, exists bool) {
  7222. v := m.name
  7223. if v == nil {
  7224. return
  7225. }
  7226. return *v, true
  7227. }
  7228. // OldName returns the old "name" field's value of the Label entity.
  7229. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7231. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  7232. if !m.op.Is(OpUpdateOne) {
  7233. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7234. }
  7235. if m.id == nil || m.oldValue == nil {
  7236. return v, errors.New("OldName requires an ID field in the mutation")
  7237. }
  7238. oldValue, err := m.oldValue(ctx)
  7239. if err != nil {
  7240. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7241. }
  7242. return oldValue.Name, nil
  7243. }
  7244. // ResetName resets all changes to the "name" field.
  7245. func (m *LabelMutation) ResetName() {
  7246. m.name = nil
  7247. }
  7248. // SetFrom sets the "from" field.
  7249. func (m *LabelMutation) SetFrom(i int) {
  7250. m.from = &i
  7251. m.addfrom = nil
  7252. }
  7253. // From returns the value of the "from" field in the mutation.
  7254. func (m *LabelMutation) From() (r int, exists bool) {
  7255. v := m.from
  7256. if v == nil {
  7257. return
  7258. }
  7259. return *v, true
  7260. }
  7261. // OldFrom returns the old "from" field's value of the Label entity.
  7262. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7264. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  7265. if !m.op.Is(OpUpdateOne) {
  7266. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  7267. }
  7268. if m.id == nil || m.oldValue == nil {
  7269. return v, errors.New("OldFrom requires an ID field in the mutation")
  7270. }
  7271. oldValue, err := m.oldValue(ctx)
  7272. if err != nil {
  7273. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  7274. }
  7275. return oldValue.From, nil
  7276. }
  7277. // AddFrom adds i to the "from" field.
  7278. func (m *LabelMutation) AddFrom(i int) {
  7279. if m.addfrom != nil {
  7280. *m.addfrom += i
  7281. } else {
  7282. m.addfrom = &i
  7283. }
  7284. }
  7285. // AddedFrom returns the value that was added to the "from" field in this mutation.
  7286. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  7287. v := m.addfrom
  7288. if v == nil {
  7289. return
  7290. }
  7291. return *v, true
  7292. }
  7293. // ResetFrom resets all changes to the "from" field.
  7294. func (m *LabelMutation) ResetFrom() {
  7295. m.from = nil
  7296. m.addfrom = nil
  7297. }
  7298. // SetMode sets the "mode" field.
  7299. func (m *LabelMutation) SetMode(i int) {
  7300. m.mode = &i
  7301. m.addmode = nil
  7302. }
  7303. // Mode returns the value of the "mode" field in the mutation.
  7304. func (m *LabelMutation) Mode() (r int, exists bool) {
  7305. v := m.mode
  7306. if v == nil {
  7307. return
  7308. }
  7309. return *v, true
  7310. }
  7311. // OldMode returns the old "mode" field's value of the Label entity.
  7312. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7314. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  7315. if !m.op.Is(OpUpdateOne) {
  7316. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  7317. }
  7318. if m.id == nil || m.oldValue == nil {
  7319. return v, errors.New("OldMode requires an ID field in the mutation")
  7320. }
  7321. oldValue, err := m.oldValue(ctx)
  7322. if err != nil {
  7323. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  7324. }
  7325. return oldValue.Mode, nil
  7326. }
  7327. // AddMode adds i to the "mode" field.
  7328. func (m *LabelMutation) AddMode(i int) {
  7329. if m.addmode != nil {
  7330. *m.addmode += i
  7331. } else {
  7332. m.addmode = &i
  7333. }
  7334. }
  7335. // AddedMode returns the value that was added to the "mode" field in this mutation.
  7336. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  7337. v := m.addmode
  7338. if v == nil {
  7339. return
  7340. }
  7341. return *v, true
  7342. }
  7343. // ResetMode resets all changes to the "mode" field.
  7344. func (m *LabelMutation) ResetMode() {
  7345. m.mode = nil
  7346. m.addmode = nil
  7347. }
  7348. // SetConditions sets the "conditions" field.
  7349. func (m *LabelMutation) SetConditions(s string) {
  7350. m.conditions = &s
  7351. }
  7352. // Conditions returns the value of the "conditions" field in the mutation.
  7353. func (m *LabelMutation) Conditions() (r string, exists bool) {
  7354. v := m.conditions
  7355. if v == nil {
  7356. return
  7357. }
  7358. return *v, true
  7359. }
  7360. // OldConditions returns the old "conditions" field's value of the Label entity.
  7361. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7363. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  7364. if !m.op.Is(OpUpdateOne) {
  7365. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  7366. }
  7367. if m.id == nil || m.oldValue == nil {
  7368. return v, errors.New("OldConditions requires an ID field in the mutation")
  7369. }
  7370. oldValue, err := m.oldValue(ctx)
  7371. if err != nil {
  7372. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  7373. }
  7374. return oldValue.Conditions, nil
  7375. }
  7376. // ClearConditions clears the value of the "conditions" field.
  7377. func (m *LabelMutation) ClearConditions() {
  7378. m.conditions = nil
  7379. m.clearedFields[label.FieldConditions] = struct{}{}
  7380. }
  7381. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  7382. func (m *LabelMutation) ConditionsCleared() bool {
  7383. _, ok := m.clearedFields[label.FieldConditions]
  7384. return ok
  7385. }
  7386. // ResetConditions resets all changes to the "conditions" field.
  7387. func (m *LabelMutation) ResetConditions() {
  7388. m.conditions = nil
  7389. delete(m.clearedFields, label.FieldConditions)
  7390. }
  7391. // SetOrganizationID sets the "organization_id" field.
  7392. func (m *LabelMutation) SetOrganizationID(u uint64) {
  7393. m.organization_id = &u
  7394. m.addorganization_id = nil
  7395. }
  7396. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7397. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  7398. v := m.organization_id
  7399. if v == nil {
  7400. return
  7401. }
  7402. return *v, true
  7403. }
  7404. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  7405. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7407. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7408. if !m.op.Is(OpUpdateOne) {
  7409. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7410. }
  7411. if m.id == nil || m.oldValue == nil {
  7412. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7413. }
  7414. oldValue, err := m.oldValue(ctx)
  7415. if err != nil {
  7416. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7417. }
  7418. return oldValue.OrganizationID, nil
  7419. }
  7420. // AddOrganizationID adds u to the "organization_id" field.
  7421. func (m *LabelMutation) AddOrganizationID(u int64) {
  7422. if m.addorganization_id != nil {
  7423. *m.addorganization_id += u
  7424. } else {
  7425. m.addorganization_id = &u
  7426. }
  7427. }
  7428. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7429. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  7430. v := m.addorganization_id
  7431. if v == nil {
  7432. return
  7433. }
  7434. return *v, true
  7435. }
  7436. // ClearOrganizationID clears the value of the "organization_id" field.
  7437. func (m *LabelMutation) ClearOrganizationID() {
  7438. m.organization_id = nil
  7439. m.addorganization_id = nil
  7440. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  7441. }
  7442. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  7443. func (m *LabelMutation) OrganizationIDCleared() bool {
  7444. _, ok := m.clearedFields[label.FieldOrganizationID]
  7445. return ok
  7446. }
  7447. // ResetOrganizationID resets all changes to the "organization_id" field.
  7448. func (m *LabelMutation) ResetOrganizationID() {
  7449. m.organization_id = nil
  7450. m.addorganization_id = nil
  7451. delete(m.clearedFields, label.FieldOrganizationID)
  7452. }
  7453. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  7454. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  7455. if m.label_relationships == nil {
  7456. m.label_relationships = make(map[uint64]struct{})
  7457. }
  7458. for i := range ids {
  7459. m.label_relationships[ids[i]] = struct{}{}
  7460. }
  7461. }
  7462. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  7463. func (m *LabelMutation) ClearLabelRelationships() {
  7464. m.clearedlabel_relationships = true
  7465. }
  7466. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  7467. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  7468. return m.clearedlabel_relationships
  7469. }
  7470. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  7471. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  7472. if m.removedlabel_relationships == nil {
  7473. m.removedlabel_relationships = make(map[uint64]struct{})
  7474. }
  7475. for i := range ids {
  7476. delete(m.label_relationships, ids[i])
  7477. m.removedlabel_relationships[ids[i]] = struct{}{}
  7478. }
  7479. }
  7480. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  7481. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  7482. for id := range m.removedlabel_relationships {
  7483. ids = append(ids, id)
  7484. }
  7485. return
  7486. }
  7487. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  7488. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  7489. for id := range m.label_relationships {
  7490. ids = append(ids, id)
  7491. }
  7492. return
  7493. }
  7494. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  7495. func (m *LabelMutation) ResetLabelRelationships() {
  7496. m.label_relationships = nil
  7497. m.clearedlabel_relationships = false
  7498. m.removedlabel_relationships = nil
  7499. }
  7500. // Where appends a list predicates to the LabelMutation builder.
  7501. func (m *LabelMutation) Where(ps ...predicate.Label) {
  7502. m.predicates = append(m.predicates, ps...)
  7503. }
  7504. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  7505. // users can use type-assertion to append predicates that do not depend on any generated package.
  7506. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  7507. p := make([]predicate.Label, len(ps))
  7508. for i := range ps {
  7509. p[i] = ps[i]
  7510. }
  7511. m.Where(p...)
  7512. }
  7513. // Op returns the operation name.
  7514. func (m *LabelMutation) Op() Op {
  7515. return m.op
  7516. }
  7517. // SetOp allows setting the mutation operation.
  7518. func (m *LabelMutation) SetOp(op Op) {
  7519. m.op = op
  7520. }
  7521. // Type returns the node type of this mutation (Label).
  7522. func (m *LabelMutation) Type() string {
  7523. return m.typ
  7524. }
  7525. // Fields returns all fields that were changed during this mutation. Note that in
  7526. // order to get all numeric fields that were incremented/decremented, call
  7527. // AddedFields().
  7528. func (m *LabelMutation) Fields() []string {
  7529. fields := make([]string, 0, 9)
  7530. if m.created_at != nil {
  7531. fields = append(fields, label.FieldCreatedAt)
  7532. }
  7533. if m.updated_at != nil {
  7534. fields = append(fields, label.FieldUpdatedAt)
  7535. }
  7536. if m.status != nil {
  7537. fields = append(fields, label.FieldStatus)
  7538. }
  7539. if m._type != nil {
  7540. fields = append(fields, label.FieldType)
  7541. }
  7542. if m.name != nil {
  7543. fields = append(fields, label.FieldName)
  7544. }
  7545. if m.from != nil {
  7546. fields = append(fields, label.FieldFrom)
  7547. }
  7548. if m.mode != nil {
  7549. fields = append(fields, label.FieldMode)
  7550. }
  7551. if m.conditions != nil {
  7552. fields = append(fields, label.FieldConditions)
  7553. }
  7554. if m.organization_id != nil {
  7555. fields = append(fields, label.FieldOrganizationID)
  7556. }
  7557. return fields
  7558. }
  7559. // Field returns the value of a field with the given name. The second boolean
  7560. // return value indicates that this field was not set, or was not defined in the
  7561. // schema.
  7562. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  7563. switch name {
  7564. case label.FieldCreatedAt:
  7565. return m.CreatedAt()
  7566. case label.FieldUpdatedAt:
  7567. return m.UpdatedAt()
  7568. case label.FieldStatus:
  7569. return m.Status()
  7570. case label.FieldType:
  7571. return m.GetType()
  7572. case label.FieldName:
  7573. return m.Name()
  7574. case label.FieldFrom:
  7575. return m.From()
  7576. case label.FieldMode:
  7577. return m.Mode()
  7578. case label.FieldConditions:
  7579. return m.Conditions()
  7580. case label.FieldOrganizationID:
  7581. return m.OrganizationID()
  7582. }
  7583. return nil, false
  7584. }
  7585. // OldField returns the old value of the field from the database. An error is
  7586. // returned if the mutation operation is not UpdateOne, or the query to the
  7587. // database failed.
  7588. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7589. switch name {
  7590. case label.FieldCreatedAt:
  7591. return m.OldCreatedAt(ctx)
  7592. case label.FieldUpdatedAt:
  7593. return m.OldUpdatedAt(ctx)
  7594. case label.FieldStatus:
  7595. return m.OldStatus(ctx)
  7596. case label.FieldType:
  7597. return m.OldType(ctx)
  7598. case label.FieldName:
  7599. return m.OldName(ctx)
  7600. case label.FieldFrom:
  7601. return m.OldFrom(ctx)
  7602. case label.FieldMode:
  7603. return m.OldMode(ctx)
  7604. case label.FieldConditions:
  7605. return m.OldConditions(ctx)
  7606. case label.FieldOrganizationID:
  7607. return m.OldOrganizationID(ctx)
  7608. }
  7609. return nil, fmt.Errorf("unknown Label field %s", name)
  7610. }
  7611. // SetField sets the value of a field with the given name. It returns an error if
  7612. // the field is not defined in the schema, or if the type mismatched the field
  7613. // type.
  7614. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  7615. switch name {
  7616. case label.FieldCreatedAt:
  7617. v, ok := value.(time.Time)
  7618. if !ok {
  7619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7620. }
  7621. m.SetCreatedAt(v)
  7622. return nil
  7623. case label.FieldUpdatedAt:
  7624. v, ok := value.(time.Time)
  7625. if !ok {
  7626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7627. }
  7628. m.SetUpdatedAt(v)
  7629. return nil
  7630. case label.FieldStatus:
  7631. v, ok := value.(uint8)
  7632. if !ok {
  7633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7634. }
  7635. m.SetStatus(v)
  7636. return nil
  7637. case label.FieldType:
  7638. v, ok := value.(int)
  7639. if !ok {
  7640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7641. }
  7642. m.SetType(v)
  7643. return nil
  7644. case label.FieldName:
  7645. v, ok := value.(string)
  7646. if !ok {
  7647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7648. }
  7649. m.SetName(v)
  7650. return nil
  7651. case label.FieldFrom:
  7652. v, ok := value.(int)
  7653. if !ok {
  7654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7655. }
  7656. m.SetFrom(v)
  7657. return nil
  7658. case label.FieldMode:
  7659. v, ok := value.(int)
  7660. if !ok {
  7661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7662. }
  7663. m.SetMode(v)
  7664. return nil
  7665. case label.FieldConditions:
  7666. v, ok := value.(string)
  7667. if !ok {
  7668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7669. }
  7670. m.SetConditions(v)
  7671. return nil
  7672. case label.FieldOrganizationID:
  7673. v, ok := value.(uint64)
  7674. if !ok {
  7675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7676. }
  7677. m.SetOrganizationID(v)
  7678. return nil
  7679. }
  7680. return fmt.Errorf("unknown Label field %s", name)
  7681. }
  7682. // AddedFields returns all numeric fields that were incremented/decremented during
  7683. // this mutation.
  7684. func (m *LabelMutation) AddedFields() []string {
  7685. var fields []string
  7686. if m.addstatus != nil {
  7687. fields = append(fields, label.FieldStatus)
  7688. }
  7689. if m.add_type != nil {
  7690. fields = append(fields, label.FieldType)
  7691. }
  7692. if m.addfrom != nil {
  7693. fields = append(fields, label.FieldFrom)
  7694. }
  7695. if m.addmode != nil {
  7696. fields = append(fields, label.FieldMode)
  7697. }
  7698. if m.addorganization_id != nil {
  7699. fields = append(fields, label.FieldOrganizationID)
  7700. }
  7701. return fields
  7702. }
  7703. // AddedField returns the numeric value that was incremented/decremented on a field
  7704. // with the given name. The second boolean return value indicates that this field
  7705. // was not set, or was not defined in the schema.
  7706. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  7707. switch name {
  7708. case label.FieldStatus:
  7709. return m.AddedStatus()
  7710. case label.FieldType:
  7711. return m.AddedType()
  7712. case label.FieldFrom:
  7713. return m.AddedFrom()
  7714. case label.FieldMode:
  7715. return m.AddedMode()
  7716. case label.FieldOrganizationID:
  7717. return m.AddedOrganizationID()
  7718. }
  7719. return nil, false
  7720. }
  7721. // AddField adds the value to the field with the given name. It returns an error if
  7722. // the field is not defined in the schema, or if the type mismatched the field
  7723. // type.
  7724. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  7725. switch name {
  7726. case label.FieldStatus:
  7727. v, ok := value.(int8)
  7728. if !ok {
  7729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7730. }
  7731. m.AddStatus(v)
  7732. return nil
  7733. case label.FieldType:
  7734. v, ok := value.(int)
  7735. if !ok {
  7736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7737. }
  7738. m.AddType(v)
  7739. return nil
  7740. case label.FieldFrom:
  7741. v, ok := value.(int)
  7742. if !ok {
  7743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7744. }
  7745. m.AddFrom(v)
  7746. return nil
  7747. case label.FieldMode:
  7748. v, ok := value.(int)
  7749. if !ok {
  7750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7751. }
  7752. m.AddMode(v)
  7753. return nil
  7754. case label.FieldOrganizationID:
  7755. v, ok := value.(int64)
  7756. if !ok {
  7757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7758. }
  7759. m.AddOrganizationID(v)
  7760. return nil
  7761. }
  7762. return fmt.Errorf("unknown Label numeric field %s", name)
  7763. }
  7764. // ClearedFields returns all nullable fields that were cleared during this
  7765. // mutation.
  7766. func (m *LabelMutation) ClearedFields() []string {
  7767. var fields []string
  7768. if m.FieldCleared(label.FieldStatus) {
  7769. fields = append(fields, label.FieldStatus)
  7770. }
  7771. if m.FieldCleared(label.FieldConditions) {
  7772. fields = append(fields, label.FieldConditions)
  7773. }
  7774. if m.FieldCleared(label.FieldOrganizationID) {
  7775. fields = append(fields, label.FieldOrganizationID)
  7776. }
  7777. return fields
  7778. }
  7779. // FieldCleared returns a boolean indicating if a field with the given name was
  7780. // cleared in this mutation.
  7781. func (m *LabelMutation) FieldCleared(name string) bool {
  7782. _, ok := m.clearedFields[name]
  7783. return ok
  7784. }
  7785. // ClearField clears the value of the field with the given name. It returns an
  7786. // error if the field is not defined in the schema.
  7787. func (m *LabelMutation) ClearField(name string) error {
  7788. switch name {
  7789. case label.FieldStatus:
  7790. m.ClearStatus()
  7791. return nil
  7792. case label.FieldConditions:
  7793. m.ClearConditions()
  7794. return nil
  7795. case label.FieldOrganizationID:
  7796. m.ClearOrganizationID()
  7797. return nil
  7798. }
  7799. return fmt.Errorf("unknown Label nullable field %s", name)
  7800. }
  7801. // ResetField resets all changes in the mutation for the field with the given name.
  7802. // It returns an error if the field is not defined in the schema.
  7803. func (m *LabelMutation) ResetField(name string) error {
  7804. switch name {
  7805. case label.FieldCreatedAt:
  7806. m.ResetCreatedAt()
  7807. return nil
  7808. case label.FieldUpdatedAt:
  7809. m.ResetUpdatedAt()
  7810. return nil
  7811. case label.FieldStatus:
  7812. m.ResetStatus()
  7813. return nil
  7814. case label.FieldType:
  7815. m.ResetType()
  7816. return nil
  7817. case label.FieldName:
  7818. m.ResetName()
  7819. return nil
  7820. case label.FieldFrom:
  7821. m.ResetFrom()
  7822. return nil
  7823. case label.FieldMode:
  7824. m.ResetMode()
  7825. return nil
  7826. case label.FieldConditions:
  7827. m.ResetConditions()
  7828. return nil
  7829. case label.FieldOrganizationID:
  7830. m.ResetOrganizationID()
  7831. return nil
  7832. }
  7833. return fmt.Errorf("unknown Label field %s", name)
  7834. }
  7835. // AddedEdges returns all edge names that were set/added in this mutation.
  7836. func (m *LabelMutation) AddedEdges() []string {
  7837. edges := make([]string, 0, 1)
  7838. if m.label_relationships != nil {
  7839. edges = append(edges, label.EdgeLabelRelationships)
  7840. }
  7841. return edges
  7842. }
  7843. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7844. // name in this mutation.
  7845. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  7846. switch name {
  7847. case label.EdgeLabelRelationships:
  7848. ids := make([]ent.Value, 0, len(m.label_relationships))
  7849. for id := range m.label_relationships {
  7850. ids = append(ids, id)
  7851. }
  7852. return ids
  7853. }
  7854. return nil
  7855. }
  7856. // RemovedEdges returns all edge names that were removed in this mutation.
  7857. func (m *LabelMutation) RemovedEdges() []string {
  7858. edges := make([]string, 0, 1)
  7859. if m.removedlabel_relationships != nil {
  7860. edges = append(edges, label.EdgeLabelRelationships)
  7861. }
  7862. return edges
  7863. }
  7864. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7865. // the given name in this mutation.
  7866. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  7867. switch name {
  7868. case label.EdgeLabelRelationships:
  7869. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  7870. for id := range m.removedlabel_relationships {
  7871. ids = append(ids, id)
  7872. }
  7873. return ids
  7874. }
  7875. return nil
  7876. }
  7877. // ClearedEdges returns all edge names that were cleared in this mutation.
  7878. func (m *LabelMutation) ClearedEdges() []string {
  7879. edges := make([]string, 0, 1)
  7880. if m.clearedlabel_relationships {
  7881. edges = append(edges, label.EdgeLabelRelationships)
  7882. }
  7883. return edges
  7884. }
  7885. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7886. // was cleared in this mutation.
  7887. func (m *LabelMutation) EdgeCleared(name string) bool {
  7888. switch name {
  7889. case label.EdgeLabelRelationships:
  7890. return m.clearedlabel_relationships
  7891. }
  7892. return false
  7893. }
  7894. // ClearEdge clears the value of the edge with the given name. It returns an error
  7895. // if that edge is not defined in the schema.
  7896. func (m *LabelMutation) ClearEdge(name string) error {
  7897. switch name {
  7898. }
  7899. return fmt.Errorf("unknown Label unique edge %s", name)
  7900. }
  7901. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7902. // It returns an error if the edge is not defined in the schema.
  7903. func (m *LabelMutation) ResetEdge(name string) error {
  7904. switch name {
  7905. case label.EdgeLabelRelationships:
  7906. m.ResetLabelRelationships()
  7907. return nil
  7908. }
  7909. return fmt.Errorf("unknown Label edge %s", name)
  7910. }
  7911. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  7912. type LabelRelationshipMutation struct {
  7913. config
  7914. op Op
  7915. typ string
  7916. id *uint64
  7917. created_at *time.Time
  7918. updated_at *time.Time
  7919. status *uint8
  7920. addstatus *int8
  7921. deleted_at *time.Time
  7922. organization_id *uint64
  7923. addorganization_id *int64
  7924. clearedFields map[string]struct{}
  7925. contacts *uint64
  7926. clearedcontacts bool
  7927. labels *uint64
  7928. clearedlabels bool
  7929. done bool
  7930. oldValue func(context.Context) (*LabelRelationship, error)
  7931. predicates []predicate.LabelRelationship
  7932. }
  7933. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  7934. // labelrelationshipOption allows management of the mutation configuration using functional options.
  7935. type labelrelationshipOption func(*LabelRelationshipMutation)
  7936. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  7937. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  7938. m := &LabelRelationshipMutation{
  7939. config: c,
  7940. op: op,
  7941. typ: TypeLabelRelationship,
  7942. clearedFields: make(map[string]struct{}),
  7943. }
  7944. for _, opt := range opts {
  7945. opt(m)
  7946. }
  7947. return m
  7948. }
  7949. // withLabelRelationshipID sets the ID field of the mutation.
  7950. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  7951. return func(m *LabelRelationshipMutation) {
  7952. var (
  7953. err error
  7954. once sync.Once
  7955. value *LabelRelationship
  7956. )
  7957. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  7958. once.Do(func() {
  7959. if m.done {
  7960. err = errors.New("querying old values post mutation is not allowed")
  7961. } else {
  7962. value, err = m.Client().LabelRelationship.Get(ctx, id)
  7963. }
  7964. })
  7965. return value, err
  7966. }
  7967. m.id = &id
  7968. }
  7969. }
  7970. // withLabelRelationship sets the old LabelRelationship of the mutation.
  7971. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  7972. return func(m *LabelRelationshipMutation) {
  7973. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  7974. return node, nil
  7975. }
  7976. m.id = &node.ID
  7977. }
  7978. }
  7979. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7980. // executed in a transaction (ent.Tx), a transactional client is returned.
  7981. func (m LabelRelationshipMutation) Client() *Client {
  7982. client := &Client{config: m.config}
  7983. client.init()
  7984. return client
  7985. }
  7986. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7987. // it returns an error otherwise.
  7988. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  7989. if _, ok := m.driver.(*txDriver); !ok {
  7990. return nil, errors.New("ent: mutation is not running in a transaction")
  7991. }
  7992. tx := &Tx{config: m.config}
  7993. tx.init()
  7994. return tx, nil
  7995. }
  7996. // SetID sets the value of the id field. Note that this
  7997. // operation is only accepted on creation of LabelRelationship entities.
  7998. func (m *LabelRelationshipMutation) SetID(id uint64) {
  7999. m.id = &id
  8000. }
  8001. // ID returns the ID value in the mutation. Note that the ID is only available
  8002. // if it was provided to the builder or after it was returned from the database.
  8003. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  8004. if m.id == nil {
  8005. return
  8006. }
  8007. return *m.id, true
  8008. }
  8009. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8010. // That means, if the mutation is applied within a transaction with an isolation level such
  8011. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8012. // or updated by the mutation.
  8013. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  8014. switch {
  8015. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8016. id, exists := m.ID()
  8017. if exists {
  8018. return []uint64{id}, nil
  8019. }
  8020. fallthrough
  8021. case m.op.Is(OpUpdate | OpDelete):
  8022. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  8023. default:
  8024. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8025. }
  8026. }
  8027. // SetCreatedAt sets the "created_at" field.
  8028. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  8029. m.created_at = &t
  8030. }
  8031. // CreatedAt returns the value of the "created_at" field in the mutation.
  8032. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  8033. v := m.created_at
  8034. if v == nil {
  8035. return
  8036. }
  8037. return *v, true
  8038. }
  8039. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  8040. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8042. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8043. if !m.op.Is(OpUpdateOne) {
  8044. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8045. }
  8046. if m.id == nil || m.oldValue == nil {
  8047. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8048. }
  8049. oldValue, err := m.oldValue(ctx)
  8050. if err != nil {
  8051. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8052. }
  8053. return oldValue.CreatedAt, nil
  8054. }
  8055. // ResetCreatedAt resets all changes to the "created_at" field.
  8056. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  8057. m.created_at = nil
  8058. }
  8059. // SetUpdatedAt sets the "updated_at" field.
  8060. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  8061. m.updated_at = &t
  8062. }
  8063. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8064. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  8065. v := m.updated_at
  8066. if v == nil {
  8067. return
  8068. }
  8069. return *v, true
  8070. }
  8071. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  8072. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8074. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8075. if !m.op.Is(OpUpdateOne) {
  8076. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8077. }
  8078. if m.id == nil || m.oldValue == nil {
  8079. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8080. }
  8081. oldValue, err := m.oldValue(ctx)
  8082. if err != nil {
  8083. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8084. }
  8085. return oldValue.UpdatedAt, nil
  8086. }
  8087. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8088. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  8089. m.updated_at = nil
  8090. }
  8091. // SetStatus sets the "status" field.
  8092. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  8093. m.status = &u
  8094. m.addstatus = nil
  8095. }
  8096. // Status returns the value of the "status" field in the mutation.
  8097. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  8098. v := m.status
  8099. if v == nil {
  8100. return
  8101. }
  8102. return *v, true
  8103. }
  8104. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  8105. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8107. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  8108. if !m.op.Is(OpUpdateOne) {
  8109. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  8110. }
  8111. if m.id == nil || m.oldValue == nil {
  8112. return v, errors.New("OldStatus requires an ID field in the mutation")
  8113. }
  8114. oldValue, err := m.oldValue(ctx)
  8115. if err != nil {
  8116. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  8117. }
  8118. return oldValue.Status, nil
  8119. }
  8120. // AddStatus adds u to the "status" field.
  8121. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  8122. if m.addstatus != nil {
  8123. *m.addstatus += u
  8124. } else {
  8125. m.addstatus = &u
  8126. }
  8127. }
  8128. // AddedStatus returns the value that was added to the "status" field in this mutation.
  8129. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  8130. v := m.addstatus
  8131. if v == nil {
  8132. return
  8133. }
  8134. return *v, true
  8135. }
  8136. // ClearStatus clears the value of the "status" field.
  8137. func (m *LabelRelationshipMutation) ClearStatus() {
  8138. m.status = nil
  8139. m.addstatus = nil
  8140. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  8141. }
  8142. // StatusCleared returns if the "status" field was cleared in this mutation.
  8143. func (m *LabelRelationshipMutation) StatusCleared() bool {
  8144. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  8145. return ok
  8146. }
  8147. // ResetStatus resets all changes to the "status" field.
  8148. func (m *LabelRelationshipMutation) ResetStatus() {
  8149. m.status = nil
  8150. m.addstatus = nil
  8151. delete(m.clearedFields, labelrelationship.FieldStatus)
  8152. }
  8153. // SetDeletedAt sets the "deleted_at" field.
  8154. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  8155. m.deleted_at = &t
  8156. }
  8157. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8158. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  8159. v := m.deleted_at
  8160. if v == nil {
  8161. return
  8162. }
  8163. return *v, true
  8164. }
  8165. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  8166. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8167. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8168. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8169. if !m.op.Is(OpUpdateOne) {
  8170. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8171. }
  8172. if m.id == nil || m.oldValue == nil {
  8173. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8174. }
  8175. oldValue, err := m.oldValue(ctx)
  8176. if err != nil {
  8177. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8178. }
  8179. return oldValue.DeletedAt, nil
  8180. }
  8181. // ClearDeletedAt clears the value of the "deleted_at" field.
  8182. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  8183. m.deleted_at = nil
  8184. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  8185. }
  8186. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8187. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  8188. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  8189. return ok
  8190. }
  8191. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8192. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  8193. m.deleted_at = nil
  8194. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  8195. }
  8196. // SetLabelID sets the "label_id" field.
  8197. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  8198. m.labels = &u
  8199. }
  8200. // LabelID returns the value of the "label_id" field in the mutation.
  8201. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  8202. v := m.labels
  8203. if v == nil {
  8204. return
  8205. }
  8206. return *v, true
  8207. }
  8208. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  8209. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8211. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  8212. if !m.op.Is(OpUpdateOne) {
  8213. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  8214. }
  8215. if m.id == nil || m.oldValue == nil {
  8216. return v, errors.New("OldLabelID requires an ID field in the mutation")
  8217. }
  8218. oldValue, err := m.oldValue(ctx)
  8219. if err != nil {
  8220. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  8221. }
  8222. return oldValue.LabelID, nil
  8223. }
  8224. // ResetLabelID resets all changes to the "label_id" field.
  8225. func (m *LabelRelationshipMutation) ResetLabelID() {
  8226. m.labels = nil
  8227. }
  8228. // SetContactID sets the "contact_id" field.
  8229. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  8230. m.contacts = &u
  8231. }
  8232. // ContactID returns the value of the "contact_id" field in the mutation.
  8233. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  8234. v := m.contacts
  8235. if v == nil {
  8236. return
  8237. }
  8238. return *v, true
  8239. }
  8240. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  8241. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8243. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  8244. if !m.op.Is(OpUpdateOne) {
  8245. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  8246. }
  8247. if m.id == nil || m.oldValue == nil {
  8248. return v, errors.New("OldContactID requires an ID field in the mutation")
  8249. }
  8250. oldValue, err := m.oldValue(ctx)
  8251. if err != nil {
  8252. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  8253. }
  8254. return oldValue.ContactID, nil
  8255. }
  8256. // ResetContactID resets all changes to the "contact_id" field.
  8257. func (m *LabelRelationshipMutation) ResetContactID() {
  8258. m.contacts = nil
  8259. }
  8260. // SetOrganizationID sets the "organization_id" field.
  8261. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  8262. m.organization_id = &u
  8263. m.addorganization_id = nil
  8264. }
  8265. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8266. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  8267. v := m.organization_id
  8268. if v == nil {
  8269. return
  8270. }
  8271. return *v, true
  8272. }
  8273. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  8274. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8276. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8277. if !m.op.Is(OpUpdateOne) {
  8278. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8279. }
  8280. if m.id == nil || m.oldValue == nil {
  8281. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8282. }
  8283. oldValue, err := m.oldValue(ctx)
  8284. if err != nil {
  8285. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8286. }
  8287. return oldValue.OrganizationID, nil
  8288. }
  8289. // AddOrganizationID adds u to the "organization_id" field.
  8290. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  8291. if m.addorganization_id != nil {
  8292. *m.addorganization_id += u
  8293. } else {
  8294. m.addorganization_id = &u
  8295. }
  8296. }
  8297. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8298. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  8299. v := m.addorganization_id
  8300. if v == nil {
  8301. return
  8302. }
  8303. return *v, true
  8304. }
  8305. // ClearOrganizationID clears the value of the "organization_id" field.
  8306. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  8307. m.organization_id = nil
  8308. m.addorganization_id = nil
  8309. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  8310. }
  8311. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  8312. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  8313. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  8314. return ok
  8315. }
  8316. // ResetOrganizationID resets all changes to the "organization_id" field.
  8317. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  8318. m.organization_id = nil
  8319. m.addorganization_id = nil
  8320. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  8321. }
  8322. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  8323. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  8324. m.contacts = &id
  8325. }
  8326. // ClearContacts clears the "contacts" edge to the Contact entity.
  8327. func (m *LabelRelationshipMutation) ClearContacts() {
  8328. m.clearedcontacts = true
  8329. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  8330. }
  8331. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  8332. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  8333. return m.clearedcontacts
  8334. }
  8335. // ContactsID returns the "contacts" edge ID in the mutation.
  8336. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  8337. if m.contacts != nil {
  8338. return *m.contacts, true
  8339. }
  8340. return
  8341. }
  8342. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  8343. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  8344. // ContactsID instead. It exists only for internal usage by the builders.
  8345. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  8346. if id := m.contacts; id != nil {
  8347. ids = append(ids, *id)
  8348. }
  8349. return
  8350. }
  8351. // ResetContacts resets all changes to the "contacts" edge.
  8352. func (m *LabelRelationshipMutation) ResetContacts() {
  8353. m.contacts = nil
  8354. m.clearedcontacts = false
  8355. }
  8356. // SetLabelsID sets the "labels" edge to the Label entity by id.
  8357. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  8358. m.labels = &id
  8359. }
  8360. // ClearLabels clears the "labels" edge to the Label entity.
  8361. func (m *LabelRelationshipMutation) ClearLabels() {
  8362. m.clearedlabels = true
  8363. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  8364. }
  8365. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  8366. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  8367. return m.clearedlabels
  8368. }
  8369. // LabelsID returns the "labels" edge ID in the mutation.
  8370. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  8371. if m.labels != nil {
  8372. return *m.labels, true
  8373. }
  8374. return
  8375. }
  8376. // LabelsIDs returns the "labels" edge IDs in the mutation.
  8377. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  8378. // LabelsID instead. It exists only for internal usage by the builders.
  8379. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  8380. if id := m.labels; id != nil {
  8381. ids = append(ids, *id)
  8382. }
  8383. return
  8384. }
  8385. // ResetLabels resets all changes to the "labels" edge.
  8386. func (m *LabelRelationshipMutation) ResetLabels() {
  8387. m.labels = nil
  8388. m.clearedlabels = false
  8389. }
  8390. // Where appends a list predicates to the LabelRelationshipMutation builder.
  8391. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  8392. m.predicates = append(m.predicates, ps...)
  8393. }
  8394. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  8395. // users can use type-assertion to append predicates that do not depend on any generated package.
  8396. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  8397. p := make([]predicate.LabelRelationship, len(ps))
  8398. for i := range ps {
  8399. p[i] = ps[i]
  8400. }
  8401. m.Where(p...)
  8402. }
  8403. // Op returns the operation name.
  8404. func (m *LabelRelationshipMutation) Op() Op {
  8405. return m.op
  8406. }
  8407. // SetOp allows setting the mutation operation.
  8408. func (m *LabelRelationshipMutation) SetOp(op Op) {
  8409. m.op = op
  8410. }
  8411. // Type returns the node type of this mutation (LabelRelationship).
  8412. func (m *LabelRelationshipMutation) Type() string {
  8413. return m.typ
  8414. }
  8415. // Fields returns all fields that were changed during this mutation. Note that in
  8416. // order to get all numeric fields that were incremented/decremented, call
  8417. // AddedFields().
  8418. func (m *LabelRelationshipMutation) Fields() []string {
  8419. fields := make([]string, 0, 7)
  8420. if m.created_at != nil {
  8421. fields = append(fields, labelrelationship.FieldCreatedAt)
  8422. }
  8423. if m.updated_at != nil {
  8424. fields = append(fields, labelrelationship.FieldUpdatedAt)
  8425. }
  8426. if m.status != nil {
  8427. fields = append(fields, labelrelationship.FieldStatus)
  8428. }
  8429. if m.deleted_at != nil {
  8430. fields = append(fields, labelrelationship.FieldDeletedAt)
  8431. }
  8432. if m.labels != nil {
  8433. fields = append(fields, labelrelationship.FieldLabelID)
  8434. }
  8435. if m.contacts != nil {
  8436. fields = append(fields, labelrelationship.FieldContactID)
  8437. }
  8438. if m.organization_id != nil {
  8439. fields = append(fields, labelrelationship.FieldOrganizationID)
  8440. }
  8441. return fields
  8442. }
  8443. // Field returns the value of a field with the given name. The second boolean
  8444. // return value indicates that this field was not set, or was not defined in the
  8445. // schema.
  8446. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  8447. switch name {
  8448. case labelrelationship.FieldCreatedAt:
  8449. return m.CreatedAt()
  8450. case labelrelationship.FieldUpdatedAt:
  8451. return m.UpdatedAt()
  8452. case labelrelationship.FieldStatus:
  8453. return m.Status()
  8454. case labelrelationship.FieldDeletedAt:
  8455. return m.DeletedAt()
  8456. case labelrelationship.FieldLabelID:
  8457. return m.LabelID()
  8458. case labelrelationship.FieldContactID:
  8459. return m.ContactID()
  8460. case labelrelationship.FieldOrganizationID:
  8461. return m.OrganizationID()
  8462. }
  8463. return nil, false
  8464. }
  8465. // OldField returns the old value of the field from the database. An error is
  8466. // returned if the mutation operation is not UpdateOne, or the query to the
  8467. // database failed.
  8468. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8469. switch name {
  8470. case labelrelationship.FieldCreatedAt:
  8471. return m.OldCreatedAt(ctx)
  8472. case labelrelationship.FieldUpdatedAt:
  8473. return m.OldUpdatedAt(ctx)
  8474. case labelrelationship.FieldStatus:
  8475. return m.OldStatus(ctx)
  8476. case labelrelationship.FieldDeletedAt:
  8477. return m.OldDeletedAt(ctx)
  8478. case labelrelationship.FieldLabelID:
  8479. return m.OldLabelID(ctx)
  8480. case labelrelationship.FieldContactID:
  8481. return m.OldContactID(ctx)
  8482. case labelrelationship.FieldOrganizationID:
  8483. return m.OldOrganizationID(ctx)
  8484. }
  8485. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  8486. }
  8487. // SetField sets the value of a field with the given name. It returns an error if
  8488. // the field is not defined in the schema, or if the type mismatched the field
  8489. // type.
  8490. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  8491. switch name {
  8492. case labelrelationship.FieldCreatedAt:
  8493. v, ok := value.(time.Time)
  8494. if !ok {
  8495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8496. }
  8497. m.SetCreatedAt(v)
  8498. return nil
  8499. case labelrelationship.FieldUpdatedAt:
  8500. v, ok := value.(time.Time)
  8501. if !ok {
  8502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8503. }
  8504. m.SetUpdatedAt(v)
  8505. return nil
  8506. case labelrelationship.FieldStatus:
  8507. v, ok := value.(uint8)
  8508. if !ok {
  8509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8510. }
  8511. m.SetStatus(v)
  8512. return nil
  8513. case labelrelationship.FieldDeletedAt:
  8514. v, ok := value.(time.Time)
  8515. if !ok {
  8516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8517. }
  8518. m.SetDeletedAt(v)
  8519. return nil
  8520. case labelrelationship.FieldLabelID:
  8521. v, ok := value.(uint64)
  8522. if !ok {
  8523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8524. }
  8525. m.SetLabelID(v)
  8526. return nil
  8527. case labelrelationship.FieldContactID:
  8528. v, ok := value.(uint64)
  8529. if !ok {
  8530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8531. }
  8532. m.SetContactID(v)
  8533. return nil
  8534. case labelrelationship.FieldOrganizationID:
  8535. v, ok := value.(uint64)
  8536. if !ok {
  8537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8538. }
  8539. m.SetOrganizationID(v)
  8540. return nil
  8541. }
  8542. return fmt.Errorf("unknown LabelRelationship field %s", name)
  8543. }
  8544. // AddedFields returns all numeric fields that were incremented/decremented during
  8545. // this mutation.
  8546. func (m *LabelRelationshipMutation) AddedFields() []string {
  8547. var fields []string
  8548. if m.addstatus != nil {
  8549. fields = append(fields, labelrelationship.FieldStatus)
  8550. }
  8551. if m.addorganization_id != nil {
  8552. fields = append(fields, labelrelationship.FieldOrganizationID)
  8553. }
  8554. return fields
  8555. }
  8556. // AddedField returns the numeric value that was incremented/decremented on a field
  8557. // with the given name. The second boolean return value indicates that this field
  8558. // was not set, or was not defined in the schema.
  8559. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  8560. switch name {
  8561. case labelrelationship.FieldStatus:
  8562. return m.AddedStatus()
  8563. case labelrelationship.FieldOrganizationID:
  8564. return m.AddedOrganizationID()
  8565. }
  8566. return nil, false
  8567. }
  8568. // AddField adds the value to the field with the given name. It returns an error if
  8569. // the field is not defined in the schema, or if the type mismatched the field
  8570. // type.
  8571. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  8572. switch name {
  8573. case labelrelationship.FieldStatus:
  8574. v, ok := value.(int8)
  8575. if !ok {
  8576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8577. }
  8578. m.AddStatus(v)
  8579. return nil
  8580. case labelrelationship.FieldOrganizationID:
  8581. v, ok := value.(int64)
  8582. if !ok {
  8583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8584. }
  8585. m.AddOrganizationID(v)
  8586. return nil
  8587. }
  8588. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  8589. }
  8590. // ClearedFields returns all nullable fields that were cleared during this
  8591. // mutation.
  8592. func (m *LabelRelationshipMutation) ClearedFields() []string {
  8593. var fields []string
  8594. if m.FieldCleared(labelrelationship.FieldStatus) {
  8595. fields = append(fields, labelrelationship.FieldStatus)
  8596. }
  8597. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  8598. fields = append(fields, labelrelationship.FieldDeletedAt)
  8599. }
  8600. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  8601. fields = append(fields, labelrelationship.FieldOrganizationID)
  8602. }
  8603. return fields
  8604. }
  8605. // FieldCleared returns a boolean indicating if a field with the given name was
  8606. // cleared in this mutation.
  8607. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  8608. _, ok := m.clearedFields[name]
  8609. return ok
  8610. }
  8611. // ClearField clears the value of the field with the given name. It returns an
  8612. // error if the field is not defined in the schema.
  8613. func (m *LabelRelationshipMutation) ClearField(name string) error {
  8614. switch name {
  8615. case labelrelationship.FieldStatus:
  8616. m.ClearStatus()
  8617. return nil
  8618. case labelrelationship.FieldDeletedAt:
  8619. m.ClearDeletedAt()
  8620. return nil
  8621. case labelrelationship.FieldOrganizationID:
  8622. m.ClearOrganizationID()
  8623. return nil
  8624. }
  8625. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  8626. }
  8627. // ResetField resets all changes in the mutation for the field with the given name.
  8628. // It returns an error if the field is not defined in the schema.
  8629. func (m *LabelRelationshipMutation) ResetField(name string) error {
  8630. switch name {
  8631. case labelrelationship.FieldCreatedAt:
  8632. m.ResetCreatedAt()
  8633. return nil
  8634. case labelrelationship.FieldUpdatedAt:
  8635. m.ResetUpdatedAt()
  8636. return nil
  8637. case labelrelationship.FieldStatus:
  8638. m.ResetStatus()
  8639. return nil
  8640. case labelrelationship.FieldDeletedAt:
  8641. m.ResetDeletedAt()
  8642. return nil
  8643. case labelrelationship.FieldLabelID:
  8644. m.ResetLabelID()
  8645. return nil
  8646. case labelrelationship.FieldContactID:
  8647. m.ResetContactID()
  8648. return nil
  8649. case labelrelationship.FieldOrganizationID:
  8650. m.ResetOrganizationID()
  8651. return nil
  8652. }
  8653. return fmt.Errorf("unknown LabelRelationship field %s", name)
  8654. }
  8655. // AddedEdges returns all edge names that were set/added in this mutation.
  8656. func (m *LabelRelationshipMutation) AddedEdges() []string {
  8657. edges := make([]string, 0, 2)
  8658. if m.contacts != nil {
  8659. edges = append(edges, labelrelationship.EdgeContacts)
  8660. }
  8661. if m.labels != nil {
  8662. edges = append(edges, labelrelationship.EdgeLabels)
  8663. }
  8664. return edges
  8665. }
  8666. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8667. // name in this mutation.
  8668. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  8669. switch name {
  8670. case labelrelationship.EdgeContacts:
  8671. if id := m.contacts; id != nil {
  8672. return []ent.Value{*id}
  8673. }
  8674. case labelrelationship.EdgeLabels:
  8675. if id := m.labels; id != nil {
  8676. return []ent.Value{*id}
  8677. }
  8678. }
  8679. return nil
  8680. }
  8681. // RemovedEdges returns all edge names that were removed in this mutation.
  8682. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  8683. edges := make([]string, 0, 2)
  8684. return edges
  8685. }
  8686. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8687. // the given name in this mutation.
  8688. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  8689. return nil
  8690. }
  8691. // ClearedEdges returns all edge names that were cleared in this mutation.
  8692. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  8693. edges := make([]string, 0, 2)
  8694. if m.clearedcontacts {
  8695. edges = append(edges, labelrelationship.EdgeContacts)
  8696. }
  8697. if m.clearedlabels {
  8698. edges = append(edges, labelrelationship.EdgeLabels)
  8699. }
  8700. return edges
  8701. }
  8702. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8703. // was cleared in this mutation.
  8704. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  8705. switch name {
  8706. case labelrelationship.EdgeContacts:
  8707. return m.clearedcontacts
  8708. case labelrelationship.EdgeLabels:
  8709. return m.clearedlabels
  8710. }
  8711. return false
  8712. }
  8713. // ClearEdge clears the value of the edge with the given name. It returns an error
  8714. // if that edge is not defined in the schema.
  8715. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  8716. switch name {
  8717. case labelrelationship.EdgeContacts:
  8718. m.ClearContacts()
  8719. return nil
  8720. case labelrelationship.EdgeLabels:
  8721. m.ClearLabels()
  8722. return nil
  8723. }
  8724. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  8725. }
  8726. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8727. // It returns an error if the edge is not defined in the schema.
  8728. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  8729. switch name {
  8730. case labelrelationship.EdgeContacts:
  8731. m.ResetContacts()
  8732. return nil
  8733. case labelrelationship.EdgeLabels:
  8734. m.ResetLabels()
  8735. return nil
  8736. }
  8737. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  8738. }
  8739. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  8740. type MessageMutation struct {
  8741. config
  8742. op Op
  8743. typ string
  8744. id *int
  8745. wx_wxid *string
  8746. wxid *string
  8747. content *string
  8748. clearedFields map[string]struct{}
  8749. done bool
  8750. oldValue func(context.Context) (*Message, error)
  8751. predicates []predicate.Message
  8752. }
  8753. var _ ent.Mutation = (*MessageMutation)(nil)
  8754. // messageOption allows management of the mutation configuration using functional options.
  8755. type messageOption func(*MessageMutation)
  8756. // newMessageMutation creates new mutation for the Message entity.
  8757. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  8758. m := &MessageMutation{
  8759. config: c,
  8760. op: op,
  8761. typ: TypeMessage,
  8762. clearedFields: make(map[string]struct{}),
  8763. }
  8764. for _, opt := range opts {
  8765. opt(m)
  8766. }
  8767. return m
  8768. }
  8769. // withMessageID sets the ID field of the mutation.
  8770. func withMessageID(id int) messageOption {
  8771. return func(m *MessageMutation) {
  8772. var (
  8773. err error
  8774. once sync.Once
  8775. value *Message
  8776. )
  8777. m.oldValue = func(ctx context.Context) (*Message, error) {
  8778. once.Do(func() {
  8779. if m.done {
  8780. err = errors.New("querying old values post mutation is not allowed")
  8781. } else {
  8782. value, err = m.Client().Message.Get(ctx, id)
  8783. }
  8784. })
  8785. return value, err
  8786. }
  8787. m.id = &id
  8788. }
  8789. }
  8790. // withMessage sets the old Message of the mutation.
  8791. func withMessage(node *Message) messageOption {
  8792. return func(m *MessageMutation) {
  8793. m.oldValue = func(context.Context) (*Message, error) {
  8794. return node, nil
  8795. }
  8796. m.id = &node.ID
  8797. }
  8798. }
  8799. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8800. // executed in a transaction (ent.Tx), a transactional client is returned.
  8801. func (m MessageMutation) Client() *Client {
  8802. client := &Client{config: m.config}
  8803. client.init()
  8804. return client
  8805. }
  8806. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8807. // it returns an error otherwise.
  8808. func (m MessageMutation) Tx() (*Tx, error) {
  8809. if _, ok := m.driver.(*txDriver); !ok {
  8810. return nil, errors.New("ent: mutation is not running in a transaction")
  8811. }
  8812. tx := &Tx{config: m.config}
  8813. tx.init()
  8814. return tx, nil
  8815. }
  8816. // ID returns the ID value in the mutation. Note that the ID is only available
  8817. // if it was provided to the builder or after it was returned from the database.
  8818. func (m *MessageMutation) ID() (id int, exists bool) {
  8819. if m.id == nil {
  8820. return
  8821. }
  8822. return *m.id, true
  8823. }
  8824. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8825. // That means, if the mutation is applied within a transaction with an isolation level such
  8826. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8827. // or updated by the mutation.
  8828. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  8829. switch {
  8830. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8831. id, exists := m.ID()
  8832. if exists {
  8833. return []int{id}, nil
  8834. }
  8835. fallthrough
  8836. case m.op.Is(OpUpdate | OpDelete):
  8837. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  8838. default:
  8839. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8840. }
  8841. }
  8842. // SetWxWxid sets the "wx_wxid" field.
  8843. func (m *MessageMutation) SetWxWxid(s string) {
  8844. m.wx_wxid = &s
  8845. }
  8846. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  8847. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  8848. v := m.wx_wxid
  8849. if v == nil {
  8850. return
  8851. }
  8852. return *v, true
  8853. }
  8854. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  8855. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  8856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8857. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  8858. if !m.op.Is(OpUpdateOne) {
  8859. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  8860. }
  8861. if m.id == nil || m.oldValue == nil {
  8862. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  8863. }
  8864. oldValue, err := m.oldValue(ctx)
  8865. if err != nil {
  8866. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  8867. }
  8868. return oldValue.WxWxid, nil
  8869. }
  8870. // ClearWxWxid clears the value of the "wx_wxid" field.
  8871. func (m *MessageMutation) ClearWxWxid() {
  8872. m.wx_wxid = nil
  8873. m.clearedFields[message.FieldWxWxid] = struct{}{}
  8874. }
  8875. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  8876. func (m *MessageMutation) WxWxidCleared() bool {
  8877. _, ok := m.clearedFields[message.FieldWxWxid]
  8878. return ok
  8879. }
  8880. // ResetWxWxid resets all changes to the "wx_wxid" field.
  8881. func (m *MessageMutation) ResetWxWxid() {
  8882. m.wx_wxid = nil
  8883. delete(m.clearedFields, message.FieldWxWxid)
  8884. }
  8885. // SetWxid sets the "wxid" field.
  8886. func (m *MessageMutation) SetWxid(s string) {
  8887. m.wxid = &s
  8888. }
  8889. // Wxid returns the value of the "wxid" field in the mutation.
  8890. func (m *MessageMutation) Wxid() (r string, exists bool) {
  8891. v := m.wxid
  8892. if v == nil {
  8893. return
  8894. }
  8895. return *v, true
  8896. }
  8897. // OldWxid returns the old "wxid" field's value of the Message entity.
  8898. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  8899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8900. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  8901. if !m.op.Is(OpUpdateOne) {
  8902. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  8903. }
  8904. if m.id == nil || m.oldValue == nil {
  8905. return v, errors.New("OldWxid requires an ID field in the mutation")
  8906. }
  8907. oldValue, err := m.oldValue(ctx)
  8908. if err != nil {
  8909. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  8910. }
  8911. return oldValue.Wxid, nil
  8912. }
  8913. // ResetWxid resets all changes to the "wxid" field.
  8914. func (m *MessageMutation) ResetWxid() {
  8915. m.wxid = nil
  8916. }
  8917. // SetContent sets the "content" field.
  8918. func (m *MessageMutation) SetContent(s string) {
  8919. m.content = &s
  8920. }
  8921. // Content returns the value of the "content" field in the mutation.
  8922. func (m *MessageMutation) Content() (r string, exists bool) {
  8923. v := m.content
  8924. if v == nil {
  8925. return
  8926. }
  8927. return *v, true
  8928. }
  8929. // OldContent returns the old "content" field's value of the Message entity.
  8930. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  8931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8932. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  8933. if !m.op.Is(OpUpdateOne) {
  8934. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  8935. }
  8936. if m.id == nil || m.oldValue == nil {
  8937. return v, errors.New("OldContent requires an ID field in the mutation")
  8938. }
  8939. oldValue, err := m.oldValue(ctx)
  8940. if err != nil {
  8941. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  8942. }
  8943. return oldValue.Content, nil
  8944. }
  8945. // ResetContent resets all changes to the "content" field.
  8946. func (m *MessageMutation) ResetContent() {
  8947. m.content = nil
  8948. }
  8949. // Where appends a list predicates to the MessageMutation builder.
  8950. func (m *MessageMutation) Where(ps ...predicate.Message) {
  8951. m.predicates = append(m.predicates, ps...)
  8952. }
  8953. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  8954. // users can use type-assertion to append predicates that do not depend on any generated package.
  8955. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  8956. p := make([]predicate.Message, len(ps))
  8957. for i := range ps {
  8958. p[i] = ps[i]
  8959. }
  8960. m.Where(p...)
  8961. }
  8962. // Op returns the operation name.
  8963. func (m *MessageMutation) Op() Op {
  8964. return m.op
  8965. }
  8966. // SetOp allows setting the mutation operation.
  8967. func (m *MessageMutation) SetOp(op Op) {
  8968. m.op = op
  8969. }
  8970. // Type returns the node type of this mutation (Message).
  8971. func (m *MessageMutation) Type() string {
  8972. return m.typ
  8973. }
  8974. // Fields returns all fields that were changed during this mutation. Note that in
  8975. // order to get all numeric fields that were incremented/decremented, call
  8976. // AddedFields().
  8977. func (m *MessageMutation) Fields() []string {
  8978. fields := make([]string, 0, 3)
  8979. if m.wx_wxid != nil {
  8980. fields = append(fields, message.FieldWxWxid)
  8981. }
  8982. if m.wxid != nil {
  8983. fields = append(fields, message.FieldWxid)
  8984. }
  8985. if m.content != nil {
  8986. fields = append(fields, message.FieldContent)
  8987. }
  8988. return fields
  8989. }
  8990. // Field returns the value of a field with the given name. The second boolean
  8991. // return value indicates that this field was not set, or was not defined in the
  8992. // schema.
  8993. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  8994. switch name {
  8995. case message.FieldWxWxid:
  8996. return m.WxWxid()
  8997. case message.FieldWxid:
  8998. return m.Wxid()
  8999. case message.FieldContent:
  9000. return m.Content()
  9001. }
  9002. return nil, false
  9003. }
  9004. // OldField returns the old value of the field from the database. An error is
  9005. // returned if the mutation operation is not UpdateOne, or the query to the
  9006. // database failed.
  9007. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9008. switch name {
  9009. case message.FieldWxWxid:
  9010. return m.OldWxWxid(ctx)
  9011. case message.FieldWxid:
  9012. return m.OldWxid(ctx)
  9013. case message.FieldContent:
  9014. return m.OldContent(ctx)
  9015. }
  9016. return nil, fmt.Errorf("unknown Message field %s", name)
  9017. }
  9018. // SetField sets the value of a field with the given name. It returns an error if
  9019. // the field is not defined in the schema, or if the type mismatched the field
  9020. // type.
  9021. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  9022. switch name {
  9023. case message.FieldWxWxid:
  9024. v, ok := value.(string)
  9025. if !ok {
  9026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9027. }
  9028. m.SetWxWxid(v)
  9029. return nil
  9030. case message.FieldWxid:
  9031. v, ok := value.(string)
  9032. if !ok {
  9033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9034. }
  9035. m.SetWxid(v)
  9036. return nil
  9037. case message.FieldContent:
  9038. v, ok := value.(string)
  9039. if !ok {
  9040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9041. }
  9042. m.SetContent(v)
  9043. return nil
  9044. }
  9045. return fmt.Errorf("unknown Message field %s", name)
  9046. }
  9047. // AddedFields returns all numeric fields that were incremented/decremented during
  9048. // this mutation.
  9049. func (m *MessageMutation) AddedFields() []string {
  9050. return nil
  9051. }
  9052. // AddedField returns the numeric value that was incremented/decremented on a field
  9053. // with the given name. The second boolean return value indicates that this field
  9054. // was not set, or was not defined in the schema.
  9055. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  9056. return nil, false
  9057. }
  9058. // AddField adds the value to the field with the given name. It returns an error if
  9059. // the field is not defined in the schema, or if the type mismatched the field
  9060. // type.
  9061. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  9062. switch name {
  9063. }
  9064. return fmt.Errorf("unknown Message numeric field %s", name)
  9065. }
  9066. // ClearedFields returns all nullable fields that were cleared during this
  9067. // mutation.
  9068. func (m *MessageMutation) ClearedFields() []string {
  9069. var fields []string
  9070. if m.FieldCleared(message.FieldWxWxid) {
  9071. fields = append(fields, message.FieldWxWxid)
  9072. }
  9073. return fields
  9074. }
  9075. // FieldCleared returns a boolean indicating if a field with the given name was
  9076. // cleared in this mutation.
  9077. func (m *MessageMutation) FieldCleared(name string) bool {
  9078. _, ok := m.clearedFields[name]
  9079. return ok
  9080. }
  9081. // ClearField clears the value of the field with the given name. It returns an
  9082. // error if the field is not defined in the schema.
  9083. func (m *MessageMutation) ClearField(name string) error {
  9084. switch name {
  9085. case message.FieldWxWxid:
  9086. m.ClearWxWxid()
  9087. return nil
  9088. }
  9089. return fmt.Errorf("unknown Message nullable field %s", name)
  9090. }
  9091. // ResetField resets all changes in the mutation for the field with the given name.
  9092. // It returns an error if the field is not defined in the schema.
  9093. func (m *MessageMutation) ResetField(name string) error {
  9094. switch name {
  9095. case message.FieldWxWxid:
  9096. m.ResetWxWxid()
  9097. return nil
  9098. case message.FieldWxid:
  9099. m.ResetWxid()
  9100. return nil
  9101. case message.FieldContent:
  9102. m.ResetContent()
  9103. return nil
  9104. }
  9105. return fmt.Errorf("unknown Message field %s", name)
  9106. }
  9107. // AddedEdges returns all edge names that were set/added in this mutation.
  9108. func (m *MessageMutation) AddedEdges() []string {
  9109. edges := make([]string, 0, 0)
  9110. return edges
  9111. }
  9112. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9113. // name in this mutation.
  9114. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  9115. return nil
  9116. }
  9117. // RemovedEdges returns all edge names that were removed in this mutation.
  9118. func (m *MessageMutation) RemovedEdges() []string {
  9119. edges := make([]string, 0, 0)
  9120. return edges
  9121. }
  9122. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9123. // the given name in this mutation.
  9124. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  9125. return nil
  9126. }
  9127. // ClearedEdges returns all edge names that were cleared in this mutation.
  9128. func (m *MessageMutation) ClearedEdges() []string {
  9129. edges := make([]string, 0, 0)
  9130. return edges
  9131. }
  9132. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9133. // was cleared in this mutation.
  9134. func (m *MessageMutation) EdgeCleared(name string) bool {
  9135. return false
  9136. }
  9137. // ClearEdge clears the value of the edge with the given name. It returns an error
  9138. // if that edge is not defined in the schema.
  9139. func (m *MessageMutation) ClearEdge(name string) error {
  9140. return fmt.Errorf("unknown Message unique edge %s", name)
  9141. }
  9142. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9143. // It returns an error if the edge is not defined in the schema.
  9144. func (m *MessageMutation) ResetEdge(name string) error {
  9145. return fmt.Errorf("unknown Message edge %s", name)
  9146. }
  9147. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  9148. type MessageRecordsMutation struct {
  9149. config
  9150. op Op
  9151. typ string
  9152. id *uint64
  9153. created_at *time.Time
  9154. updated_at *time.Time
  9155. status *uint8
  9156. addstatus *int8
  9157. deleted_at *time.Time
  9158. bot_wxid *string
  9159. contact_type *int
  9160. addcontact_type *int
  9161. contact_wxid *string
  9162. content_type *int
  9163. addcontent_type *int
  9164. content *string
  9165. meta *custom_types.Meta
  9166. error_detail *string
  9167. send_time *time.Time
  9168. source_type *int
  9169. addsource_type *int
  9170. organization_id *uint64
  9171. addorganization_id *int64
  9172. clearedFields map[string]struct{}
  9173. sop_stage *uint64
  9174. clearedsop_stage bool
  9175. sop_node *uint64
  9176. clearedsop_node bool
  9177. message_contact *uint64
  9178. clearedmessage_contact bool
  9179. done bool
  9180. oldValue func(context.Context) (*MessageRecords, error)
  9181. predicates []predicate.MessageRecords
  9182. }
  9183. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  9184. // messagerecordsOption allows management of the mutation configuration using functional options.
  9185. type messagerecordsOption func(*MessageRecordsMutation)
  9186. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  9187. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  9188. m := &MessageRecordsMutation{
  9189. config: c,
  9190. op: op,
  9191. typ: TypeMessageRecords,
  9192. clearedFields: make(map[string]struct{}),
  9193. }
  9194. for _, opt := range opts {
  9195. opt(m)
  9196. }
  9197. return m
  9198. }
  9199. // withMessageRecordsID sets the ID field of the mutation.
  9200. func withMessageRecordsID(id uint64) messagerecordsOption {
  9201. return func(m *MessageRecordsMutation) {
  9202. var (
  9203. err error
  9204. once sync.Once
  9205. value *MessageRecords
  9206. )
  9207. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  9208. once.Do(func() {
  9209. if m.done {
  9210. err = errors.New("querying old values post mutation is not allowed")
  9211. } else {
  9212. value, err = m.Client().MessageRecords.Get(ctx, id)
  9213. }
  9214. })
  9215. return value, err
  9216. }
  9217. m.id = &id
  9218. }
  9219. }
  9220. // withMessageRecords sets the old MessageRecords of the mutation.
  9221. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  9222. return func(m *MessageRecordsMutation) {
  9223. m.oldValue = func(context.Context) (*MessageRecords, error) {
  9224. return node, nil
  9225. }
  9226. m.id = &node.ID
  9227. }
  9228. }
  9229. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9230. // executed in a transaction (ent.Tx), a transactional client is returned.
  9231. func (m MessageRecordsMutation) Client() *Client {
  9232. client := &Client{config: m.config}
  9233. client.init()
  9234. return client
  9235. }
  9236. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9237. // it returns an error otherwise.
  9238. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  9239. if _, ok := m.driver.(*txDriver); !ok {
  9240. return nil, errors.New("ent: mutation is not running in a transaction")
  9241. }
  9242. tx := &Tx{config: m.config}
  9243. tx.init()
  9244. return tx, nil
  9245. }
  9246. // SetID sets the value of the id field. Note that this
  9247. // operation is only accepted on creation of MessageRecords entities.
  9248. func (m *MessageRecordsMutation) SetID(id uint64) {
  9249. m.id = &id
  9250. }
  9251. // ID returns the ID value in the mutation. Note that the ID is only available
  9252. // if it was provided to the builder or after it was returned from the database.
  9253. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  9254. if m.id == nil {
  9255. return
  9256. }
  9257. return *m.id, true
  9258. }
  9259. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9260. // That means, if the mutation is applied within a transaction with an isolation level such
  9261. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9262. // or updated by the mutation.
  9263. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  9264. switch {
  9265. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9266. id, exists := m.ID()
  9267. if exists {
  9268. return []uint64{id}, nil
  9269. }
  9270. fallthrough
  9271. case m.op.Is(OpUpdate | OpDelete):
  9272. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  9273. default:
  9274. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9275. }
  9276. }
  9277. // SetCreatedAt sets the "created_at" field.
  9278. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  9279. m.created_at = &t
  9280. }
  9281. // CreatedAt returns the value of the "created_at" field in the mutation.
  9282. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  9283. v := m.created_at
  9284. if v == nil {
  9285. return
  9286. }
  9287. return *v, true
  9288. }
  9289. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  9290. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9292. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9293. if !m.op.Is(OpUpdateOne) {
  9294. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9295. }
  9296. if m.id == nil || m.oldValue == nil {
  9297. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9298. }
  9299. oldValue, err := m.oldValue(ctx)
  9300. if err != nil {
  9301. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9302. }
  9303. return oldValue.CreatedAt, nil
  9304. }
  9305. // ResetCreatedAt resets all changes to the "created_at" field.
  9306. func (m *MessageRecordsMutation) ResetCreatedAt() {
  9307. m.created_at = nil
  9308. }
  9309. // SetUpdatedAt sets the "updated_at" field.
  9310. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  9311. m.updated_at = &t
  9312. }
  9313. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9314. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  9315. v := m.updated_at
  9316. if v == nil {
  9317. return
  9318. }
  9319. return *v, true
  9320. }
  9321. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  9322. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9324. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9325. if !m.op.Is(OpUpdateOne) {
  9326. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9327. }
  9328. if m.id == nil || m.oldValue == nil {
  9329. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9330. }
  9331. oldValue, err := m.oldValue(ctx)
  9332. if err != nil {
  9333. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9334. }
  9335. return oldValue.UpdatedAt, nil
  9336. }
  9337. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9338. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  9339. m.updated_at = nil
  9340. }
  9341. // SetStatus sets the "status" field.
  9342. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  9343. m.status = &u
  9344. m.addstatus = nil
  9345. }
  9346. // Status returns the value of the "status" field in the mutation.
  9347. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  9348. v := m.status
  9349. if v == nil {
  9350. return
  9351. }
  9352. return *v, true
  9353. }
  9354. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  9355. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9357. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9358. if !m.op.Is(OpUpdateOne) {
  9359. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9360. }
  9361. if m.id == nil || m.oldValue == nil {
  9362. return v, errors.New("OldStatus requires an ID field in the mutation")
  9363. }
  9364. oldValue, err := m.oldValue(ctx)
  9365. if err != nil {
  9366. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9367. }
  9368. return oldValue.Status, nil
  9369. }
  9370. // AddStatus adds u to the "status" field.
  9371. func (m *MessageRecordsMutation) AddStatus(u int8) {
  9372. if m.addstatus != nil {
  9373. *m.addstatus += u
  9374. } else {
  9375. m.addstatus = &u
  9376. }
  9377. }
  9378. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9379. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  9380. v := m.addstatus
  9381. if v == nil {
  9382. return
  9383. }
  9384. return *v, true
  9385. }
  9386. // ClearStatus clears the value of the "status" field.
  9387. func (m *MessageRecordsMutation) ClearStatus() {
  9388. m.status = nil
  9389. m.addstatus = nil
  9390. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  9391. }
  9392. // StatusCleared returns if the "status" field was cleared in this mutation.
  9393. func (m *MessageRecordsMutation) StatusCleared() bool {
  9394. _, ok := m.clearedFields[messagerecords.FieldStatus]
  9395. return ok
  9396. }
  9397. // ResetStatus resets all changes to the "status" field.
  9398. func (m *MessageRecordsMutation) ResetStatus() {
  9399. m.status = nil
  9400. m.addstatus = nil
  9401. delete(m.clearedFields, messagerecords.FieldStatus)
  9402. }
  9403. // SetDeletedAt sets the "deleted_at" field.
  9404. func (m *MessageRecordsMutation) SetDeletedAt(t time.Time) {
  9405. m.deleted_at = &t
  9406. }
  9407. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9408. func (m *MessageRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  9409. v := m.deleted_at
  9410. if v == nil {
  9411. return
  9412. }
  9413. return *v, true
  9414. }
  9415. // OldDeletedAt returns the old "deleted_at" field's value of the MessageRecords entity.
  9416. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9418. func (m *MessageRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9419. if !m.op.Is(OpUpdateOne) {
  9420. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9421. }
  9422. if m.id == nil || m.oldValue == nil {
  9423. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9424. }
  9425. oldValue, err := m.oldValue(ctx)
  9426. if err != nil {
  9427. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9428. }
  9429. return oldValue.DeletedAt, nil
  9430. }
  9431. // ClearDeletedAt clears the value of the "deleted_at" field.
  9432. func (m *MessageRecordsMutation) ClearDeletedAt() {
  9433. m.deleted_at = nil
  9434. m.clearedFields[messagerecords.FieldDeletedAt] = struct{}{}
  9435. }
  9436. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9437. func (m *MessageRecordsMutation) DeletedAtCleared() bool {
  9438. _, ok := m.clearedFields[messagerecords.FieldDeletedAt]
  9439. return ok
  9440. }
  9441. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9442. func (m *MessageRecordsMutation) ResetDeletedAt() {
  9443. m.deleted_at = nil
  9444. delete(m.clearedFields, messagerecords.FieldDeletedAt)
  9445. }
  9446. // SetBotWxid sets the "bot_wxid" field.
  9447. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  9448. m.bot_wxid = &s
  9449. }
  9450. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  9451. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  9452. v := m.bot_wxid
  9453. if v == nil {
  9454. return
  9455. }
  9456. return *v, true
  9457. }
  9458. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  9459. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9461. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  9462. if !m.op.Is(OpUpdateOne) {
  9463. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  9464. }
  9465. if m.id == nil || m.oldValue == nil {
  9466. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  9467. }
  9468. oldValue, err := m.oldValue(ctx)
  9469. if err != nil {
  9470. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  9471. }
  9472. return oldValue.BotWxid, nil
  9473. }
  9474. // ResetBotWxid resets all changes to the "bot_wxid" field.
  9475. func (m *MessageRecordsMutation) ResetBotWxid() {
  9476. m.bot_wxid = nil
  9477. }
  9478. // SetContactID sets the "contact_id" field.
  9479. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  9480. m.message_contact = &u
  9481. }
  9482. // ContactID returns the value of the "contact_id" field in the mutation.
  9483. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  9484. v := m.message_contact
  9485. if v == nil {
  9486. return
  9487. }
  9488. return *v, true
  9489. }
  9490. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  9491. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9493. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  9494. if !m.op.Is(OpUpdateOne) {
  9495. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  9496. }
  9497. if m.id == nil || m.oldValue == nil {
  9498. return v, errors.New("OldContactID requires an ID field in the mutation")
  9499. }
  9500. oldValue, err := m.oldValue(ctx)
  9501. if err != nil {
  9502. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  9503. }
  9504. return oldValue.ContactID, nil
  9505. }
  9506. // ClearContactID clears the value of the "contact_id" field.
  9507. func (m *MessageRecordsMutation) ClearContactID() {
  9508. m.message_contact = nil
  9509. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  9510. }
  9511. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  9512. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  9513. _, ok := m.clearedFields[messagerecords.FieldContactID]
  9514. return ok
  9515. }
  9516. // ResetContactID resets all changes to the "contact_id" field.
  9517. func (m *MessageRecordsMutation) ResetContactID() {
  9518. m.message_contact = nil
  9519. delete(m.clearedFields, messagerecords.FieldContactID)
  9520. }
  9521. // SetContactType sets the "contact_type" field.
  9522. func (m *MessageRecordsMutation) SetContactType(i int) {
  9523. m.contact_type = &i
  9524. m.addcontact_type = nil
  9525. }
  9526. // ContactType returns the value of the "contact_type" field in the mutation.
  9527. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  9528. v := m.contact_type
  9529. if v == nil {
  9530. return
  9531. }
  9532. return *v, true
  9533. }
  9534. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  9535. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9537. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  9538. if !m.op.Is(OpUpdateOne) {
  9539. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  9540. }
  9541. if m.id == nil || m.oldValue == nil {
  9542. return v, errors.New("OldContactType requires an ID field in the mutation")
  9543. }
  9544. oldValue, err := m.oldValue(ctx)
  9545. if err != nil {
  9546. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  9547. }
  9548. return oldValue.ContactType, nil
  9549. }
  9550. // AddContactType adds i to the "contact_type" field.
  9551. func (m *MessageRecordsMutation) AddContactType(i int) {
  9552. if m.addcontact_type != nil {
  9553. *m.addcontact_type += i
  9554. } else {
  9555. m.addcontact_type = &i
  9556. }
  9557. }
  9558. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  9559. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  9560. v := m.addcontact_type
  9561. if v == nil {
  9562. return
  9563. }
  9564. return *v, true
  9565. }
  9566. // ResetContactType resets all changes to the "contact_type" field.
  9567. func (m *MessageRecordsMutation) ResetContactType() {
  9568. m.contact_type = nil
  9569. m.addcontact_type = nil
  9570. }
  9571. // SetContactWxid sets the "contact_wxid" field.
  9572. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  9573. m.contact_wxid = &s
  9574. }
  9575. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  9576. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  9577. v := m.contact_wxid
  9578. if v == nil {
  9579. return
  9580. }
  9581. return *v, true
  9582. }
  9583. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  9584. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9586. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  9587. if !m.op.Is(OpUpdateOne) {
  9588. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  9589. }
  9590. if m.id == nil || m.oldValue == nil {
  9591. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  9592. }
  9593. oldValue, err := m.oldValue(ctx)
  9594. if err != nil {
  9595. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  9596. }
  9597. return oldValue.ContactWxid, nil
  9598. }
  9599. // ResetContactWxid resets all changes to the "contact_wxid" field.
  9600. func (m *MessageRecordsMutation) ResetContactWxid() {
  9601. m.contact_wxid = nil
  9602. }
  9603. // SetContentType sets the "content_type" field.
  9604. func (m *MessageRecordsMutation) SetContentType(i int) {
  9605. m.content_type = &i
  9606. m.addcontent_type = nil
  9607. }
  9608. // ContentType returns the value of the "content_type" field in the mutation.
  9609. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  9610. v := m.content_type
  9611. if v == nil {
  9612. return
  9613. }
  9614. return *v, true
  9615. }
  9616. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  9617. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9619. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  9620. if !m.op.Is(OpUpdateOne) {
  9621. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  9622. }
  9623. if m.id == nil || m.oldValue == nil {
  9624. return v, errors.New("OldContentType requires an ID field in the mutation")
  9625. }
  9626. oldValue, err := m.oldValue(ctx)
  9627. if err != nil {
  9628. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  9629. }
  9630. return oldValue.ContentType, nil
  9631. }
  9632. // AddContentType adds i to the "content_type" field.
  9633. func (m *MessageRecordsMutation) AddContentType(i int) {
  9634. if m.addcontent_type != nil {
  9635. *m.addcontent_type += i
  9636. } else {
  9637. m.addcontent_type = &i
  9638. }
  9639. }
  9640. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  9641. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  9642. v := m.addcontent_type
  9643. if v == nil {
  9644. return
  9645. }
  9646. return *v, true
  9647. }
  9648. // ResetContentType resets all changes to the "content_type" field.
  9649. func (m *MessageRecordsMutation) ResetContentType() {
  9650. m.content_type = nil
  9651. m.addcontent_type = nil
  9652. }
  9653. // SetContent sets the "content" field.
  9654. func (m *MessageRecordsMutation) SetContent(s string) {
  9655. m.content = &s
  9656. }
  9657. // Content returns the value of the "content" field in the mutation.
  9658. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  9659. v := m.content
  9660. if v == nil {
  9661. return
  9662. }
  9663. return *v, true
  9664. }
  9665. // OldContent returns the old "content" field's value of the MessageRecords entity.
  9666. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9668. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  9669. if !m.op.Is(OpUpdateOne) {
  9670. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  9671. }
  9672. if m.id == nil || m.oldValue == nil {
  9673. return v, errors.New("OldContent requires an ID field in the mutation")
  9674. }
  9675. oldValue, err := m.oldValue(ctx)
  9676. if err != nil {
  9677. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  9678. }
  9679. return oldValue.Content, nil
  9680. }
  9681. // ResetContent resets all changes to the "content" field.
  9682. func (m *MessageRecordsMutation) ResetContent() {
  9683. m.content = nil
  9684. }
  9685. // SetMeta sets the "meta" field.
  9686. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  9687. m.meta = &ct
  9688. }
  9689. // Meta returns the value of the "meta" field in the mutation.
  9690. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  9691. v := m.meta
  9692. if v == nil {
  9693. return
  9694. }
  9695. return *v, true
  9696. }
  9697. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  9698. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9700. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  9701. if !m.op.Is(OpUpdateOne) {
  9702. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  9703. }
  9704. if m.id == nil || m.oldValue == nil {
  9705. return v, errors.New("OldMeta requires an ID field in the mutation")
  9706. }
  9707. oldValue, err := m.oldValue(ctx)
  9708. if err != nil {
  9709. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  9710. }
  9711. return oldValue.Meta, nil
  9712. }
  9713. // ClearMeta clears the value of the "meta" field.
  9714. func (m *MessageRecordsMutation) ClearMeta() {
  9715. m.meta = nil
  9716. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  9717. }
  9718. // MetaCleared returns if the "meta" field was cleared in this mutation.
  9719. func (m *MessageRecordsMutation) MetaCleared() bool {
  9720. _, ok := m.clearedFields[messagerecords.FieldMeta]
  9721. return ok
  9722. }
  9723. // ResetMeta resets all changes to the "meta" field.
  9724. func (m *MessageRecordsMutation) ResetMeta() {
  9725. m.meta = nil
  9726. delete(m.clearedFields, messagerecords.FieldMeta)
  9727. }
  9728. // SetErrorDetail sets the "error_detail" field.
  9729. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  9730. m.error_detail = &s
  9731. }
  9732. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  9733. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  9734. v := m.error_detail
  9735. if v == nil {
  9736. return
  9737. }
  9738. return *v, true
  9739. }
  9740. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  9741. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9743. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  9744. if !m.op.Is(OpUpdateOne) {
  9745. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  9746. }
  9747. if m.id == nil || m.oldValue == nil {
  9748. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  9749. }
  9750. oldValue, err := m.oldValue(ctx)
  9751. if err != nil {
  9752. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  9753. }
  9754. return oldValue.ErrorDetail, nil
  9755. }
  9756. // ResetErrorDetail resets all changes to the "error_detail" field.
  9757. func (m *MessageRecordsMutation) ResetErrorDetail() {
  9758. m.error_detail = nil
  9759. }
  9760. // SetSendTime sets the "send_time" field.
  9761. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  9762. m.send_time = &t
  9763. }
  9764. // SendTime returns the value of the "send_time" field in the mutation.
  9765. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  9766. v := m.send_time
  9767. if v == nil {
  9768. return
  9769. }
  9770. return *v, true
  9771. }
  9772. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  9773. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9774. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9775. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  9776. if !m.op.Is(OpUpdateOne) {
  9777. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  9778. }
  9779. if m.id == nil || m.oldValue == nil {
  9780. return v, errors.New("OldSendTime requires an ID field in the mutation")
  9781. }
  9782. oldValue, err := m.oldValue(ctx)
  9783. if err != nil {
  9784. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  9785. }
  9786. return oldValue.SendTime, nil
  9787. }
  9788. // ClearSendTime clears the value of the "send_time" field.
  9789. func (m *MessageRecordsMutation) ClearSendTime() {
  9790. m.send_time = nil
  9791. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  9792. }
  9793. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  9794. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  9795. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  9796. return ok
  9797. }
  9798. // ResetSendTime resets all changes to the "send_time" field.
  9799. func (m *MessageRecordsMutation) ResetSendTime() {
  9800. m.send_time = nil
  9801. delete(m.clearedFields, messagerecords.FieldSendTime)
  9802. }
  9803. // SetSourceType sets the "source_type" field.
  9804. func (m *MessageRecordsMutation) SetSourceType(i int) {
  9805. m.source_type = &i
  9806. m.addsource_type = nil
  9807. }
  9808. // SourceType returns the value of the "source_type" field in the mutation.
  9809. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  9810. v := m.source_type
  9811. if v == nil {
  9812. return
  9813. }
  9814. return *v, true
  9815. }
  9816. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  9817. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9819. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  9820. if !m.op.Is(OpUpdateOne) {
  9821. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  9822. }
  9823. if m.id == nil || m.oldValue == nil {
  9824. return v, errors.New("OldSourceType requires an ID field in the mutation")
  9825. }
  9826. oldValue, err := m.oldValue(ctx)
  9827. if err != nil {
  9828. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  9829. }
  9830. return oldValue.SourceType, nil
  9831. }
  9832. // AddSourceType adds i to the "source_type" field.
  9833. func (m *MessageRecordsMutation) AddSourceType(i int) {
  9834. if m.addsource_type != nil {
  9835. *m.addsource_type += i
  9836. } else {
  9837. m.addsource_type = &i
  9838. }
  9839. }
  9840. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  9841. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  9842. v := m.addsource_type
  9843. if v == nil {
  9844. return
  9845. }
  9846. return *v, true
  9847. }
  9848. // ResetSourceType resets all changes to the "source_type" field.
  9849. func (m *MessageRecordsMutation) ResetSourceType() {
  9850. m.source_type = nil
  9851. m.addsource_type = nil
  9852. }
  9853. // SetSourceID sets the "source_id" field.
  9854. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  9855. m.sop_stage = &u
  9856. }
  9857. // SourceID returns the value of the "source_id" field in the mutation.
  9858. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  9859. v := m.sop_stage
  9860. if v == nil {
  9861. return
  9862. }
  9863. return *v, true
  9864. }
  9865. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  9866. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9868. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  9869. if !m.op.Is(OpUpdateOne) {
  9870. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  9871. }
  9872. if m.id == nil || m.oldValue == nil {
  9873. return v, errors.New("OldSourceID requires an ID field in the mutation")
  9874. }
  9875. oldValue, err := m.oldValue(ctx)
  9876. if err != nil {
  9877. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  9878. }
  9879. return oldValue.SourceID, nil
  9880. }
  9881. // ClearSourceID clears the value of the "source_id" field.
  9882. func (m *MessageRecordsMutation) ClearSourceID() {
  9883. m.sop_stage = nil
  9884. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  9885. }
  9886. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  9887. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  9888. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  9889. return ok
  9890. }
  9891. // ResetSourceID resets all changes to the "source_id" field.
  9892. func (m *MessageRecordsMutation) ResetSourceID() {
  9893. m.sop_stage = nil
  9894. delete(m.clearedFields, messagerecords.FieldSourceID)
  9895. }
  9896. // SetSubSourceID sets the "sub_source_id" field.
  9897. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  9898. m.sop_node = &u
  9899. }
  9900. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  9901. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  9902. v := m.sop_node
  9903. if v == nil {
  9904. return
  9905. }
  9906. return *v, true
  9907. }
  9908. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  9909. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9910. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9911. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  9912. if !m.op.Is(OpUpdateOne) {
  9913. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  9914. }
  9915. if m.id == nil || m.oldValue == nil {
  9916. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  9917. }
  9918. oldValue, err := m.oldValue(ctx)
  9919. if err != nil {
  9920. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  9921. }
  9922. return oldValue.SubSourceID, nil
  9923. }
  9924. // ClearSubSourceID clears the value of the "sub_source_id" field.
  9925. func (m *MessageRecordsMutation) ClearSubSourceID() {
  9926. m.sop_node = nil
  9927. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  9928. }
  9929. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  9930. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  9931. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  9932. return ok
  9933. }
  9934. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  9935. func (m *MessageRecordsMutation) ResetSubSourceID() {
  9936. m.sop_node = nil
  9937. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  9938. }
  9939. // SetOrganizationID sets the "organization_id" field.
  9940. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  9941. m.organization_id = &u
  9942. m.addorganization_id = nil
  9943. }
  9944. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9945. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  9946. v := m.organization_id
  9947. if v == nil {
  9948. return
  9949. }
  9950. return *v, true
  9951. }
  9952. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  9953. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9955. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9956. if !m.op.Is(OpUpdateOne) {
  9957. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9958. }
  9959. if m.id == nil || m.oldValue == nil {
  9960. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9961. }
  9962. oldValue, err := m.oldValue(ctx)
  9963. if err != nil {
  9964. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9965. }
  9966. return oldValue.OrganizationID, nil
  9967. }
  9968. // AddOrganizationID adds u to the "organization_id" field.
  9969. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  9970. if m.addorganization_id != nil {
  9971. *m.addorganization_id += u
  9972. } else {
  9973. m.addorganization_id = &u
  9974. }
  9975. }
  9976. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9977. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  9978. v := m.addorganization_id
  9979. if v == nil {
  9980. return
  9981. }
  9982. return *v, true
  9983. }
  9984. // ClearOrganizationID clears the value of the "organization_id" field.
  9985. func (m *MessageRecordsMutation) ClearOrganizationID() {
  9986. m.organization_id = nil
  9987. m.addorganization_id = nil
  9988. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  9989. }
  9990. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  9991. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  9992. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  9993. return ok
  9994. }
  9995. // ResetOrganizationID resets all changes to the "organization_id" field.
  9996. func (m *MessageRecordsMutation) ResetOrganizationID() {
  9997. m.organization_id = nil
  9998. m.addorganization_id = nil
  9999. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  10000. }
  10001. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  10002. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  10003. m.sop_stage = &id
  10004. }
  10005. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  10006. func (m *MessageRecordsMutation) ClearSopStage() {
  10007. m.clearedsop_stage = true
  10008. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  10009. }
  10010. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  10011. func (m *MessageRecordsMutation) SopStageCleared() bool {
  10012. return m.SourceIDCleared() || m.clearedsop_stage
  10013. }
  10014. // SopStageID returns the "sop_stage" edge ID in the mutation.
  10015. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  10016. if m.sop_stage != nil {
  10017. return *m.sop_stage, true
  10018. }
  10019. return
  10020. }
  10021. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  10022. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  10023. // SopStageID instead. It exists only for internal usage by the builders.
  10024. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  10025. if id := m.sop_stage; id != nil {
  10026. ids = append(ids, *id)
  10027. }
  10028. return
  10029. }
  10030. // ResetSopStage resets all changes to the "sop_stage" edge.
  10031. func (m *MessageRecordsMutation) ResetSopStage() {
  10032. m.sop_stage = nil
  10033. m.clearedsop_stage = false
  10034. }
  10035. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  10036. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  10037. m.sop_node = &id
  10038. }
  10039. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  10040. func (m *MessageRecordsMutation) ClearSopNode() {
  10041. m.clearedsop_node = true
  10042. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  10043. }
  10044. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  10045. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  10046. return m.SubSourceIDCleared() || m.clearedsop_node
  10047. }
  10048. // SopNodeID returns the "sop_node" edge ID in the mutation.
  10049. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  10050. if m.sop_node != nil {
  10051. return *m.sop_node, true
  10052. }
  10053. return
  10054. }
  10055. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  10056. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  10057. // SopNodeID instead. It exists only for internal usage by the builders.
  10058. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  10059. if id := m.sop_node; id != nil {
  10060. ids = append(ids, *id)
  10061. }
  10062. return
  10063. }
  10064. // ResetSopNode resets all changes to the "sop_node" edge.
  10065. func (m *MessageRecordsMutation) ResetSopNode() {
  10066. m.sop_node = nil
  10067. m.clearedsop_node = false
  10068. }
  10069. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  10070. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  10071. m.message_contact = &id
  10072. }
  10073. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  10074. func (m *MessageRecordsMutation) ClearMessageContact() {
  10075. m.clearedmessage_contact = true
  10076. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  10077. }
  10078. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  10079. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  10080. return m.ContactIDCleared() || m.clearedmessage_contact
  10081. }
  10082. // MessageContactID returns the "message_contact" edge ID in the mutation.
  10083. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  10084. if m.message_contact != nil {
  10085. return *m.message_contact, true
  10086. }
  10087. return
  10088. }
  10089. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  10090. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  10091. // MessageContactID instead. It exists only for internal usage by the builders.
  10092. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  10093. if id := m.message_contact; id != nil {
  10094. ids = append(ids, *id)
  10095. }
  10096. return
  10097. }
  10098. // ResetMessageContact resets all changes to the "message_contact" edge.
  10099. func (m *MessageRecordsMutation) ResetMessageContact() {
  10100. m.message_contact = nil
  10101. m.clearedmessage_contact = false
  10102. }
  10103. // Where appends a list predicates to the MessageRecordsMutation builder.
  10104. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  10105. m.predicates = append(m.predicates, ps...)
  10106. }
  10107. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  10108. // users can use type-assertion to append predicates that do not depend on any generated package.
  10109. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  10110. p := make([]predicate.MessageRecords, len(ps))
  10111. for i := range ps {
  10112. p[i] = ps[i]
  10113. }
  10114. m.Where(p...)
  10115. }
  10116. // Op returns the operation name.
  10117. func (m *MessageRecordsMutation) Op() Op {
  10118. return m.op
  10119. }
  10120. // SetOp allows setting the mutation operation.
  10121. func (m *MessageRecordsMutation) SetOp(op Op) {
  10122. m.op = op
  10123. }
  10124. // Type returns the node type of this mutation (MessageRecords).
  10125. func (m *MessageRecordsMutation) Type() string {
  10126. return m.typ
  10127. }
  10128. // Fields returns all fields that were changed during this mutation. Note that in
  10129. // order to get all numeric fields that were incremented/decremented, call
  10130. // AddedFields().
  10131. func (m *MessageRecordsMutation) Fields() []string {
  10132. fields := make([]string, 0, 17)
  10133. if m.created_at != nil {
  10134. fields = append(fields, messagerecords.FieldCreatedAt)
  10135. }
  10136. if m.updated_at != nil {
  10137. fields = append(fields, messagerecords.FieldUpdatedAt)
  10138. }
  10139. if m.status != nil {
  10140. fields = append(fields, messagerecords.FieldStatus)
  10141. }
  10142. if m.deleted_at != nil {
  10143. fields = append(fields, messagerecords.FieldDeletedAt)
  10144. }
  10145. if m.bot_wxid != nil {
  10146. fields = append(fields, messagerecords.FieldBotWxid)
  10147. }
  10148. if m.message_contact != nil {
  10149. fields = append(fields, messagerecords.FieldContactID)
  10150. }
  10151. if m.contact_type != nil {
  10152. fields = append(fields, messagerecords.FieldContactType)
  10153. }
  10154. if m.contact_wxid != nil {
  10155. fields = append(fields, messagerecords.FieldContactWxid)
  10156. }
  10157. if m.content_type != nil {
  10158. fields = append(fields, messagerecords.FieldContentType)
  10159. }
  10160. if m.content != nil {
  10161. fields = append(fields, messagerecords.FieldContent)
  10162. }
  10163. if m.meta != nil {
  10164. fields = append(fields, messagerecords.FieldMeta)
  10165. }
  10166. if m.error_detail != nil {
  10167. fields = append(fields, messagerecords.FieldErrorDetail)
  10168. }
  10169. if m.send_time != nil {
  10170. fields = append(fields, messagerecords.FieldSendTime)
  10171. }
  10172. if m.source_type != nil {
  10173. fields = append(fields, messagerecords.FieldSourceType)
  10174. }
  10175. if m.sop_stage != nil {
  10176. fields = append(fields, messagerecords.FieldSourceID)
  10177. }
  10178. if m.sop_node != nil {
  10179. fields = append(fields, messagerecords.FieldSubSourceID)
  10180. }
  10181. if m.organization_id != nil {
  10182. fields = append(fields, messagerecords.FieldOrganizationID)
  10183. }
  10184. return fields
  10185. }
  10186. // Field returns the value of a field with the given name. The second boolean
  10187. // return value indicates that this field was not set, or was not defined in the
  10188. // schema.
  10189. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  10190. switch name {
  10191. case messagerecords.FieldCreatedAt:
  10192. return m.CreatedAt()
  10193. case messagerecords.FieldUpdatedAt:
  10194. return m.UpdatedAt()
  10195. case messagerecords.FieldStatus:
  10196. return m.Status()
  10197. case messagerecords.FieldDeletedAt:
  10198. return m.DeletedAt()
  10199. case messagerecords.FieldBotWxid:
  10200. return m.BotWxid()
  10201. case messagerecords.FieldContactID:
  10202. return m.ContactID()
  10203. case messagerecords.FieldContactType:
  10204. return m.ContactType()
  10205. case messagerecords.FieldContactWxid:
  10206. return m.ContactWxid()
  10207. case messagerecords.FieldContentType:
  10208. return m.ContentType()
  10209. case messagerecords.FieldContent:
  10210. return m.Content()
  10211. case messagerecords.FieldMeta:
  10212. return m.Meta()
  10213. case messagerecords.FieldErrorDetail:
  10214. return m.ErrorDetail()
  10215. case messagerecords.FieldSendTime:
  10216. return m.SendTime()
  10217. case messagerecords.FieldSourceType:
  10218. return m.SourceType()
  10219. case messagerecords.FieldSourceID:
  10220. return m.SourceID()
  10221. case messagerecords.FieldSubSourceID:
  10222. return m.SubSourceID()
  10223. case messagerecords.FieldOrganizationID:
  10224. return m.OrganizationID()
  10225. }
  10226. return nil, false
  10227. }
  10228. // OldField returns the old value of the field from the database. An error is
  10229. // returned if the mutation operation is not UpdateOne, or the query to the
  10230. // database failed.
  10231. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10232. switch name {
  10233. case messagerecords.FieldCreatedAt:
  10234. return m.OldCreatedAt(ctx)
  10235. case messagerecords.FieldUpdatedAt:
  10236. return m.OldUpdatedAt(ctx)
  10237. case messagerecords.FieldStatus:
  10238. return m.OldStatus(ctx)
  10239. case messagerecords.FieldDeletedAt:
  10240. return m.OldDeletedAt(ctx)
  10241. case messagerecords.FieldBotWxid:
  10242. return m.OldBotWxid(ctx)
  10243. case messagerecords.FieldContactID:
  10244. return m.OldContactID(ctx)
  10245. case messagerecords.FieldContactType:
  10246. return m.OldContactType(ctx)
  10247. case messagerecords.FieldContactWxid:
  10248. return m.OldContactWxid(ctx)
  10249. case messagerecords.FieldContentType:
  10250. return m.OldContentType(ctx)
  10251. case messagerecords.FieldContent:
  10252. return m.OldContent(ctx)
  10253. case messagerecords.FieldMeta:
  10254. return m.OldMeta(ctx)
  10255. case messagerecords.FieldErrorDetail:
  10256. return m.OldErrorDetail(ctx)
  10257. case messagerecords.FieldSendTime:
  10258. return m.OldSendTime(ctx)
  10259. case messagerecords.FieldSourceType:
  10260. return m.OldSourceType(ctx)
  10261. case messagerecords.FieldSourceID:
  10262. return m.OldSourceID(ctx)
  10263. case messagerecords.FieldSubSourceID:
  10264. return m.OldSubSourceID(ctx)
  10265. case messagerecords.FieldOrganizationID:
  10266. return m.OldOrganizationID(ctx)
  10267. }
  10268. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  10269. }
  10270. // SetField sets the value of a field with the given name. It returns an error if
  10271. // the field is not defined in the schema, or if the type mismatched the field
  10272. // type.
  10273. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  10274. switch name {
  10275. case messagerecords.FieldCreatedAt:
  10276. v, ok := value.(time.Time)
  10277. if !ok {
  10278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10279. }
  10280. m.SetCreatedAt(v)
  10281. return nil
  10282. case messagerecords.FieldUpdatedAt:
  10283. v, ok := value.(time.Time)
  10284. if !ok {
  10285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10286. }
  10287. m.SetUpdatedAt(v)
  10288. return nil
  10289. case messagerecords.FieldStatus:
  10290. v, ok := value.(uint8)
  10291. if !ok {
  10292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10293. }
  10294. m.SetStatus(v)
  10295. return nil
  10296. case messagerecords.FieldDeletedAt:
  10297. v, ok := value.(time.Time)
  10298. if !ok {
  10299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10300. }
  10301. m.SetDeletedAt(v)
  10302. return nil
  10303. case messagerecords.FieldBotWxid:
  10304. v, ok := value.(string)
  10305. if !ok {
  10306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10307. }
  10308. m.SetBotWxid(v)
  10309. return nil
  10310. case messagerecords.FieldContactID:
  10311. v, ok := value.(uint64)
  10312. if !ok {
  10313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10314. }
  10315. m.SetContactID(v)
  10316. return nil
  10317. case messagerecords.FieldContactType:
  10318. v, ok := value.(int)
  10319. if !ok {
  10320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10321. }
  10322. m.SetContactType(v)
  10323. return nil
  10324. case messagerecords.FieldContactWxid:
  10325. v, ok := value.(string)
  10326. if !ok {
  10327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10328. }
  10329. m.SetContactWxid(v)
  10330. return nil
  10331. case messagerecords.FieldContentType:
  10332. v, ok := value.(int)
  10333. if !ok {
  10334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10335. }
  10336. m.SetContentType(v)
  10337. return nil
  10338. case messagerecords.FieldContent:
  10339. v, ok := value.(string)
  10340. if !ok {
  10341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10342. }
  10343. m.SetContent(v)
  10344. return nil
  10345. case messagerecords.FieldMeta:
  10346. v, ok := value.(custom_types.Meta)
  10347. if !ok {
  10348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10349. }
  10350. m.SetMeta(v)
  10351. return nil
  10352. case messagerecords.FieldErrorDetail:
  10353. v, ok := value.(string)
  10354. if !ok {
  10355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10356. }
  10357. m.SetErrorDetail(v)
  10358. return nil
  10359. case messagerecords.FieldSendTime:
  10360. v, ok := value.(time.Time)
  10361. if !ok {
  10362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10363. }
  10364. m.SetSendTime(v)
  10365. return nil
  10366. case messagerecords.FieldSourceType:
  10367. v, ok := value.(int)
  10368. if !ok {
  10369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10370. }
  10371. m.SetSourceType(v)
  10372. return nil
  10373. case messagerecords.FieldSourceID:
  10374. v, ok := value.(uint64)
  10375. if !ok {
  10376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10377. }
  10378. m.SetSourceID(v)
  10379. return nil
  10380. case messagerecords.FieldSubSourceID:
  10381. v, ok := value.(uint64)
  10382. if !ok {
  10383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10384. }
  10385. m.SetSubSourceID(v)
  10386. return nil
  10387. case messagerecords.FieldOrganizationID:
  10388. v, ok := value.(uint64)
  10389. if !ok {
  10390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10391. }
  10392. m.SetOrganizationID(v)
  10393. return nil
  10394. }
  10395. return fmt.Errorf("unknown MessageRecords field %s", name)
  10396. }
  10397. // AddedFields returns all numeric fields that were incremented/decremented during
  10398. // this mutation.
  10399. func (m *MessageRecordsMutation) AddedFields() []string {
  10400. var fields []string
  10401. if m.addstatus != nil {
  10402. fields = append(fields, messagerecords.FieldStatus)
  10403. }
  10404. if m.addcontact_type != nil {
  10405. fields = append(fields, messagerecords.FieldContactType)
  10406. }
  10407. if m.addcontent_type != nil {
  10408. fields = append(fields, messagerecords.FieldContentType)
  10409. }
  10410. if m.addsource_type != nil {
  10411. fields = append(fields, messagerecords.FieldSourceType)
  10412. }
  10413. if m.addorganization_id != nil {
  10414. fields = append(fields, messagerecords.FieldOrganizationID)
  10415. }
  10416. return fields
  10417. }
  10418. // AddedField returns the numeric value that was incremented/decremented on a field
  10419. // with the given name. The second boolean return value indicates that this field
  10420. // was not set, or was not defined in the schema.
  10421. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  10422. switch name {
  10423. case messagerecords.FieldStatus:
  10424. return m.AddedStatus()
  10425. case messagerecords.FieldContactType:
  10426. return m.AddedContactType()
  10427. case messagerecords.FieldContentType:
  10428. return m.AddedContentType()
  10429. case messagerecords.FieldSourceType:
  10430. return m.AddedSourceType()
  10431. case messagerecords.FieldOrganizationID:
  10432. return m.AddedOrganizationID()
  10433. }
  10434. return nil, false
  10435. }
  10436. // AddField adds the value to the field with the given name. It returns an error if
  10437. // the field is not defined in the schema, or if the type mismatched the field
  10438. // type.
  10439. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  10440. switch name {
  10441. case messagerecords.FieldStatus:
  10442. v, ok := value.(int8)
  10443. if !ok {
  10444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10445. }
  10446. m.AddStatus(v)
  10447. return nil
  10448. case messagerecords.FieldContactType:
  10449. v, ok := value.(int)
  10450. if !ok {
  10451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10452. }
  10453. m.AddContactType(v)
  10454. return nil
  10455. case messagerecords.FieldContentType:
  10456. v, ok := value.(int)
  10457. if !ok {
  10458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10459. }
  10460. m.AddContentType(v)
  10461. return nil
  10462. case messagerecords.FieldSourceType:
  10463. v, ok := value.(int)
  10464. if !ok {
  10465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10466. }
  10467. m.AddSourceType(v)
  10468. return nil
  10469. case messagerecords.FieldOrganizationID:
  10470. v, ok := value.(int64)
  10471. if !ok {
  10472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10473. }
  10474. m.AddOrganizationID(v)
  10475. return nil
  10476. }
  10477. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  10478. }
  10479. // ClearedFields returns all nullable fields that were cleared during this
  10480. // mutation.
  10481. func (m *MessageRecordsMutation) ClearedFields() []string {
  10482. var fields []string
  10483. if m.FieldCleared(messagerecords.FieldStatus) {
  10484. fields = append(fields, messagerecords.FieldStatus)
  10485. }
  10486. if m.FieldCleared(messagerecords.FieldDeletedAt) {
  10487. fields = append(fields, messagerecords.FieldDeletedAt)
  10488. }
  10489. if m.FieldCleared(messagerecords.FieldContactID) {
  10490. fields = append(fields, messagerecords.FieldContactID)
  10491. }
  10492. if m.FieldCleared(messagerecords.FieldMeta) {
  10493. fields = append(fields, messagerecords.FieldMeta)
  10494. }
  10495. if m.FieldCleared(messagerecords.FieldSendTime) {
  10496. fields = append(fields, messagerecords.FieldSendTime)
  10497. }
  10498. if m.FieldCleared(messagerecords.FieldSourceID) {
  10499. fields = append(fields, messagerecords.FieldSourceID)
  10500. }
  10501. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  10502. fields = append(fields, messagerecords.FieldSubSourceID)
  10503. }
  10504. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  10505. fields = append(fields, messagerecords.FieldOrganizationID)
  10506. }
  10507. return fields
  10508. }
  10509. // FieldCleared returns a boolean indicating if a field with the given name was
  10510. // cleared in this mutation.
  10511. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  10512. _, ok := m.clearedFields[name]
  10513. return ok
  10514. }
  10515. // ClearField clears the value of the field with the given name. It returns an
  10516. // error if the field is not defined in the schema.
  10517. func (m *MessageRecordsMutation) ClearField(name string) error {
  10518. switch name {
  10519. case messagerecords.FieldStatus:
  10520. m.ClearStatus()
  10521. return nil
  10522. case messagerecords.FieldDeletedAt:
  10523. m.ClearDeletedAt()
  10524. return nil
  10525. case messagerecords.FieldContactID:
  10526. m.ClearContactID()
  10527. return nil
  10528. case messagerecords.FieldMeta:
  10529. m.ClearMeta()
  10530. return nil
  10531. case messagerecords.FieldSendTime:
  10532. m.ClearSendTime()
  10533. return nil
  10534. case messagerecords.FieldSourceID:
  10535. m.ClearSourceID()
  10536. return nil
  10537. case messagerecords.FieldSubSourceID:
  10538. m.ClearSubSourceID()
  10539. return nil
  10540. case messagerecords.FieldOrganizationID:
  10541. m.ClearOrganizationID()
  10542. return nil
  10543. }
  10544. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  10545. }
  10546. // ResetField resets all changes in the mutation for the field with the given name.
  10547. // It returns an error if the field is not defined in the schema.
  10548. func (m *MessageRecordsMutation) ResetField(name string) error {
  10549. switch name {
  10550. case messagerecords.FieldCreatedAt:
  10551. m.ResetCreatedAt()
  10552. return nil
  10553. case messagerecords.FieldUpdatedAt:
  10554. m.ResetUpdatedAt()
  10555. return nil
  10556. case messagerecords.FieldStatus:
  10557. m.ResetStatus()
  10558. return nil
  10559. case messagerecords.FieldDeletedAt:
  10560. m.ResetDeletedAt()
  10561. return nil
  10562. case messagerecords.FieldBotWxid:
  10563. m.ResetBotWxid()
  10564. return nil
  10565. case messagerecords.FieldContactID:
  10566. m.ResetContactID()
  10567. return nil
  10568. case messagerecords.FieldContactType:
  10569. m.ResetContactType()
  10570. return nil
  10571. case messagerecords.FieldContactWxid:
  10572. m.ResetContactWxid()
  10573. return nil
  10574. case messagerecords.FieldContentType:
  10575. m.ResetContentType()
  10576. return nil
  10577. case messagerecords.FieldContent:
  10578. m.ResetContent()
  10579. return nil
  10580. case messagerecords.FieldMeta:
  10581. m.ResetMeta()
  10582. return nil
  10583. case messagerecords.FieldErrorDetail:
  10584. m.ResetErrorDetail()
  10585. return nil
  10586. case messagerecords.FieldSendTime:
  10587. m.ResetSendTime()
  10588. return nil
  10589. case messagerecords.FieldSourceType:
  10590. m.ResetSourceType()
  10591. return nil
  10592. case messagerecords.FieldSourceID:
  10593. m.ResetSourceID()
  10594. return nil
  10595. case messagerecords.FieldSubSourceID:
  10596. m.ResetSubSourceID()
  10597. return nil
  10598. case messagerecords.FieldOrganizationID:
  10599. m.ResetOrganizationID()
  10600. return nil
  10601. }
  10602. return fmt.Errorf("unknown MessageRecords field %s", name)
  10603. }
  10604. // AddedEdges returns all edge names that were set/added in this mutation.
  10605. func (m *MessageRecordsMutation) AddedEdges() []string {
  10606. edges := make([]string, 0, 3)
  10607. if m.sop_stage != nil {
  10608. edges = append(edges, messagerecords.EdgeSopStage)
  10609. }
  10610. if m.sop_node != nil {
  10611. edges = append(edges, messagerecords.EdgeSopNode)
  10612. }
  10613. if m.message_contact != nil {
  10614. edges = append(edges, messagerecords.EdgeMessageContact)
  10615. }
  10616. return edges
  10617. }
  10618. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10619. // name in this mutation.
  10620. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  10621. switch name {
  10622. case messagerecords.EdgeSopStage:
  10623. if id := m.sop_stage; id != nil {
  10624. return []ent.Value{*id}
  10625. }
  10626. case messagerecords.EdgeSopNode:
  10627. if id := m.sop_node; id != nil {
  10628. return []ent.Value{*id}
  10629. }
  10630. case messagerecords.EdgeMessageContact:
  10631. if id := m.message_contact; id != nil {
  10632. return []ent.Value{*id}
  10633. }
  10634. }
  10635. return nil
  10636. }
  10637. // RemovedEdges returns all edge names that were removed in this mutation.
  10638. func (m *MessageRecordsMutation) RemovedEdges() []string {
  10639. edges := make([]string, 0, 3)
  10640. return edges
  10641. }
  10642. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10643. // the given name in this mutation.
  10644. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  10645. return nil
  10646. }
  10647. // ClearedEdges returns all edge names that were cleared in this mutation.
  10648. func (m *MessageRecordsMutation) ClearedEdges() []string {
  10649. edges := make([]string, 0, 3)
  10650. if m.clearedsop_stage {
  10651. edges = append(edges, messagerecords.EdgeSopStage)
  10652. }
  10653. if m.clearedsop_node {
  10654. edges = append(edges, messagerecords.EdgeSopNode)
  10655. }
  10656. if m.clearedmessage_contact {
  10657. edges = append(edges, messagerecords.EdgeMessageContact)
  10658. }
  10659. return edges
  10660. }
  10661. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10662. // was cleared in this mutation.
  10663. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  10664. switch name {
  10665. case messagerecords.EdgeSopStage:
  10666. return m.clearedsop_stage
  10667. case messagerecords.EdgeSopNode:
  10668. return m.clearedsop_node
  10669. case messagerecords.EdgeMessageContact:
  10670. return m.clearedmessage_contact
  10671. }
  10672. return false
  10673. }
  10674. // ClearEdge clears the value of the edge with the given name. It returns an error
  10675. // if that edge is not defined in the schema.
  10676. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  10677. switch name {
  10678. case messagerecords.EdgeSopStage:
  10679. m.ClearSopStage()
  10680. return nil
  10681. case messagerecords.EdgeSopNode:
  10682. m.ClearSopNode()
  10683. return nil
  10684. case messagerecords.EdgeMessageContact:
  10685. m.ClearMessageContact()
  10686. return nil
  10687. }
  10688. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  10689. }
  10690. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10691. // It returns an error if the edge is not defined in the schema.
  10692. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  10693. switch name {
  10694. case messagerecords.EdgeSopStage:
  10695. m.ResetSopStage()
  10696. return nil
  10697. case messagerecords.EdgeSopNode:
  10698. m.ResetSopNode()
  10699. return nil
  10700. case messagerecords.EdgeMessageContact:
  10701. m.ResetMessageContact()
  10702. return nil
  10703. }
  10704. return fmt.Errorf("unknown MessageRecords edge %s", name)
  10705. }
  10706. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  10707. type MsgMutation struct {
  10708. config
  10709. op Op
  10710. typ string
  10711. id *uint64
  10712. created_at *time.Time
  10713. updated_at *time.Time
  10714. deleted_at *time.Time
  10715. status *uint8
  10716. addstatus *int8
  10717. fromwxid *string
  10718. toid *string
  10719. msgtype *int32
  10720. addmsgtype *int32
  10721. msg *string
  10722. batch_no *string
  10723. clearedFields map[string]struct{}
  10724. done bool
  10725. oldValue func(context.Context) (*Msg, error)
  10726. predicates []predicate.Msg
  10727. }
  10728. var _ ent.Mutation = (*MsgMutation)(nil)
  10729. // msgOption allows management of the mutation configuration using functional options.
  10730. type msgOption func(*MsgMutation)
  10731. // newMsgMutation creates new mutation for the Msg entity.
  10732. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  10733. m := &MsgMutation{
  10734. config: c,
  10735. op: op,
  10736. typ: TypeMsg,
  10737. clearedFields: make(map[string]struct{}),
  10738. }
  10739. for _, opt := range opts {
  10740. opt(m)
  10741. }
  10742. return m
  10743. }
  10744. // withMsgID sets the ID field of the mutation.
  10745. func withMsgID(id uint64) msgOption {
  10746. return func(m *MsgMutation) {
  10747. var (
  10748. err error
  10749. once sync.Once
  10750. value *Msg
  10751. )
  10752. m.oldValue = func(ctx context.Context) (*Msg, error) {
  10753. once.Do(func() {
  10754. if m.done {
  10755. err = errors.New("querying old values post mutation is not allowed")
  10756. } else {
  10757. value, err = m.Client().Msg.Get(ctx, id)
  10758. }
  10759. })
  10760. return value, err
  10761. }
  10762. m.id = &id
  10763. }
  10764. }
  10765. // withMsg sets the old Msg of the mutation.
  10766. func withMsg(node *Msg) msgOption {
  10767. return func(m *MsgMutation) {
  10768. m.oldValue = func(context.Context) (*Msg, error) {
  10769. return node, nil
  10770. }
  10771. m.id = &node.ID
  10772. }
  10773. }
  10774. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10775. // executed in a transaction (ent.Tx), a transactional client is returned.
  10776. func (m MsgMutation) Client() *Client {
  10777. client := &Client{config: m.config}
  10778. client.init()
  10779. return client
  10780. }
  10781. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10782. // it returns an error otherwise.
  10783. func (m MsgMutation) Tx() (*Tx, error) {
  10784. if _, ok := m.driver.(*txDriver); !ok {
  10785. return nil, errors.New("ent: mutation is not running in a transaction")
  10786. }
  10787. tx := &Tx{config: m.config}
  10788. tx.init()
  10789. return tx, nil
  10790. }
  10791. // SetID sets the value of the id field. Note that this
  10792. // operation is only accepted on creation of Msg entities.
  10793. func (m *MsgMutation) SetID(id uint64) {
  10794. m.id = &id
  10795. }
  10796. // ID returns the ID value in the mutation. Note that the ID is only available
  10797. // if it was provided to the builder or after it was returned from the database.
  10798. func (m *MsgMutation) ID() (id uint64, exists bool) {
  10799. if m.id == nil {
  10800. return
  10801. }
  10802. return *m.id, true
  10803. }
  10804. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10805. // That means, if the mutation is applied within a transaction with an isolation level such
  10806. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10807. // or updated by the mutation.
  10808. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  10809. switch {
  10810. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10811. id, exists := m.ID()
  10812. if exists {
  10813. return []uint64{id}, nil
  10814. }
  10815. fallthrough
  10816. case m.op.Is(OpUpdate | OpDelete):
  10817. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  10818. default:
  10819. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10820. }
  10821. }
  10822. // SetCreatedAt sets the "created_at" field.
  10823. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  10824. m.created_at = &t
  10825. }
  10826. // CreatedAt returns the value of the "created_at" field in the mutation.
  10827. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  10828. v := m.created_at
  10829. if v == nil {
  10830. return
  10831. }
  10832. return *v, true
  10833. }
  10834. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  10835. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10837. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10838. if !m.op.Is(OpUpdateOne) {
  10839. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10840. }
  10841. if m.id == nil || m.oldValue == nil {
  10842. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10843. }
  10844. oldValue, err := m.oldValue(ctx)
  10845. if err != nil {
  10846. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10847. }
  10848. return oldValue.CreatedAt, nil
  10849. }
  10850. // ResetCreatedAt resets all changes to the "created_at" field.
  10851. func (m *MsgMutation) ResetCreatedAt() {
  10852. m.created_at = nil
  10853. }
  10854. // SetUpdatedAt sets the "updated_at" field.
  10855. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  10856. m.updated_at = &t
  10857. }
  10858. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10859. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  10860. v := m.updated_at
  10861. if v == nil {
  10862. return
  10863. }
  10864. return *v, true
  10865. }
  10866. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  10867. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10869. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10870. if !m.op.Is(OpUpdateOne) {
  10871. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10872. }
  10873. if m.id == nil || m.oldValue == nil {
  10874. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10875. }
  10876. oldValue, err := m.oldValue(ctx)
  10877. if err != nil {
  10878. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10879. }
  10880. return oldValue.UpdatedAt, nil
  10881. }
  10882. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10883. func (m *MsgMutation) ResetUpdatedAt() {
  10884. m.updated_at = nil
  10885. }
  10886. // SetDeletedAt sets the "deleted_at" field.
  10887. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  10888. m.deleted_at = &t
  10889. }
  10890. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10891. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  10892. v := m.deleted_at
  10893. if v == nil {
  10894. return
  10895. }
  10896. return *v, true
  10897. }
  10898. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  10899. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10901. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10902. if !m.op.Is(OpUpdateOne) {
  10903. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10904. }
  10905. if m.id == nil || m.oldValue == nil {
  10906. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10907. }
  10908. oldValue, err := m.oldValue(ctx)
  10909. if err != nil {
  10910. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10911. }
  10912. return oldValue.DeletedAt, nil
  10913. }
  10914. // ClearDeletedAt clears the value of the "deleted_at" field.
  10915. func (m *MsgMutation) ClearDeletedAt() {
  10916. m.deleted_at = nil
  10917. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  10918. }
  10919. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10920. func (m *MsgMutation) DeletedAtCleared() bool {
  10921. _, ok := m.clearedFields[msg.FieldDeletedAt]
  10922. return ok
  10923. }
  10924. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10925. func (m *MsgMutation) ResetDeletedAt() {
  10926. m.deleted_at = nil
  10927. delete(m.clearedFields, msg.FieldDeletedAt)
  10928. }
  10929. // SetStatus sets the "status" field.
  10930. func (m *MsgMutation) SetStatus(u uint8) {
  10931. m.status = &u
  10932. m.addstatus = nil
  10933. }
  10934. // Status returns the value of the "status" field in the mutation.
  10935. func (m *MsgMutation) Status() (r uint8, exists bool) {
  10936. v := m.status
  10937. if v == nil {
  10938. return
  10939. }
  10940. return *v, true
  10941. }
  10942. // OldStatus returns the old "status" field's value of the Msg entity.
  10943. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10945. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  10946. if !m.op.Is(OpUpdateOne) {
  10947. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10948. }
  10949. if m.id == nil || m.oldValue == nil {
  10950. return v, errors.New("OldStatus requires an ID field in the mutation")
  10951. }
  10952. oldValue, err := m.oldValue(ctx)
  10953. if err != nil {
  10954. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10955. }
  10956. return oldValue.Status, nil
  10957. }
  10958. // AddStatus adds u to the "status" field.
  10959. func (m *MsgMutation) AddStatus(u int8) {
  10960. if m.addstatus != nil {
  10961. *m.addstatus += u
  10962. } else {
  10963. m.addstatus = &u
  10964. }
  10965. }
  10966. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10967. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  10968. v := m.addstatus
  10969. if v == nil {
  10970. return
  10971. }
  10972. return *v, true
  10973. }
  10974. // ClearStatus clears the value of the "status" field.
  10975. func (m *MsgMutation) ClearStatus() {
  10976. m.status = nil
  10977. m.addstatus = nil
  10978. m.clearedFields[msg.FieldStatus] = struct{}{}
  10979. }
  10980. // StatusCleared returns if the "status" field was cleared in this mutation.
  10981. func (m *MsgMutation) StatusCleared() bool {
  10982. _, ok := m.clearedFields[msg.FieldStatus]
  10983. return ok
  10984. }
  10985. // ResetStatus resets all changes to the "status" field.
  10986. func (m *MsgMutation) ResetStatus() {
  10987. m.status = nil
  10988. m.addstatus = nil
  10989. delete(m.clearedFields, msg.FieldStatus)
  10990. }
  10991. // SetFromwxid sets the "fromwxid" field.
  10992. func (m *MsgMutation) SetFromwxid(s string) {
  10993. m.fromwxid = &s
  10994. }
  10995. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  10996. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  10997. v := m.fromwxid
  10998. if v == nil {
  10999. return
  11000. }
  11001. return *v, true
  11002. }
  11003. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  11004. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11006. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  11007. if !m.op.Is(OpUpdateOne) {
  11008. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  11009. }
  11010. if m.id == nil || m.oldValue == nil {
  11011. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  11012. }
  11013. oldValue, err := m.oldValue(ctx)
  11014. if err != nil {
  11015. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  11016. }
  11017. return oldValue.Fromwxid, nil
  11018. }
  11019. // ClearFromwxid clears the value of the "fromwxid" field.
  11020. func (m *MsgMutation) ClearFromwxid() {
  11021. m.fromwxid = nil
  11022. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  11023. }
  11024. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  11025. func (m *MsgMutation) FromwxidCleared() bool {
  11026. _, ok := m.clearedFields[msg.FieldFromwxid]
  11027. return ok
  11028. }
  11029. // ResetFromwxid resets all changes to the "fromwxid" field.
  11030. func (m *MsgMutation) ResetFromwxid() {
  11031. m.fromwxid = nil
  11032. delete(m.clearedFields, msg.FieldFromwxid)
  11033. }
  11034. // SetToid sets the "toid" field.
  11035. func (m *MsgMutation) SetToid(s string) {
  11036. m.toid = &s
  11037. }
  11038. // Toid returns the value of the "toid" field in the mutation.
  11039. func (m *MsgMutation) Toid() (r string, exists bool) {
  11040. v := m.toid
  11041. if v == nil {
  11042. return
  11043. }
  11044. return *v, true
  11045. }
  11046. // OldToid returns the old "toid" field's value of the Msg entity.
  11047. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11049. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  11050. if !m.op.Is(OpUpdateOne) {
  11051. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  11052. }
  11053. if m.id == nil || m.oldValue == nil {
  11054. return v, errors.New("OldToid requires an ID field in the mutation")
  11055. }
  11056. oldValue, err := m.oldValue(ctx)
  11057. if err != nil {
  11058. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  11059. }
  11060. return oldValue.Toid, nil
  11061. }
  11062. // ClearToid clears the value of the "toid" field.
  11063. func (m *MsgMutation) ClearToid() {
  11064. m.toid = nil
  11065. m.clearedFields[msg.FieldToid] = struct{}{}
  11066. }
  11067. // ToidCleared returns if the "toid" field was cleared in this mutation.
  11068. func (m *MsgMutation) ToidCleared() bool {
  11069. _, ok := m.clearedFields[msg.FieldToid]
  11070. return ok
  11071. }
  11072. // ResetToid resets all changes to the "toid" field.
  11073. func (m *MsgMutation) ResetToid() {
  11074. m.toid = nil
  11075. delete(m.clearedFields, msg.FieldToid)
  11076. }
  11077. // SetMsgtype sets the "msgtype" field.
  11078. func (m *MsgMutation) SetMsgtype(i int32) {
  11079. m.msgtype = &i
  11080. m.addmsgtype = nil
  11081. }
  11082. // Msgtype returns the value of the "msgtype" field in the mutation.
  11083. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  11084. v := m.msgtype
  11085. if v == nil {
  11086. return
  11087. }
  11088. return *v, true
  11089. }
  11090. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  11091. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11093. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  11094. if !m.op.Is(OpUpdateOne) {
  11095. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  11096. }
  11097. if m.id == nil || m.oldValue == nil {
  11098. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  11099. }
  11100. oldValue, err := m.oldValue(ctx)
  11101. if err != nil {
  11102. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  11103. }
  11104. return oldValue.Msgtype, nil
  11105. }
  11106. // AddMsgtype adds i to the "msgtype" field.
  11107. func (m *MsgMutation) AddMsgtype(i int32) {
  11108. if m.addmsgtype != nil {
  11109. *m.addmsgtype += i
  11110. } else {
  11111. m.addmsgtype = &i
  11112. }
  11113. }
  11114. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  11115. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  11116. v := m.addmsgtype
  11117. if v == nil {
  11118. return
  11119. }
  11120. return *v, true
  11121. }
  11122. // ClearMsgtype clears the value of the "msgtype" field.
  11123. func (m *MsgMutation) ClearMsgtype() {
  11124. m.msgtype = nil
  11125. m.addmsgtype = nil
  11126. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  11127. }
  11128. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  11129. func (m *MsgMutation) MsgtypeCleared() bool {
  11130. _, ok := m.clearedFields[msg.FieldMsgtype]
  11131. return ok
  11132. }
  11133. // ResetMsgtype resets all changes to the "msgtype" field.
  11134. func (m *MsgMutation) ResetMsgtype() {
  11135. m.msgtype = nil
  11136. m.addmsgtype = nil
  11137. delete(m.clearedFields, msg.FieldMsgtype)
  11138. }
  11139. // SetMsg sets the "msg" field.
  11140. func (m *MsgMutation) SetMsg(s string) {
  11141. m.msg = &s
  11142. }
  11143. // Msg returns the value of the "msg" field in the mutation.
  11144. func (m *MsgMutation) Msg() (r string, exists bool) {
  11145. v := m.msg
  11146. if v == nil {
  11147. return
  11148. }
  11149. return *v, true
  11150. }
  11151. // OldMsg returns the old "msg" field's value of the Msg entity.
  11152. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11154. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  11155. if !m.op.Is(OpUpdateOne) {
  11156. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  11157. }
  11158. if m.id == nil || m.oldValue == nil {
  11159. return v, errors.New("OldMsg requires an ID field in the mutation")
  11160. }
  11161. oldValue, err := m.oldValue(ctx)
  11162. if err != nil {
  11163. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  11164. }
  11165. return oldValue.Msg, nil
  11166. }
  11167. // ClearMsg clears the value of the "msg" field.
  11168. func (m *MsgMutation) ClearMsg() {
  11169. m.msg = nil
  11170. m.clearedFields[msg.FieldMsg] = struct{}{}
  11171. }
  11172. // MsgCleared returns if the "msg" field was cleared in this mutation.
  11173. func (m *MsgMutation) MsgCleared() bool {
  11174. _, ok := m.clearedFields[msg.FieldMsg]
  11175. return ok
  11176. }
  11177. // ResetMsg resets all changes to the "msg" field.
  11178. func (m *MsgMutation) ResetMsg() {
  11179. m.msg = nil
  11180. delete(m.clearedFields, msg.FieldMsg)
  11181. }
  11182. // SetBatchNo sets the "batch_no" field.
  11183. func (m *MsgMutation) SetBatchNo(s string) {
  11184. m.batch_no = &s
  11185. }
  11186. // BatchNo returns the value of the "batch_no" field in the mutation.
  11187. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  11188. v := m.batch_no
  11189. if v == nil {
  11190. return
  11191. }
  11192. return *v, true
  11193. }
  11194. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  11195. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11197. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  11198. if !m.op.Is(OpUpdateOne) {
  11199. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  11200. }
  11201. if m.id == nil || m.oldValue == nil {
  11202. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  11203. }
  11204. oldValue, err := m.oldValue(ctx)
  11205. if err != nil {
  11206. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  11207. }
  11208. return oldValue.BatchNo, nil
  11209. }
  11210. // ClearBatchNo clears the value of the "batch_no" field.
  11211. func (m *MsgMutation) ClearBatchNo() {
  11212. m.batch_no = nil
  11213. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  11214. }
  11215. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  11216. func (m *MsgMutation) BatchNoCleared() bool {
  11217. _, ok := m.clearedFields[msg.FieldBatchNo]
  11218. return ok
  11219. }
  11220. // ResetBatchNo resets all changes to the "batch_no" field.
  11221. func (m *MsgMutation) ResetBatchNo() {
  11222. m.batch_no = nil
  11223. delete(m.clearedFields, msg.FieldBatchNo)
  11224. }
  11225. // Where appends a list predicates to the MsgMutation builder.
  11226. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  11227. m.predicates = append(m.predicates, ps...)
  11228. }
  11229. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  11230. // users can use type-assertion to append predicates that do not depend on any generated package.
  11231. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  11232. p := make([]predicate.Msg, len(ps))
  11233. for i := range ps {
  11234. p[i] = ps[i]
  11235. }
  11236. m.Where(p...)
  11237. }
  11238. // Op returns the operation name.
  11239. func (m *MsgMutation) Op() Op {
  11240. return m.op
  11241. }
  11242. // SetOp allows setting the mutation operation.
  11243. func (m *MsgMutation) SetOp(op Op) {
  11244. m.op = op
  11245. }
  11246. // Type returns the node type of this mutation (Msg).
  11247. func (m *MsgMutation) Type() string {
  11248. return m.typ
  11249. }
  11250. // Fields returns all fields that were changed during this mutation. Note that in
  11251. // order to get all numeric fields that were incremented/decremented, call
  11252. // AddedFields().
  11253. func (m *MsgMutation) Fields() []string {
  11254. fields := make([]string, 0, 9)
  11255. if m.created_at != nil {
  11256. fields = append(fields, msg.FieldCreatedAt)
  11257. }
  11258. if m.updated_at != nil {
  11259. fields = append(fields, msg.FieldUpdatedAt)
  11260. }
  11261. if m.deleted_at != nil {
  11262. fields = append(fields, msg.FieldDeletedAt)
  11263. }
  11264. if m.status != nil {
  11265. fields = append(fields, msg.FieldStatus)
  11266. }
  11267. if m.fromwxid != nil {
  11268. fields = append(fields, msg.FieldFromwxid)
  11269. }
  11270. if m.toid != nil {
  11271. fields = append(fields, msg.FieldToid)
  11272. }
  11273. if m.msgtype != nil {
  11274. fields = append(fields, msg.FieldMsgtype)
  11275. }
  11276. if m.msg != nil {
  11277. fields = append(fields, msg.FieldMsg)
  11278. }
  11279. if m.batch_no != nil {
  11280. fields = append(fields, msg.FieldBatchNo)
  11281. }
  11282. return fields
  11283. }
  11284. // Field returns the value of a field with the given name. The second boolean
  11285. // return value indicates that this field was not set, or was not defined in the
  11286. // schema.
  11287. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  11288. switch name {
  11289. case msg.FieldCreatedAt:
  11290. return m.CreatedAt()
  11291. case msg.FieldUpdatedAt:
  11292. return m.UpdatedAt()
  11293. case msg.FieldDeletedAt:
  11294. return m.DeletedAt()
  11295. case msg.FieldStatus:
  11296. return m.Status()
  11297. case msg.FieldFromwxid:
  11298. return m.Fromwxid()
  11299. case msg.FieldToid:
  11300. return m.Toid()
  11301. case msg.FieldMsgtype:
  11302. return m.Msgtype()
  11303. case msg.FieldMsg:
  11304. return m.Msg()
  11305. case msg.FieldBatchNo:
  11306. return m.BatchNo()
  11307. }
  11308. return nil, false
  11309. }
  11310. // OldField returns the old value of the field from the database. An error is
  11311. // returned if the mutation operation is not UpdateOne, or the query to the
  11312. // database failed.
  11313. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11314. switch name {
  11315. case msg.FieldCreatedAt:
  11316. return m.OldCreatedAt(ctx)
  11317. case msg.FieldUpdatedAt:
  11318. return m.OldUpdatedAt(ctx)
  11319. case msg.FieldDeletedAt:
  11320. return m.OldDeletedAt(ctx)
  11321. case msg.FieldStatus:
  11322. return m.OldStatus(ctx)
  11323. case msg.FieldFromwxid:
  11324. return m.OldFromwxid(ctx)
  11325. case msg.FieldToid:
  11326. return m.OldToid(ctx)
  11327. case msg.FieldMsgtype:
  11328. return m.OldMsgtype(ctx)
  11329. case msg.FieldMsg:
  11330. return m.OldMsg(ctx)
  11331. case msg.FieldBatchNo:
  11332. return m.OldBatchNo(ctx)
  11333. }
  11334. return nil, fmt.Errorf("unknown Msg field %s", name)
  11335. }
  11336. // SetField sets the value of a field with the given name. It returns an error if
  11337. // the field is not defined in the schema, or if the type mismatched the field
  11338. // type.
  11339. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  11340. switch name {
  11341. case msg.FieldCreatedAt:
  11342. v, ok := value.(time.Time)
  11343. if !ok {
  11344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11345. }
  11346. m.SetCreatedAt(v)
  11347. return nil
  11348. case msg.FieldUpdatedAt:
  11349. v, ok := value.(time.Time)
  11350. if !ok {
  11351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11352. }
  11353. m.SetUpdatedAt(v)
  11354. return nil
  11355. case msg.FieldDeletedAt:
  11356. v, ok := value.(time.Time)
  11357. if !ok {
  11358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11359. }
  11360. m.SetDeletedAt(v)
  11361. return nil
  11362. case msg.FieldStatus:
  11363. v, ok := value.(uint8)
  11364. if !ok {
  11365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11366. }
  11367. m.SetStatus(v)
  11368. return nil
  11369. case msg.FieldFromwxid:
  11370. v, ok := value.(string)
  11371. if !ok {
  11372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11373. }
  11374. m.SetFromwxid(v)
  11375. return nil
  11376. case msg.FieldToid:
  11377. v, ok := value.(string)
  11378. if !ok {
  11379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11380. }
  11381. m.SetToid(v)
  11382. return nil
  11383. case msg.FieldMsgtype:
  11384. v, ok := value.(int32)
  11385. if !ok {
  11386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11387. }
  11388. m.SetMsgtype(v)
  11389. return nil
  11390. case msg.FieldMsg:
  11391. v, ok := value.(string)
  11392. if !ok {
  11393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11394. }
  11395. m.SetMsg(v)
  11396. return nil
  11397. case msg.FieldBatchNo:
  11398. v, ok := value.(string)
  11399. if !ok {
  11400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11401. }
  11402. m.SetBatchNo(v)
  11403. return nil
  11404. }
  11405. return fmt.Errorf("unknown Msg field %s", name)
  11406. }
  11407. // AddedFields returns all numeric fields that were incremented/decremented during
  11408. // this mutation.
  11409. func (m *MsgMutation) AddedFields() []string {
  11410. var fields []string
  11411. if m.addstatus != nil {
  11412. fields = append(fields, msg.FieldStatus)
  11413. }
  11414. if m.addmsgtype != nil {
  11415. fields = append(fields, msg.FieldMsgtype)
  11416. }
  11417. return fields
  11418. }
  11419. // AddedField returns the numeric value that was incremented/decremented on a field
  11420. // with the given name. The second boolean return value indicates that this field
  11421. // was not set, or was not defined in the schema.
  11422. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  11423. switch name {
  11424. case msg.FieldStatus:
  11425. return m.AddedStatus()
  11426. case msg.FieldMsgtype:
  11427. return m.AddedMsgtype()
  11428. }
  11429. return nil, false
  11430. }
  11431. // AddField adds the value to the field with the given name. It returns an error if
  11432. // the field is not defined in the schema, or if the type mismatched the field
  11433. // type.
  11434. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  11435. switch name {
  11436. case msg.FieldStatus:
  11437. v, ok := value.(int8)
  11438. if !ok {
  11439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11440. }
  11441. m.AddStatus(v)
  11442. return nil
  11443. case msg.FieldMsgtype:
  11444. v, ok := value.(int32)
  11445. if !ok {
  11446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11447. }
  11448. m.AddMsgtype(v)
  11449. return nil
  11450. }
  11451. return fmt.Errorf("unknown Msg numeric field %s", name)
  11452. }
  11453. // ClearedFields returns all nullable fields that were cleared during this
  11454. // mutation.
  11455. func (m *MsgMutation) ClearedFields() []string {
  11456. var fields []string
  11457. if m.FieldCleared(msg.FieldDeletedAt) {
  11458. fields = append(fields, msg.FieldDeletedAt)
  11459. }
  11460. if m.FieldCleared(msg.FieldStatus) {
  11461. fields = append(fields, msg.FieldStatus)
  11462. }
  11463. if m.FieldCleared(msg.FieldFromwxid) {
  11464. fields = append(fields, msg.FieldFromwxid)
  11465. }
  11466. if m.FieldCleared(msg.FieldToid) {
  11467. fields = append(fields, msg.FieldToid)
  11468. }
  11469. if m.FieldCleared(msg.FieldMsgtype) {
  11470. fields = append(fields, msg.FieldMsgtype)
  11471. }
  11472. if m.FieldCleared(msg.FieldMsg) {
  11473. fields = append(fields, msg.FieldMsg)
  11474. }
  11475. if m.FieldCleared(msg.FieldBatchNo) {
  11476. fields = append(fields, msg.FieldBatchNo)
  11477. }
  11478. return fields
  11479. }
  11480. // FieldCleared returns a boolean indicating if a field with the given name was
  11481. // cleared in this mutation.
  11482. func (m *MsgMutation) FieldCleared(name string) bool {
  11483. _, ok := m.clearedFields[name]
  11484. return ok
  11485. }
  11486. // ClearField clears the value of the field with the given name. It returns an
  11487. // error if the field is not defined in the schema.
  11488. func (m *MsgMutation) ClearField(name string) error {
  11489. switch name {
  11490. case msg.FieldDeletedAt:
  11491. m.ClearDeletedAt()
  11492. return nil
  11493. case msg.FieldStatus:
  11494. m.ClearStatus()
  11495. return nil
  11496. case msg.FieldFromwxid:
  11497. m.ClearFromwxid()
  11498. return nil
  11499. case msg.FieldToid:
  11500. m.ClearToid()
  11501. return nil
  11502. case msg.FieldMsgtype:
  11503. m.ClearMsgtype()
  11504. return nil
  11505. case msg.FieldMsg:
  11506. m.ClearMsg()
  11507. return nil
  11508. case msg.FieldBatchNo:
  11509. m.ClearBatchNo()
  11510. return nil
  11511. }
  11512. return fmt.Errorf("unknown Msg nullable field %s", name)
  11513. }
  11514. // ResetField resets all changes in the mutation for the field with the given name.
  11515. // It returns an error if the field is not defined in the schema.
  11516. func (m *MsgMutation) ResetField(name string) error {
  11517. switch name {
  11518. case msg.FieldCreatedAt:
  11519. m.ResetCreatedAt()
  11520. return nil
  11521. case msg.FieldUpdatedAt:
  11522. m.ResetUpdatedAt()
  11523. return nil
  11524. case msg.FieldDeletedAt:
  11525. m.ResetDeletedAt()
  11526. return nil
  11527. case msg.FieldStatus:
  11528. m.ResetStatus()
  11529. return nil
  11530. case msg.FieldFromwxid:
  11531. m.ResetFromwxid()
  11532. return nil
  11533. case msg.FieldToid:
  11534. m.ResetToid()
  11535. return nil
  11536. case msg.FieldMsgtype:
  11537. m.ResetMsgtype()
  11538. return nil
  11539. case msg.FieldMsg:
  11540. m.ResetMsg()
  11541. return nil
  11542. case msg.FieldBatchNo:
  11543. m.ResetBatchNo()
  11544. return nil
  11545. }
  11546. return fmt.Errorf("unknown Msg field %s", name)
  11547. }
  11548. // AddedEdges returns all edge names that were set/added in this mutation.
  11549. func (m *MsgMutation) AddedEdges() []string {
  11550. edges := make([]string, 0, 0)
  11551. return edges
  11552. }
  11553. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11554. // name in this mutation.
  11555. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  11556. return nil
  11557. }
  11558. // RemovedEdges returns all edge names that were removed in this mutation.
  11559. func (m *MsgMutation) RemovedEdges() []string {
  11560. edges := make([]string, 0, 0)
  11561. return edges
  11562. }
  11563. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11564. // the given name in this mutation.
  11565. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  11566. return nil
  11567. }
  11568. // ClearedEdges returns all edge names that were cleared in this mutation.
  11569. func (m *MsgMutation) ClearedEdges() []string {
  11570. edges := make([]string, 0, 0)
  11571. return edges
  11572. }
  11573. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11574. // was cleared in this mutation.
  11575. func (m *MsgMutation) EdgeCleared(name string) bool {
  11576. return false
  11577. }
  11578. // ClearEdge clears the value of the edge with the given name. It returns an error
  11579. // if that edge is not defined in the schema.
  11580. func (m *MsgMutation) ClearEdge(name string) error {
  11581. return fmt.Errorf("unknown Msg unique edge %s", name)
  11582. }
  11583. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11584. // It returns an error if the edge is not defined in the schema.
  11585. func (m *MsgMutation) ResetEdge(name string) error {
  11586. return fmt.Errorf("unknown Msg edge %s", name)
  11587. }
  11588. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  11589. type ServerMutation struct {
  11590. config
  11591. op Op
  11592. typ string
  11593. id *uint64
  11594. created_at *time.Time
  11595. updated_at *time.Time
  11596. status *uint8
  11597. addstatus *int8
  11598. deleted_at *time.Time
  11599. name *string
  11600. public_ip *string
  11601. private_ip *string
  11602. admin_port *string
  11603. clearedFields map[string]struct{}
  11604. wxs map[uint64]struct{}
  11605. removedwxs map[uint64]struct{}
  11606. clearedwxs bool
  11607. done bool
  11608. oldValue func(context.Context) (*Server, error)
  11609. predicates []predicate.Server
  11610. }
  11611. var _ ent.Mutation = (*ServerMutation)(nil)
  11612. // serverOption allows management of the mutation configuration using functional options.
  11613. type serverOption func(*ServerMutation)
  11614. // newServerMutation creates new mutation for the Server entity.
  11615. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  11616. m := &ServerMutation{
  11617. config: c,
  11618. op: op,
  11619. typ: TypeServer,
  11620. clearedFields: make(map[string]struct{}),
  11621. }
  11622. for _, opt := range opts {
  11623. opt(m)
  11624. }
  11625. return m
  11626. }
  11627. // withServerID sets the ID field of the mutation.
  11628. func withServerID(id uint64) serverOption {
  11629. return func(m *ServerMutation) {
  11630. var (
  11631. err error
  11632. once sync.Once
  11633. value *Server
  11634. )
  11635. m.oldValue = func(ctx context.Context) (*Server, error) {
  11636. once.Do(func() {
  11637. if m.done {
  11638. err = errors.New("querying old values post mutation is not allowed")
  11639. } else {
  11640. value, err = m.Client().Server.Get(ctx, id)
  11641. }
  11642. })
  11643. return value, err
  11644. }
  11645. m.id = &id
  11646. }
  11647. }
  11648. // withServer sets the old Server of the mutation.
  11649. func withServer(node *Server) serverOption {
  11650. return func(m *ServerMutation) {
  11651. m.oldValue = func(context.Context) (*Server, error) {
  11652. return node, nil
  11653. }
  11654. m.id = &node.ID
  11655. }
  11656. }
  11657. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11658. // executed in a transaction (ent.Tx), a transactional client is returned.
  11659. func (m ServerMutation) Client() *Client {
  11660. client := &Client{config: m.config}
  11661. client.init()
  11662. return client
  11663. }
  11664. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11665. // it returns an error otherwise.
  11666. func (m ServerMutation) Tx() (*Tx, error) {
  11667. if _, ok := m.driver.(*txDriver); !ok {
  11668. return nil, errors.New("ent: mutation is not running in a transaction")
  11669. }
  11670. tx := &Tx{config: m.config}
  11671. tx.init()
  11672. return tx, nil
  11673. }
  11674. // SetID sets the value of the id field. Note that this
  11675. // operation is only accepted on creation of Server entities.
  11676. func (m *ServerMutation) SetID(id uint64) {
  11677. m.id = &id
  11678. }
  11679. // ID returns the ID value in the mutation. Note that the ID is only available
  11680. // if it was provided to the builder or after it was returned from the database.
  11681. func (m *ServerMutation) ID() (id uint64, exists bool) {
  11682. if m.id == nil {
  11683. return
  11684. }
  11685. return *m.id, true
  11686. }
  11687. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11688. // That means, if the mutation is applied within a transaction with an isolation level such
  11689. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11690. // or updated by the mutation.
  11691. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  11692. switch {
  11693. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11694. id, exists := m.ID()
  11695. if exists {
  11696. return []uint64{id}, nil
  11697. }
  11698. fallthrough
  11699. case m.op.Is(OpUpdate | OpDelete):
  11700. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  11701. default:
  11702. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11703. }
  11704. }
  11705. // SetCreatedAt sets the "created_at" field.
  11706. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  11707. m.created_at = &t
  11708. }
  11709. // CreatedAt returns the value of the "created_at" field in the mutation.
  11710. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  11711. v := m.created_at
  11712. if v == nil {
  11713. return
  11714. }
  11715. return *v, true
  11716. }
  11717. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  11718. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11720. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11721. if !m.op.Is(OpUpdateOne) {
  11722. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11723. }
  11724. if m.id == nil || m.oldValue == nil {
  11725. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11726. }
  11727. oldValue, err := m.oldValue(ctx)
  11728. if err != nil {
  11729. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11730. }
  11731. return oldValue.CreatedAt, nil
  11732. }
  11733. // ResetCreatedAt resets all changes to the "created_at" field.
  11734. func (m *ServerMutation) ResetCreatedAt() {
  11735. m.created_at = nil
  11736. }
  11737. // SetUpdatedAt sets the "updated_at" field.
  11738. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  11739. m.updated_at = &t
  11740. }
  11741. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11742. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  11743. v := m.updated_at
  11744. if v == nil {
  11745. return
  11746. }
  11747. return *v, true
  11748. }
  11749. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  11750. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11751. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11752. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11753. if !m.op.Is(OpUpdateOne) {
  11754. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11755. }
  11756. if m.id == nil || m.oldValue == nil {
  11757. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11758. }
  11759. oldValue, err := m.oldValue(ctx)
  11760. if err != nil {
  11761. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11762. }
  11763. return oldValue.UpdatedAt, nil
  11764. }
  11765. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11766. func (m *ServerMutation) ResetUpdatedAt() {
  11767. m.updated_at = nil
  11768. }
  11769. // SetStatus sets the "status" field.
  11770. func (m *ServerMutation) SetStatus(u uint8) {
  11771. m.status = &u
  11772. m.addstatus = nil
  11773. }
  11774. // Status returns the value of the "status" field in the mutation.
  11775. func (m *ServerMutation) Status() (r uint8, exists bool) {
  11776. v := m.status
  11777. if v == nil {
  11778. return
  11779. }
  11780. return *v, true
  11781. }
  11782. // OldStatus returns the old "status" field's value of the Server entity.
  11783. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11785. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11786. if !m.op.Is(OpUpdateOne) {
  11787. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11788. }
  11789. if m.id == nil || m.oldValue == nil {
  11790. return v, errors.New("OldStatus requires an ID field in the mutation")
  11791. }
  11792. oldValue, err := m.oldValue(ctx)
  11793. if err != nil {
  11794. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11795. }
  11796. return oldValue.Status, nil
  11797. }
  11798. // AddStatus adds u to the "status" field.
  11799. func (m *ServerMutation) AddStatus(u int8) {
  11800. if m.addstatus != nil {
  11801. *m.addstatus += u
  11802. } else {
  11803. m.addstatus = &u
  11804. }
  11805. }
  11806. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11807. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  11808. v := m.addstatus
  11809. if v == nil {
  11810. return
  11811. }
  11812. return *v, true
  11813. }
  11814. // ClearStatus clears the value of the "status" field.
  11815. func (m *ServerMutation) ClearStatus() {
  11816. m.status = nil
  11817. m.addstatus = nil
  11818. m.clearedFields[server.FieldStatus] = struct{}{}
  11819. }
  11820. // StatusCleared returns if the "status" field was cleared in this mutation.
  11821. func (m *ServerMutation) StatusCleared() bool {
  11822. _, ok := m.clearedFields[server.FieldStatus]
  11823. return ok
  11824. }
  11825. // ResetStatus resets all changes to the "status" field.
  11826. func (m *ServerMutation) ResetStatus() {
  11827. m.status = nil
  11828. m.addstatus = nil
  11829. delete(m.clearedFields, server.FieldStatus)
  11830. }
  11831. // SetDeletedAt sets the "deleted_at" field.
  11832. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  11833. m.deleted_at = &t
  11834. }
  11835. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11836. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  11837. v := m.deleted_at
  11838. if v == nil {
  11839. return
  11840. }
  11841. return *v, true
  11842. }
  11843. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  11844. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11846. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11847. if !m.op.Is(OpUpdateOne) {
  11848. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11849. }
  11850. if m.id == nil || m.oldValue == nil {
  11851. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11852. }
  11853. oldValue, err := m.oldValue(ctx)
  11854. if err != nil {
  11855. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11856. }
  11857. return oldValue.DeletedAt, nil
  11858. }
  11859. // ClearDeletedAt clears the value of the "deleted_at" field.
  11860. func (m *ServerMutation) ClearDeletedAt() {
  11861. m.deleted_at = nil
  11862. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  11863. }
  11864. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11865. func (m *ServerMutation) DeletedAtCleared() bool {
  11866. _, ok := m.clearedFields[server.FieldDeletedAt]
  11867. return ok
  11868. }
  11869. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11870. func (m *ServerMutation) ResetDeletedAt() {
  11871. m.deleted_at = nil
  11872. delete(m.clearedFields, server.FieldDeletedAt)
  11873. }
  11874. // SetName sets the "name" field.
  11875. func (m *ServerMutation) SetName(s string) {
  11876. m.name = &s
  11877. }
  11878. // Name returns the value of the "name" field in the mutation.
  11879. func (m *ServerMutation) Name() (r string, exists bool) {
  11880. v := m.name
  11881. if v == nil {
  11882. return
  11883. }
  11884. return *v, true
  11885. }
  11886. // OldName returns the old "name" field's value of the Server entity.
  11887. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11889. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  11890. if !m.op.Is(OpUpdateOne) {
  11891. return v, errors.New("OldName is only allowed on UpdateOne operations")
  11892. }
  11893. if m.id == nil || m.oldValue == nil {
  11894. return v, errors.New("OldName requires an ID field in the mutation")
  11895. }
  11896. oldValue, err := m.oldValue(ctx)
  11897. if err != nil {
  11898. return v, fmt.Errorf("querying old value for OldName: %w", err)
  11899. }
  11900. return oldValue.Name, nil
  11901. }
  11902. // ResetName resets all changes to the "name" field.
  11903. func (m *ServerMutation) ResetName() {
  11904. m.name = nil
  11905. }
  11906. // SetPublicIP sets the "public_ip" field.
  11907. func (m *ServerMutation) SetPublicIP(s string) {
  11908. m.public_ip = &s
  11909. }
  11910. // PublicIP returns the value of the "public_ip" field in the mutation.
  11911. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  11912. v := m.public_ip
  11913. if v == nil {
  11914. return
  11915. }
  11916. return *v, true
  11917. }
  11918. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  11919. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11921. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  11922. if !m.op.Is(OpUpdateOne) {
  11923. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  11924. }
  11925. if m.id == nil || m.oldValue == nil {
  11926. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  11927. }
  11928. oldValue, err := m.oldValue(ctx)
  11929. if err != nil {
  11930. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  11931. }
  11932. return oldValue.PublicIP, nil
  11933. }
  11934. // ResetPublicIP resets all changes to the "public_ip" field.
  11935. func (m *ServerMutation) ResetPublicIP() {
  11936. m.public_ip = nil
  11937. }
  11938. // SetPrivateIP sets the "private_ip" field.
  11939. func (m *ServerMutation) SetPrivateIP(s string) {
  11940. m.private_ip = &s
  11941. }
  11942. // PrivateIP returns the value of the "private_ip" field in the mutation.
  11943. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  11944. v := m.private_ip
  11945. if v == nil {
  11946. return
  11947. }
  11948. return *v, true
  11949. }
  11950. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  11951. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11953. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  11954. if !m.op.Is(OpUpdateOne) {
  11955. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  11956. }
  11957. if m.id == nil || m.oldValue == nil {
  11958. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  11959. }
  11960. oldValue, err := m.oldValue(ctx)
  11961. if err != nil {
  11962. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  11963. }
  11964. return oldValue.PrivateIP, nil
  11965. }
  11966. // ResetPrivateIP resets all changes to the "private_ip" field.
  11967. func (m *ServerMutation) ResetPrivateIP() {
  11968. m.private_ip = nil
  11969. }
  11970. // SetAdminPort sets the "admin_port" field.
  11971. func (m *ServerMutation) SetAdminPort(s string) {
  11972. m.admin_port = &s
  11973. }
  11974. // AdminPort returns the value of the "admin_port" field in the mutation.
  11975. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  11976. v := m.admin_port
  11977. if v == nil {
  11978. return
  11979. }
  11980. return *v, true
  11981. }
  11982. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  11983. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11984. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11985. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  11986. if !m.op.Is(OpUpdateOne) {
  11987. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  11988. }
  11989. if m.id == nil || m.oldValue == nil {
  11990. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  11991. }
  11992. oldValue, err := m.oldValue(ctx)
  11993. if err != nil {
  11994. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  11995. }
  11996. return oldValue.AdminPort, nil
  11997. }
  11998. // ResetAdminPort resets all changes to the "admin_port" field.
  11999. func (m *ServerMutation) ResetAdminPort() {
  12000. m.admin_port = nil
  12001. }
  12002. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  12003. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  12004. if m.wxs == nil {
  12005. m.wxs = make(map[uint64]struct{})
  12006. }
  12007. for i := range ids {
  12008. m.wxs[ids[i]] = struct{}{}
  12009. }
  12010. }
  12011. // ClearWxs clears the "wxs" edge to the Wx entity.
  12012. func (m *ServerMutation) ClearWxs() {
  12013. m.clearedwxs = true
  12014. }
  12015. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  12016. func (m *ServerMutation) WxsCleared() bool {
  12017. return m.clearedwxs
  12018. }
  12019. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  12020. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  12021. if m.removedwxs == nil {
  12022. m.removedwxs = make(map[uint64]struct{})
  12023. }
  12024. for i := range ids {
  12025. delete(m.wxs, ids[i])
  12026. m.removedwxs[ids[i]] = struct{}{}
  12027. }
  12028. }
  12029. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  12030. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  12031. for id := range m.removedwxs {
  12032. ids = append(ids, id)
  12033. }
  12034. return
  12035. }
  12036. // WxsIDs returns the "wxs" edge IDs in the mutation.
  12037. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  12038. for id := range m.wxs {
  12039. ids = append(ids, id)
  12040. }
  12041. return
  12042. }
  12043. // ResetWxs resets all changes to the "wxs" edge.
  12044. func (m *ServerMutation) ResetWxs() {
  12045. m.wxs = nil
  12046. m.clearedwxs = false
  12047. m.removedwxs = nil
  12048. }
  12049. // Where appends a list predicates to the ServerMutation builder.
  12050. func (m *ServerMutation) Where(ps ...predicate.Server) {
  12051. m.predicates = append(m.predicates, ps...)
  12052. }
  12053. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  12054. // users can use type-assertion to append predicates that do not depend on any generated package.
  12055. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  12056. p := make([]predicate.Server, len(ps))
  12057. for i := range ps {
  12058. p[i] = ps[i]
  12059. }
  12060. m.Where(p...)
  12061. }
  12062. // Op returns the operation name.
  12063. func (m *ServerMutation) Op() Op {
  12064. return m.op
  12065. }
  12066. // SetOp allows setting the mutation operation.
  12067. func (m *ServerMutation) SetOp(op Op) {
  12068. m.op = op
  12069. }
  12070. // Type returns the node type of this mutation (Server).
  12071. func (m *ServerMutation) Type() string {
  12072. return m.typ
  12073. }
  12074. // Fields returns all fields that were changed during this mutation. Note that in
  12075. // order to get all numeric fields that were incremented/decremented, call
  12076. // AddedFields().
  12077. func (m *ServerMutation) Fields() []string {
  12078. fields := make([]string, 0, 8)
  12079. if m.created_at != nil {
  12080. fields = append(fields, server.FieldCreatedAt)
  12081. }
  12082. if m.updated_at != nil {
  12083. fields = append(fields, server.FieldUpdatedAt)
  12084. }
  12085. if m.status != nil {
  12086. fields = append(fields, server.FieldStatus)
  12087. }
  12088. if m.deleted_at != nil {
  12089. fields = append(fields, server.FieldDeletedAt)
  12090. }
  12091. if m.name != nil {
  12092. fields = append(fields, server.FieldName)
  12093. }
  12094. if m.public_ip != nil {
  12095. fields = append(fields, server.FieldPublicIP)
  12096. }
  12097. if m.private_ip != nil {
  12098. fields = append(fields, server.FieldPrivateIP)
  12099. }
  12100. if m.admin_port != nil {
  12101. fields = append(fields, server.FieldAdminPort)
  12102. }
  12103. return fields
  12104. }
  12105. // Field returns the value of a field with the given name. The second boolean
  12106. // return value indicates that this field was not set, or was not defined in the
  12107. // schema.
  12108. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  12109. switch name {
  12110. case server.FieldCreatedAt:
  12111. return m.CreatedAt()
  12112. case server.FieldUpdatedAt:
  12113. return m.UpdatedAt()
  12114. case server.FieldStatus:
  12115. return m.Status()
  12116. case server.FieldDeletedAt:
  12117. return m.DeletedAt()
  12118. case server.FieldName:
  12119. return m.Name()
  12120. case server.FieldPublicIP:
  12121. return m.PublicIP()
  12122. case server.FieldPrivateIP:
  12123. return m.PrivateIP()
  12124. case server.FieldAdminPort:
  12125. return m.AdminPort()
  12126. }
  12127. return nil, false
  12128. }
  12129. // OldField returns the old value of the field from the database. An error is
  12130. // returned if the mutation operation is not UpdateOne, or the query to the
  12131. // database failed.
  12132. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12133. switch name {
  12134. case server.FieldCreatedAt:
  12135. return m.OldCreatedAt(ctx)
  12136. case server.FieldUpdatedAt:
  12137. return m.OldUpdatedAt(ctx)
  12138. case server.FieldStatus:
  12139. return m.OldStatus(ctx)
  12140. case server.FieldDeletedAt:
  12141. return m.OldDeletedAt(ctx)
  12142. case server.FieldName:
  12143. return m.OldName(ctx)
  12144. case server.FieldPublicIP:
  12145. return m.OldPublicIP(ctx)
  12146. case server.FieldPrivateIP:
  12147. return m.OldPrivateIP(ctx)
  12148. case server.FieldAdminPort:
  12149. return m.OldAdminPort(ctx)
  12150. }
  12151. return nil, fmt.Errorf("unknown Server field %s", name)
  12152. }
  12153. // SetField sets the value of a field with the given name. It returns an error if
  12154. // the field is not defined in the schema, or if the type mismatched the field
  12155. // type.
  12156. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  12157. switch name {
  12158. case server.FieldCreatedAt:
  12159. v, ok := value.(time.Time)
  12160. if !ok {
  12161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12162. }
  12163. m.SetCreatedAt(v)
  12164. return nil
  12165. case server.FieldUpdatedAt:
  12166. v, ok := value.(time.Time)
  12167. if !ok {
  12168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12169. }
  12170. m.SetUpdatedAt(v)
  12171. return nil
  12172. case server.FieldStatus:
  12173. v, ok := value.(uint8)
  12174. if !ok {
  12175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12176. }
  12177. m.SetStatus(v)
  12178. return nil
  12179. case server.FieldDeletedAt:
  12180. v, ok := value.(time.Time)
  12181. if !ok {
  12182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12183. }
  12184. m.SetDeletedAt(v)
  12185. return nil
  12186. case server.FieldName:
  12187. v, ok := value.(string)
  12188. if !ok {
  12189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12190. }
  12191. m.SetName(v)
  12192. return nil
  12193. case server.FieldPublicIP:
  12194. v, ok := value.(string)
  12195. if !ok {
  12196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12197. }
  12198. m.SetPublicIP(v)
  12199. return nil
  12200. case server.FieldPrivateIP:
  12201. v, ok := value.(string)
  12202. if !ok {
  12203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12204. }
  12205. m.SetPrivateIP(v)
  12206. return nil
  12207. case server.FieldAdminPort:
  12208. v, ok := value.(string)
  12209. if !ok {
  12210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12211. }
  12212. m.SetAdminPort(v)
  12213. return nil
  12214. }
  12215. return fmt.Errorf("unknown Server field %s", name)
  12216. }
  12217. // AddedFields returns all numeric fields that were incremented/decremented during
  12218. // this mutation.
  12219. func (m *ServerMutation) AddedFields() []string {
  12220. var fields []string
  12221. if m.addstatus != nil {
  12222. fields = append(fields, server.FieldStatus)
  12223. }
  12224. return fields
  12225. }
  12226. // AddedField returns the numeric value that was incremented/decremented on a field
  12227. // with the given name. The second boolean return value indicates that this field
  12228. // was not set, or was not defined in the schema.
  12229. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  12230. switch name {
  12231. case server.FieldStatus:
  12232. return m.AddedStatus()
  12233. }
  12234. return nil, false
  12235. }
  12236. // AddField adds the value to the field with the given name. It returns an error if
  12237. // the field is not defined in the schema, or if the type mismatched the field
  12238. // type.
  12239. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  12240. switch name {
  12241. case server.FieldStatus:
  12242. v, ok := value.(int8)
  12243. if !ok {
  12244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12245. }
  12246. m.AddStatus(v)
  12247. return nil
  12248. }
  12249. return fmt.Errorf("unknown Server numeric field %s", name)
  12250. }
  12251. // ClearedFields returns all nullable fields that were cleared during this
  12252. // mutation.
  12253. func (m *ServerMutation) ClearedFields() []string {
  12254. var fields []string
  12255. if m.FieldCleared(server.FieldStatus) {
  12256. fields = append(fields, server.FieldStatus)
  12257. }
  12258. if m.FieldCleared(server.FieldDeletedAt) {
  12259. fields = append(fields, server.FieldDeletedAt)
  12260. }
  12261. return fields
  12262. }
  12263. // FieldCleared returns a boolean indicating if a field with the given name was
  12264. // cleared in this mutation.
  12265. func (m *ServerMutation) FieldCleared(name string) bool {
  12266. _, ok := m.clearedFields[name]
  12267. return ok
  12268. }
  12269. // ClearField clears the value of the field with the given name. It returns an
  12270. // error if the field is not defined in the schema.
  12271. func (m *ServerMutation) ClearField(name string) error {
  12272. switch name {
  12273. case server.FieldStatus:
  12274. m.ClearStatus()
  12275. return nil
  12276. case server.FieldDeletedAt:
  12277. m.ClearDeletedAt()
  12278. return nil
  12279. }
  12280. return fmt.Errorf("unknown Server nullable field %s", name)
  12281. }
  12282. // ResetField resets all changes in the mutation for the field with the given name.
  12283. // It returns an error if the field is not defined in the schema.
  12284. func (m *ServerMutation) ResetField(name string) error {
  12285. switch name {
  12286. case server.FieldCreatedAt:
  12287. m.ResetCreatedAt()
  12288. return nil
  12289. case server.FieldUpdatedAt:
  12290. m.ResetUpdatedAt()
  12291. return nil
  12292. case server.FieldStatus:
  12293. m.ResetStatus()
  12294. return nil
  12295. case server.FieldDeletedAt:
  12296. m.ResetDeletedAt()
  12297. return nil
  12298. case server.FieldName:
  12299. m.ResetName()
  12300. return nil
  12301. case server.FieldPublicIP:
  12302. m.ResetPublicIP()
  12303. return nil
  12304. case server.FieldPrivateIP:
  12305. m.ResetPrivateIP()
  12306. return nil
  12307. case server.FieldAdminPort:
  12308. m.ResetAdminPort()
  12309. return nil
  12310. }
  12311. return fmt.Errorf("unknown Server field %s", name)
  12312. }
  12313. // AddedEdges returns all edge names that were set/added in this mutation.
  12314. func (m *ServerMutation) AddedEdges() []string {
  12315. edges := make([]string, 0, 1)
  12316. if m.wxs != nil {
  12317. edges = append(edges, server.EdgeWxs)
  12318. }
  12319. return edges
  12320. }
  12321. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12322. // name in this mutation.
  12323. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  12324. switch name {
  12325. case server.EdgeWxs:
  12326. ids := make([]ent.Value, 0, len(m.wxs))
  12327. for id := range m.wxs {
  12328. ids = append(ids, id)
  12329. }
  12330. return ids
  12331. }
  12332. return nil
  12333. }
  12334. // RemovedEdges returns all edge names that were removed in this mutation.
  12335. func (m *ServerMutation) RemovedEdges() []string {
  12336. edges := make([]string, 0, 1)
  12337. if m.removedwxs != nil {
  12338. edges = append(edges, server.EdgeWxs)
  12339. }
  12340. return edges
  12341. }
  12342. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12343. // the given name in this mutation.
  12344. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  12345. switch name {
  12346. case server.EdgeWxs:
  12347. ids := make([]ent.Value, 0, len(m.removedwxs))
  12348. for id := range m.removedwxs {
  12349. ids = append(ids, id)
  12350. }
  12351. return ids
  12352. }
  12353. return nil
  12354. }
  12355. // ClearedEdges returns all edge names that were cleared in this mutation.
  12356. func (m *ServerMutation) ClearedEdges() []string {
  12357. edges := make([]string, 0, 1)
  12358. if m.clearedwxs {
  12359. edges = append(edges, server.EdgeWxs)
  12360. }
  12361. return edges
  12362. }
  12363. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12364. // was cleared in this mutation.
  12365. func (m *ServerMutation) EdgeCleared(name string) bool {
  12366. switch name {
  12367. case server.EdgeWxs:
  12368. return m.clearedwxs
  12369. }
  12370. return false
  12371. }
  12372. // ClearEdge clears the value of the edge with the given name. It returns an error
  12373. // if that edge is not defined in the schema.
  12374. func (m *ServerMutation) ClearEdge(name string) error {
  12375. switch name {
  12376. }
  12377. return fmt.Errorf("unknown Server unique edge %s", name)
  12378. }
  12379. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12380. // It returns an error if the edge is not defined in the schema.
  12381. func (m *ServerMutation) ResetEdge(name string) error {
  12382. switch name {
  12383. case server.EdgeWxs:
  12384. m.ResetWxs()
  12385. return nil
  12386. }
  12387. return fmt.Errorf("unknown Server edge %s", name)
  12388. }
  12389. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  12390. type SopNodeMutation struct {
  12391. config
  12392. op Op
  12393. typ string
  12394. id *uint64
  12395. created_at *time.Time
  12396. updated_at *time.Time
  12397. status *uint8
  12398. addstatus *int8
  12399. deleted_at *time.Time
  12400. parent_id *uint64
  12401. addparent_id *int64
  12402. name *string
  12403. condition_type *int
  12404. addcondition_type *int
  12405. condition_list *[]string
  12406. appendcondition_list []string
  12407. no_reply_condition *uint64
  12408. addno_reply_condition *int64
  12409. action_message *[]custom_types.Action
  12410. appendaction_message []custom_types.Action
  12411. action_label *[]uint64
  12412. appendaction_label []uint64
  12413. clearedFields map[string]struct{}
  12414. sop_stage *uint64
  12415. clearedsop_stage bool
  12416. node_messages map[uint64]struct{}
  12417. removednode_messages map[uint64]struct{}
  12418. clearednode_messages bool
  12419. done bool
  12420. oldValue func(context.Context) (*SopNode, error)
  12421. predicates []predicate.SopNode
  12422. }
  12423. var _ ent.Mutation = (*SopNodeMutation)(nil)
  12424. // sopnodeOption allows management of the mutation configuration using functional options.
  12425. type sopnodeOption func(*SopNodeMutation)
  12426. // newSopNodeMutation creates new mutation for the SopNode entity.
  12427. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  12428. m := &SopNodeMutation{
  12429. config: c,
  12430. op: op,
  12431. typ: TypeSopNode,
  12432. clearedFields: make(map[string]struct{}),
  12433. }
  12434. for _, opt := range opts {
  12435. opt(m)
  12436. }
  12437. return m
  12438. }
  12439. // withSopNodeID sets the ID field of the mutation.
  12440. func withSopNodeID(id uint64) sopnodeOption {
  12441. return func(m *SopNodeMutation) {
  12442. var (
  12443. err error
  12444. once sync.Once
  12445. value *SopNode
  12446. )
  12447. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  12448. once.Do(func() {
  12449. if m.done {
  12450. err = errors.New("querying old values post mutation is not allowed")
  12451. } else {
  12452. value, err = m.Client().SopNode.Get(ctx, id)
  12453. }
  12454. })
  12455. return value, err
  12456. }
  12457. m.id = &id
  12458. }
  12459. }
  12460. // withSopNode sets the old SopNode of the mutation.
  12461. func withSopNode(node *SopNode) sopnodeOption {
  12462. return func(m *SopNodeMutation) {
  12463. m.oldValue = func(context.Context) (*SopNode, error) {
  12464. return node, nil
  12465. }
  12466. m.id = &node.ID
  12467. }
  12468. }
  12469. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12470. // executed in a transaction (ent.Tx), a transactional client is returned.
  12471. func (m SopNodeMutation) Client() *Client {
  12472. client := &Client{config: m.config}
  12473. client.init()
  12474. return client
  12475. }
  12476. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12477. // it returns an error otherwise.
  12478. func (m SopNodeMutation) Tx() (*Tx, error) {
  12479. if _, ok := m.driver.(*txDriver); !ok {
  12480. return nil, errors.New("ent: mutation is not running in a transaction")
  12481. }
  12482. tx := &Tx{config: m.config}
  12483. tx.init()
  12484. return tx, nil
  12485. }
  12486. // SetID sets the value of the id field. Note that this
  12487. // operation is only accepted on creation of SopNode entities.
  12488. func (m *SopNodeMutation) SetID(id uint64) {
  12489. m.id = &id
  12490. }
  12491. // ID returns the ID value in the mutation. Note that the ID is only available
  12492. // if it was provided to the builder or after it was returned from the database.
  12493. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  12494. if m.id == nil {
  12495. return
  12496. }
  12497. return *m.id, true
  12498. }
  12499. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12500. // That means, if the mutation is applied within a transaction with an isolation level such
  12501. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12502. // or updated by the mutation.
  12503. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  12504. switch {
  12505. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12506. id, exists := m.ID()
  12507. if exists {
  12508. return []uint64{id}, nil
  12509. }
  12510. fallthrough
  12511. case m.op.Is(OpUpdate | OpDelete):
  12512. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  12513. default:
  12514. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12515. }
  12516. }
  12517. // SetCreatedAt sets the "created_at" field.
  12518. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  12519. m.created_at = &t
  12520. }
  12521. // CreatedAt returns the value of the "created_at" field in the mutation.
  12522. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  12523. v := m.created_at
  12524. if v == nil {
  12525. return
  12526. }
  12527. return *v, true
  12528. }
  12529. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  12530. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12532. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12533. if !m.op.Is(OpUpdateOne) {
  12534. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12535. }
  12536. if m.id == nil || m.oldValue == nil {
  12537. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12538. }
  12539. oldValue, err := m.oldValue(ctx)
  12540. if err != nil {
  12541. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12542. }
  12543. return oldValue.CreatedAt, nil
  12544. }
  12545. // ResetCreatedAt resets all changes to the "created_at" field.
  12546. func (m *SopNodeMutation) ResetCreatedAt() {
  12547. m.created_at = nil
  12548. }
  12549. // SetUpdatedAt sets the "updated_at" field.
  12550. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  12551. m.updated_at = &t
  12552. }
  12553. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12554. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  12555. v := m.updated_at
  12556. if v == nil {
  12557. return
  12558. }
  12559. return *v, true
  12560. }
  12561. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  12562. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12564. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12565. if !m.op.Is(OpUpdateOne) {
  12566. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12567. }
  12568. if m.id == nil || m.oldValue == nil {
  12569. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12570. }
  12571. oldValue, err := m.oldValue(ctx)
  12572. if err != nil {
  12573. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12574. }
  12575. return oldValue.UpdatedAt, nil
  12576. }
  12577. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12578. func (m *SopNodeMutation) ResetUpdatedAt() {
  12579. m.updated_at = nil
  12580. }
  12581. // SetStatus sets the "status" field.
  12582. func (m *SopNodeMutation) SetStatus(u uint8) {
  12583. m.status = &u
  12584. m.addstatus = nil
  12585. }
  12586. // Status returns the value of the "status" field in the mutation.
  12587. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  12588. v := m.status
  12589. if v == nil {
  12590. return
  12591. }
  12592. return *v, true
  12593. }
  12594. // OldStatus returns the old "status" field's value of the SopNode entity.
  12595. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12597. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12598. if !m.op.Is(OpUpdateOne) {
  12599. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12600. }
  12601. if m.id == nil || m.oldValue == nil {
  12602. return v, errors.New("OldStatus requires an ID field in the mutation")
  12603. }
  12604. oldValue, err := m.oldValue(ctx)
  12605. if err != nil {
  12606. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12607. }
  12608. return oldValue.Status, nil
  12609. }
  12610. // AddStatus adds u to the "status" field.
  12611. func (m *SopNodeMutation) AddStatus(u int8) {
  12612. if m.addstatus != nil {
  12613. *m.addstatus += u
  12614. } else {
  12615. m.addstatus = &u
  12616. }
  12617. }
  12618. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12619. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  12620. v := m.addstatus
  12621. if v == nil {
  12622. return
  12623. }
  12624. return *v, true
  12625. }
  12626. // ClearStatus clears the value of the "status" field.
  12627. func (m *SopNodeMutation) ClearStatus() {
  12628. m.status = nil
  12629. m.addstatus = nil
  12630. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  12631. }
  12632. // StatusCleared returns if the "status" field was cleared in this mutation.
  12633. func (m *SopNodeMutation) StatusCleared() bool {
  12634. _, ok := m.clearedFields[sopnode.FieldStatus]
  12635. return ok
  12636. }
  12637. // ResetStatus resets all changes to the "status" field.
  12638. func (m *SopNodeMutation) ResetStatus() {
  12639. m.status = nil
  12640. m.addstatus = nil
  12641. delete(m.clearedFields, sopnode.FieldStatus)
  12642. }
  12643. // SetDeletedAt sets the "deleted_at" field.
  12644. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  12645. m.deleted_at = &t
  12646. }
  12647. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12648. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  12649. v := m.deleted_at
  12650. if v == nil {
  12651. return
  12652. }
  12653. return *v, true
  12654. }
  12655. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  12656. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12658. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12659. if !m.op.Is(OpUpdateOne) {
  12660. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12661. }
  12662. if m.id == nil || m.oldValue == nil {
  12663. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12664. }
  12665. oldValue, err := m.oldValue(ctx)
  12666. if err != nil {
  12667. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12668. }
  12669. return oldValue.DeletedAt, nil
  12670. }
  12671. // ClearDeletedAt clears the value of the "deleted_at" field.
  12672. func (m *SopNodeMutation) ClearDeletedAt() {
  12673. m.deleted_at = nil
  12674. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  12675. }
  12676. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12677. func (m *SopNodeMutation) DeletedAtCleared() bool {
  12678. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  12679. return ok
  12680. }
  12681. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12682. func (m *SopNodeMutation) ResetDeletedAt() {
  12683. m.deleted_at = nil
  12684. delete(m.clearedFields, sopnode.FieldDeletedAt)
  12685. }
  12686. // SetStageID sets the "stage_id" field.
  12687. func (m *SopNodeMutation) SetStageID(u uint64) {
  12688. m.sop_stage = &u
  12689. }
  12690. // StageID returns the value of the "stage_id" field in the mutation.
  12691. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  12692. v := m.sop_stage
  12693. if v == nil {
  12694. return
  12695. }
  12696. return *v, true
  12697. }
  12698. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  12699. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12701. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  12702. if !m.op.Is(OpUpdateOne) {
  12703. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  12704. }
  12705. if m.id == nil || m.oldValue == nil {
  12706. return v, errors.New("OldStageID requires an ID field in the mutation")
  12707. }
  12708. oldValue, err := m.oldValue(ctx)
  12709. if err != nil {
  12710. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  12711. }
  12712. return oldValue.StageID, nil
  12713. }
  12714. // ResetStageID resets all changes to the "stage_id" field.
  12715. func (m *SopNodeMutation) ResetStageID() {
  12716. m.sop_stage = nil
  12717. }
  12718. // SetParentID sets the "parent_id" field.
  12719. func (m *SopNodeMutation) SetParentID(u uint64) {
  12720. m.parent_id = &u
  12721. m.addparent_id = nil
  12722. }
  12723. // ParentID returns the value of the "parent_id" field in the mutation.
  12724. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  12725. v := m.parent_id
  12726. if v == nil {
  12727. return
  12728. }
  12729. return *v, true
  12730. }
  12731. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  12732. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12734. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  12735. if !m.op.Is(OpUpdateOne) {
  12736. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  12737. }
  12738. if m.id == nil || m.oldValue == nil {
  12739. return v, errors.New("OldParentID requires an ID field in the mutation")
  12740. }
  12741. oldValue, err := m.oldValue(ctx)
  12742. if err != nil {
  12743. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  12744. }
  12745. return oldValue.ParentID, nil
  12746. }
  12747. // AddParentID adds u to the "parent_id" field.
  12748. func (m *SopNodeMutation) AddParentID(u int64) {
  12749. if m.addparent_id != nil {
  12750. *m.addparent_id += u
  12751. } else {
  12752. m.addparent_id = &u
  12753. }
  12754. }
  12755. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  12756. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  12757. v := m.addparent_id
  12758. if v == nil {
  12759. return
  12760. }
  12761. return *v, true
  12762. }
  12763. // ResetParentID resets all changes to the "parent_id" field.
  12764. func (m *SopNodeMutation) ResetParentID() {
  12765. m.parent_id = nil
  12766. m.addparent_id = nil
  12767. }
  12768. // SetName sets the "name" field.
  12769. func (m *SopNodeMutation) SetName(s string) {
  12770. m.name = &s
  12771. }
  12772. // Name returns the value of the "name" field in the mutation.
  12773. func (m *SopNodeMutation) Name() (r string, exists bool) {
  12774. v := m.name
  12775. if v == nil {
  12776. return
  12777. }
  12778. return *v, true
  12779. }
  12780. // OldName returns the old "name" field's value of the SopNode entity.
  12781. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12783. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  12784. if !m.op.Is(OpUpdateOne) {
  12785. return v, errors.New("OldName is only allowed on UpdateOne operations")
  12786. }
  12787. if m.id == nil || m.oldValue == nil {
  12788. return v, errors.New("OldName requires an ID field in the mutation")
  12789. }
  12790. oldValue, err := m.oldValue(ctx)
  12791. if err != nil {
  12792. return v, fmt.Errorf("querying old value for OldName: %w", err)
  12793. }
  12794. return oldValue.Name, nil
  12795. }
  12796. // ResetName resets all changes to the "name" field.
  12797. func (m *SopNodeMutation) ResetName() {
  12798. m.name = nil
  12799. }
  12800. // SetConditionType sets the "condition_type" field.
  12801. func (m *SopNodeMutation) SetConditionType(i int) {
  12802. m.condition_type = &i
  12803. m.addcondition_type = nil
  12804. }
  12805. // ConditionType returns the value of the "condition_type" field in the mutation.
  12806. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  12807. v := m.condition_type
  12808. if v == nil {
  12809. return
  12810. }
  12811. return *v, true
  12812. }
  12813. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  12814. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12815. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12816. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  12817. if !m.op.Is(OpUpdateOne) {
  12818. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  12819. }
  12820. if m.id == nil || m.oldValue == nil {
  12821. return v, errors.New("OldConditionType requires an ID field in the mutation")
  12822. }
  12823. oldValue, err := m.oldValue(ctx)
  12824. if err != nil {
  12825. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  12826. }
  12827. return oldValue.ConditionType, nil
  12828. }
  12829. // AddConditionType adds i to the "condition_type" field.
  12830. func (m *SopNodeMutation) AddConditionType(i int) {
  12831. if m.addcondition_type != nil {
  12832. *m.addcondition_type += i
  12833. } else {
  12834. m.addcondition_type = &i
  12835. }
  12836. }
  12837. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  12838. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  12839. v := m.addcondition_type
  12840. if v == nil {
  12841. return
  12842. }
  12843. return *v, true
  12844. }
  12845. // ResetConditionType resets all changes to the "condition_type" field.
  12846. func (m *SopNodeMutation) ResetConditionType() {
  12847. m.condition_type = nil
  12848. m.addcondition_type = nil
  12849. }
  12850. // SetConditionList sets the "condition_list" field.
  12851. func (m *SopNodeMutation) SetConditionList(s []string) {
  12852. m.condition_list = &s
  12853. m.appendcondition_list = nil
  12854. }
  12855. // ConditionList returns the value of the "condition_list" field in the mutation.
  12856. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  12857. v := m.condition_list
  12858. if v == nil {
  12859. return
  12860. }
  12861. return *v, true
  12862. }
  12863. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  12864. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12865. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12866. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  12867. if !m.op.Is(OpUpdateOne) {
  12868. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  12869. }
  12870. if m.id == nil || m.oldValue == nil {
  12871. return v, errors.New("OldConditionList requires an ID field in the mutation")
  12872. }
  12873. oldValue, err := m.oldValue(ctx)
  12874. if err != nil {
  12875. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  12876. }
  12877. return oldValue.ConditionList, nil
  12878. }
  12879. // AppendConditionList adds s to the "condition_list" field.
  12880. func (m *SopNodeMutation) AppendConditionList(s []string) {
  12881. m.appendcondition_list = append(m.appendcondition_list, s...)
  12882. }
  12883. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  12884. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  12885. if len(m.appendcondition_list) == 0 {
  12886. return nil, false
  12887. }
  12888. return m.appendcondition_list, true
  12889. }
  12890. // ClearConditionList clears the value of the "condition_list" field.
  12891. func (m *SopNodeMutation) ClearConditionList() {
  12892. m.condition_list = nil
  12893. m.appendcondition_list = nil
  12894. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  12895. }
  12896. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  12897. func (m *SopNodeMutation) ConditionListCleared() bool {
  12898. _, ok := m.clearedFields[sopnode.FieldConditionList]
  12899. return ok
  12900. }
  12901. // ResetConditionList resets all changes to the "condition_list" field.
  12902. func (m *SopNodeMutation) ResetConditionList() {
  12903. m.condition_list = nil
  12904. m.appendcondition_list = nil
  12905. delete(m.clearedFields, sopnode.FieldConditionList)
  12906. }
  12907. // SetNoReplyCondition sets the "no_reply_condition" field.
  12908. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  12909. m.no_reply_condition = &u
  12910. m.addno_reply_condition = nil
  12911. }
  12912. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  12913. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  12914. v := m.no_reply_condition
  12915. if v == nil {
  12916. return
  12917. }
  12918. return *v, true
  12919. }
  12920. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  12921. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12923. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  12924. if !m.op.Is(OpUpdateOne) {
  12925. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  12926. }
  12927. if m.id == nil || m.oldValue == nil {
  12928. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  12929. }
  12930. oldValue, err := m.oldValue(ctx)
  12931. if err != nil {
  12932. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  12933. }
  12934. return oldValue.NoReplyCondition, nil
  12935. }
  12936. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  12937. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  12938. if m.addno_reply_condition != nil {
  12939. *m.addno_reply_condition += u
  12940. } else {
  12941. m.addno_reply_condition = &u
  12942. }
  12943. }
  12944. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  12945. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  12946. v := m.addno_reply_condition
  12947. if v == nil {
  12948. return
  12949. }
  12950. return *v, true
  12951. }
  12952. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  12953. func (m *SopNodeMutation) ResetNoReplyCondition() {
  12954. m.no_reply_condition = nil
  12955. m.addno_reply_condition = nil
  12956. }
  12957. // SetActionMessage sets the "action_message" field.
  12958. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  12959. m.action_message = &ct
  12960. m.appendaction_message = nil
  12961. }
  12962. // ActionMessage returns the value of the "action_message" field in the mutation.
  12963. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  12964. v := m.action_message
  12965. if v == nil {
  12966. return
  12967. }
  12968. return *v, true
  12969. }
  12970. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  12971. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12973. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  12974. if !m.op.Is(OpUpdateOne) {
  12975. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  12976. }
  12977. if m.id == nil || m.oldValue == nil {
  12978. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  12979. }
  12980. oldValue, err := m.oldValue(ctx)
  12981. if err != nil {
  12982. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  12983. }
  12984. return oldValue.ActionMessage, nil
  12985. }
  12986. // AppendActionMessage adds ct to the "action_message" field.
  12987. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  12988. m.appendaction_message = append(m.appendaction_message, ct...)
  12989. }
  12990. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  12991. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  12992. if len(m.appendaction_message) == 0 {
  12993. return nil, false
  12994. }
  12995. return m.appendaction_message, true
  12996. }
  12997. // ClearActionMessage clears the value of the "action_message" field.
  12998. func (m *SopNodeMutation) ClearActionMessage() {
  12999. m.action_message = nil
  13000. m.appendaction_message = nil
  13001. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  13002. }
  13003. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  13004. func (m *SopNodeMutation) ActionMessageCleared() bool {
  13005. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  13006. return ok
  13007. }
  13008. // ResetActionMessage resets all changes to the "action_message" field.
  13009. func (m *SopNodeMutation) ResetActionMessage() {
  13010. m.action_message = nil
  13011. m.appendaction_message = nil
  13012. delete(m.clearedFields, sopnode.FieldActionMessage)
  13013. }
  13014. // SetActionLabel sets the "action_label" field.
  13015. func (m *SopNodeMutation) SetActionLabel(u []uint64) {
  13016. m.action_label = &u
  13017. m.appendaction_label = nil
  13018. }
  13019. // ActionLabel returns the value of the "action_label" field in the mutation.
  13020. func (m *SopNodeMutation) ActionLabel() (r []uint64, exists bool) {
  13021. v := m.action_label
  13022. if v == nil {
  13023. return
  13024. }
  13025. return *v, true
  13026. }
  13027. // OldActionLabel returns the old "action_label" field's value of the SopNode entity.
  13028. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  13029. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13030. func (m *SopNodeMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  13031. if !m.op.Is(OpUpdateOne) {
  13032. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  13033. }
  13034. if m.id == nil || m.oldValue == nil {
  13035. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  13036. }
  13037. oldValue, err := m.oldValue(ctx)
  13038. if err != nil {
  13039. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  13040. }
  13041. return oldValue.ActionLabel, nil
  13042. }
  13043. // AppendActionLabel adds u to the "action_label" field.
  13044. func (m *SopNodeMutation) AppendActionLabel(u []uint64) {
  13045. m.appendaction_label = append(m.appendaction_label, u...)
  13046. }
  13047. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  13048. func (m *SopNodeMutation) AppendedActionLabel() ([]uint64, bool) {
  13049. if len(m.appendaction_label) == 0 {
  13050. return nil, false
  13051. }
  13052. return m.appendaction_label, true
  13053. }
  13054. // ClearActionLabel clears the value of the "action_label" field.
  13055. func (m *SopNodeMutation) ClearActionLabel() {
  13056. m.action_label = nil
  13057. m.appendaction_label = nil
  13058. m.clearedFields[sopnode.FieldActionLabel] = struct{}{}
  13059. }
  13060. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  13061. func (m *SopNodeMutation) ActionLabelCleared() bool {
  13062. _, ok := m.clearedFields[sopnode.FieldActionLabel]
  13063. return ok
  13064. }
  13065. // ResetActionLabel resets all changes to the "action_label" field.
  13066. func (m *SopNodeMutation) ResetActionLabel() {
  13067. m.action_label = nil
  13068. m.appendaction_label = nil
  13069. delete(m.clearedFields, sopnode.FieldActionLabel)
  13070. }
  13071. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  13072. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  13073. m.sop_stage = &id
  13074. }
  13075. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  13076. func (m *SopNodeMutation) ClearSopStage() {
  13077. m.clearedsop_stage = true
  13078. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  13079. }
  13080. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  13081. func (m *SopNodeMutation) SopStageCleared() bool {
  13082. return m.clearedsop_stage
  13083. }
  13084. // SopStageID returns the "sop_stage" edge ID in the mutation.
  13085. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  13086. if m.sop_stage != nil {
  13087. return *m.sop_stage, true
  13088. }
  13089. return
  13090. }
  13091. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  13092. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13093. // SopStageID instead. It exists only for internal usage by the builders.
  13094. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  13095. if id := m.sop_stage; id != nil {
  13096. ids = append(ids, *id)
  13097. }
  13098. return
  13099. }
  13100. // ResetSopStage resets all changes to the "sop_stage" edge.
  13101. func (m *SopNodeMutation) ResetSopStage() {
  13102. m.sop_stage = nil
  13103. m.clearedsop_stage = false
  13104. }
  13105. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  13106. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  13107. if m.node_messages == nil {
  13108. m.node_messages = make(map[uint64]struct{})
  13109. }
  13110. for i := range ids {
  13111. m.node_messages[ids[i]] = struct{}{}
  13112. }
  13113. }
  13114. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  13115. func (m *SopNodeMutation) ClearNodeMessages() {
  13116. m.clearednode_messages = true
  13117. }
  13118. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  13119. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  13120. return m.clearednode_messages
  13121. }
  13122. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  13123. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  13124. if m.removednode_messages == nil {
  13125. m.removednode_messages = make(map[uint64]struct{})
  13126. }
  13127. for i := range ids {
  13128. delete(m.node_messages, ids[i])
  13129. m.removednode_messages[ids[i]] = struct{}{}
  13130. }
  13131. }
  13132. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  13133. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  13134. for id := range m.removednode_messages {
  13135. ids = append(ids, id)
  13136. }
  13137. return
  13138. }
  13139. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  13140. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  13141. for id := range m.node_messages {
  13142. ids = append(ids, id)
  13143. }
  13144. return
  13145. }
  13146. // ResetNodeMessages resets all changes to the "node_messages" edge.
  13147. func (m *SopNodeMutation) ResetNodeMessages() {
  13148. m.node_messages = nil
  13149. m.clearednode_messages = false
  13150. m.removednode_messages = nil
  13151. }
  13152. // Where appends a list predicates to the SopNodeMutation builder.
  13153. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  13154. m.predicates = append(m.predicates, ps...)
  13155. }
  13156. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  13157. // users can use type-assertion to append predicates that do not depend on any generated package.
  13158. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  13159. p := make([]predicate.SopNode, len(ps))
  13160. for i := range ps {
  13161. p[i] = ps[i]
  13162. }
  13163. m.Where(p...)
  13164. }
  13165. // Op returns the operation name.
  13166. func (m *SopNodeMutation) Op() Op {
  13167. return m.op
  13168. }
  13169. // SetOp allows setting the mutation operation.
  13170. func (m *SopNodeMutation) SetOp(op Op) {
  13171. m.op = op
  13172. }
  13173. // Type returns the node type of this mutation (SopNode).
  13174. func (m *SopNodeMutation) Type() string {
  13175. return m.typ
  13176. }
  13177. // Fields returns all fields that were changed during this mutation. Note that in
  13178. // order to get all numeric fields that were incremented/decremented, call
  13179. // AddedFields().
  13180. func (m *SopNodeMutation) Fields() []string {
  13181. fields := make([]string, 0, 12)
  13182. if m.created_at != nil {
  13183. fields = append(fields, sopnode.FieldCreatedAt)
  13184. }
  13185. if m.updated_at != nil {
  13186. fields = append(fields, sopnode.FieldUpdatedAt)
  13187. }
  13188. if m.status != nil {
  13189. fields = append(fields, sopnode.FieldStatus)
  13190. }
  13191. if m.deleted_at != nil {
  13192. fields = append(fields, sopnode.FieldDeletedAt)
  13193. }
  13194. if m.sop_stage != nil {
  13195. fields = append(fields, sopnode.FieldStageID)
  13196. }
  13197. if m.parent_id != nil {
  13198. fields = append(fields, sopnode.FieldParentID)
  13199. }
  13200. if m.name != nil {
  13201. fields = append(fields, sopnode.FieldName)
  13202. }
  13203. if m.condition_type != nil {
  13204. fields = append(fields, sopnode.FieldConditionType)
  13205. }
  13206. if m.condition_list != nil {
  13207. fields = append(fields, sopnode.FieldConditionList)
  13208. }
  13209. if m.no_reply_condition != nil {
  13210. fields = append(fields, sopnode.FieldNoReplyCondition)
  13211. }
  13212. if m.action_message != nil {
  13213. fields = append(fields, sopnode.FieldActionMessage)
  13214. }
  13215. if m.action_label != nil {
  13216. fields = append(fields, sopnode.FieldActionLabel)
  13217. }
  13218. return fields
  13219. }
  13220. // Field returns the value of a field with the given name. The second boolean
  13221. // return value indicates that this field was not set, or was not defined in the
  13222. // schema.
  13223. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  13224. switch name {
  13225. case sopnode.FieldCreatedAt:
  13226. return m.CreatedAt()
  13227. case sopnode.FieldUpdatedAt:
  13228. return m.UpdatedAt()
  13229. case sopnode.FieldStatus:
  13230. return m.Status()
  13231. case sopnode.FieldDeletedAt:
  13232. return m.DeletedAt()
  13233. case sopnode.FieldStageID:
  13234. return m.StageID()
  13235. case sopnode.FieldParentID:
  13236. return m.ParentID()
  13237. case sopnode.FieldName:
  13238. return m.Name()
  13239. case sopnode.FieldConditionType:
  13240. return m.ConditionType()
  13241. case sopnode.FieldConditionList:
  13242. return m.ConditionList()
  13243. case sopnode.FieldNoReplyCondition:
  13244. return m.NoReplyCondition()
  13245. case sopnode.FieldActionMessage:
  13246. return m.ActionMessage()
  13247. case sopnode.FieldActionLabel:
  13248. return m.ActionLabel()
  13249. }
  13250. return nil, false
  13251. }
  13252. // OldField returns the old value of the field from the database. An error is
  13253. // returned if the mutation operation is not UpdateOne, or the query to the
  13254. // database failed.
  13255. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13256. switch name {
  13257. case sopnode.FieldCreatedAt:
  13258. return m.OldCreatedAt(ctx)
  13259. case sopnode.FieldUpdatedAt:
  13260. return m.OldUpdatedAt(ctx)
  13261. case sopnode.FieldStatus:
  13262. return m.OldStatus(ctx)
  13263. case sopnode.FieldDeletedAt:
  13264. return m.OldDeletedAt(ctx)
  13265. case sopnode.FieldStageID:
  13266. return m.OldStageID(ctx)
  13267. case sopnode.FieldParentID:
  13268. return m.OldParentID(ctx)
  13269. case sopnode.FieldName:
  13270. return m.OldName(ctx)
  13271. case sopnode.FieldConditionType:
  13272. return m.OldConditionType(ctx)
  13273. case sopnode.FieldConditionList:
  13274. return m.OldConditionList(ctx)
  13275. case sopnode.FieldNoReplyCondition:
  13276. return m.OldNoReplyCondition(ctx)
  13277. case sopnode.FieldActionMessage:
  13278. return m.OldActionMessage(ctx)
  13279. case sopnode.FieldActionLabel:
  13280. return m.OldActionLabel(ctx)
  13281. }
  13282. return nil, fmt.Errorf("unknown SopNode field %s", name)
  13283. }
  13284. // SetField sets the value of a field with the given name. It returns an error if
  13285. // the field is not defined in the schema, or if the type mismatched the field
  13286. // type.
  13287. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  13288. switch name {
  13289. case sopnode.FieldCreatedAt:
  13290. v, ok := value.(time.Time)
  13291. if !ok {
  13292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13293. }
  13294. m.SetCreatedAt(v)
  13295. return nil
  13296. case sopnode.FieldUpdatedAt:
  13297. v, ok := value.(time.Time)
  13298. if !ok {
  13299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13300. }
  13301. m.SetUpdatedAt(v)
  13302. return nil
  13303. case sopnode.FieldStatus:
  13304. v, ok := value.(uint8)
  13305. if !ok {
  13306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13307. }
  13308. m.SetStatus(v)
  13309. return nil
  13310. case sopnode.FieldDeletedAt:
  13311. v, ok := value.(time.Time)
  13312. if !ok {
  13313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13314. }
  13315. m.SetDeletedAt(v)
  13316. return nil
  13317. case sopnode.FieldStageID:
  13318. v, ok := value.(uint64)
  13319. if !ok {
  13320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13321. }
  13322. m.SetStageID(v)
  13323. return nil
  13324. case sopnode.FieldParentID:
  13325. v, ok := value.(uint64)
  13326. if !ok {
  13327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13328. }
  13329. m.SetParentID(v)
  13330. return nil
  13331. case sopnode.FieldName:
  13332. v, ok := value.(string)
  13333. if !ok {
  13334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13335. }
  13336. m.SetName(v)
  13337. return nil
  13338. case sopnode.FieldConditionType:
  13339. v, ok := value.(int)
  13340. if !ok {
  13341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13342. }
  13343. m.SetConditionType(v)
  13344. return nil
  13345. case sopnode.FieldConditionList:
  13346. v, ok := value.([]string)
  13347. if !ok {
  13348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13349. }
  13350. m.SetConditionList(v)
  13351. return nil
  13352. case sopnode.FieldNoReplyCondition:
  13353. v, ok := value.(uint64)
  13354. if !ok {
  13355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13356. }
  13357. m.SetNoReplyCondition(v)
  13358. return nil
  13359. case sopnode.FieldActionMessage:
  13360. v, ok := value.([]custom_types.Action)
  13361. if !ok {
  13362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13363. }
  13364. m.SetActionMessage(v)
  13365. return nil
  13366. case sopnode.FieldActionLabel:
  13367. v, ok := value.([]uint64)
  13368. if !ok {
  13369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13370. }
  13371. m.SetActionLabel(v)
  13372. return nil
  13373. }
  13374. return fmt.Errorf("unknown SopNode field %s", name)
  13375. }
  13376. // AddedFields returns all numeric fields that were incremented/decremented during
  13377. // this mutation.
  13378. func (m *SopNodeMutation) AddedFields() []string {
  13379. var fields []string
  13380. if m.addstatus != nil {
  13381. fields = append(fields, sopnode.FieldStatus)
  13382. }
  13383. if m.addparent_id != nil {
  13384. fields = append(fields, sopnode.FieldParentID)
  13385. }
  13386. if m.addcondition_type != nil {
  13387. fields = append(fields, sopnode.FieldConditionType)
  13388. }
  13389. if m.addno_reply_condition != nil {
  13390. fields = append(fields, sopnode.FieldNoReplyCondition)
  13391. }
  13392. return fields
  13393. }
  13394. // AddedField returns the numeric value that was incremented/decremented on a field
  13395. // with the given name. The second boolean return value indicates that this field
  13396. // was not set, or was not defined in the schema.
  13397. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  13398. switch name {
  13399. case sopnode.FieldStatus:
  13400. return m.AddedStatus()
  13401. case sopnode.FieldParentID:
  13402. return m.AddedParentID()
  13403. case sopnode.FieldConditionType:
  13404. return m.AddedConditionType()
  13405. case sopnode.FieldNoReplyCondition:
  13406. return m.AddedNoReplyCondition()
  13407. }
  13408. return nil, false
  13409. }
  13410. // AddField adds the value to the field with the given name. It returns an error if
  13411. // the field is not defined in the schema, or if the type mismatched the field
  13412. // type.
  13413. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  13414. switch name {
  13415. case sopnode.FieldStatus:
  13416. v, ok := value.(int8)
  13417. if !ok {
  13418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13419. }
  13420. m.AddStatus(v)
  13421. return nil
  13422. case sopnode.FieldParentID:
  13423. v, ok := value.(int64)
  13424. if !ok {
  13425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13426. }
  13427. m.AddParentID(v)
  13428. return nil
  13429. case sopnode.FieldConditionType:
  13430. v, ok := value.(int)
  13431. if !ok {
  13432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13433. }
  13434. m.AddConditionType(v)
  13435. return nil
  13436. case sopnode.FieldNoReplyCondition:
  13437. v, ok := value.(int64)
  13438. if !ok {
  13439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13440. }
  13441. m.AddNoReplyCondition(v)
  13442. return nil
  13443. }
  13444. return fmt.Errorf("unknown SopNode numeric field %s", name)
  13445. }
  13446. // ClearedFields returns all nullable fields that were cleared during this
  13447. // mutation.
  13448. func (m *SopNodeMutation) ClearedFields() []string {
  13449. var fields []string
  13450. if m.FieldCleared(sopnode.FieldStatus) {
  13451. fields = append(fields, sopnode.FieldStatus)
  13452. }
  13453. if m.FieldCleared(sopnode.FieldDeletedAt) {
  13454. fields = append(fields, sopnode.FieldDeletedAt)
  13455. }
  13456. if m.FieldCleared(sopnode.FieldConditionList) {
  13457. fields = append(fields, sopnode.FieldConditionList)
  13458. }
  13459. if m.FieldCleared(sopnode.FieldActionMessage) {
  13460. fields = append(fields, sopnode.FieldActionMessage)
  13461. }
  13462. if m.FieldCleared(sopnode.FieldActionLabel) {
  13463. fields = append(fields, sopnode.FieldActionLabel)
  13464. }
  13465. return fields
  13466. }
  13467. // FieldCleared returns a boolean indicating if a field with the given name was
  13468. // cleared in this mutation.
  13469. func (m *SopNodeMutation) FieldCleared(name string) bool {
  13470. _, ok := m.clearedFields[name]
  13471. return ok
  13472. }
  13473. // ClearField clears the value of the field with the given name. It returns an
  13474. // error if the field is not defined in the schema.
  13475. func (m *SopNodeMutation) ClearField(name string) error {
  13476. switch name {
  13477. case sopnode.FieldStatus:
  13478. m.ClearStatus()
  13479. return nil
  13480. case sopnode.FieldDeletedAt:
  13481. m.ClearDeletedAt()
  13482. return nil
  13483. case sopnode.FieldConditionList:
  13484. m.ClearConditionList()
  13485. return nil
  13486. case sopnode.FieldActionMessage:
  13487. m.ClearActionMessage()
  13488. return nil
  13489. case sopnode.FieldActionLabel:
  13490. m.ClearActionLabel()
  13491. return nil
  13492. }
  13493. return fmt.Errorf("unknown SopNode nullable field %s", name)
  13494. }
  13495. // ResetField resets all changes in the mutation for the field with the given name.
  13496. // It returns an error if the field is not defined in the schema.
  13497. func (m *SopNodeMutation) ResetField(name string) error {
  13498. switch name {
  13499. case sopnode.FieldCreatedAt:
  13500. m.ResetCreatedAt()
  13501. return nil
  13502. case sopnode.FieldUpdatedAt:
  13503. m.ResetUpdatedAt()
  13504. return nil
  13505. case sopnode.FieldStatus:
  13506. m.ResetStatus()
  13507. return nil
  13508. case sopnode.FieldDeletedAt:
  13509. m.ResetDeletedAt()
  13510. return nil
  13511. case sopnode.FieldStageID:
  13512. m.ResetStageID()
  13513. return nil
  13514. case sopnode.FieldParentID:
  13515. m.ResetParentID()
  13516. return nil
  13517. case sopnode.FieldName:
  13518. m.ResetName()
  13519. return nil
  13520. case sopnode.FieldConditionType:
  13521. m.ResetConditionType()
  13522. return nil
  13523. case sopnode.FieldConditionList:
  13524. m.ResetConditionList()
  13525. return nil
  13526. case sopnode.FieldNoReplyCondition:
  13527. m.ResetNoReplyCondition()
  13528. return nil
  13529. case sopnode.FieldActionMessage:
  13530. m.ResetActionMessage()
  13531. return nil
  13532. case sopnode.FieldActionLabel:
  13533. m.ResetActionLabel()
  13534. return nil
  13535. }
  13536. return fmt.Errorf("unknown SopNode field %s", name)
  13537. }
  13538. // AddedEdges returns all edge names that were set/added in this mutation.
  13539. func (m *SopNodeMutation) AddedEdges() []string {
  13540. edges := make([]string, 0, 2)
  13541. if m.sop_stage != nil {
  13542. edges = append(edges, sopnode.EdgeSopStage)
  13543. }
  13544. if m.node_messages != nil {
  13545. edges = append(edges, sopnode.EdgeNodeMessages)
  13546. }
  13547. return edges
  13548. }
  13549. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13550. // name in this mutation.
  13551. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  13552. switch name {
  13553. case sopnode.EdgeSopStage:
  13554. if id := m.sop_stage; id != nil {
  13555. return []ent.Value{*id}
  13556. }
  13557. case sopnode.EdgeNodeMessages:
  13558. ids := make([]ent.Value, 0, len(m.node_messages))
  13559. for id := range m.node_messages {
  13560. ids = append(ids, id)
  13561. }
  13562. return ids
  13563. }
  13564. return nil
  13565. }
  13566. // RemovedEdges returns all edge names that were removed in this mutation.
  13567. func (m *SopNodeMutation) RemovedEdges() []string {
  13568. edges := make([]string, 0, 2)
  13569. if m.removednode_messages != nil {
  13570. edges = append(edges, sopnode.EdgeNodeMessages)
  13571. }
  13572. return edges
  13573. }
  13574. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13575. // the given name in this mutation.
  13576. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  13577. switch name {
  13578. case sopnode.EdgeNodeMessages:
  13579. ids := make([]ent.Value, 0, len(m.removednode_messages))
  13580. for id := range m.removednode_messages {
  13581. ids = append(ids, id)
  13582. }
  13583. return ids
  13584. }
  13585. return nil
  13586. }
  13587. // ClearedEdges returns all edge names that were cleared in this mutation.
  13588. func (m *SopNodeMutation) ClearedEdges() []string {
  13589. edges := make([]string, 0, 2)
  13590. if m.clearedsop_stage {
  13591. edges = append(edges, sopnode.EdgeSopStage)
  13592. }
  13593. if m.clearednode_messages {
  13594. edges = append(edges, sopnode.EdgeNodeMessages)
  13595. }
  13596. return edges
  13597. }
  13598. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13599. // was cleared in this mutation.
  13600. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  13601. switch name {
  13602. case sopnode.EdgeSopStage:
  13603. return m.clearedsop_stage
  13604. case sopnode.EdgeNodeMessages:
  13605. return m.clearednode_messages
  13606. }
  13607. return false
  13608. }
  13609. // ClearEdge clears the value of the edge with the given name. It returns an error
  13610. // if that edge is not defined in the schema.
  13611. func (m *SopNodeMutation) ClearEdge(name string) error {
  13612. switch name {
  13613. case sopnode.EdgeSopStage:
  13614. m.ClearSopStage()
  13615. return nil
  13616. }
  13617. return fmt.Errorf("unknown SopNode unique edge %s", name)
  13618. }
  13619. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13620. // It returns an error if the edge is not defined in the schema.
  13621. func (m *SopNodeMutation) ResetEdge(name string) error {
  13622. switch name {
  13623. case sopnode.EdgeSopStage:
  13624. m.ResetSopStage()
  13625. return nil
  13626. case sopnode.EdgeNodeMessages:
  13627. m.ResetNodeMessages()
  13628. return nil
  13629. }
  13630. return fmt.Errorf("unknown SopNode edge %s", name)
  13631. }
  13632. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  13633. type SopStageMutation struct {
  13634. config
  13635. op Op
  13636. typ string
  13637. id *uint64
  13638. created_at *time.Time
  13639. updated_at *time.Time
  13640. status *uint8
  13641. addstatus *int8
  13642. deleted_at *time.Time
  13643. name *string
  13644. condition_type *int
  13645. addcondition_type *int
  13646. condition_operator *int
  13647. addcondition_operator *int
  13648. condition_list *[]custom_types.Condition
  13649. appendcondition_list []custom_types.Condition
  13650. action_message *[]custom_types.Action
  13651. appendaction_message []custom_types.Action
  13652. action_label *[]uint64
  13653. appendaction_label []uint64
  13654. index_sort *int
  13655. addindex_sort *int
  13656. clearedFields map[string]struct{}
  13657. sop_task *uint64
  13658. clearedsop_task bool
  13659. stage_nodes map[uint64]struct{}
  13660. removedstage_nodes map[uint64]struct{}
  13661. clearedstage_nodes bool
  13662. stage_messages map[uint64]struct{}
  13663. removedstage_messages map[uint64]struct{}
  13664. clearedstage_messages bool
  13665. done bool
  13666. oldValue func(context.Context) (*SopStage, error)
  13667. predicates []predicate.SopStage
  13668. }
  13669. var _ ent.Mutation = (*SopStageMutation)(nil)
  13670. // sopstageOption allows management of the mutation configuration using functional options.
  13671. type sopstageOption func(*SopStageMutation)
  13672. // newSopStageMutation creates new mutation for the SopStage entity.
  13673. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  13674. m := &SopStageMutation{
  13675. config: c,
  13676. op: op,
  13677. typ: TypeSopStage,
  13678. clearedFields: make(map[string]struct{}),
  13679. }
  13680. for _, opt := range opts {
  13681. opt(m)
  13682. }
  13683. return m
  13684. }
  13685. // withSopStageID sets the ID field of the mutation.
  13686. func withSopStageID(id uint64) sopstageOption {
  13687. return func(m *SopStageMutation) {
  13688. var (
  13689. err error
  13690. once sync.Once
  13691. value *SopStage
  13692. )
  13693. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  13694. once.Do(func() {
  13695. if m.done {
  13696. err = errors.New("querying old values post mutation is not allowed")
  13697. } else {
  13698. value, err = m.Client().SopStage.Get(ctx, id)
  13699. }
  13700. })
  13701. return value, err
  13702. }
  13703. m.id = &id
  13704. }
  13705. }
  13706. // withSopStage sets the old SopStage of the mutation.
  13707. func withSopStage(node *SopStage) sopstageOption {
  13708. return func(m *SopStageMutation) {
  13709. m.oldValue = func(context.Context) (*SopStage, error) {
  13710. return node, nil
  13711. }
  13712. m.id = &node.ID
  13713. }
  13714. }
  13715. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13716. // executed in a transaction (ent.Tx), a transactional client is returned.
  13717. func (m SopStageMutation) Client() *Client {
  13718. client := &Client{config: m.config}
  13719. client.init()
  13720. return client
  13721. }
  13722. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13723. // it returns an error otherwise.
  13724. func (m SopStageMutation) Tx() (*Tx, error) {
  13725. if _, ok := m.driver.(*txDriver); !ok {
  13726. return nil, errors.New("ent: mutation is not running in a transaction")
  13727. }
  13728. tx := &Tx{config: m.config}
  13729. tx.init()
  13730. return tx, nil
  13731. }
  13732. // SetID sets the value of the id field. Note that this
  13733. // operation is only accepted on creation of SopStage entities.
  13734. func (m *SopStageMutation) SetID(id uint64) {
  13735. m.id = &id
  13736. }
  13737. // ID returns the ID value in the mutation. Note that the ID is only available
  13738. // if it was provided to the builder or after it was returned from the database.
  13739. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  13740. if m.id == nil {
  13741. return
  13742. }
  13743. return *m.id, true
  13744. }
  13745. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13746. // That means, if the mutation is applied within a transaction with an isolation level such
  13747. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13748. // or updated by the mutation.
  13749. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  13750. switch {
  13751. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13752. id, exists := m.ID()
  13753. if exists {
  13754. return []uint64{id}, nil
  13755. }
  13756. fallthrough
  13757. case m.op.Is(OpUpdate | OpDelete):
  13758. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  13759. default:
  13760. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13761. }
  13762. }
  13763. // SetCreatedAt sets the "created_at" field.
  13764. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  13765. m.created_at = &t
  13766. }
  13767. // CreatedAt returns the value of the "created_at" field in the mutation.
  13768. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  13769. v := m.created_at
  13770. if v == nil {
  13771. return
  13772. }
  13773. return *v, true
  13774. }
  13775. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  13776. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13778. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13779. if !m.op.Is(OpUpdateOne) {
  13780. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13781. }
  13782. if m.id == nil || m.oldValue == nil {
  13783. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13784. }
  13785. oldValue, err := m.oldValue(ctx)
  13786. if err != nil {
  13787. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13788. }
  13789. return oldValue.CreatedAt, nil
  13790. }
  13791. // ResetCreatedAt resets all changes to the "created_at" field.
  13792. func (m *SopStageMutation) ResetCreatedAt() {
  13793. m.created_at = nil
  13794. }
  13795. // SetUpdatedAt sets the "updated_at" field.
  13796. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  13797. m.updated_at = &t
  13798. }
  13799. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13800. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  13801. v := m.updated_at
  13802. if v == nil {
  13803. return
  13804. }
  13805. return *v, true
  13806. }
  13807. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  13808. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13810. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13811. if !m.op.Is(OpUpdateOne) {
  13812. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13813. }
  13814. if m.id == nil || m.oldValue == nil {
  13815. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13816. }
  13817. oldValue, err := m.oldValue(ctx)
  13818. if err != nil {
  13819. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13820. }
  13821. return oldValue.UpdatedAt, nil
  13822. }
  13823. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13824. func (m *SopStageMutation) ResetUpdatedAt() {
  13825. m.updated_at = nil
  13826. }
  13827. // SetStatus sets the "status" field.
  13828. func (m *SopStageMutation) SetStatus(u uint8) {
  13829. m.status = &u
  13830. m.addstatus = nil
  13831. }
  13832. // Status returns the value of the "status" field in the mutation.
  13833. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  13834. v := m.status
  13835. if v == nil {
  13836. return
  13837. }
  13838. return *v, true
  13839. }
  13840. // OldStatus returns the old "status" field's value of the SopStage entity.
  13841. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13843. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13844. if !m.op.Is(OpUpdateOne) {
  13845. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13846. }
  13847. if m.id == nil || m.oldValue == nil {
  13848. return v, errors.New("OldStatus requires an ID field in the mutation")
  13849. }
  13850. oldValue, err := m.oldValue(ctx)
  13851. if err != nil {
  13852. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13853. }
  13854. return oldValue.Status, nil
  13855. }
  13856. // AddStatus adds u to the "status" field.
  13857. func (m *SopStageMutation) AddStatus(u int8) {
  13858. if m.addstatus != nil {
  13859. *m.addstatus += u
  13860. } else {
  13861. m.addstatus = &u
  13862. }
  13863. }
  13864. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13865. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  13866. v := m.addstatus
  13867. if v == nil {
  13868. return
  13869. }
  13870. return *v, true
  13871. }
  13872. // ClearStatus clears the value of the "status" field.
  13873. func (m *SopStageMutation) ClearStatus() {
  13874. m.status = nil
  13875. m.addstatus = nil
  13876. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  13877. }
  13878. // StatusCleared returns if the "status" field was cleared in this mutation.
  13879. func (m *SopStageMutation) StatusCleared() bool {
  13880. _, ok := m.clearedFields[sopstage.FieldStatus]
  13881. return ok
  13882. }
  13883. // ResetStatus resets all changes to the "status" field.
  13884. func (m *SopStageMutation) ResetStatus() {
  13885. m.status = nil
  13886. m.addstatus = nil
  13887. delete(m.clearedFields, sopstage.FieldStatus)
  13888. }
  13889. // SetDeletedAt sets the "deleted_at" field.
  13890. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  13891. m.deleted_at = &t
  13892. }
  13893. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13894. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  13895. v := m.deleted_at
  13896. if v == nil {
  13897. return
  13898. }
  13899. return *v, true
  13900. }
  13901. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  13902. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13903. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13904. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13905. if !m.op.Is(OpUpdateOne) {
  13906. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13907. }
  13908. if m.id == nil || m.oldValue == nil {
  13909. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13910. }
  13911. oldValue, err := m.oldValue(ctx)
  13912. if err != nil {
  13913. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13914. }
  13915. return oldValue.DeletedAt, nil
  13916. }
  13917. // ClearDeletedAt clears the value of the "deleted_at" field.
  13918. func (m *SopStageMutation) ClearDeletedAt() {
  13919. m.deleted_at = nil
  13920. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  13921. }
  13922. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13923. func (m *SopStageMutation) DeletedAtCleared() bool {
  13924. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  13925. return ok
  13926. }
  13927. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13928. func (m *SopStageMutation) ResetDeletedAt() {
  13929. m.deleted_at = nil
  13930. delete(m.clearedFields, sopstage.FieldDeletedAt)
  13931. }
  13932. // SetTaskID sets the "task_id" field.
  13933. func (m *SopStageMutation) SetTaskID(u uint64) {
  13934. m.sop_task = &u
  13935. }
  13936. // TaskID returns the value of the "task_id" field in the mutation.
  13937. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  13938. v := m.sop_task
  13939. if v == nil {
  13940. return
  13941. }
  13942. return *v, true
  13943. }
  13944. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  13945. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13947. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  13948. if !m.op.Is(OpUpdateOne) {
  13949. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  13950. }
  13951. if m.id == nil || m.oldValue == nil {
  13952. return v, errors.New("OldTaskID requires an ID field in the mutation")
  13953. }
  13954. oldValue, err := m.oldValue(ctx)
  13955. if err != nil {
  13956. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  13957. }
  13958. return oldValue.TaskID, nil
  13959. }
  13960. // ResetTaskID resets all changes to the "task_id" field.
  13961. func (m *SopStageMutation) ResetTaskID() {
  13962. m.sop_task = nil
  13963. }
  13964. // SetName sets the "name" field.
  13965. func (m *SopStageMutation) SetName(s string) {
  13966. m.name = &s
  13967. }
  13968. // Name returns the value of the "name" field in the mutation.
  13969. func (m *SopStageMutation) Name() (r string, exists bool) {
  13970. v := m.name
  13971. if v == nil {
  13972. return
  13973. }
  13974. return *v, true
  13975. }
  13976. // OldName returns the old "name" field's value of the SopStage entity.
  13977. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13978. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13979. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  13980. if !m.op.Is(OpUpdateOne) {
  13981. return v, errors.New("OldName is only allowed on UpdateOne operations")
  13982. }
  13983. if m.id == nil || m.oldValue == nil {
  13984. return v, errors.New("OldName requires an ID field in the mutation")
  13985. }
  13986. oldValue, err := m.oldValue(ctx)
  13987. if err != nil {
  13988. return v, fmt.Errorf("querying old value for OldName: %w", err)
  13989. }
  13990. return oldValue.Name, nil
  13991. }
  13992. // ResetName resets all changes to the "name" field.
  13993. func (m *SopStageMutation) ResetName() {
  13994. m.name = nil
  13995. }
  13996. // SetConditionType sets the "condition_type" field.
  13997. func (m *SopStageMutation) SetConditionType(i int) {
  13998. m.condition_type = &i
  13999. m.addcondition_type = nil
  14000. }
  14001. // ConditionType returns the value of the "condition_type" field in the mutation.
  14002. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  14003. v := m.condition_type
  14004. if v == nil {
  14005. return
  14006. }
  14007. return *v, true
  14008. }
  14009. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  14010. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14012. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  14013. if !m.op.Is(OpUpdateOne) {
  14014. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  14015. }
  14016. if m.id == nil || m.oldValue == nil {
  14017. return v, errors.New("OldConditionType requires an ID field in the mutation")
  14018. }
  14019. oldValue, err := m.oldValue(ctx)
  14020. if err != nil {
  14021. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  14022. }
  14023. return oldValue.ConditionType, nil
  14024. }
  14025. // AddConditionType adds i to the "condition_type" field.
  14026. func (m *SopStageMutation) AddConditionType(i int) {
  14027. if m.addcondition_type != nil {
  14028. *m.addcondition_type += i
  14029. } else {
  14030. m.addcondition_type = &i
  14031. }
  14032. }
  14033. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  14034. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  14035. v := m.addcondition_type
  14036. if v == nil {
  14037. return
  14038. }
  14039. return *v, true
  14040. }
  14041. // ResetConditionType resets all changes to the "condition_type" field.
  14042. func (m *SopStageMutation) ResetConditionType() {
  14043. m.condition_type = nil
  14044. m.addcondition_type = nil
  14045. }
  14046. // SetConditionOperator sets the "condition_operator" field.
  14047. func (m *SopStageMutation) SetConditionOperator(i int) {
  14048. m.condition_operator = &i
  14049. m.addcondition_operator = nil
  14050. }
  14051. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  14052. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  14053. v := m.condition_operator
  14054. if v == nil {
  14055. return
  14056. }
  14057. return *v, true
  14058. }
  14059. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  14060. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14061. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14062. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  14063. if !m.op.Is(OpUpdateOne) {
  14064. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  14065. }
  14066. if m.id == nil || m.oldValue == nil {
  14067. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  14068. }
  14069. oldValue, err := m.oldValue(ctx)
  14070. if err != nil {
  14071. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  14072. }
  14073. return oldValue.ConditionOperator, nil
  14074. }
  14075. // AddConditionOperator adds i to the "condition_operator" field.
  14076. func (m *SopStageMutation) AddConditionOperator(i int) {
  14077. if m.addcondition_operator != nil {
  14078. *m.addcondition_operator += i
  14079. } else {
  14080. m.addcondition_operator = &i
  14081. }
  14082. }
  14083. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  14084. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  14085. v := m.addcondition_operator
  14086. if v == nil {
  14087. return
  14088. }
  14089. return *v, true
  14090. }
  14091. // ResetConditionOperator resets all changes to the "condition_operator" field.
  14092. func (m *SopStageMutation) ResetConditionOperator() {
  14093. m.condition_operator = nil
  14094. m.addcondition_operator = nil
  14095. }
  14096. // SetConditionList sets the "condition_list" field.
  14097. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  14098. m.condition_list = &ct
  14099. m.appendcondition_list = nil
  14100. }
  14101. // ConditionList returns the value of the "condition_list" field in the mutation.
  14102. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  14103. v := m.condition_list
  14104. if v == nil {
  14105. return
  14106. }
  14107. return *v, true
  14108. }
  14109. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  14110. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14112. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  14113. if !m.op.Is(OpUpdateOne) {
  14114. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  14115. }
  14116. if m.id == nil || m.oldValue == nil {
  14117. return v, errors.New("OldConditionList requires an ID field in the mutation")
  14118. }
  14119. oldValue, err := m.oldValue(ctx)
  14120. if err != nil {
  14121. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  14122. }
  14123. return oldValue.ConditionList, nil
  14124. }
  14125. // AppendConditionList adds ct to the "condition_list" field.
  14126. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  14127. m.appendcondition_list = append(m.appendcondition_list, ct...)
  14128. }
  14129. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  14130. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  14131. if len(m.appendcondition_list) == 0 {
  14132. return nil, false
  14133. }
  14134. return m.appendcondition_list, true
  14135. }
  14136. // ResetConditionList resets all changes to the "condition_list" field.
  14137. func (m *SopStageMutation) ResetConditionList() {
  14138. m.condition_list = nil
  14139. m.appendcondition_list = nil
  14140. }
  14141. // SetActionMessage sets the "action_message" field.
  14142. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  14143. m.action_message = &ct
  14144. m.appendaction_message = nil
  14145. }
  14146. // ActionMessage returns the value of the "action_message" field in the mutation.
  14147. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  14148. v := m.action_message
  14149. if v == nil {
  14150. return
  14151. }
  14152. return *v, true
  14153. }
  14154. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  14155. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14157. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  14158. if !m.op.Is(OpUpdateOne) {
  14159. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  14160. }
  14161. if m.id == nil || m.oldValue == nil {
  14162. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  14163. }
  14164. oldValue, err := m.oldValue(ctx)
  14165. if err != nil {
  14166. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  14167. }
  14168. return oldValue.ActionMessage, nil
  14169. }
  14170. // AppendActionMessage adds ct to the "action_message" field.
  14171. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  14172. m.appendaction_message = append(m.appendaction_message, ct...)
  14173. }
  14174. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  14175. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  14176. if len(m.appendaction_message) == 0 {
  14177. return nil, false
  14178. }
  14179. return m.appendaction_message, true
  14180. }
  14181. // ClearActionMessage clears the value of the "action_message" field.
  14182. func (m *SopStageMutation) ClearActionMessage() {
  14183. m.action_message = nil
  14184. m.appendaction_message = nil
  14185. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  14186. }
  14187. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  14188. func (m *SopStageMutation) ActionMessageCleared() bool {
  14189. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  14190. return ok
  14191. }
  14192. // ResetActionMessage resets all changes to the "action_message" field.
  14193. func (m *SopStageMutation) ResetActionMessage() {
  14194. m.action_message = nil
  14195. m.appendaction_message = nil
  14196. delete(m.clearedFields, sopstage.FieldActionMessage)
  14197. }
  14198. // SetActionLabel sets the "action_label" field.
  14199. func (m *SopStageMutation) SetActionLabel(u []uint64) {
  14200. m.action_label = &u
  14201. m.appendaction_label = nil
  14202. }
  14203. // ActionLabel returns the value of the "action_label" field in the mutation.
  14204. func (m *SopStageMutation) ActionLabel() (r []uint64, exists bool) {
  14205. v := m.action_label
  14206. if v == nil {
  14207. return
  14208. }
  14209. return *v, true
  14210. }
  14211. // OldActionLabel returns the old "action_label" field's value of the SopStage entity.
  14212. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14214. func (m *SopStageMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  14215. if !m.op.Is(OpUpdateOne) {
  14216. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  14217. }
  14218. if m.id == nil || m.oldValue == nil {
  14219. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  14220. }
  14221. oldValue, err := m.oldValue(ctx)
  14222. if err != nil {
  14223. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  14224. }
  14225. return oldValue.ActionLabel, nil
  14226. }
  14227. // AppendActionLabel adds u to the "action_label" field.
  14228. func (m *SopStageMutation) AppendActionLabel(u []uint64) {
  14229. m.appendaction_label = append(m.appendaction_label, u...)
  14230. }
  14231. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  14232. func (m *SopStageMutation) AppendedActionLabel() ([]uint64, bool) {
  14233. if len(m.appendaction_label) == 0 {
  14234. return nil, false
  14235. }
  14236. return m.appendaction_label, true
  14237. }
  14238. // ClearActionLabel clears the value of the "action_label" field.
  14239. func (m *SopStageMutation) ClearActionLabel() {
  14240. m.action_label = nil
  14241. m.appendaction_label = nil
  14242. m.clearedFields[sopstage.FieldActionLabel] = struct{}{}
  14243. }
  14244. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  14245. func (m *SopStageMutation) ActionLabelCleared() bool {
  14246. _, ok := m.clearedFields[sopstage.FieldActionLabel]
  14247. return ok
  14248. }
  14249. // ResetActionLabel resets all changes to the "action_label" field.
  14250. func (m *SopStageMutation) ResetActionLabel() {
  14251. m.action_label = nil
  14252. m.appendaction_label = nil
  14253. delete(m.clearedFields, sopstage.FieldActionLabel)
  14254. }
  14255. // SetIndexSort sets the "index_sort" field.
  14256. func (m *SopStageMutation) SetIndexSort(i int) {
  14257. m.index_sort = &i
  14258. m.addindex_sort = nil
  14259. }
  14260. // IndexSort returns the value of the "index_sort" field in the mutation.
  14261. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  14262. v := m.index_sort
  14263. if v == nil {
  14264. return
  14265. }
  14266. return *v, true
  14267. }
  14268. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  14269. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14271. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  14272. if !m.op.Is(OpUpdateOne) {
  14273. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  14274. }
  14275. if m.id == nil || m.oldValue == nil {
  14276. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  14277. }
  14278. oldValue, err := m.oldValue(ctx)
  14279. if err != nil {
  14280. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  14281. }
  14282. return oldValue.IndexSort, nil
  14283. }
  14284. // AddIndexSort adds i to the "index_sort" field.
  14285. func (m *SopStageMutation) AddIndexSort(i int) {
  14286. if m.addindex_sort != nil {
  14287. *m.addindex_sort += i
  14288. } else {
  14289. m.addindex_sort = &i
  14290. }
  14291. }
  14292. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  14293. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  14294. v := m.addindex_sort
  14295. if v == nil {
  14296. return
  14297. }
  14298. return *v, true
  14299. }
  14300. // ClearIndexSort clears the value of the "index_sort" field.
  14301. func (m *SopStageMutation) ClearIndexSort() {
  14302. m.index_sort = nil
  14303. m.addindex_sort = nil
  14304. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  14305. }
  14306. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  14307. func (m *SopStageMutation) IndexSortCleared() bool {
  14308. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  14309. return ok
  14310. }
  14311. // ResetIndexSort resets all changes to the "index_sort" field.
  14312. func (m *SopStageMutation) ResetIndexSort() {
  14313. m.index_sort = nil
  14314. m.addindex_sort = nil
  14315. delete(m.clearedFields, sopstage.FieldIndexSort)
  14316. }
  14317. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  14318. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  14319. m.sop_task = &id
  14320. }
  14321. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  14322. func (m *SopStageMutation) ClearSopTask() {
  14323. m.clearedsop_task = true
  14324. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  14325. }
  14326. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  14327. func (m *SopStageMutation) SopTaskCleared() bool {
  14328. return m.clearedsop_task
  14329. }
  14330. // SopTaskID returns the "sop_task" edge ID in the mutation.
  14331. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  14332. if m.sop_task != nil {
  14333. return *m.sop_task, true
  14334. }
  14335. return
  14336. }
  14337. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  14338. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14339. // SopTaskID instead. It exists only for internal usage by the builders.
  14340. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  14341. if id := m.sop_task; id != nil {
  14342. ids = append(ids, *id)
  14343. }
  14344. return
  14345. }
  14346. // ResetSopTask resets all changes to the "sop_task" edge.
  14347. func (m *SopStageMutation) ResetSopTask() {
  14348. m.sop_task = nil
  14349. m.clearedsop_task = false
  14350. }
  14351. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  14352. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  14353. if m.stage_nodes == nil {
  14354. m.stage_nodes = make(map[uint64]struct{})
  14355. }
  14356. for i := range ids {
  14357. m.stage_nodes[ids[i]] = struct{}{}
  14358. }
  14359. }
  14360. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  14361. func (m *SopStageMutation) ClearStageNodes() {
  14362. m.clearedstage_nodes = true
  14363. }
  14364. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  14365. func (m *SopStageMutation) StageNodesCleared() bool {
  14366. return m.clearedstage_nodes
  14367. }
  14368. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  14369. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  14370. if m.removedstage_nodes == nil {
  14371. m.removedstage_nodes = make(map[uint64]struct{})
  14372. }
  14373. for i := range ids {
  14374. delete(m.stage_nodes, ids[i])
  14375. m.removedstage_nodes[ids[i]] = struct{}{}
  14376. }
  14377. }
  14378. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  14379. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  14380. for id := range m.removedstage_nodes {
  14381. ids = append(ids, id)
  14382. }
  14383. return
  14384. }
  14385. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  14386. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  14387. for id := range m.stage_nodes {
  14388. ids = append(ids, id)
  14389. }
  14390. return
  14391. }
  14392. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  14393. func (m *SopStageMutation) ResetStageNodes() {
  14394. m.stage_nodes = nil
  14395. m.clearedstage_nodes = false
  14396. m.removedstage_nodes = nil
  14397. }
  14398. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  14399. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  14400. if m.stage_messages == nil {
  14401. m.stage_messages = make(map[uint64]struct{})
  14402. }
  14403. for i := range ids {
  14404. m.stage_messages[ids[i]] = struct{}{}
  14405. }
  14406. }
  14407. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  14408. func (m *SopStageMutation) ClearStageMessages() {
  14409. m.clearedstage_messages = true
  14410. }
  14411. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  14412. func (m *SopStageMutation) StageMessagesCleared() bool {
  14413. return m.clearedstage_messages
  14414. }
  14415. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  14416. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  14417. if m.removedstage_messages == nil {
  14418. m.removedstage_messages = make(map[uint64]struct{})
  14419. }
  14420. for i := range ids {
  14421. delete(m.stage_messages, ids[i])
  14422. m.removedstage_messages[ids[i]] = struct{}{}
  14423. }
  14424. }
  14425. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  14426. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  14427. for id := range m.removedstage_messages {
  14428. ids = append(ids, id)
  14429. }
  14430. return
  14431. }
  14432. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  14433. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  14434. for id := range m.stage_messages {
  14435. ids = append(ids, id)
  14436. }
  14437. return
  14438. }
  14439. // ResetStageMessages resets all changes to the "stage_messages" edge.
  14440. func (m *SopStageMutation) ResetStageMessages() {
  14441. m.stage_messages = nil
  14442. m.clearedstage_messages = false
  14443. m.removedstage_messages = nil
  14444. }
  14445. // Where appends a list predicates to the SopStageMutation builder.
  14446. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  14447. m.predicates = append(m.predicates, ps...)
  14448. }
  14449. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  14450. // users can use type-assertion to append predicates that do not depend on any generated package.
  14451. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  14452. p := make([]predicate.SopStage, len(ps))
  14453. for i := range ps {
  14454. p[i] = ps[i]
  14455. }
  14456. m.Where(p...)
  14457. }
  14458. // Op returns the operation name.
  14459. func (m *SopStageMutation) Op() Op {
  14460. return m.op
  14461. }
  14462. // SetOp allows setting the mutation operation.
  14463. func (m *SopStageMutation) SetOp(op Op) {
  14464. m.op = op
  14465. }
  14466. // Type returns the node type of this mutation (SopStage).
  14467. func (m *SopStageMutation) Type() string {
  14468. return m.typ
  14469. }
  14470. // Fields returns all fields that were changed during this mutation. Note that in
  14471. // order to get all numeric fields that were incremented/decremented, call
  14472. // AddedFields().
  14473. func (m *SopStageMutation) Fields() []string {
  14474. fields := make([]string, 0, 12)
  14475. if m.created_at != nil {
  14476. fields = append(fields, sopstage.FieldCreatedAt)
  14477. }
  14478. if m.updated_at != nil {
  14479. fields = append(fields, sopstage.FieldUpdatedAt)
  14480. }
  14481. if m.status != nil {
  14482. fields = append(fields, sopstage.FieldStatus)
  14483. }
  14484. if m.deleted_at != nil {
  14485. fields = append(fields, sopstage.FieldDeletedAt)
  14486. }
  14487. if m.sop_task != nil {
  14488. fields = append(fields, sopstage.FieldTaskID)
  14489. }
  14490. if m.name != nil {
  14491. fields = append(fields, sopstage.FieldName)
  14492. }
  14493. if m.condition_type != nil {
  14494. fields = append(fields, sopstage.FieldConditionType)
  14495. }
  14496. if m.condition_operator != nil {
  14497. fields = append(fields, sopstage.FieldConditionOperator)
  14498. }
  14499. if m.condition_list != nil {
  14500. fields = append(fields, sopstage.FieldConditionList)
  14501. }
  14502. if m.action_message != nil {
  14503. fields = append(fields, sopstage.FieldActionMessage)
  14504. }
  14505. if m.action_label != nil {
  14506. fields = append(fields, sopstage.FieldActionLabel)
  14507. }
  14508. if m.index_sort != nil {
  14509. fields = append(fields, sopstage.FieldIndexSort)
  14510. }
  14511. return fields
  14512. }
  14513. // Field returns the value of a field with the given name. The second boolean
  14514. // return value indicates that this field was not set, or was not defined in the
  14515. // schema.
  14516. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  14517. switch name {
  14518. case sopstage.FieldCreatedAt:
  14519. return m.CreatedAt()
  14520. case sopstage.FieldUpdatedAt:
  14521. return m.UpdatedAt()
  14522. case sopstage.FieldStatus:
  14523. return m.Status()
  14524. case sopstage.FieldDeletedAt:
  14525. return m.DeletedAt()
  14526. case sopstage.FieldTaskID:
  14527. return m.TaskID()
  14528. case sopstage.FieldName:
  14529. return m.Name()
  14530. case sopstage.FieldConditionType:
  14531. return m.ConditionType()
  14532. case sopstage.FieldConditionOperator:
  14533. return m.ConditionOperator()
  14534. case sopstage.FieldConditionList:
  14535. return m.ConditionList()
  14536. case sopstage.FieldActionMessage:
  14537. return m.ActionMessage()
  14538. case sopstage.FieldActionLabel:
  14539. return m.ActionLabel()
  14540. case sopstage.FieldIndexSort:
  14541. return m.IndexSort()
  14542. }
  14543. return nil, false
  14544. }
  14545. // OldField returns the old value of the field from the database. An error is
  14546. // returned if the mutation operation is not UpdateOne, or the query to the
  14547. // database failed.
  14548. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14549. switch name {
  14550. case sopstage.FieldCreatedAt:
  14551. return m.OldCreatedAt(ctx)
  14552. case sopstage.FieldUpdatedAt:
  14553. return m.OldUpdatedAt(ctx)
  14554. case sopstage.FieldStatus:
  14555. return m.OldStatus(ctx)
  14556. case sopstage.FieldDeletedAt:
  14557. return m.OldDeletedAt(ctx)
  14558. case sopstage.FieldTaskID:
  14559. return m.OldTaskID(ctx)
  14560. case sopstage.FieldName:
  14561. return m.OldName(ctx)
  14562. case sopstage.FieldConditionType:
  14563. return m.OldConditionType(ctx)
  14564. case sopstage.FieldConditionOperator:
  14565. return m.OldConditionOperator(ctx)
  14566. case sopstage.FieldConditionList:
  14567. return m.OldConditionList(ctx)
  14568. case sopstage.FieldActionMessage:
  14569. return m.OldActionMessage(ctx)
  14570. case sopstage.FieldActionLabel:
  14571. return m.OldActionLabel(ctx)
  14572. case sopstage.FieldIndexSort:
  14573. return m.OldIndexSort(ctx)
  14574. }
  14575. return nil, fmt.Errorf("unknown SopStage field %s", name)
  14576. }
  14577. // SetField sets the value of a field with the given name. It returns an error if
  14578. // the field is not defined in the schema, or if the type mismatched the field
  14579. // type.
  14580. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  14581. switch name {
  14582. case sopstage.FieldCreatedAt:
  14583. v, ok := value.(time.Time)
  14584. if !ok {
  14585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14586. }
  14587. m.SetCreatedAt(v)
  14588. return nil
  14589. case sopstage.FieldUpdatedAt:
  14590. v, ok := value.(time.Time)
  14591. if !ok {
  14592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14593. }
  14594. m.SetUpdatedAt(v)
  14595. return nil
  14596. case sopstage.FieldStatus:
  14597. v, ok := value.(uint8)
  14598. if !ok {
  14599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14600. }
  14601. m.SetStatus(v)
  14602. return nil
  14603. case sopstage.FieldDeletedAt:
  14604. v, ok := value.(time.Time)
  14605. if !ok {
  14606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14607. }
  14608. m.SetDeletedAt(v)
  14609. return nil
  14610. case sopstage.FieldTaskID:
  14611. v, ok := value.(uint64)
  14612. if !ok {
  14613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14614. }
  14615. m.SetTaskID(v)
  14616. return nil
  14617. case sopstage.FieldName:
  14618. v, ok := value.(string)
  14619. if !ok {
  14620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14621. }
  14622. m.SetName(v)
  14623. return nil
  14624. case sopstage.FieldConditionType:
  14625. v, ok := value.(int)
  14626. if !ok {
  14627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14628. }
  14629. m.SetConditionType(v)
  14630. return nil
  14631. case sopstage.FieldConditionOperator:
  14632. v, ok := value.(int)
  14633. if !ok {
  14634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14635. }
  14636. m.SetConditionOperator(v)
  14637. return nil
  14638. case sopstage.FieldConditionList:
  14639. v, ok := value.([]custom_types.Condition)
  14640. if !ok {
  14641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14642. }
  14643. m.SetConditionList(v)
  14644. return nil
  14645. case sopstage.FieldActionMessage:
  14646. v, ok := value.([]custom_types.Action)
  14647. if !ok {
  14648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14649. }
  14650. m.SetActionMessage(v)
  14651. return nil
  14652. case sopstage.FieldActionLabel:
  14653. v, ok := value.([]uint64)
  14654. if !ok {
  14655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14656. }
  14657. m.SetActionLabel(v)
  14658. return nil
  14659. case sopstage.FieldIndexSort:
  14660. v, ok := value.(int)
  14661. if !ok {
  14662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14663. }
  14664. m.SetIndexSort(v)
  14665. return nil
  14666. }
  14667. return fmt.Errorf("unknown SopStage field %s", name)
  14668. }
  14669. // AddedFields returns all numeric fields that were incremented/decremented during
  14670. // this mutation.
  14671. func (m *SopStageMutation) AddedFields() []string {
  14672. var fields []string
  14673. if m.addstatus != nil {
  14674. fields = append(fields, sopstage.FieldStatus)
  14675. }
  14676. if m.addcondition_type != nil {
  14677. fields = append(fields, sopstage.FieldConditionType)
  14678. }
  14679. if m.addcondition_operator != nil {
  14680. fields = append(fields, sopstage.FieldConditionOperator)
  14681. }
  14682. if m.addindex_sort != nil {
  14683. fields = append(fields, sopstage.FieldIndexSort)
  14684. }
  14685. return fields
  14686. }
  14687. // AddedField returns the numeric value that was incremented/decremented on a field
  14688. // with the given name. The second boolean return value indicates that this field
  14689. // was not set, or was not defined in the schema.
  14690. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  14691. switch name {
  14692. case sopstage.FieldStatus:
  14693. return m.AddedStatus()
  14694. case sopstage.FieldConditionType:
  14695. return m.AddedConditionType()
  14696. case sopstage.FieldConditionOperator:
  14697. return m.AddedConditionOperator()
  14698. case sopstage.FieldIndexSort:
  14699. return m.AddedIndexSort()
  14700. }
  14701. return nil, false
  14702. }
  14703. // AddField adds the value to the field with the given name. It returns an error if
  14704. // the field is not defined in the schema, or if the type mismatched the field
  14705. // type.
  14706. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  14707. switch name {
  14708. case sopstage.FieldStatus:
  14709. v, ok := value.(int8)
  14710. if !ok {
  14711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14712. }
  14713. m.AddStatus(v)
  14714. return nil
  14715. case sopstage.FieldConditionType:
  14716. v, ok := value.(int)
  14717. if !ok {
  14718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14719. }
  14720. m.AddConditionType(v)
  14721. return nil
  14722. case sopstage.FieldConditionOperator:
  14723. v, ok := value.(int)
  14724. if !ok {
  14725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14726. }
  14727. m.AddConditionOperator(v)
  14728. return nil
  14729. case sopstage.FieldIndexSort:
  14730. v, ok := value.(int)
  14731. if !ok {
  14732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14733. }
  14734. m.AddIndexSort(v)
  14735. return nil
  14736. }
  14737. return fmt.Errorf("unknown SopStage numeric field %s", name)
  14738. }
  14739. // ClearedFields returns all nullable fields that were cleared during this
  14740. // mutation.
  14741. func (m *SopStageMutation) ClearedFields() []string {
  14742. var fields []string
  14743. if m.FieldCleared(sopstage.FieldStatus) {
  14744. fields = append(fields, sopstage.FieldStatus)
  14745. }
  14746. if m.FieldCleared(sopstage.FieldDeletedAt) {
  14747. fields = append(fields, sopstage.FieldDeletedAt)
  14748. }
  14749. if m.FieldCleared(sopstage.FieldActionMessage) {
  14750. fields = append(fields, sopstage.FieldActionMessage)
  14751. }
  14752. if m.FieldCleared(sopstage.FieldActionLabel) {
  14753. fields = append(fields, sopstage.FieldActionLabel)
  14754. }
  14755. if m.FieldCleared(sopstage.FieldIndexSort) {
  14756. fields = append(fields, sopstage.FieldIndexSort)
  14757. }
  14758. return fields
  14759. }
  14760. // FieldCleared returns a boolean indicating if a field with the given name was
  14761. // cleared in this mutation.
  14762. func (m *SopStageMutation) FieldCleared(name string) bool {
  14763. _, ok := m.clearedFields[name]
  14764. return ok
  14765. }
  14766. // ClearField clears the value of the field with the given name. It returns an
  14767. // error if the field is not defined in the schema.
  14768. func (m *SopStageMutation) ClearField(name string) error {
  14769. switch name {
  14770. case sopstage.FieldStatus:
  14771. m.ClearStatus()
  14772. return nil
  14773. case sopstage.FieldDeletedAt:
  14774. m.ClearDeletedAt()
  14775. return nil
  14776. case sopstage.FieldActionMessage:
  14777. m.ClearActionMessage()
  14778. return nil
  14779. case sopstage.FieldActionLabel:
  14780. m.ClearActionLabel()
  14781. return nil
  14782. case sopstage.FieldIndexSort:
  14783. m.ClearIndexSort()
  14784. return nil
  14785. }
  14786. return fmt.Errorf("unknown SopStage nullable field %s", name)
  14787. }
  14788. // ResetField resets all changes in the mutation for the field with the given name.
  14789. // It returns an error if the field is not defined in the schema.
  14790. func (m *SopStageMutation) ResetField(name string) error {
  14791. switch name {
  14792. case sopstage.FieldCreatedAt:
  14793. m.ResetCreatedAt()
  14794. return nil
  14795. case sopstage.FieldUpdatedAt:
  14796. m.ResetUpdatedAt()
  14797. return nil
  14798. case sopstage.FieldStatus:
  14799. m.ResetStatus()
  14800. return nil
  14801. case sopstage.FieldDeletedAt:
  14802. m.ResetDeletedAt()
  14803. return nil
  14804. case sopstage.FieldTaskID:
  14805. m.ResetTaskID()
  14806. return nil
  14807. case sopstage.FieldName:
  14808. m.ResetName()
  14809. return nil
  14810. case sopstage.FieldConditionType:
  14811. m.ResetConditionType()
  14812. return nil
  14813. case sopstage.FieldConditionOperator:
  14814. m.ResetConditionOperator()
  14815. return nil
  14816. case sopstage.FieldConditionList:
  14817. m.ResetConditionList()
  14818. return nil
  14819. case sopstage.FieldActionMessage:
  14820. m.ResetActionMessage()
  14821. return nil
  14822. case sopstage.FieldActionLabel:
  14823. m.ResetActionLabel()
  14824. return nil
  14825. case sopstage.FieldIndexSort:
  14826. m.ResetIndexSort()
  14827. return nil
  14828. }
  14829. return fmt.Errorf("unknown SopStage field %s", name)
  14830. }
  14831. // AddedEdges returns all edge names that were set/added in this mutation.
  14832. func (m *SopStageMutation) AddedEdges() []string {
  14833. edges := make([]string, 0, 3)
  14834. if m.sop_task != nil {
  14835. edges = append(edges, sopstage.EdgeSopTask)
  14836. }
  14837. if m.stage_nodes != nil {
  14838. edges = append(edges, sopstage.EdgeStageNodes)
  14839. }
  14840. if m.stage_messages != nil {
  14841. edges = append(edges, sopstage.EdgeStageMessages)
  14842. }
  14843. return edges
  14844. }
  14845. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14846. // name in this mutation.
  14847. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  14848. switch name {
  14849. case sopstage.EdgeSopTask:
  14850. if id := m.sop_task; id != nil {
  14851. return []ent.Value{*id}
  14852. }
  14853. case sopstage.EdgeStageNodes:
  14854. ids := make([]ent.Value, 0, len(m.stage_nodes))
  14855. for id := range m.stage_nodes {
  14856. ids = append(ids, id)
  14857. }
  14858. return ids
  14859. case sopstage.EdgeStageMessages:
  14860. ids := make([]ent.Value, 0, len(m.stage_messages))
  14861. for id := range m.stage_messages {
  14862. ids = append(ids, id)
  14863. }
  14864. return ids
  14865. }
  14866. return nil
  14867. }
  14868. // RemovedEdges returns all edge names that were removed in this mutation.
  14869. func (m *SopStageMutation) RemovedEdges() []string {
  14870. edges := make([]string, 0, 3)
  14871. if m.removedstage_nodes != nil {
  14872. edges = append(edges, sopstage.EdgeStageNodes)
  14873. }
  14874. if m.removedstage_messages != nil {
  14875. edges = append(edges, sopstage.EdgeStageMessages)
  14876. }
  14877. return edges
  14878. }
  14879. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14880. // the given name in this mutation.
  14881. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  14882. switch name {
  14883. case sopstage.EdgeStageNodes:
  14884. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  14885. for id := range m.removedstage_nodes {
  14886. ids = append(ids, id)
  14887. }
  14888. return ids
  14889. case sopstage.EdgeStageMessages:
  14890. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  14891. for id := range m.removedstage_messages {
  14892. ids = append(ids, id)
  14893. }
  14894. return ids
  14895. }
  14896. return nil
  14897. }
  14898. // ClearedEdges returns all edge names that were cleared in this mutation.
  14899. func (m *SopStageMutation) ClearedEdges() []string {
  14900. edges := make([]string, 0, 3)
  14901. if m.clearedsop_task {
  14902. edges = append(edges, sopstage.EdgeSopTask)
  14903. }
  14904. if m.clearedstage_nodes {
  14905. edges = append(edges, sopstage.EdgeStageNodes)
  14906. }
  14907. if m.clearedstage_messages {
  14908. edges = append(edges, sopstage.EdgeStageMessages)
  14909. }
  14910. return edges
  14911. }
  14912. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14913. // was cleared in this mutation.
  14914. func (m *SopStageMutation) EdgeCleared(name string) bool {
  14915. switch name {
  14916. case sopstage.EdgeSopTask:
  14917. return m.clearedsop_task
  14918. case sopstage.EdgeStageNodes:
  14919. return m.clearedstage_nodes
  14920. case sopstage.EdgeStageMessages:
  14921. return m.clearedstage_messages
  14922. }
  14923. return false
  14924. }
  14925. // ClearEdge clears the value of the edge with the given name. It returns an error
  14926. // if that edge is not defined in the schema.
  14927. func (m *SopStageMutation) ClearEdge(name string) error {
  14928. switch name {
  14929. case sopstage.EdgeSopTask:
  14930. m.ClearSopTask()
  14931. return nil
  14932. }
  14933. return fmt.Errorf("unknown SopStage unique edge %s", name)
  14934. }
  14935. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14936. // It returns an error if the edge is not defined in the schema.
  14937. func (m *SopStageMutation) ResetEdge(name string) error {
  14938. switch name {
  14939. case sopstage.EdgeSopTask:
  14940. m.ResetSopTask()
  14941. return nil
  14942. case sopstage.EdgeStageNodes:
  14943. m.ResetStageNodes()
  14944. return nil
  14945. case sopstage.EdgeStageMessages:
  14946. m.ResetStageMessages()
  14947. return nil
  14948. }
  14949. return fmt.Errorf("unknown SopStage edge %s", name)
  14950. }
  14951. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  14952. type SopTaskMutation struct {
  14953. config
  14954. op Op
  14955. typ string
  14956. id *uint64
  14957. created_at *time.Time
  14958. updated_at *time.Time
  14959. status *uint8
  14960. addstatus *int8
  14961. deleted_at *time.Time
  14962. name *string
  14963. bot_wxid_list *[]string
  14964. appendbot_wxid_list []string
  14965. _type *int
  14966. add_type *int
  14967. plan_start_time *time.Time
  14968. plan_end_time *time.Time
  14969. creator_id *string
  14970. organization_id *uint64
  14971. addorganization_id *int64
  14972. clearedFields map[string]struct{}
  14973. task_stages map[uint64]struct{}
  14974. removedtask_stages map[uint64]struct{}
  14975. clearedtask_stages bool
  14976. done bool
  14977. oldValue func(context.Context) (*SopTask, error)
  14978. predicates []predicate.SopTask
  14979. }
  14980. var _ ent.Mutation = (*SopTaskMutation)(nil)
  14981. // soptaskOption allows management of the mutation configuration using functional options.
  14982. type soptaskOption func(*SopTaskMutation)
  14983. // newSopTaskMutation creates new mutation for the SopTask entity.
  14984. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  14985. m := &SopTaskMutation{
  14986. config: c,
  14987. op: op,
  14988. typ: TypeSopTask,
  14989. clearedFields: make(map[string]struct{}),
  14990. }
  14991. for _, opt := range opts {
  14992. opt(m)
  14993. }
  14994. return m
  14995. }
  14996. // withSopTaskID sets the ID field of the mutation.
  14997. func withSopTaskID(id uint64) soptaskOption {
  14998. return func(m *SopTaskMutation) {
  14999. var (
  15000. err error
  15001. once sync.Once
  15002. value *SopTask
  15003. )
  15004. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  15005. once.Do(func() {
  15006. if m.done {
  15007. err = errors.New("querying old values post mutation is not allowed")
  15008. } else {
  15009. value, err = m.Client().SopTask.Get(ctx, id)
  15010. }
  15011. })
  15012. return value, err
  15013. }
  15014. m.id = &id
  15015. }
  15016. }
  15017. // withSopTask sets the old SopTask of the mutation.
  15018. func withSopTask(node *SopTask) soptaskOption {
  15019. return func(m *SopTaskMutation) {
  15020. m.oldValue = func(context.Context) (*SopTask, error) {
  15021. return node, nil
  15022. }
  15023. m.id = &node.ID
  15024. }
  15025. }
  15026. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15027. // executed in a transaction (ent.Tx), a transactional client is returned.
  15028. func (m SopTaskMutation) Client() *Client {
  15029. client := &Client{config: m.config}
  15030. client.init()
  15031. return client
  15032. }
  15033. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15034. // it returns an error otherwise.
  15035. func (m SopTaskMutation) Tx() (*Tx, error) {
  15036. if _, ok := m.driver.(*txDriver); !ok {
  15037. return nil, errors.New("ent: mutation is not running in a transaction")
  15038. }
  15039. tx := &Tx{config: m.config}
  15040. tx.init()
  15041. return tx, nil
  15042. }
  15043. // SetID sets the value of the id field. Note that this
  15044. // operation is only accepted on creation of SopTask entities.
  15045. func (m *SopTaskMutation) SetID(id uint64) {
  15046. m.id = &id
  15047. }
  15048. // ID returns the ID value in the mutation. Note that the ID is only available
  15049. // if it was provided to the builder or after it was returned from the database.
  15050. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  15051. if m.id == nil {
  15052. return
  15053. }
  15054. return *m.id, true
  15055. }
  15056. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15057. // That means, if the mutation is applied within a transaction with an isolation level such
  15058. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15059. // or updated by the mutation.
  15060. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  15061. switch {
  15062. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15063. id, exists := m.ID()
  15064. if exists {
  15065. return []uint64{id}, nil
  15066. }
  15067. fallthrough
  15068. case m.op.Is(OpUpdate | OpDelete):
  15069. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  15070. default:
  15071. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15072. }
  15073. }
  15074. // SetCreatedAt sets the "created_at" field.
  15075. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  15076. m.created_at = &t
  15077. }
  15078. // CreatedAt returns the value of the "created_at" field in the mutation.
  15079. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  15080. v := m.created_at
  15081. if v == nil {
  15082. return
  15083. }
  15084. return *v, true
  15085. }
  15086. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  15087. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15089. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15090. if !m.op.Is(OpUpdateOne) {
  15091. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15092. }
  15093. if m.id == nil || m.oldValue == nil {
  15094. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15095. }
  15096. oldValue, err := m.oldValue(ctx)
  15097. if err != nil {
  15098. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15099. }
  15100. return oldValue.CreatedAt, nil
  15101. }
  15102. // ResetCreatedAt resets all changes to the "created_at" field.
  15103. func (m *SopTaskMutation) ResetCreatedAt() {
  15104. m.created_at = nil
  15105. }
  15106. // SetUpdatedAt sets the "updated_at" field.
  15107. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  15108. m.updated_at = &t
  15109. }
  15110. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15111. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  15112. v := m.updated_at
  15113. if v == nil {
  15114. return
  15115. }
  15116. return *v, true
  15117. }
  15118. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  15119. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15121. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15122. if !m.op.Is(OpUpdateOne) {
  15123. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15124. }
  15125. if m.id == nil || m.oldValue == nil {
  15126. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15127. }
  15128. oldValue, err := m.oldValue(ctx)
  15129. if err != nil {
  15130. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15131. }
  15132. return oldValue.UpdatedAt, nil
  15133. }
  15134. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15135. func (m *SopTaskMutation) ResetUpdatedAt() {
  15136. m.updated_at = nil
  15137. }
  15138. // SetStatus sets the "status" field.
  15139. func (m *SopTaskMutation) SetStatus(u uint8) {
  15140. m.status = &u
  15141. m.addstatus = nil
  15142. }
  15143. // Status returns the value of the "status" field in the mutation.
  15144. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  15145. v := m.status
  15146. if v == nil {
  15147. return
  15148. }
  15149. return *v, true
  15150. }
  15151. // OldStatus returns the old "status" field's value of the SopTask entity.
  15152. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15154. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15155. if !m.op.Is(OpUpdateOne) {
  15156. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15157. }
  15158. if m.id == nil || m.oldValue == nil {
  15159. return v, errors.New("OldStatus requires an ID field in the mutation")
  15160. }
  15161. oldValue, err := m.oldValue(ctx)
  15162. if err != nil {
  15163. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15164. }
  15165. return oldValue.Status, nil
  15166. }
  15167. // AddStatus adds u to the "status" field.
  15168. func (m *SopTaskMutation) AddStatus(u int8) {
  15169. if m.addstatus != nil {
  15170. *m.addstatus += u
  15171. } else {
  15172. m.addstatus = &u
  15173. }
  15174. }
  15175. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15176. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  15177. v := m.addstatus
  15178. if v == nil {
  15179. return
  15180. }
  15181. return *v, true
  15182. }
  15183. // ClearStatus clears the value of the "status" field.
  15184. func (m *SopTaskMutation) ClearStatus() {
  15185. m.status = nil
  15186. m.addstatus = nil
  15187. m.clearedFields[soptask.FieldStatus] = struct{}{}
  15188. }
  15189. // StatusCleared returns if the "status" field was cleared in this mutation.
  15190. func (m *SopTaskMutation) StatusCleared() bool {
  15191. _, ok := m.clearedFields[soptask.FieldStatus]
  15192. return ok
  15193. }
  15194. // ResetStatus resets all changes to the "status" field.
  15195. func (m *SopTaskMutation) ResetStatus() {
  15196. m.status = nil
  15197. m.addstatus = nil
  15198. delete(m.clearedFields, soptask.FieldStatus)
  15199. }
  15200. // SetDeletedAt sets the "deleted_at" field.
  15201. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  15202. m.deleted_at = &t
  15203. }
  15204. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15205. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  15206. v := m.deleted_at
  15207. if v == nil {
  15208. return
  15209. }
  15210. return *v, true
  15211. }
  15212. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  15213. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15215. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15216. if !m.op.Is(OpUpdateOne) {
  15217. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15218. }
  15219. if m.id == nil || m.oldValue == nil {
  15220. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15221. }
  15222. oldValue, err := m.oldValue(ctx)
  15223. if err != nil {
  15224. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15225. }
  15226. return oldValue.DeletedAt, nil
  15227. }
  15228. // ClearDeletedAt clears the value of the "deleted_at" field.
  15229. func (m *SopTaskMutation) ClearDeletedAt() {
  15230. m.deleted_at = nil
  15231. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  15232. }
  15233. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15234. func (m *SopTaskMutation) DeletedAtCleared() bool {
  15235. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  15236. return ok
  15237. }
  15238. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15239. func (m *SopTaskMutation) ResetDeletedAt() {
  15240. m.deleted_at = nil
  15241. delete(m.clearedFields, soptask.FieldDeletedAt)
  15242. }
  15243. // SetName sets the "name" field.
  15244. func (m *SopTaskMutation) SetName(s string) {
  15245. m.name = &s
  15246. }
  15247. // Name returns the value of the "name" field in the mutation.
  15248. func (m *SopTaskMutation) Name() (r string, exists bool) {
  15249. v := m.name
  15250. if v == nil {
  15251. return
  15252. }
  15253. return *v, true
  15254. }
  15255. // OldName returns the old "name" field's value of the SopTask entity.
  15256. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15258. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  15259. if !m.op.Is(OpUpdateOne) {
  15260. return v, errors.New("OldName is only allowed on UpdateOne operations")
  15261. }
  15262. if m.id == nil || m.oldValue == nil {
  15263. return v, errors.New("OldName requires an ID field in the mutation")
  15264. }
  15265. oldValue, err := m.oldValue(ctx)
  15266. if err != nil {
  15267. return v, fmt.Errorf("querying old value for OldName: %w", err)
  15268. }
  15269. return oldValue.Name, nil
  15270. }
  15271. // ResetName resets all changes to the "name" field.
  15272. func (m *SopTaskMutation) ResetName() {
  15273. m.name = nil
  15274. }
  15275. // SetBotWxidList sets the "bot_wxid_list" field.
  15276. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  15277. m.bot_wxid_list = &s
  15278. m.appendbot_wxid_list = nil
  15279. }
  15280. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  15281. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  15282. v := m.bot_wxid_list
  15283. if v == nil {
  15284. return
  15285. }
  15286. return *v, true
  15287. }
  15288. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  15289. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15291. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  15292. if !m.op.Is(OpUpdateOne) {
  15293. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  15294. }
  15295. if m.id == nil || m.oldValue == nil {
  15296. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  15297. }
  15298. oldValue, err := m.oldValue(ctx)
  15299. if err != nil {
  15300. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  15301. }
  15302. return oldValue.BotWxidList, nil
  15303. }
  15304. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  15305. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  15306. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  15307. }
  15308. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  15309. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  15310. if len(m.appendbot_wxid_list) == 0 {
  15311. return nil, false
  15312. }
  15313. return m.appendbot_wxid_list, true
  15314. }
  15315. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  15316. func (m *SopTaskMutation) ClearBotWxidList() {
  15317. m.bot_wxid_list = nil
  15318. m.appendbot_wxid_list = nil
  15319. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  15320. }
  15321. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  15322. func (m *SopTaskMutation) BotWxidListCleared() bool {
  15323. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  15324. return ok
  15325. }
  15326. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  15327. func (m *SopTaskMutation) ResetBotWxidList() {
  15328. m.bot_wxid_list = nil
  15329. m.appendbot_wxid_list = nil
  15330. delete(m.clearedFields, soptask.FieldBotWxidList)
  15331. }
  15332. // SetType sets the "type" field.
  15333. func (m *SopTaskMutation) SetType(i int) {
  15334. m._type = &i
  15335. m.add_type = nil
  15336. }
  15337. // GetType returns the value of the "type" field in the mutation.
  15338. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  15339. v := m._type
  15340. if v == nil {
  15341. return
  15342. }
  15343. return *v, true
  15344. }
  15345. // OldType returns the old "type" field's value of the SopTask entity.
  15346. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15348. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  15349. if !m.op.Is(OpUpdateOne) {
  15350. return v, errors.New("OldType is only allowed on UpdateOne operations")
  15351. }
  15352. if m.id == nil || m.oldValue == nil {
  15353. return v, errors.New("OldType requires an ID field in the mutation")
  15354. }
  15355. oldValue, err := m.oldValue(ctx)
  15356. if err != nil {
  15357. return v, fmt.Errorf("querying old value for OldType: %w", err)
  15358. }
  15359. return oldValue.Type, nil
  15360. }
  15361. // AddType adds i to the "type" field.
  15362. func (m *SopTaskMutation) AddType(i int) {
  15363. if m.add_type != nil {
  15364. *m.add_type += i
  15365. } else {
  15366. m.add_type = &i
  15367. }
  15368. }
  15369. // AddedType returns the value that was added to the "type" field in this mutation.
  15370. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  15371. v := m.add_type
  15372. if v == nil {
  15373. return
  15374. }
  15375. return *v, true
  15376. }
  15377. // ResetType resets all changes to the "type" field.
  15378. func (m *SopTaskMutation) ResetType() {
  15379. m._type = nil
  15380. m.add_type = nil
  15381. }
  15382. // SetPlanStartTime sets the "plan_start_time" field.
  15383. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  15384. m.plan_start_time = &t
  15385. }
  15386. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  15387. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  15388. v := m.plan_start_time
  15389. if v == nil {
  15390. return
  15391. }
  15392. return *v, true
  15393. }
  15394. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  15395. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15397. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  15398. if !m.op.Is(OpUpdateOne) {
  15399. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  15400. }
  15401. if m.id == nil || m.oldValue == nil {
  15402. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  15403. }
  15404. oldValue, err := m.oldValue(ctx)
  15405. if err != nil {
  15406. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  15407. }
  15408. return oldValue.PlanStartTime, nil
  15409. }
  15410. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  15411. func (m *SopTaskMutation) ClearPlanStartTime() {
  15412. m.plan_start_time = nil
  15413. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  15414. }
  15415. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  15416. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  15417. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  15418. return ok
  15419. }
  15420. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  15421. func (m *SopTaskMutation) ResetPlanStartTime() {
  15422. m.plan_start_time = nil
  15423. delete(m.clearedFields, soptask.FieldPlanStartTime)
  15424. }
  15425. // SetPlanEndTime sets the "plan_end_time" field.
  15426. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  15427. m.plan_end_time = &t
  15428. }
  15429. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  15430. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  15431. v := m.plan_end_time
  15432. if v == nil {
  15433. return
  15434. }
  15435. return *v, true
  15436. }
  15437. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  15438. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15440. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  15441. if !m.op.Is(OpUpdateOne) {
  15442. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  15443. }
  15444. if m.id == nil || m.oldValue == nil {
  15445. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  15446. }
  15447. oldValue, err := m.oldValue(ctx)
  15448. if err != nil {
  15449. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  15450. }
  15451. return oldValue.PlanEndTime, nil
  15452. }
  15453. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  15454. func (m *SopTaskMutation) ClearPlanEndTime() {
  15455. m.plan_end_time = nil
  15456. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  15457. }
  15458. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  15459. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  15460. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  15461. return ok
  15462. }
  15463. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  15464. func (m *SopTaskMutation) ResetPlanEndTime() {
  15465. m.plan_end_time = nil
  15466. delete(m.clearedFields, soptask.FieldPlanEndTime)
  15467. }
  15468. // SetCreatorID sets the "creator_id" field.
  15469. func (m *SopTaskMutation) SetCreatorID(s string) {
  15470. m.creator_id = &s
  15471. }
  15472. // CreatorID returns the value of the "creator_id" field in the mutation.
  15473. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  15474. v := m.creator_id
  15475. if v == nil {
  15476. return
  15477. }
  15478. return *v, true
  15479. }
  15480. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  15481. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15482. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15483. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  15484. if !m.op.Is(OpUpdateOne) {
  15485. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  15486. }
  15487. if m.id == nil || m.oldValue == nil {
  15488. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  15489. }
  15490. oldValue, err := m.oldValue(ctx)
  15491. if err != nil {
  15492. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  15493. }
  15494. return oldValue.CreatorID, nil
  15495. }
  15496. // ClearCreatorID clears the value of the "creator_id" field.
  15497. func (m *SopTaskMutation) ClearCreatorID() {
  15498. m.creator_id = nil
  15499. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  15500. }
  15501. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  15502. func (m *SopTaskMutation) CreatorIDCleared() bool {
  15503. _, ok := m.clearedFields[soptask.FieldCreatorID]
  15504. return ok
  15505. }
  15506. // ResetCreatorID resets all changes to the "creator_id" field.
  15507. func (m *SopTaskMutation) ResetCreatorID() {
  15508. m.creator_id = nil
  15509. delete(m.clearedFields, soptask.FieldCreatorID)
  15510. }
  15511. // SetOrganizationID sets the "organization_id" field.
  15512. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  15513. m.organization_id = &u
  15514. m.addorganization_id = nil
  15515. }
  15516. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15517. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  15518. v := m.organization_id
  15519. if v == nil {
  15520. return
  15521. }
  15522. return *v, true
  15523. }
  15524. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  15525. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15527. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15528. if !m.op.Is(OpUpdateOne) {
  15529. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15530. }
  15531. if m.id == nil || m.oldValue == nil {
  15532. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15533. }
  15534. oldValue, err := m.oldValue(ctx)
  15535. if err != nil {
  15536. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15537. }
  15538. return oldValue.OrganizationID, nil
  15539. }
  15540. // AddOrganizationID adds u to the "organization_id" field.
  15541. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  15542. if m.addorganization_id != nil {
  15543. *m.addorganization_id += u
  15544. } else {
  15545. m.addorganization_id = &u
  15546. }
  15547. }
  15548. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15549. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  15550. v := m.addorganization_id
  15551. if v == nil {
  15552. return
  15553. }
  15554. return *v, true
  15555. }
  15556. // ClearOrganizationID clears the value of the "organization_id" field.
  15557. func (m *SopTaskMutation) ClearOrganizationID() {
  15558. m.organization_id = nil
  15559. m.addorganization_id = nil
  15560. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  15561. }
  15562. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15563. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  15564. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  15565. return ok
  15566. }
  15567. // ResetOrganizationID resets all changes to the "organization_id" field.
  15568. func (m *SopTaskMutation) ResetOrganizationID() {
  15569. m.organization_id = nil
  15570. m.addorganization_id = nil
  15571. delete(m.clearedFields, soptask.FieldOrganizationID)
  15572. }
  15573. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  15574. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  15575. if m.task_stages == nil {
  15576. m.task_stages = make(map[uint64]struct{})
  15577. }
  15578. for i := range ids {
  15579. m.task_stages[ids[i]] = struct{}{}
  15580. }
  15581. }
  15582. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  15583. func (m *SopTaskMutation) ClearTaskStages() {
  15584. m.clearedtask_stages = true
  15585. }
  15586. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  15587. func (m *SopTaskMutation) TaskStagesCleared() bool {
  15588. return m.clearedtask_stages
  15589. }
  15590. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  15591. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  15592. if m.removedtask_stages == nil {
  15593. m.removedtask_stages = make(map[uint64]struct{})
  15594. }
  15595. for i := range ids {
  15596. delete(m.task_stages, ids[i])
  15597. m.removedtask_stages[ids[i]] = struct{}{}
  15598. }
  15599. }
  15600. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  15601. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  15602. for id := range m.removedtask_stages {
  15603. ids = append(ids, id)
  15604. }
  15605. return
  15606. }
  15607. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  15608. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  15609. for id := range m.task_stages {
  15610. ids = append(ids, id)
  15611. }
  15612. return
  15613. }
  15614. // ResetTaskStages resets all changes to the "task_stages" edge.
  15615. func (m *SopTaskMutation) ResetTaskStages() {
  15616. m.task_stages = nil
  15617. m.clearedtask_stages = false
  15618. m.removedtask_stages = nil
  15619. }
  15620. // Where appends a list predicates to the SopTaskMutation builder.
  15621. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  15622. m.predicates = append(m.predicates, ps...)
  15623. }
  15624. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  15625. // users can use type-assertion to append predicates that do not depend on any generated package.
  15626. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  15627. p := make([]predicate.SopTask, len(ps))
  15628. for i := range ps {
  15629. p[i] = ps[i]
  15630. }
  15631. m.Where(p...)
  15632. }
  15633. // Op returns the operation name.
  15634. func (m *SopTaskMutation) Op() Op {
  15635. return m.op
  15636. }
  15637. // SetOp allows setting the mutation operation.
  15638. func (m *SopTaskMutation) SetOp(op Op) {
  15639. m.op = op
  15640. }
  15641. // Type returns the node type of this mutation (SopTask).
  15642. func (m *SopTaskMutation) Type() string {
  15643. return m.typ
  15644. }
  15645. // Fields returns all fields that were changed during this mutation. Note that in
  15646. // order to get all numeric fields that were incremented/decremented, call
  15647. // AddedFields().
  15648. func (m *SopTaskMutation) Fields() []string {
  15649. fields := make([]string, 0, 11)
  15650. if m.created_at != nil {
  15651. fields = append(fields, soptask.FieldCreatedAt)
  15652. }
  15653. if m.updated_at != nil {
  15654. fields = append(fields, soptask.FieldUpdatedAt)
  15655. }
  15656. if m.status != nil {
  15657. fields = append(fields, soptask.FieldStatus)
  15658. }
  15659. if m.deleted_at != nil {
  15660. fields = append(fields, soptask.FieldDeletedAt)
  15661. }
  15662. if m.name != nil {
  15663. fields = append(fields, soptask.FieldName)
  15664. }
  15665. if m.bot_wxid_list != nil {
  15666. fields = append(fields, soptask.FieldBotWxidList)
  15667. }
  15668. if m._type != nil {
  15669. fields = append(fields, soptask.FieldType)
  15670. }
  15671. if m.plan_start_time != nil {
  15672. fields = append(fields, soptask.FieldPlanStartTime)
  15673. }
  15674. if m.plan_end_time != nil {
  15675. fields = append(fields, soptask.FieldPlanEndTime)
  15676. }
  15677. if m.creator_id != nil {
  15678. fields = append(fields, soptask.FieldCreatorID)
  15679. }
  15680. if m.organization_id != nil {
  15681. fields = append(fields, soptask.FieldOrganizationID)
  15682. }
  15683. return fields
  15684. }
  15685. // Field returns the value of a field with the given name. The second boolean
  15686. // return value indicates that this field was not set, or was not defined in the
  15687. // schema.
  15688. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  15689. switch name {
  15690. case soptask.FieldCreatedAt:
  15691. return m.CreatedAt()
  15692. case soptask.FieldUpdatedAt:
  15693. return m.UpdatedAt()
  15694. case soptask.FieldStatus:
  15695. return m.Status()
  15696. case soptask.FieldDeletedAt:
  15697. return m.DeletedAt()
  15698. case soptask.FieldName:
  15699. return m.Name()
  15700. case soptask.FieldBotWxidList:
  15701. return m.BotWxidList()
  15702. case soptask.FieldType:
  15703. return m.GetType()
  15704. case soptask.FieldPlanStartTime:
  15705. return m.PlanStartTime()
  15706. case soptask.FieldPlanEndTime:
  15707. return m.PlanEndTime()
  15708. case soptask.FieldCreatorID:
  15709. return m.CreatorID()
  15710. case soptask.FieldOrganizationID:
  15711. return m.OrganizationID()
  15712. }
  15713. return nil, false
  15714. }
  15715. // OldField returns the old value of the field from the database. An error is
  15716. // returned if the mutation operation is not UpdateOne, or the query to the
  15717. // database failed.
  15718. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15719. switch name {
  15720. case soptask.FieldCreatedAt:
  15721. return m.OldCreatedAt(ctx)
  15722. case soptask.FieldUpdatedAt:
  15723. return m.OldUpdatedAt(ctx)
  15724. case soptask.FieldStatus:
  15725. return m.OldStatus(ctx)
  15726. case soptask.FieldDeletedAt:
  15727. return m.OldDeletedAt(ctx)
  15728. case soptask.FieldName:
  15729. return m.OldName(ctx)
  15730. case soptask.FieldBotWxidList:
  15731. return m.OldBotWxidList(ctx)
  15732. case soptask.FieldType:
  15733. return m.OldType(ctx)
  15734. case soptask.FieldPlanStartTime:
  15735. return m.OldPlanStartTime(ctx)
  15736. case soptask.FieldPlanEndTime:
  15737. return m.OldPlanEndTime(ctx)
  15738. case soptask.FieldCreatorID:
  15739. return m.OldCreatorID(ctx)
  15740. case soptask.FieldOrganizationID:
  15741. return m.OldOrganizationID(ctx)
  15742. }
  15743. return nil, fmt.Errorf("unknown SopTask field %s", name)
  15744. }
  15745. // SetField sets the value of a field with the given name. It returns an error if
  15746. // the field is not defined in the schema, or if the type mismatched the field
  15747. // type.
  15748. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  15749. switch name {
  15750. case soptask.FieldCreatedAt:
  15751. v, ok := value.(time.Time)
  15752. if !ok {
  15753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15754. }
  15755. m.SetCreatedAt(v)
  15756. return nil
  15757. case soptask.FieldUpdatedAt:
  15758. v, ok := value.(time.Time)
  15759. if !ok {
  15760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15761. }
  15762. m.SetUpdatedAt(v)
  15763. return nil
  15764. case soptask.FieldStatus:
  15765. v, ok := value.(uint8)
  15766. if !ok {
  15767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15768. }
  15769. m.SetStatus(v)
  15770. return nil
  15771. case soptask.FieldDeletedAt:
  15772. v, ok := value.(time.Time)
  15773. if !ok {
  15774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15775. }
  15776. m.SetDeletedAt(v)
  15777. return nil
  15778. case soptask.FieldName:
  15779. v, ok := value.(string)
  15780. if !ok {
  15781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15782. }
  15783. m.SetName(v)
  15784. return nil
  15785. case soptask.FieldBotWxidList:
  15786. v, ok := value.([]string)
  15787. if !ok {
  15788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15789. }
  15790. m.SetBotWxidList(v)
  15791. return nil
  15792. case soptask.FieldType:
  15793. v, ok := value.(int)
  15794. if !ok {
  15795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15796. }
  15797. m.SetType(v)
  15798. return nil
  15799. case soptask.FieldPlanStartTime:
  15800. v, ok := value.(time.Time)
  15801. if !ok {
  15802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15803. }
  15804. m.SetPlanStartTime(v)
  15805. return nil
  15806. case soptask.FieldPlanEndTime:
  15807. v, ok := value.(time.Time)
  15808. if !ok {
  15809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15810. }
  15811. m.SetPlanEndTime(v)
  15812. return nil
  15813. case soptask.FieldCreatorID:
  15814. v, ok := value.(string)
  15815. if !ok {
  15816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15817. }
  15818. m.SetCreatorID(v)
  15819. return nil
  15820. case soptask.FieldOrganizationID:
  15821. v, ok := value.(uint64)
  15822. if !ok {
  15823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15824. }
  15825. m.SetOrganizationID(v)
  15826. return nil
  15827. }
  15828. return fmt.Errorf("unknown SopTask field %s", name)
  15829. }
  15830. // AddedFields returns all numeric fields that were incremented/decremented during
  15831. // this mutation.
  15832. func (m *SopTaskMutation) AddedFields() []string {
  15833. var fields []string
  15834. if m.addstatus != nil {
  15835. fields = append(fields, soptask.FieldStatus)
  15836. }
  15837. if m.add_type != nil {
  15838. fields = append(fields, soptask.FieldType)
  15839. }
  15840. if m.addorganization_id != nil {
  15841. fields = append(fields, soptask.FieldOrganizationID)
  15842. }
  15843. return fields
  15844. }
  15845. // AddedField returns the numeric value that was incremented/decremented on a field
  15846. // with the given name. The second boolean return value indicates that this field
  15847. // was not set, or was not defined in the schema.
  15848. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  15849. switch name {
  15850. case soptask.FieldStatus:
  15851. return m.AddedStatus()
  15852. case soptask.FieldType:
  15853. return m.AddedType()
  15854. case soptask.FieldOrganizationID:
  15855. return m.AddedOrganizationID()
  15856. }
  15857. return nil, false
  15858. }
  15859. // AddField adds the value to the field with the given name. It returns an error if
  15860. // the field is not defined in the schema, or if the type mismatched the field
  15861. // type.
  15862. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  15863. switch name {
  15864. case soptask.FieldStatus:
  15865. v, ok := value.(int8)
  15866. if !ok {
  15867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15868. }
  15869. m.AddStatus(v)
  15870. return nil
  15871. case soptask.FieldType:
  15872. v, ok := value.(int)
  15873. if !ok {
  15874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15875. }
  15876. m.AddType(v)
  15877. return nil
  15878. case soptask.FieldOrganizationID:
  15879. v, ok := value.(int64)
  15880. if !ok {
  15881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15882. }
  15883. m.AddOrganizationID(v)
  15884. return nil
  15885. }
  15886. return fmt.Errorf("unknown SopTask numeric field %s", name)
  15887. }
  15888. // ClearedFields returns all nullable fields that were cleared during this
  15889. // mutation.
  15890. func (m *SopTaskMutation) ClearedFields() []string {
  15891. var fields []string
  15892. if m.FieldCleared(soptask.FieldStatus) {
  15893. fields = append(fields, soptask.FieldStatus)
  15894. }
  15895. if m.FieldCleared(soptask.FieldDeletedAt) {
  15896. fields = append(fields, soptask.FieldDeletedAt)
  15897. }
  15898. if m.FieldCleared(soptask.FieldBotWxidList) {
  15899. fields = append(fields, soptask.FieldBotWxidList)
  15900. }
  15901. if m.FieldCleared(soptask.FieldPlanStartTime) {
  15902. fields = append(fields, soptask.FieldPlanStartTime)
  15903. }
  15904. if m.FieldCleared(soptask.FieldPlanEndTime) {
  15905. fields = append(fields, soptask.FieldPlanEndTime)
  15906. }
  15907. if m.FieldCleared(soptask.FieldCreatorID) {
  15908. fields = append(fields, soptask.FieldCreatorID)
  15909. }
  15910. if m.FieldCleared(soptask.FieldOrganizationID) {
  15911. fields = append(fields, soptask.FieldOrganizationID)
  15912. }
  15913. return fields
  15914. }
  15915. // FieldCleared returns a boolean indicating if a field with the given name was
  15916. // cleared in this mutation.
  15917. func (m *SopTaskMutation) FieldCleared(name string) bool {
  15918. _, ok := m.clearedFields[name]
  15919. return ok
  15920. }
  15921. // ClearField clears the value of the field with the given name. It returns an
  15922. // error if the field is not defined in the schema.
  15923. func (m *SopTaskMutation) ClearField(name string) error {
  15924. switch name {
  15925. case soptask.FieldStatus:
  15926. m.ClearStatus()
  15927. return nil
  15928. case soptask.FieldDeletedAt:
  15929. m.ClearDeletedAt()
  15930. return nil
  15931. case soptask.FieldBotWxidList:
  15932. m.ClearBotWxidList()
  15933. return nil
  15934. case soptask.FieldPlanStartTime:
  15935. m.ClearPlanStartTime()
  15936. return nil
  15937. case soptask.FieldPlanEndTime:
  15938. m.ClearPlanEndTime()
  15939. return nil
  15940. case soptask.FieldCreatorID:
  15941. m.ClearCreatorID()
  15942. return nil
  15943. case soptask.FieldOrganizationID:
  15944. m.ClearOrganizationID()
  15945. return nil
  15946. }
  15947. return fmt.Errorf("unknown SopTask nullable field %s", name)
  15948. }
  15949. // ResetField resets all changes in the mutation for the field with the given name.
  15950. // It returns an error if the field is not defined in the schema.
  15951. func (m *SopTaskMutation) ResetField(name string) error {
  15952. switch name {
  15953. case soptask.FieldCreatedAt:
  15954. m.ResetCreatedAt()
  15955. return nil
  15956. case soptask.FieldUpdatedAt:
  15957. m.ResetUpdatedAt()
  15958. return nil
  15959. case soptask.FieldStatus:
  15960. m.ResetStatus()
  15961. return nil
  15962. case soptask.FieldDeletedAt:
  15963. m.ResetDeletedAt()
  15964. return nil
  15965. case soptask.FieldName:
  15966. m.ResetName()
  15967. return nil
  15968. case soptask.FieldBotWxidList:
  15969. m.ResetBotWxidList()
  15970. return nil
  15971. case soptask.FieldType:
  15972. m.ResetType()
  15973. return nil
  15974. case soptask.FieldPlanStartTime:
  15975. m.ResetPlanStartTime()
  15976. return nil
  15977. case soptask.FieldPlanEndTime:
  15978. m.ResetPlanEndTime()
  15979. return nil
  15980. case soptask.FieldCreatorID:
  15981. m.ResetCreatorID()
  15982. return nil
  15983. case soptask.FieldOrganizationID:
  15984. m.ResetOrganizationID()
  15985. return nil
  15986. }
  15987. return fmt.Errorf("unknown SopTask field %s", name)
  15988. }
  15989. // AddedEdges returns all edge names that were set/added in this mutation.
  15990. func (m *SopTaskMutation) AddedEdges() []string {
  15991. edges := make([]string, 0, 1)
  15992. if m.task_stages != nil {
  15993. edges = append(edges, soptask.EdgeTaskStages)
  15994. }
  15995. return edges
  15996. }
  15997. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15998. // name in this mutation.
  15999. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  16000. switch name {
  16001. case soptask.EdgeTaskStages:
  16002. ids := make([]ent.Value, 0, len(m.task_stages))
  16003. for id := range m.task_stages {
  16004. ids = append(ids, id)
  16005. }
  16006. return ids
  16007. }
  16008. return nil
  16009. }
  16010. // RemovedEdges returns all edge names that were removed in this mutation.
  16011. func (m *SopTaskMutation) RemovedEdges() []string {
  16012. edges := make([]string, 0, 1)
  16013. if m.removedtask_stages != nil {
  16014. edges = append(edges, soptask.EdgeTaskStages)
  16015. }
  16016. return edges
  16017. }
  16018. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16019. // the given name in this mutation.
  16020. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  16021. switch name {
  16022. case soptask.EdgeTaskStages:
  16023. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  16024. for id := range m.removedtask_stages {
  16025. ids = append(ids, id)
  16026. }
  16027. return ids
  16028. }
  16029. return nil
  16030. }
  16031. // ClearedEdges returns all edge names that were cleared in this mutation.
  16032. func (m *SopTaskMutation) ClearedEdges() []string {
  16033. edges := make([]string, 0, 1)
  16034. if m.clearedtask_stages {
  16035. edges = append(edges, soptask.EdgeTaskStages)
  16036. }
  16037. return edges
  16038. }
  16039. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16040. // was cleared in this mutation.
  16041. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  16042. switch name {
  16043. case soptask.EdgeTaskStages:
  16044. return m.clearedtask_stages
  16045. }
  16046. return false
  16047. }
  16048. // ClearEdge clears the value of the edge with the given name. It returns an error
  16049. // if that edge is not defined in the schema.
  16050. func (m *SopTaskMutation) ClearEdge(name string) error {
  16051. switch name {
  16052. }
  16053. return fmt.Errorf("unknown SopTask unique edge %s", name)
  16054. }
  16055. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16056. // It returns an error if the edge is not defined in the schema.
  16057. func (m *SopTaskMutation) ResetEdge(name string) error {
  16058. switch name {
  16059. case soptask.EdgeTaskStages:
  16060. m.ResetTaskStages()
  16061. return nil
  16062. }
  16063. return fmt.Errorf("unknown SopTask edge %s", name)
  16064. }
  16065. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  16066. type TokenMutation struct {
  16067. config
  16068. op Op
  16069. typ string
  16070. id *uint64
  16071. created_at *time.Time
  16072. updated_at *time.Time
  16073. deleted_at *time.Time
  16074. expire_at *time.Time
  16075. token *string
  16076. mac *string
  16077. clearedFields map[string]struct{}
  16078. done bool
  16079. oldValue func(context.Context) (*Token, error)
  16080. predicates []predicate.Token
  16081. }
  16082. var _ ent.Mutation = (*TokenMutation)(nil)
  16083. // tokenOption allows management of the mutation configuration using functional options.
  16084. type tokenOption func(*TokenMutation)
  16085. // newTokenMutation creates new mutation for the Token entity.
  16086. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  16087. m := &TokenMutation{
  16088. config: c,
  16089. op: op,
  16090. typ: TypeToken,
  16091. clearedFields: make(map[string]struct{}),
  16092. }
  16093. for _, opt := range opts {
  16094. opt(m)
  16095. }
  16096. return m
  16097. }
  16098. // withTokenID sets the ID field of the mutation.
  16099. func withTokenID(id uint64) tokenOption {
  16100. return func(m *TokenMutation) {
  16101. var (
  16102. err error
  16103. once sync.Once
  16104. value *Token
  16105. )
  16106. m.oldValue = func(ctx context.Context) (*Token, error) {
  16107. once.Do(func() {
  16108. if m.done {
  16109. err = errors.New("querying old values post mutation is not allowed")
  16110. } else {
  16111. value, err = m.Client().Token.Get(ctx, id)
  16112. }
  16113. })
  16114. return value, err
  16115. }
  16116. m.id = &id
  16117. }
  16118. }
  16119. // withToken sets the old Token of the mutation.
  16120. func withToken(node *Token) tokenOption {
  16121. return func(m *TokenMutation) {
  16122. m.oldValue = func(context.Context) (*Token, error) {
  16123. return node, nil
  16124. }
  16125. m.id = &node.ID
  16126. }
  16127. }
  16128. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16129. // executed in a transaction (ent.Tx), a transactional client is returned.
  16130. func (m TokenMutation) Client() *Client {
  16131. client := &Client{config: m.config}
  16132. client.init()
  16133. return client
  16134. }
  16135. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16136. // it returns an error otherwise.
  16137. func (m TokenMutation) Tx() (*Tx, error) {
  16138. if _, ok := m.driver.(*txDriver); !ok {
  16139. return nil, errors.New("ent: mutation is not running in a transaction")
  16140. }
  16141. tx := &Tx{config: m.config}
  16142. tx.init()
  16143. return tx, nil
  16144. }
  16145. // SetID sets the value of the id field. Note that this
  16146. // operation is only accepted on creation of Token entities.
  16147. func (m *TokenMutation) SetID(id uint64) {
  16148. m.id = &id
  16149. }
  16150. // ID returns the ID value in the mutation. Note that the ID is only available
  16151. // if it was provided to the builder or after it was returned from the database.
  16152. func (m *TokenMutation) ID() (id uint64, exists bool) {
  16153. if m.id == nil {
  16154. return
  16155. }
  16156. return *m.id, true
  16157. }
  16158. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16159. // That means, if the mutation is applied within a transaction with an isolation level such
  16160. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16161. // or updated by the mutation.
  16162. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  16163. switch {
  16164. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16165. id, exists := m.ID()
  16166. if exists {
  16167. return []uint64{id}, nil
  16168. }
  16169. fallthrough
  16170. case m.op.Is(OpUpdate | OpDelete):
  16171. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  16172. default:
  16173. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16174. }
  16175. }
  16176. // SetCreatedAt sets the "created_at" field.
  16177. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  16178. m.created_at = &t
  16179. }
  16180. // CreatedAt returns the value of the "created_at" field in the mutation.
  16181. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  16182. v := m.created_at
  16183. if v == nil {
  16184. return
  16185. }
  16186. return *v, true
  16187. }
  16188. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  16189. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16191. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16192. if !m.op.Is(OpUpdateOne) {
  16193. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16194. }
  16195. if m.id == nil || m.oldValue == nil {
  16196. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16197. }
  16198. oldValue, err := m.oldValue(ctx)
  16199. if err != nil {
  16200. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16201. }
  16202. return oldValue.CreatedAt, nil
  16203. }
  16204. // ResetCreatedAt resets all changes to the "created_at" field.
  16205. func (m *TokenMutation) ResetCreatedAt() {
  16206. m.created_at = nil
  16207. }
  16208. // SetUpdatedAt sets the "updated_at" field.
  16209. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  16210. m.updated_at = &t
  16211. }
  16212. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16213. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  16214. v := m.updated_at
  16215. if v == nil {
  16216. return
  16217. }
  16218. return *v, true
  16219. }
  16220. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  16221. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16223. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16224. if !m.op.Is(OpUpdateOne) {
  16225. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16226. }
  16227. if m.id == nil || m.oldValue == nil {
  16228. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16229. }
  16230. oldValue, err := m.oldValue(ctx)
  16231. if err != nil {
  16232. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16233. }
  16234. return oldValue.UpdatedAt, nil
  16235. }
  16236. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16237. func (m *TokenMutation) ResetUpdatedAt() {
  16238. m.updated_at = nil
  16239. }
  16240. // SetDeletedAt sets the "deleted_at" field.
  16241. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  16242. m.deleted_at = &t
  16243. }
  16244. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16245. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  16246. v := m.deleted_at
  16247. if v == nil {
  16248. return
  16249. }
  16250. return *v, true
  16251. }
  16252. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  16253. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16255. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16256. if !m.op.Is(OpUpdateOne) {
  16257. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16258. }
  16259. if m.id == nil || m.oldValue == nil {
  16260. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16261. }
  16262. oldValue, err := m.oldValue(ctx)
  16263. if err != nil {
  16264. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16265. }
  16266. return oldValue.DeletedAt, nil
  16267. }
  16268. // ClearDeletedAt clears the value of the "deleted_at" field.
  16269. func (m *TokenMutation) ClearDeletedAt() {
  16270. m.deleted_at = nil
  16271. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  16272. }
  16273. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16274. func (m *TokenMutation) DeletedAtCleared() bool {
  16275. _, ok := m.clearedFields[token.FieldDeletedAt]
  16276. return ok
  16277. }
  16278. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16279. func (m *TokenMutation) ResetDeletedAt() {
  16280. m.deleted_at = nil
  16281. delete(m.clearedFields, token.FieldDeletedAt)
  16282. }
  16283. // SetExpireAt sets the "expire_at" field.
  16284. func (m *TokenMutation) SetExpireAt(t time.Time) {
  16285. m.expire_at = &t
  16286. }
  16287. // ExpireAt returns the value of the "expire_at" field in the mutation.
  16288. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  16289. v := m.expire_at
  16290. if v == nil {
  16291. return
  16292. }
  16293. return *v, true
  16294. }
  16295. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  16296. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16298. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  16299. if !m.op.Is(OpUpdateOne) {
  16300. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  16301. }
  16302. if m.id == nil || m.oldValue == nil {
  16303. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  16304. }
  16305. oldValue, err := m.oldValue(ctx)
  16306. if err != nil {
  16307. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  16308. }
  16309. return oldValue.ExpireAt, nil
  16310. }
  16311. // ClearExpireAt clears the value of the "expire_at" field.
  16312. func (m *TokenMutation) ClearExpireAt() {
  16313. m.expire_at = nil
  16314. m.clearedFields[token.FieldExpireAt] = struct{}{}
  16315. }
  16316. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  16317. func (m *TokenMutation) ExpireAtCleared() bool {
  16318. _, ok := m.clearedFields[token.FieldExpireAt]
  16319. return ok
  16320. }
  16321. // ResetExpireAt resets all changes to the "expire_at" field.
  16322. func (m *TokenMutation) ResetExpireAt() {
  16323. m.expire_at = nil
  16324. delete(m.clearedFields, token.FieldExpireAt)
  16325. }
  16326. // SetToken sets the "token" field.
  16327. func (m *TokenMutation) SetToken(s string) {
  16328. m.token = &s
  16329. }
  16330. // Token returns the value of the "token" field in the mutation.
  16331. func (m *TokenMutation) Token() (r string, exists bool) {
  16332. v := m.token
  16333. if v == nil {
  16334. return
  16335. }
  16336. return *v, true
  16337. }
  16338. // OldToken returns the old "token" field's value of the Token entity.
  16339. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16340. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16341. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  16342. if !m.op.Is(OpUpdateOne) {
  16343. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  16344. }
  16345. if m.id == nil || m.oldValue == nil {
  16346. return v, errors.New("OldToken requires an ID field in the mutation")
  16347. }
  16348. oldValue, err := m.oldValue(ctx)
  16349. if err != nil {
  16350. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  16351. }
  16352. return oldValue.Token, nil
  16353. }
  16354. // ClearToken clears the value of the "token" field.
  16355. func (m *TokenMutation) ClearToken() {
  16356. m.token = nil
  16357. m.clearedFields[token.FieldToken] = struct{}{}
  16358. }
  16359. // TokenCleared returns if the "token" field was cleared in this mutation.
  16360. func (m *TokenMutation) TokenCleared() bool {
  16361. _, ok := m.clearedFields[token.FieldToken]
  16362. return ok
  16363. }
  16364. // ResetToken resets all changes to the "token" field.
  16365. func (m *TokenMutation) ResetToken() {
  16366. m.token = nil
  16367. delete(m.clearedFields, token.FieldToken)
  16368. }
  16369. // SetMAC sets the "mac" field.
  16370. func (m *TokenMutation) SetMAC(s string) {
  16371. m.mac = &s
  16372. }
  16373. // MAC returns the value of the "mac" field in the mutation.
  16374. func (m *TokenMutation) MAC() (r string, exists bool) {
  16375. v := m.mac
  16376. if v == nil {
  16377. return
  16378. }
  16379. return *v, true
  16380. }
  16381. // OldMAC returns the old "mac" field's value of the Token entity.
  16382. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16384. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  16385. if !m.op.Is(OpUpdateOne) {
  16386. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  16387. }
  16388. if m.id == nil || m.oldValue == nil {
  16389. return v, errors.New("OldMAC requires an ID field in the mutation")
  16390. }
  16391. oldValue, err := m.oldValue(ctx)
  16392. if err != nil {
  16393. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  16394. }
  16395. return oldValue.MAC, nil
  16396. }
  16397. // ResetMAC resets all changes to the "mac" field.
  16398. func (m *TokenMutation) ResetMAC() {
  16399. m.mac = nil
  16400. }
  16401. // Where appends a list predicates to the TokenMutation builder.
  16402. func (m *TokenMutation) Where(ps ...predicate.Token) {
  16403. m.predicates = append(m.predicates, ps...)
  16404. }
  16405. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  16406. // users can use type-assertion to append predicates that do not depend on any generated package.
  16407. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  16408. p := make([]predicate.Token, len(ps))
  16409. for i := range ps {
  16410. p[i] = ps[i]
  16411. }
  16412. m.Where(p...)
  16413. }
  16414. // Op returns the operation name.
  16415. func (m *TokenMutation) Op() Op {
  16416. return m.op
  16417. }
  16418. // SetOp allows setting the mutation operation.
  16419. func (m *TokenMutation) SetOp(op Op) {
  16420. m.op = op
  16421. }
  16422. // Type returns the node type of this mutation (Token).
  16423. func (m *TokenMutation) Type() string {
  16424. return m.typ
  16425. }
  16426. // Fields returns all fields that were changed during this mutation. Note that in
  16427. // order to get all numeric fields that were incremented/decremented, call
  16428. // AddedFields().
  16429. func (m *TokenMutation) Fields() []string {
  16430. fields := make([]string, 0, 6)
  16431. if m.created_at != nil {
  16432. fields = append(fields, token.FieldCreatedAt)
  16433. }
  16434. if m.updated_at != nil {
  16435. fields = append(fields, token.FieldUpdatedAt)
  16436. }
  16437. if m.deleted_at != nil {
  16438. fields = append(fields, token.FieldDeletedAt)
  16439. }
  16440. if m.expire_at != nil {
  16441. fields = append(fields, token.FieldExpireAt)
  16442. }
  16443. if m.token != nil {
  16444. fields = append(fields, token.FieldToken)
  16445. }
  16446. if m.mac != nil {
  16447. fields = append(fields, token.FieldMAC)
  16448. }
  16449. return fields
  16450. }
  16451. // Field returns the value of a field with the given name. The second boolean
  16452. // return value indicates that this field was not set, or was not defined in the
  16453. // schema.
  16454. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  16455. switch name {
  16456. case token.FieldCreatedAt:
  16457. return m.CreatedAt()
  16458. case token.FieldUpdatedAt:
  16459. return m.UpdatedAt()
  16460. case token.FieldDeletedAt:
  16461. return m.DeletedAt()
  16462. case token.FieldExpireAt:
  16463. return m.ExpireAt()
  16464. case token.FieldToken:
  16465. return m.Token()
  16466. case token.FieldMAC:
  16467. return m.MAC()
  16468. }
  16469. return nil, false
  16470. }
  16471. // OldField returns the old value of the field from the database. An error is
  16472. // returned if the mutation operation is not UpdateOne, or the query to the
  16473. // database failed.
  16474. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16475. switch name {
  16476. case token.FieldCreatedAt:
  16477. return m.OldCreatedAt(ctx)
  16478. case token.FieldUpdatedAt:
  16479. return m.OldUpdatedAt(ctx)
  16480. case token.FieldDeletedAt:
  16481. return m.OldDeletedAt(ctx)
  16482. case token.FieldExpireAt:
  16483. return m.OldExpireAt(ctx)
  16484. case token.FieldToken:
  16485. return m.OldToken(ctx)
  16486. case token.FieldMAC:
  16487. return m.OldMAC(ctx)
  16488. }
  16489. return nil, fmt.Errorf("unknown Token field %s", name)
  16490. }
  16491. // SetField sets the value of a field with the given name. It returns an error if
  16492. // the field is not defined in the schema, or if the type mismatched the field
  16493. // type.
  16494. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  16495. switch name {
  16496. case token.FieldCreatedAt:
  16497. v, ok := value.(time.Time)
  16498. if !ok {
  16499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16500. }
  16501. m.SetCreatedAt(v)
  16502. return nil
  16503. case token.FieldUpdatedAt:
  16504. v, ok := value.(time.Time)
  16505. if !ok {
  16506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16507. }
  16508. m.SetUpdatedAt(v)
  16509. return nil
  16510. case token.FieldDeletedAt:
  16511. v, ok := value.(time.Time)
  16512. if !ok {
  16513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16514. }
  16515. m.SetDeletedAt(v)
  16516. return nil
  16517. case token.FieldExpireAt:
  16518. v, ok := value.(time.Time)
  16519. if !ok {
  16520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16521. }
  16522. m.SetExpireAt(v)
  16523. return nil
  16524. case token.FieldToken:
  16525. v, ok := value.(string)
  16526. if !ok {
  16527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16528. }
  16529. m.SetToken(v)
  16530. return nil
  16531. case token.FieldMAC:
  16532. v, ok := value.(string)
  16533. if !ok {
  16534. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16535. }
  16536. m.SetMAC(v)
  16537. return nil
  16538. }
  16539. return fmt.Errorf("unknown Token field %s", name)
  16540. }
  16541. // AddedFields returns all numeric fields that were incremented/decremented during
  16542. // this mutation.
  16543. func (m *TokenMutation) AddedFields() []string {
  16544. return nil
  16545. }
  16546. // AddedField returns the numeric value that was incremented/decremented on a field
  16547. // with the given name. The second boolean return value indicates that this field
  16548. // was not set, or was not defined in the schema.
  16549. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  16550. return nil, false
  16551. }
  16552. // AddField adds the value to the field with the given name. It returns an error if
  16553. // the field is not defined in the schema, or if the type mismatched the field
  16554. // type.
  16555. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  16556. switch name {
  16557. }
  16558. return fmt.Errorf("unknown Token numeric field %s", name)
  16559. }
  16560. // ClearedFields returns all nullable fields that were cleared during this
  16561. // mutation.
  16562. func (m *TokenMutation) ClearedFields() []string {
  16563. var fields []string
  16564. if m.FieldCleared(token.FieldDeletedAt) {
  16565. fields = append(fields, token.FieldDeletedAt)
  16566. }
  16567. if m.FieldCleared(token.FieldExpireAt) {
  16568. fields = append(fields, token.FieldExpireAt)
  16569. }
  16570. if m.FieldCleared(token.FieldToken) {
  16571. fields = append(fields, token.FieldToken)
  16572. }
  16573. return fields
  16574. }
  16575. // FieldCleared returns a boolean indicating if a field with the given name was
  16576. // cleared in this mutation.
  16577. func (m *TokenMutation) FieldCleared(name string) bool {
  16578. _, ok := m.clearedFields[name]
  16579. return ok
  16580. }
  16581. // ClearField clears the value of the field with the given name. It returns an
  16582. // error if the field is not defined in the schema.
  16583. func (m *TokenMutation) ClearField(name string) error {
  16584. switch name {
  16585. case token.FieldDeletedAt:
  16586. m.ClearDeletedAt()
  16587. return nil
  16588. case token.FieldExpireAt:
  16589. m.ClearExpireAt()
  16590. return nil
  16591. case token.FieldToken:
  16592. m.ClearToken()
  16593. return nil
  16594. }
  16595. return fmt.Errorf("unknown Token nullable field %s", name)
  16596. }
  16597. // ResetField resets all changes in the mutation for the field with the given name.
  16598. // It returns an error if the field is not defined in the schema.
  16599. func (m *TokenMutation) ResetField(name string) error {
  16600. switch name {
  16601. case token.FieldCreatedAt:
  16602. m.ResetCreatedAt()
  16603. return nil
  16604. case token.FieldUpdatedAt:
  16605. m.ResetUpdatedAt()
  16606. return nil
  16607. case token.FieldDeletedAt:
  16608. m.ResetDeletedAt()
  16609. return nil
  16610. case token.FieldExpireAt:
  16611. m.ResetExpireAt()
  16612. return nil
  16613. case token.FieldToken:
  16614. m.ResetToken()
  16615. return nil
  16616. case token.FieldMAC:
  16617. m.ResetMAC()
  16618. return nil
  16619. }
  16620. return fmt.Errorf("unknown Token field %s", name)
  16621. }
  16622. // AddedEdges returns all edge names that were set/added in this mutation.
  16623. func (m *TokenMutation) AddedEdges() []string {
  16624. edges := make([]string, 0, 0)
  16625. return edges
  16626. }
  16627. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16628. // name in this mutation.
  16629. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  16630. return nil
  16631. }
  16632. // RemovedEdges returns all edge names that were removed in this mutation.
  16633. func (m *TokenMutation) RemovedEdges() []string {
  16634. edges := make([]string, 0, 0)
  16635. return edges
  16636. }
  16637. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16638. // the given name in this mutation.
  16639. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  16640. return nil
  16641. }
  16642. // ClearedEdges returns all edge names that were cleared in this mutation.
  16643. func (m *TokenMutation) ClearedEdges() []string {
  16644. edges := make([]string, 0, 0)
  16645. return edges
  16646. }
  16647. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16648. // was cleared in this mutation.
  16649. func (m *TokenMutation) EdgeCleared(name string) bool {
  16650. return false
  16651. }
  16652. // ClearEdge clears the value of the edge with the given name. It returns an error
  16653. // if that edge is not defined in the schema.
  16654. func (m *TokenMutation) ClearEdge(name string) error {
  16655. return fmt.Errorf("unknown Token unique edge %s", name)
  16656. }
  16657. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16658. // It returns an error if the edge is not defined in the schema.
  16659. func (m *TokenMutation) ResetEdge(name string) error {
  16660. return fmt.Errorf("unknown Token edge %s", name)
  16661. }
  16662. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  16663. type TutorialMutation struct {
  16664. config
  16665. op Op
  16666. typ string
  16667. id *uint64
  16668. created_at *time.Time
  16669. updated_at *time.Time
  16670. deleted_at *time.Time
  16671. index *int
  16672. addindex *int
  16673. title *string
  16674. content *string
  16675. organization_id *uint64
  16676. addorganization_id *int64
  16677. clearedFields map[string]struct{}
  16678. employee *uint64
  16679. clearedemployee bool
  16680. done bool
  16681. oldValue func(context.Context) (*Tutorial, error)
  16682. predicates []predicate.Tutorial
  16683. }
  16684. var _ ent.Mutation = (*TutorialMutation)(nil)
  16685. // tutorialOption allows management of the mutation configuration using functional options.
  16686. type tutorialOption func(*TutorialMutation)
  16687. // newTutorialMutation creates new mutation for the Tutorial entity.
  16688. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  16689. m := &TutorialMutation{
  16690. config: c,
  16691. op: op,
  16692. typ: TypeTutorial,
  16693. clearedFields: make(map[string]struct{}),
  16694. }
  16695. for _, opt := range opts {
  16696. opt(m)
  16697. }
  16698. return m
  16699. }
  16700. // withTutorialID sets the ID field of the mutation.
  16701. func withTutorialID(id uint64) tutorialOption {
  16702. return func(m *TutorialMutation) {
  16703. var (
  16704. err error
  16705. once sync.Once
  16706. value *Tutorial
  16707. )
  16708. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  16709. once.Do(func() {
  16710. if m.done {
  16711. err = errors.New("querying old values post mutation is not allowed")
  16712. } else {
  16713. value, err = m.Client().Tutorial.Get(ctx, id)
  16714. }
  16715. })
  16716. return value, err
  16717. }
  16718. m.id = &id
  16719. }
  16720. }
  16721. // withTutorial sets the old Tutorial of the mutation.
  16722. func withTutorial(node *Tutorial) tutorialOption {
  16723. return func(m *TutorialMutation) {
  16724. m.oldValue = func(context.Context) (*Tutorial, error) {
  16725. return node, nil
  16726. }
  16727. m.id = &node.ID
  16728. }
  16729. }
  16730. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16731. // executed in a transaction (ent.Tx), a transactional client is returned.
  16732. func (m TutorialMutation) Client() *Client {
  16733. client := &Client{config: m.config}
  16734. client.init()
  16735. return client
  16736. }
  16737. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16738. // it returns an error otherwise.
  16739. func (m TutorialMutation) Tx() (*Tx, error) {
  16740. if _, ok := m.driver.(*txDriver); !ok {
  16741. return nil, errors.New("ent: mutation is not running in a transaction")
  16742. }
  16743. tx := &Tx{config: m.config}
  16744. tx.init()
  16745. return tx, nil
  16746. }
  16747. // SetID sets the value of the id field. Note that this
  16748. // operation is only accepted on creation of Tutorial entities.
  16749. func (m *TutorialMutation) SetID(id uint64) {
  16750. m.id = &id
  16751. }
  16752. // ID returns the ID value in the mutation. Note that the ID is only available
  16753. // if it was provided to the builder or after it was returned from the database.
  16754. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  16755. if m.id == nil {
  16756. return
  16757. }
  16758. return *m.id, true
  16759. }
  16760. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16761. // That means, if the mutation is applied within a transaction with an isolation level such
  16762. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16763. // or updated by the mutation.
  16764. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  16765. switch {
  16766. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16767. id, exists := m.ID()
  16768. if exists {
  16769. return []uint64{id}, nil
  16770. }
  16771. fallthrough
  16772. case m.op.Is(OpUpdate | OpDelete):
  16773. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  16774. default:
  16775. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16776. }
  16777. }
  16778. // SetCreatedAt sets the "created_at" field.
  16779. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  16780. m.created_at = &t
  16781. }
  16782. // CreatedAt returns the value of the "created_at" field in the mutation.
  16783. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  16784. v := m.created_at
  16785. if v == nil {
  16786. return
  16787. }
  16788. return *v, true
  16789. }
  16790. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  16791. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16793. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16794. if !m.op.Is(OpUpdateOne) {
  16795. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16796. }
  16797. if m.id == nil || m.oldValue == nil {
  16798. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16799. }
  16800. oldValue, err := m.oldValue(ctx)
  16801. if err != nil {
  16802. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16803. }
  16804. return oldValue.CreatedAt, nil
  16805. }
  16806. // ResetCreatedAt resets all changes to the "created_at" field.
  16807. func (m *TutorialMutation) ResetCreatedAt() {
  16808. m.created_at = nil
  16809. }
  16810. // SetUpdatedAt sets the "updated_at" field.
  16811. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  16812. m.updated_at = &t
  16813. }
  16814. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16815. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  16816. v := m.updated_at
  16817. if v == nil {
  16818. return
  16819. }
  16820. return *v, true
  16821. }
  16822. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  16823. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16825. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16826. if !m.op.Is(OpUpdateOne) {
  16827. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16828. }
  16829. if m.id == nil || m.oldValue == nil {
  16830. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16831. }
  16832. oldValue, err := m.oldValue(ctx)
  16833. if err != nil {
  16834. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16835. }
  16836. return oldValue.UpdatedAt, nil
  16837. }
  16838. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16839. func (m *TutorialMutation) ResetUpdatedAt() {
  16840. m.updated_at = nil
  16841. }
  16842. // SetDeletedAt sets the "deleted_at" field.
  16843. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  16844. m.deleted_at = &t
  16845. }
  16846. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16847. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  16848. v := m.deleted_at
  16849. if v == nil {
  16850. return
  16851. }
  16852. return *v, true
  16853. }
  16854. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  16855. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16857. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16858. if !m.op.Is(OpUpdateOne) {
  16859. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16860. }
  16861. if m.id == nil || m.oldValue == nil {
  16862. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16863. }
  16864. oldValue, err := m.oldValue(ctx)
  16865. if err != nil {
  16866. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16867. }
  16868. return oldValue.DeletedAt, nil
  16869. }
  16870. // ClearDeletedAt clears the value of the "deleted_at" field.
  16871. func (m *TutorialMutation) ClearDeletedAt() {
  16872. m.deleted_at = nil
  16873. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  16874. }
  16875. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16876. func (m *TutorialMutation) DeletedAtCleared() bool {
  16877. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  16878. return ok
  16879. }
  16880. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16881. func (m *TutorialMutation) ResetDeletedAt() {
  16882. m.deleted_at = nil
  16883. delete(m.clearedFields, tutorial.FieldDeletedAt)
  16884. }
  16885. // SetEmployeeID sets the "employee_id" field.
  16886. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  16887. m.employee = &u
  16888. }
  16889. // EmployeeID returns the value of the "employee_id" field in the mutation.
  16890. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  16891. v := m.employee
  16892. if v == nil {
  16893. return
  16894. }
  16895. return *v, true
  16896. }
  16897. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  16898. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16900. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  16901. if !m.op.Is(OpUpdateOne) {
  16902. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  16903. }
  16904. if m.id == nil || m.oldValue == nil {
  16905. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  16906. }
  16907. oldValue, err := m.oldValue(ctx)
  16908. if err != nil {
  16909. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  16910. }
  16911. return oldValue.EmployeeID, nil
  16912. }
  16913. // ResetEmployeeID resets all changes to the "employee_id" field.
  16914. func (m *TutorialMutation) ResetEmployeeID() {
  16915. m.employee = nil
  16916. }
  16917. // SetIndex sets the "index" field.
  16918. func (m *TutorialMutation) SetIndex(i int) {
  16919. m.index = &i
  16920. m.addindex = nil
  16921. }
  16922. // Index returns the value of the "index" field in the mutation.
  16923. func (m *TutorialMutation) Index() (r int, exists bool) {
  16924. v := m.index
  16925. if v == nil {
  16926. return
  16927. }
  16928. return *v, true
  16929. }
  16930. // OldIndex returns the old "index" field's value of the Tutorial entity.
  16931. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16933. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  16934. if !m.op.Is(OpUpdateOne) {
  16935. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  16936. }
  16937. if m.id == nil || m.oldValue == nil {
  16938. return v, errors.New("OldIndex requires an ID field in the mutation")
  16939. }
  16940. oldValue, err := m.oldValue(ctx)
  16941. if err != nil {
  16942. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  16943. }
  16944. return oldValue.Index, nil
  16945. }
  16946. // AddIndex adds i to the "index" field.
  16947. func (m *TutorialMutation) AddIndex(i int) {
  16948. if m.addindex != nil {
  16949. *m.addindex += i
  16950. } else {
  16951. m.addindex = &i
  16952. }
  16953. }
  16954. // AddedIndex returns the value that was added to the "index" field in this mutation.
  16955. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  16956. v := m.addindex
  16957. if v == nil {
  16958. return
  16959. }
  16960. return *v, true
  16961. }
  16962. // ResetIndex resets all changes to the "index" field.
  16963. func (m *TutorialMutation) ResetIndex() {
  16964. m.index = nil
  16965. m.addindex = nil
  16966. }
  16967. // SetTitle sets the "title" field.
  16968. func (m *TutorialMutation) SetTitle(s string) {
  16969. m.title = &s
  16970. }
  16971. // Title returns the value of the "title" field in the mutation.
  16972. func (m *TutorialMutation) Title() (r string, exists bool) {
  16973. v := m.title
  16974. if v == nil {
  16975. return
  16976. }
  16977. return *v, true
  16978. }
  16979. // OldTitle returns the old "title" field's value of the Tutorial entity.
  16980. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16981. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16982. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  16983. if !m.op.Is(OpUpdateOne) {
  16984. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  16985. }
  16986. if m.id == nil || m.oldValue == nil {
  16987. return v, errors.New("OldTitle requires an ID field in the mutation")
  16988. }
  16989. oldValue, err := m.oldValue(ctx)
  16990. if err != nil {
  16991. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  16992. }
  16993. return oldValue.Title, nil
  16994. }
  16995. // ResetTitle resets all changes to the "title" field.
  16996. func (m *TutorialMutation) ResetTitle() {
  16997. m.title = nil
  16998. }
  16999. // SetContent sets the "content" field.
  17000. func (m *TutorialMutation) SetContent(s string) {
  17001. m.content = &s
  17002. }
  17003. // Content returns the value of the "content" field in the mutation.
  17004. func (m *TutorialMutation) Content() (r string, exists bool) {
  17005. v := m.content
  17006. if v == nil {
  17007. return
  17008. }
  17009. return *v, true
  17010. }
  17011. // OldContent returns the old "content" field's value of the Tutorial entity.
  17012. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  17013. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17014. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  17015. if !m.op.Is(OpUpdateOne) {
  17016. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  17017. }
  17018. if m.id == nil || m.oldValue == nil {
  17019. return v, errors.New("OldContent requires an ID field in the mutation")
  17020. }
  17021. oldValue, err := m.oldValue(ctx)
  17022. if err != nil {
  17023. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  17024. }
  17025. return oldValue.Content, nil
  17026. }
  17027. // ResetContent resets all changes to the "content" field.
  17028. func (m *TutorialMutation) ResetContent() {
  17029. m.content = nil
  17030. }
  17031. // SetOrganizationID sets the "organization_id" field.
  17032. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  17033. m.organization_id = &u
  17034. m.addorganization_id = nil
  17035. }
  17036. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17037. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  17038. v := m.organization_id
  17039. if v == nil {
  17040. return
  17041. }
  17042. return *v, true
  17043. }
  17044. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  17045. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  17046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17047. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17048. if !m.op.Is(OpUpdateOne) {
  17049. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17050. }
  17051. if m.id == nil || m.oldValue == nil {
  17052. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17053. }
  17054. oldValue, err := m.oldValue(ctx)
  17055. if err != nil {
  17056. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17057. }
  17058. return oldValue.OrganizationID, nil
  17059. }
  17060. // AddOrganizationID adds u to the "organization_id" field.
  17061. func (m *TutorialMutation) AddOrganizationID(u int64) {
  17062. if m.addorganization_id != nil {
  17063. *m.addorganization_id += u
  17064. } else {
  17065. m.addorganization_id = &u
  17066. }
  17067. }
  17068. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17069. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  17070. v := m.addorganization_id
  17071. if v == nil {
  17072. return
  17073. }
  17074. return *v, true
  17075. }
  17076. // ResetOrganizationID resets all changes to the "organization_id" field.
  17077. func (m *TutorialMutation) ResetOrganizationID() {
  17078. m.organization_id = nil
  17079. m.addorganization_id = nil
  17080. }
  17081. // ClearEmployee clears the "employee" edge to the Employee entity.
  17082. func (m *TutorialMutation) ClearEmployee() {
  17083. m.clearedemployee = true
  17084. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  17085. }
  17086. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  17087. func (m *TutorialMutation) EmployeeCleared() bool {
  17088. return m.clearedemployee
  17089. }
  17090. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  17091. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17092. // EmployeeID instead. It exists only for internal usage by the builders.
  17093. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  17094. if id := m.employee; id != nil {
  17095. ids = append(ids, *id)
  17096. }
  17097. return
  17098. }
  17099. // ResetEmployee resets all changes to the "employee" edge.
  17100. func (m *TutorialMutation) ResetEmployee() {
  17101. m.employee = nil
  17102. m.clearedemployee = false
  17103. }
  17104. // Where appends a list predicates to the TutorialMutation builder.
  17105. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  17106. m.predicates = append(m.predicates, ps...)
  17107. }
  17108. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  17109. // users can use type-assertion to append predicates that do not depend on any generated package.
  17110. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  17111. p := make([]predicate.Tutorial, len(ps))
  17112. for i := range ps {
  17113. p[i] = ps[i]
  17114. }
  17115. m.Where(p...)
  17116. }
  17117. // Op returns the operation name.
  17118. func (m *TutorialMutation) Op() Op {
  17119. return m.op
  17120. }
  17121. // SetOp allows setting the mutation operation.
  17122. func (m *TutorialMutation) SetOp(op Op) {
  17123. m.op = op
  17124. }
  17125. // Type returns the node type of this mutation (Tutorial).
  17126. func (m *TutorialMutation) Type() string {
  17127. return m.typ
  17128. }
  17129. // Fields returns all fields that were changed during this mutation. Note that in
  17130. // order to get all numeric fields that were incremented/decremented, call
  17131. // AddedFields().
  17132. func (m *TutorialMutation) Fields() []string {
  17133. fields := make([]string, 0, 8)
  17134. if m.created_at != nil {
  17135. fields = append(fields, tutorial.FieldCreatedAt)
  17136. }
  17137. if m.updated_at != nil {
  17138. fields = append(fields, tutorial.FieldUpdatedAt)
  17139. }
  17140. if m.deleted_at != nil {
  17141. fields = append(fields, tutorial.FieldDeletedAt)
  17142. }
  17143. if m.employee != nil {
  17144. fields = append(fields, tutorial.FieldEmployeeID)
  17145. }
  17146. if m.index != nil {
  17147. fields = append(fields, tutorial.FieldIndex)
  17148. }
  17149. if m.title != nil {
  17150. fields = append(fields, tutorial.FieldTitle)
  17151. }
  17152. if m.content != nil {
  17153. fields = append(fields, tutorial.FieldContent)
  17154. }
  17155. if m.organization_id != nil {
  17156. fields = append(fields, tutorial.FieldOrganizationID)
  17157. }
  17158. return fields
  17159. }
  17160. // Field returns the value of a field with the given name. The second boolean
  17161. // return value indicates that this field was not set, or was not defined in the
  17162. // schema.
  17163. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  17164. switch name {
  17165. case tutorial.FieldCreatedAt:
  17166. return m.CreatedAt()
  17167. case tutorial.FieldUpdatedAt:
  17168. return m.UpdatedAt()
  17169. case tutorial.FieldDeletedAt:
  17170. return m.DeletedAt()
  17171. case tutorial.FieldEmployeeID:
  17172. return m.EmployeeID()
  17173. case tutorial.FieldIndex:
  17174. return m.Index()
  17175. case tutorial.FieldTitle:
  17176. return m.Title()
  17177. case tutorial.FieldContent:
  17178. return m.Content()
  17179. case tutorial.FieldOrganizationID:
  17180. return m.OrganizationID()
  17181. }
  17182. return nil, false
  17183. }
  17184. // OldField returns the old value of the field from the database. An error is
  17185. // returned if the mutation operation is not UpdateOne, or the query to the
  17186. // database failed.
  17187. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17188. switch name {
  17189. case tutorial.FieldCreatedAt:
  17190. return m.OldCreatedAt(ctx)
  17191. case tutorial.FieldUpdatedAt:
  17192. return m.OldUpdatedAt(ctx)
  17193. case tutorial.FieldDeletedAt:
  17194. return m.OldDeletedAt(ctx)
  17195. case tutorial.FieldEmployeeID:
  17196. return m.OldEmployeeID(ctx)
  17197. case tutorial.FieldIndex:
  17198. return m.OldIndex(ctx)
  17199. case tutorial.FieldTitle:
  17200. return m.OldTitle(ctx)
  17201. case tutorial.FieldContent:
  17202. return m.OldContent(ctx)
  17203. case tutorial.FieldOrganizationID:
  17204. return m.OldOrganizationID(ctx)
  17205. }
  17206. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  17207. }
  17208. // SetField sets the value of a field with the given name. It returns an error if
  17209. // the field is not defined in the schema, or if the type mismatched the field
  17210. // type.
  17211. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  17212. switch name {
  17213. case tutorial.FieldCreatedAt:
  17214. v, ok := value.(time.Time)
  17215. if !ok {
  17216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17217. }
  17218. m.SetCreatedAt(v)
  17219. return nil
  17220. case tutorial.FieldUpdatedAt:
  17221. v, ok := value.(time.Time)
  17222. if !ok {
  17223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17224. }
  17225. m.SetUpdatedAt(v)
  17226. return nil
  17227. case tutorial.FieldDeletedAt:
  17228. v, ok := value.(time.Time)
  17229. if !ok {
  17230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17231. }
  17232. m.SetDeletedAt(v)
  17233. return nil
  17234. case tutorial.FieldEmployeeID:
  17235. v, ok := value.(uint64)
  17236. if !ok {
  17237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17238. }
  17239. m.SetEmployeeID(v)
  17240. return nil
  17241. case tutorial.FieldIndex:
  17242. v, ok := value.(int)
  17243. if !ok {
  17244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17245. }
  17246. m.SetIndex(v)
  17247. return nil
  17248. case tutorial.FieldTitle:
  17249. v, ok := value.(string)
  17250. if !ok {
  17251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17252. }
  17253. m.SetTitle(v)
  17254. return nil
  17255. case tutorial.FieldContent:
  17256. v, ok := value.(string)
  17257. if !ok {
  17258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17259. }
  17260. m.SetContent(v)
  17261. return nil
  17262. case tutorial.FieldOrganizationID:
  17263. v, ok := value.(uint64)
  17264. if !ok {
  17265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17266. }
  17267. m.SetOrganizationID(v)
  17268. return nil
  17269. }
  17270. return fmt.Errorf("unknown Tutorial field %s", name)
  17271. }
  17272. // AddedFields returns all numeric fields that were incremented/decremented during
  17273. // this mutation.
  17274. func (m *TutorialMutation) AddedFields() []string {
  17275. var fields []string
  17276. if m.addindex != nil {
  17277. fields = append(fields, tutorial.FieldIndex)
  17278. }
  17279. if m.addorganization_id != nil {
  17280. fields = append(fields, tutorial.FieldOrganizationID)
  17281. }
  17282. return fields
  17283. }
  17284. // AddedField returns the numeric value that was incremented/decremented on a field
  17285. // with the given name. The second boolean return value indicates that this field
  17286. // was not set, or was not defined in the schema.
  17287. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  17288. switch name {
  17289. case tutorial.FieldIndex:
  17290. return m.AddedIndex()
  17291. case tutorial.FieldOrganizationID:
  17292. return m.AddedOrganizationID()
  17293. }
  17294. return nil, false
  17295. }
  17296. // AddField adds the value to the field with the given name. It returns an error if
  17297. // the field is not defined in the schema, or if the type mismatched the field
  17298. // type.
  17299. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  17300. switch name {
  17301. case tutorial.FieldIndex:
  17302. v, ok := value.(int)
  17303. if !ok {
  17304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17305. }
  17306. m.AddIndex(v)
  17307. return nil
  17308. case tutorial.FieldOrganizationID:
  17309. v, ok := value.(int64)
  17310. if !ok {
  17311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17312. }
  17313. m.AddOrganizationID(v)
  17314. return nil
  17315. }
  17316. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  17317. }
  17318. // ClearedFields returns all nullable fields that were cleared during this
  17319. // mutation.
  17320. func (m *TutorialMutation) ClearedFields() []string {
  17321. var fields []string
  17322. if m.FieldCleared(tutorial.FieldDeletedAt) {
  17323. fields = append(fields, tutorial.FieldDeletedAt)
  17324. }
  17325. return fields
  17326. }
  17327. // FieldCleared returns a boolean indicating if a field with the given name was
  17328. // cleared in this mutation.
  17329. func (m *TutorialMutation) FieldCleared(name string) bool {
  17330. _, ok := m.clearedFields[name]
  17331. return ok
  17332. }
  17333. // ClearField clears the value of the field with the given name. It returns an
  17334. // error if the field is not defined in the schema.
  17335. func (m *TutorialMutation) ClearField(name string) error {
  17336. switch name {
  17337. case tutorial.FieldDeletedAt:
  17338. m.ClearDeletedAt()
  17339. return nil
  17340. }
  17341. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  17342. }
  17343. // ResetField resets all changes in the mutation for the field with the given name.
  17344. // It returns an error if the field is not defined in the schema.
  17345. func (m *TutorialMutation) ResetField(name string) error {
  17346. switch name {
  17347. case tutorial.FieldCreatedAt:
  17348. m.ResetCreatedAt()
  17349. return nil
  17350. case tutorial.FieldUpdatedAt:
  17351. m.ResetUpdatedAt()
  17352. return nil
  17353. case tutorial.FieldDeletedAt:
  17354. m.ResetDeletedAt()
  17355. return nil
  17356. case tutorial.FieldEmployeeID:
  17357. m.ResetEmployeeID()
  17358. return nil
  17359. case tutorial.FieldIndex:
  17360. m.ResetIndex()
  17361. return nil
  17362. case tutorial.FieldTitle:
  17363. m.ResetTitle()
  17364. return nil
  17365. case tutorial.FieldContent:
  17366. m.ResetContent()
  17367. return nil
  17368. case tutorial.FieldOrganizationID:
  17369. m.ResetOrganizationID()
  17370. return nil
  17371. }
  17372. return fmt.Errorf("unknown Tutorial field %s", name)
  17373. }
  17374. // AddedEdges returns all edge names that were set/added in this mutation.
  17375. func (m *TutorialMutation) AddedEdges() []string {
  17376. edges := make([]string, 0, 1)
  17377. if m.employee != nil {
  17378. edges = append(edges, tutorial.EdgeEmployee)
  17379. }
  17380. return edges
  17381. }
  17382. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17383. // name in this mutation.
  17384. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  17385. switch name {
  17386. case tutorial.EdgeEmployee:
  17387. if id := m.employee; id != nil {
  17388. return []ent.Value{*id}
  17389. }
  17390. }
  17391. return nil
  17392. }
  17393. // RemovedEdges returns all edge names that were removed in this mutation.
  17394. func (m *TutorialMutation) RemovedEdges() []string {
  17395. edges := make([]string, 0, 1)
  17396. return edges
  17397. }
  17398. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17399. // the given name in this mutation.
  17400. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  17401. return nil
  17402. }
  17403. // ClearedEdges returns all edge names that were cleared in this mutation.
  17404. func (m *TutorialMutation) ClearedEdges() []string {
  17405. edges := make([]string, 0, 1)
  17406. if m.clearedemployee {
  17407. edges = append(edges, tutorial.EdgeEmployee)
  17408. }
  17409. return edges
  17410. }
  17411. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17412. // was cleared in this mutation.
  17413. func (m *TutorialMutation) EdgeCleared(name string) bool {
  17414. switch name {
  17415. case tutorial.EdgeEmployee:
  17416. return m.clearedemployee
  17417. }
  17418. return false
  17419. }
  17420. // ClearEdge clears the value of the edge with the given name. It returns an error
  17421. // if that edge is not defined in the schema.
  17422. func (m *TutorialMutation) ClearEdge(name string) error {
  17423. switch name {
  17424. case tutorial.EdgeEmployee:
  17425. m.ClearEmployee()
  17426. return nil
  17427. }
  17428. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  17429. }
  17430. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17431. // It returns an error if the edge is not defined in the schema.
  17432. func (m *TutorialMutation) ResetEdge(name string) error {
  17433. switch name {
  17434. case tutorial.EdgeEmployee:
  17435. m.ResetEmployee()
  17436. return nil
  17437. }
  17438. return fmt.Errorf("unknown Tutorial edge %s", name)
  17439. }
  17440. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  17441. type WorkExperienceMutation struct {
  17442. config
  17443. op Op
  17444. typ string
  17445. id *uint64
  17446. created_at *time.Time
  17447. updated_at *time.Time
  17448. deleted_at *time.Time
  17449. start_date *time.Time
  17450. end_date *time.Time
  17451. company *string
  17452. experience *string
  17453. organization_id *uint64
  17454. addorganization_id *int64
  17455. clearedFields map[string]struct{}
  17456. employee *uint64
  17457. clearedemployee bool
  17458. done bool
  17459. oldValue func(context.Context) (*WorkExperience, error)
  17460. predicates []predicate.WorkExperience
  17461. }
  17462. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  17463. // workexperienceOption allows management of the mutation configuration using functional options.
  17464. type workexperienceOption func(*WorkExperienceMutation)
  17465. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  17466. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  17467. m := &WorkExperienceMutation{
  17468. config: c,
  17469. op: op,
  17470. typ: TypeWorkExperience,
  17471. clearedFields: make(map[string]struct{}),
  17472. }
  17473. for _, opt := range opts {
  17474. opt(m)
  17475. }
  17476. return m
  17477. }
  17478. // withWorkExperienceID sets the ID field of the mutation.
  17479. func withWorkExperienceID(id uint64) workexperienceOption {
  17480. return func(m *WorkExperienceMutation) {
  17481. var (
  17482. err error
  17483. once sync.Once
  17484. value *WorkExperience
  17485. )
  17486. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  17487. once.Do(func() {
  17488. if m.done {
  17489. err = errors.New("querying old values post mutation is not allowed")
  17490. } else {
  17491. value, err = m.Client().WorkExperience.Get(ctx, id)
  17492. }
  17493. })
  17494. return value, err
  17495. }
  17496. m.id = &id
  17497. }
  17498. }
  17499. // withWorkExperience sets the old WorkExperience of the mutation.
  17500. func withWorkExperience(node *WorkExperience) workexperienceOption {
  17501. return func(m *WorkExperienceMutation) {
  17502. m.oldValue = func(context.Context) (*WorkExperience, error) {
  17503. return node, nil
  17504. }
  17505. m.id = &node.ID
  17506. }
  17507. }
  17508. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17509. // executed in a transaction (ent.Tx), a transactional client is returned.
  17510. func (m WorkExperienceMutation) Client() *Client {
  17511. client := &Client{config: m.config}
  17512. client.init()
  17513. return client
  17514. }
  17515. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17516. // it returns an error otherwise.
  17517. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  17518. if _, ok := m.driver.(*txDriver); !ok {
  17519. return nil, errors.New("ent: mutation is not running in a transaction")
  17520. }
  17521. tx := &Tx{config: m.config}
  17522. tx.init()
  17523. return tx, nil
  17524. }
  17525. // SetID sets the value of the id field. Note that this
  17526. // operation is only accepted on creation of WorkExperience entities.
  17527. func (m *WorkExperienceMutation) SetID(id uint64) {
  17528. m.id = &id
  17529. }
  17530. // ID returns the ID value in the mutation. Note that the ID is only available
  17531. // if it was provided to the builder or after it was returned from the database.
  17532. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  17533. if m.id == nil {
  17534. return
  17535. }
  17536. return *m.id, true
  17537. }
  17538. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17539. // That means, if the mutation is applied within a transaction with an isolation level such
  17540. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17541. // or updated by the mutation.
  17542. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  17543. switch {
  17544. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17545. id, exists := m.ID()
  17546. if exists {
  17547. return []uint64{id}, nil
  17548. }
  17549. fallthrough
  17550. case m.op.Is(OpUpdate | OpDelete):
  17551. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  17552. default:
  17553. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17554. }
  17555. }
  17556. // SetCreatedAt sets the "created_at" field.
  17557. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  17558. m.created_at = &t
  17559. }
  17560. // CreatedAt returns the value of the "created_at" field in the mutation.
  17561. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  17562. v := m.created_at
  17563. if v == nil {
  17564. return
  17565. }
  17566. return *v, true
  17567. }
  17568. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  17569. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17571. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17572. if !m.op.Is(OpUpdateOne) {
  17573. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17574. }
  17575. if m.id == nil || m.oldValue == nil {
  17576. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17577. }
  17578. oldValue, err := m.oldValue(ctx)
  17579. if err != nil {
  17580. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17581. }
  17582. return oldValue.CreatedAt, nil
  17583. }
  17584. // ResetCreatedAt resets all changes to the "created_at" field.
  17585. func (m *WorkExperienceMutation) ResetCreatedAt() {
  17586. m.created_at = nil
  17587. }
  17588. // SetUpdatedAt sets the "updated_at" field.
  17589. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  17590. m.updated_at = &t
  17591. }
  17592. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17593. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  17594. v := m.updated_at
  17595. if v == nil {
  17596. return
  17597. }
  17598. return *v, true
  17599. }
  17600. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  17601. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17603. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17604. if !m.op.Is(OpUpdateOne) {
  17605. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17606. }
  17607. if m.id == nil || m.oldValue == nil {
  17608. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17609. }
  17610. oldValue, err := m.oldValue(ctx)
  17611. if err != nil {
  17612. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17613. }
  17614. return oldValue.UpdatedAt, nil
  17615. }
  17616. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17617. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  17618. m.updated_at = nil
  17619. }
  17620. // SetDeletedAt sets the "deleted_at" field.
  17621. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  17622. m.deleted_at = &t
  17623. }
  17624. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17625. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  17626. v := m.deleted_at
  17627. if v == nil {
  17628. return
  17629. }
  17630. return *v, true
  17631. }
  17632. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  17633. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17635. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17636. if !m.op.Is(OpUpdateOne) {
  17637. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17638. }
  17639. if m.id == nil || m.oldValue == nil {
  17640. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17641. }
  17642. oldValue, err := m.oldValue(ctx)
  17643. if err != nil {
  17644. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17645. }
  17646. return oldValue.DeletedAt, nil
  17647. }
  17648. // ClearDeletedAt clears the value of the "deleted_at" field.
  17649. func (m *WorkExperienceMutation) ClearDeletedAt() {
  17650. m.deleted_at = nil
  17651. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  17652. }
  17653. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17654. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  17655. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  17656. return ok
  17657. }
  17658. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17659. func (m *WorkExperienceMutation) ResetDeletedAt() {
  17660. m.deleted_at = nil
  17661. delete(m.clearedFields, workexperience.FieldDeletedAt)
  17662. }
  17663. // SetEmployeeID sets the "employee_id" field.
  17664. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  17665. m.employee = &u
  17666. }
  17667. // EmployeeID returns the value of the "employee_id" field in the mutation.
  17668. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  17669. v := m.employee
  17670. if v == nil {
  17671. return
  17672. }
  17673. return *v, true
  17674. }
  17675. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  17676. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17678. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  17679. if !m.op.Is(OpUpdateOne) {
  17680. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  17681. }
  17682. if m.id == nil || m.oldValue == nil {
  17683. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  17684. }
  17685. oldValue, err := m.oldValue(ctx)
  17686. if err != nil {
  17687. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  17688. }
  17689. return oldValue.EmployeeID, nil
  17690. }
  17691. // ResetEmployeeID resets all changes to the "employee_id" field.
  17692. func (m *WorkExperienceMutation) ResetEmployeeID() {
  17693. m.employee = nil
  17694. }
  17695. // SetStartDate sets the "start_date" field.
  17696. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  17697. m.start_date = &t
  17698. }
  17699. // StartDate returns the value of the "start_date" field in the mutation.
  17700. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  17701. v := m.start_date
  17702. if v == nil {
  17703. return
  17704. }
  17705. return *v, true
  17706. }
  17707. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  17708. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17710. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  17711. if !m.op.Is(OpUpdateOne) {
  17712. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  17713. }
  17714. if m.id == nil || m.oldValue == nil {
  17715. return v, errors.New("OldStartDate requires an ID field in the mutation")
  17716. }
  17717. oldValue, err := m.oldValue(ctx)
  17718. if err != nil {
  17719. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  17720. }
  17721. return oldValue.StartDate, nil
  17722. }
  17723. // ResetStartDate resets all changes to the "start_date" field.
  17724. func (m *WorkExperienceMutation) ResetStartDate() {
  17725. m.start_date = nil
  17726. }
  17727. // SetEndDate sets the "end_date" field.
  17728. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  17729. m.end_date = &t
  17730. }
  17731. // EndDate returns the value of the "end_date" field in the mutation.
  17732. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  17733. v := m.end_date
  17734. if v == nil {
  17735. return
  17736. }
  17737. return *v, true
  17738. }
  17739. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  17740. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17742. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  17743. if !m.op.Is(OpUpdateOne) {
  17744. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  17745. }
  17746. if m.id == nil || m.oldValue == nil {
  17747. return v, errors.New("OldEndDate requires an ID field in the mutation")
  17748. }
  17749. oldValue, err := m.oldValue(ctx)
  17750. if err != nil {
  17751. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  17752. }
  17753. return oldValue.EndDate, nil
  17754. }
  17755. // ResetEndDate resets all changes to the "end_date" field.
  17756. func (m *WorkExperienceMutation) ResetEndDate() {
  17757. m.end_date = nil
  17758. }
  17759. // SetCompany sets the "company" field.
  17760. func (m *WorkExperienceMutation) SetCompany(s string) {
  17761. m.company = &s
  17762. }
  17763. // Company returns the value of the "company" field in the mutation.
  17764. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  17765. v := m.company
  17766. if v == nil {
  17767. return
  17768. }
  17769. return *v, true
  17770. }
  17771. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  17772. // If the WorkExperience 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 *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  17775. if !m.op.Is(OpUpdateOne) {
  17776. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  17777. }
  17778. if m.id == nil || m.oldValue == nil {
  17779. return v, errors.New("OldCompany 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 OldCompany: %w", err)
  17784. }
  17785. return oldValue.Company, nil
  17786. }
  17787. // ResetCompany resets all changes to the "company" field.
  17788. func (m *WorkExperienceMutation) ResetCompany() {
  17789. m.company = nil
  17790. }
  17791. // SetExperience sets the "experience" field.
  17792. func (m *WorkExperienceMutation) SetExperience(s string) {
  17793. m.experience = &s
  17794. }
  17795. // Experience returns the value of the "experience" field in the mutation.
  17796. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  17797. v := m.experience
  17798. if v == nil {
  17799. return
  17800. }
  17801. return *v, true
  17802. }
  17803. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  17804. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17806. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  17807. if !m.op.Is(OpUpdateOne) {
  17808. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  17809. }
  17810. if m.id == nil || m.oldValue == nil {
  17811. return v, errors.New("OldExperience requires an ID field in the mutation")
  17812. }
  17813. oldValue, err := m.oldValue(ctx)
  17814. if err != nil {
  17815. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  17816. }
  17817. return oldValue.Experience, nil
  17818. }
  17819. // ResetExperience resets all changes to the "experience" field.
  17820. func (m *WorkExperienceMutation) ResetExperience() {
  17821. m.experience = nil
  17822. }
  17823. // SetOrganizationID sets the "organization_id" field.
  17824. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  17825. m.organization_id = &u
  17826. m.addorganization_id = nil
  17827. }
  17828. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17829. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  17830. v := m.organization_id
  17831. if v == nil {
  17832. return
  17833. }
  17834. return *v, true
  17835. }
  17836. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  17837. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17839. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17840. if !m.op.Is(OpUpdateOne) {
  17841. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17842. }
  17843. if m.id == nil || m.oldValue == nil {
  17844. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17845. }
  17846. oldValue, err := m.oldValue(ctx)
  17847. if err != nil {
  17848. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17849. }
  17850. return oldValue.OrganizationID, nil
  17851. }
  17852. // AddOrganizationID adds u to the "organization_id" field.
  17853. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  17854. if m.addorganization_id != nil {
  17855. *m.addorganization_id += u
  17856. } else {
  17857. m.addorganization_id = &u
  17858. }
  17859. }
  17860. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17861. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  17862. v := m.addorganization_id
  17863. if v == nil {
  17864. return
  17865. }
  17866. return *v, true
  17867. }
  17868. // ResetOrganizationID resets all changes to the "organization_id" field.
  17869. func (m *WorkExperienceMutation) ResetOrganizationID() {
  17870. m.organization_id = nil
  17871. m.addorganization_id = nil
  17872. }
  17873. // ClearEmployee clears the "employee" edge to the Employee entity.
  17874. func (m *WorkExperienceMutation) ClearEmployee() {
  17875. m.clearedemployee = true
  17876. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  17877. }
  17878. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  17879. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  17880. return m.clearedemployee
  17881. }
  17882. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  17883. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17884. // EmployeeID instead. It exists only for internal usage by the builders.
  17885. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  17886. if id := m.employee; id != nil {
  17887. ids = append(ids, *id)
  17888. }
  17889. return
  17890. }
  17891. // ResetEmployee resets all changes to the "employee" edge.
  17892. func (m *WorkExperienceMutation) ResetEmployee() {
  17893. m.employee = nil
  17894. m.clearedemployee = false
  17895. }
  17896. // Where appends a list predicates to the WorkExperienceMutation builder.
  17897. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  17898. m.predicates = append(m.predicates, ps...)
  17899. }
  17900. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  17901. // users can use type-assertion to append predicates that do not depend on any generated package.
  17902. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  17903. p := make([]predicate.WorkExperience, len(ps))
  17904. for i := range ps {
  17905. p[i] = ps[i]
  17906. }
  17907. m.Where(p...)
  17908. }
  17909. // Op returns the operation name.
  17910. func (m *WorkExperienceMutation) Op() Op {
  17911. return m.op
  17912. }
  17913. // SetOp allows setting the mutation operation.
  17914. func (m *WorkExperienceMutation) SetOp(op Op) {
  17915. m.op = op
  17916. }
  17917. // Type returns the node type of this mutation (WorkExperience).
  17918. func (m *WorkExperienceMutation) Type() string {
  17919. return m.typ
  17920. }
  17921. // Fields returns all fields that were changed during this mutation. Note that in
  17922. // order to get all numeric fields that were incremented/decremented, call
  17923. // AddedFields().
  17924. func (m *WorkExperienceMutation) Fields() []string {
  17925. fields := make([]string, 0, 9)
  17926. if m.created_at != nil {
  17927. fields = append(fields, workexperience.FieldCreatedAt)
  17928. }
  17929. if m.updated_at != nil {
  17930. fields = append(fields, workexperience.FieldUpdatedAt)
  17931. }
  17932. if m.deleted_at != nil {
  17933. fields = append(fields, workexperience.FieldDeletedAt)
  17934. }
  17935. if m.employee != nil {
  17936. fields = append(fields, workexperience.FieldEmployeeID)
  17937. }
  17938. if m.start_date != nil {
  17939. fields = append(fields, workexperience.FieldStartDate)
  17940. }
  17941. if m.end_date != nil {
  17942. fields = append(fields, workexperience.FieldEndDate)
  17943. }
  17944. if m.company != nil {
  17945. fields = append(fields, workexperience.FieldCompany)
  17946. }
  17947. if m.experience != nil {
  17948. fields = append(fields, workexperience.FieldExperience)
  17949. }
  17950. if m.organization_id != nil {
  17951. fields = append(fields, workexperience.FieldOrganizationID)
  17952. }
  17953. return fields
  17954. }
  17955. // Field returns the value of a field with the given name. The second boolean
  17956. // return value indicates that this field was not set, or was not defined in the
  17957. // schema.
  17958. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  17959. switch name {
  17960. case workexperience.FieldCreatedAt:
  17961. return m.CreatedAt()
  17962. case workexperience.FieldUpdatedAt:
  17963. return m.UpdatedAt()
  17964. case workexperience.FieldDeletedAt:
  17965. return m.DeletedAt()
  17966. case workexperience.FieldEmployeeID:
  17967. return m.EmployeeID()
  17968. case workexperience.FieldStartDate:
  17969. return m.StartDate()
  17970. case workexperience.FieldEndDate:
  17971. return m.EndDate()
  17972. case workexperience.FieldCompany:
  17973. return m.Company()
  17974. case workexperience.FieldExperience:
  17975. return m.Experience()
  17976. case workexperience.FieldOrganizationID:
  17977. return m.OrganizationID()
  17978. }
  17979. return nil, false
  17980. }
  17981. // OldField returns the old value of the field from the database. An error is
  17982. // returned if the mutation operation is not UpdateOne, or the query to the
  17983. // database failed.
  17984. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17985. switch name {
  17986. case workexperience.FieldCreatedAt:
  17987. return m.OldCreatedAt(ctx)
  17988. case workexperience.FieldUpdatedAt:
  17989. return m.OldUpdatedAt(ctx)
  17990. case workexperience.FieldDeletedAt:
  17991. return m.OldDeletedAt(ctx)
  17992. case workexperience.FieldEmployeeID:
  17993. return m.OldEmployeeID(ctx)
  17994. case workexperience.FieldStartDate:
  17995. return m.OldStartDate(ctx)
  17996. case workexperience.FieldEndDate:
  17997. return m.OldEndDate(ctx)
  17998. case workexperience.FieldCompany:
  17999. return m.OldCompany(ctx)
  18000. case workexperience.FieldExperience:
  18001. return m.OldExperience(ctx)
  18002. case workexperience.FieldOrganizationID:
  18003. return m.OldOrganizationID(ctx)
  18004. }
  18005. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  18006. }
  18007. // SetField sets the value of a field with the given name. It returns an error if
  18008. // the field is not defined in the schema, or if the type mismatched the field
  18009. // type.
  18010. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  18011. switch name {
  18012. case workexperience.FieldCreatedAt:
  18013. v, ok := value.(time.Time)
  18014. if !ok {
  18015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18016. }
  18017. m.SetCreatedAt(v)
  18018. return nil
  18019. case workexperience.FieldUpdatedAt:
  18020. v, ok := value.(time.Time)
  18021. if !ok {
  18022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18023. }
  18024. m.SetUpdatedAt(v)
  18025. return nil
  18026. case workexperience.FieldDeletedAt:
  18027. v, ok := value.(time.Time)
  18028. if !ok {
  18029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18030. }
  18031. m.SetDeletedAt(v)
  18032. return nil
  18033. case workexperience.FieldEmployeeID:
  18034. v, ok := value.(uint64)
  18035. if !ok {
  18036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18037. }
  18038. m.SetEmployeeID(v)
  18039. return nil
  18040. case workexperience.FieldStartDate:
  18041. v, ok := value.(time.Time)
  18042. if !ok {
  18043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18044. }
  18045. m.SetStartDate(v)
  18046. return nil
  18047. case workexperience.FieldEndDate:
  18048. v, ok := value.(time.Time)
  18049. if !ok {
  18050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18051. }
  18052. m.SetEndDate(v)
  18053. return nil
  18054. case workexperience.FieldCompany:
  18055. v, ok := value.(string)
  18056. if !ok {
  18057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18058. }
  18059. m.SetCompany(v)
  18060. return nil
  18061. case workexperience.FieldExperience:
  18062. v, ok := value.(string)
  18063. if !ok {
  18064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18065. }
  18066. m.SetExperience(v)
  18067. return nil
  18068. case workexperience.FieldOrganizationID:
  18069. v, ok := value.(uint64)
  18070. if !ok {
  18071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18072. }
  18073. m.SetOrganizationID(v)
  18074. return nil
  18075. }
  18076. return fmt.Errorf("unknown WorkExperience field %s", name)
  18077. }
  18078. // AddedFields returns all numeric fields that were incremented/decremented during
  18079. // this mutation.
  18080. func (m *WorkExperienceMutation) AddedFields() []string {
  18081. var fields []string
  18082. if m.addorganization_id != nil {
  18083. fields = append(fields, workexperience.FieldOrganizationID)
  18084. }
  18085. return fields
  18086. }
  18087. // AddedField returns the numeric value that was incremented/decremented on a field
  18088. // with the given name. The second boolean return value indicates that this field
  18089. // was not set, or was not defined in the schema.
  18090. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  18091. switch name {
  18092. case workexperience.FieldOrganizationID:
  18093. return m.AddedOrganizationID()
  18094. }
  18095. return nil, false
  18096. }
  18097. // AddField adds the value to the field with the given name. It returns an error if
  18098. // the field is not defined in the schema, or if the type mismatched the field
  18099. // type.
  18100. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  18101. switch name {
  18102. case workexperience.FieldOrganizationID:
  18103. v, ok := value.(int64)
  18104. if !ok {
  18105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18106. }
  18107. m.AddOrganizationID(v)
  18108. return nil
  18109. }
  18110. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  18111. }
  18112. // ClearedFields returns all nullable fields that were cleared during this
  18113. // mutation.
  18114. func (m *WorkExperienceMutation) ClearedFields() []string {
  18115. var fields []string
  18116. if m.FieldCleared(workexperience.FieldDeletedAt) {
  18117. fields = append(fields, workexperience.FieldDeletedAt)
  18118. }
  18119. return fields
  18120. }
  18121. // FieldCleared returns a boolean indicating if a field with the given name was
  18122. // cleared in this mutation.
  18123. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  18124. _, ok := m.clearedFields[name]
  18125. return ok
  18126. }
  18127. // ClearField clears the value of the field with the given name. It returns an
  18128. // error if the field is not defined in the schema.
  18129. func (m *WorkExperienceMutation) ClearField(name string) error {
  18130. switch name {
  18131. case workexperience.FieldDeletedAt:
  18132. m.ClearDeletedAt()
  18133. return nil
  18134. }
  18135. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  18136. }
  18137. // ResetField resets all changes in the mutation for the field with the given name.
  18138. // It returns an error if the field is not defined in the schema.
  18139. func (m *WorkExperienceMutation) ResetField(name string) error {
  18140. switch name {
  18141. case workexperience.FieldCreatedAt:
  18142. m.ResetCreatedAt()
  18143. return nil
  18144. case workexperience.FieldUpdatedAt:
  18145. m.ResetUpdatedAt()
  18146. return nil
  18147. case workexperience.FieldDeletedAt:
  18148. m.ResetDeletedAt()
  18149. return nil
  18150. case workexperience.FieldEmployeeID:
  18151. m.ResetEmployeeID()
  18152. return nil
  18153. case workexperience.FieldStartDate:
  18154. m.ResetStartDate()
  18155. return nil
  18156. case workexperience.FieldEndDate:
  18157. m.ResetEndDate()
  18158. return nil
  18159. case workexperience.FieldCompany:
  18160. m.ResetCompany()
  18161. return nil
  18162. case workexperience.FieldExperience:
  18163. m.ResetExperience()
  18164. return nil
  18165. case workexperience.FieldOrganizationID:
  18166. m.ResetOrganizationID()
  18167. return nil
  18168. }
  18169. return fmt.Errorf("unknown WorkExperience field %s", name)
  18170. }
  18171. // AddedEdges returns all edge names that were set/added in this mutation.
  18172. func (m *WorkExperienceMutation) AddedEdges() []string {
  18173. edges := make([]string, 0, 1)
  18174. if m.employee != nil {
  18175. edges = append(edges, workexperience.EdgeEmployee)
  18176. }
  18177. return edges
  18178. }
  18179. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18180. // name in this mutation.
  18181. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  18182. switch name {
  18183. case workexperience.EdgeEmployee:
  18184. if id := m.employee; id != nil {
  18185. return []ent.Value{*id}
  18186. }
  18187. }
  18188. return nil
  18189. }
  18190. // RemovedEdges returns all edge names that were removed in this mutation.
  18191. func (m *WorkExperienceMutation) RemovedEdges() []string {
  18192. edges := make([]string, 0, 1)
  18193. return edges
  18194. }
  18195. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18196. // the given name in this mutation.
  18197. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  18198. return nil
  18199. }
  18200. // ClearedEdges returns all edge names that were cleared in this mutation.
  18201. func (m *WorkExperienceMutation) ClearedEdges() []string {
  18202. edges := make([]string, 0, 1)
  18203. if m.clearedemployee {
  18204. edges = append(edges, workexperience.EdgeEmployee)
  18205. }
  18206. return edges
  18207. }
  18208. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18209. // was cleared in this mutation.
  18210. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  18211. switch name {
  18212. case workexperience.EdgeEmployee:
  18213. return m.clearedemployee
  18214. }
  18215. return false
  18216. }
  18217. // ClearEdge clears the value of the edge with the given name. It returns an error
  18218. // if that edge is not defined in the schema.
  18219. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  18220. switch name {
  18221. case workexperience.EdgeEmployee:
  18222. m.ClearEmployee()
  18223. return nil
  18224. }
  18225. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  18226. }
  18227. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18228. // It returns an error if the edge is not defined in the schema.
  18229. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  18230. switch name {
  18231. case workexperience.EdgeEmployee:
  18232. m.ResetEmployee()
  18233. return nil
  18234. }
  18235. return fmt.Errorf("unknown WorkExperience edge %s", name)
  18236. }
  18237. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  18238. type WxMutation struct {
  18239. config
  18240. op Op
  18241. typ string
  18242. id *uint64
  18243. created_at *time.Time
  18244. updated_at *time.Time
  18245. status *uint8
  18246. addstatus *int8
  18247. deleted_at *time.Time
  18248. port *string
  18249. process_id *string
  18250. callback *string
  18251. wxid *string
  18252. account *string
  18253. nickname *string
  18254. tel *string
  18255. head_big *string
  18256. organization_id *uint64
  18257. addorganization_id *int64
  18258. api_base *string
  18259. api_key *string
  18260. clearedFields map[string]struct{}
  18261. server *uint64
  18262. clearedserver bool
  18263. agent *uint64
  18264. clearedagent bool
  18265. done bool
  18266. oldValue func(context.Context) (*Wx, error)
  18267. predicates []predicate.Wx
  18268. }
  18269. var _ ent.Mutation = (*WxMutation)(nil)
  18270. // wxOption allows management of the mutation configuration using functional options.
  18271. type wxOption func(*WxMutation)
  18272. // newWxMutation creates new mutation for the Wx entity.
  18273. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  18274. m := &WxMutation{
  18275. config: c,
  18276. op: op,
  18277. typ: TypeWx,
  18278. clearedFields: make(map[string]struct{}),
  18279. }
  18280. for _, opt := range opts {
  18281. opt(m)
  18282. }
  18283. return m
  18284. }
  18285. // withWxID sets the ID field of the mutation.
  18286. func withWxID(id uint64) wxOption {
  18287. return func(m *WxMutation) {
  18288. var (
  18289. err error
  18290. once sync.Once
  18291. value *Wx
  18292. )
  18293. m.oldValue = func(ctx context.Context) (*Wx, error) {
  18294. once.Do(func() {
  18295. if m.done {
  18296. err = errors.New("querying old values post mutation is not allowed")
  18297. } else {
  18298. value, err = m.Client().Wx.Get(ctx, id)
  18299. }
  18300. })
  18301. return value, err
  18302. }
  18303. m.id = &id
  18304. }
  18305. }
  18306. // withWx sets the old Wx of the mutation.
  18307. func withWx(node *Wx) wxOption {
  18308. return func(m *WxMutation) {
  18309. m.oldValue = func(context.Context) (*Wx, error) {
  18310. return node, nil
  18311. }
  18312. m.id = &node.ID
  18313. }
  18314. }
  18315. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18316. // executed in a transaction (ent.Tx), a transactional client is returned.
  18317. func (m WxMutation) Client() *Client {
  18318. client := &Client{config: m.config}
  18319. client.init()
  18320. return client
  18321. }
  18322. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18323. // it returns an error otherwise.
  18324. func (m WxMutation) Tx() (*Tx, error) {
  18325. if _, ok := m.driver.(*txDriver); !ok {
  18326. return nil, errors.New("ent: mutation is not running in a transaction")
  18327. }
  18328. tx := &Tx{config: m.config}
  18329. tx.init()
  18330. return tx, nil
  18331. }
  18332. // SetID sets the value of the id field. Note that this
  18333. // operation is only accepted on creation of Wx entities.
  18334. func (m *WxMutation) SetID(id uint64) {
  18335. m.id = &id
  18336. }
  18337. // ID returns the ID value in the mutation. Note that the ID is only available
  18338. // if it was provided to the builder or after it was returned from the database.
  18339. func (m *WxMutation) ID() (id uint64, exists bool) {
  18340. if m.id == nil {
  18341. return
  18342. }
  18343. return *m.id, true
  18344. }
  18345. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18346. // That means, if the mutation is applied within a transaction with an isolation level such
  18347. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18348. // or updated by the mutation.
  18349. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  18350. switch {
  18351. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18352. id, exists := m.ID()
  18353. if exists {
  18354. return []uint64{id}, nil
  18355. }
  18356. fallthrough
  18357. case m.op.Is(OpUpdate | OpDelete):
  18358. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  18359. default:
  18360. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18361. }
  18362. }
  18363. // SetCreatedAt sets the "created_at" field.
  18364. func (m *WxMutation) SetCreatedAt(t time.Time) {
  18365. m.created_at = &t
  18366. }
  18367. // CreatedAt returns the value of the "created_at" field in the mutation.
  18368. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  18369. v := m.created_at
  18370. if v == nil {
  18371. return
  18372. }
  18373. return *v, true
  18374. }
  18375. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  18376. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18378. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18379. if !m.op.Is(OpUpdateOne) {
  18380. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18381. }
  18382. if m.id == nil || m.oldValue == nil {
  18383. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18384. }
  18385. oldValue, err := m.oldValue(ctx)
  18386. if err != nil {
  18387. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18388. }
  18389. return oldValue.CreatedAt, nil
  18390. }
  18391. // ResetCreatedAt resets all changes to the "created_at" field.
  18392. func (m *WxMutation) ResetCreatedAt() {
  18393. m.created_at = nil
  18394. }
  18395. // SetUpdatedAt sets the "updated_at" field.
  18396. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  18397. m.updated_at = &t
  18398. }
  18399. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18400. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  18401. v := m.updated_at
  18402. if v == nil {
  18403. return
  18404. }
  18405. return *v, true
  18406. }
  18407. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  18408. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18410. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18411. if !m.op.Is(OpUpdateOne) {
  18412. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18413. }
  18414. if m.id == nil || m.oldValue == nil {
  18415. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18416. }
  18417. oldValue, err := m.oldValue(ctx)
  18418. if err != nil {
  18419. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18420. }
  18421. return oldValue.UpdatedAt, nil
  18422. }
  18423. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18424. func (m *WxMutation) ResetUpdatedAt() {
  18425. m.updated_at = nil
  18426. }
  18427. // SetStatus sets the "status" field.
  18428. func (m *WxMutation) SetStatus(u uint8) {
  18429. m.status = &u
  18430. m.addstatus = nil
  18431. }
  18432. // Status returns the value of the "status" field in the mutation.
  18433. func (m *WxMutation) Status() (r uint8, exists bool) {
  18434. v := m.status
  18435. if v == nil {
  18436. return
  18437. }
  18438. return *v, true
  18439. }
  18440. // OldStatus returns the old "status" field's value of the Wx entity.
  18441. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18443. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18444. if !m.op.Is(OpUpdateOne) {
  18445. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18446. }
  18447. if m.id == nil || m.oldValue == nil {
  18448. return v, errors.New("OldStatus requires an ID field in the mutation")
  18449. }
  18450. oldValue, err := m.oldValue(ctx)
  18451. if err != nil {
  18452. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18453. }
  18454. return oldValue.Status, nil
  18455. }
  18456. // AddStatus adds u to the "status" field.
  18457. func (m *WxMutation) AddStatus(u int8) {
  18458. if m.addstatus != nil {
  18459. *m.addstatus += u
  18460. } else {
  18461. m.addstatus = &u
  18462. }
  18463. }
  18464. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18465. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  18466. v := m.addstatus
  18467. if v == nil {
  18468. return
  18469. }
  18470. return *v, true
  18471. }
  18472. // ClearStatus clears the value of the "status" field.
  18473. func (m *WxMutation) ClearStatus() {
  18474. m.status = nil
  18475. m.addstatus = nil
  18476. m.clearedFields[wx.FieldStatus] = struct{}{}
  18477. }
  18478. // StatusCleared returns if the "status" field was cleared in this mutation.
  18479. func (m *WxMutation) StatusCleared() bool {
  18480. _, ok := m.clearedFields[wx.FieldStatus]
  18481. return ok
  18482. }
  18483. // ResetStatus resets all changes to the "status" field.
  18484. func (m *WxMutation) ResetStatus() {
  18485. m.status = nil
  18486. m.addstatus = nil
  18487. delete(m.clearedFields, wx.FieldStatus)
  18488. }
  18489. // SetDeletedAt sets the "deleted_at" field.
  18490. func (m *WxMutation) SetDeletedAt(t time.Time) {
  18491. m.deleted_at = &t
  18492. }
  18493. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18494. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  18495. v := m.deleted_at
  18496. if v == nil {
  18497. return
  18498. }
  18499. return *v, true
  18500. }
  18501. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  18502. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18504. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18505. if !m.op.Is(OpUpdateOne) {
  18506. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18507. }
  18508. if m.id == nil || m.oldValue == nil {
  18509. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18510. }
  18511. oldValue, err := m.oldValue(ctx)
  18512. if err != nil {
  18513. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18514. }
  18515. return oldValue.DeletedAt, nil
  18516. }
  18517. // ClearDeletedAt clears the value of the "deleted_at" field.
  18518. func (m *WxMutation) ClearDeletedAt() {
  18519. m.deleted_at = nil
  18520. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  18521. }
  18522. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18523. func (m *WxMutation) DeletedAtCleared() bool {
  18524. _, ok := m.clearedFields[wx.FieldDeletedAt]
  18525. return ok
  18526. }
  18527. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18528. func (m *WxMutation) ResetDeletedAt() {
  18529. m.deleted_at = nil
  18530. delete(m.clearedFields, wx.FieldDeletedAt)
  18531. }
  18532. // SetServerID sets the "server_id" field.
  18533. func (m *WxMutation) SetServerID(u uint64) {
  18534. m.server = &u
  18535. }
  18536. // ServerID returns the value of the "server_id" field in the mutation.
  18537. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  18538. v := m.server
  18539. if v == nil {
  18540. return
  18541. }
  18542. return *v, true
  18543. }
  18544. // OldServerID returns the old "server_id" field's value of the Wx entity.
  18545. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18546. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18547. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  18548. if !m.op.Is(OpUpdateOne) {
  18549. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  18550. }
  18551. if m.id == nil || m.oldValue == nil {
  18552. return v, errors.New("OldServerID requires an ID field in the mutation")
  18553. }
  18554. oldValue, err := m.oldValue(ctx)
  18555. if err != nil {
  18556. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  18557. }
  18558. return oldValue.ServerID, nil
  18559. }
  18560. // ClearServerID clears the value of the "server_id" field.
  18561. func (m *WxMutation) ClearServerID() {
  18562. m.server = nil
  18563. m.clearedFields[wx.FieldServerID] = struct{}{}
  18564. }
  18565. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  18566. func (m *WxMutation) ServerIDCleared() bool {
  18567. _, ok := m.clearedFields[wx.FieldServerID]
  18568. return ok
  18569. }
  18570. // ResetServerID resets all changes to the "server_id" field.
  18571. func (m *WxMutation) ResetServerID() {
  18572. m.server = nil
  18573. delete(m.clearedFields, wx.FieldServerID)
  18574. }
  18575. // SetPort sets the "port" field.
  18576. func (m *WxMutation) SetPort(s string) {
  18577. m.port = &s
  18578. }
  18579. // Port returns the value of the "port" field in the mutation.
  18580. func (m *WxMutation) Port() (r string, exists bool) {
  18581. v := m.port
  18582. if v == nil {
  18583. return
  18584. }
  18585. return *v, true
  18586. }
  18587. // OldPort returns the old "port" field's value of the Wx entity.
  18588. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18590. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  18591. if !m.op.Is(OpUpdateOne) {
  18592. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  18593. }
  18594. if m.id == nil || m.oldValue == nil {
  18595. return v, errors.New("OldPort requires an ID field in the mutation")
  18596. }
  18597. oldValue, err := m.oldValue(ctx)
  18598. if err != nil {
  18599. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  18600. }
  18601. return oldValue.Port, nil
  18602. }
  18603. // ResetPort resets all changes to the "port" field.
  18604. func (m *WxMutation) ResetPort() {
  18605. m.port = nil
  18606. }
  18607. // SetProcessID sets the "process_id" field.
  18608. func (m *WxMutation) SetProcessID(s string) {
  18609. m.process_id = &s
  18610. }
  18611. // ProcessID returns the value of the "process_id" field in the mutation.
  18612. func (m *WxMutation) ProcessID() (r string, exists bool) {
  18613. v := m.process_id
  18614. if v == nil {
  18615. return
  18616. }
  18617. return *v, true
  18618. }
  18619. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  18620. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18622. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  18623. if !m.op.Is(OpUpdateOne) {
  18624. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  18625. }
  18626. if m.id == nil || m.oldValue == nil {
  18627. return v, errors.New("OldProcessID requires an ID field in the mutation")
  18628. }
  18629. oldValue, err := m.oldValue(ctx)
  18630. if err != nil {
  18631. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  18632. }
  18633. return oldValue.ProcessID, nil
  18634. }
  18635. // ResetProcessID resets all changes to the "process_id" field.
  18636. func (m *WxMutation) ResetProcessID() {
  18637. m.process_id = nil
  18638. }
  18639. // SetCallback sets the "callback" field.
  18640. func (m *WxMutation) SetCallback(s string) {
  18641. m.callback = &s
  18642. }
  18643. // Callback returns the value of the "callback" field in the mutation.
  18644. func (m *WxMutation) Callback() (r string, exists bool) {
  18645. v := m.callback
  18646. if v == nil {
  18647. return
  18648. }
  18649. return *v, true
  18650. }
  18651. // OldCallback returns the old "callback" field's value of the Wx entity.
  18652. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18654. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  18655. if !m.op.Is(OpUpdateOne) {
  18656. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  18657. }
  18658. if m.id == nil || m.oldValue == nil {
  18659. return v, errors.New("OldCallback requires an ID field in the mutation")
  18660. }
  18661. oldValue, err := m.oldValue(ctx)
  18662. if err != nil {
  18663. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  18664. }
  18665. return oldValue.Callback, nil
  18666. }
  18667. // ResetCallback resets all changes to the "callback" field.
  18668. func (m *WxMutation) ResetCallback() {
  18669. m.callback = nil
  18670. }
  18671. // SetWxid sets the "wxid" field.
  18672. func (m *WxMutation) SetWxid(s string) {
  18673. m.wxid = &s
  18674. }
  18675. // Wxid returns the value of the "wxid" field in the mutation.
  18676. func (m *WxMutation) Wxid() (r string, exists bool) {
  18677. v := m.wxid
  18678. if v == nil {
  18679. return
  18680. }
  18681. return *v, true
  18682. }
  18683. // OldWxid returns the old "wxid" field's value of the Wx entity.
  18684. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18686. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  18687. if !m.op.Is(OpUpdateOne) {
  18688. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  18689. }
  18690. if m.id == nil || m.oldValue == nil {
  18691. return v, errors.New("OldWxid requires an ID field in the mutation")
  18692. }
  18693. oldValue, err := m.oldValue(ctx)
  18694. if err != nil {
  18695. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  18696. }
  18697. return oldValue.Wxid, nil
  18698. }
  18699. // ResetWxid resets all changes to the "wxid" field.
  18700. func (m *WxMutation) ResetWxid() {
  18701. m.wxid = nil
  18702. }
  18703. // SetAccount sets the "account" field.
  18704. func (m *WxMutation) SetAccount(s string) {
  18705. m.account = &s
  18706. }
  18707. // Account returns the value of the "account" field in the mutation.
  18708. func (m *WxMutation) Account() (r string, exists bool) {
  18709. v := m.account
  18710. if v == nil {
  18711. return
  18712. }
  18713. return *v, true
  18714. }
  18715. // OldAccount returns the old "account" field's value of the Wx entity.
  18716. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18718. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  18719. if !m.op.Is(OpUpdateOne) {
  18720. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  18721. }
  18722. if m.id == nil || m.oldValue == nil {
  18723. return v, errors.New("OldAccount requires an ID field in the mutation")
  18724. }
  18725. oldValue, err := m.oldValue(ctx)
  18726. if err != nil {
  18727. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  18728. }
  18729. return oldValue.Account, nil
  18730. }
  18731. // ResetAccount resets all changes to the "account" field.
  18732. func (m *WxMutation) ResetAccount() {
  18733. m.account = nil
  18734. }
  18735. // SetNickname sets the "nickname" field.
  18736. func (m *WxMutation) SetNickname(s string) {
  18737. m.nickname = &s
  18738. }
  18739. // Nickname returns the value of the "nickname" field in the mutation.
  18740. func (m *WxMutation) Nickname() (r string, exists bool) {
  18741. v := m.nickname
  18742. if v == nil {
  18743. return
  18744. }
  18745. return *v, true
  18746. }
  18747. // OldNickname returns the old "nickname" field's value of the Wx entity.
  18748. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18750. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  18751. if !m.op.Is(OpUpdateOne) {
  18752. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  18753. }
  18754. if m.id == nil || m.oldValue == nil {
  18755. return v, errors.New("OldNickname requires an ID field in the mutation")
  18756. }
  18757. oldValue, err := m.oldValue(ctx)
  18758. if err != nil {
  18759. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  18760. }
  18761. return oldValue.Nickname, nil
  18762. }
  18763. // ResetNickname resets all changes to the "nickname" field.
  18764. func (m *WxMutation) ResetNickname() {
  18765. m.nickname = nil
  18766. }
  18767. // SetTel sets the "tel" field.
  18768. func (m *WxMutation) SetTel(s string) {
  18769. m.tel = &s
  18770. }
  18771. // Tel returns the value of the "tel" field in the mutation.
  18772. func (m *WxMutation) Tel() (r string, exists bool) {
  18773. v := m.tel
  18774. if v == nil {
  18775. return
  18776. }
  18777. return *v, true
  18778. }
  18779. // OldTel returns the old "tel" field's value of the Wx entity.
  18780. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18782. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  18783. if !m.op.Is(OpUpdateOne) {
  18784. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  18785. }
  18786. if m.id == nil || m.oldValue == nil {
  18787. return v, errors.New("OldTel requires an ID field in the mutation")
  18788. }
  18789. oldValue, err := m.oldValue(ctx)
  18790. if err != nil {
  18791. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  18792. }
  18793. return oldValue.Tel, nil
  18794. }
  18795. // ResetTel resets all changes to the "tel" field.
  18796. func (m *WxMutation) ResetTel() {
  18797. m.tel = nil
  18798. }
  18799. // SetHeadBig sets the "head_big" field.
  18800. func (m *WxMutation) SetHeadBig(s string) {
  18801. m.head_big = &s
  18802. }
  18803. // HeadBig returns the value of the "head_big" field in the mutation.
  18804. func (m *WxMutation) HeadBig() (r string, exists bool) {
  18805. v := m.head_big
  18806. if v == nil {
  18807. return
  18808. }
  18809. return *v, true
  18810. }
  18811. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  18812. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18814. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  18815. if !m.op.Is(OpUpdateOne) {
  18816. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  18817. }
  18818. if m.id == nil || m.oldValue == nil {
  18819. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  18820. }
  18821. oldValue, err := m.oldValue(ctx)
  18822. if err != nil {
  18823. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  18824. }
  18825. return oldValue.HeadBig, nil
  18826. }
  18827. // ResetHeadBig resets all changes to the "head_big" field.
  18828. func (m *WxMutation) ResetHeadBig() {
  18829. m.head_big = nil
  18830. }
  18831. // SetOrganizationID sets the "organization_id" field.
  18832. func (m *WxMutation) SetOrganizationID(u uint64) {
  18833. m.organization_id = &u
  18834. m.addorganization_id = nil
  18835. }
  18836. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18837. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  18838. v := m.organization_id
  18839. if v == nil {
  18840. return
  18841. }
  18842. return *v, true
  18843. }
  18844. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  18845. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18847. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18848. if !m.op.Is(OpUpdateOne) {
  18849. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18850. }
  18851. if m.id == nil || m.oldValue == nil {
  18852. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18853. }
  18854. oldValue, err := m.oldValue(ctx)
  18855. if err != nil {
  18856. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18857. }
  18858. return oldValue.OrganizationID, nil
  18859. }
  18860. // AddOrganizationID adds u to the "organization_id" field.
  18861. func (m *WxMutation) AddOrganizationID(u int64) {
  18862. if m.addorganization_id != nil {
  18863. *m.addorganization_id += u
  18864. } else {
  18865. m.addorganization_id = &u
  18866. }
  18867. }
  18868. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18869. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  18870. v := m.addorganization_id
  18871. if v == nil {
  18872. return
  18873. }
  18874. return *v, true
  18875. }
  18876. // ClearOrganizationID clears the value of the "organization_id" field.
  18877. func (m *WxMutation) ClearOrganizationID() {
  18878. m.organization_id = nil
  18879. m.addorganization_id = nil
  18880. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  18881. }
  18882. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18883. func (m *WxMutation) OrganizationIDCleared() bool {
  18884. _, ok := m.clearedFields[wx.FieldOrganizationID]
  18885. return ok
  18886. }
  18887. // ResetOrganizationID resets all changes to the "organization_id" field.
  18888. func (m *WxMutation) ResetOrganizationID() {
  18889. m.organization_id = nil
  18890. m.addorganization_id = nil
  18891. delete(m.clearedFields, wx.FieldOrganizationID)
  18892. }
  18893. // SetAgentID sets the "agent_id" field.
  18894. func (m *WxMutation) SetAgentID(u uint64) {
  18895. m.agent = &u
  18896. }
  18897. // AgentID returns the value of the "agent_id" field in the mutation.
  18898. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  18899. v := m.agent
  18900. if v == nil {
  18901. return
  18902. }
  18903. return *v, true
  18904. }
  18905. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  18906. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18908. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  18909. if !m.op.Is(OpUpdateOne) {
  18910. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  18911. }
  18912. if m.id == nil || m.oldValue == nil {
  18913. return v, errors.New("OldAgentID requires an ID field in the mutation")
  18914. }
  18915. oldValue, err := m.oldValue(ctx)
  18916. if err != nil {
  18917. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  18918. }
  18919. return oldValue.AgentID, nil
  18920. }
  18921. // ResetAgentID resets all changes to the "agent_id" field.
  18922. func (m *WxMutation) ResetAgentID() {
  18923. m.agent = nil
  18924. }
  18925. // SetAPIBase sets the "api_base" field.
  18926. func (m *WxMutation) SetAPIBase(s string) {
  18927. m.api_base = &s
  18928. }
  18929. // APIBase returns the value of the "api_base" field in the mutation.
  18930. func (m *WxMutation) APIBase() (r string, exists bool) {
  18931. v := m.api_base
  18932. if v == nil {
  18933. return
  18934. }
  18935. return *v, true
  18936. }
  18937. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  18938. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18940. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  18941. if !m.op.Is(OpUpdateOne) {
  18942. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  18943. }
  18944. if m.id == nil || m.oldValue == nil {
  18945. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  18946. }
  18947. oldValue, err := m.oldValue(ctx)
  18948. if err != nil {
  18949. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  18950. }
  18951. return oldValue.APIBase, nil
  18952. }
  18953. // ClearAPIBase clears the value of the "api_base" field.
  18954. func (m *WxMutation) ClearAPIBase() {
  18955. m.api_base = nil
  18956. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  18957. }
  18958. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  18959. func (m *WxMutation) APIBaseCleared() bool {
  18960. _, ok := m.clearedFields[wx.FieldAPIBase]
  18961. return ok
  18962. }
  18963. // ResetAPIBase resets all changes to the "api_base" field.
  18964. func (m *WxMutation) ResetAPIBase() {
  18965. m.api_base = nil
  18966. delete(m.clearedFields, wx.FieldAPIBase)
  18967. }
  18968. // SetAPIKey sets the "api_key" field.
  18969. func (m *WxMutation) SetAPIKey(s string) {
  18970. m.api_key = &s
  18971. }
  18972. // APIKey returns the value of the "api_key" field in the mutation.
  18973. func (m *WxMutation) APIKey() (r string, exists bool) {
  18974. v := m.api_key
  18975. if v == nil {
  18976. return
  18977. }
  18978. return *v, true
  18979. }
  18980. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  18981. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18983. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  18984. if !m.op.Is(OpUpdateOne) {
  18985. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  18986. }
  18987. if m.id == nil || m.oldValue == nil {
  18988. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  18989. }
  18990. oldValue, err := m.oldValue(ctx)
  18991. if err != nil {
  18992. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  18993. }
  18994. return oldValue.APIKey, nil
  18995. }
  18996. // ClearAPIKey clears the value of the "api_key" field.
  18997. func (m *WxMutation) ClearAPIKey() {
  18998. m.api_key = nil
  18999. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  19000. }
  19001. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  19002. func (m *WxMutation) APIKeyCleared() bool {
  19003. _, ok := m.clearedFields[wx.FieldAPIKey]
  19004. return ok
  19005. }
  19006. // ResetAPIKey resets all changes to the "api_key" field.
  19007. func (m *WxMutation) ResetAPIKey() {
  19008. m.api_key = nil
  19009. delete(m.clearedFields, wx.FieldAPIKey)
  19010. }
  19011. // ClearServer clears the "server" edge to the Server entity.
  19012. func (m *WxMutation) ClearServer() {
  19013. m.clearedserver = true
  19014. m.clearedFields[wx.FieldServerID] = struct{}{}
  19015. }
  19016. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  19017. func (m *WxMutation) ServerCleared() bool {
  19018. return m.ServerIDCleared() || m.clearedserver
  19019. }
  19020. // ServerIDs returns the "server" edge IDs in the mutation.
  19021. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19022. // ServerID instead. It exists only for internal usage by the builders.
  19023. func (m *WxMutation) ServerIDs() (ids []uint64) {
  19024. if id := m.server; id != nil {
  19025. ids = append(ids, *id)
  19026. }
  19027. return
  19028. }
  19029. // ResetServer resets all changes to the "server" edge.
  19030. func (m *WxMutation) ResetServer() {
  19031. m.server = nil
  19032. m.clearedserver = false
  19033. }
  19034. // ClearAgent clears the "agent" edge to the Agent entity.
  19035. func (m *WxMutation) ClearAgent() {
  19036. m.clearedagent = true
  19037. m.clearedFields[wx.FieldAgentID] = struct{}{}
  19038. }
  19039. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  19040. func (m *WxMutation) AgentCleared() bool {
  19041. return m.clearedagent
  19042. }
  19043. // AgentIDs returns the "agent" edge IDs in the mutation.
  19044. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19045. // AgentID instead. It exists only for internal usage by the builders.
  19046. func (m *WxMutation) AgentIDs() (ids []uint64) {
  19047. if id := m.agent; id != nil {
  19048. ids = append(ids, *id)
  19049. }
  19050. return
  19051. }
  19052. // ResetAgent resets all changes to the "agent" edge.
  19053. func (m *WxMutation) ResetAgent() {
  19054. m.agent = nil
  19055. m.clearedagent = false
  19056. }
  19057. // Where appends a list predicates to the WxMutation builder.
  19058. func (m *WxMutation) Where(ps ...predicate.Wx) {
  19059. m.predicates = append(m.predicates, ps...)
  19060. }
  19061. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  19062. // users can use type-assertion to append predicates that do not depend on any generated package.
  19063. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  19064. p := make([]predicate.Wx, len(ps))
  19065. for i := range ps {
  19066. p[i] = ps[i]
  19067. }
  19068. m.Where(p...)
  19069. }
  19070. // Op returns the operation name.
  19071. func (m *WxMutation) Op() Op {
  19072. return m.op
  19073. }
  19074. // SetOp allows setting the mutation operation.
  19075. func (m *WxMutation) SetOp(op Op) {
  19076. m.op = op
  19077. }
  19078. // Type returns the node type of this mutation (Wx).
  19079. func (m *WxMutation) Type() string {
  19080. return m.typ
  19081. }
  19082. // Fields returns all fields that were changed during this mutation. Note that in
  19083. // order to get all numeric fields that were incremented/decremented, call
  19084. // AddedFields().
  19085. func (m *WxMutation) Fields() []string {
  19086. fields := make([]string, 0, 17)
  19087. if m.created_at != nil {
  19088. fields = append(fields, wx.FieldCreatedAt)
  19089. }
  19090. if m.updated_at != nil {
  19091. fields = append(fields, wx.FieldUpdatedAt)
  19092. }
  19093. if m.status != nil {
  19094. fields = append(fields, wx.FieldStatus)
  19095. }
  19096. if m.deleted_at != nil {
  19097. fields = append(fields, wx.FieldDeletedAt)
  19098. }
  19099. if m.server != nil {
  19100. fields = append(fields, wx.FieldServerID)
  19101. }
  19102. if m.port != nil {
  19103. fields = append(fields, wx.FieldPort)
  19104. }
  19105. if m.process_id != nil {
  19106. fields = append(fields, wx.FieldProcessID)
  19107. }
  19108. if m.callback != nil {
  19109. fields = append(fields, wx.FieldCallback)
  19110. }
  19111. if m.wxid != nil {
  19112. fields = append(fields, wx.FieldWxid)
  19113. }
  19114. if m.account != nil {
  19115. fields = append(fields, wx.FieldAccount)
  19116. }
  19117. if m.nickname != nil {
  19118. fields = append(fields, wx.FieldNickname)
  19119. }
  19120. if m.tel != nil {
  19121. fields = append(fields, wx.FieldTel)
  19122. }
  19123. if m.head_big != nil {
  19124. fields = append(fields, wx.FieldHeadBig)
  19125. }
  19126. if m.organization_id != nil {
  19127. fields = append(fields, wx.FieldOrganizationID)
  19128. }
  19129. if m.agent != nil {
  19130. fields = append(fields, wx.FieldAgentID)
  19131. }
  19132. if m.api_base != nil {
  19133. fields = append(fields, wx.FieldAPIBase)
  19134. }
  19135. if m.api_key != nil {
  19136. fields = append(fields, wx.FieldAPIKey)
  19137. }
  19138. return fields
  19139. }
  19140. // Field returns the value of a field with the given name. The second boolean
  19141. // return value indicates that this field was not set, or was not defined in the
  19142. // schema.
  19143. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  19144. switch name {
  19145. case wx.FieldCreatedAt:
  19146. return m.CreatedAt()
  19147. case wx.FieldUpdatedAt:
  19148. return m.UpdatedAt()
  19149. case wx.FieldStatus:
  19150. return m.Status()
  19151. case wx.FieldDeletedAt:
  19152. return m.DeletedAt()
  19153. case wx.FieldServerID:
  19154. return m.ServerID()
  19155. case wx.FieldPort:
  19156. return m.Port()
  19157. case wx.FieldProcessID:
  19158. return m.ProcessID()
  19159. case wx.FieldCallback:
  19160. return m.Callback()
  19161. case wx.FieldWxid:
  19162. return m.Wxid()
  19163. case wx.FieldAccount:
  19164. return m.Account()
  19165. case wx.FieldNickname:
  19166. return m.Nickname()
  19167. case wx.FieldTel:
  19168. return m.Tel()
  19169. case wx.FieldHeadBig:
  19170. return m.HeadBig()
  19171. case wx.FieldOrganizationID:
  19172. return m.OrganizationID()
  19173. case wx.FieldAgentID:
  19174. return m.AgentID()
  19175. case wx.FieldAPIBase:
  19176. return m.APIBase()
  19177. case wx.FieldAPIKey:
  19178. return m.APIKey()
  19179. }
  19180. return nil, false
  19181. }
  19182. // OldField returns the old value of the field from the database. An error is
  19183. // returned if the mutation operation is not UpdateOne, or the query to the
  19184. // database failed.
  19185. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19186. switch name {
  19187. case wx.FieldCreatedAt:
  19188. return m.OldCreatedAt(ctx)
  19189. case wx.FieldUpdatedAt:
  19190. return m.OldUpdatedAt(ctx)
  19191. case wx.FieldStatus:
  19192. return m.OldStatus(ctx)
  19193. case wx.FieldDeletedAt:
  19194. return m.OldDeletedAt(ctx)
  19195. case wx.FieldServerID:
  19196. return m.OldServerID(ctx)
  19197. case wx.FieldPort:
  19198. return m.OldPort(ctx)
  19199. case wx.FieldProcessID:
  19200. return m.OldProcessID(ctx)
  19201. case wx.FieldCallback:
  19202. return m.OldCallback(ctx)
  19203. case wx.FieldWxid:
  19204. return m.OldWxid(ctx)
  19205. case wx.FieldAccount:
  19206. return m.OldAccount(ctx)
  19207. case wx.FieldNickname:
  19208. return m.OldNickname(ctx)
  19209. case wx.FieldTel:
  19210. return m.OldTel(ctx)
  19211. case wx.FieldHeadBig:
  19212. return m.OldHeadBig(ctx)
  19213. case wx.FieldOrganizationID:
  19214. return m.OldOrganizationID(ctx)
  19215. case wx.FieldAgentID:
  19216. return m.OldAgentID(ctx)
  19217. case wx.FieldAPIBase:
  19218. return m.OldAPIBase(ctx)
  19219. case wx.FieldAPIKey:
  19220. return m.OldAPIKey(ctx)
  19221. }
  19222. return nil, fmt.Errorf("unknown Wx field %s", name)
  19223. }
  19224. // SetField sets the value of a field with the given name. It returns an error if
  19225. // the field is not defined in the schema, or if the type mismatched the field
  19226. // type.
  19227. func (m *WxMutation) SetField(name string, value ent.Value) error {
  19228. switch name {
  19229. case wx.FieldCreatedAt:
  19230. v, ok := value.(time.Time)
  19231. if !ok {
  19232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19233. }
  19234. m.SetCreatedAt(v)
  19235. return nil
  19236. case wx.FieldUpdatedAt:
  19237. v, ok := value.(time.Time)
  19238. if !ok {
  19239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19240. }
  19241. m.SetUpdatedAt(v)
  19242. return nil
  19243. case wx.FieldStatus:
  19244. v, ok := value.(uint8)
  19245. if !ok {
  19246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19247. }
  19248. m.SetStatus(v)
  19249. return nil
  19250. case wx.FieldDeletedAt:
  19251. v, ok := value.(time.Time)
  19252. if !ok {
  19253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19254. }
  19255. m.SetDeletedAt(v)
  19256. return nil
  19257. case wx.FieldServerID:
  19258. v, ok := value.(uint64)
  19259. if !ok {
  19260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19261. }
  19262. m.SetServerID(v)
  19263. return nil
  19264. case wx.FieldPort:
  19265. v, ok := value.(string)
  19266. if !ok {
  19267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19268. }
  19269. m.SetPort(v)
  19270. return nil
  19271. case wx.FieldProcessID:
  19272. v, ok := value.(string)
  19273. if !ok {
  19274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19275. }
  19276. m.SetProcessID(v)
  19277. return nil
  19278. case wx.FieldCallback:
  19279. v, ok := value.(string)
  19280. if !ok {
  19281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19282. }
  19283. m.SetCallback(v)
  19284. return nil
  19285. case wx.FieldWxid:
  19286. v, ok := value.(string)
  19287. if !ok {
  19288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19289. }
  19290. m.SetWxid(v)
  19291. return nil
  19292. case wx.FieldAccount:
  19293. v, ok := value.(string)
  19294. if !ok {
  19295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19296. }
  19297. m.SetAccount(v)
  19298. return nil
  19299. case wx.FieldNickname:
  19300. v, ok := value.(string)
  19301. if !ok {
  19302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19303. }
  19304. m.SetNickname(v)
  19305. return nil
  19306. case wx.FieldTel:
  19307. v, ok := value.(string)
  19308. if !ok {
  19309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19310. }
  19311. m.SetTel(v)
  19312. return nil
  19313. case wx.FieldHeadBig:
  19314. v, ok := value.(string)
  19315. if !ok {
  19316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19317. }
  19318. m.SetHeadBig(v)
  19319. return nil
  19320. case wx.FieldOrganizationID:
  19321. v, ok := value.(uint64)
  19322. if !ok {
  19323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19324. }
  19325. m.SetOrganizationID(v)
  19326. return nil
  19327. case wx.FieldAgentID:
  19328. v, ok := value.(uint64)
  19329. if !ok {
  19330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19331. }
  19332. m.SetAgentID(v)
  19333. return nil
  19334. case wx.FieldAPIBase:
  19335. v, ok := value.(string)
  19336. if !ok {
  19337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19338. }
  19339. m.SetAPIBase(v)
  19340. return nil
  19341. case wx.FieldAPIKey:
  19342. v, ok := value.(string)
  19343. if !ok {
  19344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19345. }
  19346. m.SetAPIKey(v)
  19347. return nil
  19348. }
  19349. return fmt.Errorf("unknown Wx field %s", name)
  19350. }
  19351. // AddedFields returns all numeric fields that were incremented/decremented during
  19352. // this mutation.
  19353. func (m *WxMutation) AddedFields() []string {
  19354. var fields []string
  19355. if m.addstatus != nil {
  19356. fields = append(fields, wx.FieldStatus)
  19357. }
  19358. if m.addorganization_id != nil {
  19359. fields = append(fields, wx.FieldOrganizationID)
  19360. }
  19361. return fields
  19362. }
  19363. // AddedField returns the numeric value that was incremented/decremented on a field
  19364. // with the given name. The second boolean return value indicates that this field
  19365. // was not set, or was not defined in the schema.
  19366. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  19367. switch name {
  19368. case wx.FieldStatus:
  19369. return m.AddedStatus()
  19370. case wx.FieldOrganizationID:
  19371. return m.AddedOrganizationID()
  19372. }
  19373. return nil, false
  19374. }
  19375. // AddField adds the value to the field with the given name. It returns an error if
  19376. // the field is not defined in the schema, or if the type mismatched the field
  19377. // type.
  19378. func (m *WxMutation) AddField(name string, value ent.Value) error {
  19379. switch name {
  19380. case wx.FieldStatus:
  19381. v, ok := value.(int8)
  19382. if !ok {
  19383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19384. }
  19385. m.AddStatus(v)
  19386. return nil
  19387. case wx.FieldOrganizationID:
  19388. v, ok := value.(int64)
  19389. if !ok {
  19390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19391. }
  19392. m.AddOrganizationID(v)
  19393. return nil
  19394. }
  19395. return fmt.Errorf("unknown Wx numeric field %s", name)
  19396. }
  19397. // ClearedFields returns all nullable fields that were cleared during this
  19398. // mutation.
  19399. func (m *WxMutation) ClearedFields() []string {
  19400. var fields []string
  19401. if m.FieldCleared(wx.FieldStatus) {
  19402. fields = append(fields, wx.FieldStatus)
  19403. }
  19404. if m.FieldCleared(wx.FieldDeletedAt) {
  19405. fields = append(fields, wx.FieldDeletedAt)
  19406. }
  19407. if m.FieldCleared(wx.FieldServerID) {
  19408. fields = append(fields, wx.FieldServerID)
  19409. }
  19410. if m.FieldCleared(wx.FieldOrganizationID) {
  19411. fields = append(fields, wx.FieldOrganizationID)
  19412. }
  19413. if m.FieldCleared(wx.FieldAPIBase) {
  19414. fields = append(fields, wx.FieldAPIBase)
  19415. }
  19416. if m.FieldCleared(wx.FieldAPIKey) {
  19417. fields = append(fields, wx.FieldAPIKey)
  19418. }
  19419. return fields
  19420. }
  19421. // FieldCleared returns a boolean indicating if a field with the given name was
  19422. // cleared in this mutation.
  19423. func (m *WxMutation) FieldCleared(name string) bool {
  19424. _, ok := m.clearedFields[name]
  19425. return ok
  19426. }
  19427. // ClearField clears the value of the field with the given name. It returns an
  19428. // error if the field is not defined in the schema.
  19429. func (m *WxMutation) ClearField(name string) error {
  19430. switch name {
  19431. case wx.FieldStatus:
  19432. m.ClearStatus()
  19433. return nil
  19434. case wx.FieldDeletedAt:
  19435. m.ClearDeletedAt()
  19436. return nil
  19437. case wx.FieldServerID:
  19438. m.ClearServerID()
  19439. return nil
  19440. case wx.FieldOrganizationID:
  19441. m.ClearOrganizationID()
  19442. return nil
  19443. case wx.FieldAPIBase:
  19444. m.ClearAPIBase()
  19445. return nil
  19446. case wx.FieldAPIKey:
  19447. m.ClearAPIKey()
  19448. return nil
  19449. }
  19450. return fmt.Errorf("unknown Wx nullable field %s", name)
  19451. }
  19452. // ResetField resets all changes in the mutation for the field with the given name.
  19453. // It returns an error if the field is not defined in the schema.
  19454. func (m *WxMutation) ResetField(name string) error {
  19455. switch name {
  19456. case wx.FieldCreatedAt:
  19457. m.ResetCreatedAt()
  19458. return nil
  19459. case wx.FieldUpdatedAt:
  19460. m.ResetUpdatedAt()
  19461. return nil
  19462. case wx.FieldStatus:
  19463. m.ResetStatus()
  19464. return nil
  19465. case wx.FieldDeletedAt:
  19466. m.ResetDeletedAt()
  19467. return nil
  19468. case wx.FieldServerID:
  19469. m.ResetServerID()
  19470. return nil
  19471. case wx.FieldPort:
  19472. m.ResetPort()
  19473. return nil
  19474. case wx.FieldProcessID:
  19475. m.ResetProcessID()
  19476. return nil
  19477. case wx.FieldCallback:
  19478. m.ResetCallback()
  19479. return nil
  19480. case wx.FieldWxid:
  19481. m.ResetWxid()
  19482. return nil
  19483. case wx.FieldAccount:
  19484. m.ResetAccount()
  19485. return nil
  19486. case wx.FieldNickname:
  19487. m.ResetNickname()
  19488. return nil
  19489. case wx.FieldTel:
  19490. m.ResetTel()
  19491. return nil
  19492. case wx.FieldHeadBig:
  19493. m.ResetHeadBig()
  19494. return nil
  19495. case wx.FieldOrganizationID:
  19496. m.ResetOrganizationID()
  19497. return nil
  19498. case wx.FieldAgentID:
  19499. m.ResetAgentID()
  19500. return nil
  19501. case wx.FieldAPIBase:
  19502. m.ResetAPIBase()
  19503. return nil
  19504. case wx.FieldAPIKey:
  19505. m.ResetAPIKey()
  19506. return nil
  19507. }
  19508. return fmt.Errorf("unknown Wx field %s", name)
  19509. }
  19510. // AddedEdges returns all edge names that were set/added in this mutation.
  19511. func (m *WxMutation) AddedEdges() []string {
  19512. edges := make([]string, 0, 2)
  19513. if m.server != nil {
  19514. edges = append(edges, wx.EdgeServer)
  19515. }
  19516. if m.agent != nil {
  19517. edges = append(edges, wx.EdgeAgent)
  19518. }
  19519. return edges
  19520. }
  19521. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19522. // name in this mutation.
  19523. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  19524. switch name {
  19525. case wx.EdgeServer:
  19526. if id := m.server; id != nil {
  19527. return []ent.Value{*id}
  19528. }
  19529. case wx.EdgeAgent:
  19530. if id := m.agent; id != nil {
  19531. return []ent.Value{*id}
  19532. }
  19533. }
  19534. return nil
  19535. }
  19536. // RemovedEdges returns all edge names that were removed in this mutation.
  19537. func (m *WxMutation) RemovedEdges() []string {
  19538. edges := make([]string, 0, 2)
  19539. return edges
  19540. }
  19541. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19542. // the given name in this mutation.
  19543. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  19544. return nil
  19545. }
  19546. // ClearedEdges returns all edge names that were cleared in this mutation.
  19547. func (m *WxMutation) ClearedEdges() []string {
  19548. edges := make([]string, 0, 2)
  19549. if m.clearedserver {
  19550. edges = append(edges, wx.EdgeServer)
  19551. }
  19552. if m.clearedagent {
  19553. edges = append(edges, wx.EdgeAgent)
  19554. }
  19555. return edges
  19556. }
  19557. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19558. // was cleared in this mutation.
  19559. func (m *WxMutation) EdgeCleared(name string) bool {
  19560. switch name {
  19561. case wx.EdgeServer:
  19562. return m.clearedserver
  19563. case wx.EdgeAgent:
  19564. return m.clearedagent
  19565. }
  19566. return false
  19567. }
  19568. // ClearEdge clears the value of the edge with the given name. It returns an error
  19569. // if that edge is not defined in the schema.
  19570. func (m *WxMutation) ClearEdge(name string) error {
  19571. switch name {
  19572. case wx.EdgeServer:
  19573. m.ClearServer()
  19574. return nil
  19575. case wx.EdgeAgent:
  19576. m.ClearAgent()
  19577. return nil
  19578. }
  19579. return fmt.Errorf("unknown Wx unique edge %s", name)
  19580. }
  19581. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19582. // It returns an error if the edge is not defined in the schema.
  19583. func (m *WxMutation) ResetEdge(name string) error {
  19584. switch name {
  19585. case wx.EdgeServer:
  19586. m.ResetServer()
  19587. return nil
  19588. case wx.EdgeAgent:
  19589. m.ResetAgent()
  19590. return nil
  19591. }
  19592. return fmt.Errorf("unknown Wx edge %s", name)
  19593. }