mutation.go 643 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/batchmsg"
  11. "wechat-api/ent/category"
  12. "wechat-api/ent/contact"
  13. "wechat-api/ent/custom_types"
  14. "wechat-api/ent/employee"
  15. "wechat-api/ent/employeeconfig"
  16. "wechat-api/ent/label"
  17. "wechat-api/ent/labelrelationship"
  18. "wechat-api/ent/message"
  19. "wechat-api/ent/messagerecords"
  20. "wechat-api/ent/msg"
  21. "wechat-api/ent/predicate"
  22. "wechat-api/ent/server"
  23. "wechat-api/ent/sopnode"
  24. "wechat-api/ent/sopstage"
  25. "wechat-api/ent/soptask"
  26. "wechat-api/ent/token"
  27. "wechat-api/ent/tutorial"
  28. "wechat-api/ent/workexperience"
  29. "wechat-api/ent/wx"
  30. "entgo.io/ent"
  31. "entgo.io/ent/dialect/sql"
  32. )
  33. const (
  34. // Operation types.
  35. OpCreate = ent.OpCreate
  36. OpDelete = ent.OpDelete
  37. OpDeleteOne = ent.OpDeleteOne
  38. OpUpdate = ent.OpUpdate
  39. OpUpdateOne = ent.OpUpdateOne
  40. // Node types.
  41. TypeAgent = "Agent"
  42. TypeBatchMsg = "BatchMsg"
  43. TypeCategory = "Category"
  44. TypeContact = "Contact"
  45. TypeEmployee = "Employee"
  46. TypeEmployeeConfig = "EmployeeConfig"
  47. TypeLabel = "Label"
  48. TypeLabelRelationship = "LabelRelationship"
  49. TypeMessage = "Message"
  50. TypeMessageRecords = "MessageRecords"
  51. TypeMsg = "Msg"
  52. TypeServer = "Server"
  53. TypeSopNode = "SopNode"
  54. TypeSopStage = "SopStage"
  55. TypeSopTask = "SopTask"
  56. TypeToken = "Token"
  57. TypeTutorial = "Tutorial"
  58. TypeWorkExperience = "WorkExperience"
  59. TypeWx = "Wx"
  60. )
  61. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  62. type AgentMutation struct {
  63. config
  64. op Op
  65. typ string
  66. id *uint64
  67. created_at *time.Time
  68. updated_at *time.Time
  69. deleted_at *time.Time
  70. name *string
  71. role *string
  72. status *int
  73. addstatus *int
  74. background *string
  75. examples *string
  76. organization_id *uint64
  77. addorganization_id *int64
  78. dataset_id *string
  79. collection_id *string
  80. clearedFields map[string]struct{}
  81. wx_agent map[uint64]struct{}
  82. removedwx_agent map[uint64]struct{}
  83. clearedwx_agent bool
  84. done bool
  85. oldValue func(context.Context) (*Agent, error)
  86. predicates []predicate.Agent
  87. }
  88. var _ ent.Mutation = (*AgentMutation)(nil)
  89. // agentOption allows management of the mutation configuration using functional options.
  90. type agentOption func(*AgentMutation)
  91. // newAgentMutation creates new mutation for the Agent entity.
  92. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  93. m := &AgentMutation{
  94. config: c,
  95. op: op,
  96. typ: TypeAgent,
  97. clearedFields: make(map[string]struct{}),
  98. }
  99. for _, opt := range opts {
  100. opt(m)
  101. }
  102. return m
  103. }
  104. // withAgentID sets the ID field of the mutation.
  105. func withAgentID(id uint64) agentOption {
  106. return func(m *AgentMutation) {
  107. var (
  108. err error
  109. once sync.Once
  110. value *Agent
  111. )
  112. m.oldValue = func(ctx context.Context) (*Agent, error) {
  113. once.Do(func() {
  114. if m.done {
  115. err = errors.New("querying old values post mutation is not allowed")
  116. } else {
  117. value, err = m.Client().Agent.Get(ctx, id)
  118. }
  119. })
  120. return value, err
  121. }
  122. m.id = &id
  123. }
  124. }
  125. // withAgent sets the old Agent of the mutation.
  126. func withAgent(node *Agent) agentOption {
  127. return func(m *AgentMutation) {
  128. m.oldValue = func(context.Context) (*Agent, error) {
  129. return node, nil
  130. }
  131. m.id = &node.ID
  132. }
  133. }
  134. // Client returns a new `ent.Client` from the mutation. If the mutation was
  135. // executed in a transaction (ent.Tx), a transactional client is returned.
  136. func (m AgentMutation) Client() *Client {
  137. client := &Client{config: m.config}
  138. client.init()
  139. return client
  140. }
  141. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  142. // it returns an error otherwise.
  143. func (m AgentMutation) Tx() (*Tx, error) {
  144. if _, ok := m.driver.(*txDriver); !ok {
  145. return nil, errors.New("ent: mutation is not running in a transaction")
  146. }
  147. tx := &Tx{config: m.config}
  148. tx.init()
  149. return tx, nil
  150. }
  151. // SetID sets the value of the id field. Note that this
  152. // operation is only accepted on creation of Agent entities.
  153. func (m *AgentMutation) SetID(id uint64) {
  154. m.id = &id
  155. }
  156. // ID returns the ID value in the mutation. Note that the ID is only available
  157. // if it was provided to the builder or after it was returned from the database.
  158. func (m *AgentMutation) ID() (id uint64, exists bool) {
  159. if m.id == nil {
  160. return
  161. }
  162. return *m.id, true
  163. }
  164. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  165. // That means, if the mutation is applied within a transaction with an isolation level such
  166. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  167. // or updated by the mutation.
  168. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  169. switch {
  170. case m.op.Is(OpUpdateOne | OpDeleteOne):
  171. id, exists := m.ID()
  172. if exists {
  173. return []uint64{id}, nil
  174. }
  175. fallthrough
  176. case m.op.Is(OpUpdate | OpDelete):
  177. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  178. default:
  179. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  180. }
  181. }
  182. // SetCreatedAt sets the "created_at" field.
  183. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  184. m.created_at = &t
  185. }
  186. // CreatedAt returns the value of the "created_at" field in the mutation.
  187. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  188. v := m.created_at
  189. if v == nil {
  190. return
  191. }
  192. return *v, true
  193. }
  194. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  195. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  197. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  198. if !m.op.Is(OpUpdateOne) {
  199. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  200. }
  201. if m.id == nil || m.oldValue == nil {
  202. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  203. }
  204. oldValue, err := m.oldValue(ctx)
  205. if err != nil {
  206. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  207. }
  208. return oldValue.CreatedAt, nil
  209. }
  210. // ResetCreatedAt resets all changes to the "created_at" field.
  211. func (m *AgentMutation) ResetCreatedAt() {
  212. m.created_at = nil
  213. }
  214. // SetUpdatedAt sets the "updated_at" field.
  215. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  216. m.updated_at = &t
  217. }
  218. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  219. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  220. v := m.updated_at
  221. if v == nil {
  222. return
  223. }
  224. return *v, true
  225. }
  226. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  227. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  229. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  230. if !m.op.Is(OpUpdateOne) {
  231. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  232. }
  233. if m.id == nil || m.oldValue == nil {
  234. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  235. }
  236. oldValue, err := m.oldValue(ctx)
  237. if err != nil {
  238. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  239. }
  240. return oldValue.UpdatedAt, nil
  241. }
  242. // ResetUpdatedAt resets all changes to the "updated_at" field.
  243. func (m *AgentMutation) ResetUpdatedAt() {
  244. m.updated_at = nil
  245. }
  246. // SetDeletedAt sets the "deleted_at" field.
  247. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  248. m.deleted_at = &t
  249. }
  250. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  251. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  252. v := m.deleted_at
  253. if v == nil {
  254. return
  255. }
  256. return *v, true
  257. }
  258. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  259. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  261. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  262. if !m.op.Is(OpUpdateOne) {
  263. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  264. }
  265. if m.id == nil || m.oldValue == nil {
  266. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  267. }
  268. oldValue, err := m.oldValue(ctx)
  269. if err != nil {
  270. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  271. }
  272. return oldValue.DeletedAt, nil
  273. }
  274. // ClearDeletedAt clears the value of the "deleted_at" field.
  275. func (m *AgentMutation) ClearDeletedAt() {
  276. m.deleted_at = nil
  277. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  278. }
  279. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  280. func (m *AgentMutation) DeletedAtCleared() bool {
  281. _, ok := m.clearedFields[agent.FieldDeletedAt]
  282. return ok
  283. }
  284. // ResetDeletedAt resets all changes to the "deleted_at" field.
  285. func (m *AgentMutation) ResetDeletedAt() {
  286. m.deleted_at = nil
  287. delete(m.clearedFields, agent.FieldDeletedAt)
  288. }
  289. // SetName sets the "name" field.
  290. func (m *AgentMutation) SetName(s string) {
  291. m.name = &s
  292. }
  293. // Name returns the value of the "name" field in the mutation.
  294. func (m *AgentMutation) Name() (r string, exists bool) {
  295. v := m.name
  296. if v == nil {
  297. return
  298. }
  299. return *v, true
  300. }
  301. // OldName returns the old "name" field's value of the Agent entity.
  302. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  304. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  305. if !m.op.Is(OpUpdateOne) {
  306. return v, errors.New("OldName is only allowed on UpdateOne operations")
  307. }
  308. if m.id == nil || m.oldValue == nil {
  309. return v, errors.New("OldName requires an ID field in the mutation")
  310. }
  311. oldValue, err := m.oldValue(ctx)
  312. if err != nil {
  313. return v, fmt.Errorf("querying old value for OldName: %w", err)
  314. }
  315. return oldValue.Name, nil
  316. }
  317. // ResetName resets all changes to the "name" field.
  318. func (m *AgentMutation) ResetName() {
  319. m.name = nil
  320. }
  321. // SetRole sets the "role" field.
  322. func (m *AgentMutation) SetRole(s string) {
  323. m.role = &s
  324. }
  325. // Role returns the value of the "role" field in the mutation.
  326. func (m *AgentMutation) Role() (r string, exists bool) {
  327. v := m.role
  328. if v == nil {
  329. return
  330. }
  331. return *v, true
  332. }
  333. // OldRole returns the old "role" field's value of the Agent entity.
  334. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  336. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  337. if !m.op.Is(OpUpdateOne) {
  338. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  339. }
  340. if m.id == nil || m.oldValue == nil {
  341. return v, errors.New("OldRole requires an ID field in the mutation")
  342. }
  343. oldValue, err := m.oldValue(ctx)
  344. if err != nil {
  345. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  346. }
  347. return oldValue.Role, nil
  348. }
  349. // ResetRole resets all changes to the "role" field.
  350. func (m *AgentMutation) ResetRole() {
  351. m.role = nil
  352. }
  353. // SetStatus sets the "status" field.
  354. func (m *AgentMutation) SetStatus(i int) {
  355. m.status = &i
  356. m.addstatus = nil
  357. }
  358. // Status returns the value of the "status" field in the mutation.
  359. func (m *AgentMutation) Status() (r int, exists bool) {
  360. v := m.status
  361. if v == nil {
  362. return
  363. }
  364. return *v, true
  365. }
  366. // OldStatus returns the old "status" field's value of the Agent entity.
  367. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  369. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  370. if !m.op.Is(OpUpdateOne) {
  371. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  372. }
  373. if m.id == nil || m.oldValue == nil {
  374. return v, errors.New("OldStatus requires an ID field in the mutation")
  375. }
  376. oldValue, err := m.oldValue(ctx)
  377. if err != nil {
  378. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  379. }
  380. return oldValue.Status, nil
  381. }
  382. // AddStatus adds i to the "status" field.
  383. func (m *AgentMutation) AddStatus(i int) {
  384. if m.addstatus != nil {
  385. *m.addstatus += i
  386. } else {
  387. m.addstatus = &i
  388. }
  389. }
  390. // AddedStatus returns the value that was added to the "status" field in this mutation.
  391. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  392. v := m.addstatus
  393. if v == nil {
  394. return
  395. }
  396. return *v, true
  397. }
  398. // ClearStatus clears the value of the "status" field.
  399. func (m *AgentMutation) ClearStatus() {
  400. m.status = nil
  401. m.addstatus = nil
  402. m.clearedFields[agent.FieldStatus] = struct{}{}
  403. }
  404. // StatusCleared returns if the "status" field was cleared in this mutation.
  405. func (m *AgentMutation) StatusCleared() bool {
  406. _, ok := m.clearedFields[agent.FieldStatus]
  407. return ok
  408. }
  409. // ResetStatus resets all changes to the "status" field.
  410. func (m *AgentMutation) ResetStatus() {
  411. m.status = nil
  412. m.addstatus = nil
  413. delete(m.clearedFields, agent.FieldStatus)
  414. }
  415. // SetBackground sets the "background" field.
  416. func (m *AgentMutation) SetBackground(s string) {
  417. m.background = &s
  418. }
  419. // Background returns the value of the "background" field in the mutation.
  420. func (m *AgentMutation) Background() (r string, exists bool) {
  421. v := m.background
  422. if v == nil {
  423. return
  424. }
  425. return *v, true
  426. }
  427. // OldBackground returns the old "background" field's value of the Agent entity.
  428. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  430. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  431. if !m.op.Is(OpUpdateOne) {
  432. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  433. }
  434. if m.id == nil || m.oldValue == nil {
  435. return v, errors.New("OldBackground requires an ID field in the mutation")
  436. }
  437. oldValue, err := m.oldValue(ctx)
  438. if err != nil {
  439. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  440. }
  441. return oldValue.Background, nil
  442. }
  443. // ClearBackground clears the value of the "background" field.
  444. func (m *AgentMutation) ClearBackground() {
  445. m.background = nil
  446. m.clearedFields[agent.FieldBackground] = struct{}{}
  447. }
  448. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  449. func (m *AgentMutation) BackgroundCleared() bool {
  450. _, ok := m.clearedFields[agent.FieldBackground]
  451. return ok
  452. }
  453. // ResetBackground resets all changes to the "background" field.
  454. func (m *AgentMutation) ResetBackground() {
  455. m.background = nil
  456. delete(m.clearedFields, agent.FieldBackground)
  457. }
  458. // SetExamples sets the "examples" field.
  459. func (m *AgentMutation) SetExamples(s string) {
  460. m.examples = &s
  461. }
  462. // Examples returns the value of the "examples" field in the mutation.
  463. func (m *AgentMutation) Examples() (r string, exists bool) {
  464. v := m.examples
  465. if v == nil {
  466. return
  467. }
  468. return *v, true
  469. }
  470. // OldExamples returns the old "examples" field's value of the Agent entity.
  471. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  473. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  474. if !m.op.Is(OpUpdateOne) {
  475. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  476. }
  477. if m.id == nil || m.oldValue == nil {
  478. return v, errors.New("OldExamples requires an ID field in the mutation")
  479. }
  480. oldValue, err := m.oldValue(ctx)
  481. if err != nil {
  482. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  483. }
  484. return oldValue.Examples, nil
  485. }
  486. // ClearExamples clears the value of the "examples" field.
  487. func (m *AgentMutation) ClearExamples() {
  488. m.examples = nil
  489. m.clearedFields[agent.FieldExamples] = struct{}{}
  490. }
  491. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  492. func (m *AgentMutation) ExamplesCleared() bool {
  493. _, ok := m.clearedFields[agent.FieldExamples]
  494. return ok
  495. }
  496. // ResetExamples resets all changes to the "examples" field.
  497. func (m *AgentMutation) ResetExamples() {
  498. m.examples = nil
  499. delete(m.clearedFields, agent.FieldExamples)
  500. }
  501. // SetOrganizationID sets the "organization_id" field.
  502. func (m *AgentMutation) SetOrganizationID(u uint64) {
  503. m.organization_id = &u
  504. m.addorganization_id = nil
  505. }
  506. // OrganizationID returns the value of the "organization_id" field in the mutation.
  507. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  508. v := m.organization_id
  509. if v == nil {
  510. return
  511. }
  512. return *v, true
  513. }
  514. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  515. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  516. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  517. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  518. if !m.op.Is(OpUpdateOne) {
  519. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  520. }
  521. if m.id == nil || m.oldValue == nil {
  522. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  523. }
  524. oldValue, err := m.oldValue(ctx)
  525. if err != nil {
  526. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  527. }
  528. return oldValue.OrganizationID, nil
  529. }
  530. // AddOrganizationID adds u to the "organization_id" field.
  531. func (m *AgentMutation) AddOrganizationID(u int64) {
  532. if m.addorganization_id != nil {
  533. *m.addorganization_id += u
  534. } else {
  535. m.addorganization_id = &u
  536. }
  537. }
  538. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  539. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  540. v := m.addorganization_id
  541. if v == nil {
  542. return
  543. }
  544. return *v, true
  545. }
  546. // ResetOrganizationID resets all changes to the "organization_id" field.
  547. func (m *AgentMutation) ResetOrganizationID() {
  548. m.organization_id = nil
  549. m.addorganization_id = nil
  550. }
  551. // SetDatasetID sets the "dataset_id" field.
  552. func (m *AgentMutation) SetDatasetID(s string) {
  553. m.dataset_id = &s
  554. }
  555. // DatasetID returns the value of the "dataset_id" field in the mutation.
  556. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  557. v := m.dataset_id
  558. if v == nil {
  559. return
  560. }
  561. return *v, true
  562. }
  563. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  564. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  566. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  567. if !m.op.Is(OpUpdateOne) {
  568. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  569. }
  570. if m.id == nil || m.oldValue == nil {
  571. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  572. }
  573. oldValue, err := m.oldValue(ctx)
  574. if err != nil {
  575. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  576. }
  577. return oldValue.DatasetID, nil
  578. }
  579. // ResetDatasetID resets all changes to the "dataset_id" field.
  580. func (m *AgentMutation) ResetDatasetID() {
  581. m.dataset_id = nil
  582. }
  583. // SetCollectionID sets the "collection_id" field.
  584. func (m *AgentMutation) SetCollectionID(s string) {
  585. m.collection_id = &s
  586. }
  587. // CollectionID returns the value of the "collection_id" field in the mutation.
  588. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  589. v := m.collection_id
  590. if v == nil {
  591. return
  592. }
  593. return *v, true
  594. }
  595. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  596. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  598. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  599. if !m.op.Is(OpUpdateOne) {
  600. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  601. }
  602. if m.id == nil || m.oldValue == nil {
  603. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  604. }
  605. oldValue, err := m.oldValue(ctx)
  606. if err != nil {
  607. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  608. }
  609. return oldValue.CollectionID, nil
  610. }
  611. // ResetCollectionID resets all changes to the "collection_id" field.
  612. func (m *AgentMutation) ResetCollectionID() {
  613. m.collection_id = nil
  614. }
  615. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  616. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  617. if m.wx_agent == nil {
  618. m.wx_agent = make(map[uint64]struct{})
  619. }
  620. for i := range ids {
  621. m.wx_agent[ids[i]] = struct{}{}
  622. }
  623. }
  624. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  625. func (m *AgentMutation) ClearWxAgent() {
  626. m.clearedwx_agent = true
  627. }
  628. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  629. func (m *AgentMutation) WxAgentCleared() bool {
  630. return m.clearedwx_agent
  631. }
  632. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  633. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  634. if m.removedwx_agent == nil {
  635. m.removedwx_agent = make(map[uint64]struct{})
  636. }
  637. for i := range ids {
  638. delete(m.wx_agent, ids[i])
  639. m.removedwx_agent[ids[i]] = struct{}{}
  640. }
  641. }
  642. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  643. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  644. for id := range m.removedwx_agent {
  645. ids = append(ids, id)
  646. }
  647. return
  648. }
  649. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  650. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  651. for id := range m.wx_agent {
  652. ids = append(ids, id)
  653. }
  654. return
  655. }
  656. // ResetWxAgent resets all changes to the "wx_agent" edge.
  657. func (m *AgentMutation) ResetWxAgent() {
  658. m.wx_agent = nil
  659. m.clearedwx_agent = false
  660. m.removedwx_agent = nil
  661. }
  662. // Where appends a list predicates to the AgentMutation builder.
  663. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  664. m.predicates = append(m.predicates, ps...)
  665. }
  666. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  667. // users can use type-assertion to append predicates that do not depend on any generated package.
  668. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  669. p := make([]predicate.Agent, len(ps))
  670. for i := range ps {
  671. p[i] = ps[i]
  672. }
  673. m.Where(p...)
  674. }
  675. // Op returns the operation name.
  676. func (m *AgentMutation) Op() Op {
  677. return m.op
  678. }
  679. // SetOp allows setting the mutation operation.
  680. func (m *AgentMutation) SetOp(op Op) {
  681. m.op = op
  682. }
  683. // Type returns the node type of this mutation (Agent).
  684. func (m *AgentMutation) Type() string {
  685. return m.typ
  686. }
  687. // Fields returns all fields that were changed during this mutation. Note that in
  688. // order to get all numeric fields that were incremented/decremented, call
  689. // AddedFields().
  690. func (m *AgentMutation) Fields() []string {
  691. fields := make([]string, 0, 11)
  692. if m.created_at != nil {
  693. fields = append(fields, agent.FieldCreatedAt)
  694. }
  695. if m.updated_at != nil {
  696. fields = append(fields, agent.FieldUpdatedAt)
  697. }
  698. if m.deleted_at != nil {
  699. fields = append(fields, agent.FieldDeletedAt)
  700. }
  701. if m.name != nil {
  702. fields = append(fields, agent.FieldName)
  703. }
  704. if m.role != nil {
  705. fields = append(fields, agent.FieldRole)
  706. }
  707. if m.status != nil {
  708. fields = append(fields, agent.FieldStatus)
  709. }
  710. if m.background != nil {
  711. fields = append(fields, agent.FieldBackground)
  712. }
  713. if m.examples != nil {
  714. fields = append(fields, agent.FieldExamples)
  715. }
  716. if m.organization_id != nil {
  717. fields = append(fields, agent.FieldOrganizationID)
  718. }
  719. if m.dataset_id != nil {
  720. fields = append(fields, agent.FieldDatasetID)
  721. }
  722. if m.collection_id != nil {
  723. fields = append(fields, agent.FieldCollectionID)
  724. }
  725. return fields
  726. }
  727. // Field returns the value of a field with the given name. The second boolean
  728. // return value indicates that this field was not set, or was not defined in the
  729. // schema.
  730. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  731. switch name {
  732. case agent.FieldCreatedAt:
  733. return m.CreatedAt()
  734. case agent.FieldUpdatedAt:
  735. return m.UpdatedAt()
  736. case agent.FieldDeletedAt:
  737. return m.DeletedAt()
  738. case agent.FieldName:
  739. return m.Name()
  740. case agent.FieldRole:
  741. return m.Role()
  742. case agent.FieldStatus:
  743. return m.Status()
  744. case agent.FieldBackground:
  745. return m.Background()
  746. case agent.FieldExamples:
  747. return m.Examples()
  748. case agent.FieldOrganizationID:
  749. return m.OrganizationID()
  750. case agent.FieldDatasetID:
  751. return m.DatasetID()
  752. case agent.FieldCollectionID:
  753. return m.CollectionID()
  754. }
  755. return nil, false
  756. }
  757. // OldField returns the old value of the field from the database. An error is
  758. // returned if the mutation operation is not UpdateOne, or the query to the
  759. // database failed.
  760. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  761. switch name {
  762. case agent.FieldCreatedAt:
  763. return m.OldCreatedAt(ctx)
  764. case agent.FieldUpdatedAt:
  765. return m.OldUpdatedAt(ctx)
  766. case agent.FieldDeletedAt:
  767. return m.OldDeletedAt(ctx)
  768. case agent.FieldName:
  769. return m.OldName(ctx)
  770. case agent.FieldRole:
  771. return m.OldRole(ctx)
  772. case agent.FieldStatus:
  773. return m.OldStatus(ctx)
  774. case agent.FieldBackground:
  775. return m.OldBackground(ctx)
  776. case agent.FieldExamples:
  777. return m.OldExamples(ctx)
  778. case agent.FieldOrganizationID:
  779. return m.OldOrganizationID(ctx)
  780. case agent.FieldDatasetID:
  781. return m.OldDatasetID(ctx)
  782. case agent.FieldCollectionID:
  783. return m.OldCollectionID(ctx)
  784. }
  785. return nil, fmt.Errorf("unknown Agent field %s", name)
  786. }
  787. // SetField sets the value of a field with the given name. It returns an error if
  788. // the field is not defined in the schema, or if the type mismatched the field
  789. // type.
  790. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  791. switch name {
  792. case agent.FieldCreatedAt:
  793. v, ok := value.(time.Time)
  794. if !ok {
  795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  796. }
  797. m.SetCreatedAt(v)
  798. return nil
  799. case agent.FieldUpdatedAt:
  800. v, ok := value.(time.Time)
  801. if !ok {
  802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  803. }
  804. m.SetUpdatedAt(v)
  805. return nil
  806. case agent.FieldDeletedAt:
  807. v, ok := value.(time.Time)
  808. if !ok {
  809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  810. }
  811. m.SetDeletedAt(v)
  812. return nil
  813. case agent.FieldName:
  814. v, ok := value.(string)
  815. if !ok {
  816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  817. }
  818. m.SetName(v)
  819. return nil
  820. case agent.FieldRole:
  821. v, ok := value.(string)
  822. if !ok {
  823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  824. }
  825. m.SetRole(v)
  826. return nil
  827. case agent.FieldStatus:
  828. v, ok := value.(int)
  829. if !ok {
  830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  831. }
  832. m.SetStatus(v)
  833. return nil
  834. case agent.FieldBackground:
  835. v, ok := value.(string)
  836. if !ok {
  837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  838. }
  839. m.SetBackground(v)
  840. return nil
  841. case agent.FieldExamples:
  842. v, ok := value.(string)
  843. if !ok {
  844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  845. }
  846. m.SetExamples(v)
  847. return nil
  848. case agent.FieldOrganizationID:
  849. v, ok := value.(uint64)
  850. if !ok {
  851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  852. }
  853. m.SetOrganizationID(v)
  854. return nil
  855. case agent.FieldDatasetID:
  856. v, ok := value.(string)
  857. if !ok {
  858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  859. }
  860. m.SetDatasetID(v)
  861. return nil
  862. case agent.FieldCollectionID:
  863. v, ok := value.(string)
  864. if !ok {
  865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  866. }
  867. m.SetCollectionID(v)
  868. return nil
  869. }
  870. return fmt.Errorf("unknown Agent field %s", name)
  871. }
  872. // AddedFields returns all numeric fields that were incremented/decremented during
  873. // this mutation.
  874. func (m *AgentMutation) AddedFields() []string {
  875. var fields []string
  876. if m.addstatus != nil {
  877. fields = append(fields, agent.FieldStatus)
  878. }
  879. if m.addorganization_id != nil {
  880. fields = append(fields, agent.FieldOrganizationID)
  881. }
  882. return fields
  883. }
  884. // AddedField returns the numeric value that was incremented/decremented on a field
  885. // with the given name. The second boolean return value indicates that this field
  886. // was not set, or was not defined in the schema.
  887. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  888. switch name {
  889. case agent.FieldStatus:
  890. return m.AddedStatus()
  891. case agent.FieldOrganizationID:
  892. return m.AddedOrganizationID()
  893. }
  894. return nil, false
  895. }
  896. // AddField adds the value to the field with the given name. It returns an error if
  897. // the field is not defined in the schema, or if the type mismatched the field
  898. // type.
  899. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  900. switch name {
  901. case agent.FieldStatus:
  902. v, ok := value.(int)
  903. if !ok {
  904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  905. }
  906. m.AddStatus(v)
  907. return nil
  908. case agent.FieldOrganizationID:
  909. v, ok := value.(int64)
  910. if !ok {
  911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  912. }
  913. m.AddOrganizationID(v)
  914. return nil
  915. }
  916. return fmt.Errorf("unknown Agent numeric field %s", name)
  917. }
  918. // ClearedFields returns all nullable fields that were cleared during this
  919. // mutation.
  920. func (m *AgentMutation) ClearedFields() []string {
  921. var fields []string
  922. if m.FieldCleared(agent.FieldDeletedAt) {
  923. fields = append(fields, agent.FieldDeletedAt)
  924. }
  925. if m.FieldCleared(agent.FieldStatus) {
  926. fields = append(fields, agent.FieldStatus)
  927. }
  928. if m.FieldCleared(agent.FieldBackground) {
  929. fields = append(fields, agent.FieldBackground)
  930. }
  931. if m.FieldCleared(agent.FieldExamples) {
  932. fields = append(fields, agent.FieldExamples)
  933. }
  934. return fields
  935. }
  936. // FieldCleared returns a boolean indicating if a field with the given name was
  937. // cleared in this mutation.
  938. func (m *AgentMutation) FieldCleared(name string) bool {
  939. _, ok := m.clearedFields[name]
  940. return ok
  941. }
  942. // ClearField clears the value of the field with the given name. It returns an
  943. // error if the field is not defined in the schema.
  944. func (m *AgentMutation) ClearField(name string) error {
  945. switch name {
  946. case agent.FieldDeletedAt:
  947. m.ClearDeletedAt()
  948. return nil
  949. case agent.FieldStatus:
  950. m.ClearStatus()
  951. return nil
  952. case agent.FieldBackground:
  953. m.ClearBackground()
  954. return nil
  955. case agent.FieldExamples:
  956. m.ClearExamples()
  957. return nil
  958. }
  959. return fmt.Errorf("unknown Agent nullable field %s", name)
  960. }
  961. // ResetField resets all changes in the mutation for the field with the given name.
  962. // It returns an error if the field is not defined in the schema.
  963. func (m *AgentMutation) ResetField(name string) error {
  964. switch name {
  965. case agent.FieldCreatedAt:
  966. m.ResetCreatedAt()
  967. return nil
  968. case agent.FieldUpdatedAt:
  969. m.ResetUpdatedAt()
  970. return nil
  971. case agent.FieldDeletedAt:
  972. m.ResetDeletedAt()
  973. return nil
  974. case agent.FieldName:
  975. m.ResetName()
  976. return nil
  977. case agent.FieldRole:
  978. m.ResetRole()
  979. return nil
  980. case agent.FieldStatus:
  981. m.ResetStatus()
  982. return nil
  983. case agent.FieldBackground:
  984. m.ResetBackground()
  985. return nil
  986. case agent.FieldExamples:
  987. m.ResetExamples()
  988. return nil
  989. case agent.FieldOrganizationID:
  990. m.ResetOrganizationID()
  991. return nil
  992. case agent.FieldDatasetID:
  993. m.ResetDatasetID()
  994. return nil
  995. case agent.FieldCollectionID:
  996. m.ResetCollectionID()
  997. return nil
  998. }
  999. return fmt.Errorf("unknown Agent field %s", name)
  1000. }
  1001. // AddedEdges returns all edge names that were set/added in this mutation.
  1002. func (m *AgentMutation) AddedEdges() []string {
  1003. edges := make([]string, 0, 1)
  1004. if m.wx_agent != nil {
  1005. edges = append(edges, agent.EdgeWxAgent)
  1006. }
  1007. return edges
  1008. }
  1009. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1010. // name in this mutation.
  1011. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1012. switch name {
  1013. case agent.EdgeWxAgent:
  1014. ids := make([]ent.Value, 0, len(m.wx_agent))
  1015. for id := range m.wx_agent {
  1016. ids = append(ids, id)
  1017. }
  1018. return ids
  1019. }
  1020. return nil
  1021. }
  1022. // RemovedEdges returns all edge names that were removed in this mutation.
  1023. func (m *AgentMutation) RemovedEdges() []string {
  1024. edges := make([]string, 0, 1)
  1025. if m.removedwx_agent != nil {
  1026. edges = append(edges, agent.EdgeWxAgent)
  1027. }
  1028. return edges
  1029. }
  1030. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1031. // the given name in this mutation.
  1032. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1033. switch name {
  1034. case agent.EdgeWxAgent:
  1035. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1036. for id := range m.removedwx_agent {
  1037. ids = append(ids, id)
  1038. }
  1039. return ids
  1040. }
  1041. return nil
  1042. }
  1043. // ClearedEdges returns all edge names that were cleared in this mutation.
  1044. func (m *AgentMutation) ClearedEdges() []string {
  1045. edges := make([]string, 0, 1)
  1046. if m.clearedwx_agent {
  1047. edges = append(edges, agent.EdgeWxAgent)
  1048. }
  1049. return edges
  1050. }
  1051. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1052. // was cleared in this mutation.
  1053. func (m *AgentMutation) EdgeCleared(name string) bool {
  1054. switch name {
  1055. case agent.EdgeWxAgent:
  1056. return m.clearedwx_agent
  1057. }
  1058. return false
  1059. }
  1060. // ClearEdge clears the value of the edge with the given name. It returns an error
  1061. // if that edge is not defined in the schema.
  1062. func (m *AgentMutation) ClearEdge(name string) error {
  1063. switch name {
  1064. }
  1065. return fmt.Errorf("unknown Agent unique edge %s", name)
  1066. }
  1067. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1068. // It returns an error if the edge is not defined in the schema.
  1069. func (m *AgentMutation) ResetEdge(name string) error {
  1070. switch name {
  1071. case agent.EdgeWxAgent:
  1072. m.ResetWxAgent()
  1073. return nil
  1074. }
  1075. return fmt.Errorf("unknown Agent edge %s", name)
  1076. }
  1077. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  1078. type BatchMsgMutation struct {
  1079. config
  1080. op Op
  1081. typ string
  1082. id *uint64
  1083. created_at *time.Time
  1084. updated_at *time.Time
  1085. deleted_at *time.Time
  1086. status *uint8
  1087. addstatus *int8
  1088. batch_no *string
  1089. task_name *string
  1090. fromwxid *string
  1091. msg *string
  1092. tag *string
  1093. tagids *string
  1094. total *int32
  1095. addtotal *int32
  1096. success *int32
  1097. addsuccess *int32
  1098. fail *int32
  1099. addfail *int32
  1100. start_time *time.Time
  1101. stop_time *time.Time
  1102. send_time *time.Time
  1103. _type *int32
  1104. add_type *int32
  1105. organization_id *uint64
  1106. addorganization_id *int64
  1107. clearedFields map[string]struct{}
  1108. done bool
  1109. oldValue func(context.Context) (*BatchMsg, error)
  1110. predicates []predicate.BatchMsg
  1111. }
  1112. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  1113. // batchmsgOption allows management of the mutation configuration using functional options.
  1114. type batchmsgOption func(*BatchMsgMutation)
  1115. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  1116. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  1117. m := &BatchMsgMutation{
  1118. config: c,
  1119. op: op,
  1120. typ: TypeBatchMsg,
  1121. clearedFields: make(map[string]struct{}),
  1122. }
  1123. for _, opt := range opts {
  1124. opt(m)
  1125. }
  1126. return m
  1127. }
  1128. // withBatchMsgID sets the ID field of the mutation.
  1129. func withBatchMsgID(id uint64) batchmsgOption {
  1130. return func(m *BatchMsgMutation) {
  1131. var (
  1132. err error
  1133. once sync.Once
  1134. value *BatchMsg
  1135. )
  1136. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  1137. once.Do(func() {
  1138. if m.done {
  1139. err = errors.New("querying old values post mutation is not allowed")
  1140. } else {
  1141. value, err = m.Client().BatchMsg.Get(ctx, id)
  1142. }
  1143. })
  1144. return value, err
  1145. }
  1146. m.id = &id
  1147. }
  1148. }
  1149. // withBatchMsg sets the old BatchMsg of the mutation.
  1150. func withBatchMsg(node *BatchMsg) batchmsgOption {
  1151. return func(m *BatchMsgMutation) {
  1152. m.oldValue = func(context.Context) (*BatchMsg, error) {
  1153. return node, nil
  1154. }
  1155. m.id = &node.ID
  1156. }
  1157. }
  1158. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1159. // executed in a transaction (ent.Tx), a transactional client is returned.
  1160. func (m BatchMsgMutation) Client() *Client {
  1161. client := &Client{config: m.config}
  1162. client.init()
  1163. return client
  1164. }
  1165. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1166. // it returns an error otherwise.
  1167. func (m BatchMsgMutation) Tx() (*Tx, error) {
  1168. if _, ok := m.driver.(*txDriver); !ok {
  1169. return nil, errors.New("ent: mutation is not running in a transaction")
  1170. }
  1171. tx := &Tx{config: m.config}
  1172. tx.init()
  1173. return tx, nil
  1174. }
  1175. // SetID sets the value of the id field. Note that this
  1176. // operation is only accepted on creation of BatchMsg entities.
  1177. func (m *BatchMsgMutation) SetID(id uint64) {
  1178. m.id = &id
  1179. }
  1180. // ID returns the ID value in the mutation. Note that the ID is only available
  1181. // if it was provided to the builder or after it was returned from the database.
  1182. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  1183. if m.id == nil {
  1184. return
  1185. }
  1186. return *m.id, true
  1187. }
  1188. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1189. // That means, if the mutation is applied within a transaction with an isolation level such
  1190. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1191. // or updated by the mutation.
  1192. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  1193. switch {
  1194. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1195. id, exists := m.ID()
  1196. if exists {
  1197. return []uint64{id}, nil
  1198. }
  1199. fallthrough
  1200. case m.op.Is(OpUpdate | OpDelete):
  1201. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  1202. default:
  1203. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1204. }
  1205. }
  1206. // SetCreatedAt sets the "created_at" field.
  1207. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  1208. m.created_at = &t
  1209. }
  1210. // CreatedAt returns the value of the "created_at" field in the mutation.
  1211. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  1212. v := m.created_at
  1213. if v == nil {
  1214. return
  1215. }
  1216. return *v, true
  1217. }
  1218. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  1219. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1221. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  1222. if !m.op.Is(OpUpdateOne) {
  1223. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  1224. }
  1225. if m.id == nil || m.oldValue == nil {
  1226. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  1227. }
  1228. oldValue, err := m.oldValue(ctx)
  1229. if err != nil {
  1230. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  1231. }
  1232. return oldValue.CreatedAt, nil
  1233. }
  1234. // ResetCreatedAt resets all changes to the "created_at" field.
  1235. func (m *BatchMsgMutation) ResetCreatedAt() {
  1236. m.created_at = nil
  1237. }
  1238. // SetUpdatedAt sets the "updated_at" field.
  1239. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  1240. m.updated_at = &t
  1241. }
  1242. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  1243. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  1244. v := m.updated_at
  1245. if v == nil {
  1246. return
  1247. }
  1248. return *v, true
  1249. }
  1250. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  1251. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1253. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  1254. if !m.op.Is(OpUpdateOne) {
  1255. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  1256. }
  1257. if m.id == nil || m.oldValue == nil {
  1258. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  1259. }
  1260. oldValue, err := m.oldValue(ctx)
  1261. if err != nil {
  1262. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  1263. }
  1264. return oldValue.UpdatedAt, nil
  1265. }
  1266. // ResetUpdatedAt resets all changes to the "updated_at" field.
  1267. func (m *BatchMsgMutation) ResetUpdatedAt() {
  1268. m.updated_at = nil
  1269. }
  1270. // SetDeletedAt sets the "deleted_at" field.
  1271. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  1272. m.deleted_at = &t
  1273. }
  1274. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  1275. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  1276. v := m.deleted_at
  1277. if v == nil {
  1278. return
  1279. }
  1280. return *v, true
  1281. }
  1282. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  1283. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1284. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1285. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  1286. if !m.op.Is(OpUpdateOne) {
  1287. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  1288. }
  1289. if m.id == nil || m.oldValue == nil {
  1290. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  1291. }
  1292. oldValue, err := m.oldValue(ctx)
  1293. if err != nil {
  1294. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  1295. }
  1296. return oldValue.DeletedAt, nil
  1297. }
  1298. // ClearDeletedAt clears the value of the "deleted_at" field.
  1299. func (m *BatchMsgMutation) ClearDeletedAt() {
  1300. m.deleted_at = nil
  1301. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  1302. }
  1303. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  1304. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  1305. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  1306. return ok
  1307. }
  1308. // ResetDeletedAt resets all changes to the "deleted_at" field.
  1309. func (m *BatchMsgMutation) ResetDeletedAt() {
  1310. m.deleted_at = nil
  1311. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  1312. }
  1313. // SetStatus sets the "status" field.
  1314. func (m *BatchMsgMutation) SetStatus(u uint8) {
  1315. m.status = &u
  1316. m.addstatus = nil
  1317. }
  1318. // Status returns the value of the "status" field in the mutation.
  1319. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  1320. v := m.status
  1321. if v == nil {
  1322. return
  1323. }
  1324. return *v, true
  1325. }
  1326. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  1327. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1329. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  1330. if !m.op.Is(OpUpdateOne) {
  1331. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  1332. }
  1333. if m.id == nil || m.oldValue == nil {
  1334. return v, errors.New("OldStatus requires an ID field in the mutation")
  1335. }
  1336. oldValue, err := m.oldValue(ctx)
  1337. if err != nil {
  1338. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  1339. }
  1340. return oldValue.Status, nil
  1341. }
  1342. // AddStatus adds u to the "status" field.
  1343. func (m *BatchMsgMutation) AddStatus(u int8) {
  1344. if m.addstatus != nil {
  1345. *m.addstatus += u
  1346. } else {
  1347. m.addstatus = &u
  1348. }
  1349. }
  1350. // AddedStatus returns the value that was added to the "status" field in this mutation.
  1351. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  1352. v := m.addstatus
  1353. if v == nil {
  1354. return
  1355. }
  1356. return *v, true
  1357. }
  1358. // ClearStatus clears the value of the "status" field.
  1359. func (m *BatchMsgMutation) ClearStatus() {
  1360. m.status = nil
  1361. m.addstatus = nil
  1362. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  1363. }
  1364. // StatusCleared returns if the "status" field was cleared in this mutation.
  1365. func (m *BatchMsgMutation) StatusCleared() bool {
  1366. _, ok := m.clearedFields[batchmsg.FieldStatus]
  1367. return ok
  1368. }
  1369. // ResetStatus resets all changes to the "status" field.
  1370. func (m *BatchMsgMutation) ResetStatus() {
  1371. m.status = nil
  1372. m.addstatus = nil
  1373. delete(m.clearedFields, batchmsg.FieldStatus)
  1374. }
  1375. // SetBatchNo sets the "batch_no" field.
  1376. func (m *BatchMsgMutation) SetBatchNo(s string) {
  1377. m.batch_no = &s
  1378. }
  1379. // BatchNo returns the value of the "batch_no" field in the mutation.
  1380. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  1381. v := m.batch_no
  1382. if v == nil {
  1383. return
  1384. }
  1385. return *v, true
  1386. }
  1387. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  1388. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1390. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  1391. if !m.op.Is(OpUpdateOne) {
  1392. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  1393. }
  1394. if m.id == nil || m.oldValue == nil {
  1395. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  1396. }
  1397. oldValue, err := m.oldValue(ctx)
  1398. if err != nil {
  1399. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  1400. }
  1401. return oldValue.BatchNo, nil
  1402. }
  1403. // ClearBatchNo clears the value of the "batch_no" field.
  1404. func (m *BatchMsgMutation) ClearBatchNo() {
  1405. m.batch_no = nil
  1406. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  1407. }
  1408. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  1409. func (m *BatchMsgMutation) BatchNoCleared() bool {
  1410. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  1411. return ok
  1412. }
  1413. // ResetBatchNo resets all changes to the "batch_no" field.
  1414. func (m *BatchMsgMutation) ResetBatchNo() {
  1415. m.batch_no = nil
  1416. delete(m.clearedFields, batchmsg.FieldBatchNo)
  1417. }
  1418. // SetTaskName sets the "task_name" field.
  1419. func (m *BatchMsgMutation) SetTaskName(s string) {
  1420. m.task_name = &s
  1421. }
  1422. // TaskName returns the value of the "task_name" field in the mutation.
  1423. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  1424. v := m.task_name
  1425. if v == nil {
  1426. return
  1427. }
  1428. return *v, true
  1429. }
  1430. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  1431. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1433. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  1434. if !m.op.Is(OpUpdateOne) {
  1435. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  1436. }
  1437. if m.id == nil || m.oldValue == nil {
  1438. return v, errors.New("OldTaskName requires an ID field in the mutation")
  1439. }
  1440. oldValue, err := m.oldValue(ctx)
  1441. if err != nil {
  1442. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  1443. }
  1444. return oldValue.TaskName, nil
  1445. }
  1446. // ClearTaskName clears the value of the "task_name" field.
  1447. func (m *BatchMsgMutation) ClearTaskName() {
  1448. m.task_name = nil
  1449. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  1450. }
  1451. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  1452. func (m *BatchMsgMutation) TaskNameCleared() bool {
  1453. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  1454. return ok
  1455. }
  1456. // ResetTaskName resets all changes to the "task_name" field.
  1457. func (m *BatchMsgMutation) ResetTaskName() {
  1458. m.task_name = nil
  1459. delete(m.clearedFields, batchmsg.FieldTaskName)
  1460. }
  1461. // SetFromwxid sets the "fromwxid" field.
  1462. func (m *BatchMsgMutation) SetFromwxid(s string) {
  1463. m.fromwxid = &s
  1464. }
  1465. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  1466. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  1467. v := m.fromwxid
  1468. if v == nil {
  1469. return
  1470. }
  1471. return *v, true
  1472. }
  1473. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  1474. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1476. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  1477. if !m.op.Is(OpUpdateOne) {
  1478. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  1479. }
  1480. if m.id == nil || m.oldValue == nil {
  1481. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  1482. }
  1483. oldValue, err := m.oldValue(ctx)
  1484. if err != nil {
  1485. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  1486. }
  1487. return oldValue.Fromwxid, nil
  1488. }
  1489. // ClearFromwxid clears the value of the "fromwxid" field.
  1490. func (m *BatchMsgMutation) ClearFromwxid() {
  1491. m.fromwxid = nil
  1492. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  1493. }
  1494. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  1495. func (m *BatchMsgMutation) FromwxidCleared() bool {
  1496. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  1497. return ok
  1498. }
  1499. // ResetFromwxid resets all changes to the "fromwxid" field.
  1500. func (m *BatchMsgMutation) ResetFromwxid() {
  1501. m.fromwxid = nil
  1502. delete(m.clearedFields, batchmsg.FieldFromwxid)
  1503. }
  1504. // SetMsg sets the "msg" field.
  1505. func (m *BatchMsgMutation) SetMsg(s string) {
  1506. m.msg = &s
  1507. }
  1508. // Msg returns the value of the "msg" field in the mutation.
  1509. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  1510. v := m.msg
  1511. if v == nil {
  1512. return
  1513. }
  1514. return *v, true
  1515. }
  1516. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  1517. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1519. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  1520. if !m.op.Is(OpUpdateOne) {
  1521. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  1522. }
  1523. if m.id == nil || m.oldValue == nil {
  1524. return v, errors.New("OldMsg requires an ID field in the mutation")
  1525. }
  1526. oldValue, err := m.oldValue(ctx)
  1527. if err != nil {
  1528. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  1529. }
  1530. return oldValue.Msg, nil
  1531. }
  1532. // ClearMsg clears the value of the "msg" field.
  1533. func (m *BatchMsgMutation) ClearMsg() {
  1534. m.msg = nil
  1535. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  1536. }
  1537. // MsgCleared returns if the "msg" field was cleared in this mutation.
  1538. func (m *BatchMsgMutation) MsgCleared() bool {
  1539. _, ok := m.clearedFields[batchmsg.FieldMsg]
  1540. return ok
  1541. }
  1542. // ResetMsg resets all changes to the "msg" field.
  1543. func (m *BatchMsgMutation) ResetMsg() {
  1544. m.msg = nil
  1545. delete(m.clearedFields, batchmsg.FieldMsg)
  1546. }
  1547. // SetTag sets the "tag" field.
  1548. func (m *BatchMsgMutation) SetTag(s string) {
  1549. m.tag = &s
  1550. }
  1551. // Tag returns the value of the "tag" field in the mutation.
  1552. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  1553. v := m.tag
  1554. if v == nil {
  1555. return
  1556. }
  1557. return *v, true
  1558. }
  1559. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  1560. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1562. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  1563. if !m.op.Is(OpUpdateOne) {
  1564. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  1565. }
  1566. if m.id == nil || m.oldValue == nil {
  1567. return v, errors.New("OldTag requires an ID field in the mutation")
  1568. }
  1569. oldValue, err := m.oldValue(ctx)
  1570. if err != nil {
  1571. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  1572. }
  1573. return oldValue.Tag, nil
  1574. }
  1575. // ClearTag clears the value of the "tag" field.
  1576. func (m *BatchMsgMutation) ClearTag() {
  1577. m.tag = nil
  1578. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  1579. }
  1580. // TagCleared returns if the "tag" field was cleared in this mutation.
  1581. func (m *BatchMsgMutation) TagCleared() bool {
  1582. _, ok := m.clearedFields[batchmsg.FieldTag]
  1583. return ok
  1584. }
  1585. // ResetTag resets all changes to the "tag" field.
  1586. func (m *BatchMsgMutation) ResetTag() {
  1587. m.tag = nil
  1588. delete(m.clearedFields, batchmsg.FieldTag)
  1589. }
  1590. // SetTagids sets the "tagids" field.
  1591. func (m *BatchMsgMutation) SetTagids(s string) {
  1592. m.tagids = &s
  1593. }
  1594. // Tagids returns the value of the "tagids" field in the mutation.
  1595. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  1596. v := m.tagids
  1597. if v == nil {
  1598. return
  1599. }
  1600. return *v, true
  1601. }
  1602. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  1603. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1605. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  1606. if !m.op.Is(OpUpdateOne) {
  1607. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  1608. }
  1609. if m.id == nil || m.oldValue == nil {
  1610. return v, errors.New("OldTagids requires an ID field in the mutation")
  1611. }
  1612. oldValue, err := m.oldValue(ctx)
  1613. if err != nil {
  1614. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  1615. }
  1616. return oldValue.Tagids, nil
  1617. }
  1618. // ClearTagids clears the value of the "tagids" field.
  1619. func (m *BatchMsgMutation) ClearTagids() {
  1620. m.tagids = nil
  1621. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  1622. }
  1623. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  1624. func (m *BatchMsgMutation) TagidsCleared() bool {
  1625. _, ok := m.clearedFields[batchmsg.FieldTagids]
  1626. return ok
  1627. }
  1628. // ResetTagids resets all changes to the "tagids" field.
  1629. func (m *BatchMsgMutation) ResetTagids() {
  1630. m.tagids = nil
  1631. delete(m.clearedFields, batchmsg.FieldTagids)
  1632. }
  1633. // SetTotal sets the "total" field.
  1634. func (m *BatchMsgMutation) SetTotal(i int32) {
  1635. m.total = &i
  1636. m.addtotal = nil
  1637. }
  1638. // Total returns the value of the "total" field in the mutation.
  1639. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  1640. v := m.total
  1641. if v == nil {
  1642. return
  1643. }
  1644. return *v, true
  1645. }
  1646. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  1647. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1649. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  1650. if !m.op.Is(OpUpdateOne) {
  1651. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  1652. }
  1653. if m.id == nil || m.oldValue == nil {
  1654. return v, errors.New("OldTotal requires an ID field in the mutation")
  1655. }
  1656. oldValue, err := m.oldValue(ctx)
  1657. if err != nil {
  1658. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  1659. }
  1660. return oldValue.Total, nil
  1661. }
  1662. // AddTotal adds i to the "total" field.
  1663. func (m *BatchMsgMutation) AddTotal(i int32) {
  1664. if m.addtotal != nil {
  1665. *m.addtotal += i
  1666. } else {
  1667. m.addtotal = &i
  1668. }
  1669. }
  1670. // AddedTotal returns the value that was added to the "total" field in this mutation.
  1671. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  1672. v := m.addtotal
  1673. if v == nil {
  1674. return
  1675. }
  1676. return *v, true
  1677. }
  1678. // ClearTotal clears the value of the "total" field.
  1679. func (m *BatchMsgMutation) ClearTotal() {
  1680. m.total = nil
  1681. m.addtotal = nil
  1682. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  1683. }
  1684. // TotalCleared returns if the "total" field was cleared in this mutation.
  1685. func (m *BatchMsgMutation) TotalCleared() bool {
  1686. _, ok := m.clearedFields[batchmsg.FieldTotal]
  1687. return ok
  1688. }
  1689. // ResetTotal resets all changes to the "total" field.
  1690. func (m *BatchMsgMutation) ResetTotal() {
  1691. m.total = nil
  1692. m.addtotal = nil
  1693. delete(m.clearedFields, batchmsg.FieldTotal)
  1694. }
  1695. // SetSuccess sets the "success" field.
  1696. func (m *BatchMsgMutation) SetSuccess(i int32) {
  1697. m.success = &i
  1698. m.addsuccess = nil
  1699. }
  1700. // Success returns the value of the "success" field in the mutation.
  1701. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  1702. v := m.success
  1703. if v == nil {
  1704. return
  1705. }
  1706. return *v, true
  1707. }
  1708. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  1709. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1711. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  1712. if !m.op.Is(OpUpdateOne) {
  1713. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  1714. }
  1715. if m.id == nil || m.oldValue == nil {
  1716. return v, errors.New("OldSuccess requires an ID field in the mutation")
  1717. }
  1718. oldValue, err := m.oldValue(ctx)
  1719. if err != nil {
  1720. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  1721. }
  1722. return oldValue.Success, nil
  1723. }
  1724. // AddSuccess adds i to the "success" field.
  1725. func (m *BatchMsgMutation) AddSuccess(i int32) {
  1726. if m.addsuccess != nil {
  1727. *m.addsuccess += i
  1728. } else {
  1729. m.addsuccess = &i
  1730. }
  1731. }
  1732. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  1733. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  1734. v := m.addsuccess
  1735. if v == nil {
  1736. return
  1737. }
  1738. return *v, true
  1739. }
  1740. // ClearSuccess clears the value of the "success" field.
  1741. func (m *BatchMsgMutation) ClearSuccess() {
  1742. m.success = nil
  1743. m.addsuccess = nil
  1744. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  1745. }
  1746. // SuccessCleared returns if the "success" field was cleared in this mutation.
  1747. func (m *BatchMsgMutation) SuccessCleared() bool {
  1748. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  1749. return ok
  1750. }
  1751. // ResetSuccess resets all changes to the "success" field.
  1752. func (m *BatchMsgMutation) ResetSuccess() {
  1753. m.success = nil
  1754. m.addsuccess = nil
  1755. delete(m.clearedFields, batchmsg.FieldSuccess)
  1756. }
  1757. // SetFail sets the "fail" field.
  1758. func (m *BatchMsgMutation) SetFail(i int32) {
  1759. m.fail = &i
  1760. m.addfail = nil
  1761. }
  1762. // Fail returns the value of the "fail" field in the mutation.
  1763. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  1764. v := m.fail
  1765. if v == nil {
  1766. return
  1767. }
  1768. return *v, true
  1769. }
  1770. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  1771. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1773. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  1774. if !m.op.Is(OpUpdateOne) {
  1775. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  1776. }
  1777. if m.id == nil || m.oldValue == nil {
  1778. return v, errors.New("OldFail requires an ID field in the mutation")
  1779. }
  1780. oldValue, err := m.oldValue(ctx)
  1781. if err != nil {
  1782. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  1783. }
  1784. return oldValue.Fail, nil
  1785. }
  1786. // AddFail adds i to the "fail" field.
  1787. func (m *BatchMsgMutation) AddFail(i int32) {
  1788. if m.addfail != nil {
  1789. *m.addfail += i
  1790. } else {
  1791. m.addfail = &i
  1792. }
  1793. }
  1794. // AddedFail returns the value that was added to the "fail" field in this mutation.
  1795. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  1796. v := m.addfail
  1797. if v == nil {
  1798. return
  1799. }
  1800. return *v, true
  1801. }
  1802. // ClearFail clears the value of the "fail" field.
  1803. func (m *BatchMsgMutation) ClearFail() {
  1804. m.fail = nil
  1805. m.addfail = nil
  1806. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  1807. }
  1808. // FailCleared returns if the "fail" field was cleared in this mutation.
  1809. func (m *BatchMsgMutation) FailCleared() bool {
  1810. _, ok := m.clearedFields[batchmsg.FieldFail]
  1811. return ok
  1812. }
  1813. // ResetFail resets all changes to the "fail" field.
  1814. func (m *BatchMsgMutation) ResetFail() {
  1815. m.fail = nil
  1816. m.addfail = nil
  1817. delete(m.clearedFields, batchmsg.FieldFail)
  1818. }
  1819. // SetStartTime sets the "start_time" field.
  1820. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  1821. m.start_time = &t
  1822. }
  1823. // StartTime returns the value of the "start_time" field in the mutation.
  1824. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  1825. v := m.start_time
  1826. if v == nil {
  1827. return
  1828. }
  1829. return *v, true
  1830. }
  1831. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  1832. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1834. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  1835. if !m.op.Is(OpUpdateOne) {
  1836. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  1837. }
  1838. if m.id == nil || m.oldValue == nil {
  1839. return v, errors.New("OldStartTime requires an ID field in the mutation")
  1840. }
  1841. oldValue, err := m.oldValue(ctx)
  1842. if err != nil {
  1843. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  1844. }
  1845. return oldValue.StartTime, nil
  1846. }
  1847. // ClearStartTime clears the value of the "start_time" field.
  1848. func (m *BatchMsgMutation) ClearStartTime() {
  1849. m.start_time = nil
  1850. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  1851. }
  1852. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  1853. func (m *BatchMsgMutation) StartTimeCleared() bool {
  1854. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  1855. return ok
  1856. }
  1857. // ResetStartTime resets all changes to the "start_time" field.
  1858. func (m *BatchMsgMutation) ResetStartTime() {
  1859. m.start_time = nil
  1860. delete(m.clearedFields, batchmsg.FieldStartTime)
  1861. }
  1862. // SetStopTime sets the "stop_time" field.
  1863. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  1864. m.stop_time = &t
  1865. }
  1866. // StopTime returns the value of the "stop_time" field in the mutation.
  1867. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  1868. v := m.stop_time
  1869. if v == nil {
  1870. return
  1871. }
  1872. return *v, true
  1873. }
  1874. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  1875. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1877. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  1878. if !m.op.Is(OpUpdateOne) {
  1879. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  1880. }
  1881. if m.id == nil || m.oldValue == nil {
  1882. return v, errors.New("OldStopTime requires an ID field in the mutation")
  1883. }
  1884. oldValue, err := m.oldValue(ctx)
  1885. if err != nil {
  1886. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  1887. }
  1888. return oldValue.StopTime, nil
  1889. }
  1890. // ClearStopTime clears the value of the "stop_time" field.
  1891. func (m *BatchMsgMutation) ClearStopTime() {
  1892. m.stop_time = nil
  1893. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  1894. }
  1895. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  1896. func (m *BatchMsgMutation) StopTimeCleared() bool {
  1897. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  1898. return ok
  1899. }
  1900. // ResetStopTime resets all changes to the "stop_time" field.
  1901. func (m *BatchMsgMutation) ResetStopTime() {
  1902. m.stop_time = nil
  1903. delete(m.clearedFields, batchmsg.FieldStopTime)
  1904. }
  1905. // SetSendTime sets the "send_time" field.
  1906. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  1907. m.send_time = &t
  1908. }
  1909. // SendTime returns the value of the "send_time" field in the mutation.
  1910. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  1911. v := m.send_time
  1912. if v == nil {
  1913. return
  1914. }
  1915. return *v, true
  1916. }
  1917. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  1918. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1920. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  1921. if !m.op.Is(OpUpdateOne) {
  1922. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  1923. }
  1924. if m.id == nil || m.oldValue == nil {
  1925. return v, errors.New("OldSendTime requires an ID field in the mutation")
  1926. }
  1927. oldValue, err := m.oldValue(ctx)
  1928. if err != nil {
  1929. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  1930. }
  1931. return oldValue.SendTime, nil
  1932. }
  1933. // ClearSendTime clears the value of the "send_time" field.
  1934. func (m *BatchMsgMutation) ClearSendTime() {
  1935. m.send_time = nil
  1936. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  1937. }
  1938. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  1939. func (m *BatchMsgMutation) SendTimeCleared() bool {
  1940. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  1941. return ok
  1942. }
  1943. // ResetSendTime resets all changes to the "send_time" field.
  1944. func (m *BatchMsgMutation) ResetSendTime() {
  1945. m.send_time = nil
  1946. delete(m.clearedFields, batchmsg.FieldSendTime)
  1947. }
  1948. // SetType sets the "type" field.
  1949. func (m *BatchMsgMutation) SetType(i int32) {
  1950. m._type = &i
  1951. m.add_type = nil
  1952. }
  1953. // GetType returns the value of the "type" field in the mutation.
  1954. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  1955. v := m._type
  1956. if v == nil {
  1957. return
  1958. }
  1959. return *v, true
  1960. }
  1961. // OldType returns the old "type" field's value of the BatchMsg entity.
  1962. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1964. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  1965. if !m.op.Is(OpUpdateOne) {
  1966. return v, errors.New("OldType is only allowed on UpdateOne operations")
  1967. }
  1968. if m.id == nil || m.oldValue == nil {
  1969. return v, errors.New("OldType requires an ID field in the mutation")
  1970. }
  1971. oldValue, err := m.oldValue(ctx)
  1972. if err != nil {
  1973. return v, fmt.Errorf("querying old value for OldType: %w", err)
  1974. }
  1975. return oldValue.Type, nil
  1976. }
  1977. // AddType adds i to the "type" field.
  1978. func (m *BatchMsgMutation) AddType(i int32) {
  1979. if m.add_type != nil {
  1980. *m.add_type += i
  1981. } else {
  1982. m.add_type = &i
  1983. }
  1984. }
  1985. // AddedType returns the value that was added to the "type" field in this mutation.
  1986. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  1987. v := m.add_type
  1988. if v == nil {
  1989. return
  1990. }
  1991. return *v, true
  1992. }
  1993. // ClearType clears the value of the "type" field.
  1994. func (m *BatchMsgMutation) ClearType() {
  1995. m._type = nil
  1996. m.add_type = nil
  1997. m.clearedFields[batchmsg.FieldType] = struct{}{}
  1998. }
  1999. // TypeCleared returns if the "type" field was cleared in this mutation.
  2000. func (m *BatchMsgMutation) TypeCleared() bool {
  2001. _, ok := m.clearedFields[batchmsg.FieldType]
  2002. return ok
  2003. }
  2004. // ResetType resets all changes to the "type" field.
  2005. func (m *BatchMsgMutation) ResetType() {
  2006. m._type = nil
  2007. m.add_type = nil
  2008. delete(m.clearedFields, batchmsg.FieldType)
  2009. }
  2010. // SetOrganizationID sets the "organization_id" field.
  2011. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  2012. m.organization_id = &u
  2013. m.addorganization_id = nil
  2014. }
  2015. // OrganizationID returns the value of the "organization_id" field in the mutation.
  2016. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  2017. v := m.organization_id
  2018. if v == nil {
  2019. return
  2020. }
  2021. return *v, true
  2022. }
  2023. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  2024. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2026. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  2027. if !m.op.Is(OpUpdateOne) {
  2028. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  2029. }
  2030. if m.id == nil || m.oldValue == nil {
  2031. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  2032. }
  2033. oldValue, err := m.oldValue(ctx)
  2034. if err != nil {
  2035. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  2036. }
  2037. return oldValue.OrganizationID, nil
  2038. }
  2039. // AddOrganizationID adds u to the "organization_id" field.
  2040. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  2041. if m.addorganization_id != nil {
  2042. *m.addorganization_id += u
  2043. } else {
  2044. m.addorganization_id = &u
  2045. }
  2046. }
  2047. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  2048. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  2049. v := m.addorganization_id
  2050. if v == nil {
  2051. return
  2052. }
  2053. return *v, true
  2054. }
  2055. // ResetOrganizationID resets all changes to the "organization_id" field.
  2056. func (m *BatchMsgMutation) ResetOrganizationID() {
  2057. m.organization_id = nil
  2058. m.addorganization_id = nil
  2059. }
  2060. // Where appends a list predicates to the BatchMsgMutation builder.
  2061. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  2062. m.predicates = append(m.predicates, ps...)
  2063. }
  2064. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  2065. // users can use type-assertion to append predicates that do not depend on any generated package.
  2066. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  2067. p := make([]predicate.BatchMsg, len(ps))
  2068. for i := range ps {
  2069. p[i] = ps[i]
  2070. }
  2071. m.Where(p...)
  2072. }
  2073. // Op returns the operation name.
  2074. func (m *BatchMsgMutation) Op() Op {
  2075. return m.op
  2076. }
  2077. // SetOp allows setting the mutation operation.
  2078. func (m *BatchMsgMutation) SetOp(op Op) {
  2079. m.op = op
  2080. }
  2081. // Type returns the node type of this mutation (BatchMsg).
  2082. func (m *BatchMsgMutation) Type() string {
  2083. return m.typ
  2084. }
  2085. // Fields returns all fields that were changed during this mutation. Note that in
  2086. // order to get all numeric fields that were incremented/decremented, call
  2087. // AddedFields().
  2088. func (m *BatchMsgMutation) Fields() []string {
  2089. fields := make([]string, 0, 18)
  2090. if m.created_at != nil {
  2091. fields = append(fields, batchmsg.FieldCreatedAt)
  2092. }
  2093. if m.updated_at != nil {
  2094. fields = append(fields, batchmsg.FieldUpdatedAt)
  2095. }
  2096. if m.deleted_at != nil {
  2097. fields = append(fields, batchmsg.FieldDeletedAt)
  2098. }
  2099. if m.status != nil {
  2100. fields = append(fields, batchmsg.FieldStatus)
  2101. }
  2102. if m.batch_no != nil {
  2103. fields = append(fields, batchmsg.FieldBatchNo)
  2104. }
  2105. if m.task_name != nil {
  2106. fields = append(fields, batchmsg.FieldTaskName)
  2107. }
  2108. if m.fromwxid != nil {
  2109. fields = append(fields, batchmsg.FieldFromwxid)
  2110. }
  2111. if m.msg != nil {
  2112. fields = append(fields, batchmsg.FieldMsg)
  2113. }
  2114. if m.tag != nil {
  2115. fields = append(fields, batchmsg.FieldTag)
  2116. }
  2117. if m.tagids != nil {
  2118. fields = append(fields, batchmsg.FieldTagids)
  2119. }
  2120. if m.total != nil {
  2121. fields = append(fields, batchmsg.FieldTotal)
  2122. }
  2123. if m.success != nil {
  2124. fields = append(fields, batchmsg.FieldSuccess)
  2125. }
  2126. if m.fail != nil {
  2127. fields = append(fields, batchmsg.FieldFail)
  2128. }
  2129. if m.start_time != nil {
  2130. fields = append(fields, batchmsg.FieldStartTime)
  2131. }
  2132. if m.stop_time != nil {
  2133. fields = append(fields, batchmsg.FieldStopTime)
  2134. }
  2135. if m.send_time != nil {
  2136. fields = append(fields, batchmsg.FieldSendTime)
  2137. }
  2138. if m._type != nil {
  2139. fields = append(fields, batchmsg.FieldType)
  2140. }
  2141. if m.organization_id != nil {
  2142. fields = append(fields, batchmsg.FieldOrganizationID)
  2143. }
  2144. return fields
  2145. }
  2146. // Field returns the value of a field with the given name. The second boolean
  2147. // return value indicates that this field was not set, or was not defined in the
  2148. // schema.
  2149. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  2150. switch name {
  2151. case batchmsg.FieldCreatedAt:
  2152. return m.CreatedAt()
  2153. case batchmsg.FieldUpdatedAt:
  2154. return m.UpdatedAt()
  2155. case batchmsg.FieldDeletedAt:
  2156. return m.DeletedAt()
  2157. case batchmsg.FieldStatus:
  2158. return m.Status()
  2159. case batchmsg.FieldBatchNo:
  2160. return m.BatchNo()
  2161. case batchmsg.FieldTaskName:
  2162. return m.TaskName()
  2163. case batchmsg.FieldFromwxid:
  2164. return m.Fromwxid()
  2165. case batchmsg.FieldMsg:
  2166. return m.Msg()
  2167. case batchmsg.FieldTag:
  2168. return m.Tag()
  2169. case batchmsg.FieldTagids:
  2170. return m.Tagids()
  2171. case batchmsg.FieldTotal:
  2172. return m.Total()
  2173. case batchmsg.FieldSuccess:
  2174. return m.Success()
  2175. case batchmsg.FieldFail:
  2176. return m.Fail()
  2177. case batchmsg.FieldStartTime:
  2178. return m.StartTime()
  2179. case batchmsg.FieldStopTime:
  2180. return m.StopTime()
  2181. case batchmsg.FieldSendTime:
  2182. return m.SendTime()
  2183. case batchmsg.FieldType:
  2184. return m.GetType()
  2185. case batchmsg.FieldOrganizationID:
  2186. return m.OrganizationID()
  2187. }
  2188. return nil, false
  2189. }
  2190. // OldField returns the old value of the field from the database. An error is
  2191. // returned if the mutation operation is not UpdateOne, or the query to the
  2192. // database failed.
  2193. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2194. switch name {
  2195. case batchmsg.FieldCreatedAt:
  2196. return m.OldCreatedAt(ctx)
  2197. case batchmsg.FieldUpdatedAt:
  2198. return m.OldUpdatedAt(ctx)
  2199. case batchmsg.FieldDeletedAt:
  2200. return m.OldDeletedAt(ctx)
  2201. case batchmsg.FieldStatus:
  2202. return m.OldStatus(ctx)
  2203. case batchmsg.FieldBatchNo:
  2204. return m.OldBatchNo(ctx)
  2205. case batchmsg.FieldTaskName:
  2206. return m.OldTaskName(ctx)
  2207. case batchmsg.FieldFromwxid:
  2208. return m.OldFromwxid(ctx)
  2209. case batchmsg.FieldMsg:
  2210. return m.OldMsg(ctx)
  2211. case batchmsg.FieldTag:
  2212. return m.OldTag(ctx)
  2213. case batchmsg.FieldTagids:
  2214. return m.OldTagids(ctx)
  2215. case batchmsg.FieldTotal:
  2216. return m.OldTotal(ctx)
  2217. case batchmsg.FieldSuccess:
  2218. return m.OldSuccess(ctx)
  2219. case batchmsg.FieldFail:
  2220. return m.OldFail(ctx)
  2221. case batchmsg.FieldStartTime:
  2222. return m.OldStartTime(ctx)
  2223. case batchmsg.FieldStopTime:
  2224. return m.OldStopTime(ctx)
  2225. case batchmsg.FieldSendTime:
  2226. return m.OldSendTime(ctx)
  2227. case batchmsg.FieldType:
  2228. return m.OldType(ctx)
  2229. case batchmsg.FieldOrganizationID:
  2230. return m.OldOrganizationID(ctx)
  2231. }
  2232. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  2233. }
  2234. // SetField sets the value of a field with the given name. It returns an error if
  2235. // the field is not defined in the schema, or if the type mismatched the field
  2236. // type.
  2237. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  2238. switch name {
  2239. case batchmsg.FieldCreatedAt:
  2240. v, ok := value.(time.Time)
  2241. if !ok {
  2242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2243. }
  2244. m.SetCreatedAt(v)
  2245. return nil
  2246. case batchmsg.FieldUpdatedAt:
  2247. v, ok := value.(time.Time)
  2248. if !ok {
  2249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2250. }
  2251. m.SetUpdatedAt(v)
  2252. return nil
  2253. case batchmsg.FieldDeletedAt:
  2254. v, ok := value.(time.Time)
  2255. if !ok {
  2256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2257. }
  2258. m.SetDeletedAt(v)
  2259. return nil
  2260. case batchmsg.FieldStatus:
  2261. v, ok := value.(uint8)
  2262. if !ok {
  2263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2264. }
  2265. m.SetStatus(v)
  2266. return nil
  2267. case batchmsg.FieldBatchNo:
  2268. v, ok := value.(string)
  2269. if !ok {
  2270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2271. }
  2272. m.SetBatchNo(v)
  2273. return nil
  2274. case batchmsg.FieldTaskName:
  2275. v, ok := value.(string)
  2276. if !ok {
  2277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2278. }
  2279. m.SetTaskName(v)
  2280. return nil
  2281. case batchmsg.FieldFromwxid:
  2282. v, ok := value.(string)
  2283. if !ok {
  2284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2285. }
  2286. m.SetFromwxid(v)
  2287. return nil
  2288. case batchmsg.FieldMsg:
  2289. v, ok := value.(string)
  2290. if !ok {
  2291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2292. }
  2293. m.SetMsg(v)
  2294. return nil
  2295. case batchmsg.FieldTag:
  2296. v, ok := value.(string)
  2297. if !ok {
  2298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2299. }
  2300. m.SetTag(v)
  2301. return nil
  2302. case batchmsg.FieldTagids:
  2303. v, ok := value.(string)
  2304. if !ok {
  2305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2306. }
  2307. m.SetTagids(v)
  2308. return nil
  2309. case batchmsg.FieldTotal:
  2310. v, ok := value.(int32)
  2311. if !ok {
  2312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2313. }
  2314. m.SetTotal(v)
  2315. return nil
  2316. case batchmsg.FieldSuccess:
  2317. v, ok := value.(int32)
  2318. if !ok {
  2319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2320. }
  2321. m.SetSuccess(v)
  2322. return nil
  2323. case batchmsg.FieldFail:
  2324. v, ok := value.(int32)
  2325. if !ok {
  2326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2327. }
  2328. m.SetFail(v)
  2329. return nil
  2330. case batchmsg.FieldStartTime:
  2331. v, ok := value.(time.Time)
  2332. if !ok {
  2333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2334. }
  2335. m.SetStartTime(v)
  2336. return nil
  2337. case batchmsg.FieldStopTime:
  2338. v, ok := value.(time.Time)
  2339. if !ok {
  2340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2341. }
  2342. m.SetStopTime(v)
  2343. return nil
  2344. case batchmsg.FieldSendTime:
  2345. v, ok := value.(time.Time)
  2346. if !ok {
  2347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2348. }
  2349. m.SetSendTime(v)
  2350. return nil
  2351. case batchmsg.FieldType:
  2352. v, ok := value.(int32)
  2353. if !ok {
  2354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2355. }
  2356. m.SetType(v)
  2357. return nil
  2358. case batchmsg.FieldOrganizationID:
  2359. v, ok := value.(uint64)
  2360. if !ok {
  2361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2362. }
  2363. m.SetOrganizationID(v)
  2364. return nil
  2365. }
  2366. return fmt.Errorf("unknown BatchMsg field %s", name)
  2367. }
  2368. // AddedFields returns all numeric fields that were incremented/decremented during
  2369. // this mutation.
  2370. func (m *BatchMsgMutation) AddedFields() []string {
  2371. var fields []string
  2372. if m.addstatus != nil {
  2373. fields = append(fields, batchmsg.FieldStatus)
  2374. }
  2375. if m.addtotal != nil {
  2376. fields = append(fields, batchmsg.FieldTotal)
  2377. }
  2378. if m.addsuccess != nil {
  2379. fields = append(fields, batchmsg.FieldSuccess)
  2380. }
  2381. if m.addfail != nil {
  2382. fields = append(fields, batchmsg.FieldFail)
  2383. }
  2384. if m.add_type != nil {
  2385. fields = append(fields, batchmsg.FieldType)
  2386. }
  2387. if m.addorganization_id != nil {
  2388. fields = append(fields, batchmsg.FieldOrganizationID)
  2389. }
  2390. return fields
  2391. }
  2392. // AddedField returns the numeric value that was incremented/decremented on a field
  2393. // with the given name. The second boolean return value indicates that this field
  2394. // was not set, or was not defined in the schema.
  2395. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  2396. switch name {
  2397. case batchmsg.FieldStatus:
  2398. return m.AddedStatus()
  2399. case batchmsg.FieldTotal:
  2400. return m.AddedTotal()
  2401. case batchmsg.FieldSuccess:
  2402. return m.AddedSuccess()
  2403. case batchmsg.FieldFail:
  2404. return m.AddedFail()
  2405. case batchmsg.FieldType:
  2406. return m.AddedType()
  2407. case batchmsg.FieldOrganizationID:
  2408. return m.AddedOrganizationID()
  2409. }
  2410. return nil, false
  2411. }
  2412. // AddField adds the value to the field with the given name. It returns an error if
  2413. // the field is not defined in the schema, or if the type mismatched the field
  2414. // type.
  2415. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  2416. switch name {
  2417. case batchmsg.FieldStatus:
  2418. v, ok := value.(int8)
  2419. if !ok {
  2420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2421. }
  2422. m.AddStatus(v)
  2423. return nil
  2424. case batchmsg.FieldTotal:
  2425. v, ok := value.(int32)
  2426. if !ok {
  2427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2428. }
  2429. m.AddTotal(v)
  2430. return nil
  2431. case batchmsg.FieldSuccess:
  2432. v, ok := value.(int32)
  2433. if !ok {
  2434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2435. }
  2436. m.AddSuccess(v)
  2437. return nil
  2438. case batchmsg.FieldFail:
  2439. v, ok := value.(int32)
  2440. if !ok {
  2441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2442. }
  2443. m.AddFail(v)
  2444. return nil
  2445. case batchmsg.FieldType:
  2446. v, ok := value.(int32)
  2447. if !ok {
  2448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2449. }
  2450. m.AddType(v)
  2451. return nil
  2452. case batchmsg.FieldOrganizationID:
  2453. v, ok := value.(int64)
  2454. if !ok {
  2455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2456. }
  2457. m.AddOrganizationID(v)
  2458. return nil
  2459. }
  2460. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  2461. }
  2462. // ClearedFields returns all nullable fields that were cleared during this
  2463. // mutation.
  2464. func (m *BatchMsgMutation) ClearedFields() []string {
  2465. var fields []string
  2466. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  2467. fields = append(fields, batchmsg.FieldDeletedAt)
  2468. }
  2469. if m.FieldCleared(batchmsg.FieldStatus) {
  2470. fields = append(fields, batchmsg.FieldStatus)
  2471. }
  2472. if m.FieldCleared(batchmsg.FieldBatchNo) {
  2473. fields = append(fields, batchmsg.FieldBatchNo)
  2474. }
  2475. if m.FieldCleared(batchmsg.FieldTaskName) {
  2476. fields = append(fields, batchmsg.FieldTaskName)
  2477. }
  2478. if m.FieldCleared(batchmsg.FieldFromwxid) {
  2479. fields = append(fields, batchmsg.FieldFromwxid)
  2480. }
  2481. if m.FieldCleared(batchmsg.FieldMsg) {
  2482. fields = append(fields, batchmsg.FieldMsg)
  2483. }
  2484. if m.FieldCleared(batchmsg.FieldTag) {
  2485. fields = append(fields, batchmsg.FieldTag)
  2486. }
  2487. if m.FieldCleared(batchmsg.FieldTagids) {
  2488. fields = append(fields, batchmsg.FieldTagids)
  2489. }
  2490. if m.FieldCleared(batchmsg.FieldTotal) {
  2491. fields = append(fields, batchmsg.FieldTotal)
  2492. }
  2493. if m.FieldCleared(batchmsg.FieldSuccess) {
  2494. fields = append(fields, batchmsg.FieldSuccess)
  2495. }
  2496. if m.FieldCleared(batchmsg.FieldFail) {
  2497. fields = append(fields, batchmsg.FieldFail)
  2498. }
  2499. if m.FieldCleared(batchmsg.FieldStartTime) {
  2500. fields = append(fields, batchmsg.FieldStartTime)
  2501. }
  2502. if m.FieldCleared(batchmsg.FieldStopTime) {
  2503. fields = append(fields, batchmsg.FieldStopTime)
  2504. }
  2505. if m.FieldCleared(batchmsg.FieldSendTime) {
  2506. fields = append(fields, batchmsg.FieldSendTime)
  2507. }
  2508. if m.FieldCleared(batchmsg.FieldType) {
  2509. fields = append(fields, batchmsg.FieldType)
  2510. }
  2511. return fields
  2512. }
  2513. // FieldCleared returns a boolean indicating if a field with the given name was
  2514. // cleared in this mutation.
  2515. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  2516. _, ok := m.clearedFields[name]
  2517. return ok
  2518. }
  2519. // ClearField clears the value of the field with the given name. It returns an
  2520. // error if the field is not defined in the schema.
  2521. func (m *BatchMsgMutation) ClearField(name string) error {
  2522. switch name {
  2523. case batchmsg.FieldDeletedAt:
  2524. m.ClearDeletedAt()
  2525. return nil
  2526. case batchmsg.FieldStatus:
  2527. m.ClearStatus()
  2528. return nil
  2529. case batchmsg.FieldBatchNo:
  2530. m.ClearBatchNo()
  2531. return nil
  2532. case batchmsg.FieldTaskName:
  2533. m.ClearTaskName()
  2534. return nil
  2535. case batchmsg.FieldFromwxid:
  2536. m.ClearFromwxid()
  2537. return nil
  2538. case batchmsg.FieldMsg:
  2539. m.ClearMsg()
  2540. return nil
  2541. case batchmsg.FieldTag:
  2542. m.ClearTag()
  2543. return nil
  2544. case batchmsg.FieldTagids:
  2545. m.ClearTagids()
  2546. return nil
  2547. case batchmsg.FieldTotal:
  2548. m.ClearTotal()
  2549. return nil
  2550. case batchmsg.FieldSuccess:
  2551. m.ClearSuccess()
  2552. return nil
  2553. case batchmsg.FieldFail:
  2554. m.ClearFail()
  2555. return nil
  2556. case batchmsg.FieldStartTime:
  2557. m.ClearStartTime()
  2558. return nil
  2559. case batchmsg.FieldStopTime:
  2560. m.ClearStopTime()
  2561. return nil
  2562. case batchmsg.FieldSendTime:
  2563. m.ClearSendTime()
  2564. return nil
  2565. case batchmsg.FieldType:
  2566. m.ClearType()
  2567. return nil
  2568. }
  2569. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  2570. }
  2571. // ResetField resets all changes in the mutation for the field with the given name.
  2572. // It returns an error if the field is not defined in the schema.
  2573. func (m *BatchMsgMutation) ResetField(name string) error {
  2574. switch name {
  2575. case batchmsg.FieldCreatedAt:
  2576. m.ResetCreatedAt()
  2577. return nil
  2578. case batchmsg.FieldUpdatedAt:
  2579. m.ResetUpdatedAt()
  2580. return nil
  2581. case batchmsg.FieldDeletedAt:
  2582. m.ResetDeletedAt()
  2583. return nil
  2584. case batchmsg.FieldStatus:
  2585. m.ResetStatus()
  2586. return nil
  2587. case batchmsg.FieldBatchNo:
  2588. m.ResetBatchNo()
  2589. return nil
  2590. case batchmsg.FieldTaskName:
  2591. m.ResetTaskName()
  2592. return nil
  2593. case batchmsg.FieldFromwxid:
  2594. m.ResetFromwxid()
  2595. return nil
  2596. case batchmsg.FieldMsg:
  2597. m.ResetMsg()
  2598. return nil
  2599. case batchmsg.FieldTag:
  2600. m.ResetTag()
  2601. return nil
  2602. case batchmsg.FieldTagids:
  2603. m.ResetTagids()
  2604. return nil
  2605. case batchmsg.FieldTotal:
  2606. m.ResetTotal()
  2607. return nil
  2608. case batchmsg.FieldSuccess:
  2609. m.ResetSuccess()
  2610. return nil
  2611. case batchmsg.FieldFail:
  2612. m.ResetFail()
  2613. return nil
  2614. case batchmsg.FieldStartTime:
  2615. m.ResetStartTime()
  2616. return nil
  2617. case batchmsg.FieldStopTime:
  2618. m.ResetStopTime()
  2619. return nil
  2620. case batchmsg.FieldSendTime:
  2621. m.ResetSendTime()
  2622. return nil
  2623. case batchmsg.FieldType:
  2624. m.ResetType()
  2625. return nil
  2626. case batchmsg.FieldOrganizationID:
  2627. m.ResetOrganizationID()
  2628. return nil
  2629. }
  2630. return fmt.Errorf("unknown BatchMsg field %s", name)
  2631. }
  2632. // AddedEdges returns all edge names that were set/added in this mutation.
  2633. func (m *BatchMsgMutation) AddedEdges() []string {
  2634. edges := make([]string, 0, 0)
  2635. return edges
  2636. }
  2637. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2638. // name in this mutation.
  2639. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  2640. return nil
  2641. }
  2642. // RemovedEdges returns all edge names that were removed in this mutation.
  2643. func (m *BatchMsgMutation) RemovedEdges() []string {
  2644. edges := make([]string, 0, 0)
  2645. return edges
  2646. }
  2647. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2648. // the given name in this mutation.
  2649. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  2650. return nil
  2651. }
  2652. // ClearedEdges returns all edge names that were cleared in this mutation.
  2653. func (m *BatchMsgMutation) ClearedEdges() []string {
  2654. edges := make([]string, 0, 0)
  2655. return edges
  2656. }
  2657. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2658. // was cleared in this mutation.
  2659. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  2660. return false
  2661. }
  2662. // ClearEdge clears the value of the edge with the given name. It returns an error
  2663. // if that edge is not defined in the schema.
  2664. func (m *BatchMsgMutation) ClearEdge(name string) error {
  2665. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  2666. }
  2667. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2668. // It returns an error if the edge is not defined in the schema.
  2669. func (m *BatchMsgMutation) ResetEdge(name string) error {
  2670. return fmt.Errorf("unknown BatchMsg edge %s", name)
  2671. }
  2672. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  2673. type CategoryMutation struct {
  2674. config
  2675. op Op
  2676. typ string
  2677. id *uint64
  2678. created_at *time.Time
  2679. updated_at *time.Time
  2680. deleted_at *time.Time
  2681. name *string
  2682. organization_id *uint64
  2683. addorganization_id *int64
  2684. clearedFields map[string]struct{}
  2685. done bool
  2686. oldValue func(context.Context) (*Category, error)
  2687. predicates []predicate.Category
  2688. }
  2689. var _ ent.Mutation = (*CategoryMutation)(nil)
  2690. // categoryOption allows management of the mutation configuration using functional options.
  2691. type categoryOption func(*CategoryMutation)
  2692. // newCategoryMutation creates new mutation for the Category entity.
  2693. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  2694. m := &CategoryMutation{
  2695. config: c,
  2696. op: op,
  2697. typ: TypeCategory,
  2698. clearedFields: make(map[string]struct{}),
  2699. }
  2700. for _, opt := range opts {
  2701. opt(m)
  2702. }
  2703. return m
  2704. }
  2705. // withCategoryID sets the ID field of the mutation.
  2706. func withCategoryID(id uint64) categoryOption {
  2707. return func(m *CategoryMutation) {
  2708. var (
  2709. err error
  2710. once sync.Once
  2711. value *Category
  2712. )
  2713. m.oldValue = func(ctx context.Context) (*Category, error) {
  2714. once.Do(func() {
  2715. if m.done {
  2716. err = errors.New("querying old values post mutation is not allowed")
  2717. } else {
  2718. value, err = m.Client().Category.Get(ctx, id)
  2719. }
  2720. })
  2721. return value, err
  2722. }
  2723. m.id = &id
  2724. }
  2725. }
  2726. // withCategory sets the old Category of the mutation.
  2727. func withCategory(node *Category) categoryOption {
  2728. return func(m *CategoryMutation) {
  2729. m.oldValue = func(context.Context) (*Category, error) {
  2730. return node, nil
  2731. }
  2732. m.id = &node.ID
  2733. }
  2734. }
  2735. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2736. // executed in a transaction (ent.Tx), a transactional client is returned.
  2737. func (m CategoryMutation) Client() *Client {
  2738. client := &Client{config: m.config}
  2739. client.init()
  2740. return client
  2741. }
  2742. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2743. // it returns an error otherwise.
  2744. func (m CategoryMutation) Tx() (*Tx, error) {
  2745. if _, ok := m.driver.(*txDriver); !ok {
  2746. return nil, errors.New("ent: mutation is not running in a transaction")
  2747. }
  2748. tx := &Tx{config: m.config}
  2749. tx.init()
  2750. return tx, nil
  2751. }
  2752. // SetID sets the value of the id field. Note that this
  2753. // operation is only accepted on creation of Category entities.
  2754. func (m *CategoryMutation) SetID(id uint64) {
  2755. m.id = &id
  2756. }
  2757. // ID returns the ID value in the mutation. Note that the ID is only available
  2758. // if it was provided to the builder or after it was returned from the database.
  2759. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  2760. if m.id == nil {
  2761. return
  2762. }
  2763. return *m.id, true
  2764. }
  2765. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2766. // That means, if the mutation is applied within a transaction with an isolation level such
  2767. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2768. // or updated by the mutation.
  2769. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  2770. switch {
  2771. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2772. id, exists := m.ID()
  2773. if exists {
  2774. return []uint64{id}, nil
  2775. }
  2776. fallthrough
  2777. case m.op.Is(OpUpdate | OpDelete):
  2778. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  2779. default:
  2780. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2781. }
  2782. }
  2783. // SetCreatedAt sets the "created_at" field.
  2784. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  2785. m.created_at = &t
  2786. }
  2787. // CreatedAt returns the value of the "created_at" field in the mutation.
  2788. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  2789. v := m.created_at
  2790. if v == nil {
  2791. return
  2792. }
  2793. return *v, true
  2794. }
  2795. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  2796. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  2797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2798. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2799. if !m.op.Is(OpUpdateOne) {
  2800. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2801. }
  2802. if m.id == nil || m.oldValue == nil {
  2803. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2804. }
  2805. oldValue, err := m.oldValue(ctx)
  2806. if err != nil {
  2807. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2808. }
  2809. return oldValue.CreatedAt, nil
  2810. }
  2811. // ResetCreatedAt resets all changes to the "created_at" field.
  2812. func (m *CategoryMutation) ResetCreatedAt() {
  2813. m.created_at = nil
  2814. }
  2815. // SetUpdatedAt sets the "updated_at" field.
  2816. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  2817. m.updated_at = &t
  2818. }
  2819. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2820. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  2821. v := m.updated_at
  2822. if v == nil {
  2823. return
  2824. }
  2825. return *v, true
  2826. }
  2827. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  2828. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  2829. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2830. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2831. if !m.op.Is(OpUpdateOne) {
  2832. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2833. }
  2834. if m.id == nil || m.oldValue == nil {
  2835. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2836. }
  2837. oldValue, err := m.oldValue(ctx)
  2838. if err != nil {
  2839. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2840. }
  2841. return oldValue.UpdatedAt, nil
  2842. }
  2843. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2844. func (m *CategoryMutation) ResetUpdatedAt() {
  2845. m.updated_at = nil
  2846. }
  2847. // SetDeletedAt sets the "deleted_at" field.
  2848. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  2849. m.deleted_at = &t
  2850. }
  2851. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2852. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  2853. v := m.deleted_at
  2854. if v == nil {
  2855. return
  2856. }
  2857. return *v, true
  2858. }
  2859. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  2860. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  2861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2862. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2863. if !m.op.Is(OpUpdateOne) {
  2864. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2865. }
  2866. if m.id == nil || m.oldValue == nil {
  2867. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2868. }
  2869. oldValue, err := m.oldValue(ctx)
  2870. if err != nil {
  2871. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2872. }
  2873. return oldValue.DeletedAt, nil
  2874. }
  2875. // ClearDeletedAt clears the value of the "deleted_at" field.
  2876. func (m *CategoryMutation) ClearDeletedAt() {
  2877. m.deleted_at = nil
  2878. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  2879. }
  2880. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2881. func (m *CategoryMutation) DeletedAtCleared() bool {
  2882. _, ok := m.clearedFields[category.FieldDeletedAt]
  2883. return ok
  2884. }
  2885. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2886. func (m *CategoryMutation) ResetDeletedAt() {
  2887. m.deleted_at = nil
  2888. delete(m.clearedFields, category.FieldDeletedAt)
  2889. }
  2890. // SetName sets the "name" field.
  2891. func (m *CategoryMutation) SetName(s string) {
  2892. m.name = &s
  2893. }
  2894. // Name returns the value of the "name" field in the mutation.
  2895. func (m *CategoryMutation) Name() (r string, exists bool) {
  2896. v := m.name
  2897. if v == nil {
  2898. return
  2899. }
  2900. return *v, true
  2901. }
  2902. // OldName returns the old "name" field's value of the Category entity.
  2903. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  2904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2905. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  2906. if !m.op.Is(OpUpdateOne) {
  2907. return v, errors.New("OldName is only allowed on UpdateOne operations")
  2908. }
  2909. if m.id == nil || m.oldValue == nil {
  2910. return v, errors.New("OldName requires an ID field in the mutation")
  2911. }
  2912. oldValue, err := m.oldValue(ctx)
  2913. if err != nil {
  2914. return v, fmt.Errorf("querying old value for OldName: %w", err)
  2915. }
  2916. return oldValue.Name, nil
  2917. }
  2918. // ResetName resets all changes to the "name" field.
  2919. func (m *CategoryMutation) ResetName() {
  2920. m.name = nil
  2921. }
  2922. // SetOrganizationID sets the "organization_id" field.
  2923. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  2924. m.organization_id = &u
  2925. m.addorganization_id = nil
  2926. }
  2927. // OrganizationID returns the value of the "organization_id" field in the mutation.
  2928. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  2929. v := m.organization_id
  2930. if v == nil {
  2931. return
  2932. }
  2933. return *v, true
  2934. }
  2935. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  2936. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  2937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2938. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  2939. if !m.op.Is(OpUpdateOne) {
  2940. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  2941. }
  2942. if m.id == nil || m.oldValue == nil {
  2943. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  2944. }
  2945. oldValue, err := m.oldValue(ctx)
  2946. if err != nil {
  2947. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  2948. }
  2949. return oldValue.OrganizationID, nil
  2950. }
  2951. // AddOrganizationID adds u to the "organization_id" field.
  2952. func (m *CategoryMutation) AddOrganizationID(u int64) {
  2953. if m.addorganization_id != nil {
  2954. *m.addorganization_id += u
  2955. } else {
  2956. m.addorganization_id = &u
  2957. }
  2958. }
  2959. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  2960. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  2961. v := m.addorganization_id
  2962. if v == nil {
  2963. return
  2964. }
  2965. return *v, true
  2966. }
  2967. // ResetOrganizationID resets all changes to the "organization_id" field.
  2968. func (m *CategoryMutation) ResetOrganizationID() {
  2969. m.organization_id = nil
  2970. m.addorganization_id = nil
  2971. }
  2972. // Where appends a list predicates to the CategoryMutation builder.
  2973. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  2974. m.predicates = append(m.predicates, ps...)
  2975. }
  2976. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  2977. // users can use type-assertion to append predicates that do not depend on any generated package.
  2978. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  2979. p := make([]predicate.Category, len(ps))
  2980. for i := range ps {
  2981. p[i] = ps[i]
  2982. }
  2983. m.Where(p...)
  2984. }
  2985. // Op returns the operation name.
  2986. func (m *CategoryMutation) Op() Op {
  2987. return m.op
  2988. }
  2989. // SetOp allows setting the mutation operation.
  2990. func (m *CategoryMutation) SetOp(op Op) {
  2991. m.op = op
  2992. }
  2993. // Type returns the node type of this mutation (Category).
  2994. func (m *CategoryMutation) Type() string {
  2995. return m.typ
  2996. }
  2997. // Fields returns all fields that were changed during this mutation. Note that in
  2998. // order to get all numeric fields that were incremented/decremented, call
  2999. // AddedFields().
  3000. func (m *CategoryMutation) Fields() []string {
  3001. fields := make([]string, 0, 5)
  3002. if m.created_at != nil {
  3003. fields = append(fields, category.FieldCreatedAt)
  3004. }
  3005. if m.updated_at != nil {
  3006. fields = append(fields, category.FieldUpdatedAt)
  3007. }
  3008. if m.deleted_at != nil {
  3009. fields = append(fields, category.FieldDeletedAt)
  3010. }
  3011. if m.name != nil {
  3012. fields = append(fields, category.FieldName)
  3013. }
  3014. if m.organization_id != nil {
  3015. fields = append(fields, category.FieldOrganizationID)
  3016. }
  3017. return fields
  3018. }
  3019. // Field returns the value of a field with the given name. The second boolean
  3020. // return value indicates that this field was not set, or was not defined in the
  3021. // schema.
  3022. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  3023. switch name {
  3024. case category.FieldCreatedAt:
  3025. return m.CreatedAt()
  3026. case category.FieldUpdatedAt:
  3027. return m.UpdatedAt()
  3028. case category.FieldDeletedAt:
  3029. return m.DeletedAt()
  3030. case category.FieldName:
  3031. return m.Name()
  3032. case category.FieldOrganizationID:
  3033. return m.OrganizationID()
  3034. }
  3035. return nil, false
  3036. }
  3037. // OldField returns the old value of the field from the database. An error is
  3038. // returned if the mutation operation is not UpdateOne, or the query to the
  3039. // database failed.
  3040. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3041. switch name {
  3042. case category.FieldCreatedAt:
  3043. return m.OldCreatedAt(ctx)
  3044. case category.FieldUpdatedAt:
  3045. return m.OldUpdatedAt(ctx)
  3046. case category.FieldDeletedAt:
  3047. return m.OldDeletedAt(ctx)
  3048. case category.FieldName:
  3049. return m.OldName(ctx)
  3050. case category.FieldOrganizationID:
  3051. return m.OldOrganizationID(ctx)
  3052. }
  3053. return nil, fmt.Errorf("unknown Category field %s", name)
  3054. }
  3055. // SetField sets the value of a field with the given name. It returns an error if
  3056. // the field is not defined in the schema, or if the type mismatched the field
  3057. // type.
  3058. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  3059. switch name {
  3060. case category.FieldCreatedAt:
  3061. v, ok := value.(time.Time)
  3062. if !ok {
  3063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3064. }
  3065. m.SetCreatedAt(v)
  3066. return nil
  3067. case category.FieldUpdatedAt:
  3068. v, ok := value.(time.Time)
  3069. if !ok {
  3070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3071. }
  3072. m.SetUpdatedAt(v)
  3073. return nil
  3074. case category.FieldDeletedAt:
  3075. v, ok := value.(time.Time)
  3076. if !ok {
  3077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3078. }
  3079. m.SetDeletedAt(v)
  3080. return nil
  3081. case category.FieldName:
  3082. v, ok := value.(string)
  3083. if !ok {
  3084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3085. }
  3086. m.SetName(v)
  3087. return nil
  3088. case category.FieldOrganizationID:
  3089. v, ok := value.(uint64)
  3090. if !ok {
  3091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3092. }
  3093. m.SetOrganizationID(v)
  3094. return nil
  3095. }
  3096. return fmt.Errorf("unknown Category field %s", name)
  3097. }
  3098. // AddedFields returns all numeric fields that were incremented/decremented during
  3099. // this mutation.
  3100. func (m *CategoryMutation) AddedFields() []string {
  3101. var fields []string
  3102. if m.addorganization_id != nil {
  3103. fields = append(fields, category.FieldOrganizationID)
  3104. }
  3105. return fields
  3106. }
  3107. // AddedField returns the numeric value that was incremented/decremented on a field
  3108. // with the given name. The second boolean return value indicates that this field
  3109. // was not set, or was not defined in the schema.
  3110. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  3111. switch name {
  3112. case category.FieldOrganizationID:
  3113. return m.AddedOrganizationID()
  3114. }
  3115. return nil, false
  3116. }
  3117. // AddField adds the value to the field with the given name. It returns an error if
  3118. // the field is not defined in the schema, or if the type mismatched the field
  3119. // type.
  3120. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  3121. switch name {
  3122. case category.FieldOrganizationID:
  3123. v, ok := value.(int64)
  3124. if !ok {
  3125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3126. }
  3127. m.AddOrganizationID(v)
  3128. return nil
  3129. }
  3130. return fmt.Errorf("unknown Category numeric field %s", name)
  3131. }
  3132. // ClearedFields returns all nullable fields that were cleared during this
  3133. // mutation.
  3134. func (m *CategoryMutation) ClearedFields() []string {
  3135. var fields []string
  3136. if m.FieldCleared(category.FieldDeletedAt) {
  3137. fields = append(fields, category.FieldDeletedAt)
  3138. }
  3139. return fields
  3140. }
  3141. // FieldCleared returns a boolean indicating if a field with the given name was
  3142. // cleared in this mutation.
  3143. func (m *CategoryMutation) FieldCleared(name string) bool {
  3144. _, ok := m.clearedFields[name]
  3145. return ok
  3146. }
  3147. // ClearField clears the value of the field with the given name. It returns an
  3148. // error if the field is not defined in the schema.
  3149. func (m *CategoryMutation) ClearField(name string) error {
  3150. switch name {
  3151. case category.FieldDeletedAt:
  3152. m.ClearDeletedAt()
  3153. return nil
  3154. }
  3155. return fmt.Errorf("unknown Category nullable field %s", name)
  3156. }
  3157. // ResetField resets all changes in the mutation for the field with the given name.
  3158. // It returns an error if the field is not defined in the schema.
  3159. func (m *CategoryMutation) ResetField(name string) error {
  3160. switch name {
  3161. case category.FieldCreatedAt:
  3162. m.ResetCreatedAt()
  3163. return nil
  3164. case category.FieldUpdatedAt:
  3165. m.ResetUpdatedAt()
  3166. return nil
  3167. case category.FieldDeletedAt:
  3168. m.ResetDeletedAt()
  3169. return nil
  3170. case category.FieldName:
  3171. m.ResetName()
  3172. return nil
  3173. case category.FieldOrganizationID:
  3174. m.ResetOrganizationID()
  3175. return nil
  3176. }
  3177. return fmt.Errorf("unknown Category field %s", name)
  3178. }
  3179. // AddedEdges returns all edge names that were set/added in this mutation.
  3180. func (m *CategoryMutation) AddedEdges() []string {
  3181. edges := make([]string, 0, 0)
  3182. return edges
  3183. }
  3184. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3185. // name in this mutation.
  3186. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  3187. return nil
  3188. }
  3189. // RemovedEdges returns all edge names that were removed in this mutation.
  3190. func (m *CategoryMutation) RemovedEdges() []string {
  3191. edges := make([]string, 0, 0)
  3192. return edges
  3193. }
  3194. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3195. // the given name in this mutation.
  3196. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  3197. return nil
  3198. }
  3199. // ClearedEdges returns all edge names that were cleared in this mutation.
  3200. func (m *CategoryMutation) ClearedEdges() []string {
  3201. edges := make([]string, 0, 0)
  3202. return edges
  3203. }
  3204. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3205. // was cleared in this mutation.
  3206. func (m *CategoryMutation) EdgeCleared(name string) bool {
  3207. return false
  3208. }
  3209. // ClearEdge clears the value of the edge with the given name. It returns an error
  3210. // if that edge is not defined in the schema.
  3211. func (m *CategoryMutation) ClearEdge(name string) error {
  3212. return fmt.Errorf("unknown Category unique edge %s", name)
  3213. }
  3214. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3215. // It returns an error if the edge is not defined in the schema.
  3216. func (m *CategoryMutation) ResetEdge(name string) error {
  3217. return fmt.Errorf("unknown Category edge %s", name)
  3218. }
  3219. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  3220. type ContactMutation struct {
  3221. config
  3222. op Op
  3223. typ string
  3224. id *uint64
  3225. created_at *time.Time
  3226. updated_at *time.Time
  3227. status *uint8
  3228. addstatus *int8
  3229. deleted_at *time.Time
  3230. wx_wxid *string
  3231. _type *int
  3232. add_type *int
  3233. wxid *string
  3234. account *string
  3235. nickname *string
  3236. markname *string
  3237. headimg *string
  3238. sex *int
  3239. addsex *int
  3240. starrole *string
  3241. dontseeit *int
  3242. adddontseeit *int
  3243. dontseeme *int
  3244. adddontseeme *int
  3245. lag *string
  3246. gid *string
  3247. gname *string
  3248. v3 *string
  3249. organization_id *uint64
  3250. addorganization_id *int64
  3251. clearedFields map[string]struct{}
  3252. contact_relationships map[uint64]struct{}
  3253. removedcontact_relationships map[uint64]struct{}
  3254. clearedcontact_relationships bool
  3255. contact_messages map[uint64]struct{}
  3256. removedcontact_messages map[uint64]struct{}
  3257. clearedcontact_messages bool
  3258. done bool
  3259. oldValue func(context.Context) (*Contact, error)
  3260. predicates []predicate.Contact
  3261. }
  3262. var _ ent.Mutation = (*ContactMutation)(nil)
  3263. // contactOption allows management of the mutation configuration using functional options.
  3264. type contactOption func(*ContactMutation)
  3265. // newContactMutation creates new mutation for the Contact entity.
  3266. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  3267. m := &ContactMutation{
  3268. config: c,
  3269. op: op,
  3270. typ: TypeContact,
  3271. clearedFields: make(map[string]struct{}),
  3272. }
  3273. for _, opt := range opts {
  3274. opt(m)
  3275. }
  3276. return m
  3277. }
  3278. // withContactID sets the ID field of the mutation.
  3279. func withContactID(id uint64) contactOption {
  3280. return func(m *ContactMutation) {
  3281. var (
  3282. err error
  3283. once sync.Once
  3284. value *Contact
  3285. )
  3286. m.oldValue = func(ctx context.Context) (*Contact, error) {
  3287. once.Do(func() {
  3288. if m.done {
  3289. err = errors.New("querying old values post mutation is not allowed")
  3290. } else {
  3291. value, err = m.Client().Contact.Get(ctx, id)
  3292. }
  3293. })
  3294. return value, err
  3295. }
  3296. m.id = &id
  3297. }
  3298. }
  3299. // withContact sets the old Contact of the mutation.
  3300. func withContact(node *Contact) contactOption {
  3301. return func(m *ContactMutation) {
  3302. m.oldValue = func(context.Context) (*Contact, error) {
  3303. return node, nil
  3304. }
  3305. m.id = &node.ID
  3306. }
  3307. }
  3308. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3309. // executed in a transaction (ent.Tx), a transactional client is returned.
  3310. func (m ContactMutation) Client() *Client {
  3311. client := &Client{config: m.config}
  3312. client.init()
  3313. return client
  3314. }
  3315. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3316. // it returns an error otherwise.
  3317. func (m ContactMutation) Tx() (*Tx, error) {
  3318. if _, ok := m.driver.(*txDriver); !ok {
  3319. return nil, errors.New("ent: mutation is not running in a transaction")
  3320. }
  3321. tx := &Tx{config: m.config}
  3322. tx.init()
  3323. return tx, nil
  3324. }
  3325. // SetID sets the value of the id field. Note that this
  3326. // operation is only accepted on creation of Contact entities.
  3327. func (m *ContactMutation) SetID(id uint64) {
  3328. m.id = &id
  3329. }
  3330. // ID returns the ID value in the mutation. Note that the ID is only available
  3331. // if it was provided to the builder or after it was returned from the database.
  3332. func (m *ContactMutation) ID() (id uint64, exists bool) {
  3333. if m.id == nil {
  3334. return
  3335. }
  3336. return *m.id, true
  3337. }
  3338. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3339. // That means, if the mutation is applied within a transaction with an isolation level such
  3340. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3341. // or updated by the mutation.
  3342. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  3343. switch {
  3344. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3345. id, exists := m.ID()
  3346. if exists {
  3347. return []uint64{id}, nil
  3348. }
  3349. fallthrough
  3350. case m.op.Is(OpUpdate | OpDelete):
  3351. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  3352. default:
  3353. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3354. }
  3355. }
  3356. // SetCreatedAt sets the "created_at" field.
  3357. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  3358. m.created_at = &t
  3359. }
  3360. // CreatedAt returns the value of the "created_at" field in the mutation.
  3361. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  3362. v := m.created_at
  3363. if v == nil {
  3364. return
  3365. }
  3366. return *v, true
  3367. }
  3368. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  3369. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3371. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3372. if !m.op.Is(OpUpdateOne) {
  3373. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3374. }
  3375. if m.id == nil || m.oldValue == nil {
  3376. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3377. }
  3378. oldValue, err := m.oldValue(ctx)
  3379. if err != nil {
  3380. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3381. }
  3382. return oldValue.CreatedAt, nil
  3383. }
  3384. // ResetCreatedAt resets all changes to the "created_at" field.
  3385. func (m *ContactMutation) ResetCreatedAt() {
  3386. m.created_at = nil
  3387. }
  3388. // SetUpdatedAt sets the "updated_at" field.
  3389. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  3390. m.updated_at = &t
  3391. }
  3392. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3393. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  3394. v := m.updated_at
  3395. if v == nil {
  3396. return
  3397. }
  3398. return *v, true
  3399. }
  3400. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  3401. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3403. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3404. if !m.op.Is(OpUpdateOne) {
  3405. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3406. }
  3407. if m.id == nil || m.oldValue == nil {
  3408. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3409. }
  3410. oldValue, err := m.oldValue(ctx)
  3411. if err != nil {
  3412. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3413. }
  3414. return oldValue.UpdatedAt, nil
  3415. }
  3416. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3417. func (m *ContactMutation) ResetUpdatedAt() {
  3418. m.updated_at = nil
  3419. }
  3420. // SetStatus sets the "status" field.
  3421. func (m *ContactMutation) SetStatus(u uint8) {
  3422. m.status = &u
  3423. m.addstatus = nil
  3424. }
  3425. // Status returns the value of the "status" field in the mutation.
  3426. func (m *ContactMutation) Status() (r uint8, exists bool) {
  3427. v := m.status
  3428. if v == nil {
  3429. return
  3430. }
  3431. return *v, true
  3432. }
  3433. // OldStatus returns the old "status" field's value of the Contact entity.
  3434. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3435. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3436. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  3437. if !m.op.Is(OpUpdateOne) {
  3438. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3439. }
  3440. if m.id == nil || m.oldValue == nil {
  3441. return v, errors.New("OldStatus requires an ID field in the mutation")
  3442. }
  3443. oldValue, err := m.oldValue(ctx)
  3444. if err != nil {
  3445. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3446. }
  3447. return oldValue.Status, nil
  3448. }
  3449. // AddStatus adds u to the "status" field.
  3450. func (m *ContactMutation) AddStatus(u int8) {
  3451. if m.addstatus != nil {
  3452. *m.addstatus += u
  3453. } else {
  3454. m.addstatus = &u
  3455. }
  3456. }
  3457. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3458. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  3459. v := m.addstatus
  3460. if v == nil {
  3461. return
  3462. }
  3463. return *v, true
  3464. }
  3465. // ClearStatus clears the value of the "status" field.
  3466. func (m *ContactMutation) ClearStatus() {
  3467. m.status = nil
  3468. m.addstatus = nil
  3469. m.clearedFields[contact.FieldStatus] = struct{}{}
  3470. }
  3471. // StatusCleared returns if the "status" field was cleared in this mutation.
  3472. func (m *ContactMutation) StatusCleared() bool {
  3473. _, ok := m.clearedFields[contact.FieldStatus]
  3474. return ok
  3475. }
  3476. // ResetStatus resets all changes to the "status" field.
  3477. func (m *ContactMutation) ResetStatus() {
  3478. m.status = nil
  3479. m.addstatus = nil
  3480. delete(m.clearedFields, contact.FieldStatus)
  3481. }
  3482. // SetDeletedAt sets the "deleted_at" field.
  3483. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  3484. m.deleted_at = &t
  3485. }
  3486. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3487. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  3488. v := m.deleted_at
  3489. if v == nil {
  3490. return
  3491. }
  3492. return *v, true
  3493. }
  3494. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  3495. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3497. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3498. if !m.op.Is(OpUpdateOne) {
  3499. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3500. }
  3501. if m.id == nil || m.oldValue == nil {
  3502. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3503. }
  3504. oldValue, err := m.oldValue(ctx)
  3505. if err != nil {
  3506. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3507. }
  3508. return oldValue.DeletedAt, nil
  3509. }
  3510. // ClearDeletedAt clears the value of the "deleted_at" field.
  3511. func (m *ContactMutation) ClearDeletedAt() {
  3512. m.deleted_at = nil
  3513. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  3514. }
  3515. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3516. func (m *ContactMutation) DeletedAtCleared() bool {
  3517. _, ok := m.clearedFields[contact.FieldDeletedAt]
  3518. return ok
  3519. }
  3520. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3521. func (m *ContactMutation) ResetDeletedAt() {
  3522. m.deleted_at = nil
  3523. delete(m.clearedFields, contact.FieldDeletedAt)
  3524. }
  3525. // SetWxWxid sets the "wx_wxid" field.
  3526. func (m *ContactMutation) SetWxWxid(s string) {
  3527. m.wx_wxid = &s
  3528. }
  3529. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  3530. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  3531. v := m.wx_wxid
  3532. if v == nil {
  3533. return
  3534. }
  3535. return *v, true
  3536. }
  3537. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  3538. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3540. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  3541. if !m.op.Is(OpUpdateOne) {
  3542. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  3543. }
  3544. if m.id == nil || m.oldValue == nil {
  3545. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  3546. }
  3547. oldValue, err := m.oldValue(ctx)
  3548. if err != nil {
  3549. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  3550. }
  3551. return oldValue.WxWxid, nil
  3552. }
  3553. // ClearWxWxid clears the value of the "wx_wxid" field.
  3554. func (m *ContactMutation) ClearWxWxid() {
  3555. m.wx_wxid = nil
  3556. m.clearedFields[contact.FieldWxWxid] = struct{}{}
  3557. }
  3558. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  3559. func (m *ContactMutation) WxWxidCleared() bool {
  3560. _, ok := m.clearedFields[contact.FieldWxWxid]
  3561. return ok
  3562. }
  3563. // ResetWxWxid resets all changes to the "wx_wxid" field.
  3564. func (m *ContactMutation) ResetWxWxid() {
  3565. m.wx_wxid = nil
  3566. delete(m.clearedFields, contact.FieldWxWxid)
  3567. }
  3568. // SetType sets the "type" field.
  3569. func (m *ContactMutation) SetType(i int) {
  3570. m._type = &i
  3571. m.add_type = nil
  3572. }
  3573. // GetType returns the value of the "type" field in the mutation.
  3574. func (m *ContactMutation) GetType() (r int, exists bool) {
  3575. v := m._type
  3576. if v == nil {
  3577. return
  3578. }
  3579. return *v, true
  3580. }
  3581. // OldType returns the old "type" field's value of the Contact entity.
  3582. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3583. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3584. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  3585. if !m.op.Is(OpUpdateOne) {
  3586. return v, errors.New("OldType is only allowed on UpdateOne operations")
  3587. }
  3588. if m.id == nil || m.oldValue == nil {
  3589. return v, errors.New("OldType requires an ID field in the mutation")
  3590. }
  3591. oldValue, err := m.oldValue(ctx)
  3592. if err != nil {
  3593. return v, fmt.Errorf("querying old value for OldType: %w", err)
  3594. }
  3595. return oldValue.Type, nil
  3596. }
  3597. // AddType adds i to the "type" field.
  3598. func (m *ContactMutation) AddType(i int) {
  3599. if m.add_type != nil {
  3600. *m.add_type += i
  3601. } else {
  3602. m.add_type = &i
  3603. }
  3604. }
  3605. // AddedType returns the value that was added to the "type" field in this mutation.
  3606. func (m *ContactMutation) AddedType() (r int, exists bool) {
  3607. v := m.add_type
  3608. if v == nil {
  3609. return
  3610. }
  3611. return *v, true
  3612. }
  3613. // ClearType clears the value of the "type" field.
  3614. func (m *ContactMutation) ClearType() {
  3615. m._type = nil
  3616. m.add_type = nil
  3617. m.clearedFields[contact.FieldType] = struct{}{}
  3618. }
  3619. // TypeCleared returns if the "type" field was cleared in this mutation.
  3620. func (m *ContactMutation) TypeCleared() bool {
  3621. _, ok := m.clearedFields[contact.FieldType]
  3622. return ok
  3623. }
  3624. // ResetType resets all changes to the "type" field.
  3625. func (m *ContactMutation) ResetType() {
  3626. m._type = nil
  3627. m.add_type = nil
  3628. delete(m.clearedFields, contact.FieldType)
  3629. }
  3630. // SetWxid sets the "wxid" field.
  3631. func (m *ContactMutation) SetWxid(s string) {
  3632. m.wxid = &s
  3633. }
  3634. // Wxid returns the value of the "wxid" field in the mutation.
  3635. func (m *ContactMutation) Wxid() (r string, exists bool) {
  3636. v := m.wxid
  3637. if v == nil {
  3638. return
  3639. }
  3640. return *v, true
  3641. }
  3642. // OldWxid returns the old "wxid" field's value of the Contact entity.
  3643. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3645. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  3646. if !m.op.Is(OpUpdateOne) {
  3647. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  3648. }
  3649. if m.id == nil || m.oldValue == nil {
  3650. return v, errors.New("OldWxid requires an ID field in the mutation")
  3651. }
  3652. oldValue, err := m.oldValue(ctx)
  3653. if err != nil {
  3654. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  3655. }
  3656. return oldValue.Wxid, nil
  3657. }
  3658. // ResetWxid resets all changes to the "wxid" field.
  3659. func (m *ContactMutation) ResetWxid() {
  3660. m.wxid = nil
  3661. }
  3662. // SetAccount sets the "account" field.
  3663. func (m *ContactMutation) SetAccount(s string) {
  3664. m.account = &s
  3665. }
  3666. // Account returns the value of the "account" field in the mutation.
  3667. func (m *ContactMutation) Account() (r string, exists bool) {
  3668. v := m.account
  3669. if v == nil {
  3670. return
  3671. }
  3672. return *v, true
  3673. }
  3674. // OldAccount returns the old "account" field's value of the Contact entity.
  3675. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3677. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  3678. if !m.op.Is(OpUpdateOne) {
  3679. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  3680. }
  3681. if m.id == nil || m.oldValue == nil {
  3682. return v, errors.New("OldAccount requires an ID field in the mutation")
  3683. }
  3684. oldValue, err := m.oldValue(ctx)
  3685. if err != nil {
  3686. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  3687. }
  3688. return oldValue.Account, nil
  3689. }
  3690. // ResetAccount resets all changes to the "account" field.
  3691. func (m *ContactMutation) ResetAccount() {
  3692. m.account = nil
  3693. }
  3694. // SetNickname sets the "nickname" field.
  3695. func (m *ContactMutation) SetNickname(s string) {
  3696. m.nickname = &s
  3697. }
  3698. // Nickname returns the value of the "nickname" field in the mutation.
  3699. func (m *ContactMutation) Nickname() (r string, exists bool) {
  3700. v := m.nickname
  3701. if v == nil {
  3702. return
  3703. }
  3704. return *v, true
  3705. }
  3706. // OldNickname returns the old "nickname" field's value of the Contact entity.
  3707. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3709. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  3710. if !m.op.Is(OpUpdateOne) {
  3711. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  3712. }
  3713. if m.id == nil || m.oldValue == nil {
  3714. return v, errors.New("OldNickname requires an ID field in the mutation")
  3715. }
  3716. oldValue, err := m.oldValue(ctx)
  3717. if err != nil {
  3718. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  3719. }
  3720. return oldValue.Nickname, nil
  3721. }
  3722. // ResetNickname resets all changes to the "nickname" field.
  3723. func (m *ContactMutation) ResetNickname() {
  3724. m.nickname = nil
  3725. }
  3726. // SetMarkname sets the "markname" field.
  3727. func (m *ContactMutation) SetMarkname(s string) {
  3728. m.markname = &s
  3729. }
  3730. // Markname returns the value of the "markname" field in the mutation.
  3731. func (m *ContactMutation) Markname() (r string, exists bool) {
  3732. v := m.markname
  3733. if v == nil {
  3734. return
  3735. }
  3736. return *v, true
  3737. }
  3738. // OldMarkname returns the old "markname" field's value of the Contact entity.
  3739. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3741. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  3742. if !m.op.Is(OpUpdateOne) {
  3743. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  3744. }
  3745. if m.id == nil || m.oldValue == nil {
  3746. return v, errors.New("OldMarkname requires an ID field in the mutation")
  3747. }
  3748. oldValue, err := m.oldValue(ctx)
  3749. if err != nil {
  3750. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  3751. }
  3752. return oldValue.Markname, nil
  3753. }
  3754. // ResetMarkname resets all changes to the "markname" field.
  3755. func (m *ContactMutation) ResetMarkname() {
  3756. m.markname = nil
  3757. }
  3758. // SetHeadimg sets the "headimg" field.
  3759. func (m *ContactMutation) SetHeadimg(s string) {
  3760. m.headimg = &s
  3761. }
  3762. // Headimg returns the value of the "headimg" field in the mutation.
  3763. func (m *ContactMutation) Headimg() (r string, exists bool) {
  3764. v := m.headimg
  3765. if v == nil {
  3766. return
  3767. }
  3768. return *v, true
  3769. }
  3770. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  3771. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3773. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  3774. if !m.op.Is(OpUpdateOne) {
  3775. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  3776. }
  3777. if m.id == nil || m.oldValue == nil {
  3778. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  3779. }
  3780. oldValue, err := m.oldValue(ctx)
  3781. if err != nil {
  3782. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  3783. }
  3784. return oldValue.Headimg, nil
  3785. }
  3786. // ResetHeadimg resets all changes to the "headimg" field.
  3787. func (m *ContactMutation) ResetHeadimg() {
  3788. m.headimg = nil
  3789. }
  3790. // SetSex sets the "sex" field.
  3791. func (m *ContactMutation) SetSex(i int) {
  3792. m.sex = &i
  3793. m.addsex = nil
  3794. }
  3795. // Sex returns the value of the "sex" field in the mutation.
  3796. func (m *ContactMutation) Sex() (r int, exists bool) {
  3797. v := m.sex
  3798. if v == nil {
  3799. return
  3800. }
  3801. return *v, true
  3802. }
  3803. // OldSex returns the old "sex" field's value of the Contact entity.
  3804. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3806. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  3807. if !m.op.Is(OpUpdateOne) {
  3808. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  3809. }
  3810. if m.id == nil || m.oldValue == nil {
  3811. return v, errors.New("OldSex requires an ID field in the mutation")
  3812. }
  3813. oldValue, err := m.oldValue(ctx)
  3814. if err != nil {
  3815. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  3816. }
  3817. return oldValue.Sex, nil
  3818. }
  3819. // AddSex adds i to the "sex" field.
  3820. func (m *ContactMutation) AddSex(i int) {
  3821. if m.addsex != nil {
  3822. *m.addsex += i
  3823. } else {
  3824. m.addsex = &i
  3825. }
  3826. }
  3827. // AddedSex returns the value that was added to the "sex" field in this mutation.
  3828. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  3829. v := m.addsex
  3830. if v == nil {
  3831. return
  3832. }
  3833. return *v, true
  3834. }
  3835. // ResetSex resets all changes to the "sex" field.
  3836. func (m *ContactMutation) ResetSex() {
  3837. m.sex = nil
  3838. m.addsex = nil
  3839. }
  3840. // SetStarrole sets the "starrole" field.
  3841. func (m *ContactMutation) SetStarrole(s string) {
  3842. m.starrole = &s
  3843. }
  3844. // Starrole returns the value of the "starrole" field in the mutation.
  3845. func (m *ContactMutation) Starrole() (r string, exists bool) {
  3846. v := m.starrole
  3847. if v == nil {
  3848. return
  3849. }
  3850. return *v, true
  3851. }
  3852. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  3853. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3855. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  3856. if !m.op.Is(OpUpdateOne) {
  3857. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  3858. }
  3859. if m.id == nil || m.oldValue == nil {
  3860. return v, errors.New("OldStarrole requires an ID field in the mutation")
  3861. }
  3862. oldValue, err := m.oldValue(ctx)
  3863. if err != nil {
  3864. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  3865. }
  3866. return oldValue.Starrole, nil
  3867. }
  3868. // ResetStarrole resets all changes to the "starrole" field.
  3869. func (m *ContactMutation) ResetStarrole() {
  3870. m.starrole = nil
  3871. }
  3872. // SetDontseeit sets the "dontseeit" field.
  3873. func (m *ContactMutation) SetDontseeit(i int) {
  3874. m.dontseeit = &i
  3875. m.adddontseeit = nil
  3876. }
  3877. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  3878. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  3879. v := m.dontseeit
  3880. if v == nil {
  3881. return
  3882. }
  3883. return *v, true
  3884. }
  3885. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  3886. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3888. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  3889. if !m.op.Is(OpUpdateOne) {
  3890. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  3891. }
  3892. if m.id == nil || m.oldValue == nil {
  3893. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  3894. }
  3895. oldValue, err := m.oldValue(ctx)
  3896. if err != nil {
  3897. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  3898. }
  3899. return oldValue.Dontseeit, nil
  3900. }
  3901. // AddDontseeit adds i to the "dontseeit" field.
  3902. func (m *ContactMutation) AddDontseeit(i int) {
  3903. if m.adddontseeit != nil {
  3904. *m.adddontseeit += i
  3905. } else {
  3906. m.adddontseeit = &i
  3907. }
  3908. }
  3909. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  3910. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  3911. v := m.adddontseeit
  3912. if v == nil {
  3913. return
  3914. }
  3915. return *v, true
  3916. }
  3917. // ResetDontseeit resets all changes to the "dontseeit" field.
  3918. func (m *ContactMutation) ResetDontseeit() {
  3919. m.dontseeit = nil
  3920. m.adddontseeit = nil
  3921. }
  3922. // SetDontseeme sets the "dontseeme" field.
  3923. func (m *ContactMutation) SetDontseeme(i int) {
  3924. m.dontseeme = &i
  3925. m.adddontseeme = nil
  3926. }
  3927. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  3928. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  3929. v := m.dontseeme
  3930. if v == nil {
  3931. return
  3932. }
  3933. return *v, true
  3934. }
  3935. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  3936. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3938. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  3939. if !m.op.Is(OpUpdateOne) {
  3940. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  3941. }
  3942. if m.id == nil || m.oldValue == nil {
  3943. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  3944. }
  3945. oldValue, err := m.oldValue(ctx)
  3946. if err != nil {
  3947. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  3948. }
  3949. return oldValue.Dontseeme, nil
  3950. }
  3951. // AddDontseeme adds i to the "dontseeme" field.
  3952. func (m *ContactMutation) AddDontseeme(i int) {
  3953. if m.adddontseeme != nil {
  3954. *m.adddontseeme += i
  3955. } else {
  3956. m.adddontseeme = &i
  3957. }
  3958. }
  3959. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  3960. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  3961. v := m.adddontseeme
  3962. if v == nil {
  3963. return
  3964. }
  3965. return *v, true
  3966. }
  3967. // ResetDontseeme resets all changes to the "dontseeme" field.
  3968. func (m *ContactMutation) ResetDontseeme() {
  3969. m.dontseeme = nil
  3970. m.adddontseeme = nil
  3971. }
  3972. // SetLag sets the "lag" field.
  3973. func (m *ContactMutation) SetLag(s string) {
  3974. m.lag = &s
  3975. }
  3976. // Lag returns the value of the "lag" field in the mutation.
  3977. func (m *ContactMutation) Lag() (r string, exists bool) {
  3978. v := m.lag
  3979. if v == nil {
  3980. return
  3981. }
  3982. return *v, true
  3983. }
  3984. // OldLag returns the old "lag" field's value of the Contact entity.
  3985. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3987. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  3988. if !m.op.Is(OpUpdateOne) {
  3989. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  3990. }
  3991. if m.id == nil || m.oldValue == nil {
  3992. return v, errors.New("OldLag requires an ID field in the mutation")
  3993. }
  3994. oldValue, err := m.oldValue(ctx)
  3995. if err != nil {
  3996. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  3997. }
  3998. return oldValue.Lag, nil
  3999. }
  4000. // ResetLag resets all changes to the "lag" field.
  4001. func (m *ContactMutation) ResetLag() {
  4002. m.lag = nil
  4003. }
  4004. // SetGid sets the "gid" field.
  4005. func (m *ContactMutation) SetGid(s string) {
  4006. m.gid = &s
  4007. }
  4008. // Gid returns the value of the "gid" field in the mutation.
  4009. func (m *ContactMutation) Gid() (r string, exists bool) {
  4010. v := m.gid
  4011. if v == nil {
  4012. return
  4013. }
  4014. return *v, true
  4015. }
  4016. // OldGid returns the old "gid" field's value of the Contact entity.
  4017. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  4018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4019. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  4020. if !m.op.Is(OpUpdateOne) {
  4021. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  4022. }
  4023. if m.id == nil || m.oldValue == nil {
  4024. return v, errors.New("OldGid requires an ID field in the mutation")
  4025. }
  4026. oldValue, err := m.oldValue(ctx)
  4027. if err != nil {
  4028. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  4029. }
  4030. return oldValue.Gid, nil
  4031. }
  4032. // ResetGid resets all changes to the "gid" field.
  4033. func (m *ContactMutation) ResetGid() {
  4034. m.gid = nil
  4035. }
  4036. // SetGname sets the "gname" field.
  4037. func (m *ContactMutation) SetGname(s string) {
  4038. m.gname = &s
  4039. }
  4040. // Gname returns the value of the "gname" field in the mutation.
  4041. func (m *ContactMutation) Gname() (r string, exists bool) {
  4042. v := m.gname
  4043. if v == nil {
  4044. return
  4045. }
  4046. return *v, true
  4047. }
  4048. // OldGname returns the old "gname" field's value of the Contact entity.
  4049. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  4050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4051. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  4052. if !m.op.Is(OpUpdateOne) {
  4053. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  4054. }
  4055. if m.id == nil || m.oldValue == nil {
  4056. return v, errors.New("OldGname requires an ID field in the mutation")
  4057. }
  4058. oldValue, err := m.oldValue(ctx)
  4059. if err != nil {
  4060. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  4061. }
  4062. return oldValue.Gname, nil
  4063. }
  4064. // ResetGname resets all changes to the "gname" field.
  4065. func (m *ContactMutation) ResetGname() {
  4066. m.gname = nil
  4067. }
  4068. // SetV3 sets the "v3" field.
  4069. func (m *ContactMutation) SetV3(s string) {
  4070. m.v3 = &s
  4071. }
  4072. // V3 returns the value of the "v3" field in the mutation.
  4073. func (m *ContactMutation) V3() (r string, exists bool) {
  4074. v := m.v3
  4075. if v == nil {
  4076. return
  4077. }
  4078. return *v, true
  4079. }
  4080. // OldV3 returns the old "v3" field's value of the Contact entity.
  4081. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  4082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4083. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  4084. if !m.op.Is(OpUpdateOne) {
  4085. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  4086. }
  4087. if m.id == nil || m.oldValue == nil {
  4088. return v, errors.New("OldV3 requires an ID field in the mutation")
  4089. }
  4090. oldValue, err := m.oldValue(ctx)
  4091. if err != nil {
  4092. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  4093. }
  4094. return oldValue.V3, nil
  4095. }
  4096. // ResetV3 resets all changes to the "v3" field.
  4097. func (m *ContactMutation) ResetV3() {
  4098. m.v3 = nil
  4099. }
  4100. // SetOrganizationID sets the "organization_id" field.
  4101. func (m *ContactMutation) SetOrganizationID(u uint64) {
  4102. m.organization_id = &u
  4103. m.addorganization_id = nil
  4104. }
  4105. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4106. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  4107. v := m.organization_id
  4108. if v == nil {
  4109. return
  4110. }
  4111. return *v, true
  4112. }
  4113. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  4114. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  4115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4116. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4117. if !m.op.Is(OpUpdateOne) {
  4118. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4119. }
  4120. if m.id == nil || m.oldValue == nil {
  4121. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4122. }
  4123. oldValue, err := m.oldValue(ctx)
  4124. if err != nil {
  4125. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4126. }
  4127. return oldValue.OrganizationID, nil
  4128. }
  4129. // AddOrganizationID adds u to the "organization_id" field.
  4130. func (m *ContactMutation) AddOrganizationID(u int64) {
  4131. if m.addorganization_id != nil {
  4132. *m.addorganization_id += u
  4133. } else {
  4134. m.addorganization_id = &u
  4135. }
  4136. }
  4137. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4138. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  4139. v := m.addorganization_id
  4140. if v == nil {
  4141. return
  4142. }
  4143. return *v, true
  4144. }
  4145. // ClearOrganizationID clears the value of the "organization_id" field.
  4146. func (m *ContactMutation) ClearOrganizationID() {
  4147. m.organization_id = nil
  4148. m.addorganization_id = nil
  4149. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  4150. }
  4151. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  4152. func (m *ContactMutation) OrganizationIDCleared() bool {
  4153. _, ok := m.clearedFields[contact.FieldOrganizationID]
  4154. return ok
  4155. }
  4156. // ResetOrganizationID resets all changes to the "organization_id" field.
  4157. func (m *ContactMutation) ResetOrganizationID() {
  4158. m.organization_id = nil
  4159. m.addorganization_id = nil
  4160. delete(m.clearedFields, contact.FieldOrganizationID)
  4161. }
  4162. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  4163. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  4164. if m.contact_relationships == nil {
  4165. m.contact_relationships = make(map[uint64]struct{})
  4166. }
  4167. for i := range ids {
  4168. m.contact_relationships[ids[i]] = struct{}{}
  4169. }
  4170. }
  4171. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  4172. func (m *ContactMutation) ClearContactRelationships() {
  4173. m.clearedcontact_relationships = true
  4174. }
  4175. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  4176. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  4177. return m.clearedcontact_relationships
  4178. }
  4179. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  4180. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  4181. if m.removedcontact_relationships == nil {
  4182. m.removedcontact_relationships = make(map[uint64]struct{})
  4183. }
  4184. for i := range ids {
  4185. delete(m.contact_relationships, ids[i])
  4186. m.removedcontact_relationships[ids[i]] = struct{}{}
  4187. }
  4188. }
  4189. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  4190. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  4191. for id := range m.removedcontact_relationships {
  4192. ids = append(ids, id)
  4193. }
  4194. return
  4195. }
  4196. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  4197. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  4198. for id := range m.contact_relationships {
  4199. ids = append(ids, id)
  4200. }
  4201. return
  4202. }
  4203. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  4204. func (m *ContactMutation) ResetContactRelationships() {
  4205. m.contact_relationships = nil
  4206. m.clearedcontact_relationships = false
  4207. m.removedcontact_relationships = nil
  4208. }
  4209. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  4210. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  4211. if m.contact_messages == nil {
  4212. m.contact_messages = make(map[uint64]struct{})
  4213. }
  4214. for i := range ids {
  4215. m.contact_messages[ids[i]] = struct{}{}
  4216. }
  4217. }
  4218. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  4219. func (m *ContactMutation) ClearContactMessages() {
  4220. m.clearedcontact_messages = true
  4221. }
  4222. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  4223. func (m *ContactMutation) ContactMessagesCleared() bool {
  4224. return m.clearedcontact_messages
  4225. }
  4226. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  4227. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  4228. if m.removedcontact_messages == nil {
  4229. m.removedcontact_messages = make(map[uint64]struct{})
  4230. }
  4231. for i := range ids {
  4232. delete(m.contact_messages, ids[i])
  4233. m.removedcontact_messages[ids[i]] = struct{}{}
  4234. }
  4235. }
  4236. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  4237. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  4238. for id := range m.removedcontact_messages {
  4239. ids = append(ids, id)
  4240. }
  4241. return
  4242. }
  4243. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  4244. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  4245. for id := range m.contact_messages {
  4246. ids = append(ids, id)
  4247. }
  4248. return
  4249. }
  4250. // ResetContactMessages resets all changes to the "contact_messages" edge.
  4251. func (m *ContactMutation) ResetContactMessages() {
  4252. m.contact_messages = nil
  4253. m.clearedcontact_messages = false
  4254. m.removedcontact_messages = nil
  4255. }
  4256. // Where appends a list predicates to the ContactMutation builder.
  4257. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  4258. m.predicates = append(m.predicates, ps...)
  4259. }
  4260. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  4261. // users can use type-assertion to append predicates that do not depend on any generated package.
  4262. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  4263. p := make([]predicate.Contact, len(ps))
  4264. for i := range ps {
  4265. p[i] = ps[i]
  4266. }
  4267. m.Where(p...)
  4268. }
  4269. // Op returns the operation name.
  4270. func (m *ContactMutation) Op() Op {
  4271. return m.op
  4272. }
  4273. // SetOp allows setting the mutation operation.
  4274. func (m *ContactMutation) SetOp(op Op) {
  4275. m.op = op
  4276. }
  4277. // Type returns the node type of this mutation (Contact).
  4278. func (m *ContactMutation) Type() string {
  4279. return m.typ
  4280. }
  4281. // Fields returns all fields that were changed during this mutation. Note that in
  4282. // order to get all numeric fields that were incremented/decremented, call
  4283. // AddedFields().
  4284. func (m *ContactMutation) Fields() []string {
  4285. fields := make([]string, 0, 20)
  4286. if m.created_at != nil {
  4287. fields = append(fields, contact.FieldCreatedAt)
  4288. }
  4289. if m.updated_at != nil {
  4290. fields = append(fields, contact.FieldUpdatedAt)
  4291. }
  4292. if m.status != nil {
  4293. fields = append(fields, contact.FieldStatus)
  4294. }
  4295. if m.deleted_at != nil {
  4296. fields = append(fields, contact.FieldDeletedAt)
  4297. }
  4298. if m.wx_wxid != nil {
  4299. fields = append(fields, contact.FieldWxWxid)
  4300. }
  4301. if m._type != nil {
  4302. fields = append(fields, contact.FieldType)
  4303. }
  4304. if m.wxid != nil {
  4305. fields = append(fields, contact.FieldWxid)
  4306. }
  4307. if m.account != nil {
  4308. fields = append(fields, contact.FieldAccount)
  4309. }
  4310. if m.nickname != nil {
  4311. fields = append(fields, contact.FieldNickname)
  4312. }
  4313. if m.markname != nil {
  4314. fields = append(fields, contact.FieldMarkname)
  4315. }
  4316. if m.headimg != nil {
  4317. fields = append(fields, contact.FieldHeadimg)
  4318. }
  4319. if m.sex != nil {
  4320. fields = append(fields, contact.FieldSex)
  4321. }
  4322. if m.starrole != nil {
  4323. fields = append(fields, contact.FieldStarrole)
  4324. }
  4325. if m.dontseeit != nil {
  4326. fields = append(fields, contact.FieldDontseeit)
  4327. }
  4328. if m.dontseeme != nil {
  4329. fields = append(fields, contact.FieldDontseeme)
  4330. }
  4331. if m.lag != nil {
  4332. fields = append(fields, contact.FieldLag)
  4333. }
  4334. if m.gid != nil {
  4335. fields = append(fields, contact.FieldGid)
  4336. }
  4337. if m.gname != nil {
  4338. fields = append(fields, contact.FieldGname)
  4339. }
  4340. if m.v3 != nil {
  4341. fields = append(fields, contact.FieldV3)
  4342. }
  4343. if m.organization_id != nil {
  4344. fields = append(fields, contact.FieldOrganizationID)
  4345. }
  4346. return fields
  4347. }
  4348. // Field returns the value of a field with the given name. The second boolean
  4349. // return value indicates that this field was not set, or was not defined in the
  4350. // schema.
  4351. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  4352. switch name {
  4353. case contact.FieldCreatedAt:
  4354. return m.CreatedAt()
  4355. case contact.FieldUpdatedAt:
  4356. return m.UpdatedAt()
  4357. case contact.FieldStatus:
  4358. return m.Status()
  4359. case contact.FieldDeletedAt:
  4360. return m.DeletedAt()
  4361. case contact.FieldWxWxid:
  4362. return m.WxWxid()
  4363. case contact.FieldType:
  4364. return m.GetType()
  4365. case contact.FieldWxid:
  4366. return m.Wxid()
  4367. case contact.FieldAccount:
  4368. return m.Account()
  4369. case contact.FieldNickname:
  4370. return m.Nickname()
  4371. case contact.FieldMarkname:
  4372. return m.Markname()
  4373. case contact.FieldHeadimg:
  4374. return m.Headimg()
  4375. case contact.FieldSex:
  4376. return m.Sex()
  4377. case contact.FieldStarrole:
  4378. return m.Starrole()
  4379. case contact.FieldDontseeit:
  4380. return m.Dontseeit()
  4381. case contact.FieldDontseeme:
  4382. return m.Dontseeme()
  4383. case contact.FieldLag:
  4384. return m.Lag()
  4385. case contact.FieldGid:
  4386. return m.Gid()
  4387. case contact.FieldGname:
  4388. return m.Gname()
  4389. case contact.FieldV3:
  4390. return m.V3()
  4391. case contact.FieldOrganizationID:
  4392. return m.OrganizationID()
  4393. }
  4394. return nil, false
  4395. }
  4396. // OldField returns the old value of the field from the database. An error is
  4397. // returned if the mutation operation is not UpdateOne, or the query to the
  4398. // database failed.
  4399. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4400. switch name {
  4401. case contact.FieldCreatedAt:
  4402. return m.OldCreatedAt(ctx)
  4403. case contact.FieldUpdatedAt:
  4404. return m.OldUpdatedAt(ctx)
  4405. case contact.FieldStatus:
  4406. return m.OldStatus(ctx)
  4407. case contact.FieldDeletedAt:
  4408. return m.OldDeletedAt(ctx)
  4409. case contact.FieldWxWxid:
  4410. return m.OldWxWxid(ctx)
  4411. case contact.FieldType:
  4412. return m.OldType(ctx)
  4413. case contact.FieldWxid:
  4414. return m.OldWxid(ctx)
  4415. case contact.FieldAccount:
  4416. return m.OldAccount(ctx)
  4417. case contact.FieldNickname:
  4418. return m.OldNickname(ctx)
  4419. case contact.FieldMarkname:
  4420. return m.OldMarkname(ctx)
  4421. case contact.FieldHeadimg:
  4422. return m.OldHeadimg(ctx)
  4423. case contact.FieldSex:
  4424. return m.OldSex(ctx)
  4425. case contact.FieldStarrole:
  4426. return m.OldStarrole(ctx)
  4427. case contact.FieldDontseeit:
  4428. return m.OldDontseeit(ctx)
  4429. case contact.FieldDontseeme:
  4430. return m.OldDontseeme(ctx)
  4431. case contact.FieldLag:
  4432. return m.OldLag(ctx)
  4433. case contact.FieldGid:
  4434. return m.OldGid(ctx)
  4435. case contact.FieldGname:
  4436. return m.OldGname(ctx)
  4437. case contact.FieldV3:
  4438. return m.OldV3(ctx)
  4439. case contact.FieldOrganizationID:
  4440. return m.OldOrganizationID(ctx)
  4441. }
  4442. return nil, fmt.Errorf("unknown Contact field %s", name)
  4443. }
  4444. // SetField sets the value of a field with the given name. It returns an error if
  4445. // the field is not defined in the schema, or if the type mismatched the field
  4446. // type.
  4447. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  4448. switch name {
  4449. case contact.FieldCreatedAt:
  4450. v, ok := value.(time.Time)
  4451. if !ok {
  4452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4453. }
  4454. m.SetCreatedAt(v)
  4455. return nil
  4456. case contact.FieldUpdatedAt:
  4457. v, ok := value.(time.Time)
  4458. if !ok {
  4459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4460. }
  4461. m.SetUpdatedAt(v)
  4462. return nil
  4463. case contact.FieldStatus:
  4464. v, ok := value.(uint8)
  4465. if !ok {
  4466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4467. }
  4468. m.SetStatus(v)
  4469. return nil
  4470. case contact.FieldDeletedAt:
  4471. v, ok := value.(time.Time)
  4472. if !ok {
  4473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4474. }
  4475. m.SetDeletedAt(v)
  4476. return nil
  4477. case contact.FieldWxWxid:
  4478. v, ok := value.(string)
  4479. if !ok {
  4480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4481. }
  4482. m.SetWxWxid(v)
  4483. return nil
  4484. case contact.FieldType:
  4485. v, ok := value.(int)
  4486. if !ok {
  4487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4488. }
  4489. m.SetType(v)
  4490. return nil
  4491. case contact.FieldWxid:
  4492. v, ok := value.(string)
  4493. if !ok {
  4494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4495. }
  4496. m.SetWxid(v)
  4497. return nil
  4498. case contact.FieldAccount:
  4499. v, ok := value.(string)
  4500. if !ok {
  4501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4502. }
  4503. m.SetAccount(v)
  4504. return nil
  4505. case contact.FieldNickname:
  4506. v, ok := value.(string)
  4507. if !ok {
  4508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4509. }
  4510. m.SetNickname(v)
  4511. return nil
  4512. case contact.FieldMarkname:
  4513. v, ok := value.(string)
  4514. if !ok {
  4515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4516. }
  4517. m.SetMarkname(v)
  4518. return nil
  4519. case contact.FieldHeadimg:
  4520. v, ok := value.(string)
  4521. if !ok {
  4522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4523. }
  4524. m.SetHeadimg(v)
  4525. return nil
  4526. case contact.FieldSex:
  4527. v, ok := value.(int)
  4528. if !ok {
  4529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4530. }
  4531. m.SetSex(v)
  4532. return nil
  4533. case contact.FieldStarrole:
  4534. v, ok := value.(string)
  4535. if !ok {
  4536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4537. }
  4538. m.SetStarrole(v)
  4539. return nil
  4540. case contact.FieldDontseeit:
  4541. v, ok := value.(int)
  4542. if !ok {
  4543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4544. }
  4545. m.SetDontseeit(v)
  4546. return nil
  4547. case contact.FieldDontseeme:
  4548. v, ok := value.(int)
  4549. if !ok {
  4550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4551. }
  4552. m.SetDontseeme(v)
  4553. return nil
  4554. case contact.FieldLag:
  4555. v, ok := value.(string)
  4556. if !ok {
  4557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4558. }
  4559. m.SetLag(v)
  4560. return nil
  4561. case contact.FieldGid:
  4562. v, ok := value.(string)
  4563. if !ok {
  4564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4565. }
  4566. m.SetGid(v)
  4567. return nil
  4568. case contact.FieldGname:
  4569. v, ok := value.(string)
  4570. if !ok {
  4571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4572. }
  4573. m.SetGname(v)
  4574. return nil
  4575. case contact.FieldV3:
  4576. v, ok := value.(string)
  4577. if !ok {
  4578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4579. }
  4580. m.SetV3(v)
  4581. return nil
  4582. case contact.FieldOrganizationID:
  4583. v, ok := value.(uint64)
  4584. if !ok {
  4585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4586. }
  4587. m.SetOrganizationID(v)
  4588. return nil
  4589. }
  4590. return fmt.Errorf("unknown Contact field %s", name)
  4591. }
  4592. // AddedFields returns all numeric fields that were incremented/decremented during
  4593. // this mutation.
  4594. func (m *ContactMutation) AddedFields() []string {
  4595. var fields []string
  4596. if m.addstatus != nil {
  4597. fields = append(fields, contact.FieldStatus)
  4598. }
  4599. if m.add_type != nil {
  4600. fields = append(fields, contact.FieldType)
  4601. }
  4602. if m.addsex != nil {
  4603. fields = append(fields, contact.FieldSex)
  4604. }
  4605. if m.adddontseeit != nil {
  4606. fields = append(fields, contact.FieldDontseeit)
  4607. }
  4608. if m.adddontseeme != nil {
  4609. fields = append(fields, contact.FieldDontseeme)
  4610. }
  4611. if m.addorganization_id != nil {
  4612. fields = append(fields, contact.FieldOrganizationID)
  4613. }
  4614. return fields
  4615. }
  4616. // AddedField returns the numeric value that was incremented/decremented on a field
  4617. // with the given name. The second boolean return value indicates that this field
  4618. // was not set, or was not defined in the schema.
  4619. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  4620. switch name {
  4621. case contact.FieldStatus:
  4622. return m.AddedStatus()
  4623. case contact.FieldType:
  4624. return m.AddedType()
  4625. case contact.FieldSex:
  4626. return m.AddedSex()
  4627. case contact.FieldDontseeit:
  4628. return m.AddedDontseeit()
  4629. case contact.FieldDontseeme:
  4630. return m.AddedDontseeme()
  4631. case contact.FieldOrganizationID:
  4632. return m.AddedOrganizationID()
  4633. }
  4634. return nil, false
  4635. }
  4636. // AddField adds the value to the field with the given name. It returns an error if
  4637. // the field is not defined in the schema, or if the type mismatched the field
  4638. // type.
  4639. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  4640. switch name {
  4641. case contact.FieldStatus:
  4642. v, ok := value.(int8)
  4643. if !ok {
  4644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4645. }
  4646. m.AddStatus(v)
  4647. return nil
  4648. case contact.FieldType:
  4649. v, ok := value.(int)
  4650. if !ok {
  4651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4652. }
  4653. m.AddType(v)
  4654. return nil
  4655. case contact.FieldSex:
  4656. v, ok := value.(int)
  4657. if !ok {
  4658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4659. }
  4660. m.AddSex(v)
  4661. return nil
  4662. case contact.FieldDontseeit:
  4663. v, ok := value.(int)
  4664. if !ok {
  4665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4666. }
  4667. m.AddDontseeit(v)
  4668. return nil
  4669. case contact.FieldDontseeme:
  4670. v, ok := value.(int)
  4671. if !ok {
  4672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4673. }
  4674. m.AddDontseeme(v)
  4675. return nil
  4676. case contact.FieldOrganizationID:
  4677. v, ok := value.(int64)
  4678. if !ok {
  4679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4680. }
  4681. m.AddOrganizationID(v)
  4682. return nil
  4683. }
  4684. return fmt.Errorf("unknown Contact numeric field %s", name)
  4685. }
  4686. // ClearedFields returns all nullable fields that were cleared during this
  4687. // mutation.
  4688. func (m *ContactMutation) ClearedFields() []string {
  4689. var fields []string
  4690. if m.FieldCleared(contact.FieldStatus) {
  4691. fields = append(fields, contact.FieldStatus)
  4692. }
  4693. if m.FieldCleared(contact.FieldDeletedAt) {
  4694. fields = append(fields, contact.FieldDeletedAt)
  4695. }
  4696. if m.FieldCleared(contact.FieldWxWxid) {
  4697. fields = append(fields, contact.FieldWxWxid)
  4698. }
  4699. if m.FieldCleared(contact.FieldType) {
  4700. fields = append(fields, contact.FieldType)
  4701. }
  4702. if m.FieldCleared(contact.FieldOrganizationID) {
  4703. fields = append(fields, contact.FieldOrganizationID)
  4704. }
  4705. return fields
  4706. }
  4707. // FieldCleared returns a boolean indicating if a field with the given name was
  4708. // cleared in this mutation.
  4709. func (m *ContactMutation) FieldCleared(name string) bool {
  4710. _, ok := m.clearedFields[name]
  4711. return ok
  4712. }
  4713. // ClearField clears the value of the field with the given name. It returns an
  4714. // error if the field is not defined in the schema.
  4715. func (m *ContactMutation) ClearField(name string) error {
  4716. switch name {
  4717. case contact.FieldStatus:
  4718. m.ClearStatus()
  4719. return nil
  4720. case contact.FieldDeletedAt:
  4721. m.ClearDeletedAt()
  4722. return nil
  4723. case contact.FieldWxWxid:
  4724. m.ClearWxWxid()
  4725. return nil
  4726. case contact.FieldType:
  4727. m.ClearType()
  4728. return nil
  4729. case contact.FieldOrganizationID:
  4730. m.ClearOrganizationID()
  4731. return nil
  4732. }
  4733. return fmt.Errorf("unknown Contact nullable field %s", name)
  4734. }
  4735. // ResetField resets all changes in the mutation for the field with the given name.
  4736. // It returns an error if the field is not defined in the schema.
  4737. func (m *ContactMutation) ResetField(name string) error {
  4738. switch name {
  4739. case contact.FieldCreatedAt:
  4740. m.ResetCreatedAt()
  4741. return nil
  4742. case contact.FieldUpdatedAt:
  4743. m.ResetUpdatedAt()
  4744. return nil
  4745. case contact.FieldStatus:
  4746. m.ResetStatus()
  4747. return nil
  4748. case contact.FieldDeletedAt:
  4749. m.ResetDeletedAt()
  4750. return nil
  4751. case contact.FieldWxWxid:
  4752. m.ResetWxWxid()
  4753. return nil
  4754. case contact.FieldType:
  4755. m.ResetType()
  4756. return nil
  4757. case contact.FieldWxid:
  4758. m.ResetWxid()
  4759. return nil
  4760. case contact.FieldAccount:
  4761. m.ResetAccount()
  4762. return nil
  4763. case contact.FieldNickname:
  4764. m.ResetNickname()
  4765. return nil
  4766. case contact.FieldMarkname:
  4767. m.ResetMarkname()
  4768. return nil
  4769. case contact.FieldHeadimg:
  4770. m.ResetHeadimg()
  4771. return nil
  4772. case contact.FieldSex:
  4773. m.ResetSex()
  4774. return nil
  4775. case contact.FieldStarrole:
  4776. m.ResetStarrole()
  4777. return nil
  4778. case contact.FieldDontseeit:
  4779. m.ResetDontseeit()
  4780. return nil
  4781. case contact.FieldDontseeme:
  4782. m.ResetDontseeme()
  4783. return nil
  4784. case contact.FieldLag:
  4785. m.ResetLag()
  4786. return nil
  4787. case contact.FieldGid:
  4788. m.ResetGid()
  4789. return nil
  4790. case contact.FieldGname:
  4791. m.ResetGname()
  4792. return nil
  4793. case contact.FieldV3:
  4794. m.ResetV3()
  4795. return nil
  4796. case contact.FieldOrganizationID:
  4797. m.ResetOrganizationID()
  4798. return nil
  4799. }
  4800. return fmt.Errorf("unknown Contact field %s", name)
  4801. }
  4802. // AddedEdges returns all edge names that were set/added in this mutation.
  4803. func (m *ContactMutation) AddedEdges() []string {
  4804. edges := make([]string, 0, 2)
  4805. if m.contact_relationships != nil {
  4806. edges = append(edges, contact.EdgeContactRelationships)
  4807. }
  4808. if m.contact_messages != nil {
  4809. edges = append(edges, contact.EdgeContactMessages)
  4810. }
  4811. return edges
  4812. }
  4813. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4814. // name in this mutation.
  4815. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  4816. switch name {
  4817. case contact.EdgeContactRelationships:
  4818. ids := make([]ent.Value, 0, len(m.contact_relationships))
  4819. for id := range m.contact_relationships {
  4820. ids = append(ids, id)
  4821. }
  4822. return ids
  4823. case contact.EdgeContactMessages:
  4824. ids := make([]ent.Value, 0, len(m.contact_messages))
  4825. for id := range m.contact_messages {
  4826. ids = append(ids, id)
  4827. }
  4828. return ids
  4829. }
  4830. return nil
  4831. }
  4832. // RemovedEdges returns all edge names that were removed in this mutation.
  4833. func (m *ContactMutation) RemovedEdges() []string {
  4834. edges := make([]string, 0, 2)
  4835. if m.removedcontact_relationships != nil {
  4836. edges = append(edges, contact.EdgeContactRelationships)
  4837. }
  4838. if m.removedcontact_messages != nil {
  4839. edges = append(edges, contact.EdgeContactMessages)
  4840. }
  4841. return edges
  4842. }
  4843. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4844. // the given name in this mutation.
  4845. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  4846. switch name {
  4847. case contact.EdgeContactRelationships:
  4848. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  4849. for id := range m.removedcontact_relationships {
  4850. ids = append(ids, id)
  4851. }
  4852. return ids
  4853. case contact.EdgeContactMessages:
  4854. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  4855. for id := range m.removedcontact_messages {
  4856. ids = append(ids, id)
  4857. }
  4858. return ids
  4859. }
  4860. return nil
  4861. }
  4862. // ClearedEdges returns all edge names that were cleared in this mutation.
  4863. func (m *ContactMutation) ClearedEdges() []string {
  4864. edges := make([]string, 0, 2)
  4865. if m.clearedcontact_relationships {
  4866. edges = append(edges, contact.EdgeContactRelationships)
  4867. }
  4868. if m.clearedcontact_messages {
  4869. edges = append(edges, contact.EdgeContactMessages)
  4870. }
  4871. return edges
  4872. }
  4873. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4874. // was cleared in this mutation.
  4875. func (m *ContactMutation) EdgeCleared(name string) bool {
  4876. switch name {
  4877. case contact.EdgeContactRelationships:
  4878. return m.clearedcontact_relationships
  4879. case contact.EdgeContactMessages:
  4880. return m.clearedcontact_messages
  4881. }
  4882. return false
  4883. }
  4884. // ClearEdge clears the value of the edge with the given name. It returns an error
  4885. // if that edge is not defined in the schema.
  4886. func (m *ContactMutation) ClearEdge(name string) error {
  4887. switch name {
  4888. }
  4889. return fmt.Errorf("unknown Contact unique edge %s", name)
  4890. }
  4891. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4892. // It returns an error if the edge is not defined in the schema.
  4893. func (m *ContactMutation) ResetEdge(name string) error {
  4894. switch name {
  4895. case contact.EdgeContactRelationships:
  4896. m.ResetContactRelationships()
  4897. return nil
  4898. case contact.EdgeContactMessages:
  4899. m.ResetContactMessages()
  4900. return nil
  4901. }
  4902. return fmt.Errorf("unknown Contact edge %s", name)
  4903. }
  4904. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  4905. type EmployeeMutation struct {
  4906. config
  4907. op Op
  4908. typ string
  4909. id *uint64
  4910. created_at *time.Time
  4911. updated_at *time.Time
  4912. deleted_at *time.Time
  4913. title *string
  4914. avatar *string
  4915. tags *string
  4916. hire_count *int
  4917. addhire_count *int
  4918. service_count *int
  4919. addservice_count *int
  4920. achievement_count *int
  4921. addachievement_count *int
  4922. intro *string
  4923. estimate *string
  4924. skill *string
  4925. ability_type *string
  4926. scene *string
  4927. switch_in *string
  4928. video_url *string
  4929. organization_id *uint64
  4930. addorganization_id *int64
  4931. category_id *uint64
  4932. addcategory_id *int64
  4933. clearedFields map[string]struct{}
  4934. em_work_experiences map[uint64]struct{}
  4935. removedem_work_experiences map[uint64]struct{}
  4936. clearedem_work_experiences bool
  4937. em_tutorial map[uint64]struct{}
  4938. removedem_tutorial map[uint64]struct{}
  4939. clearedem_tutorial bool
  4940. done bool
  4941. oldValue func(context.Context) (*Employee, error)
  4942. predicates []predicate.Employee
  4943. }
  4944. var _ ent.Mutation = (*EmployeeMutation)(nil)
  4945. // employeeOption allows management of the mutation configuration using functional options.
  4946. type employeeOption func(*EmployeeMutation)
  4947. // newEmployeeMutation creates new mutation for the Employee entity.
  4948. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  4949. m := &EmployeeMutation{
  4950. config: c,
  4951. op: op,
  4952. typ: TypeEmployee,
  4953. clearedFields: make(map[string]struct{}),
  4954. }
  4955. for _, opt := range opts {
  4956. opt(m)
  4957. }
  4958. return m
  4959. }
  4960. // withEmployeeID sets the ID field of the mutation.
  4961. func withEmployeeID(id uint64) employeeOption {
  4962. return func(m *EmployeeMutation) {
  4963. var (
  4964. err error
  4965. once sync.Once
  4966. value *Employee
  4967. )
  4968. m.oldValue = func(ctx context.Context) (*Employee, error) {
  4969. once.Do(func() {
  4970. if m.done {
  4971. err = errors.New("querying old values post mutation is not allowed")
  4972. } else {
  4973. value, err = m.Client().Employee.Get(ctx, id)
  4974. }
  4975. })
  4976. return value, err
  4977. }
  4978. m.id = &id
  4979. }
  4980. }
  4981. // withEmployee sets the old Employee of the mutation.
  4982. func withEmployee(node *Employee) employeeOption {
  4983. return func(m *EmployeeMutation) {
  4984. m.oldValue = func(context.Context) (*Employee, error) {
  4985. return node, nil
  4986. }
  4987. m.id = &node.ID
  4988. }
  4989. }
  4990. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4991. // executed in a transaction (ent.Tx), a transactional client is returned.
  4992. func (m EmployeeMutation) Client() *Client {
  4993. client := &Client{config: m.config}
  4994. client.init()
  4995. return client
  4996. }
  4997. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4998. // it returns an error otherwise.
  4999. func (m EmployeeMutation) Tx() (*Tx, error) {
  5000. if _, ok := m.driver.(*txDriver); !ok {
  5001. return nil, errors.New("ent: mutation is not running in a transaction")
  5002. }
  5003. tx := &Tx{config: m.config}
  5004. tx.init()
  5005. return tx, nil
  5006. }
  5007. // SetID sets the value of the id field. Note that this
  5008. // operation is only accepted on creation of Employee entities.
  5009. func (m *EmployeeMutation) SetID(id uint64) {
  5010. m.id = &id
  5011. }
  5012. // ID returns the ID value in the mutation. Note that the ID is only available
  5013. // if it was provided to the builder or after it was returned from the database.
  5014. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  5015. if m.id == nil {
  5016. return
  5017. }
  5018. return *m.id, true
  5019. }
  5020. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5021. // That means, if the mutation is applied within a transaction with an isolation level such
  5022. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5023. // or updated by the mutation.
  5024. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  5025. switch {
  5026. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5027. id, exists := m.ID()
  5028. if exists {
  5029. return []uint64{id}, nil
  5030. }
  5031. fallthrough
  5032. case m.op.Is(OpUpdate | OpDelete):
  5033. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  5034. default:
  5035. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5036. }
  5037. }
  5038. // SetCreatedAt sets the "created_at" field.
  5039. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  5040. m.created_at = &t
  5041. }
  5042. // CreatedAt returns the value of the "created_at" field in the mutation.
  5043. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  5044. v := m.created_at
  5045. if v == nil {
  5046. return
  5047. }
  5048. return *v, true
  5049. }
  5050. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  5051. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5053. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5054. if !m.op.Is(OpUpdateOne) {
  5055. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5056. }
  5057. if m.id == nil || m.oldValue == nil {
  5058. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5059. }
  5060. oldValue, err := m.oldValue(ctx)
  5061. if err != nil {
  5062. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5063. }
  5064. return oldValue.CreatedAt, nil
  5065. }
  5066. // ResetCreatedAt resets all changes to the "created_at" field.
  5067. func (m *EmployeeMutation) ResetCreatedAt() {
  5068. m.created_at = nil
  5069. }
  5070. // SetUpdatedAt sets the "updated_at" field.
  5071. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  5072. m.updated_at = &t
  5073. }
  5074. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5075. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  5076. v := m.updated_at
  5077. if v == nil {
  5078. return
  5079. }
  5080. return *v, true
  5081. }
  5082. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  5083. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5085. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5086. if !m.op.Is(OpUpdateOne) {
  5087. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5088. }
  5089. if m.id == nil || m.oldValue == nil {
  5090. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5091. }
  5092. oldValue, err := m.oldValue(ctx)
  5093. if err != nil {
  5094. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5095. }
  5096. return oldValue.UpdatedAt, nil
  5097. }
  5098. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5099. func (m *EmployeeMutation) ResetUpdatedAt() {
  5100. m.updated_at = nil
  5101. }
  5102. // SetDeletedAt sets the "deleted_at" field.
  5103. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  5104. m.deleted_at = &t
  5105. }
  5106. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5107. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  5108. v := m.deleted_at
  5109. if v == nil {
  5110. return
  5111. }
  5112. return *v, true
  5113. }
  5114. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  5115. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5116. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5117. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5118. if !m.op.Is(OpUpdateOne) {
  5119. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5120. }
  5121. if m.id == nil || m.oldValue == nil {
  5122. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5123. }
  5124. oldValue, err := m.oldValue(ctx)
  5125. if err != nil {
  5126. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5127. }
  5128. return oldValue.DeletedAt, nil
  5129. }
  5130. // ClearDeletedAt clears the value of the "deleted_at" field.
  5131. func (m *EmployeeMutation) ClearDeletedAt() {
  5132. m.deleted_at = nil
  5133. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  5134. }
  5135. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5136. func (m *EmployeeMutation) DeletedAtCleared() bool {
  5137. _, ok := m.clearedFields[employee.FieldDeletedAt]
  5138. return ok
  5139. }
  5140. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5141. func (m *EmployeeMutation) ResetDeletedAt() {
  5142. m.deleted_at = nil
  5143. delete(m.clearedFields, employee.FieldDeletedAt)
  5144. }
  5145. // SetTitle sets the "title" field.
  5146. func (m *EmployeeMutation) SetTitle(s string) {
  5147. m.title = &s
  5148. }
  5149. // Title returns the value of the "title" field in the mutation.
  5150. func (m *EmployeeMutation) Title() (r string, exists bool) {
  5151. v := m.title
  5152. if v == nil {
  5153. return
  5154. }
  5155. return *v, true
  5156. }
  5157. // OldTitle returns the old "title" field's value of the Employee entity.
  5158. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5160. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  5161. if !m.op.Is(OpUpdateOne) {
  5162. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  5163. }
  5164. if m.id == nil || m.oldValue == nil {
  5165. return v, errors.New("OldTitle requires an ID field in the mutation")
  5166. }
  5167. oldValue, err := m.oldValue(ctx)
  5168. if err != nil {
  5169. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  5170. }
  5171. return oldValue.Title, nil
  5172. }
  5173. // ResetTitle resets all changes to the "title" field.
  5174. func (m *EmployeeMutation) ResetTitle() {
  5175. m.title = nil
  5176. }
  5177. // SetAvatar sets the "avatar" field.
  5178. func (m *EmployeeMutation) SetAvatar(s string) {
  5179. m.avatar = &s
  5180. }
  5181. // Avatar returns the value of the "avatar" field in the mutation.
  5182. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  5183. v := m.avatar
  5184. if v == nil {
  5185. return
  5186. }
  5187. return *v, true
  5188. }
  5189. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  5190. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5192. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  5193. if !m.op.Is(OpUpdateOne) {
  5194. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  5195. }
  5196. if m.id == nil || m.oldValue == nil {
  5197. return v, errors.New("OldAvatar requires an ID field in the mutation")
  5198. }
  5199. oldValue, err := m.oldValue(ctx)
  5200. if err != nil {
  5201. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  5202. }
  5203. return oldValue.Avatar, nil
  5204. }
  5205. // ResetAvatar resets all changes to the "avatar" field.
  5206. func (m *EmployeeMutation) ResetAvatar() {
  5207. m.avatar = nil
  5208. }
  5209. // SetTags sets the "tags" field.
  5210. func (m *EmployeeMutation) SetTags(s string) {
  5211. m.tags = &s
  5212. }
  5213. // Tags returns the value of the "tags" field in the mutation.
  5214. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  5215. v := m.tags
  5216. if v == nil {
  5217. return
  5218. }
  5219. return *v, true
  5220. }
  5221. // OldTags returns the old "tags" field's value of the Employee entity.
  5222. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5224. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  5225. if !m.op.Is(OpUpdateOne) {
  5226. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  5227. }
  5228. if m.id == nil || m.oldValue == nil {
  5229. return v, errors.New("OldTags requires an ID field in the mutation")
  5230. }
  5231. oldValue, err := m.oldValue(ctx)
  5232. if err != nil {
  5233. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  5234. }
  5235. return oldValue.Tags, nil
  5236. }
  5237. // ResetTags resets all changes to the "tags" field.
  5238. func (m *EmployeeMutation) ResetTags() {
  5239. m.tags = nil
  5240. }
  5241. // SetHireCount sets the "hire_count" field.
  5242. func (m *EmployeeMutation) SetHireCount(i int) {
  5243. m.hire_count = &i
  5244. m.addhire_count = nil
  5245. }
  5246. // HireCount returns the value of the "hire_count" field in the mutation.
  5247. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  5248. v := m.hire_count
  5249. if v == nil {
  5250. return
  5251. }
  5252. return *v, true
  5253. }
  5254. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  5255. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5257. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  5258. if !m.op.Is(OpUpdateOne) {
  5259. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  5260. }
  5261. if m.id == nil || m.oldValue == nil {
  5262. return v, errors.New("OldHireCount requires an ID field in the mutation")
  5263. }
  5264. oldValue, err := m.oldValue(ctx)
  5265. if err != nil {
  5266. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  5267. }
  5268. return oldValue.HireCount, nil
  5269. }
  5270. // AddHireCount adds i to the "hire_count" field.
  5271. func (m *EmployeeMutation) AddHireCount(i int) {
  5272. if m.addhire_count != nil {
  5273. *m.addhire_count += i
  5274. } else {
  5275. m.addhire_count = &i
  5276. }
  5277. }
  5278. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  5279. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  5280. v := m.addhire_count
  5281. if v == nil {
  5282. return
  5283. }
  5284. return *v, true
  5285. }
  5286. // ResetHireCount resets all changes to the "hire_count" field.
  5287. func (m *EmployeeMutation) ResetHireCount() {
  5288. m.hire_count = nil
  5289. m.addhire_count = nil
  5290. }
  5291. // SetServiceCount sets the "service_count" field.
  5292. func (m *EmployeeMutation) SetServiceCount(i int) {
  5293. m.service_count = &i
  5294. m.addservice_count = nil
  5295. }
  5296. // ServiceCount returns the value of the "service_count" field in the mutation.
  5297. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  5298. v := m.service_count
  5299. if v == nil {
  5300. return
  5301. }
  5302. return *v, true
  5303. }
  5304. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  5305. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5307. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  5308. if !m.op.Is(OpUpdateOne) {
  5309. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  5310. }
  5311. if m.id == nil || m.oldValue == nil {
  5312. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  5313. }
  5314. oldValue, err := m.oldValue(ctx)
  5315. if err != nil {
  5316. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  5317. }
  5318. return oldValue.ServiceCount, nil
  5319. }
  5320. // AddServiceCount adds i to the "service_count" field.
  5321. func (m *EmployeeMutation) AddServiceCount(i int) {
  5322. if m.addservice_count != nil {
  5323. *m.addservice_count += i
  5324. } else {
  5325. m.addservice_count = &i
  5326. }
  5327. }
  5328. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  5329. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  5330. v := m.addservice_count
  5331. if v == nil {
  5332. return
  5333. }
  5334. return *v, true
  5335. }
  5336. // ResetServiceCount resets all changes to the "service_count" field.
  5337. func (m *EmployeeMutation) ResetServiceCount() {
  5338. m.service_count = nil
  5339. m.addservice_count = nil
  5340. }
  5341. // SetAchievementCount sets the "achievement_count" field.
  5342. func (m *EmployeeMutation) SetAchievementCount(i int) {
  5343. m.achievement_count = &i
  5344. m.addachievement_count = nil
  5345. }
  5346. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  5347. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  5348. v := m.achievement_count
  5349. if v == nil {
  5350. return
  5351. }
  5352. return *v, true
  5353. }
  5354. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  5355. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5357. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  5358. if !m.op.Is(OpUpdateOne) {
  5359. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  5360. }
  5361. if m.id == nil || m.oldValue == nil {
  5362. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  5363. }
  5364. oldValue, err := m.oldValue(ctx)
  5365. if err != nil {
  5366. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  5367. }
  5368. return oldValue.AchievementCount, nil
  5369. }
  5370. // AddAchievementCount adds i to the "achievement_count" field.
  5371. func (m *EmployeeMutation) AddAchievementCount(i int) {
  5372. if m.addachievement_count != nil {
  5373. *m.addachievement_count += i
  5374. } else {
  5375. m.addachievement_count = &i
  5376. }
  5377. }
  5378. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  5379. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  5380. v := m.addachievement_count
  5381. if v == nil {
  5382. return
  5383. }
  5384. return *v, true
  5385. }
  5386. // ResetAchievementCount resets all changes to the "achievement_count" field.
  5387. func (m *EmployeeMutation) ResetAchievementCount() {
  5388. m.achievement_count = nil
  5389. m.addachievement_count = nil
  5390. }
  5391. // SetIntro sets the "intro" field.
  5392. func (m *EmployeeMutation) SetIntro(s string) {
  5393. m.intro = &s
  5394. }
  5395. // Intro returns the value of the "intro" field in the mutation.
  5396. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  5397. v := m.intro
  5398. if v == nil {
  5399. return
  5400. }
  5401. return *v, true
  5402. }
  5403. // OldIntro returns the old "intro" field's value of the Employee entity.
  5404. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5406. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  5407. if !m.op.Is(OpUpdateOne) {
  5408. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  5409. }
  5410. if m.id == nil || m.oldValue == nil {
  5411. return v, errors.New("OldIntro requires an ID field in the mutation")
  5412. }
  5413. oldValue, err := m.oldValue(ctx)
  5414. if err != nil {
  5415. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  5416. }
  5417. return oldValue.Intro, nil
  5418. }
  5419. // ResetIntro resets all changes to the "intro" field.
  5420. func (m *EmployeeMutation) ResetIntro() {
  5421. m.intro = nil
  5422. }
  5423. // SetEstimate sets the "estimate" field.
  5424. func (m *EmployeeMutation) SetEstimate(s string) {
  5425. m.estimate = &s
  5426. }
  5427. // Estimate returns the value of the "estimate" field in the mutation.
  5428. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  5429. v := m.estimate
  5430. if v == nil {
  5431. return
  5432. }
  5433. return *v, true
  5434. }
  5435. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  5436. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5438. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  5439. if !m.op.Is(OpUpdateOne) {
  5440. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  5441. }
  5442. if m.id == nil || m.oldValue == nil {
  5443. return v, errors.New("OldEstimate requires an ID field in the mutation")
  5444. }
  5445. oldValue, err := m.oldValue(ctx)
  5446. if err != nil {
  5447. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  5448. }
  5449. return oldValue.Estimate, nil
  5450. }
  5451. // ResetEstimate resets all changes to the "estimate" field.
  5452. func (m *EmployeeMutation) ResetEstimate() {
  5453. m.estimate = nil
  5454. }
  5455. // SetSkill sets the "skill" field.
  5456. func (m *EmployeeMutation) SetSkill(s string) {
  5457. m.skill = &s
  5458. }
  5459. // Skill returns the value of the "skill" field in the mutation.
  5460. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  5461. v := m.skill
  5462. if v == nil {
  5463. return
  5464. }
  5465. return *v, true
  5466. }
  5467. // OldSkill returns the old "skill" field's value of the Employee entity.
  5468. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5470. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  5471. if !m.op.Is(OpUpdateOne) {
  5472. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  5473. }
  5474. if m.id == nil || m.oldValue == nil {
  5475. return v, errors.New("OldSkill requires an ID field in the mutation")
  5476. }
  5477. oldValue, err := m.oldValue(ctx)
  5478. if err != nil {
  5479. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  5480. }
  5481. return oldValue.Skill, nil
  5482. }
  5483. // ResetSkill resets all changes to the "skill" field.
  5484. func (m *EmployeeMutation) ResetSkill() {
  5485. m.skill = nil
  5486. }
  5487. // SetAbilityType sets the "ability_type" field.
  5488. func (m *EmployeeMutation) SetAbilityType(s string) {
  5489. m.ability_type = &s
  5490. }
  5491. // AbilityType returns the value of the "ability_type" field in the mutation.
  5492. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  5493. v := m.ability_type
  5494. if v == nil {
  5495. return
  5496. }
  5497. return *v, true
  5498. }
  5499. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  5500. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5501. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5502. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  5503. if !m.op.Is(OpUpdateOne) {
  5504. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  5505. }
  5506. if m.id == nil || m.oldValue == nil {
  5507. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  5508. }
  5509. oldValue, err := m.oldValue(ctx)
  5510. if err != nil {
  5511. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  5512. }
  5513. return oldValue.AbilityType, nil
  5514. }
  5515. // ResetAbilityType resets all changes to the "ability_type" field.
  5516. func (m *EmployeeMutation) ResetAbilityType() {
  5517. m.ability_type = nil
  5518. }
  5519. // SetScene sets the "scene" field.
  5520. func (m *EmployeeMutation) SetScene(s string) {
  5521. m.scene = &s
  5522. }
  5523. // Scene returns the value of the "scene" field in the mutation.
  5524. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  5525. v := m.scene
  5526. if v == nil {
  5527. return
  5528. }
  5529. return *v, true
  5530. }
  5531. // OldScene returns the old "scene" field's value of the Employee entity.
  5532. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5534. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  5535. if !m.op.Is(OpUpdateOne) {
  5536. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  5537. }
  5538. if m.id == nil || m.oldValue == nil {
  5539. return v, errors.New("OldScene requires an ID field in the mutation")
  5540. }
  5541. oldValue, err := m.oldValue(ctx)
  5542. if err != nil {
  5543. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  5544. }
  5545. return oldValue.Scene, nil
  5546. }
  5547. // ResetScene resets all changes to the "scene" field.
  5548. func (m *EmployeeMutation) ResetScene() {
  5549. m.scene = nil
  5550. }
  5551. // SetSwitchIn sets the "switch_in" field.
  5552. func (m *EmployeeMutation) SetSwitchIn(s string) {
  5553. m.switch_in = &s
  5554. }
  5555. // SwitchIn returns the value of the "switch_in" field in the mutation.
  5556. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  5557. v := m.switch_in
  5558. if v == nil {
  5559. return
  5560. }
  5561. return *v, true
  5562. }
  5563. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  5564. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5566. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  5567. if !m.op.Is(OpUpdateOne) {
  5568. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  5569. }
  5570. if m.id == nil || m.oldValue == nil {
  5571. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  5572. }
  5573. oldValue, err := m.oldValue(ctx)
  5574. if err != nil {
  5575. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  5576. }
  5577. return oldValue.SwitchIn, nil
  5578. }
  5579. // ResetSwitchIn resets all changes to the "switch_in" field.
  5580. func (m *EmployeeMutation) ResetSwitchIn() {
  5581. m.switch_in = nil
  5582. }
  5583. // SetVideoURL sets the "video_url" field.
  5584. func (m *EmployeeMutation) SetVideoURL(s string) {
  5585. m.video_url = &s
  5586. }
  5587. // VideoURL returns the value of the "video_url" field in the mutation.
  5588. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  5589. v := m.video_url
  5590. if v == nil {
  5591. return
  5592. }
  5593. return *v, true
  5594. }
  5595. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  5596. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5598. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  5599. if !m.op.Is(OpUpdateOne) {
  5600. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  5601. }
  5602. if m.id == nil || m.oldValue == nil {
  5603. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  5604. }
  5605. oldValue, err := m.oldValue(ctx)
  5606. if err != nil {
  5607. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  5608. }
  5609. return oldValue.VideoURL, nil
  5610. }
  5611. // ResetVideoURL resets all changes to the "video_url" field.
  5612. func (m *EmployeeMutation) ResetVideoURL() {
  5613. m.video_url = nil
  5614. }
  5615. // SetOrganizationID sets the "organization_id" field.
  5616. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  5617. m.organization_id = &u
  5618. m.addorganization_id = nil
  5619. }
  5620. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5621. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  5622. v := m.organization_id
  5623. if v == nil {
  5624. return
  5625. }
  5626. return *v, true
  5627. }
  5628. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  5629. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5631. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5632. if !m.op.Is(OpUpdateOne) {
  5633. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5634. }
  5635. if m.id == nil || m.oldValue == nil {
  5636. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5637. }
  5638. oldValue, err := m.oldValue(ctx)
  5639. if err != nil {
  5640. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5641. }
  5642. return oldValue.OrganizationID, nil
  5643. }
  5644. // AddOrganizationID adds u to the "organization_id" field.
  5645. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  5646. if m.addorganization_id != nil {
  5647. *m.addorganization_id += u
  5648. } else {
  5649. m.addorganization_id = &u
  5650. }
  5651. }
  5652. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5653. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  5654. v := m.addorganization_id
  5655. if v == nil {
  5656. return
  5657. }
  5658. return *v, true
  5659. }
  5660. // ResetOrganizationID resets all changes to the "organization_id" field.
  5661. func (m *EmployeeMutation) ResetOrganizationID() {
  5662. m.organization_id = nil
  5663. m.addorganization_id = nil
  5664. }
  5665. // SetCategoryID sets the "category_id" field.
  5666. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  5667. m.category_id = &u
  5668. m.addcategory_id = nil
  5669. }
  5670. // CategoryID returns the value of the "category_id" field in the mutation.
  5671. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  5672. v := m.category_id
  5673. if v == nil {
  5674. return
  5675. }
  5676. return *v, true
  5677. }
  5678. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  5679. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5681. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  5682. if !m.op.Is(OpUpdateOne) {
  5683. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  5684. }
  5685. if m.id == nil || m.oldValue == nil {
  5686. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  5687. }
  5688. oldValue, err := m.oldValue(ctx)
  5689. if err != nil {
  5690. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  5691. }
  5692. return oldValue.CategoryID, nil
  5693. }
  5694. // AddCategoryID adds u to the "category_id" field.
  5695. func (m *EmployeeMutation) AddCategoryID(u int64) {
  5696. if m.addcategory_id != nil {
  5697. *m.addcategory_id += u
  5698. } else {
  5699. m.addcategory_id = &u
  5700. }
  5701. }
  5702. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  5703. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  5704. v := m.addcategory_id
  5705. if v == nil {
  5706. return
  5707. }
  5708. return *v, true
  5709. }
  5710. // ResetCategoryID resets all changes to the "category_id" field.
  5711. func (m *EmployeeMutation) ResetCategoryID() {
  5712. m.category_id = nil
  5713. m.addcategory_id = nil
  5714. }
  5715. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  5716. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  5717. if m.em_work_experiences == nil {
  5718. m.em_work_experiences = make(map[uint64]struct{})
  5719. }
  5720. for i := range ids {
  5721. m.em_work_experiences[ids[i]] = struct{}{}
  5722. }
  5723. }
  5724. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  5725. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  5726. m.clearedem_work_experiences = true
  5727. }
  5728. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  5729. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  5730. return m.clearedem_work_experiences
  5731. }
  5732. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  5733. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  5734. if m.removedem_work_experiences == nil {
  5735. m.removedem_work_experiences = make(map[uint64]struct{})
  5736. }
  5737. for i := range ids {
  5738. delete(m.em_work_experiences, ids[i])
  5739. m.removedem_work_experiences[ids[i]] = struct{}{}
  5740. }
  5741. }
  5742. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  5743. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  5744. for id := range m.removedem_work_experiences {
  5745. ids = append(ids, id)
  5746. }
  5747. return
  5748. }
  5749. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  5750. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  5751. for id := range m.em_work_experiences {
  5752. ids = append(ids, id)
  5753. }
  5754. return
  5755. }
  5756. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  5757. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  5758. m.em_work_experiences = nil
  5759. m.clearedem_work_experiences = false
  5760. m.removedem_work_experiences = nil
  5761. }
  5762. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  5763. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  5764. if m.em_tutorial == nil {
  5765. m.em_tutorial = make(map[uint64]struct{})
  5766. }
  5767. for i := range ids {
  5768. m.em_tutorial[ids[i]] = struct{}{}
  5769. }
  5770. }
  5771. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  5772. func (m *EmployeeMutation) ClearEmTutorial() {
  5773. m.clearedem_tutorial = true
  5774. }
  5775. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  5776. func (m *EmployeeMutation) EmTutorialCleared() bool {
  5777. return m.clearedem_tutorial
  5778. }
  5779. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  5780. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  5781. if m.removedem_tutorial == nil {
  5782. m.removedem_tutorial = make(map[uint64]struct{})
  5783. }
  5784. for i := range ids {
  5785. delete(m.em_tutorial, ids[i])
  5786. m.removedem_tutorial[ids[i]] = struct{}{}
  5787. }
  5788. }
  5789. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  5790. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  5791. for id := range m.removedem_tutorial {
  5792. ids = append(ids, id)
  5793. }
  5794. return
  5795. }
  5796. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  5797. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  5798. for id := range m.em_tutorial {
  5799. ids = append(ids, id)
  5800. }
  5801. return
  5802. }
  5803. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  5804. func (m *EmployeeMutation) ResetEmTutorial() {
  5805. m.em_tutorial = nil
  5806. m.clearedem_tutorial = false
  5807. m.removedem_tutorial = nil
  5808. }
  5809. // Where appends a list predicates to the EmployeeMutation builder.
  5810. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  5811. m.predicates = append(m.predicates, ps...)
  5812. }
  5813. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  5814. // users can use type-assertion to append predicates that do not depend on any generated package.
  5815. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  5816. p := make([]predicate.Employee, len(ps))
  5817. for i := range ps {
  5818. p[i] = ps[i]
  5819. }
  5820. m.Where(p...)
  5821. }
  5822. // Op returns the operation name.
  5823. func (m *EmployeeMutation) Op() Op {
  5824. return m.op
  5825. }
  5826. // SetOp allows setting the mutation operation.
  5827. func (m *EmployeeMutation) SetOp(op Op) {
  5828. m.op = op
  5829. }
  5830. // Type returns the node type of this mutation (Employee).
  5831. func (m *EmployeeMutation) Type() string {
  5832. return m.typ
  5833. }
  5834. // Fields returns all fields that were changed during this mutation. Note that in
  5835. // order to get all numeric fields that were incremented/decremented, call
  5836. // AddedFields().
  5837. func (m *EmployeeMutation) Fields() []string {
  5838. fields := make([]string, 0, 18)
  5839. if m.created_at != nil {
  5840. fields = append(fields, employee.FieldCreatedAt)
  5841. }
  5842. if m.updated_at != nil {
  5843. fields = append(fields, employee.FieldUpdatedAt)
  5844. }
  5845. if m.deleted_at != nil {
  5846. fields = append(fields, employee.FieldDeletedAt)
  5847. }
  5848. if m.title != nil {
  5849. fields = append(fields, employee.FieldTitle)
  5850. }
  5851. if m.avatar != nil {
  5852. fields = append(fields, employee.FieldAvatar)
  5853. }
  5854. if m.tags != nil {
  5855. fields = append(fields, employee.FieldTags)
  5856. }
  5857. if m.hire_count != nil {
  5858. fields = append(fields, employee.FieldHireCount)
  5859. }
  5860. if m.service_count != nil {
  5861. fields = append(fields, employee.FieldServiceCount)
  5862. }
  5863. if m.achievement_count != nil {
  5864. fields = append(fields, employee.FieldAchievementCount)
  5865. }
  5866. if m.intro != nil {
  5867. fields = append(fields, employee.FieldIntro)
  5868. }
  5869. if m.estimate != nil {
  5870. fields = append(fields, employee.FieldEstimate)
  5871. }
  5872. if m.skill != nil {
  5873. fields = append(fields, employee.FieldSkill)
  5874. }
  5875. if m.ability_type != nil {
  5876. fields = append(fields, employee.FieldAbilityType)
  5877. }
  5878. if m.scene != nil {
  5879. fields = append(fields, employee.FieldScene)
  5880. }
  5881. if m.switch_in != nil {
  5882. fields = append(fields, employee.FieldSwitchIn)
  5883. }
  5884. if m.video_url != nil {
  5885. fields = append(fields, employee.FieldVideoURL)
  5886. }
  5887. if m.organization_id != nil {
  5888. fields = append(fields, employee.FieldOrganizationID)
  5889. }
  5890. if m.category_id != nil {
  5891. fields = append(fields, employee.FieldCategoryID)
  5892. }
  5893. return fields
  5894. }
  5895. // Field returns the value of a field with the given name. The second boolean
  5896. // return value indicates that this field was not set, or was not defined in the
  5897. // schema.
  5898. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  5899. switch name {
  5900. case employee.FieldCreatedAt:
  5901. return m.CreatedAt()
  5902. case employee.FieldUpdatedAt:
  5903. return m.UpdatedAt()
  5904. case employee.FieldDeletedAt:
  5905. return m.DeletedAt()
  5906. case employee.FieldTitle:
  5907. return m.Title()
  5908. case employee.FieldAvatar:
  5909. return m.Avatar()
  5910. case employee.FieldTags:
  5911. return m.Tags()
  5912. case employee.FieldHireCount:
  5913. return m.HireCount()
  5914. case employee.FieldServiceCount:
  5915. return m.ServiceCount()
  5916. case employee.FieldAchievementCount:
  5917. return m.AchievementCount()
  5918. case employee.FieldIntro:
  5919. return m.Intro()
  5920. case employee.FieldEstimate:
  5921. return m.Estimate()
  5922. case employee.FieldSkill:
  5923. return m.Skill()
  5924. case employee.FieldAbilityType:
  5925. return m.AbilityType()
  5926. case employee.FieldScene:
  5927. return m.Scene()
  5928. case employee.FieldSwitchIn:
  5929. return m.SwitchIn()
  5930. case employee.FieldVideoURL:
  5931. return m.VideoURL()
  5932. case employee.FieldOrganizationID:
  5933. return m.OrganizationID()
  5934. case employee.FieldCategoryID:
  5935. return m.CategoryID()
  5936. }
  5937. return nil, false
  5938. }
  5939. // OldField returns the old value of the field from the database. An error is
  5940. // returned if the mutation operation is not UpdateOne, or the query to the
  5941. // database failed.
  5942. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5943. switch name {
  5944. case employee.FieldCreatedAt:
  5945. return m.OldCreatedAt(ctx)
  5946. case employee.FieldUpdatedAt:
  5947. return m.OldUpdatedAt(ctx)
  5948. case employee.FieldDeletedAt:
  5949. return m.OldDeletedAt(ctx)
  5950. case employee.FieldTitle:
  5951. return m.OldTitle(ctx)
  5952. case employee.FieldAvatar:
  5953. return m.OldAvatar(ctx)
  5954. case employee.FieldTags:
  5955. return m.OldTags(ctx)
  5956. case employee.FieldHireCount:
  5957. return m.OldHireCount(ctx)
  5958. case employee.FieldServiceCount:
  5959. return m.OldServiceCount(ctx)
  5960. case employee.FieldAchievementCount:
  5961. return m.OldAchievementCount(ctx)
  5962. case employee.FieldIntro:
  5963. return m.OldIntro(ctx)
  5964. case employee.FieldEstimate:
  5965. return m.OldEstimate(ctx)
  5966. case employee.FieldSkill:
  5967. return m.OldSkill(ctx)
  5968. case employee.FieldAbilityType:
  5969. return m.OldAbilityType(ctx)
  5970. case employee.FieldScene:
  5971. return m.OldScene(ctx)
  5972. case employee.FieldSwitchIn:
  5973. return m.OldSwitchIn(ctx)
  5974. case employee.FieldVideoURL:
  5975. return m.OldVideoURL(ctx)
  5976. case employee.FieldOrganizationID:
  5977. return m.OldOrganizationID(ctx)
  5978. case employee.FieldCategoryID:
  5979. return m.OldCategoryID(ctx)
  5980. }
  5981. return nil, fmt.Errorf("unknown Employee field %s", name)
  5982. }
  5983. // SetField sets the value of a field with the given name. It returns an error if
  5984. // the field is not defined in the schema, or if the type mismatched the field
  5985. // type.
  5986. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  5987. switch name {
  5988. case employee.FieldCreatedAt:
  5989. v, ok := value.(time.Time)
  5990. if !ok {
  5991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5992. }
  5993. m.SetCreatedAt(v)
  5994. return nil
  5995. case employee.FieldUpdatedAt:
  5996. v, ok := value.(time.Time)
  5997. if !ok {
  5998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5999. }
  6000. m.SetUpdatedAt(v)
  6001. return nil
  6002. case employee.FieldDeletedAt:
  6003. v, ok := value.(time.Time)
  6004. if !ok {
  6005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6006. }
  6007. m.SetDeletedAt(v)
  6008. return nil
  6009. case employee.FieldTitle:
  6010. v, ok := value.(string)
  6011. if !ok {
  6012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6013. }
  6014. m.SetTitle(v)
  6015. return nil
  6016. case employee.FieldAvatar:
  6017. v, ok := value.(string)
  6018. if !ok {
  6019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6020. }
  6021. m.SetAvatar(v)
  6022. return nil
  6023. case employee.FieldTags:
  6024. v, ok := value.(string)
  6025. if !ok {
  6026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6027. }
  6028. m.SetTags(v)
  6029. return nil
  6030. case employee.FieldHireCount:
  6031. v, ok := value.(int)
  6032. if !ok {
  6033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6034. }
  6035. m.SetHireCount(v)
  6036. return nil
  6037. case employee.FieldServiceCount:
  6038. v, ok := value.(int)
  6039. if !ok {
  6040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6041. }
  6042. m.SetServiceCount(v)
  6043. return nil
  6044. case employee.FieldAchievementCount:
  6045. v, ok := value.(int)
  6046. if !ok {
  6047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6048. }
  6049. m.SetAchievementCount(v)
  6050. return nil
  6051. case employee.FieldIntro:
  6052. v, ok := value.(string)
  6053. if !ok {
  6054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6055. }
  6056. m.SetIntro(v)
  6057. return nil
  6058. case employee.FieldEstimate:
  6059. v, ok := value.(string)
  6060. if !ok {
  6061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6062. }
  6063. m.SetEstimate(v)
  6064. return nil
  6065. case employee.FieldSkill:
  6066. v, ok := value.(string)
  6067. if !ok {
  6068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6069. }
  6070. m.SetSkill(v)
  6071. return nil
  6072. case employee.FieldAbilityType:
  6073. v, ok := value.(string)
  6074. if !ok {
  6075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6076. }
  6077. m.SetAbilityType(v)
  6078. return nil
  6079. case employee.FieldScene:
  6080. v, ok := value.(string)
  6081. if !ok {
  6082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6083. }
  6084. m.SetScene(v)
  6085. return nil
  6086. case employee.FieldSwitchIn:
  6087. v, ok := value.(string)
  6088. if !ok {
  6089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6090. }
  6091. m.SetSwitchIn(v)
  6092. return nil
  6093. case employee.FieldVideoURL:
  6094. v, ok := value.(string)
  6095. if !ok {
  6096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6097. }
  6098. m.SetVideoURL(v)
  6099. return nil
  6100. case employee.FieldOrganizationID:
  6101. v, ok := value.(uint64)
  6102. if !ok {
  6103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6104. }
  6105. m.SetOrganizationID(v)
  6106. return nil
  6107. case employee.FieldCategoryID:
  6108. v, ok := value.(uint64)
  6109. if !ok {
  6110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6111. }
  6112. m.SetCategoryID(v)
  6113. return nil
  6114. }
  6115. return fmt.Errorf("unknown Employee field %s", name)
  6116. }
  6117. // AddedFields returns all numeric fields that were incremented/decremented during
  6118. // this mutation.
  6119. func (m *EmployeeMutation) AddedFields() []string {
  6120. var fields []string
  6121. if m.addhire_count != nil {
  6122. fields = append(fields, employee.FieldHireCount)
  6123. }
  6124. if m.addservice_count != nil {
  6125. fields = append(fields, employee.FieldServiceCount)
  6126. }
  6127. if m.addachievement_count != nil {
  6128. fields = append(fields, employee.FieldAchievementCount)
  6129. }
  6130. if m.addorganization_id != nil {
  6131. fields = append(fields, employee.FieldOrganizationID)
  6132. }
  6133. if m.addcategory_id != nil {
  6134. fields = append(fields, employee.FieldCategoryID)
  6135. }
  6136. return fields
  6137. }
  6138. // AddedField returns the numeric value that was incremented/decremented on a field
  6139. // with the given name. The second boolean return value indicates that this field
  6140. // was not set, or was not defined in the schema.
  6141. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  6142. switch name {
  6143. case employee.FieldHireCount:
  6144. return m.AddedHireCount()
  6145. case employee.FieldServiceCount:
  6146. return m.AddedServiceCount()
  6147. case employee.FieldAchievementCount:
  6148. return m.AddedAchievementCount()
  6149. case employee.FieldOrganizationID:
  6150. return m.AddedOrganizationID()
  6151. case employee.FieldCategoryID:
  6152. return m.AddedCategoryID()
  6153. }
  6154. return nil, false
  6155. }
  6156. // AddField adds the value to the field with the given name. It returns an error if
  6157. // the field is not defined in the schema, or if the type mismatched the field
  6158. // type.
  6159. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  6160. switch name {
  6161. case employee.FieldHireCount:
  6162. v, ok := value.(int)
  6163. if !ok {
  6164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6165. }
  6166. m.AddHireCount(v)
  6167. return nil
  6168. case employee.FieldServiceCount:
  6169. v, ok := value.(int)
  6170. if !ok {
  6171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6172. }
  6173. m.AddServiceCount(v)
  6174. return nil
  6175. case employee.FieldAchievementCount:
  6176. v, ok := value.(int)
  6177. if !ok {
  6178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6179. }
  6180. m.AddAchievementCount(v)
  6181. return nil
  6182. case employee.FieldOrganizationID:
  6183. v, ok := value.(int64)
  6184. if !ok {
  6185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6186. }
  6187. m.AddOrganizationID(v)
  6188. return nil
  6189. case employee.FieldCategoryID:
  6190. v, ok := value.(int64)
  6191. if !ok {
  6192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6193. }
  6194. m.AddCategoryID(v)
  6195. return nil
  6196. }
  6197. return fmt.Errorf("unknown Employee numeric field %s", name)
  6198. }
  6199. // ClearedFields returns all nullable fields that were cleared during this
  6200. // mutation.
  6201. func (m *EmployeeMutation) ClearedFields() []string {
  6202. var fields []string
  6203. if m.FieldCleared(employee.FieldDeletedAt) {
  6204. fields = append(fields, employee.FieldDeletedAt)
  6205. }
  6206. return fields
  6207. }
  6208. // FieldCleared returns a boolean indicating if a field with the given name was
  6209. // cleared in this mutation.
  6210. func (m *EmployeeMutation) FieldCleared(name string) bool {
  6211. _, ok := m.clearedFields[name]
  6212. return ok
  6213. }
  6214. // ClearField clears the value of the field with the given name. It returns an
  6215. // error if the field is not defined in the schema.
  6216. func (m *EmployeeMutation) ClearField(name string) error {
  6217. switch name {
  6218. case employee.FieldDeletedAt:
  6219. m.ClearDeletedAt()
  6220. return nil
  6221. }
  6222. return fmt.Errorf("unknown Employee nullable field %s", name)
  6223. }
  6224. // ResetField resets all changes in the mutation for the field with the given name.
  6225. // It returns an error if the field is not defined in the schema.
  6226. func (m *EmployeeMutation) ResetField(name string) error {
  6227. switch name {
  6228. case employee.FieldCreatedAt:
  6229. m.ResetCreatedAt()
  6230. return nil
  6231. case employee.FieldUpdatedAt:
  6232. m.ResetUpdatedAt()
  6233. return nil
  6234. case employee.FieldDeletedAt:
  6235. m.ResetDeletedAt()
  6236. return nil
  6237. case employee.FieldTitle:
  6238. m.ResetTitle()
  6239. return nil
  6240. case employee.FieldAvatar:
  6241. m.ResetAvatar()
  6242. return nil
  6243. case employee.FieldTags:
  6244. m.ResetTags()
  6245. return nil
  6246. case employee.FieldHireCount:
  6247. m.ResetHireCount()
  6248. return nil
  6249. case employee.FieldServiceCount:
  6250. m.ResetServiceCount()
  6251. return nil
  6252. case employee.FieldAchievementCount:
  6253. m.ResetAchievementCount()
  6254. return nil
  6255. case employee.FieldIntro:
  6256. m.ResetIntro()
  6257. return nil
  6258. case employee.FieldEstimate:
  6259. m.ResetEstimate()
  6260. return nil
  6261. case employee.FieldSkill:
  6262. m.ResetSkill()
  6263. return nil
  6264. case employee.FieldAbilityType:
  6265. m.ResetAbilityType()
  6266. return nil
  6267. case employee.FieldScene:
  6268. m.ResetScene()
  6269. return nil
  6270. case employee.FieldSwitchIn:
  6271. m.ResetSwitchIn()
  6272. return nil
  6273. case employee.FieldVideoURL:
  6274. m.ResetVideoURL()
  6275. return nil
  6276. case employee.FieldOrganizationID:
  6277. m.ResetOrganizationID()
  6278. return nil
  6279. case employee.FieldCategoryID:
  6280. m.ResetCategoryID()
  6281. return nil
  6282. }
  6283. return fmt.Errorf("unknown Employee field %s", name)
  6284. }
  6285. // AddedEdges returns all edge names that were set/added in this mutation.
  6286. func (m *EmployeeMutation) AddedEdges() []string {
  6287. edges := make([]string, 0, 2)
  6288. if m.em_work_experiences != nil {
  6289. edges = append(edges, employee.EdgeEmWorkExperiences)
  6290. }
  6291. if m.em_tutorial != nil {
  6292. edges = append(edges, employee.EdgeEmTutorial)
  6293. }
  6294. return edges
  6295. }
  6296. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6297. // name in this mutation.
  6298. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  6299. switch name {
  6300. case employee.EdgeEmWorkExperiences:
  6301. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  6302. for id := range m.em_work_experiences {
  6303. ids = append(ids, id)
  6304. }
  6305. return ids
  6306. case employee.EdgeEmTutorial:
  6307. ids := make([]ent.Value, 0, len(m.em_tutorial))
  6308. for id := range m.em_tutorial {
  6309. ids = append(ids, id)
  6310. }
  6311. return ids
  6312. }
  6313. return nil
  6314. }
  6315. // RemovedEdges returns all edge names that were removed in this mutation.
  6316. func (m *EmployeeMutation) RemovedEdges() []string {
  6317. edges := make([]string, 0, 2)
  6318. if m.removedem_work_experiences != nil {
  6319. edges = append(edges, employee.EdgeEmWorkExperiences)
  6320. }
  6321. if m.removedem_tutorial != nil {
  6322. edges = append(edges, employee.EdgeEmTutorial)
  6323. }
  6324. return edges
  6325. }
  6326. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6327. // the given name in this mutation.
  6328. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  6329. switch name {
  6330. case employee.EdgeEmWorkExperiences:
  6331. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  6332. for id := range m.removedem_work_experiences {
  6333. ids = append(ids, id)
  6334. }
  6335. return ids
  6336. case employee.EdgeEmTutorial:
  6337. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  6338. for id := range m.removedem_tutorial {
  6339. ids = append(ids, id)
  6340. }
  6341. return ids
  6342. }
  6343. return nil
  6344. }
  6345. // ClearedEdges returns all edge names that were cleared in this mutation.
  6346. func (m *EmployeeMutation) ClearedEdges() []string {
  6347. edges := make([]string, 0, 2)
  6348. if m.clearedem_work_experiences {
  6349. edges = append(edges, employee.EdgeEmWorkExperiences)
  6350. }
  6351. if m.clearedem_tutorial {
  6352. edges = append(edges, employee.EdgeEmTutorial)
  6353. }
  6354. return edges
  6355. }
  6356. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6357. // was cleared in this mutation.
  6358. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  6359. switch name {
  6360. case employee.EdgeEmWorkExperiences:
  6361. return m.clearedem_work_experiences
  6362. case employee.EdgeEmTutorial:
  6363. return m.clearedem_tutorial
  6364. }
  6365. return false
  6366. }
  6367. // ClearEdge clears the value of the edge with the given name. It returns an error
  6368. // if that edge is not defined in the schema.
  6369. func (m *EmployeeMutation) ClearEdge(name string) error {
  6370. switch name {
  6371. }
  6372. return fmt.Errorf("unknown Employee unique edge %s", name)
  6373. }
  6374. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6375. // It returns an error if the edge is not defined in the schema.
  6376. func (m *EmployeeMutation) ResetEdge(name string) error {
  6377. switch name {
  6378. case employee.EdgeEmWorkExperiences:
  6379. m.ResetEmWorkExperiences()
  6380. return nil
  6381. case employee.EdgeEmTutorial:
  6382. m.ResetEmTutorial()
  6383. return nil
  6384. }
  6385. return fmt.Errorf("unknown Employee edge %s", name)
  6386. }
  6387. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  6388. type EmployeeConfigMutation struct {
  6389. config
  6390. op Op
  6391. typ string
  6392. id *uint64
  6393. created_at *time.Time
  6394. updated_at *time.Time
  6395. deleted_at *time.Time
  6396. stype *string
  6397. title *string
  6398. photo *string
  6399. organization_id *uint64
  6400. addorganization_id *int64
  6401. clearedFields map[string]struct{}
  6402. done bool
  6403. oldValue func(context.Context) (*EmployeeConfig, error)
  6404. predicates []predicate.EmployeeConfig
  6405. }
  6406. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  6407. // employeeconfigOption allows management of the mutation configuration using functional options.
  6408. type employeeconfigOption func(*EmployeeConfigMutation)
  6409. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  6410. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  6411. m := &EmployeeConfigMutation{
  6412. config: c,
  6413. op: op,
  6414. typ: TypeEmployeeConfig,
  6415. clearedFields: make(map[string]struct{}),
  6416. }
  6417. for _, opt := range opts {
  6418. opt(m)
  6419. }
  6420. return m
  6421. }
  6422. // withEmployeeConfigID sets the ID field of the mutation.
  6423. func withEmployeeConfigID(id uint64) employeeconfigOption {
  6424. return func(m *EmployeeConfigMutation) {
  6425. var (
  6426. err error
  6427. once sync.Once
  6428. value *EmployeeConfig
  6429. )
  6430. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  6431. once.Do(func() {
  6432. if m.done {
  6433. err = errors.New("querying old values post mutation is not allowed")
  6434. } else {
  6435. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  6436. }
  6437. })
  6438. return value, err
  6439. }
  6440. m.id = &id
  6441. }
  6442. }
  6443. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  6444. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  6445. return func(m *EmployeeConfigMutation) {
  6446. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  6447. return node, nil
  6448. }
  6449. m.id = &node.ID
  6450. }
  6451. }
  6452. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6453. // executed in a transaction (ent.Tx), a transactional client is returned.
  6454. func (m EmployeeConfigMutation) Client() *Client {
  6455. client := &Client{config: m.config}
  6456. client.init()
  6457. return client
  6458. }
  6459. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6460. // it returns an error otherwise.
  6461. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  6462. if _, ok := m.driver.(*txDriver); !ok {
  6463. return nil, errors.New("ent: mutation is not running in a transaction")
  6464. }
  6465. tx := &Tx{config: m.config}
  6466. tx.init()
  6467. return tx, nil
  6468. }
  6469. // SetID sets the value of the id field. Note that this
  6470. // operation is only accepted on creation of EmployeeConfig entities.
  6471. func (m *EmployeeConfigMutation) SetID(id uint64) {
  6472. m.id = &id
  6473. }
  6474. // ID returns the ID value in the mutation. Note that the ID is only available
  6475. // if it was provided to the builder or after it was returned from the database.
  6476. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  6477. if m.id == nil {
  6478. return
  6479. }
  6480. return *m.id, true
  6481. }
  6482. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6483. // That means, if the mutation is applied within a transaction with an isolation level such
  6484. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6485. // or updated by the mutation.
  6486. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  6487. switch {
  6488. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6489. id, exists := m.ID()
  6490. if exists {
  6491. return []uint64{id}, nil
  6492. }
  6493. fallthrough
  6494. case m.op.Is(OpUpdate | OpDelete):
  6495. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  6496. default:
  6497. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6498. }
  6499. }
  6500. // SetCreatedAt sets the "created_at" field.
  6501. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  6502. m.created_at = &t
  6503. }
  6504. // CreatedAt returns the value of the "created_at" field in the mutation.
  6505. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  6506. v := m.created_at
  6507. if v == nil {
  6508. return
  6509. }
  6510. return *v, true
  6511. }
  6512. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  6513. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6515. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6516. if !m.op.Is(OpUpdateOne) {
  6517. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6518. }
  6519. if m.id == nil || m.oldValue == nil {
  6520. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6521. }
  6522. oldValue, err := m.oldValue(ctx)
  6523. if err != nil {
  6524. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6525. }
  6526. return oldValue.CreatedAt, nil
  6527. }
  6528. // ResetCreatedAt resets all changes to the "created_at" field.
  6529. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  6530. m.created_at = nil
  6531. }
  6532. // SetUpdatedAt sets the "updated_at" field.
  6533. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  6534. m.updated_at = &t
  6535. }
  6536. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6537. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  6538. v := m.updated_at
  6539. if v == nil {
  6540. return
  6541. }
  6542. return *v, true
  6543. }
  6544. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  6545. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6546. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6547. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6548. if !m.op.Is(OpUpdateOne) {
  6549. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6550. }
  6551. if m.id == nil || m.oldValue == nil {
  6552. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6553. }
  6554. oldValue, err := m.oldValue(ctx)
  6555. if err != nil {
  6556. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6557. }
  6558. return oldValue.UpdatedAt, nil
  6559. }
  6560. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6561. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  6562. m.updated_at = nil
  6563. }
  6564. // SetDeletedAt sets the "deleted_at" field.
  6565. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  6566. m.deleted_at = &t
  6567. }
  6568. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6569. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  6570. v := m.deleted_at
  6571. if v == nil {
  6572. return
  6573. }
  6574. return *v, true
  6575. }
  6576. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  6577. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6579. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6580. if !m.op.Is(OpUpdateOne) {
  6581. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6582. }
  6583. if m.id == nil || m.oldValue == nil {
  6584. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6585. }
  6586. oldValue, err := m.oldValue(ctx)
  6587. if err != nil {
  6588. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6589. }
  6590. return oldValue.DeletedAt, nil
  6591. }
  6592. // ClearDeletedAt clears the value of the "deleted_at" field.
  6593. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  6594. m.deleted_at = nil
  6595. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  6596. }
  6597. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6598. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  6599. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  6600. return ok
  6601. }
  6602. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6603. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  6604. m.deleted_at = nil
  6605. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  6606. }
  6607. // SetStype sets the "stype" field.
  6608. func (m *EmployeeConfigMutation) SetStype(s string) {
  6609. m.stype = &s
  6610. }
  6611. // Stype returns the value of the "stype" field in the mutation.
  6612. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  6613. v := m.stype
  6614. if v == nil {
  6615. return
  6616. }
  6617. return *v, true
  6618. }
  6619. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  6620. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6622. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  6623. if !m.op.Is(OpUpdateOne) {
  6624. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  6625. }
  6626. if m.id == nil || m.oldValue == nil {
  6627. return v, errors.New("OldStype requires an ID field in the mutation")
  6628. }
  6629. oldValue, err := m.oldValue(ctx)
  6630. if err != nil {
  6631. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  6632. }
  6633. return oldValue.Stype, nil
  6634. }
  6635. // ResetStype resets all changes to the "stype" field.
  6636. func (m *EmployeeConfigMutation) ResetStype() {
  6637. m.stype = nil
  6638. }
  6639. // SetTitle sets the "title" field.
  6640. func (m *EmployeeConfigMutation) SetTitle(s string) {
  6641. m.title = &s
  6642. }
  6643. // Title returns the value of the "title" field in the mutation.
  6644. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  6645. v := m.title
  6646. if v == nil {
  6647. return
  6648. }
  6649. return *v, true
  6650. }
  6651. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  6652. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6654. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  6655. if !m.op.Is(OpUpdateOne) {
  6656. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  6657. }
  6658. if m.id == nil || m.oldValue == nil {
  6659. return v, errors.New("OldTitle requires an ID field in the mutation")
  6660. }
  6661. oldValue, err := m.oldValue(ctx)
  6662. if err != nil {
  6663. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  6664. }
  6665. return oldValue.Title, nil
  6666. }
  6667. // ResetTitle resets all changes to the "title" field.
  6668. func (m *EmployeeConfigMutation) ResetTitle() {
  6669. m.title = nil
  6670. }
  6671. // SetPhoto sets the "photo" field.
  6672. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  6673. m.photo = &s
  6674. }
  6675. // Photo returns the value of the "photo" field in the mutation.
  6676. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  6677. v := m.photo
  6678. if v == nil {
  6679. return
  6680. }
  6681. return *v, true
  6682. }
  6683. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  6684. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6686. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  6687. if !m.op.Is(OpUpdateOne) {
  6688. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  6689. }
  6690. if m.id == nil || m.oldValue == nil {
  6691. return v, errors.New("OldPhoto requires an ID field in the mutation")
  6692. }
  6693. oldValue, err := m.oldValue(ctx)
  6694. if err != nil {
  6695. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  6696. }
  6697. return oldValue.Photo, nil
  6698. }
  6699. // ResetPhoto resets all changes to the "photo" field.
  6700. func (m *EmployeeConfigMutation) ResetPhoto() {
  6701. m.photo = nil
  6702. }
  6703. // SetOrganizationID sets the "organization_id" field.
  6704. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  6705. m.organization_id = &u
  6706. m.addorganization_id = nil
  6707. }
  6708. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6709. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  6710. v := m.organization_id
  6711. if v == nil {
  6712. return
  6713. }
  6714. return *v, true
  6715. }
  6716. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  6717. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6719. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6720. if !m.op.Is(OpUpdateOne) {
  6721. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6722. }
  6723. if m.id == nil || m.oldValue == nil {
  6724. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6725. }
  6726. oldValue, err := m.oldValue(ctx)
  6727. if err != nil {
  6728. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6729. }
  6730. return oldValue.OrganizationID, nil
  6731. }
  6732. // AddOrganizationID adds u to the "organization_id" field.
  6733. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  6734. if m.addorganization_id != nil {
  6735. *m.addorganization_id += u
  6736. } else {
  6737. m.addorganization_id = &u
  6738. }
  6739. }
  6740. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6741. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  6742. v := m.addorganization_id
  6743. if v == nil {
  6744. return
  6745. }
  6746. return *v, true
  6747. }
  6748. // ClearOrganizationID clears the value of the "organization_id" field.
  6749. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  6750. m.organization_id = nil
  6751. m.addorganization_id = nil
  6752. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  6753. }
  6754. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  6755. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  6756. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  6757. return ok
  6758. }
  6759. // ResetOrganizationID resets all changes to the "organization_id" field.
  6760. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  6761. m.organization_id = nil
  6762. m.addorganization_id = nil
  6763. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  6764. }
  6765. // Where appends a list predicates to the EmployeeConfigMutation builder.
  6766. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  6767. m.predicates = append(m.predicates, ps...)
  6768. }
  6769. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  6770. // users can use type-assertion to append predicates that do not depend on any generated package.
  6771. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  6772. p := make([]predicate.EmployeeConfig, len(ps))
  6773. for i := range ps {
  6774. p[i] = ps[i]
  6775. }
  6776. m.Where(p...)
  6777. }
  6778. // Op returns the operation name.
  6779. func (m *EmployeeConfigMutation) Op() Op {
  6780. return m.op
  6781. }
  6782. // SetOp allows setting the mutation operation.
  6783. func (m *EmployeeConfigMutation) SetOp(op Op) {
  6784. m.op = op
  6785. }
  6786. // Type returns the node type of this mutation (EmployeeConfig).
  6787. func (m *EmployeeConfigMutation) Type() string {
  6788. return m.typ
  6789. }
  6790. // Fields returns all fields that were changed during this mutation. Note that in
  6791. // order to get all numeric fields that were incremented/decremented, call
  6792. // AddedFields().
  6793. func (m *EmployeeConfigMutation) Fields() []string {
  6794. fields := make([]string, 0, 7)
  6795. if m.created_at != nil {
  6796. fields = append(fields, employeeconfig.FieldCreatedAt)
  6797. }
  6798. if m.updated_at != nil {
  6799. fields = append(fields, employeeconfig.FieldUpdatedAt)
  6800. }
  6801. if m.deleted_at != nil {
  6802. fields = append(fields, employeeconfig.FieldDeletedAt)
  6803. }
  6804. if m.stype != nil {
  6805. fields = append(fields, employeeconfig.FieldStype)
  6806. }
  6807. if m.title != nil {
  6808. fields = append(fields, employeeconfig.FieldTitle)
  6809. }
  6810. if m.photo != nil {
  6811. fields = append(fields, employeeconfig.FieldPhoto)
  6812. }
  6813. if m.organization_id != nil {
  6814. fields = append(fields, employeeconfig.FieldOrganizationID)
  6815. }
  6816. return fields
  6817. }
  6818. // Field returns the value of a field with the given name. The second boolean
  6819. // return value indicates that this field was not set, or was not defined in the
  6820. // schema.
  6821. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  6822. switch name {
  6823. case employeeconfig.FieldCreatedAt:
  6824. return m.CreatedAt()
  6825. case employeeconfig.FieldUpdatedAt:
  6826. return m.UpdatedAt()
  6827. case employeeconfig.FieldDeletedAt:
  6828. return m.DeletedAt()
  6829. case employeeconfig.FieldStype:
  6830. return m.Stype()
  6831. case employeeconfig.FieldTitle:
  6832. return m.Title()
  6833. case employeeconfig.FieldPhoto:
  6834. return m.Photo()
  6835. case employeeconfig.FieldOrganizationID:
  6836. return m.OrganizationID()
  6837. }
  6838. return nil, false
  6839. }
  6840. // OldField returns the old value of the field from the database. An error is
  6841. // returned if the mutation operation is not UpdateOne, or the query to the
  6842. // database failed.
  6843. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6844. switch name {
  6845. case employeeconfig.FieldCreatedAt:
  6846. return m.OldCreatedAt(ctx)
  6847. case employeeconfig.FieldUpdatedAt:
  6848. return m.OldUpdatedAt(ctx)
  6849. case employeeconfig.FieldDeletedAt:
  6850. return m.OldDeletedAt(ctx)
  6851. case employeeconfig.FieldStype:
  6852. return m.OldStype(ctx)
  6853. case employeeconfig.FieldTitle:
  6854. return m.OldTitle(ctx)
  6855. case employeeconfig.FieldPhoto:
  6856. return m.OldPhoto(ctx)
  6857. case employeeconfig.FieldOrganizationID:
  6858. return m.OldOrganizationID(ctx)
  6859. }
  6860. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  6861. }
  6862. // SetField sets the value of a field with the given name. It returns an error if
  6863. // the field is not defined in the schema, or if the type mismatched the field
  6864. // type.
  6865. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  6866. switch name {
  6867. case employeeconfig.FieldCreatedAt:
  6868. v, ok := value.(time.Time)
  6869. if !ok {
  6870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6871. }
  6872. m.SetCreatedAt(v)
  6873. return nil
  6874. case employeeconfig.FieldUpdatedAt:
  6875. v, ok := value.(time.Time)
  6876. if !ok {
  6877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6878. }
  6879. m.SetUpdatedAt(v)
  6880. return nil
  6881. case employeeconfig.FieldDeletedAt:
  6882. v, ok := value.(time.Time)
  6883. if !ok {
  6884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6885. }
  6886. m.SetDeletedAt(v)
  6887. return nil
  6888. case employeeconfig.FieldStype:
  6889. v, ok := value.(string)
  6890. if !ok {
  6891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6892. }
  6893. m.SetStype(v)
  6894. return nil
  6895. case employeeconfig.FieldTitle:
  6896. v, ok := value.(string)
  6897. if !ok {
  6898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6899. }
  6900. m.SetTitle(v)
  6901. return nil
  6902. case employeeconfig.FieldPhoto:
  6903. v, ok := value.(string)
  6904. if !ok {
  6905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6906. }
  6907. m.SetPhoto(v)
  6908. return nil
  6909. case employeeconfig.FieldOrganizationID:
  6910. v, ok := value.(uint64)
  6911. if !ok {
  6912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6913. }
  6914. m.SetOrganizationID(v)
  6915. return nil
  6916. }
  6917. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  6918. }
  6919. // AddedFields returns all numeric fields that were incremented/decremented during
  6920. // this mutation.
  6921. func (m *EmployeeConfigMutation) AddedFields() []string {
  6922. var fields []string
  6923. if m.addorganization_id != nil {
  6924. fields = append(fields, employeeconfig.FieldOrganizationID)
  6925. }
  6926. return fields
  6927. }
  6928. // AddedField returns the numeric value that was incremented/decremented on a field
  6929. // with the given name. The second boolean return value indicates that this field
  6930. // was not set, or was not defined in the schema.
  6931. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  6932. switch name {
  6933. case employeeconfig.FieldOrganizationID:
  6934. return m.AddedOrganizationID()
  6935. }
  6936. return nil, false
  6937. }
  6938. // AddField adds the value to the field with the given name. It returns an error if
  6939. // the field is not defined in the schema, or if the type mismatched the field
  6940. // type.
  6941. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  6942. switch name {
  6943. case employeeconfig.FieldOrganizationID:
  6944. v, ok := value.(int64)
  6945. if !ok {
  6946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6947. }
  6948. m.AddOrganizationID(v)
  6949. return nil
  6950. }
  6951. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  6952. }
  6953. // ClearedFields returns all nullable fields that were cleared during this
  6954. // mutation.
  6955. func (m *EmployeeConfigMutation) ClearedFields() []string {
  6956. var fields []string
  6957. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  6958. fields = append(fields, employeeconfig.FieldDeletedAt)
  6959. }
  6960. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  6961. fields = append(fields, employeeconfig.FieldOrganizationID)
  6962. }
  6963. return fields
  6964. }
  6965. // FieldCleared returns a boolean indicating if a field with the given name was
  6966. // cleared in this mutation.
  6967. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  6968. _, ok := m.clearedFields[name]
  6969. return ok
  6970. }
  6971. // ClearField clears the value of the field with the given name. It returns an
  6972. // error if the field is not defined in the schema.
  6973. func (m *EmployeeConfigMutation) ClearField(name string) error {
  6974. switch name {
  6975. case employeeconfig.FieldDeletedAt:
  6976. m.ClearDeletedAt()
  6977. return nil
  6978. case employeeconfig.FieldOrganizationID:
  6979. m.ClearOrganizationID()
  6980. return nil
  6981. }
  6982. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  6983. }
  6984. // ResetField resets all changes in the mutation for the field with the given name.
  6985. // It returns an error if the field is not defined in the schema.
  6986. func (m *EmployeeConfigMutation) ResetField(name string) error {
  6987. switch name {
  6988. case employeeconfig.FieldCreatedAt:
  6989. m.ResetCreatedAt()
  6990. return nil
  6991. case employeeconfig.FieldUpdatedAt:
  6992. m.ResetUpdatedAt()
  6993. return nil
  6994. case employeeconfig.FieldDeletedAt:
  6995. m.ResetDeletedAt()
  6996. return nil
  6997. case employeeconfig.FieldStype:
  6998. m.ResetStype()
  6999. return nil
  7000. case employeeconfig.FieldTitle:
  7001. m.ResetTitle()
  7002. return nil
  7003. case employeeconfig.FieldPhoto:
  7004. m.ResetPhoto()
  7005. return nil
  7006. case employeeconfig.FieldOrganizationID:
  7007. m.ResetOrganizationID()
  7008. return nil
  7009. }
  7010. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  7011. }
  7012. // AddedEdges returns all edge names that were set/added in this mutation.
  7013. func (m *EmployeeConfigMutation) AddedEdges() []string {
  7014. edges := make([]string, 0, 0)
  7015. return edges
  7016. }
  7017. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7018. // name in this mutation.
  7019. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  7020. return nil
  7021. }
  7022. // RemovedEdges returns all edge names that were removed in this mutation.
  7023. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  7024. edges := make([]string, 0, 0)
  7025. return edges
  7026. }
  7027. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7028. // the given name in this mutation.
  7029. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  7030. return nil
  7031. }
  7032. // ClearedEdges returns all edge names that were cleared in this mutation.
  7033. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  7034. edges := make([]string, 0, 0)
  7035. return edges
  7036. }
  7037. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7038. // was cleared in this mutation.
  7039. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  7040. return false
  7041. }
  7042. // ClearEdge clears the value of the edge with the given name. It returns an error
  7043. // if that edge is not defined in the schema.
  7044. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  7045. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  7046. }
  7047. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7048. // It returns an error if the edge is not defined in the schema.
  7049. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  7050. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  7051. }
  7052. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  7053. type LabelMutation struct {
  7054. config
  7055. op Op
  7056. typ string
  7057. id *uint64
  7058. created_at *time.Time
  7059. updated_at *time.Time
  7060. status *uint8
  7061. addstatus *int8
  7062. _type *int
  7063. add_type *int
  7064. name *string
  7065. from *int
  7066. addfrom *int
  7067. mode *int
  7068. addmode *int
  7069. conditions *string
  7070. organization_id *uint64
  7071. addorganization_id *int64
  7072. clearedFields map[string]struct{}
  7073. label_relationships map[uint64]struct{}
  7074. removedlabel_relationships map[uint64]struct{}
  7075. clearedlabel_relationships bool
  7076. done bool
  7077. oldValue func(context.Context) (*Label, error)
  7078. predicates []predicate.Label
  7079. }
  7080. var _ ent.Mutation = (*LabelMutation)(nil)
  7081. // labelOption allows management of the mutation configuration using functional options.
  7082. type labelOption func(*LabelMutation)
  7083. // newLabelMutation creates new mutation for the Label entity.
  7084. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  7085. m := &LabelMutation{
  7086. config: c,
  7087. op: op,
  7088. typ: TypeLabel,
  7089. clearedFields: make(map[string]struct{}),
  7090. }
  7091. for _, opt := range opts {
  7092. opt(m)
  7093. }
  7094. return m
  7095. }
  7096. // withLabelID sets the ID field of the mutation.
  7097. func withLabelID(id uint64) labelOption {
  7098. return func(m *LabelMutation) {
  7099. var (
  7100. err error
  7101. once sync.Once
  7102. value *Label
  7103. )
  7104. m.oldValue = func(ctx context.Context) (*Label, error) {
  7105. once.Do(func() {
  7106. if m.done {
  7107. err = errors.New("querying old values post mutation is not allowed")
  7108. } else {
  7109. value, err = m.Client().Label.Get(ctx, id)
  7110. }
  7111. })
  7112. return value, err
  7113. }
  7114. m.id = &id
  7115. }
  7116. }
  7117. // withLabel sets the old Label of the mutation.
  7118. func withLabel(node *Label) labelOption {
  7119. return func(m *LabelMutation) {
  7120. m.oldValue = func(context.Context) (*Label, error) {
  7121. return node, nil
  7122. }
  7123. m.id = &node.ID
  7124. }
  7125. }
  7126. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7127. // executed in a transaction (ent.Tx), a transactional client is returned.
  7128. func (m LabelMutation) Client() *Client {
  7129. client := &Client{config: m.config}
  7130. client.init()
  7131. return client
  7132. }
  7133. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7134. // it returns an error otherwise.
  7135. func (m LabelMutation) Tx() (*Tx, error) {
  7136. if _, ok := m.driver.(*txDriver); !ok {
  7137. return nil, errors.New("ent: mutation is not running in a transaction")
  7138. }
  7139. tx := &Tx{config: m.config}
  7140. tx.init()
  7141. return tx, nil
  7142. }
  7143. // SetID sets the value of the id field. Note that this
  7144. // operation is only accepted on creation of Label entities.
  7145. func (m *LabelMutation) SetID(id uint64) {
  7146. m.id = &id
  7147. }
  7148. // ID returns the ID value in the mutation. Note that the ID is only available
  7149. // if it was provided to the builder or after it was returned from the database.
  7150. func (m *LabelMutation) ID() (id uint64, exists bool) {
  7151. if m.id == nil {
  7152. return
  7153. }
  7154. return *m.id, true
  7155. }
  7156. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7157. // That means, if the mutation is applied within a transaction with an isolation level such
  7158. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7159. // or updated by the mutation.
  7160. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  7161. switch {
  7162. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7163. id, exists := m.ID()
  7164. if exists {
  7165. return []uint64{id}, nil
  7166. }
  7167. fallthrough
  7168. case m.op.Is(OpUpdate | OpDelete):
  7169. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  7170. default:
  7171. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7172. }
  7173. }
  7174. // SetCreatedAt sets the "created_at" field.
  7175. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  7176. m.created_at = &t
  7177. }
  7178. // CreatedAt returns the value of the "created_at" field in the mutation.
  7179. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  7180. v := m.created_at
  7181. if v == nil {
  7182. return
  7183. }
  7184. return *v, true
  7185. }
  7186. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  7187. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7189. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7190. if !m.op.Is(OpUpdateOne) {
  7191. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7192. }
  7193. if m.id == nil || m.oldValue == nil {
  7194. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7195. }
  7196. oldValue, err := m.oldValue(ctx)
  7197. if err != nil {
  7198. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7199. }
  7200. return oldValue.CreatedAt, nil
  7201. }
  7202. // ResetCreatedAt resets all changes to the "created_at" field.
  7203. func (m *LabelMutation) ResetCreatedAt() {
  7204. m.created_at = nil
  7205. }
  7206. // SetUpdatedAt sets the "updated_at" field.
  7207. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  7208. m.updated_at = &t
  7209. }
  7210. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7211. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  7212. v := m.updated_at
  7213. if v == nil {
  7214. return
  7215. }
  7216. return *v, true
  7217. }
  7218. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  7219. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7221. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7222. if !m.op.Is(OpUpdateOne) {
  7223. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7224. }
  7225. if m.id == nil || m.oldValue == nil {
  7226. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7227. }
  7228. oldValue, err := m.oldValue(ctx)
  7229. if err != nil {
  7230. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7231. }
  7232. return oldValue.UpdatedAt, nil
  7233. }
  7234. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7235. func (m *LabelMutation) ResetUpdatedAt() {
  7236. m.updated_at = nil
  7237. }
  7238. // SetStatus sets the "status" field.
  7239. func (m *LabelMutation) SetStatus(u uint8) {
  7240. m.status = &u
  7241. m.addstatus = nil
  7242. }
  7243. // Status returns the value of the "status" field in the mutation.
  7244. func (m *LabelMutation) Status() (r uint8, exists bool) {
  7245. v := m.status
  7246. if v == nil {
  7247. return
  7248. }
  7249. return *v, true
  7250. }
  7251. // OldStatus returns the old "status" field's value of the Label entity.
  7252. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7254. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7255. if !m.op.Is(OpUpdateOne) {
  7256. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7257. }
  7258. if m.id == nil || m.oldValue == nil {
  7259. return v, errors.New("OldStatus requires an ID field in the mutation")
  7260. }
  7261. oldValue, err := m.oldValue(ctx)
  7262. if err != nil {
  7263. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7264. }
  7265. return oldValue.Status, nil
  7266. }
  7267. // AddStatus adds u to the "status" field.
  7268. func (m *LabelMutation) AddStatus(u int8) {
  7269. if m.addstatus != nil {
  7270. *m.addstatus += u
  7271. } else {
  7272. m.addstatus = &u
  7273. }
  7274. }
  7275. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7276. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  7277. v := m.addstatus
  7278. if v == nil {
  7279. return
  7280. }
  7281. return *v, true
  7282. }
  7283. // ClearStatus clears the value of the "status" field.
  7284. func (m *LabelMutation) ClearStatus() {
  7285. m.status = nil
  7286. m.addstatus = nil
  7287. m.clearedFields[label.FieldStatus] = struct{}{}
  7288. }
  7289. // StatusCleared returns if the "status" field was cleared in this mutation.
  7290. func (m *LabelMutation) StatusCleared() bool {
  7291. _, ok := m.clearedFields[label.FieldStatus]
  7292. return ok
  7293. }
  7294. // ResetStatus resets all changes to the "status" field.
  7295. func (m *LabelMutation) ResetStatus() {
  7296. m.status = nil
  7297. m.addstatus = nil
  7298. delete(m.clearedFields, label.FieldStatus)
  7299. }
  7300. // SetType sets the "type" field.
  7301. func (m *LabelMutation) SetType(i int) {
  7302. m._type = &i
  7303. m.add_type = nil
  7304. }
  7305. // GetType returns the value of the "type" field in the mutation.
  7306. func (m *LabelMutation) GetType() (r int, exists bool) {
  7307. v := m._type
  7308. if v == nil {
  7309. return
  7310. }
  7311. return *v, true
  7312. }
  7313. // OldType returns the old "type" field's value of the Label entity.
  7314. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7316. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  7317. if !m.op.Is(OpUpdateOne) {
  7318. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7319. }
  7320. if m.id == nil || m.oldValue == nil {
  7321. return v, errors.New("OldType requires an ID field in the mutation")
  7322. }
  7323. oldValue, err := m.oldValue(ctx)
  7324. if err != nil {
  7325. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7326. }
  7327. return oldValue.Type, nil
  7328. }
  7329. // AddType adds i to the "type" field.
  7330. func (m *LabelMutation) AddType(i int) {
  7331. if m.add_type != nil {
  7332. *m.add_type += i
  7333. } else {
  7334. m.add_type = &i
  7335. }
  7336. }
  7337. // AddedType returns the value that was added to the "type" field in this mutation.
  7338. func (m *LabelMutation) AddedType() (r int, exists bool) {
  7339. v := m.add_type
  7340. if v == nil {
  7341. return
  7342. }
  7343. return *v, true
  7344. }
  7345. // ResetType resets all changes to the "type" field.
  7346. func (m *LabelMutation) ResetType() {
  7347. m._type = nil
  7348. m.add_type = nil
  7349. }
  7350. // SetName sets the "name" field.
  7351. func (m *LabelMutation) SetName(s string) {
  7352. m.name = &s
  7353. }
  7354. // Name returns the value of the "name" field in the mutation.
  7355. func (m *LabelMutation) Name() (r string, exists bool) {
  7356. v := m.name
  7357. if v == nil {
  7358. return
  7359. }
  7360. return *v, true
  7361. }
  7362. // OldName returns the old "name" field's value of the Label entity.
  7363. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7365. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  7366. if !m.op.Is(OpUpdateOne) {
  7367. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7368. }
  7369. if m.id == nil || m.oldValue == nil {
  7370. return v, errors.New("OldName requires an ID field in the mutation")
  7371. }
  7372. oldValue, err := m.oldValue(ctx)
  7373. if err != nil {
  7374. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7375. }
  7376. return oldValue.Name, nil
  7377. }
  7378. // ResetName resets all changes to the "name" field.
  7379. func (m *LabelMutation) ResetName() {
  7380. m.name = nil
  7381. }
  7382. // SetFrom sets the "from" field.
  7383. func (m *LabelMutation) SetFrom(i int) {
  7384. m.from = &i
  7385. m.addfrom = nil
  7386. }
  7387. // From returns the value of the "from" field in the mutation.
  7388. func (m *LabelMutation) From() (r int, exists bool) {
  7389. v := m.from
  7390. if v == nil {
  7391. return
  7392. }
  7393. return *v, true
  7394. }
  7395. // OldFrom returns the old "from" field's value of the Label entity.
  7396. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7398. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  7399. if !m.op.Is(OpUpdateOne) {
  7400. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  7401. }
  7402. if m.id == nil || m.oldValue == nil {
  7403. return v, errors.New("OldFrom requires an ID field in the mutation")
  7404. }
  7405. oldValue, err := m.oldValue(ctx)
  7406. if err != nil {
  7407. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  7408. }
  7409. return oldValue.From, nil
  7410. }
  7411. // AddFrom adds i to the "from" field.
  7412. func (m *LabelMutation) AddFrom(i int) {
  7413. if m.addfrom != nil {
  7414. *m.addfrom += i
  7415. } else {
  7416. m.addfrom = &i
  7417. }
  7418. }
  7419. // AddedFrom returns the value that was added to the "from" field in this mutation.
  7420. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  7421. v := m.addfrom
  7422. if v == nil {
  7423. return
  7424. }
  7425. return *v, true
  7426. }
  7427. // ResetFrom resets all changes to the "from" field.
  7428. func (m *LabelMutation) ResetFrom() {
  7429. m.from = nil
  7430. m.addfrom = nil
  7431. }
  7432. // SetMode sets the "mode" field.
  7433. func (m *LabelMutation) SetMode(i int) {
  7434. m.mode = &i
  7435. m.addmode = nil
  7436. }
  7437. // Mode returns the value of the "mode" field in the mutation.
  7438. func (m *LabelMutation) Mode() (r int, exists bool) {
  7439. v := m.mode
  7440. if v == nil {
  7441. return
  7442. }
  7443. return *v, true
  7444. }
  7445. // OldMode returns the old "mode" field's value of the Label entity.
  7446. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7447. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7448. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  7449. if !m.op.Is(OpUpdateOne) {
  7450. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  7451. }
  7452. if m.id == nil || m.oldValue == nil {
  7453. return v, errors.New("OldMode requires an ID field in the mutation")
  7454. }
  7455. oldValue, err := m.oldValue(ctx)
  7456. if err != nil {
  7457. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  7458. }
  7459. return oldValue.Mode, nil
  7460. }
  7461. // AddMode adds i to the "mode" field.
  7462. func (m *LabelMutation) AddMode(i int) {
  7463. if m.addmode != nil {
  7464. *m.addmode += i
  7465. } else {
  7466. m.addmode = &i
  7467. }
  7468. }
  7469. // AddedMode returns the value that was added to the "mode" field in this mutation.
  7470. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  7471. v := m.addmode
  7472. if v == nil {
  7473. return
  7474. }
  7475. return *v, true
  7476. }
  7477. // ResetMode resets all changes to the "mode" field.
  7478. func (m *LabelMutation) ResetMode() {
  7479. m.mode = nil
  7480. m.addmode = nil
  7481. }
  7482. // SetConditions sets the "conditions" field.
  7483. func (m *LabelMutation) SetConditions(s string) {
  7484. m.conditions = &s
  7485. }
  7486. // Conditions returns the value of the "conditions" field in the mutation.
  7487. func (m *LabelMutation) Conditions() (r string, exists bool) {
  7488. v := m.conditions
  7489. if v == nil {
  7490. return
  7491. }
  7492. return *v, true
  7493. }
  7494. // OldConditions returns the old "conditions" field's value of the Label entity.
  7495. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7497. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  7498. if !m.op.Is(OpUpdateOne) {
  7499. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  7500. }
  7501. if m.id == nil || m.oldValue == nil {
  7502. return v, errors.New("OldConditions requires an ID field in the mutation")
  7503. }
  7504. oldValue, err := m.oldValue(ctx)
  7505. if err != nil {
  7506. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  7507. }
  7508. return oldValue.Conditions, nil
  7509. }
  7510. // ClearConditions clears the value of the "conditions" field.
  7511. func (m *LabelMutation) ClearConditions() {
  7512. m.conditions = nil
  7513. m.clearedFields[label.FieldConditions] = struct{}{}
  7514. }
  7515. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  7516. func (m *LabelMutation) ConditionsCleared() bool {
  7517. _, ok := m.clearedFields[label.FieldConditions]
  7518. return ok
  7519. }
  7520. // ResetConditions resets all changes to the "conditions" field.
  7521. func (m *LabelMutation) ResetConditions() {
  7522. m.conditions = nil
  7523. delete(m.clearedFields, label.FieldConditions)
  7524. }
  7525. // SetOrganizationID sets the "organization_id" field.
  7526. func (m *LabelMutation) SetOrganizationID(u uint64) {
  7527. m.organization_id = &u
  7528. m.addorganization_id = nil
  7529. }
  7530. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7531. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  7532. v := m.organization_id
  7533. if v == nil {
  7534. return
  7535. }
  7536. return *v, true
  7537. }
  7538. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  7539. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7541. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7542. if !m.op.Is(OpUpdateOne) {
  7543. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7544. }
  7545. if m.id == nil || m.oldValue == nil {
  7546. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7547. }
  7548. oldValue, err := m.oldValue(ctx)
  7549. if err != nil {
  7550. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7551. }
  7552. return oldValue.OrganizationID, nil
  7553. }
  7554. // AddOrganizationID adds u to the "organization_id" field.
  7555. func (m *LabelMutation) AddOrganizationID(u int64) {
  7556. if m.addorganization_id != nil {
  7557. *m.addorganization_id += u
  7558. } else {
  7559. m.addorganization_id = &u
  7560. }
  7561. }
  7562. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7563. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  7564. v := m.addorganization_id
  7565. if v == nil {
  7566. return
  7567. }
  7568. return *v, true
  7569. }
  7570. // ClearOrganizationID clears the value of the "organization_id" field.
  7571. func (m *LabelMutation) ClearOrganizationID() {
  7572. m.organization_id = nil
  7573. m.addorganization_id = nil
  7574. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  7575. }
  7576. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  7577. func (m *LabelMutation) OrganizationIDCleared() bool {
  7578. _, ok := m.clearedFields[label.FieldOrganizationID]
  7579. return ok
  7580. }
  7581. // ResetOrganizationID resets all changes to the "organization_id" field.
  7582. func (m *LabelMutation) ResetOrganizationID() {
  7583. m.organization_id = nil
  7584. m.addorganization_id = nil
  7585. delete(m.clearedFields, label.FieldOrganizationID)
  7586. }
  7587. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  7588. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  7589. if m.label_relationships == nil {
  7590. m.label_relationships = make(map[uint64]struct{})
  7591. }
  7592. for i := range ids {
  7593. m.label_relationships[ids[i]] = struct{}{}
  7594. }
  7595. }
  7596. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  7597. func (m *LabelMutation) ClearLabelRelationships() {
  7598. m.clearedlabel_relationships = true
  7599. }
  7600. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  7601. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  7602. return m.clearedlabel_relationships
  7603. }
  7604. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  7605. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  7606. if m.removedlabel_relationships == nil {
  7607. m.removedlabel_relationships = make(map[uint64]struct{})
  7608. }
  7609. for i := range ids {
  7610. delete(m.label_relationships, ids[i])
  7611. m.removedlabel_relationships[ids[i]] = struct{}{}
  7612. }
  7613. }
  7614. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  7615. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  7616. for id := range m.removedlabel_relationships {
  7617. ids = append(ids, id)
  7618. }
  7619. return
  7620. }
  7621. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  7622. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  7623. for id := range m.label_relationships {
  7624. ids = append(ids, id)
  7625. }
  7626. return
  7627. }
  7628. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  7629. func (m *LabelMutation) ResetLabelRelationships() {
  7630. m.label_relationships = nil
  7631. m.clearedlabel_relationships = false
  7632. m.removedlabel_relationships = nil
  7633. }
  7634. // Where appends a list predicates to the LabelMutation builder.
  7635. func (m *LabelMutation) Where(ps ...predicate.Label) {
  7636. m.predicates = append(m.predicates, ps...)
  7637. }
  7638. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  7639. // users can use type-assertion to append predicates that do not depend on any generated package.
  7640. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  7641. p := make([]predicate.Label, len(ps))
  7642. for i := range ps {
  7643. p[i] = ps[i]
  7644. }
  7645. m.Where(p...)
  7646. }
  7647. // Op returns the operation name.
  7648. func (m *LabelMutation) Op() Op {
  7649. return m.op
  7650. }
  7651. // SetOp allows setting the mutation operation.
  7652. func (m *LabelMutation) SetOp(op Op) {
  7653. m.op = op
  7654. }
  7655. // Type returns the node type of this mutation (Label).
  7656. func (m *LabelMutation) Type() string {
  7657. return m.typ
  7658. }
  7659. // Fields returns all fields that were changed during this mutation. Note that in
  7660. // order to get all numeric fields that were incremented/decremented, call
  7661. // AddedFields().
  7662. func (m *LabelMutation) Fields() []string {
  7663. fields := make([]string, 0, 9)
  7664. if m.created_at != nil {
  7665. fields = append(fields, label.FieldCreatedAt)
  7666. }
  7667. if m.updated_at != nil {
  7668. fields = append(fields, label.FieldUpdatedAt)
  7669. }
  7670. if m.status != nil {
  7671. fields = append(fields, label.FieldStatus)
  7672. }
  7673. if m._type != nil {
  7674. fields = append(fields, label.FieldType)
  7675. }
  7676. if m.name != nil {
  7677. fields = append(fields, label.FieldName)
  7678. }
  7679. if m.from != nil {
  7680. fields = append(fields, label.FieldFrom)
  7681. }
  7682. if m.mode != nil {
  7683. fields = append(fields, label.FieldMode)
  7684. }
  7685. if m.conditions != nil {
  7686. fields = append(fields, label.FieldConditions)
  7687. }
  7688. if m.organization_id != nil {
  7689. fields = append(fields, label.FieldOrganizationID)
  7690. }
  7691. return fields
  7692. }
  7693. // Field returns the value of a field with the given name. The second boolean
  7694. // return value indicates that this field was not set, or was not defined in the
  7695. // schema.
  7696. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  7697. switch name {
  7698. case label.FieldCreatedAt:
  7699. return m.CreatedAt()
  7700. case label.FieldUpdatedAt:
  7701. return m.UpdatedAt()
  7702. case label.FieldStatus:
  7703. return m.Status()
  7704. case label.FieldType:
  7705. return m.GetType()
  7706. case label.FieldName:
  7707. return m.Name()
  7708. case label.FieldFrom:
  7709. return m.From()
  7710. case label.FieldMode:
  7711. return m.Mode()
  7712. case label.FieldConditions:
  7713. return m.Conditions()
  7714. case label.FieldOrganizationID:
  7715. return m.OrganizationID()
  7716. }
  7717. return nil, false
  7718. }
  7719. // OldField returns the old value of the field from the database. An error is
  7720. // returned if the mutation operation is not UpdateOne, or the query to the
  7721. // database failed.
  7722. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7723. switch name {
  7724. case label.FieldCreatedAt:
  7725. return m.OldCreatedAt(ctx)
  7726. case label.FieldUpdatedAt:
  7727. return m.OldUpdatedAt(ctx)
  7728. case label.FieldStatus:
  7729. return m.OldStatus(ctx)
  7730. case label.FieldType:
  7731. return m.OldType(ctx)
  7732. case label.FieldName:
  7733. return m.OldName(ctx)
  7734. case label.FieldFrom:
  7735. return m.OldFrom(ctx)
  7736. case label.FieldMode:
  7737. return m.OldMode(ctx)
  7738. case label.FieldConditions:
  7739. return m.OldConditions(ctx)
  7740. case label.FieldOrganizationID:
  7741. return m.OldOrganizationID(ctx)
  7742. }
  7743. return nil, fmt.Errorf("unknown Label field %s", name)
  7744. }
  7745. // SetField sets the value of a field with the given name. It returns an error if
  7746. // the field is not defined in the schema, or if the type mismatched the field
  7747. // type.
  7748. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  7749. switch name {
  7750. case label.FieldCreatedAt:
  7751. v, ok := value.(time.Time)
  7752. if !ok {
  7753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7754. }
  7755. m.SetCreatedAt(v)
  7756. return nil
  7757. case label.FieldUpdatedAt:
  7758. v, ok := value.(time.Time)
  7759. if !ok {
  7760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7761. }
  7762. m.SetUpdatedAt(v)
  7763. return nil
  7764. case label.FieldStatus:
  7765. v, ok := value.(uint8)
  7766. if !ok {
  7767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7768. }
  7769. m.SetStatus(v)
  7770. return nil
  7771. case label.FieldType:
  7772. v, ok := value.(int)
  7773. if !ok {
  7774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7775. }
  7776. m.SetType(v)
  7777. return nil
  7778. case label.FieldName:
  7779. v, ok := value.(string)
  7780. if !ok {
  7781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7782. }
  7783. m.SetName(v)
  7784. return nil
  7785. case label.FieldFrom:
  7786. v, ok := value.(int)
  7787. if !ok {
  7788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7789. }
  7790. m.SetFrom(v)
  7791. return nil
  7792. case label.FieldMode:
  7793. v, ok := value.(int)
  7794. if !ok {
  7795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7796. }
  7797. m.SetMode(v)
  7798. return nil
  7799. case label.FieldConditions:
  7800. v, ok := value.(string)
  7801. if !ok {
  7802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7803. }
  7804. m.SetConditions(v)
  7805. return nil
  7806. case label.FieldOrganizationID:
  7807. v, ok := value.(uint64)
  7808. if !ok {
  7809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7810. }
  7811. m.SetOrganizationID(v)
  7812. return nil
  7813. }
  7814. return fmt.Errorf("unknown Label field %s", name)
  7815. }
  7816. // AddedFields returns all numeric fields that were incremented/decremented during
  7817. // this mutation.
  7818. func (m *LabelMutation) AddedFields() []string {
  7819. var fields []string
  7820. if m.addstatus != nil {
  7821. fields = append(fields, label.FieldStatus)
  7822. }
  7823. if m.add_type != nil {
  7824. fields = append(fields, label.FieldType)
  7825. }
  7826. if m.addfrom != nil {
  7827. fields = append(fields, label.FieldFrom)
  7828. }
  7829. if m.addmode != nil {
  7830. fields = append(fields, label.FieldMode)
  7831. }
  7832. if m.addorganization_id != nil {
  7833. fields = append(fields, label.FieldOrganizationID)
  7834. }
  7835. return fields
  7836. }
  7837. // AddedField returns the numeric value that was incremented/decremented on a field
  7838. // with the given name. The second boolean return value indicates that this field
  7839. // was not set, or was not defined in the schema.
  7840. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  7841. switch name {
  7842. case label.FieldStatus:
  7843. return m.AddedStatus()
  7844. case label.FieldType:
  7845. return m.AddedType()
  7846. case label.FieldFrom:
  7847. return m.AddedFrom()
  7848. case label.FieldMode:
  7849. return m.AddedMode()
  7850. case label.FieldOrganizationID:
  7851. return m.AddedOrganizationID()
  7852. }
  7853. return nil, false
  7854. }
  7855. // AddField adds the value to the field with the given name. It returns an error if
  7856. // the field is not defined in the schema, or if the type mismatched the field
  7857. // type.
  7858. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  7859. switch name {
  7860. case label.FieldStatus:
  7861. v, ok := value.(int8)
  7862. if !ok {
  7863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7864. }
  7865. m.AddStatus(v)
  7866. return nil
  7867. case label.FieldType:
  7868. v, ok := value.(int)
  7869. if !ok {
  7870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7871. }
  7872. m.AddType(v)
  7873. return nil
  7874. case label.FieldFrom:
  7875. v, ok := value.(int)
  7876. if !ok {
  7877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7878. }
  7879. m.AddFrom(v)
  7880. return nil
  7881. case label.FieldMode:
  7882. v, ok := value.(int)
  7883. if !ok {
  7884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7885. }
  7886. m.AddMode(v)
  7887. return nil
  7888. case label.FieldOrganizationID:
  7889. v, ok := value.(int64)
  7890. if !ok {
  7891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7892. }
  7893. m.AddOrganizationID(v)
  7894. return nil
  7895. }
  7896. return fmt.Errorf("unknown Label numeric field %s", name)
  7897. }
  7898. // ClearedFields returns all nullable fields that were cleared during this
  7899. // mutation.
  7900. func (m *LabelMutation) ClearedFields() []string {
  7901. var fields []string
  7902. if m.FieldCleared(label.FieldStatus) {
  7903. fields = append(fields, label.FieldStatus)
  7904. }
  7905. if m.FieldCleared(label.FieldConditions) {
  7906. fields = append(fields, label.FieldConditions)
  7907. }
  7908. if m.FieldCleared(label.FieldOrganizationID) {
  7909. fields = append(fields, label.FieldOrganizationID)
  7910. }
  7911. return fields
  7912. }
  7913. // FieldCleared returns a boolean indicating if a field with the given name was
  7914. // cleared in this mutation.
  7915. func (m *LabelMutation) FieldCleared(name string) bool {
  7916. _, ok := m.clearedFields[name]
  7917. return ok
  7918. }
  7919. // ClearField clears the value of the field with the given name. It returns an
  7920. // error if the field is not defined in the schema.
  7921. func (m *LabelMutation) ClearField(name string) error {
  7922. switch name {
  7923. case label.FieldStatus:
  7924. m.ClearStatus()
  7925. return nil
  7926. case label.FieldConditions:
  7927. m.ClearConditions()
  7928. return nil
  7929. case label.FieldOrganizationID:
  7930. m.ClearOrganizationID()
  7931. return nil
  7932. }
  7933. return fmt.Errorf("unknown Label nullable field %s", name)
  7934. }
  7935. // ResetField resets all changes in the mutation for the field with the given name.
  7936. // It returns an error if the field is not defined in the schema.
  7937. func (m *LabelMutation) ResetField(name string) error {
  7938. switch name {
  7939. case label.FieldCreatedAt:
  7940. m.ResetCreatedAt()
  7941. return nil
  7942. case label.FieldUpdatedAt:
  7943. m.ResetUpdatedAt()
  7944. return nil
  7945. case label.FieldStatus:
  7946. m.ResetStatus()
  7947. return nil
  7948. case label.FieldType:
  7949. m.ResetType()
  7950. return nil
  7951. case label.FieldName:
  7952. m.ResetName()
  7953. return nil
  7954. case label.FieldFrom:
  7955. m.ResetFrom()
  7956. return nil
  7957. case label.FieldMode:
  7958. m.ResetMode()
  7959. return nil
  7960. case label.FieldConditions:
  7961. m.ResetConditions()
  7962. return nil
  7963. case label.FieldOrganizationID:
  7964. m.ResetOrganizationID()
  7965. return nil
  7966. }
  7967. return fmt.Errorf("unknown Label field %s", name)
  7968. }
  7969. // AddedEdges returns all edge names that were set/added in this mutation.
  7970. func (m *LabelMutation) AddedEdges() []string {
  7971. edges := make([]string, 0, 1)
  7972. if m.label_relationships != nil {
  7973. edges = append(edges, label.EdgeLabelRelationships)
  7974. }
  7975. return edges
  7976. }
  7977. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7978. // name in this mutation.
  7979. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  7980. switch name {
  7981. case label.EdgeLabelRelationships:
  7982. ids := make([]ent.Value, 0, len(m.label_relationships))
  7983. for id := range m.label_relationships {
  7984. ids = append(ids, id)
  7985. }
  7986. return ids
  7987. }
  7988. return nil
  7989. }
  7990. // RemovedEdges returns all edge names that were removed in this mutation.
  7991. func (m *LabelMutation) RemovedEdges() []string {
  7992. edges := make([]string, 0, 1)
  7993. if m.removedlabel_relationships != nil {
  7994. edges = append(edges, label.EdgeLabelRelationships)
  7995. }
  7996. return edges
  7997. }
  7998. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7999. // the given name in this mutation.
  8000. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  8001. switch name {
  8002. case label.EdgeLabelRelationships:
  8003. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  8004. for id := range m.removedlabel_relationships {
  8005. ids = append(ids, id)
  8006. }
  8007. return ids
  8008. }
  8009. return nil
  8010. }
  8011. // ClearedEdges returns all edge names that were cleared in this mutation.
  8012. func (m *LabelMutation) ClearedEdges() []string {
  8013. edges := make([]string, 0, 1)
  8014. if m.clearedlabel_relationships {
  8015. edges = append(edges, label.EdgeLabelRelationships)
  8016. }
  8017. return edges
  8018. }
  8019. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8020. // was cleared in this mutation.
  8021. func (m *LabelMutation) EdgeCleared(name string) bool {
  8022. switch name {
  8023. case label.EdgeLabelRelationships:
  8024. return m.clearedlabel_relationships
  8025. }
  8026. return false
  8027. }
  8028. // ClearEdge clears the value of the edge with the given name. It returns an error
  8029. // if that edge is not defined in the schema.
  8030. func (m *LabelMutation) ClearEdge(name string) error {
  8031. switch name {
  8032. }
  8033. return fmt.Errorf("unknown Label unique edge %s", name)
  8034. }
  8035. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8036. // It returns an error if the edge is not defined in the schema.
  8037. func (m *LabelMutation) ResetEdge(name string) error {
  8038. switch name {
  8039. case label.EdgeLabelRelationships:
  8040. m.ResetLabelRelationships()
  8041. return nil
  8042. }
  8043. return fmt.Errorf("unknown Label edge %s", name)
  8044. }
  8045. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  8046. type LabelRelationshipMutation struct {
  8047. config
  8048. op Op
  8049. typ string
  8050. id *uint64
  8051. created_at *time.Time
  8052. updated_at *time.Time
  8053. status *uint8
  8054. addstatus *int8
  8055. deleted_at *time.Time
  8056. organization_id *uint64
  8057. addorganization_id *int64
  8058. clearedFields map[string]struct{}
  8059. contacts *uint64
  8060. clearedcontacts bool
  8061. labels *uint64
  8062. clearedlabels bool
  8063. done bool
  8064. oldValue func(context.Context) (*LabelRelationship, error)
  8065. predicates []predicate.LabelRelationship
  8066. }
  8067. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  8068. // labelrelationshipOption allows management of the mutation configuration using functional options.
  8069. type labelrelationshipOption func(*LabelRelationshipMutation)
  8070. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  8071. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  8072. m := &LabelRelationshipMutation{
  8073. config: c,
  8074. op: op,
  8075. typ: TypeLabelRelationship,
  8076. clearedFields: make(map[string]struct{}),
  8077. }
  8078. for _, opt := range opts {
  8079. opt(m)
  8080. }
  8081. return m
  8082. }
  8083. // withLabelRelationshipID sets the ID field of the mutation.
  8084. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  8085. return func(m *LabelRelationshipMutation) {
  8086. var (
  8087. err error
  8088. once sync.Once
  8089. value *LabelRelationship
  8090. )
  8091. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  8092. once.Do(func() {
  8093. if m.done {
  8094. err = errors.New("querying old values post mutation is not allowed")
  8095. } else {
  8096. value, err = m.Client().LabelRelationship.Get(ctx, id)
  8097. }
  8098. })
  8099. return value, err
  8100. }
  8101. m.id = &id
  8102. }
  8103. }
  8104. // withLabelRelationship sets the old LabelRelationship of the mutation.
  8105. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  8106. return func(m *LabelRelationshipMutation) {
  8107. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  8108. return node, nil
  8109. }
  8110. m.id = &node.ID
  8111. }
  8112. }
  8113. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8114. // executed in a transaction (ent.Tx), a transactional client is returned.
  8115. func (m LabelRelationshipMutation) Client() *Client {
  8116. client := &Client{config: m.config}
  8117. client.init()
  8118. return client
  8119. }
  8120. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8121. // it returns an error otherwise.
  8122. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  8123. if _, ok := m.driver.(*txDriver); !ok {
  8124. return nil, errors.New("ent: mutation is not running in a transaction")
  8125. }
  8126. tx := &Tx{config: m.config}
  8127. tx.init()
  8128. return tx, nil
  8129. }
  8130. // SetID sets the value of the id field. Note that this
  8131. // operation is only accepted on creation of LabelRelationship entities.
  8132. func (m *LabelRelationshipMutation) SetID(id uint64) {
  8133. m.id = &id
  8134. }
  8135. // ID returns the ID value in the mutation. Note that the ID is only available
  8136. // if it was provided to the builder or after it was returned from the database.
  8137. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  8138. if m.id == nil {
  8139. return
  8140. }
  8141. return *m.id, true
  8142. }
  8143. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8144. // That means, if the mutation is applied within a transaction with an isolation level such
  8145. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8146. // or updated by the mutation.
  8147. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  8148. switch {
  8149. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8150. id, exists := m.ID()
  8151. if exists {
  8152. return []uint64{id}, nil
  8153. }
  8154. fallthrough
  8155. case m.op.Is(OpUpdate | OpDelete):
  8156. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  8157. default:
  8158. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8159. }
  8160. }
  8161. // SetCreatedAt sets the "created_at" field.
  8162. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  8163. m.created_at = &t
  8164. }
  8165. // CreatedAt returns the value of the "created_at" field in the mutation.
  8166. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  8167. v := m.created_at
  8168. if v == nil {
  8169. return
  8170. }
  8171. return *v, true
  8172. }
  8173. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  8174. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8176. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8177. if !m.op.Is(OpUpdateOne) {
  8178. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8179. }
  8180. if m.id == nil || m.oldValue == nil {
  8181. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8182. }
  8183. oldValue, err := m.oldValue(ctx)
  8184. if err != nil {
  8185. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8186. }
  8187. return oldValue.CreatedAt, nil
  8188. }
  8189. // ResetCreatedAt resets all changes to the "created_at" field.
  8190. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  8191. m.created_at = nil
  8192. }
  8193. // SetUpdatedAt sets the "updated_at" field.
  8194. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  8195. m.updated_at = &t
  8196. }
  8197. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8198. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  8199. v := m.updated_at
  8200. if v == nil {
  8201. return
  8202. }
  8203. return *v, true
  8204. }
  8205. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  8206. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8208. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8209. if !m.op.Is(OpUpdateOne) {
  8210. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8211. }
  8212. if m.id == nil || m.oldValue == nil {
  8213. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8214. }
  8215. oldValue, err := m.oldValue(ctx)
  8216. if err != nil {
  8217. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8218. }
  8219. return oldValue.UpdatedAt, nil
  8220. }
  8221. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8222. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  8223. m.updated_at = nil
  8224. }
  8225. // SetStatus sets the "status" field.
  8226. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  8227. m.status = &u
  8228. m.addstatus = nil
  8229. }
  8230. // Status returns the value of the "status" field in the mutation.
  8231. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  8232. v := m.status
  8233. if v == nil {
  8234. return
  8235. }
  8236. return *v, true
  8237. }
  8238. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  8239. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8241. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  8242. if !m.op.Is(OpUpdateOne) {
  8243. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  8244. }
  8245. if m.id == nil || m.oldValue == nil {
  8246. return v, errors.New("OldStatus requires an ID field in the mutation")
  8247. }
  8248. oldValue, err := m.oldValue(ctx)
  8249. if err != nil {
  8250. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  8251. }
  8252. return oldValue.Status, nil
  8253. }
  8254. // AddStatus adds u to the "status" field.
  8255. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  8256. if m.addstatus != nil {
  8257. *m.addstatus += u
  8258. } else {
  8259. m.addstatus = &u
  8260. }
  8261. }
  8262. // AddedStatus returns the value that was added to the "status" field in this mutation.
  8263. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  8264. v := m.addstatus
  8265. if v == nil {
  8266. return
  8267. }
  8268. return *v, true
  8269. }
  8270. // ClearStatus clears the value of the "status" field.
  8271. func (m *LabelRelationshipMutation) ClearStatus() {
  8272. m.status = nil
  8273. m.addstatus = nil
  8274. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  8275. }
  8276. // StatusCleared returns if the "status" field was cleared in this mutation.
  8277. func (m *LabelRelationshipMutation) StatusCleared() bool {
  8278. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  8279. return ok
  8280. }
  8281. // ResetStatus resets all changes to the "status" field.
  8282. func (m *LabelRelationshipMutation) ResetStatus() {
  8283. m.status = nil
  8284. m.addstatus = nil
  8285. delete(m.clearedFields, labelrelationship.FieldStatus)
  8286. }
  8287. // SetDeletedAt sets the "deleted_at" field.
  8288. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  8289. m.deleted_at = &t
  8290. }
  8291. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8292. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  8293. v := m.deleted_at
  8294. if v == nil {
  8295. return
  8296. }
  8297. return *v, true
  8298. }
  8299. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  8300. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8302. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8303. if !m.op.Is(OpUpdateOne) {
  8304. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8305. }
  8306. if m.id == nil || m.oldValue == nil {
  8307. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8308. }
  8309. oldValue, err := m.oldValue(ctx)
  8310. if err != nil {
  8311. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8312. }
  8313. return oldValue.DeletedAt, nil
  8314. }
  8315. // ClearDeletedAt clears the value of the "deleted_at" field.
  8316. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  8317. m.deleted_at = nil
  8318. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  8319. }
  8320. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8321. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  8322. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  8323. return ok
  8324. }
  8325. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8326. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  8327. m.deleted_at = nil
  8328. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  8329. }
  8330. // SetLabelID sets the "label_id" field.
  8331. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  8332. m.labels = &u
  8333. }
  8334. // LabelID returns the value of the "label_id" field in the mutation.
  8335. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  8336. v := m.labels
  8337. if v == nil {
  8338. return
  8339. }
  8340. return *v, true
  8341. }
  8342. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  8343. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8345. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  8346. if !m.op.Is(OpUpdateOne) {
  8347. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  8348. }
  8349. if m.id == nil || m.oldValue == nil {
  8350. return v, errors.New("OldLabelID requires an ID field in the mutation")
  8351. }
  8352. oldValue, err := m.oldValue(ctx)
  8353. if err != nil {
  8354. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  8355. }
  8356. return oldValue.LabelID, nil
  8357. }
  8358. // ResetLabelID resets all changes to the "label_id" field.
  8359. func (m *LabelRelationshipMutation) ResetLabelID() {
  8360. m.labels = nil
  8361. }
  8362. // SetContactID sets the "contact_id" field.
  8363. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  8364. m.contacts = &u
  8365. }
  8366. // ContactID returns the value of the "contact_id" field in the mutation.
  8367. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  8368. v := m.contacts
  8369. if v == nil {
  8370. return
  8371. }
  8372. return *v, true
  8373. }
  8374. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  8375. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8377. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  8378. if !m.op.Is(OpUpdateOne) {
  8379. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  8380. }
  8381. if m.id == nil || m.oldValue == nil {
  8382. return v, errors.New("OldContactID requires an ID field in the mutation")
  8383. }
  8384. oldValue, err := m.oldValue(ctx)
  8385. if err != nil {
  8386. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  8387. }
  8388. return oldValue.ContactID, nil
  8389. }
  8390. // ResetContactID resets all changes to the "contact_id" field.
  8391. func (m *LabelRelationshipMutation) ResetContactID() {
  8392. m.contacts = nil
  8393. }
  8394. // SetOrganizationID sets the "organization_id" field.
  8395. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  8396. m.organization_id = &u
  8397. m.addorganization_id = nil
  8398. }
  8399. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8400. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  8401. v := m.organization_id
  8402. if v == nil {
  8403. return
  8404. }
  8405. return *v, true
  8406. }
  8407. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  8408. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8410. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8411. if !m.op.Is(OpUpdateOne) {
  8412. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8413. }
  8414. if m.id == nil || m.oldValue == nil {
  8415. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8416. }
  8417. oldValue, err := m.oldValue(ctx)
  8418. if err != nil {
  8419. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8420. }
  8421. return oldValue.OrganizationID, nil
  8422. }
  8423. // AddOrganizationID adds u to the "organization_id" field.
  8424. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  8425. if m.addorganization_id != nil {
  8426. *m.addorganization_id += u
  8427. } else {
  8428. m.addorganization_id = &u
  8429. }
  8430. }
  8431. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8432. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  8433. v := m.addorganization_id
  8434. if v == nil {
  8435. return
  8436. }
  8437. return *v, true
  8438. }
  8439. // ClearOrganizationID clears the value of the "organization_id" field.
  8440. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  8441. m.organization_id = nil
  8442. m.addorganization_id = nil
  8443. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  8444. }
  8445. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  8446. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  8447. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  8448. return ok
  8449. }
  8450. // ResetOrganizationID resets all changes to the "organization_id" field.
  8451. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  8452. m.organization_id = nil
  8453. m.addorganization_id = nil
  8454. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  8455. }
  8456. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  8457. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  8458. m.contacts = &id
  8459. }
  8460. // ClearContacts clears the "contacts" edge to the Contact entity.
  8461. func (m *LabelRelationshipMutation) ClearContacts() {
  8462. m.clearedcontacts = true
  8463. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  8464. }
  8465. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  8466. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  8467. return m.clearedcontacts
  8468. }
  8469. // ContactsID returns the "contacts" edge ID in the mutation.
  8470. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  8471. if m.contacts != nil {
  8472. return *m.contacts, true
  8473. }
  8474. return
  8475. }
  8476. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  8477. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  8478. // ContactsID instead. It exists only for internal usage by the builders.
  8479. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  8480. if id := m.contacts; id != nil {
  8481. ids = append(ids, *id)
  8482. }
  8483. return
  8484. }
  8485. // ResetContacts resets all changes to the "contacts" edge.
  8486. func (m *LabelRelationshipMutation) ResetContacts() {
  8487. m.contacts = nil
  8488. m.clearedcontacts = false
  8489. }
  8490. // SetLabelsID sets the "labels" edge to the Label entity by id.
  8491. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  8492. m.labels = &id
  8493. }
  8494. // ClearLabels clears the "labels" edge to the Label entity.
  8495. func (m *LabelRelationshipMutation) ClearLabels() {
  8496. m.clearedlabels = true
  8497. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  8498. }
  8499. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  8500. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  8501. return m.clearedlabels
  8502. }
  8503. // LabelsID returns the "labels" edge ID in the mutation.
  8504. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  8505. if m.labels != nil {
  8506. return *m.labels, true
  8507. }
  8508. return
  8509. }
  8510. // LabelsIDs returns the "labels" edge IDs in the mutation.
  8511. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  8512. // LabelsID instead. It exists only for internal usage by the builders.
  8513. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  8514. if id := m.labels; id != nil {
  8515. ids = append(ids, *id)
  8516. }
  8517. return
  8518. }
  8519. // ResetLabels resets all changes to the "labels" edge.
  8520. func (m *LabelRelationshipMutation) ResetLabels() {
  8521. m.labels = nil
  8522. m.clearedlabels = false
  8523. }
  8524. // Where appends a list predicates to the LabelRelationshipMutation builder.
  8525. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  8526. m.predicates = append(m.predicates, ps...)
  8527. }
  8528. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  8529. // users can use type-assertion to append predicates that do not depend on any generated package.
  8530. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  8531. p := make([]predicate.LabelRelationship, len(ps))
  8532. for i := range ps {
  8533. p[i] = ps[i]
  8534. }
  8535. m.Where(p...)
  8536. }
  8537. // Op returns the operation name.
  8538. func (m *LabelRelationshipMutation) Op() Op {
  8539. return m.op
  8540. }
  8541. // SetOp allows setting the mutation operation.
  8542. func (m *LabelRelationshipMutation) SetOp(op Op) {
  8543. m.op = op
  8544. }
  8545. // Type returns the node type of this mutation (LabelRelationship).
  8546. func (m *LabelRelationshipMutation) Type() string {
  8547. return m.typ
  8548. }
  8549. // Fields returns all fields that were changed during this mutation. Note that in
  8550. // order to get all numeric fields that were incremented/decremented, call
  8551. // AddedFields().
  8552. func (m *LabelRelationshipMutation) Fields() []string {
  8553. fields := make([]string, 0, 7)
  8554. if m.created_at != nil {
  8555. fields = append(fields, labelrelationship.FieldCreatedAt)
  8556. }
  8557. if m.updated_at != nil {
  8558. fields = append(fields, labelrelationship.FieldUpdatedAt)
  8559. }
  8560. if m.status != nil {
  8561. fields = append(fields, labelrelationship.FieldStatus)
  8562. }
  8563. if m.deleted_at != nil {
  8564. fields = append(fields, labelrelationship.FieldDeletedAt)
  8565. }
  8566. if m.labels != nil {
  8567. fields = append(fields, labelrelationship.FieldLabelID)
  8568. }
  8569. if m.contacts != nil {
  8570. fields = append(fields, labelrelationship.FieldContactID)
  8571. }
  8572. if m.organization_id != nil {
  8573. fields = append(fields, labelrelationship.FieldOrganizationID)
  8574. }
  8575. return fields
  8576. }
  8577. // Field returns the value of a field with the given name. The second boolean
  8578. // return value indicates that this field was not set, or was not defined in the
  8579. // schema.
  8580. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  8581. switch name {
  8582. case labelrelationship.FieldCreatedAt:
  8583. return m.CreatedAt()
  8584. case labelrelationship.FieldUpdatedAt:
  8585. return m.UpdatedAt()
  8586. case labelrelationship.FieldStatus:
  8587. return m.Status()
  8588. case labelrelationship.FieldDeletedAt:
  8589. return m.DeletedAt()
  8590. case labelrelationship.FieldLabelID:
  8591. return m.LabelID()
  8592. case labelrelationship.FieldContactID:
  8593. return m.ContactID()
  8594. case labelrelationship.FieldOrganizationID:
  8595. return m.OrganizationID()
  8596. }
  8597. return nil, false
  8598. }
  8599. // OldField returns the old value of the field from the database. An error is
  8600. // returned if the mutation operation is not UpdateOne, or the query to the
  8601. // database failed.
  8602. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8603. switch name {
  8604. case labelrelationship.FieldCreatedAt:
  8605. return m.OldCreatedAt(ctx)
  8606. case labelrelationship.FieldUpdatedAt:
  8607. return m.OldUpdatedAt(ctx)
  8608. case labelrelationship.FieldStatus:
  8609. return m.OldStatus(ctx)
  8610. case labelrelationship.FieldDeletedAt:
  8611. return m.OldDeletedAt(ctx)
  8612. case labelrelationship.FieldLabelID:
  8613. return m.OldLabelID(ctx)
  8614. case labelrelationship.FieldContactID:
  8615. return m.OldContactID(ctx)
  8616. case labelrelationship.FieldOrganizationID:
  8617. return m.OldOrganizationID(ctx)
  8618. }
  8619. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  8620. }
  8621. // SetField sets the value of a field with the given name. It returns an error if
  8622. // the field is not defined in the schema, or if the type mismatched the field
  8623. // type.
  8624. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  8625. switch name {
  8626. case labelrelationship.FieldCreatedAt:
  8627. v, ok := value.(time.Time)
  8628. if !ok {
  8629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8630. }
  8631. m.SetCreatedAt(v)
  8632. return nil
  8633. case labelrelationship.FieldUpdatedAt:
  8634. v, ok := value.(time.Time)
  8635. if !ok {
  8636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8637. }
  8638. m.SetUpdatedAt(v)
  8639. return nil
  8640. case labelrelationship.FieldStatus:
  8641. v, ok := value.(uint8)
  8642. if !ok {
  8643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8644. }
  8645. m.SetStatus(v)
  8646. return nil
  8647. case labelrelationship.FieldDeletedAt:
  8648. v, ok := value.(time.Time)
  8649. if !ok {
  8650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8651. }
  8652. m.SetDeletedAt(v)
  8653. return nil
  8654. case labelrelationship.FieldLabelID:
  8655. v, ok := value.(uint64)
  8656. if !ok {
  8657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8658. }
  8659. m.SetLabelID(v)
  8660. return nil
  8661. case labelrelationship.FieldContactID:
  8662. v, ok := value.(uint64)
  8663. if !ok {
  8664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8665. }
  8666. m.SetContactID(v)
  8667. return nil
  8668. case labelrelationship.FieldOrganizationID:
  8669. v, ok := value.(uint64)
  8670. if !ok {
  8671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8672. }
  8673. m.SetOrganizationID(v)
  8674. return nil
  8675. }
  8676. return fmt.Errorf("unknown LabelRelationship field %s", name)
  8677. }
  8678. // AddedFields returns all numeric fields that were incremented/decremented during
  8679. // this mutation.
  8680. func (m *LabelRelationshipMutation) AddedFields() []string {
  8681. var fields []string
  8682. if m.addstatus != nil {
  8683. fields = append(fields, labelrelationship.FieldStatus)
  8684. }
  8685. if m.addorganization_id != nil {
  8686. fields = append(fields, labelrelationship.FieldOrganizationID)
  8687. }
  8688. return fields
  8689. }
  8690. // AddedField returns the numeric value that was incremented/decremented on a field
  8691. // with the given name. The second boolean return value indicates that this field
  8692. // was not set, or was not defined in the schema.
  8693. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  8694. switch name {
  8695. case labelrelationship.FieldStatus:
  8696. return m.AddedStatus()
  8697. case labelrelationship.FieldOrganizationID:
  8698. return m.AddedOrganizationID()
  8699. }
  8700. return nil, false
  8701. }
  8702. // AddField adds the value to the field with the given name. It returns an error if
  8703. // the field is not defined in the schema, or if the type mismatched the field
  8704. // type.
  8705. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  8706. switch name {
  8707. case labelrelationship.FieldStatus:
  8708. v, ok := value.(int8)
  8709. if !ok {
  8710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8711. }
  8712. m.AddStatus(v)
  8713. return nil
  8714. case labelrelationship.FieldOrganizationID:
  8715. v, ok := value.(int64)
  8716. if !ok {
  8717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8718. }
  8719. m.AddOrganizationID(v)
  8720. return nil
  8721. }
  8722. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  8723. }
  8724. // ClearedFields returns all nullable fields that were cleared during this
  8725. // mutation.
  8726. func (m *LabelRelationshipMutation) ClearedFields() []string {
  8727. var fields []string
  8728. if m.FieldCleared(labelrelationship.FieldStatus) {
  8729. fields = append(fields, labelrelationship.FieldStatus)
  8730. }
  8731. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  8732. fields = append(fields, labelrelationship.FieldDeletedAt)
  8733. }
  8734. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  8735. fields = append(fields, labelrelationship.FieldOrganizationID)
  8736. }
  8737. return fields
  8738. }
  8739. // FieldCleared returns a boolean indicating if a field with the given name was
  8740. // cleared in this mutation.
  8741. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  8742. _, ok := m.clearedFields[name]
  8743. return ok
  8744. }
  8745. // ClearField clears the value of the field with the given name. It returns an
  8746. // error if the field is not defined in the schema.
  8747. func (m *LabelRelationshipMutation) ClearField(name string) error {
  8748. switch name {
  8749. case labelrelationship.FieldStatus:
  8750. m.ClearStatus()
  8751. return nil
  8752. case labelrelationship.FieldDeletedAt:
  8753. m.ClearDeletedAt()
  8754. return nil
  8755. case labelrelationship.FieldOrganizationID:
  8756. m.ClearOrganizationID()
  8757. return nil
  8758. }
  8759. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  8760. }
  8761. // ResetField resets all changes in the mutation for the field with the given name.
  8762. // It returns an error if the field is not defined in the schema.
  8763. func (m *LabelRelationshipMutation) ResetField(name string) error {
  8764. switch name {
  8765. case labelrelationship.FieldCreatedAt:
  8766. m.ResetCreatedAt()
  8767. return nil
  8768. case labelrelationship.FieldUpdatedAt:
  8769. m.ResetUpdatedAt()
  8770. return nil
  8771. case labelrelationship.FieldStatus:
  8772. m.ResetStatus()
  8773. return nil
  8774. case labelrelationship.FieldDeletedAt:
  8775. m.ResetDeletedAt()
  8776. return nil
  8777. case labelrelationship.FieldLabelID:
  8778. m.ResetLabelID()
  8779. return nil
  8780. case labelrelationship.FieldContactID:
  8781. m.ResetContactID()
  8782. return nil
  8783. case labelrelationship.FieldOrganizationID:
  8784. m.ResetOrganizationID()
  8785. return nil
  8786. }
  8787. return fmt.Errorf("unknown LabelRelationship field %s", name)
  8788. }
  8789. // AddedEdges returns all edge names that were set/added in this mutation.
  8790. func (m *LabelRelationshipMutation) AddedEdges() []string {
  8791. edges := make([]string, 0, 2)
  8792. if m.contacts != nil {
  8793. edges = append(edges, labelrelationship.EdgeContacts)
  8794. }
  8795. if m.labels != nil {
  8796. edges = append(edges, labelrelationship.EdgeLabels)
  8797. }
  8798. return edges
  8799. }
  8800. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8801. // name in this mutation.
  8802. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  8803. switch name {
  8804. case labelrelationship.EdgeContacts:
  8805. if id := m.contacts; id != nil {
  8806. return []ent.Value{*id}
  8807. }
  8808. case labelrelationship.EdgeLabels:
  8809. if id := m.labels; id != nil {
  8810. return []ent.Value{*id}
  8811. }
  8812. }
  8813. return nil
  8814. }
  8815. // RemovedEdges returns all edge names that were removed in this mutation.
  8816. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  8817. edges := make([]string, 0, 2)
  8818. return edges
  8819. }
  8820. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8821. // the given name in this mutation.
  8822. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  8823. return nil
  8824. }
  8825. // ClearedEdges returns all edge names that were cleared in this mutation.
  8826. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  8827. edges := make([]string, 0, 2)
  8828. if m.clearedcontacts {
  8829. edges = append(edges, labelrelationship.EdgeContacts)
  8830. }
  8831. if m.clearedlabels {
  8832. edges = append(edges, labelrelationship.EdgeLabels)
  8833. }
  8834. return edges
  8835. }
  8836. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8837. // was cleared in this mutation.
  8838. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  8839. switch name {
  8840. case labelrelationship.EdgeContacts:
  8841. return m.clearedcontacts
  8842. case labelrelationship.EdgeLabels:
  8843. return m.clearedlabels
  8844. }
  8845. return false
  8846. }
  8847. // ClearEdge clears the value of the edge with the given name. It returns an error
  8848. // if that edge is not defined in the schema.
  8849. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  8850. switch name {
  8851. case labelrelationship.EdgeContacts:
  8852. m.ClearContacts()
  8853. return nil
  8854. case labelrelationship.EdgeLabels:
  8855. m.ClearLabels()
  8856. return nil
  8857. }
  8858. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  8859. }
  8860. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8861. // It returns an error if the edge is not defined in the schema.
  8862. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  8863. switch name {
  8864. case labelrelationship.EdgeContacts:
  8865. m.ResetContacts()
  8866. return nil
  8867. case labelrelationship.EdgeLabels:
  8868. m.ResetLabels()
  8869. return nil
  8870. }
  8871. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  8872. }
  8873. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  8874. type MessageMutation struct {
  8875. config
  8876. op Op
  8877. typ string
  8878. id *int
  8879. wx_wxid *string
  8880. wxid *string
  8881. content *string
  8882. clearedFields map[string]struct{}
  8883. done bool
  8884. oldValue func(context.Context) (*Message, error)
  8885. predicates []predicate.Message
  8886. }
  8887. var _ ent.Mutation = (*MessageMutation)(nil)
  8888. // messageOption allows management of the mutation configuration using functional options.
  8889. type messageOption func(*MessageMutation)
  8890. // newMessageMutation creates new mutation for the Message entity.
  8891. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  8892. m := &MessageMutation{
  8893. config: c,
  8894. op: op,
  8895. typ: TypeMessage,
  8896. clearedFields: make(map[string]struct{}),
  8897. }
  8898. for _, opt := range opts {
  8899. opt(m)
  8900. }
  8901. return m
  8902. }
  8903. // withMessageID sets the ID field of the mutation.
  8904. func withMessageID(id int) messageOption {
  8905. return func(m *MessageMutation) {
  8906. var (
  8907. err error
  8908. once sync.Once
  8909. value *Message
  8910. )
  8911. m.oldValue = func(ctx context.Context) (*Message, error) {
  8912. once.Do(func() {
  8913. if m.done {
  8914. err = errors.New("querying old values post mutation is not allowed")
  8915. } else {
  8916. value, err = m.Client().Message.Get(ctx, id)
  8917. }
  8918. })
  8919. return value, err
  8920. }
  8921. m.id = &id
  8922. }
  8923. }
  8924. // withMessage sets the old Message of the mutation.
  8925. func withMessage(node *Message) messageOption {
  8926. return func(m *MessageMutation) {
  8927. m.oldValue = func(context.Context) (*Message, error) {
  8928. return node, nil
  8929. }
  8930. m.id = &node.ID
  8931. }
  8932. }
  8933. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8934. // executed in a transaction (ent.Tx), a transactional client is returned.
  8935. func (m MessageMutation) Client() *Client {
  8936. client := &Client{config: m.config}
  8937. client.init()
  8938. return client
  8939. }
  8940. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8941. // it returns an error otherwise.
  8942. func (m MessageMutation) Tx() (*Tx, error) {
  8943. if _, ok := m.driver.(*txDriver); !ok {
  8944. return nil, errors.New("ent: mutation is not running in a transaction")
  8945. }
  8946. tx := &Tx{config: m.config}
  8947. tx.init()
  8948. return tx, nil
  8949. }
  8950. // ID returns the ID value in the mutation. Note that the ID is only available
  8951. // if it was provided to the builder or after it was returned from the database.
  8952. func (m *MessageMutation) ID() (id int, exists bool) {
  8953. if m.id == nil {
  8954. return
  8955. }
  8956. return *m.id, true
  8957. }
  8958. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8959. // That means, if the mutation is applied within a transaction with an isolation level such
  8960. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8961. // or updated by the mutation.
  8962. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  8963. switch {
  8964. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8965. id, exists := m.ID()
  8966. if exists {
  8967. return []int{id}, nil
  8968. }
  8969. fallthrough
  8970. case m.op.Is(OpUpdate | OpDelete):
  8971. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  8972. default:
  8973. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8974. }
  8975. }
  8976. // SetWxWxid sets the "wx_wxid" field.
  8977. func (m *MessageMutation) SetWxWxid(s string) {
  8978. m.wx_wxid = &s
  8979. }
  8980. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  8981. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  8982. v := m.wx_wxid
  8983. if v == nil {
  8984. return
  8985. }
  8986. return *v, true
  8987. }
  8988. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  8989. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  8990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8991. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  8992. if !m.op.Is(OpUpdateOne) {
  8993. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  8994. }
  8995. if m.id == nil || m.oldValue == nil {
  8996. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  8997. }
  8998. oldValue, err := m.oldValue(ctx)
  8999. if err != nil {
  9000. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  9001. }
  9002. return oldValue.WxWxid, nil
  9003. }
  9004. // ClearWxWxid clears the value of the "wx_wxid" field.
  9005. func (m *MessageMutation) ClearWxWxid() {
  9006. m.wx_wxid = nil
  9007. m.clearedFields[message.FieldWxWxid] = struct{}{}
  9008. }
  9009. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  9010. func (m *MessageMutation) WxWxidCleared() bool {
  9011. _, ok := m.clearedFields[message.FieldWxWxid]
  9012. return ok
  9013. }
  9014. // ResetWxWxid resets all changes to the "wx_wxid" field.
  9015. func (m *MessageMutation) ResetWxWxid() {
  9016. m.wx_wxid = nil
  9017. delete(m.clearedFields, message.FieldWxWxid)
  9018. }
  9019. // SetWxid sets the "wxid" field.
  9020. func (m *MessageMutation) SetWxid(s string) {
  9021. m.wxid = &s
  9022. }
  9023. // Wxid returns the value of the "wxid" field in the mutation.
  9024. func (m *MessageMutation) Wxid() (r string, exists bool) {
  9025. v := m.wxid
  9026. if v == nil {
  9027. return
  9028. }
  9029. return *v, true
  9030. }
  9031. // OldWxid returns the old "wxid" field's value of the Message entity.
  9032. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  9033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9034. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  9035. if !m.op.Is(OpUpdateOne) {
  9036. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  9037. }
  9038. if m.id == nil || m.oldValue == nil {
  9039. return v, errors.New("OldWxid requires an ID field in the mutation")
  9040. }
  9041. oldValue, err := m.oldValue(ctx)
  9042. if err != nil {
  9043. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  9044. }
  9045. return oldValue.Wxid, nil
  9046. }
  9047. // ResetWxid resets all changes to the "wxid" field.
  9048. func (m *MessageMutation) ResetWxid() {
  9049. m.wxid = nil
  9050. }
  9051. // SetContent sets the "content" field.
  9052. func (m *MessageMutation) SetContent(s string) {
  9053. m.content = &s
  9054. }
  9055. // Content returns the value of the "content" field in the mutation.
  9056. func (m *MessageMutation) Content() (r string, exists bool) {
  9057. v := m.content
  9058. if v == nil {
  9059. return
  9060. }
  9061. return *v, true
  9062. }
  9063. // OldContent returns the old "content" field's value of the Message entity.
  9064. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  9065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9066. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  9067. if !m.op.Is(OpUpdateOne) {
  9068. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  9069. }
  9070. if m.id == nil || m.oldValue == nil {
  9071. return v, errors.New("OldContent requires an ID field in the mutation")
  9072. }
  9073. oldValue, err := m.oldValue(ctx)
  9074. if err != nil {
  9075. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  9076. }
  9077. return oldValue.Content, nil
  9078. }
  9079. // ResetContent resets all changes to the "content" field.
  9080. func (m *MessageMutation) ResetContent() {
  9081. m.content = nil
  9082. }
  9083. // Where appends a list predicates to the MessageMutation builder.
  9084. func (m *MessageMutation) Where(ps ...predicate.Message) {
  9085. m.predicates = append(m.predicates, ps...)
  9086. }
  9087. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  9088. // users can use type-assertion to append predicates that do not depend on any generated package.
  9089. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  9090. p := make([]predicate.Message, len(ps))
  9091. for i := range ps {
  9092. p[i] = ps[i]
  9093. }
  9094. m.Where(p...)
  9095. }
  9096. // Op returns the operation name.
  9097. func (m *MessageMutation) Op() Op {
  9098. return m.op
  9099. }
  9100. // SetOp allows setting the mutation operation.
  9101. func (m *MessageMutation) SetOp(op Op) {
  9102. m.op = op
  9103. }
  9104. // Type returns the node type of this mutation (Message).
  9105. func (m *MessageMutation) Type() string {
  9106. return m.typ
  9107. }
  9108. // Fields returns all fields that were changed during this mutation. Note that in
  9109. // order to get all numeric fields that were incremented/decremented, call
  9110. // AddedFields().
  9111. func (m *MessageMutation) Fields() []string {
  9112. fields := make([]string, 0, 3)
  9113. if m.wx_wxid != nil {
  9114. fields = append(fields, message.FieldWxWxid)
  9115. }
  9116. if m.wxid != nil {
  9117. fields = append(fields, message.FieldWxid)
  9118. }
  9119. if m.content != nil {
  9120. fields = append(fields, message.FieldContent)
  9121. }
  9122. return fields
  9123. }
  9124. // Field returns the value of a field with the given name. The second boolean
  9125. // return value indicates that this field was not set, or was not defined in the
  9126. // schema.
  9127. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  9128. switch name {
  9129. case message.FieldWxWxid:
  9130. return m.WxWxid()
  9131. case message.FieldWxid:
  9132. return m.Wxid()
  9133. case message.FieldContent:
  9134. return m.Content()
  9135. }
  9136. return nil, false
  9137. }
  9138. // OldField returns the old value of the field from the database. An error is
  9139. // returned if the mutation operation is not UpdateOne, or the query to the
  9140. // database failed.
  9141. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9142. switch name {
  9143. case message.FieldWxWxid:
  9144. return m.OldWxWxid(ctx)
  9145. case message.FieldWxid:
  9146. return m.OldWxid(ctx)
  9147. case message.FieldContent:
  9148. return m.OldContent(ctx)
  9149. }
  9150. return nil, fmt.Errorf("unknown Message field %s", name)
  9151. }
  9152. // SetField sets the value of a field with the given name. It returns an error if
  9153. // the field is not defined in the schema, or if the type mismatched the field
  9154. // type.
  9155. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  9156. switch name {
  9157. case message.FieldWxWxid:
  9158. v, ok := value.(string)
  9159. if !ok {
  9160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9161. }
  9162. m.SetWxWxid(v)
  9163. return nil
  9164. case message.FieldWxid:
  9165. v, ok := value.(string)
  9166. if !ok {
  9167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9168. }
  9169. m.SetWxid(v)
  9170. return nil
  9171. case message.FieldContent:
  9172. v, ok := value.(string)
  9173. if !ok {
  9174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9175. }
  9176. m.SetContent(v)
  9177. return nil
  9178. }
  9179. return fmt.Errorf("unknown Message field %s", name)
  9180. }
  9181. // AddedFields returns all numeric fields that were incremented/decremented during
  9182. // this mutation.
  9183. func (m *MessageMutation) AddedFields() []string {
  9184. return nil
  9185. }
  9186. // AddedField returns the numeric value that was incremented/decremented on a field
  9187. // with the given name. The second boolean return value indicates that this field
  9188. // was not set, or was not defined in the schema.
  9189. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  9190. return nil, false
  9191. }
  9192. // AddField adds the value to the field with the given name. It returns an error if
  9193. // the field is not defined in the schema, or if the type mismatched the field
  9194. // type.
  9195. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  9196. switch name {
  9197. }
  9198. return fmt.Errorf("unknown Message numeric field %s", name)
  9199. }
  9200. // ClearedFields returns all nullable fields that were cleared during this
  9201. // mutation.
  9202. func (m *MessageMutation) ClearedFields() []string {
  9203. var fields []string
  9204. if m.FieldCleared(message.FieldWxWxid) {
  9205. fields = append(fields, message.FieldWxWxid)
  9206. }
  9207. return fields
  9208. }
  9209. // FieldCleared returns a boolean indicating if a field with the given name was
  9210. // cleared in this mutation.
  9211. func (m *MessageMutation) FieldCleared(name string) bool {
  9212. _, ok := m.clearedFields[name]
  9213. return ok
  9214. }
  9215. // ClearField clears the value of the field with the given name. It returns an
  9216. // error if the field is not defined in the schema.
  9217. func (m *MessageMutation) ClearField(name string) error {
  9218. switch name {
  9219. case message.FieldWxWxid:
  9220. m.ClearWxWxid()
  9221. return nil
  9222. }
  9223. return fmt.Errorf("unknown Message nullable field %s", name)
  9224. }
  9225. // ResetField resets all changes in the mutation for the field with the given name.
  9226. // It returns an error if the field is not defined in the schema.
  9227. func (m *MessageMutation) ResetField(name string) error {
  9228. switch name {
  9229. case message.FieldWxWxid:
  9230. m.ResetWxWxid()
  9231. return nil
  9232. case message.FieldWxid:
  9233. m.ResetWxid()
  9234. return nil
  9235. case message.FieldContent:
  9236. m.ResetContent()
  9237. return nil
  9238. }
  9239. return fmt.Errorf("unknown Message field %s", name)
  9240. }
  9241. // AddedEdges returns all edge names that were set/added in this mutation.
  9242. func (m *MessageMutation) AddedEdges() []string {
  9243. edges := make([]string, 0, 0)
  9244. return edges
  9245. }
  9246. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9247. // name in this mutation.
  9248. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  9249. return nil
  9250. }
  9251. // RemovedEdges returns all edge names that were removed in this mutation.
  9252. func (m *MessageMutation) RemovedEdges() []string {
  9253. edges := make([]string, 0, 0)
  9254. return edges
  9255. }
  9256. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9257. // the given name in this mutation.
  9258. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  9259. return nil
  9260. }
  9261. // ClearedEdges returns all edge names that were cleared in this mutation.
  9262. func (m *MessageMutation) ClearedEdges() []string {
  9263. edges := make([]string, 0, 0)
  9264. return edges
  9265. }
  9266. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9267. // was cleared in this mutation.
  9268. func (m *MessageMutation) EdgeCleared(name string) bool {
  9269. return false
  9270. }
  9271. // ClearEdge clears the value of the edge with the given name. It returns an error
  9272. // if that edge is not defined in the schema.
  9273. func (m *MessageMutation) ClearEdge(name string) error {
  9274. return fmt.Errorf("unknown Message unique edge %s", name)
  9275. }
  9276. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9277. // It returns an error if the edge is not defined in the schema.
  9278. func (m *MessageMutation) ResetEdge(name string) error {
  9279. return fmt.Errorf("unknown Message edge %s", name)
  9280. }
  9281. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  9282. type MessageRecordsMutation struct {
  9283. config
  9284. op Op
  9285. typ string
  9286. id *uint64
  9287. created_at *time.Time
  9288. updated_at *time.Time
  9289. status *uint8
  9290. addstatus *int8
  9291. bot_wxid *string
  9292. contact_type *int
  9293. addcontact_type *int
  9294. contact_wxid *string
  9295. content_type *int
  9296. addcontent_type *int
  9297. content *string
  9298. meta *custom_types.Meta
  9299. error_detail *string
  9300. send_time *time.Time
  9301. source_type *int
  9302. addsource_type *int
  9303. organization_id *uint64
  9304. addorganization_id *int64
  9305. clearedFields map[string]struct{}
  9306. sop_stage *uint64
  9307. clearedsop_stage bool
  9308. sop_node *uint64
  9309. clearedsop_node bool
  9310. message_contact *uint64
  9311. clearedmessage_contact bool
  9312. done bool
  9313. oldValue func(context.Context) (*MessageRecords, error)
  9314. predicates []predicate.MessageRecords
  9315. }
  9316. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  9317. // messagerecordsOption allows management of the mutation configuration using functional options.
  9318. type messagerecordsOption func(*MessageRecordsMutation)
  9319. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  9320. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  9321. m := &MessageRecordsMutation{
  9322. config: c,
  9323. op: op,
  9324. typ: TypeMessageRecords,
  9325. clearedFields: make(map[string]struct{}),
  9326. }
  9327. for _, opt := range opts {
  9328. opt(m)
  9329. }
  9330. return m
  9331. }
  9332. // withMessageRecordsID sets the ID field of the mutation.
  9333. func withMessageRecordsID(id uint64) messagerecordsOption {
  9334. return func(m *MessageRecordsMutation) {
  9335. var (
  9336. err error
  9337. once sync.Once
  9338. value *MessageRecords
  9339. )
  9340. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  9341. once.Do(func() {
  9342. if m.done {
  9343. err = errors.New("querying old values post mutation is not allowed")
  9344. } else {
  9345. value, err = m.Client().MessageRecords.Get(ctx, id)
  9346. }
  9347. })
  9348. return value, err
  9349. }
  9350. m.id = &id
  9351. }
  9352. }
  9353. // withMessageRecords sets the old MessageRecords of the mutation.
  9354. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  9355. return func(m *MessageRecordsMutation) {
  9356. m.oldValue = func(context.Context) (*MessageRecords, error) {
  9357. return node, nil
  9358. }
  9359. m.id = &node.ID
  9360. }
  9361. }
  9362. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9363. // executed in a transaction (ent.Tx), a transactional client is returned.
  9364. func (m MessageRecordsMutation) Client() *Client {
  9365. client := &Client{config: m.config}
  9366. client.init()
  9367. return client
  9368. }
  9369. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9370. // it returns an error otherwise.
  9371. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  9372. if _, ok := m.driver.(*txDriver); !ok {
  9373. return nil, errors.New("ent: mutation is not running in a transaction")
  9374. }
  9375. tx := &Tx{config: m.config}
  9376. tx.init()
  9377. return tx, nil
  9378. }
  9379. // SetID sets the value of the id field. Note that this
  9380. // operation is only accepted on creation of MessageRecords entities.
  9381. func (m *MessageRecordsMutation) SetID(id uint64) {
  9382. m.id = &id
  9383. }
  9384. // ID returns the ID value in the mutation. Note that the ID is only available
  9385. // if it was provided to the builder or after it was returned from the database.
  9386. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  9387. if m.id == nil {
  9388. return
  9389. }
  9390. return *m.id, true
  9391. }
  9392. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9393. // That means, if the mutation is applied within a transaction with an isolation level such
  9394. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9395. // or updated by the mutation.
  9396. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  9397. switch {
  9398. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9399. id, exists := m.ID()
  9400. if exists {
  9401. return []uint64{id}, nil
  9402. }
  9403. fallthrough
  9404. case m.op.Is(OpUpdate | OpDelete):
  9405. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  9406. default:
  9407. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9408. }
  9409. }
  9410. // SetCreatedAt sets the "created_at" field.
  9411. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  9412. m.created_at = &t
  9413. }
  9414. // CreatedAt returns the value of the "created_at" field in the mutation.
  9415. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  9416. v := m.created_at
  9417. if v == nil {
  9418. return
  9419. }
  9420. return *v, true
  9421. }
  9422. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  9423. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9425. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9426. if !m.op.Is(OpUpdateOne) {
  9427. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9428. }
  9429. if m.id == nil || m.oldValue == nil {
  9430. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9431. }
  9432. oldValue, err := m.oldValue(ctx)
  9433. if err != nil {
  9434. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9435. }
  9436. return oldValue.CreatedAt, nil
  9437. }
  9438. // ResetCreatedAt resets all changes to the "created_at" field.
  9439. func (m *MessageRecordsMutation) ResetCreatedAt() {
  9440. m.created_at = nil
  9441. }
  9442. // SetUpdatedAt sets the "updated_at" field.
  9443. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  9444. m.updated_at = &t
  9445. }
  9446. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9447. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  9448. v := m.updated_at
  9449. if v == nil {
  9450. return
  9451. }
  9452. return *v, true
  9453. }
  9454. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  9455. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9457. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9458. if !m.op.Is(OpUpdateOne) {
  9459. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9460. }
  9461. if m.id == nil || m.oldValue == nil {
  9462. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9463. }
  9464. oldValue, err := m.oldValue(ctx)
  9465. if err != nil {
  9466. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9467. }
  9468. return oldValue.UpdatedAt, nil
  9469. }
  9470. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9471. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  9472. m.updated_at = nil
  9473. }
  9474. // SetStatus sets the "status" field.
  9475. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  9476. m.status = &u
  9477. m.addstatus = nil
  9478. }
  9479. // Status returns the value of the "status" field in the mutation.
  9480. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  9481. v := m.status
  9482. if v == nil {
  9483. return
  9484. }
  9485. return *v, true
  9486. }
  9487. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  9488. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9490. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9491. if !m.op.Is(OpUpdateOne) {
  9492. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9493. }
  9494. if m.id == nil || m.oldValue == nil {
  9495. return v, errors.New("OldStatus requires an ID field in the mutation")
  9496. }
  9497. oldValue, err := m.oldValue(ctx)
  9498. if err != nil {
  9499. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9500. }
  9501. return oldValue.Status, nil
  9502. }
  9503. // AddStatus adds u to the "status" field.
  9504. func (m *MessageRecordsMutation) AddStatus(u int8) {
  9505. if m.addstatus != nil {
  9506. *m.addstatus += u
  9507. } else {
  9508. m.addstatus = &u
  9509. }
  9510. }
  9511. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9512. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  9513. v := m.addstatus
  9514. if v == nil {
  9515. return
  9516. }
  9517. return *v, true
  9518. }
  9519. // ClearStatus clears the value of the "status" field.
  9520. func (m *MessageRecordsMutation) ClearStatus() {
  9521. m.status = nil
  9522. m.addstatus = nil
  9523. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  9524. }
  9525. // StatusCleared returns if the "status" field was cleared in this mutation.
  9526. func (m *MessageRecordsMutation) StatusCleared() bool {
  9527. _, ok := m.clearedFields[messagerecords.FieldStatus]
  9528. return ok
  9529. }
  9530. // ResetStatus resets all changes to the "status" field.
  9531. func (m *MessageRecordsMutation) ResetStatus() {
  9532. m.status = nil
  9533. m.addstatus = nil
  9534. delete(m.clearedFields, messagerecords.FieldStatus)
  9535. }
  9536. // SetBotWxid sets the "bot_wxid" field.
  9537. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  9538. m.bot_wxid = &s
  9539. }
  9540. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  9541. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  9542. v := m.bot_wxid
  9543. if v == nil {
  9544. return
  9545. }
  9546. return *v, true
  9547. }
  9548. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  9549. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9551. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  9552. if !m.op.Is(OpUpdateOne) {
  9553. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  9554. }
  9555. if m.id == nil || m.oldValue == nil {
  9556. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  9557. }
  9558. oldValue, err := m.oldValue(ctx)
  9559. if err != nil {
  9560. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  9561. }
  9562. return oldValue.BotWxid, nil
  9563. }
  9564. // ResetBotWxid resets all changes to the "bot_wxid" field.
  9565. func (m *MessageRecordsMutation) ResetBotWxid() {
  9566. m.bot_wxid = nil
  9567. }
  9568. // SetContactID sets the "contact_id" field.
  9569. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  9570. m.message_contact = &u
  9571. }
  9572. // ContactID returns the value of the "contact_id" field in the mutation.
  9573. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  9574. v := m.message_contact
  9575. if v == nil {
  9576. return
  9577. }
  9578. return *v, true
  9579. }
  9580. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  9581. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9583. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  9584. if !m.op.Is(OpUpdateOne) {
  9585. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  9586. }
  9587. if m.id == nil || m.oldValue == nil {
  9588. return v, errors.New("OldContactID requires an ID field in the mutation")
  9589. }
  9590. oldValue, err := m.oldValue(ctx)
  9591. if err != nil {
  9592. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  9593. }
  9594. return oldValue.ContactID, nil
  9595. }
  9596. // ClearContactID clears the value of the "contact_id" field.
  9597. func (m *MessageRecordsMutation) ClearContactID() {
  9598. m.message_contact = nil
  9599. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  9600. }
  9601. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  9602. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  9603. _, ok := m.clearedFields[messagerecords.FieldContactID]
  9604. return ok
  9605. }
  9606. // ResetContactID resets all changes to the "contact_id" field.
  9607. func (m *MessageRecordsMutation) ResetContactID() {
  9608. m.message_contact = nil
  9609. delete(m.clearedFields, messagerecords.FieldContactID)
  9610. }
  9611. // SetContactType sets the "contact_type" field.
  9612. func (m *MessageRecordsMutation) SetContactType(i int) {
  9613. m.contact_type = &i
  9614. m.addcontact_type = nil
  9615. }
  9616. // ContactType returns the value of the "contact_type" field in the mutation.
  9617. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  9618. v := m.contact_type
  9619. if v == nil {
  9620. return
  9621. }
  9622. return *v, true
  9623. }
  9624. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  9625. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9627. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  9628. if !m.op.Is(OpUpdateOne) {
  9629. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  9630. }
  9631. if m.id == nil || m.oldValue == nil {
  9632. return v, errors.New("OldContactType requires an ID field in the mutation")
  9633. }
  9634. oldValue, err := m.oldValue(ctx)
  9635. if err != nil {
  9636. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  9637. }
  9638. return oldValue.ContactType, nil
  9639. }
  9640. // AddContactType adds i to the "contact_type" field.
  9641. func (m *MessageRecordsMutation) AddContactType(i int) {
  9642. if m.addcontact_type != nil {
  9643. *m.addcontact_type += i
  9644. } else {
  9645. m.addcontact_type = &i
  9646. }
  9647. }
  9648. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  9649. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  9650. v := m.addcontact_type
  9651. if v == nil {
  9652. return
  9653. }
  9654. return *v, true
  9655. }
  9656. // ResetContactType resets all changes to the "contact_type" field.
  9657. func (m *MessageRecordsMutation) ResetContactType() {
  9658. m.contact_type = nil
  9659. m.addcontact_type = nil
  9660. }
  9661. // SetContactWxid sets the "contact_wxid" field.
  9662. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  9663. m.contact_wxid = &s
  9664. }
  9665. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  9666. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  9667. v := m.contact_wxid
  9668. if v == nil {
  9669. return
  9670. }
  9671. return *v, true
  9672. }
  9673. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  9674. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9676. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  9677. if !m.op.Is(OpUpdateOne) {
  9678. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  9679. }
  9680. if m.id == nil || m.oldValue == nil {
  9681. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  9682. }
  9683. oldValue, err := m.oldValue(ctx)
  9684. if err != nil {
  9685. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  9686. }
  9687. return oldValue.ContactWxid, nil
  9688. }
  9689. // ResetContactWxid resets all changes to the "contact_wxid" field.
  9690. func (m *MessageRecordsMutation) ResetContactWxid() {
  9691. m.contact_wxid = nil
  9692. }
  9693. // SetContentType sets the "content_type" field.
  9694. func (m *MessageRecordsMutation) SetContentType(i int) {
  9695. m.content_type = &i
  9696. m.addcontent_type = nil
  9697. }
  9698. // ContentType returns the value of the "content_type" field in the mutation.
  9699. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  9700. v := m.content_type
  9701. if v == nil {
  9702. return
  9703. }
  9704. return *v, true
  9705. }
  9706. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  9707. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9709. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  9710. if !m.op.Is(OpUpdateOne) {
  9711. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  9712. }
  9713. if m.id == nil || m.oldValue == nil {
  9714. return v, errors.New("OldContentType requires an ID field in the mutation")
  9715. }
  9716. oldValue, err := m.oldValue(ctx)
  9717. if err != nil {
  9718. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  9719. }
  9720. return oldValue.ContentType, nil
  9721. }
  9722. // AddContentType adds i to the "content_type" field.
  9723. func (m *MessageRecordsMutation) AddContentType(i int) {
  9724. if m.addcontent_type != nil {
  9725. *m.addcontent_type += i
  9726. } else {
  9727. m.addcontent_type = &i
  9728. }
  9729. }
  9730. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  9731. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  9732. v := m.addcontent_type
  9733. if v == nil {
  9734. return
  9735. }
  9736. return *v, true
  9737. }
  9738. // ResetContentType resets all changes to the "content_type" field.
  9739. func (m *MessageRecordsMutation) ResetContentType() {
  9740. m.content_type = nil
  9741. m.addcontent_type = nil
  9742. }
  9743. // SetContent sets the "content" field.
  9744. func (m *MessageRecordsMutation) SetContent(s string) {
  9745. m.content = &s
  9746. }
  9747. // Content returns the value of the "content" field in the mutation.
  9748. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  9749. v := m.content
  9750. if v == nil {
  9751. return
  9752. }
  9753. return *v, true
  9754. }
  9755. // OldContent returns the old "content" field's value of the MessageRecords entity.
  9756. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9758. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  9759. if !m.op.Is(OpUpdateOne) {
  9760. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  9761. }
  9762. if m.id == nil || m.oldValue == nil {
  9763. return v, errors.New("OldContent requires an ID field in the mutation")
  9764. }
  9765. oldValue, err := m.oldValue(ctx)
  9766. if err != nil {
  9767. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  9768. }
  9769. return oldValue.Content, nil
  9770. }
  9771. // ResetContent resets all changes to the "content" field.
  9772. func (m *MessageRecordsMutation) ResetContent() {
  9773. m.content = nil
  9774. }
  9775. // SetMeta sets the "meta" field.
  9776. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  9777. m.meta = &ct
  9778. }
  9779. // Meta returns the value of the "meta" field in the mutation.
  9780. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  9781. v := m.meta
  9782. if v == nil {
  9783. return
  9784. }
  9785. return *v, true
  9786. }
  9787. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  9788. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9789. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9790. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  9791. if !m.op.Is(OpUpdateOne) {
  9792. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  9793. }
  9794. if m.id == nil || m.oldValue == nil {
  9795. return v, errors.New("OldMeta requires an ID field in the mutation")
  9796. }
  9797. oldValue, err := m.oldValue(ctx)
  9798. if err != nil {
  9799. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  9800. }
  9801. return oldValue.Meta, nil
  9802. }
  9803. // ClearMeta clears the value of the "meta" field.
  9804. func (m *MessageRecordsMutation) ClearMeta() {
  9805. m.meta = nil
  9806. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  9807. }
  9808. // MetaCleared returns if the "meta" field was cleared in this mutation.
  9809. func (m *MessageRecordsMutation) MetaCleared() bool {
  9810. _, ok := m.clearedFields[messagerecords.FieldMeta]
  9811. return ok
  9812. }
  9813. // ResetMeta resets all changes to the "meta" field.
  9814. func (m *MessageRecordsMutation) ResetMeta() {
  9815. m.meta = nil
  9816. delete(m.clearedFields, messagerecords.FieldMeta)
  9817. }
  9818. // SetErrorDetail sets the "error_detail" field.
  9819. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  9820. m.error_detail = &s
  9821. }
  9822. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  9823. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  9824. v := m.error_detail
  9825. if v == nil {
  9826. return
  9827. }
  9828. return *v, true
  9829. }
  9830. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  9831. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9833. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  9834. if !m.op.Is(OpUpdateOne) {
  9835. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  9836. }
  9837. if m.id == nil || m.oldValue == nil {
  9838. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  9839. }
  9840. oldValue, err := m.oldValue(ctx)
  9841. if err != nil {
  9842. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  9843. }
  9844. return oldValue.ErrorDetail, nil
  9845. }
  9846. // ResetErrorDetail resets all changes to the "error_detail" field.
  9847. func (m *MessageRecordsMutation) ResetErrorDetail() {
  9848. m.error_detail = nil
  9849. }
  9850. // SetSendTime sets the "send_time" field.
  9851. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  9852. m.send_time = &t
  9853. }
  9854. // SendTime returns the value of the "send_time" field in the mutation.
  9855. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  9856. v := m.send_time
  9857. if v == nil {
  9858. return
  9859. }
  9860. return *v, true
  9861. }
  9862. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  9863. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9865. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  9866. if !m.op.Is(OpUpdateOne) {
  9867. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  9868. }
  9869. if m.id == nil || m.oldValue == nil {
  9870. return v, errors.New("OldSendTime requires an ID field in the mutation")
  9871. }
  9872. oldValue, err := m.oldValue(ctx)
  9873. if err != nil {
  9874. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  9875. }
  9876. return oldValue.SendTime, nil
  9877. }
  9878. // ClearSendTime clears the value of the "send_time" field.
  9879. func (m *MessageRecordsMutation) ClearSendTime() {
  9880. m.send_time = nil
  9881. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  9882. }
  9883. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  9884. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  9885. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  9886. return ok
  9887. }
  9888. // ResetSendTime resets all changes to the "send_time" field.
  9889. func (m *MessageRecordsMutation) ResetSendTime() {
  9890. m.send_time = nil
  9891. delete(m.clearedFields, messagerecords.FieldSendTime)
  9892. }
  9893. // SetSourceType sets the "source_type" field.
  9894. func (m *MessageRecordsMutation) SetSourceType(i int) {
  9895. m.source_type = &i
  9896. m.addsource_type = nil
  9897. }
  9898. // SourceType returns the value of the "source_type" field in the mutation.
  9899. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  9900. v := m.source_type
  9901. if v == nil {
  9902. return
  9903. }
  9904. return *v, true
  9905. }
  9906. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  9907. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9909. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  9910. if !m.op.Is(OpUpdateOne) {
  9911. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  9912. }
  9913. if m.id == nil || m.oldValue == nil {
  9914. return v, errors.New("OldSourceType requires an ID field in the mutation")
  9915. }
  9916. oldValue, err := m.oldValue(ctx)
  9917. if err != nil {
  9918. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  9919. }
  9920. return oldValue.SourceType, nil
  9921. }
  9922. // AddSourceType adds i to the "source_type" field.
  9923. func (m *MessageRecordsMutation) AddSourceType(i int) {
  9924. if m.addsource_type != nil {
  9925. *m.addsource_type += i
  9926. } else {
  9927. m.addsource_type = &i
  9928. }
  9929. }
  9930. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  9931. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  9932. v := m.addsource_type
  9933. if v == nil {
  9934. return
  9935. }
  9936. return *v, true
  9937. }
  9938. // ResetSourceType resets all changes to the "source_type" field.
  9939. func (m *MessageRecordsMutation) ResetSourceType() {
  9940. m.source_type = nil
  9941. m.addsource_type = nil
  9942. }
  9943. // SetSourceID sets the "source_id" field.
  9944. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  9945. m.sop_stage = &u
  9946. }
  9947. // SourceID returns the value of the "source_id" field in the mutation.
  9948. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  9949. v := m.sop_stage
  9950. if v == nil {
  9951. return
  9952. }
  9953. return *v, true
  9954. }
  9955. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  9956. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9958. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  9959. if !m.op.Is(OpUpdateOne) {
  9960. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  9961. }
  9962. if m.id == nil || m.oldValue == nil {
  9963. return v, errors.New("OldSourceID requires an ID field in the mutation")
  9964. }
  9965. oldValue, err := m.oldValue(ctx)
  9966. if err != nil {
  9967. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  9968. }
  9969. return oldValue.SourceID, nil
  9970. }
  9971. // ClearSourceID clears the value of the "source_id" field.
  9972. func (m *MessageRecordsMutation) ClearSourceID() {
  9973. m.sop_stage = nil
  9974. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  9975. }
  9976. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  9977. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  9978. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  9979. return ok
  9980. }
  9981. // ResetSourceID resets all changes to the "source_id" field.
  9982. func (m *MessageRecordsMutation) ResetSourceID() {
  9983. m.sop_stage = nil
  9984. delete(m.clearedFields, messagerecords.FieldSourceID)
  9985. }
  9986. // SetSubSourceID sets the "sub_source_id" field.
  9987. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  9988. m.sop_node = &u
  9989. }
  9990. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  9991. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  9992. v := m.sop_node
  9993. if v == nil {
  9994. return
  9995. }
  9996. return *v, true
  9997. }
  9998. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  9999. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  10000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10001. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  10002. if !m.op.Is(OpUpdateOne) {
  10003. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  10004. }
  10005. if m.id == nil || m.oldValue == nil {
  10006. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  10007. }
  10008. oldValue, err := m.oldValue(ctx)
  10009. if err != nil {
  10010. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  10011. }
  10012. return oldValue.SubSourceID, nil
  10013. }
  10014. // ClearSubSourceID clears the value of the "sub_source_id" field.
  10015. func (m *MessageRecordsMutation) ClearSubSourceID() {
  10016. m.sop_node = nil
  10017. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  10018. }
  10019. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  10020. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  10021. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  10022. return ok
  10023. }
  10024. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  10025. func (m *MessageRecordsMutation) ResetSubSourceID() {
  10026. m.sop_node = nil
  10027. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  10028. }
  10029. // SetOrganizationID sets the "organization_id" field.
  10030. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  10031. m.organization_id = &u
  10032. m.addorganization_id = nil
  10033. }
  10034. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10035. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  10036. v := m.organization_id
  10037. if v == nil {
  10038. return
  10039. }
  10040. return *v, true
  10041. }
  10042. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  10043. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  10044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10045. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10046. if !m.op.Is(OpUpdateOne) {
  10047. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10048. }
  10049. if m.id == nil || m.oldValue == nil {
  10050. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10051. }
  10052. oldValue, err := m.oldValue(ctx)
  10053. if err != nil {
  10054. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10055. }
  10056. return oldValue.OrganizationID, nil
  10057. }
  10058. // AddOrganizationID adds u to the "organization_id" field.
  10059. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  10060. if m.addorganization_id != nil {
  10061. *m.addorganization_id += u
  10062. } else {
  10063. m.addorganization_id = &u
  10064. }
  10065. }
  10066. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10067. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  10068. v := m.addorganization_id
  10069. if v == nil {
  10070. return
  10071. }
  10072. return *v, true
  10073. }
  10074. // ClearOrganizationID clears the value of the "organization_id" field.
  10075. func (m *MessageRecordsMutation) ClearOrganizationID() {
  10076. m.organization_id = nil
  10077. m.addorganization_id = nil
  10078. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  10079. }
  10080. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10081. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  10082. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  10083. return ok
  10084. }
  10085. // ResetOrganizationID resets all changes to the "organization_id" field.
  10086. func (m *MessageRecordsMutation) ResetOrganizationID() {
  10087. m.organization_id = nil
  10088. m.addorganization_id = nil
  10089. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  10090. }
  10091. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  10092. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  10093. m.sop_stage = &id
  10094. }
  10095. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  10096. func (m *MessageRecordsMutation) ClearSopStage() {
  10097. m.clearedsop_stage = true
  10098. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  10099. }
  10100. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  10101. func (m *MessageRecordsMutation) SopStageCleared() bool {
  10102. return m.SourceIDCleared() || m.clearedsop_stage
  10103. }
  10104. // SopStageID returns the "sop_stage" edge ID in the mutation.
  10105. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  10106. if m.sop_stage != nil {
  10107. return *m.sop_stage, true
  10108. }
  10109. return
  10110. }
  10111. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  10112. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  10113. // SopStageID instead. It exists only for internal usage by the builders.
  10114. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  10115. if id := m.sop_stage; id != nil {
  10116. ids = append(ids, *id)
  10117. }
  10118. return
  10119. }
  10120. // ResetSopStage resets all changes to the "sop_stage" edge.
  10121. func (m *MessageRecordsMutation) ResetSopStage() {
  10122. m.sop_stage = nil
  10123. m.clearedsop_stage = false
  10124. }
  10125. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  10126. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  10127. m.sop_node = &id
  10128. }
  10129. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  10130. func (m *MessageRecordsMutation) ClearSopNode() {
  10131. m.clearedsop_node = true
  10132. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  10133. }
  10134. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  10135. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  10136. return m.SubSourceIDCleared() || m.clearedsop_node
  10137. }
  10138. // SopNodeID returns the "sop_node" edge ID in the mutation.
  10139. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  10140. if m.sop_node != nil {
  10141. return *m.sop_node, true
  10142. }
  10143. return
  10144. }
  10145. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  10146. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  10147. // SopNodeID instead. It exists only for internal usage by the builders.
  10148. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  10149. if id := m.sop_node; id != nil {
  10150. ids = append(ids, *id)
  10151. }
  10152. return
  10153. }
  10154. // ResetSopNode resets all changes to the "sop_node" edge.
  10155. func (m *MessageRecordsMutation) ResetSopNode() {
  10156. m.sop_node = nil
  10157. m.clearedsop_node = false
  10158. }
  10159. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  10160. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  10161. m.message_contact = &id
  10162. }
  10163. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  10164. func (m *MessageRecordsMutation) ClearMessageContact() {
  10165. m.clearedmessage_contact = true
  10166. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  10167. }
  10168. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  10169. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  10170. return m.ContactIDCleared() || m.clearedmessage_contact
  10171. }
  10172. // MessageContactID returns the "message_contact" edge ID in the mutation.
  10173. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  10174. if m.message_contact != nil {
  10175. return *m.message_contact, true
  10176. }
  10177. return
  10178. }
  10179. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  10180. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  10181. // MessageContactID instead. It exists only for internal usage by the builders.
  10182. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  10183. if id := m.message_contact; id != nil {
  10184. ids = append(ids, *id)
  10185. }
  10186. return
  10187. }
  10188. // ResetMessageContact resets all changes to the "message_contact" edge.
  10189. func (m *MessageRecordsMutation) ResetMessageContact() {
  10190. m.message_contact = nil
  10191. m.clearedmessage_contact = false
  10192. }
  10193. // Where appends a list predicates to the MessageRecordsMutation builder.
  10194. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  10195. m.predicates = append(m.predicates, ps...)
  10196. }
  10197. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  10198. // users can use type-assertion to append predicates that do not depend on any generated package.
  10199. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  10200. p := make([]predicate.MessageRecords, len(ps))
  10201. for i := range ps {
  10202. p[i] = ps[i]
  10203. }
  10204. m.Where(p...)
  10205. }
  10206. // Op returns the operation name.
  10207. func (m *MessageRecordsMutation) Op() Op {
  10208. return m.op
  10209. }
  10210. // SetOp allows setting the mutation operation.
  10211. func (m *MessageRecordsMutation) SetOp(op Op) {
  10212. m.op = op
  10213. }
  10214. // Type returns the node type of this mutation (MessageRecords).
  10215. func (m *MessageRecordsMutation) Type() string {
  10216. return m.typ
  10217. }
  10218. // Fields returns all fields that were changed during this mutation. Note that in
  10219. // order to get all numeric fields that were incremented/decremented, call
  10220. // AddedFields().
  10221. func (m *MessageRecordsMutation) Fields() []string {
  10222. fields := make([]string, 0, 16)
  10223. if m.created_at != nil {
  10224. fields = append(fields, messagerecords.FieldCreatedAt)
  10225. }
  10226. if m.updated_at != nil {
  10227. fields = append(fields, messagerecords.FieldUpdatedAt)
  10228. }
  10229. if m.status != nil {
  10230. fields = append(fields, messagerecords.FieldStatus)
  10231. }
  10232. if m.bot_wxid != nil {
  10233. fields = append(fields, messagerecords.FieldBotWxid)
  10234. }
  10235. if m.message_contact != nil {
  10236. fields = append(fields, messagerecords.FieldContactID)
  10237. }
  10238. if m.contact_type != nil {
  10239. fields = append(fields, messagerecords.FieldContactType)
  10240. }
  10241. if m.contact_wxid != nil {
  10242. fields = append(fields, messagerecords.FieldContactWxid)
  10243. }
  10244. if m.content_type != nil {
  10245. fields = append(fields, messagerecords.FieldContentType)
  10246. }
  10247. if m.content != nil {
  10248. fields = append(fields, messagerecords.FieldContent)
  10249. }
  10250. if m.meta != nil {
  10251. fields = append(fields, messagerecords.FieldMeta)
  10252. }
  10253. if m.error_detail != nil {
  10254. fields = append(fields, messagerecords.FieldErrorDetail)
  10255. }
  10256. if m.send_time != nil {
  10257. fields = append(fields, messagerecords.FieldSendTime)
  10258. }
  10259. if m.source_type != nil {
  10260. fields = append(fields, messagerecords.FieldSourceType)
  10261. }
  10262. if m.sop_stage != nil {
  10263. fields = append(fields, messagerecords.FieldSourceID)
  10264. }
  10265. if m.sop_node != nil {
  10266. fields = append(fields, messagerecords.FieldSubSourceID)
  10267. }
  10268. if m.organization_id != nil {
  10269. fields = append(fields, messagerecords.FieldOrganizationID)
  10270. }
  10271. return fields
  10272. }
  10273. // Field returns the value of a field with the given name. The second boolean
  10274. // return value indicates that this field was not set, or was not defined in the
  10275. // schema.
  10276. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  10277. switch name {
  10278. case messagerecords.FieldCreatedAt:
  10279. return m.CreatedAt()
  10280. case messagerecords.FieldUpdatedAt:
  10281. return m.UpdatedAt()
  10282. case messagerecords.FieldStatus:
  10283. return m.Status()
  10284. case messagerecords.FieldBotWxid:
  10285. return m.BotWxid()
  10286. case messagerecords.FieldContactID:
  10287. return m.ContactID()
  10288. case messagerecords.FieldContactType:
  10289. return m.ContactType()
  10290. case messagerecords.FieldContactWxid:
  10291. return m.ContactWxid()
  10292. case messagerecords.FieldContentType:
  10293. return m.ContentType()
  10294. case messagerecords.FieldContent:
  10295. return m.Content()
  10296. case messagerecords.FieldMeta:
  10297. return m.Meta()
  10298. case messagerecords.FieldErrorDetail:
  10299. return m.ErrorDetail()
  10300. case messagerecords.FieldSendTime:
  10301. return m.SendTime()
  10302. case messagerecords.FieldSourceType:
  10303. return m.SourceType()
  10304. case messagerecords.FieldSourceID:
  10305. return m.SourceID()
  10306. case messagerecords.FieldSubSourceID:
  10307. return m.SubSourceID()
  10308. case messagerecords.FieldOrganizationID:
  10309. return m.OrganizationID()
  10310. }
  10311. return nil, false
  10312. }
  10313. // OldField returns the old value of the field from the database. An error is
  10314. // returned if the mutation operation is not UpdateOne, or the query to the
  10315. // database failed.
  10316. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10317. switch name {
  10318. case messagerecords.FieldCreatedAt:
  10319. return m.OldCreatedAt(ctx)
  10320. case messagerecords.FieldUpdatedAt:
  10321. return m.OldUpdatedAt(ctx)
  10322. case messagerecords.FieldStatus:
  10323. return m.OldStatus(ctx)
  10324. case messagerecords.FieldBotWxid:
  10325. return m.OldBotWxid(ctx)
  10326. case messagerecords.FieldContactID:
  10327. return m.OldContactID(ctx)
  10328. case messagerecords.FieldContactType:
  10329. return m.OldContactType(ctx)
  10330. case messagerecords.FieldContactWxid:
  10331. return m.OldContactWxid(ctx)
  10332. case messagerecords.FieldContentType:
  10333. return m.OldContentType(ctx)
  10334. case messagerecords.FieldContent:
  10335. return m.OldContent(ctx)
  10336. case messagerecords.FieldMeta:
  10337. return m.OldMeta(ctx)
  10338. case messagerecords.FieldErrorDetail:
  10339. return m.OldErrorDetail(ctx)
  10340. case messagerecords.FieldSendTime:
  10341. return m.OldSendTime(ctx)
  10342. case messagerecords.FieldSourceType:
  10343. return m.OldSourceType(ctx)
  10344. case messagerecords.FieldSourceID:
  10345. return m.OldSourceID(ctx)
  10346. case messagerecords.FieldSubSourceID:
  10347. return m.OldSubSourceID(ctx)
  10348. case messagerecords.FieldOrganizationID:
  10349. return m.OldOrganizationID(ctx)
  10350. }
  10351. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  10352. }
  10353. // SetField sets the value of a field with the given name. It returns an error if
  10354. // the field is not defined in the schema, or if the type mismatched the field
  10355. // type.
  10356. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  10357. switch name {
  10358. case messagerecords.FieldCreatedAt:
  10359. v, ok := value.(time.Time)
  10360. if !ok {
  10361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10362. }
  10363. m.SetCreatedAt(v)
  10364. return nil
  10365. case messagerecords.FieldUpdatedAt:
  10366. v, ok := value.(time.Time)
  10367. if !ok {
  10368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10369. }
  10370. m.SetUpdatedAt(v)
  10371. return nil
  10372. case messagerecords.FieldStatus:
  10373. v, ok := value.(uint8)
  10374. if !ok {
  10375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10376. }
  10377. m.SetStatus(v)
  10378. return nil
  10379. case messagerecords.FieldBotWxid:
  10380. v, ok := value.(string)
  10381. if !ok {
  10382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10383. }
  10384. m.SetBotWxid(v)
  10385. return nil
  10386. case messagerecords.FieldContactID:
  10387. v, ok := value.(uint64)
  10388. if !ok {
  10389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10390. }
  10391. m.SetContactID(v)
  10392. return nil
  10393. case messagerecords.FieldContactType:
  10394. v, ok := value.(int)
  10395. if !ok {
  10396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10397. }
  10398. m.SetContactType(v)
  10399. return nil
  10400. case messagerecords.FieldContactWxid:
  10401. v, ok := value.(string)
  10402. if !ok {
  10403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10404. }
  10405. m.SetContactWxid(v)
  10406. return nil
  10407. case messagerecords.FieldContentType:
  10408. v, ok := value.(int)
  10409. if !ok {
  10410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10411. }
  10412. m.SetContentType(v)
  10413. return nil
  10414. case messagerecords.FieldContent:
  10415. v, ok := value.(string)
  10416. if !ok {
  10417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10418. }
  10419. m.SetContent(v)
  10420. return nil
  10421. case messagerecords.FieldMeta:
  10422. v, ok := value.(custom_types.Meta)
  10423. if !ok {
  10424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10425. }
  10426. m.SetMeta(v)
  10427. return nil
  10428. case messagerecords.FieldErrorDetail:
  10429. v, ok := value.(string)
  10430. if !ok {
  10431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10432. }
  10433. m.SetErrorDetail(v)
  10434. return nil
  10435. case messagerecords.FieldSendTime:
  10436. v, ok := value.(time.Time)
  10437. if !ok {
  10438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10439. }
  10440. m.SetSendTime(v)
  10441. return nil
  10442. case messagerecords.FieldSourceType:
  10443. v, ok := value.(int)
  10444. if !ok {
  10445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10446. }
  10447. m.SetSourceType(v)
  10448. return nil
  10449. case messagerecords.FieldSourceID:
  10450. v, ok := value.(uint64)
  10451. if !ok {
  10452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10453. }
  10454. m.SetSourceID(v)
  10455. return nil
  10456. case messagerecords.FieldSubSourceID:
  10457. v, ok := value.(uint64)
  10458. if !ok {
  10459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10460. }
  10461. m.SetSubSourceID(v)
  10462. return nil
  10463. case messagerecords.FieldOrganizationID:
  10464. v, ok := value.(uint64)
  10465. if !ok {
  10466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10467. }
  10468. m.SetOrganizationID(v)
  10469. return nil
  10470. }
  10471. return fmt.Errorf("unknown MessageRecords field %s", name)
  10472. }
  10473. // AddedFields returns all numeric fields that were incremented/decremented during
  10474. // this mutation.
  10475. func (m *MessageRecordsMutation) AddedFields() []string {
  10476. var fields []string
  10477. if m.addstatus != nil {
  10478. fields = append(fields, messagerecords.FieldStatus)
  10479. }
  10480. if m.addcontact_type != nil {
  10481. fields = append(fields, messagerecords.FieldContactType)
  10482. }
  10483. if m.addcontent_type != nil {
  10484. fields = append(fields, messagerecords.FieldContentType)
  10485. }
  10486. if m.addsource_type != nil {
  10487. fields = append(fields, messagerecords.FieldSourceType)
  10488. }
  10489. if m.addorganization_id != nil {
  10490. fields = append(fields, messagerecords.FieldOrganizationID)
  10491. }
  10492. return fields
  10493. }
  10494. // AddedField returns the numeric value that was incremented/decremented on a field
  10495. // with the given name. The second boolean return value indicates that this field
  10496. // was not set, or was not defined in the schema.
  10497. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  10498. switch name {
  10499. case messagerecords.FieldStatus:
  10500. return m.AddedStatus()
  10501. case messagerecords.FieldContactType:
  10502. return m.AddedContactType()
  10503. case messagerecords.FieldContentType:
  10504. return m.AddedContentType()
  10505. case messagerecords.FieldSourceType:
  10506. return m.AddedSourceType()
  10507. case messagerecords.FieldOrganizationID:
  10508. return m.AddedOrganizationID()
  10509. }
  10510. return nil, false
  10511. }
  10512. // AddField adds the value to the field with the given name. It returns an error if
  10513. // the field is not defined in the schema, or if the type mismatched the field
  10514. // type.
  10515. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  10516. switch name {
  10517. case messagerecords.FieldStatus:
  10518. v, ok := value.(int8)
  10519. if !ok {
  10520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10521. }
  10522. m.AddStatus(v)
  10523. return nil
  10524. case messagerecords.FieldContactType:
  10525. v, ok := value.(int)
  10526. if !ok {
  10527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10528. }
  10529. m.AddContactType(v)
  10530. return nil
  10531. case messagerecords.FieldContentType:
  10532. v, ok := value.(int)
  10533. if !ok {
  10534. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10535. }
  10536. m.AddContentType(v)
  10537. return nil
  10538. case messagerecords.FieldSourceType:
  10539. v, ok := value.(int)
  10540. if !ok {
  10541. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10542. }
  10543. m.AddSourceType(v)
  10544. return nil
  10545. case messagerecords.FieldOrganizationID:
  10546. v, ok := value.(int64)
  10547. if !ok {
  10548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10549. }
  10550. m.AddOrganizationID(v)
  10551. return nil
  10552. }
  10553. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  10554. }
  10555. // ClearedFields returns all nullable fields that were cleared during this
  10556. // mutation.
  10557. func (m *MessageRecordsMutation) ClearedFields() []string {
  10558. var fields []string
  10559. if m.FieldCleared(messagerecords.FieldStatus) {
  10560. fields = append(fields, messagerecords.FieldStatus)
  10561. }
  10562. if m.FieldCleared(messagerecords.FieldContactID) {
  10563. fields = append(fields, messagerecords.FieldContactID)
  10564. }
  10565. if m.FieldCleared(messagerecords.FieldMeta) {
  10566. fields = append(fields, messagerecords.FieldMeta)
  10567. }
  10568. if m.FieldCleared(messagerecords.FieldSendTime) {
  10569. fields = append(fields, messagerecords.FieldSendTime)
  10570. }
  10571. if m.FieldCleared(messagerecords.FieldSourceID) {
  10572. fields = append(fields, messagerecords.FieldSourceID)
  10573. }
  10574. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  10575. fields = append(fields, messagerecords.FieldSubSourceID)
  10576. }
  10577. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  10578. fields = append(fields, messagerecords.FieldOrganizationID)
  10579. }
  10580. return fields
  10581. }
  10582. // FieldCleared returns a boolean indicating if a field with the given name was
  10583. // cleared in this mutation.
  10584. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  10585. _, ok := m.clearedFields[name]
  10586. return ok
  10587. }
  10588. // ClearField clears the value of the field with the given name. It returns an
  10589. // error if the field is not defined in the schema.
  10590. func (m *MessageRecordsMutation) ClearField(name string) error {
  10591. switch name {
  10592. case messagerecords.FieldStatus:
  10593. m.ClearStatus()
  10594. return nil
  10595. case messagerecords.FieldContactID:
  10596. m.ClearContactID()
  10597. return nil
  10598. case messagerecords.FieldMeta:
  10599. m.ClearMeta()
  10600. return nil
  10601. case messagerecords.FieldSendTime:
  10602. m.ClearSendTime()
  10603. return nil
  10604. case messagerecords.FieldSourceID:
  10605. m.ClearSourceID()
  10606. return nil
  10607. case messagerecords.FieldSubSourceID:
  10608. m.ClearSubSourceID()
  10609. return nil
  10610. case messagerecords.FieldOrganizationID:
  10611. m.ClearOrganizationID()
  10612. return nil
  10613. }
  10614. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  10615. }
  10616. // ResetField resets all changes in the mutation for the field with the given name.
  10617. // It returns an error if the field is not defined in the schema.
  10618. func (m *MessageRecordsMutation) ResetField(name string) error {
  10619. switch name {
  10620. case messagerecords.FieldCreatedAt:
  10621. m.ResetCreatedAt()
  10622. return nil
  10623. case messagerecords.FieldUpdatedAt:
  10624. m.ResetUpdatedAt()
  10625. return nil
  10626. case messagerecords.FieldStatus:
  10627. m.ResetStatus()
  10628. return nil
  10629. case messagerecords.FieldBotWxid:
  10630. m.ResetBotWxid()
  10631. return nil
  10632. case messagerecords.FieldContactID:
  10633. m.ResetContactID()
  10634. return nil
  10635. case messagerecords.FieldContactType:
  10636. m.ResetContactType()
  10637. return nil
  10638. case messagerecords.FieldContactWxid:
  10639. m.ResetContactWxid()
  10640. return nil
  10641. case messagerecords.FieldContentType:
  10642. m.ResetContentType()
  10643. return nil
  10644. case messagerecords.FieldContent:
  10645. m.ResetContent()
  10646. return nil
  10647. case messagerecords.FieldMeta:
  10648. m.ResetMeta()
  10649. return nil
  10650. case messagerecords.FieldErrorDetail:
  10651. m.ResetErrorDetail()
  10652. return nil
  10653. case messagerecords.FieldSendTime:
  10654. m.ResetSendTime()
  10655. return nil
  10656. case messagerecords.FieldSourceType:
  10657. m.ResetSourceType()
  10658. return nil
  10659. case messagerecords.FieldSourceID:
  10660. m.ResetSourceID()
  10661. return nil
  10662. case messagerecords.FieldSubSourceID:
  10663. m.ResetSubSourceID()
  10664. return nil
  10665. case messagerecords.FieldOrganizationID:
  10666. m.ResetOrganizationID()
  10667. return nil
  10668. }
  10669. return fmt.Errorf("unknown MessageRecords field %s", name)
  10670. }
  10671. // AddedEdges returns all edge names that were set/added in this mutation.
  10672. func (m *MessageRecordsMutation) AddedEdges() []string {
  10673. edges := make([]string, 0, 3)
  10674. if m.sop_stage != nil {
  10675. edges = append(edges, messagerecords.EdgeSopStage)
  10676. }
  10677. if m.sop_node != nil {
  10678. edges = append(edges, messagerecords.EdgeSopNode)
  10679. }
  10680. if m.message_contact != nil {
  10681. edges = append(edges, messagerecords.EdgeMessageContact)
  10682. }
  10683. return edges
  10684. }
  10685. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10686. // name in this mutation.
  10687. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  10688. switch name {
  10689. case messagerecords.EdgeSopStage:
  10690. if id := m.sop_stage; id != nil {
  10691. return []ent.Value{*id}
  10692. }
  10693. case messagerecords.EdgeSopNode:
  10694. if id := m.sop_node; id != nil {
  10695. return []ent.Value{*id}
  10696. }
  10697. case messagerecords.EdgeMessageContact:
  10698. if id := m.message_contact; id != nil {
  10699. return []ent.Value{*id}
  10700. }
  10701. }
  10702. return nil
  10703. }
  10704. // RemovedEdges returns all edge names that were removed in this mutation.
  10705. func (m *MessageRecordsMutation) RemovedEdges() []string {
  10706. edges := make([]string, 0, 3)
  10707. return edges
  10708. }
  10709. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10710. // the given name in this mutation.
  10711. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  10712. return nil
  10713. }
  10714. // ClearedEdges returns all edge names that were cleared in this mutation.
  10715. func (m *MessageRecordsMutation) ClearedEdges() []string {
  10716. edges := make([]string, 0, 3)
  10717. if m.clearedsop_stage {
  10718. edges = append(edges, messagerecords.EdgeSopStage)
  10719. }
  10720. if m.clearedsop_node {
  10721. edges = append(edges, messagerecords.EdgeSopNode)
  10722. }
  10723. if m.clearedmessage_contact {
  10724. edges = append(edges, messagerecords.EdgeMessageContact)
  10725. }
  10726. return edges
  10727. }
  10728. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10729. // was cleared in this mutation.
  10730. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  10731. switch name {
  10732. case messagerecords.EdgeSopStage:
  10733. return m.clearedsop_stage
  10734. case messagerecords.EdgeSopNode:
  10735. return m.clearedsop_node
  10736. case messagerecords.EdgeMessageContact:
  10737. return m.clearedmessage_contact
  10738. }
  10739. return false
  10740. }
  10741. // ClearEdge clears the value of the edge with the given name. It returns an error
  10742. // if that edge is not defined in the schema.
  10743. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  10744. switch name {
  10745. case messagerecords.EdgeSopStage:
  10746. m.ClearSopStage()
  10747. return nil
  10748. case messagerecords.EdgeSopNode:
  10749. m.ClearSopNode()
  10750. return nil
  10751. case messagerecords.EdgeMessageContact:
  10752. m.ClearMessageContact()
  10753. return nil
  10754. }
  10755. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  10756. }
  10757. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10758. // It returns an error if the edge is not defined in the schema.
  10759. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  10760. switch name {
  10761. case messagerecords.EdgeSopStage:
  10762. m.ResetSopStage()
  10763. return nil
  10764. case messagerecords.EdgeSopNode:
  10765. m.ResetSopNode()
  10766. return nil
  10767. case messagerecords.EdgeMessageContact:
  10768. m.ResetMessageContact()
  10769. return nil
  10770. }
  10771. return fmt.Errorf("unknown MessageRecords edge %s", name)
  10772. }
  10773. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  10774. type MsgMutation struct {
  10775. config
  10776. op Op
  10777. typ string
  10778. id *uint64
  10779. created_at *time.Time
  10780. updated_at *time.Time
  10781. deleted_at *time.Time
  10782. status *uint8
  10783. addstatus *int8
  10784. fromwxid *string
  10785. toid *string
  10786. msgtype *int32
  10787. addmsgtype *int32
  10788. msg *string
  10789. batch_no *string
  10790. clearedFields map[string]struct{}
  10791. done bool
  10792. oldValue func(context.Context) (*Msg, error)
  10793. predicates []predicate.Msg
  10794. }
  10795. var _ ent.Mutation = (*MsgMutation)(nil)
  10796. // msgOption allows management of the mutation configuration using functional options.
  10797. type msgOption func(*MsgMutation)
  10798. // newMsgMutation creates new mutation for the Msg entity.
  10799. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  10800. m := &MsgMutation{
  10801. config: c,
  10802. op: op,
  10803. typ: TypeMsg,
  10804. clearedFields: make(map[string]struct{}),
  10805. }
  10806. for _, opt := range opts {
  10807. opt(m)
  10808. }
  10809. return m
  10810. }
  10811. // withMsgID sets the ID field of the mutation.
  10812. func withMsgID(id uint64) msgOption {
  10813. return func(m *MsgMutation) {
  10814. var (
  10815. err error
  10816. once sync.Once
  10817. value *Msg
  10818. )
  10819. m.oldValue = func(ctx context.Context) (*Msg, error) {
  10820. once.Do(func() {
  10821. if m.done {
  10822. err = errors.New("querying old values post mutation is not allowed")
  10823. } else {
  10824. value, err = m.Client().Msg.Get(ctx, id)
  10825. }
  10826. })
  10827. return value, err
  10828. }
  10829. m.id = &id
  10830. }
  10831. }
  10832. // withMsg sets the old Msg of the mutation.
  10833. func withMsg(node *Msg) msgOption {
  10834. return func(m *MsgMutation) {
  10835. m.oldValue = func(context.Context) (*Msg, error) {
  10836. return node, nil
  10837. }
  10838. m.id = &node.ID
  10839. }
  10840. }
  10841. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10842. // executed in a transaction (ent.Tx), a transactional client is returned.
  10843. func (m MsgMutation) Client() *Client {
  10844. client := &Client{config: m.config}
  10845. client.init()
  10846. return client
  10847. }
  10848. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10849. // it returns an error otherwise.
  10850. func (m MsgMutation) Tx() (*Tx, error) {
  10851. if _, ok := m.driver.(*txDriver); !ok {
  10852. return nil, errors.New("ent: mutation is not running in a transaction")
  10853. }
  10854. tx := &Tx{config: m.config}
  10855. tx.init()
  10856. return tx, nil
  10857. }
  10858. // SetID sets the value of the id field. Note that this
  10859. // operation is only accepted on creation of Msg entities.
  10860. func (m *MsgMutation) SetID(id uint64) {
  10861. m.id = &id
  10862. }
  10863. // ID returns the ID value in the mutation. Note that the ID is only available
  10864. // if it was provided to the builder or after it was returned from the database.
  10865. func (m *MsgMutation) ID() (id uint64, exists bool) {
  10866. if m.id == nil {
  10867. return
  10868. }
  10869. return *m.id, true
  10870. }
  10871. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10872. // That means, if the mutation is applied within a transaction with an isolation level such
  10873. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10874. // or updated by the mutation.
  10875. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  10876. switch {
  10877. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10878. id, exists := m.ID()
  10879. if exists {
  10880. return []uint64{id}, nil
  10881. }
  10882. fallthrough
  10883. case m.op.Is(OpUpdate | OpDelete):
  10884. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  10885. default:
  10886. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10887. }
  10888. }
  10889. // SetCreatedAt sets the "created_at" field.
  10890. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  10891. m.created_at = &t
  10892. }
  10893. // CreatedAt returns the value of the "created_at" field in the mutation.
  10894. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  10895. v := m.created_at
  10896. if v == nil {
  10897. return
  10898. }
  10899. return *v, true
  10900. }
  10901. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  10902. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10903. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10904. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10905. if !m.op.Is(OpUpdateOne) {
  10906. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10907. }
  10908. if m.id == nil || m.oldValue == nil {
  10909. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10910. }
  10911. oldValue, err := m.oldValue(ctx)
  10912. if err != nil {
  10913. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10914. }
  10915. return oldValue.CreatedAt, nil
  10916. }
  10917. // ResetCreatedAt resets all changes to the "created_at" field.
  10918. func (m *MsgMutation) ResetCreatedAt() {
  10919. m.created_at = nil
  10920. }
  10921. // SetUpdatedAt sets the "updated_at" field.
  10922. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  10923. m.updated_at = &t
  10924. }
  10925. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10926. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  10927. v := m.updated_at
  10928. if v == nil {
  10929. return
  10930. }
  10931. return *v, true
  10932. }
  10933. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  10934. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10935. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10936. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10937. if !m.op.Is(OpUpdateOne) {
  10938. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10939. }
  10940. if m.id == nil || m.oldValue == nil {
  10941. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10942. }
  10943. oldValue, err := m.oldValue(ctx)
  10944. if err != nil {
  10945. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10946. }
  10947. return oldValue.UpdatedAt, nil
  10948. }
  10949. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10950. func (m *MsgMutation) ResetUpdatedAt() {
  10951. m.updated_at = nil
  10952. }
  10953. // SetDeletedAt sets the "deleted_at" field.
  10954. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  10955. m.deleted_at = &t
  10956. }
  10957. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10958. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  10959. v := m.deleted_at
  10960. if v == nil {
  10961. return
  10962. }
  10963. return *v, true
  10964. }
  10965. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  10966. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10968. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10969. if !m.op.Is(OpUpdateOne) {
  10970. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10971. }
  10972. if m.id == nil || m.oldValue == nil {
  10973. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10974. }
  10975. oldValue, err := m.oldValue(ctx)
  10976. if err != nil {
  10977. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10978. }
  10979. return oldValue.DeletedAt, nil
  10980. }
  10981. // ClearDeletedAt clears the value of the "deleted_at" field.
  10982. func (m *MsgMutation) ClearDeletedAt() {
  10983. m.deleted_at = nil
  10984. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  10985. }
  10986. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10987. func (m *MsgMutation) DeletedAtCleared() bool {
  10988. _, ok := m.clearedFields[msg.FieldDeletedAt]
  10989. return ok
  10990. }
  10991. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10992. func (m *MsgMutation) ResetDeletedAt() {
  10993. m.deleted_at = nil
  10994. delete(m.clearedFields, msg.FieldDeletedAt)
  10995. }
  10996. // SetStatus sets the "status" field.
  10997. func (m *MsgMutation) SetStatus(u uint8) {
  10998. m.status = &u
  10999. m.addstatus = nil
  11000. }
  11001. // Status returns the value of the "status" field in the mutation.
  11002. func (m *MsgMutation) Status() (r uint8, exists bool) {
  11003. v := m.status
  11004. if v == nil {
  11005. return
  11006. }
  11007. return *v, true
  11008. }
  11009. // OldStatus returns the old "status" field's value of the Msg entity.
  11010. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11012. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11013. if !m.op.Is(OpUpdateOne) {
  11014. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11015. }
  11016. if m.id == nil || m.oldValue == nil {
  11017. return v, errors.New("OldStatus requires an ID field in the mutation")
  11018. }
  11019. oldValue, err := m.oldValue(ctx)
  11020. if err != nil {
  11021. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11022. }
  11023. return oldValue.Status, nil
  11024. }
  11025. // AddStatus adds u to the "status" field.
  11026. func (m *MsgMutation) AddStatus(u int8) {
  11027. if m.addstatus != nil {
  11028. *m.addstatus += u
  11029. } else {
  11030. m.addstatus = &u
  11031. }
  11032. }
  11033. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11034. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  11035. v := m.addstatus
  11036. if v == nil {
  11037. return
  11038. }
  11039. return *v, true
  11040. }
  11041. // ClearStatus clears the value of the "status" field.
  11042. func (m *MsgMutation) ClearStatus() {
  11043. m.status = nil
  11044. m.addstatus = nil
  11045. m.clearedFields[msg.FieldStatus] = struct{}{}
  11046. }
  11047. // StatusCleared returns if the "status" field was cleared in this mutation.
  11048. func (m *MsgMutation) StatusCleared() bool {
  11049. _, ok := m.clearedFields[msg.FieldStatus]
  11050. return ok
  11051. }
  11052. // ResetStatus resets all changes to the "status" field.
  11053. func (m *MsgMutation) ResetStatus() {
  11054. m.status = nil
  11055. m.addstatus = nil
  11056. delete(m.clearedFields, msg.FieldStatus)
  11057. }
  11058. // SetFromwxid sets the "fromwxid" field.
  11059. func (m *MsgMutation) SetFromwxid(s string) {
  11060. m.fromwxid = &s
  11061. }
  11062. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  11063. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  11064. v := m.fromwxid
  11065. if v == nil {
  11066. return
  11067. }
  11068. return *v, true
  11069. }
  11070. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  11071. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11073. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  11074. if !m.op.Is(OpUpdateOne) {
  11075. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  11076. }
  11077. if m.id == nil || m.oldValue == nil {
  11078. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  11079. }
  11080. oldValue, err := m.oldValue(ctx)
  11081. if err != nil {
  11082. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  11083. }
  11084. return oldValue.Fromwxid, nil
  11085. }
  11086. // ClearFromwxid clears the value of the "fromwxid" field.
  11087. func (m *MsgMutation) ClearFromwxid() {
  11088. m.fromwxid = nil
  11089. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  11090. }
  11091. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  11092. func (m *MsgMutation) FromwxidCleared() bool {
  11093. _, ok := m.clearedFields[msg.FieldFromwxid]
  11094. return ok
  11095. }
  11096. // ResetFromwxid resets all changes to the "fromwxid" field.
  11097. func (m *MsgMutation) ResetFromwxid() {
  11098. m.fromwxid = nil
  11099. delete(m.clearedFields, msg.FieldFromwxid)
  11100. }
  11101. // SetToid sets the "toid" field.
  11102. func (m *MsgMutation) SetToid(s string) {
  11103. m.toid = &s
  11104. }
  11105. // Toid returns the value of the "toid" field in the mutation.
  11106. func (m *MsgMutation) Toid() (r string, exists bool) {
  11107. v := m.toid
  11108. if v == nil {
  11109. return
  11110. }
  11111. return *v, true
  11112. }
  11113. // OldToid returns the old "toid" field's value of the Msg entity.
  11114. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11116. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  11117. if !m.op.Is(OpUpdateOne) {
  11118. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  11119. }
  11120. if m.id == nil || m.oldValue == nil {
  11121. return v, errors.New("OldToid requires an ID field in the mutation")
  11122. }
  11123. oldValue, err := m.oldValue(ctx)
  11124. if err != nil {
  11125. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  11126. }
  11127. return oldValue.Toid, nil
  11128. }
  11129. // ClearToid clears the value of the "toid" field.
  11130. func (m *MsgMutation) ClearToid() {
  11131. m.toid = nil
  11132. m.clearedFields[msg.FieldToid] = struct{}{}
  11133. }
  11134. // ToidCleared returns if the "toid" field was cleared in this mutation.
  11135. func (m *MsgMutation) ToidCleared() bool {
  11136. _, ok := m.clearedFields[msg.FieldToid]
  11137. return ok
  11138. }
  11139. // ResetToid resets all changes to the "toid" field.
  11140. func (m *MsgMutation) ResetToid() {
  11141. m.toid = nil
  11142. delete(m.clearedFields, msg.FieldToid)
  11143. }
  11144. // SetMsgtype sets the "msgtype" field.
  11145. func (m *MsgMutation) SetMsgtype(i int32) {
  11146. m.msgtype = &i
  11147. m.addmsgtype = nil
  11148. }
  11149. // Msgtype returns the value of the "msgtype" field in the mutation.
  11150. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  11151. v := m.msgtype
  11152. if v == nil {
  11153. return
  11154. }
  11155. return *v, true
  11156. }
  11157. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  11158. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11160. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  11161. if !m.op.Is(OpUpdateOne) {
  11162. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  11163. }
  11164. if m.id == nil || m.oldValue == nil {
  11165. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  11166. }
  11167. oldValue, err := m.oldValue(ctx)
  11168. if err != nil {
  11169. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  11170. }
  11171. return oldValue.Msgtype, nil
  11172. }
  11173. // AddMsgtype adds i to the "msgtype" field.
  11174. func (m *MsgMutation) AddMsgtype(i int32) {
  11175. if m.addmsgtype != nil {
  11176. *m.addmsgtype += i
  11177. } else {
  11178. m.addmsgtype = &i
  11179. }
  11180. }
  11181. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  11182. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  11183. v := m.addmsgtype
  11184. if v == nil {
  11185. return
  11186. }
  11187. return *v, true
  11188. }
  11189. // ClearMsgtype clears the value of the "msgtype" field.
  11190. func (m *MsgMutation) ClearMsgtype() {
  11191. m.msgtype = nil
  11192. m.addmsgtype = nil
  11193. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  11194. }
  11195. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  11196. func (m *MsgMutation) MsgtypeCleared() bool {
  11197. _, ok := m.clearedFields[msg.FieldMsgtype]
  11198. return ok
  11199. }
  11200. // ResetMsgtype resets all changes to the "msgtype" field.
  11201. func (m *MsgMutation) ResetMsgtype() {
  11202. m.msgtype = nil
  11203. m.addmsgtype = nil
  11204. delete(m.clearedFields, msg.FieldMsgtype)
  11205. }
  11206. // SetMsg sets the "msg" field.
  11207. func (m *MsgMutation) SetMsg(s string) {
  11208. m.msg = &s
  11209. }
  11210. // Msg returns the value of the "msg" field in the mutation.
  11211. func (m *MsgMutation) Msg() (r string, exists bool) {
  11212. v := m.msg
  11213. if v == nil {
  11214. return
  11215. }
  11216. return *v, true
  11217. }
  11218. // OldMsg returns the old "msg" field's value of the Msg entity.
  11219. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11221. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  11222. if !m.op.Is(OpUpdateOne) {
  11223. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  11224. }
  11225. if m.id == nil || m.oldValue == nil {
  11226. return v, errors.New("OldMsg requires an ID field in the mutation")
  11227. }
  11228. oldValue, err := m.oldValue(ctx)
  11229. if err != nil {
  11230. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  11231. }
  11232. return oldValue.Msg, nil
  11233. }
  11234. // ClearMsg clears the value of the "msg" field.
  11235. func (m *MsgMutation) ClearMsg() {
  11236. m.msg = nil
  11237. m.clearedFields[msg.FieldMsg] = struct{}{}
  11238. }
  11239. // MsgCleared returns if the "msg" field was cleared in this mutation.
  11240. func (m *MsgMutation) MsgCleared() bool {
  11241. _, ok := m.clearedFields[msg.FieldMsg]
  11242. return ok
  11243. }
  11244. // ResetMsg resets all changes to the "msg" field.
  11245. func (m *MsgMutation) ResetMsg() {
  11246. m.msg = nil
  11247. delete(m.clearedFields, msg.FieldMsg)
  11248. }
  11249. // SetBatchNo sets the "batch_no" field.
  11250. func (m *MsgMutation) SetBatchNo(s string) {
  11251. m.batch_no = &s
  11252. }
  11253. // BatchNo returns the value of the "batch_no" field in the mutation.
  11254. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  11255. v := m.batch_no
  11256. if v == nil {
  11257. return
  11258. }
  11259. return *v, true
  11260. }
  11261. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  11262. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11264. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  11265. if !m.op.Is(OpUpdateOne) {
  11266. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  11267. }
  11268. if m.id == nil || m.oldValue == nil {
  11269. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  11270. }
  11271. oldValue, err := m.oldValue(ctx)
  11272. if err != nil {
  11273. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  11274. }
  11275. return oldValue.BatchNo, nil
  11276. }
  11277. // ClearBatchNo clears the value of the "batch_no" field.
  11278. func (m *MsgMutation) ClearBatchNo() {
  11279. m.batch_no = nil
  11280. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  11281. }
  11282. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  11283. func (m *MsgMutation) BatchNoCleared() bool {
  11284. _, ok := m.clearedFields[msg.FieldBatchNo]
  11285. return ok
  11286. }
  11287. // ResetBatchNo resets all changes to the "batch_no" field.
  11288. func (m *MsgMutation) ResetBatchNo() {
  11289. m.batch_no = nil
  11290. delete(m.clearedFields, msg.FieldBatchNo)
  11291. }
  11292. // Where appends a list predicates to the MsgMutation builder.
  11293. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  11294. m.predicates = append(m.predicates, ps...)
  11295. }
  11296. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  11297. // users can use type-assertion to append predicates that do not depend on any generated package.
  11298. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  11299. p := make([]predicate.Msg, len(ps))
  11300. for i := range ps {
  11301. p[i] = ps[i]
  11302. }
  11303. m.Where(p...)
  11304. }
  11305. // Op returns the operation name.
  11306. func (m *MsgMutation) Op() Op {
  11307. return m.op
  11308. }
  11309. // SetOp allows setting the mutation operation.
  11310. func (m *MsgMutation) SetOp(op Op) {
  11311. m.op = op
  11312. }
  11313. // Type returns the node type of this mutation (Msg).
  11314. func (m *MsgMutation) Type() string {
  11315. return m.typ
  11316. }
  11317. // Fields returns all fields that were changed during this mutation. Note that in
  11318. // order to get all numeric fields that were incremented/decremented, call
  11319. // AddedFields().
  11320. func (m *MsgMutation) Fields() []string {
  11321. fields := make([]string, 0, 9)
  11322. if m.created_at != nil {
  11323. fields = append(fields, msg.FieldCreatedAt)
  11324. }
  11325. if m.updated_at != nil {
  11326. fields = append(fields, msg.FieldUpdatedAt)
  11327. }
  11328. if m.deleted_at != nil {
  11329. fields = append(fields, msg.FieldDeletedAt)
  11330. }
  11331. if m.status != nil {
  11332. fields = append(fields, msg.FieldStatus)
  11333. }
  11334. if m.fromwxid != nil {
  11335. fields = append(fields, msg.FieldFromwxid)
  11336. }
  11337. if m.toid != nil {
  11338. fields = append(fields, msg.FieldToid)
  11339. }
  11340. if m.msgtype != nil {
  11341. fields = append(fields, msg.FieldMsgtype)
  11342. }
  11343. if m.msg != nil {
  11344. fields = append(fields, msg.FieldMsg)
  11345. }
  11346. if m.batch_no != nil {
  11347. fields = append(fields, msg.FieldBatchNo)
  11348. }
  11349. return fields
  11350. }
  11351. // Field returns the value of a field with the given name. The second boolean
  11352. // return value indicates that this field was not set, or was not defined in the
  11353. // schema.
  11354. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  11355. switch name {
  11356. case msg.FieldCreatedAt:
  11357. return m.CreatedAt()
  11358. case msg.FieldUpdatedAt:
  11359. return m.UpdatedAt()
  11360. case msg.FieldDeletedAt:
  11361. return m.DeletedAt()
  11362. case msg.FieldStatus:
  11363. return m.Status()
  11364. case msg.FieldFromwxid:
  11365. return m.Fromwxid()
  11366. case msg.FieldToid:
  11367. return m.Toid()
  11368. case msg.FieldMsgtype:
  11369. return m.Msgtype()
  11370. case msg.FieldMsg:
  11371. return m.Msg()
  11372. case msg.FieldBatchNo:
  11373. return m.BatchNo()
  11374. }
  11375. return nil, false
  11376. }
  11377. // OldField returns the old value of the field from the database. An error is
  11378. // returned if the mutation operation is not UpdateOne, or the query to the
  11379. // database failed.
  11380. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11381. switch name {
  11382. case msg.FieldCreatedAt:
  11383. return m.OldCreatedAt(ctx)
  11384. case msg.FieldUpdatedAt:
  11385. return m.OldUpdatedAt(ctx)
  11386. case msg.FieldDeletedAt:
  11387. return m.OldDeletedAt(ctx)
  11388. case msg.FieldStatus:
  11389. return m.OldStatus(ctx)
  11390. case msg.FieldFromwxid:
  11391. return m.OldFromwxid(ctx)
  11392. case msg.FieldToid:
  11393. return m.OldToid(ctx)
  11394. case msg.FieldMsgtype:
  11395. return m.OldMsgtype(ctx)
  11396. case msg.FieldMsg:
  11397. return m.OldMsg(ctx)
  11398. case msg.FieldBatchNo:
  11399. return m.OldBatchNo(ctx)
  11400. }
  11401. return nil, fmt.Errorf("unknown Msg field %s", name)
  11402. }
  11403. // SetField sets the value of a field with the given name. It returns an error if
  11404. // the field is not defined in the schema, or if the type mismatched the field
  11405. // type.
  11406. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  11407. switch name {
  11408. case msg.FieldCreatedAt:
  11409. v, ok := value.(time.Time)
  11410. if !ok {
  11411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11412. }
  11413. m.SetCreatedAt(v)
  11414. return nil
  11415. case msg.FieldUpdatedAt:
  11416. v, ok := value.(time.Time)
  11417. if !ok {
  11418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11419. }
  11420. m.SetUpdatedAt(v)
  11421. return nil
  11422. case msg.FieldDeletedAt:
  11423. v, ok := value.(time.Time)
  11424. if !ok {
  11425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11426. }
  11427. m.SetDeletedAt(v)
  11428. return nil
  11429. case msg.FieldStatus:
  11430. v, ok := value.(uint8)
  11431. if !ok {
  11432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11433. }
  11434. m.SetStatus(v)
  11435. return nil
  11436. case msg.FieldFromwxid:
  11437. v, ok := value.(string)
  11438. if !ok {
  11439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11440. }
  11441. m.SetFromwxid(v)
  11442. return nil
  11443. case msg.FieldToid:
  11444. v, ok := value.(string)
  11445. if !ok {
  11446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11447. }
  11448. m.SetToid(v)
  11449. return nil
  11450. case msg.FieldMsgtype:
  11451. v, ok := value.(int32)
  11452. if !ok {
  11453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11454. }
  11455. m.SetMsgtype(v)
  11456. return nil
  11457. case msg.FieldMsg:
  11458. v, ok := value.(string)
  11459. if !ok {
  11460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11461. }
  11462. m.SetMsg(v)
  11463. return nil
  11464. case msg.FieldBatchNo:
  11465. v, ok := value.(string)
  11466. if !ok {
  11467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11468. }
  11469. m.SetBatchNo(v)
  11470. return nil
  11471. }
  11472. return fmt.Errorf("unknown Msg field %s", name)
  11473. }
  11474. // AddedFields returns all numeric fields that were incremented/decremented during
  11475. // this mutation.
  11476. func (m *MsgMutation) AddedFields() []string {
  11477. var fields []string
  11478. if m.addstatus != nil {
  11479. fields = append(fields, msg.FieldStatus)
  11480. }
  11481. if m.addmsgtype != nil {
  11482. fields = append(fields, msg.FieldMsgtype)
  11483. }
  11484. return fields
  11485. }
  11486. // AddedField returns the numeric value that was incremented/decremented on a field
  11487. // with the given name. The second boolean return value indicates that this field
  11488. // was not set, or was not defined in the schema.
  11489. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  11490. switch name {
  11491. case msg.FieldStatus:
  11492. return m.AddedStatus()
  11493. case msg.FieldMsgtype:
  11494. return m.AddedMsgtype()
  11495. }
  11496. return nil, false
  11497. }
  11498. // AddField adds the value to the field with the given name. It returns an error if
  11499. // the field is not defined in the schema, or if the type mismatched the field
  11500. // type.
  11501. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  11502. switch name {
  11503. case msg.FieldStatus:
  11504. v, ok := value.(int8)
  11505. if !ok {
  11506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11507. }
  11508. m.AddStatus(v)
  11509. return nil
  11510. case msg.FieldMsgtype:
  11511. v, ok := value.(int32)
  11512. if !ok {
  11513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11514. }
  11515. m.AddMsgtype(v)
  11516. return nil
  11517. }
  11518. return fmt.Errorf("unknown Msg numeric field %s", name)
  11519. }
  11520. // ClearedFields returns all nullable fields that were cleared during this
  11521. // mutation.
  11522. func (m *MsgMutation) ClearedFields() []string {
  11523. var fields []string
  11524. if m.FieldCleared(msg.FieldDeletedAt) {
  11525. fields = append(fields, msg.FieldDeletedAt)
  11526. }
  11527. if m.FieldCleared(msg.FieldStatus) {
  11528. fields = append(fields, msg.FieldStatus)
  11529. }
  11530. if m.FieldCleared(msg.FieldFromwxid) {
  11531. fields = append(fields, msg.FieldFromwxid)
  11532. }
  11533. if m.FieldCleared(msg.FieldToid) {
  11534. fields = append(fields, msg.FieldToid)
  11535. }
  11536. if m.FieldCleared(msg.FieldMsgtype) {
  11537. fields = append(fields, msg.FieldMsgtype)
  11538. }
  11539. if m.FieldCleared(msg.FieldMsg) {
  11540. fields = append(fields, msg.FieldMsg)
  11541. }
  11542. if m.FieldCleared(msg.FieldBatchNo) {
  11543. fields = append(fields, msg.FieldBatchNo)
  11544. }
  11545. return fields
  11546. }
  11547. // FieldCleared returns a boolean indicating if a field with the given name was
  11548. // cleared in this mutation.
  11549. func (m *MsgMutation) FieldCleared(name string) bool {
  11550. _, ok := m.clearedFields[name]
  11551. return ok
  11552. }
  11553. // ClearField clears the value of the field with the given name. It returns an
  11554. // error if the field is not defined in the schema.
  11555. func (m *MsgMutation) ClearField(name string) error {
  11556. switch name {
  11557. case msg.FieldDeletedAt:
  11558. m.ClearDeletedAt()
  11559. return nil
  11560. case msg.FieldStatus:
  11561. m.ClearStatus()
  11562. return nil
  11563. case msg.FieldFromwxid:
  11564. m.ClearFromwxid()
  11565. return nil
  11566. case msg.FieldToid:
  11567. m.ClearToid()
  11568. return nil
  11569. case msg.FieldMsgtype:
  11570. m.ClearMsgtype()
  11571. return nil
  11572. case msg.FieldMsg:
  11573. m.ClearMsg()
  11574. return nil
  11575. case msg.FieldBatchNo:
  11576. m.ClearBatchNo()
  11577. return nil
  11578. }
  11579. return fmt.Errorf("unknown Msg nullable field %s", name)
  11580. }
  11581. // ResetField resets all changes in the mutation for the field with the given name.
  11582. // It returns an error if the field is not defined in the schema.
  11583. func (m *MsgMutation) ResetField(name string) error {
  11584. switch name {
  11585. case msg.FieldCreatedAt:
  11586. m.ResetCreatedAt()
  11587. return nil
  11588. case msg.FieldUpdatedAt:
  11589. m.ResetUpdatedAt()
  11590. return nil
  11591. case msg.FieldDeletedAt:
  11592. m.ResetDeletedAt()
  11593. return nil
  11594. case msg.FieldStatus:
  11595. m.ResetStatus()
  11596. return nil
  11597. case msg.FieldFromwxid:
  11598. m.ResetFromwxid()
  11599. return nil
  11600. case msg.FieldToid:
  11601. m.ResetToid()
  11602. return nil
  11603. case msg.FieldMsgtype:
  11604. m.ResetMsgtype()
  11605. return nil
  11606. case msg.FieldMsg:
  11607. m.ResetMsg()
  11608. return nil
  11609. case msg.FieldBatchNo:
  11610. m.ResetBatchNo()
  11611. return nil
  11612. }
  11613. return fmt.Errorf("unknown Msg field %s", name)
  11614. }
  11615. // AddedEdges returns all edge names that were set/added in this mutation.
  11616. func (m *MsgMutation) AddedEdges() []string {
  11617. edges := make([]string, 0, 0)
  11618. return edges
  11619. }
  11620. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11621. // name in this mutation.
  11622. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  11623. return nil
  11624. }
  11625. // RemovedEdges returns all edge names that were removed in this mutation.
  11626. func (m *MsgMutation) RemovedEdges() []string {
  11627. edges := make([]string, 0, 0)
  11628. return edges
  11629. }
  11630. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11631. // the given name in this mutation.
  11632. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  11633. return nil
  11634. }
  11635. // ClearedEdges returns all edge names that were cleared in this mutation.
  11636. func (m *MsgMutation) ClearedEdges() []string {
  11637. edges := make([]string, 0, 0)
  11638. return edges
  11639. }
  11640. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11641. // was cleared in this mutation.
  11642. func (m *MsgMutation) EdgeCleared(name string) bool {
  11643. return false
  11644. }
  11645. // ClearEdge clears the value of the edge with the given name. It returns an error
  11646. // if that edge is not defined in the schema.
  11647. func (m *MsgMutation) ClearEdge(name string) error {
  11648. return fmt.Errorf("unknown Msg unique edge %s", name)
  11649. }
  11650. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11651. // It returns an error if the edge is not defined in the schema.
  11652. func (m *MsgMutation) ResetEdge(name string) error {
  11653. return fmt.Errorf("unknown Msg edge %s", name)
  11654. }
  11655. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  11656. type ServerMutation struct {
  11657. config
  11658. op Op
  11659. typ string
  11660. id *uint64
  11661. created_at *time.Time
  11662. updated_at *time.Time
  11663. status *uint8
  11664. addstatus *int8
  11665. deleted_at *time.Time
  11666. name *string
  11667. public_ip *string
  11668. private_ip *string
  11669. admin_port *string
  11670. clearedFields map[string]struct{}
  11671. wxs map[uint64]struct{}
  11672. removedwxs map[uint64]struct{}
  11673. clearedwxs bool
  11674. done bool
  11675. oldValue func(context.Context) (*Server, error)
  11676. predicates []predicate.Server
  11677. }
  11678. var _ ent.Mutation = (*ServerMutation)(nil)
  11679. // serverOption allows management of the mutation configuration using functional options.
  11680. type serverOption func(*ServerMutation)
  11681. // newServerMutation creates new mutation for the Server entity.
  11682. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  11683. m := &ServerMutation{
  11684. config: c,
  11685. op: op,
  11686. typ: TypeServer,
  11687. clearedFields: make(map[string]struct{}),
  11688. }
  11689. for _, opt := range opts {
  11690. opt(m)
  11691. }
  11692. return m
  11693. }
  11694. // withServerID sets the ID field of the mutation.
  11695. func withServerID(id uint64) serverOption {
  11696. return func(m *ServerMutation) {
  11697. var (
  11698. err error
  11699. once sync.Once
  11700. value *Server
  11701. )
  11702. m.oldValue = func(ctx context.Context) (*Server, error) {
  11703. once.Do(func() {
  11704. if m.done {
  11705. err = errors.New("querying old values post mutation is not allowed")
  11706. } else {
  11707. value, err = m.Client().Server.Get(ctx, id)
  11708. }
  11709. })
  11710. return value, err
  11711. }
  11712. m.id = &id
  11713. }
  11714. }
  11715. // withServer sets the old Server of the mutation.
  11716. func withServer(node *Server) serverOption {
  11717. return func(m *ServerMutation) {
  11718. m.oldValue = func(context.Context) (*Server, error) {
  11719. return node, nil
  11720. }
  11721. m.id = &node.ID
  11722. }
  11723. }
  11724. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11725. // executed in a transaction (ent.Tx), a transactional client is returned.
  11726. func (m ServerMutation) Client() *Client {
  11727. client := &Client{config: m.config}
  11728. client.init()
  11729. return client
  11730. }
  11731. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11732. // it returns an error otherwise.
  11733. func (m ServerMutation) Tx() (*Tx, error) {
  11734. if _, ok := m.driver.(*txDriver); !ok {
  11735. return nil, errors.New("ent: mutation is not running in a transaction")
  11736. }
  11737. tx := &Tx{config: m.config}
  11738. tx.init()
  11739. return tx, nil
  11740. }
  11741. // SetID sets the value of the id field. Note that this
  11742. // operation is only accepted on creation of Server entities.
  11743. func (m *ServerMutation) SetID(id uint64) {
  11744. m.id = &id
  11745. }
  11746. // ID returns the ID value in the mutation. Note that the ID is only available
  11747. // if it was provided to the builder or after it was returned from the database.
  11748. func (m *ServerMutation) ID() (id uint64, exists bool) {
  11749. if m.id == nil {
  11750. return
  11751. }
  11752. return *m.id, true
  11753. }
  11754. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11755. // That means, if the mutation is applied within a transaction with an isolation level such
  11756. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11757. // or updated by the mutation.
  11758. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  11759. switch {
  11760. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11761. id, exists := m.ID()
  11762. if exists {
  11763. return []uint64{id}, nil
  11764. }
  11765. fallthrough
  11766. case m.op.Is(OpUpdate | OpDelete):
  11767. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  11768. default:
  11769. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11770. }
  11771. }
  11772. // SetCreatedAt sets the "created_at" field.
  11773. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  11774. m.created_at = &t
  11775. }
  11776. // CreatedAt returns the value of the "created_at" field in the mutation.
  11777. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  11778. v := m.created_at
  11779. if v == nil {
  11780. return
  11781. }
  11782. return *v, true
  11783. }
  11784. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  11785. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11787. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11788. if !m.op.Is(OpUpdateOne) {
  11789. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11790. }
  11791. if m.id == nil || m.oldValue == nil {
  11792. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11793. }
  11794. oldValue, err := m.oldValue(ctx)
  11795. if err != nil {
  11796. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11797. }
  11798. return oldValue.CreatedAt, nil
  11799. }
  11800. // ResetCreatedAt resets all changes to the "created_at" field.
  11801. func (m *ServerMutation) ResetCreatedAt() {
  11802. m.created_at = nil
  11803. }
  11804. // SetUpdatedAt sets the "updated_at" field.
  11805. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  11806. m.updated_at = &t
  11807. }
  11808. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11809. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  11810. v := m.updated_at
  11811. if v == nil {
  11812. return
  11813. }
  11814. return *v, true
  11815. }
  11816. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  11817. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11819. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11820. if !m.op.Is(OpUpdateOne) {
  11821. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11822. }
  11823. if m.id == nil || m.oldValue == nil {
  11824. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11825. }
  11826. oldValue, err := m.oldValue(ctx)
  11827. if err != nil {
  11828. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11829. }
  11830. return oldValue.UpdatedAt, nil
  11831. }
  11832. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11833. func (m *ServerMutation) ResetUpdatedAt() {
  11834. m.updated_at = nil
  11835. }
  11836. // SetStatus sets the "status" field.
  11837. func (m *ServerMutation) SetStatus(u uint8) {
  11838. m.status = &u
  11839. m.addstatus = nil
  11840. }
  11841. // Status returns the value of the "status" field in the mutation.
  11842. func (m *ServerMutation) Status() (r uint8, exists bool) {
  11843. v := m.status
  11844. if v == nil {
  11845. return
  11846. }
  11847. return *v, true
  11848. }
  11849. // OldStatus returns the old "status" field's value of the Server entity.
  11850. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11851. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11852. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11853. if !m.op.Is(OpUpdateOne) {
  11854. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11855. }
  11856. if m.id == nil || m.oldValue == nil {
  11857. return v, errors.New("OldStatus requires an ID field in the mutation")
  11858. }
  11859. oldValue, err := m.oldValue(ctx)
  11860. if err != nil {
  11861. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11862. }
  11863. return oldValue.Status, nil
  11864. }
  11865. // AddStatus adds u to the "status" field.
  11866. func (m *ServerMutation) AddStatus(u int8) {
  11867. if m.addstatus != nil {
  11868. *m.addstatus += u
  11869. } else {
  11870. m.addstatus = &u
  11871. }
  11872. }
  11873. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11874. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  11875. v := m.addstatus
  11876. if v == nil {
  11877. return
  11878. }
  11879. return *v, true
  11880. }
  11881. // ClearStatus clears the value of the "status" field.
  11882. func (m *ServerMutation) ClearStatus() {
  11883. m.status = nil
  11884. m.addstatus = nil
  11885. m.clearedFields[server.FieldStatus] = struct{}{}
  11886. }
  11887. // StatusCleared returns if the "status" field was cleared in this mutation.
  11888. func (m *ServerMutation) StatusCleared() bool {
  11889. _, ok := m.clearedFields[server.FieldStatus]
  11890. return ok
  11891. }
  11892. // ResetStatus resets all changes to the "status" field.
  11893. func (m *ServerMutation) ResetStatus() {
  11894. m.status = nil
  11895. m.addstatus = nil
  11896. delete(m.clearedFields, server.FieldStatus)
  11897. }
  11898. // SetDeletedAt sets the "deleted_at" field.
  11899. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  11900. m.deleted_at = &t
  11901. }
  11902. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11903. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  11904. v := m.deleted_at
  11905. if v == nil {
  11906. return
  11907. }
  11908. return *v, true
  11909. }
  11910. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  11911. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11913. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11914. if !m.op.Is(OpUpdateOne) {
  11915. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11916. }
  11917. if m.id == nil || m.oldValue == nil {
  11918. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11919. }
  11920. oldValue, err := m.oldValue(ctx)
  11921. if err != nil {
  11922. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11923. }
  11924. return oldValue.DeletedAt, nil
  11925. }
  11926. // ClearDeletedAt clears the value of the "deleted_at" field.
  11927. func (m *ServerMutation) ClearDeletedAt() {
  11928. m.deleted_at = nil
  11929. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  11930. }
  11931. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11932. func (m *ServerMutation) DeletedAtCleared() bool {
  11933. _, ok := m.clearedFields[server.FieldDeletedAt]
  11934. return ok
  11935. }
  11936. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11937. func (m *ServerMutation) ResetDeletedAt() {
  11938. m.deleted_at = nil
  11939. delete(m.clearedFields, server.FieldDeletedAt)
  11940. }
  11941. // SetName sets the "name" field.
  11942. func (m *ServerMutation) SetName(s string) {
  11943. m.name = &s
  11944. }
  11945. // Name returns the value of the "name" field in the mutation.
  11946. func (m *ServerMutation) Name() (r string, exists bool) {
  11947. v := m.name
  11948. if v == nil {
  11949. return
  11950. }
  11951. return *v, true
  11952. }
  11953. // OldName returns the old "name" field's value of the Server entity.
  11954. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11956. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  11957. if !m.op.Is(OpUpdateOne) {
  11958. return v, errors.New("OldName is only allowed on UpdateOne operations")
  11959. }
  11960. if m.id == nil || m.oldValue == nil {
  11961. return v, errors.New("OldName requires an ID field in the mutation")
  11962. }
  11963. oldValue, err := m.oldValue(ctx)
  11964. if err != nil {
  11965. return v, fmt.Errorf("querying old value for OldName: %w", err)
  11966. }
  11967. return oldValue.Name, nil
  11968. }
  11969. // ResetName resets all changes to the "name" field.
  11970. func (m *ServerMutation) ResetName() {
  11971. m.name = nil
  11972. }
  11973. // SetPublicIP sets the "public_ip" field.
  11974. func (m *ServerMutation) SetPublicIP(s string) {
  11975. m.public_ip = &s
  11976. }
  11977. // PublicIP returns the value of the "public_ip" field in the mutation.
  11978. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  11979. v := m.public_ip
  11980. if v == nil {
  11981. return
  11982. }
  11983. return *v, true
  11984. }
  11985. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  11986. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11988. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  11989. if !m.op.Is(OpUpdateOne) {
  11990. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  11991. }
  11992. if m.id == nil || m.oldValue == nil {
  11993. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  11994. }
  11995. oldValue, err := m.oldValue(ctx)
  11996. if err != nil {
  11997. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  11998. }
  11999. return oldValue.PublicIP, nil
  12000. }
  12001. // ResetPublicIP resets all changes to the "public_ip" field.
  12002. func (m *ServerMutation) ResetPublicIP() {
  12003. m.public_ip = nil
  12004. }
  12005. // SetPrivateIP sets the "private_ip" field.
  12006. func (m *ServerMutation) SetPrivateIP(s string) {
  12007. m.private_ip = &s
  12008. }
  12009. // PrivateIP returns the value of the "private_ip" field in the mutation.
  12010. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  12011. v := m.private_ip
  12012. if v == nil {
  12013. return
  12014. }
  12015. return *v, true
  12016. }
  12017. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  12018. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  12019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12020. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  12021. if !m.op.Is(OpUpdateOne) {
  12022. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  12023. }
  12024. if m.id == nil || m.oldValue == nil {
  12025. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  12026. }
  12027. oldValue, err := m.oldValue(ctx)
  12028. if err != nil {
  12029. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  12030. }
  12031. return oldValue.PrivateIP, nil
  12032. }
  12033. // ResetPrivateIP resets all changes to the "private_ip" field.
  12034. func (m *ServerMutation) ResetPrivateIP() {
  12035. m.private_ip = nil
  12036. }
  12037. // SetAdminPort sets the "admin_port" field.
  12038. func (m *ServerMutation) SetAdminPort(s string) {
  12039. m.admin_port = &s
  12040. }
  12041. // AdminPort returns the value of the "admin_port" field in the mutation.
  12042. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  12043. v := m.admin_port
  12044. if v == nil {
  12045. return
  12046. }
  12047. return *v, true
  12048. }
  12049. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  12050. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  12051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12052. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  12053. if !m.op.Is(OpUpdateOne) {
  12054. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  12055. }
  12056. if m.id == nil || m.oldValue == nil {
  12057. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  12058. }
  12059. oldValue, err := m.oldValue(ctx)
  12060. if err != nil {
  12061. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  12062. }
  12063. return oldValue.AdminPort, nil
  12064. }
  12065. // ResetAdminPort resets all changes to the "admin_port" field.
  12066. func (m *ServerMutation) ResetAdminPort() {
  12067. m.admin_port = nil
  12068. }
  12069. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  12070. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  12071. if m.wxs == nil {
  12072. m.wxs = make(map[uint64]struct{})
  12073. }
  12074. for i := range ids {
  12075. m.wxs[ids[i]] = struct{}{}
  12076. }
  12077. }
  12078. // ClearWxs clears the "wxs" edge to the Wx entity.
  12079. func (m *ServerMutation) ClearWxs() {
  12080. m.clearedwxs = true
  12081. }
  12082. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  12083. func (m *ServerMutation) WxsCleared() bool {
  12084. return m.clearedwxs
  12085. }
  12086. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  12087. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  12088. if m.removedwxs == nil {
  12089. m.removedwxs = make(map[uint64]struct{})
  12090. }
  12091. for i := range ids {
  12092. delete(m.wxs, ids[i])
  12093. m.removedwxs[ids[i]] = struct{}{}
  12094. }
  12095. }
  12096. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  12097. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  12098. for id := range m.removedwxs {
  12099. ids = append(ids, id)
  12100. }
  12101. return
  12102. }
  12103. // WxsIDs returns the "wxs" edge IDs in the mutation.
  12104. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  12105. for id := range m.wxs {
  12106. ids = append(ids, id)
  12107. }
  12108. return
  12109. }
  12110. // ResetWxs resets all changes to the "wxs" edge.
  12111. func (m *ServerMutation) ResetWxs() {
  12112. m.wxs = nil
  12113. m.clearedwxs = false
  12114. m.removedwxs = nil
  12115. }
  12116. // Where appends a list predicates to the ServerMutation builder.
  12117. func (m *ServerMutation) Where(ps ...predicate.Server) {
  12118. m.predicates = append(m.predicates, ps...)
  12119. }
  12120. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  12121. // users can use type-assertion to append predicates that do not depend on any generated package.
  12122. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  12123. p := make([]predicate.Server, len(ps))
  12124. for i := range ps {
  12125. p[i] = ps[i]
  12126. }
  12127. m.Where(p...)
  12128. }
  12129. // Op returns the operation name.
  12130. func (m *ServerMutation) Op() Op {
  12131. return m.op
  12132. }
  12133. // SetOp allows setting the mutation operation.
  12134. func (m *ServerMutation) SetOp(op Op) {
  12135. m.op = op
  12136. }
  12137. // Type returns the node type of this mutation (Server).
  12138. func (m *ServerMutation) Type() string {
  12139. return m.typ
  12140. }
  12141. // Fields returns all fields that were changed during this mutation. Note that in
  12142. // order to get all numeric fields that were incremented/decremented, call
  12143. // AddedFields().
  12144. func (m *ServerMutation) Fields() []string {
  12145. fields := make([]string, 0, 8)
  12146. if m.created_at != nil {
  12147. fields = append(fields, server.FieldCreatedAt)
  12148. }
  12149. if m.updated_at != nil {
  12150. fields = append(fields, server.FieldUpdatedAt)
  12151. }
  12152. if m.status != nil {
  12153. fields = append(fields, server.FieldStatus)
  12154. }
  12155. if m.deleted_at != nil {
  12156. fields = append(fields, server.FieldDeletedAt)
  12157. }
  12158. if m.name != nil {
  12159. fields = append(fields, server.FieldName)
  12160. }
  12161. if m.public_ip != nil {
  12162. fields = append(fields, server.FieldPublicIP)
  12163. }
  12164. if m.private_ip != nil {
  12165. fields = append(fields, server.FieldPrivateIP)
  12166. }
  12167. if m.admin_port != nil {
  12168. fields = append(fields, server.FieldAdminPort)
  12169. }
  12170. return fields
  12171. }
  12172. // Field returns the value of a field with the given name. The second boolean
  12173. // return value indicates that this field was not set, or was not defined in the
  12174. // schema.
  12175. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  12176. switch name {
  12177. case server.FieldCreatedAt:
  12178. return m.CreatedAt()
  12179. case server.FieldUpdatedAt:
  12180. return m.UpdatedAt()
  12181. case server.FieldStatus:
  12182. return m.Status()
  12183. case server.FieldDeletedAt:
  12184. return m.DeletedAt()
  12185. case server.FieldName:
  12186. return m.Name()
  12187. case server.FieldPublicIP:
  12188. return m.PublicIP()
  12189. case server.FieldPrivateIP:
  12190. return m.PrivateIP()
  12191. case server.FieldAdminPort:
  12192. return m.AdminPort()
  12193. }
  12194. return nil, false
  12195. }
  12196. // OldField returns the old value of the field from the database. An error is
  12197. // returned if the mutation operation is not UpdateOne, or the query to the
  12198. // database failed.
  12199. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12200. switch name {
  12201. case server.FieldCreatedAt:
  12202. return m.OldCreatedAt(ctx)
  12203. case server.FieldUpdatedAt:
  12204. return m.OldUpdatedAt(ctx)
  12205. case server.FieldStatus:
  12206. return m.OldStatus(ctx)
  12207. case server.FieldDeletedAt:
  12208. return m.OldDeletedAt(ctx)
  12209. case server.FieldName:
  12210. return m.OldName(ctx)
  12211. case server.FieldPublicIP:
  12212. return m.OldPublicIP(ctx)
  12213. case server.FieldPrivateIP:
  12214. return m.OldPrivateIP(ctx)
  12215. case server.FieldAdminPort:
  12216. return m.OldAdminPort(ctx)
  12217. }
  12218. return nil, fmt.Errorf("unknown Server field %s", name)
  12219. }
  12220. // SetField sets the value of a field with the given name. It returns an error if
  12221. // the field is not defined in the schema, or if the type mismatched the field
  12222. // type.
  12223. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  12224. switch name {
  12225. case server.FieldCreatedAt:
  12226. v, ok := value.(time.Time)
  12227. if !ok {
  12228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12229. }
  12230. m.SetCreatedAt(v)
  12231. return nil
  12232. case server.FieldUpdatedAt:
  12233. v, ok := value.(time.Time)
  12234. if !ok {
  12235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12236. }
  12237. m.SetUpdatedAt(v)
  12238. return nil
  12239. case server.FieldStatus:
  12240. v, ok := value.(uint8)
  12241. if !ok {
  12242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12243. }
  12244. m.SetStatus(v)
  12245. return nil
  12246. case server.FieldDeletedAt:
  12247. v, ok := value.(time.Time)
  12248. if !ok {
  12249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12250. }
  12251. m.SetDeletedAt(v)
  12252. return nil
  12253. case server.FieldName:
  12254. v, ok := value.(string)
  12255. if !ok {
  12256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12257. }
  12258. m.SetName(v)
  12259. return nil
  12260. case server.FieldPublicIP:
  12261. v, ok := value.(string)
  12262. if !ok {
  12263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12264. }
  12265. m.SetPublicIP(v)
  12266. return nil
  12267. case server.FieldPrivateIP:
  12268. v, ok := value.(string)
  12269. if !ok {
  12270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12271. }
  12272. m.SetPrivateIP(v)
  12273. return nil
  12274. case server.FieldAdminPort:
  12275. v, ok := value.(string)
  12276. if !ok {
  12277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12278. }
  12279. m.SetAdminPort(v)
  12280. return nil
  12281. }
  12282. return fmt.Errorf("unknown Server field %s", name)
  12283. }
  12284. // AddedFields returns all numeric fields that were incremented/decremented during
  12285. // this mutation.
  12286. func (m *ServerMutation) AddedFields() []string {
  12287. var fields []string
  12288. if m.addstatus != nil {
  12289. fields = append(fields, server.FieldStatus)
  12290. }
  12291. return fields
  12292. }
  12293. // AddedField returns the numeric value that was incremented/decremented on a field
  12294. // with the given name. The second boolean return value indicates that this field
  12295. // was not set, or was not defined in the schema.
  12296. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  12297. switch name {
  12298. case server.FieldStatus:
  12299. return m.AddedStatus()
  12300. }
  12301. return nil, false
  12302. }
  12303. // AddField adds the value to the field with the given name. It returns an error if
  12304. // the field is not defined in the schema, or if the type mismatched the field
  12305. // type.
  12306. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  12307. switch name {
  12308. case server.FieldStatus:
  12309. v, ok := value.(int8)
  12310. if !ok {
  12311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12312. }
  12313. m.AddStatus(v)
  12314. return nil
  12315. }
  12316. return fmt.Errorf("unknown Server numeric field %s", name)
  12317. }
  12318. // ClearedFields returns all nullable fields that were cleared during this
  12319. // mutation.
  12320. func (m *ServerMutation) ClearedFields() []string {
  12321. var fields []string
  12322. if m.FieldCleared(server.FieldStatus) {
  12323. fields = append(fields, server.FieldStatus)
  12324. }
  12325. if m.FieldCleared(server.FieldDeletedAt) {
  12326. fields = append(fields, server.FieldDeletedAt)
  12327. }
  12328. return fields
  12329. }
  12330. // FieldCleared returns a boolean indicating if a field with the given name was
  12331. // cleared in this mutation.
  12332. func (m *ServerMutation) FieldCleared(name string) bool {
  12333. _, ok := m.clearedFields[name]
  12334. return ok
  12335. }
  12336. // ClearField clears the value of the field with the given name. It returns an
  12337. // error if the field is not defined in the schema.
  12338. func (m *ServerMutation) ClearField(name string) error {
  12339. switch name {
  12340. case server.FieldStatus:
  12341. m.ClearStatus()
  12342. return nil
  12343. case server.FieldDeletedAt:
  12344. m.ClearDeletedAt()
  12345. return nil
  12346. }
  12347. return fmt.Errorf("unknown Server nullable field %s", name)
  12348. }
  12349. // ResetField resets all changes in the mutation for the field with the given name.
  12350. // It returns an error if the field is not defined in the schema.
  12351. func (m *ServerMutation) ResetField(name string) error {
  12352. switch name {
  12353. case server.FieldCreatedAt:
  12354. m.ResetCreatedAt()
  12355. return nil
  12356. case server.FieldUpdatedAt:
  12357. m.ResetUpdatedAt()
  12358. return nil
  12359. case server.FieldStatus:
  12360. m.ResetStatus()
  12361. return nil
  12362. case server.FieldDeletedAt:
  12363. m.ResetDeletedAt()
  12364. return nil
  12365. case server.FieldName:
  12366. m.ResetName()
  12367. return nil
  12368. case server.FieldPublicIP:
  12369. m.ResetPublicIP()
  12370. return nil
  12371. case server.FieldPrivateIP:
  12372. m.ResetPrivateIP()
  12373. return nil
  12374. case server.FieldAdminPort:
  12375. m.ResetAdminPort()
  12376. return nil
  12377. }
  12378. return fmt.Errorf("unknown Server field %s", name)
  12379. }
  12380. // AddedEdges returns all edge names that were set/added in this mutation.
  12381. func (m *ServerMutation) AddedEdges() []string {
  12382. edges := make([]string, 0, 1)
  12383. if m.wxs != nil {
  12384. edges = append(edges, server.EdgeWxs)
  12385. }
  12386. return edges
  12387. }
  12388. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12389. // name in this mutation.
  12390. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  12391. switch name {
  12392. case server.EdgeWxs:
  12393. ids := make([]ent.Value, 0, len(m.wxs))
  12394. for id := range m.wxs {
  12395. ids = append(ids, id)
  12396. }
  12397. return ids
  12398. }
  12399. return nil
  12400. }
  12401. // RemovedEdges returns all edge names that were removed in this mutation.
  12402. func (m *ServerMutation) RemovedEdges() []string {
  12403. edges := make([]string, 0, 1)
  12404. if m.removedwxs != nil {
  12405. edges = append(edges, server.EdgeWxs)
  12406. }
  12407. return edges
  12408. }
  12409. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12410. // the given name in this mutation.
  12411. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  12412. switch name {
  12413. case server.EdgeWxs:
  12414. ids := make([]ent.Value, 0, len(m.removedwxs))
  12415. for id := range m.removedwxs {
  12416. ids = append(ids, id)
  12417. }
  12418. return ids
  12419. }
  12420. return nil
  12421. }
  12422. // ClearedEdges returns all edge names that were cleared in this mutation.
  12423. func (m *ServerMutation) ClearedEdges() []string {
  12424. edges := make([]string, 0, 1)
  12425. if m.clearedwxs {
  12426. edges = append(edges, server.EdgeWxs)
  12427. }
  12428. return edges
  12429. }
  12430. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12431. // was cleared in this mutation.
  12432. func (m *ServerMutation) EdgeCleared(name string) bool {
  12433. switch name {
  12434. case server.EdgeWxs:
  12435. return m.clearedwxs
  12436. }
  12437. return false
  12438. }
  12439. // ClearEdge clears the value of the edge with the given name. It returns an error
  12440. // if that edge is not defined in the schema.
  12441. func (m *ServerMutation) ClearEdge(name string) error {
  12442. switch name {
  12443. }
  12444. return fmt.Errorf("unknown Server unique edge %s", name)
  12445. }
  12446. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12447. // It returns an error if the edge is not defined in the schema.
  12448. func (m *ServerMutation) ResetEdge(name string) error {
  12449. switch name {
  12450. case server.EdgeWxs:
  12451. m.ResetWxs()
  12452. return nil
  12453. }
  12454. return fmt.Errorf("unknown Server edge %s", name)
  12455. }
  12456. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  12457. type SopNodeMutation struct {
  12458. config
  12459. op Op
  12460. typ string
  12461. id *uint64
  12462. created_at *time.Time
  12463. updated_at *time.Time
  12464. status *uint8
  12465. addstatus *int8
  12466. deleted_at *time.Time
  12467. parent_id *uint64
  12468. addparent_id *int64
  12469. name *string
  12470. condition_type *int
  12471. addcondition_type *int
  12472. condition_list *[]string
  12473. appendcondition_list []string
  12474. no_reply_condition *uint64
  12475. addno_reply_condition *int64
  12476. action_message *[]custom_types.Action
  12477. appendaction_message []custom_types.Action
  12478. action_label *[]uint64
  12479. appendaction_label []uint64
  12480. clearedFields map[string]struct{}
  12481. sop_stage *uint64
  12482. clearedsop_stage bool
  12483. node_messages map[uint64]struct{}
  12484. removednode_messages map[uint64]struct{}
  12485. clearednode_messages bool
  12486. done bool
  12487. oldValue func(context.Context) (*SopNode, error)
  12488. predicates []predicate.SopNode
  12489. }
  12490. var _ ent.Mutation = (*SopNodeMutation)(nil)
  12491. // sopnodeOption allows management of the mutation configuration using functional options.
  12492. type sopnodeOption func(*SopNodeMutation)
  12493. // newSopNodeMutation creates new mutation for the SopNode entity.
  12494. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  12495. m := &SopNodeMutation{
  12496. config: c,
  12497. op: op,
  12498. typ: TypeSopNode,
  12499. clearedFields: make(map[string]struct{}),
  12500. }
  12501. for _, opt := range opts {
  12502. opt(m)
  12503. }
  12504. return m
  12505. }
  12506. // withSopNodeID sets the ID field of the mutation.
  12507. func withSopNodeID(id uint64) sopnodeOption {
  12508. return func(m *SopNodeMutation) {
  12509. var (
  12510. err error
  12511. once sync.Once
  12512. value *SopNode
  12513. )
  12514. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  12515. once.Do(func() {
  12516. if m.done {
  12517. err = errors.New("querying old values post mutation is not allowed")
  12518. } else {
  12519. value, err = m.Client().SopNode.Get(ctx, id)
  12520. }
  12521. })
  12522. return value, err
  12523. }
  12524. m.id = &id
  12525. }
  12526. }
  12527. // withSopNode sets the old SopNode of the mutation.
  12528. func withSopNode(node *SopNode) sopnodeOption {
  12529. return func(m *SopNodeMutation) {
  12530. m.oldValue = func(context.Context) (*SopNode, error) {
  12531. return node, nil
  12532. }
  12533. m.id = &node.ID
  12534. }
  12535. }
  12536. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12537. // executed in a transaction (ent.Tx), a transactional client is returned.
  12538. func (m SopNodeMutation) Client() *Client {
  12539. client := &Client{config: m.config}
  12540. client.init()
  12541. return client
  12542. }
  12543. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12544. // it returns an error otherwise.
  12545. func (m SopNodeMutation) Tx() (*Tx, error) {
  12546. if _, ok := m.driver.(*txDriver); !ok {
  12547. return nil, errors.New("ent: mutation is not running in a transaction")
  12548. }
  12549. tx := &Tx{config: m.config}
  12550. tx.init()
  12551. return tx, nil
  12552. }
  12553. // SetID sets the value of the id field. Note that this
  12554. // operation is only accepted on creation of SopNode entities.
  12555. func (m *SopNodeMutation) SetID(id uint64) {
  12556. m.id = &id
  12557. }
  12558. // ID returns the ID value in the mutation. Note that the ID is only available
  12559. // if it was provided to the builder or after it was returned from the database.
  12560. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  12561. if m.id == nil {
  12562. return
  12563. }
  12564. return *m.id, true
  12565. }
  12566. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12567. // That means, if the mutation is applied within a transaction with an isolation level such
  12568. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12569. // or updated by the mutation.
  12570. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  12571. switch {
  12572. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12573. id, exists := m.ID()
  12574. if exists {
  12575. return []uint64{id}, nil
  12576. }
  12577. fallthrough
  12578. case m.op.Is(OpUpdate | OpDelete):
  12579. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  12580. default:
  12581. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12582. }
  12583. }
  12584. // SetCreatedAt sets the "created_at" field.
  12585. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  12586. m.created_at = &t
  12587. }
  12588. // CreatedAt returns the value of the "created_at" field in the mutation.
  12589. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  12590. v := m.created_at
  12591. if v == nil {
  12592. return
  12593. }
  12594. return *v, true
  12595. }
  12596. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  12597. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12599. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12600. if !m.op.Is(OpUpdateOne) {
  12601. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12602. }
  12603. if m.id == nil || m.oldValue == nil {
  12604. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12605. }
  12606. oldValue, err := m.oldValue(ctx)
  12607. if err != nil {
  12608. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12609. }
  12610. return oldValue.CreatedAt, nil
  12611. }
  12612. // ResetCreatedAt resets all changes to the "created_at" field.
  12613. func (m *SopNodeMutation) ResetCreatedAt() {
  12614. m.created_at = nil
  12615. }
  12616. // SetUpdatedAt sets the "updated_at" field.
  12617. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  12618. m.updated_at = &t
  12619. }
  12620. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12621. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  12622. v := m.updated_at
  12623. if v == nil {
  12624. return
  12625. }
  12626. return *v, true
  12627. }
  12628. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  12629. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12631. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12632. if !m.op.Is(OpUpdateOne) {
  12633. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12634. }
  12635. if m.id == nil || m.oldValue == nil {
  12636. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12637. }
  12638. oldValue, err := m.oldValue(ctx)
  12639. if err != nil {
  12640. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12641. }
  12642. return oldValue.UpdatedAt, nil
  12643. }
  12644. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12645. func (m *SopNodeMutation) ResetUpdatedAt() {
  12646. m.updated_at = nil
  12647. }
  12648. // SetStatus sets the "status" field.
  12649. func (m *SopNodeMutation) SetStatus(u uint8) {
  12650. m.status = &u
  12651. m.addstatus = nil
  12652. }
  12653. // Status returns the value of the "status" field in the mutation.
  12654. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  12655. v := m.status
  12656. if v == nil {
  12657. return
  12658. }
  12659. return *v, true
  12660. }
  12661. // OldStatus returns the old "status" field's value of the SopNode entity.
  12662. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12664. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12665. if !m.op.Is(OpUpdateOne) {
  12666. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12667. }
  12668. if m.id == nil || m.oldValue == nil {
  12669. return v, errors.New("OldStatus requires an ID field in the mutation")
  12670. }
  12671. oldValue, err := m.oldValue(ctx)
  12672. if err != nil {
  12673. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12674. }
  12675. return oldValue.Status, nil
  12676. }
  12677. // AddStatus adds u to the "status" field.
  12678. func (m *SopNodeMutation) AddStatus(u int8) {
  12679. if m.addstatus != nil {
  12680. *m.addstatus += u
  12681. } else {
  12682. m.addstatus = &u
  12683. }
  12684. }
  12685. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12686. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  12687. v := m.addstatus
  12688. if v == nil {
  12689. return
  12690. }
  12691. return *v, true
  12692. }
  12693. // ClearStatus clears the value of the "status" field.
  12694. func (m *SopNodeMutation) ClearStatus() {
  12695. m.status = nil
  12696. m.addstatus = nil
  12697. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  12698. }
  12699. // StatusCleared returns if the "status" field was cleared in this mutation.
  12700. func (m *SopNodeMutation) StatusCleared() bool {
  12701. _, ok := m.clearedFields[sopnode.FieldStatus]
  12702. return ok
  12703. }
  12704. // ResetStatus resets all changes to the "status" field.
  12705. func (m *SopNodeMutation) ResetStatus() {
  12706. m.status = nil
  12707. m.addstatus = nil
  12708. delete(m.clearedFields, sopnode.FieldStatus)
  12709. }
  12710. // SetDeletedAt sets the "deleted_at" field.
  12711. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  12712. m.deleted_at = &t
  12713. }
  12714. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12715. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  12716. v := m.deleted_at
  12717. if v == nil {
  12718. return
  12719. }
  12720. return *v, true
  12721. }
  12722. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  12723. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12724. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12725. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12726. if !m.op.Is(OpUpdateOne) {
  12727. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12728. }
  12729. if m.id == nil || m.oldValue == nil {
  12730. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12731. }
  12732. oldValue, err := m.oldValue(ctx)
  12733. if err != nil {
  12734. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12735. }
  12736. return oldValue.DeletedAt, nil
  12737. }
  12738. // ClearDeletedAt clears the value of the "deleted_at" field.
  12739. func (m *SopNodeMutation) ClearDeletedAt() {
  12740. m.deleted_at = nil
  12741. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  12742. }
  12743. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12744. func (m *SopNodeMutation) DeletedAtCleared() bool {
  12745. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  12746. return ok
  12747. }
  12748. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12749. func (m *SopNodeMutation) ResetDeletedAt() {
  12750. m.deleted_at = nil
  12751. delete(m.clearedFields, sopnode.FieldDeletedAt)
  12752. }
  12753. // SetStageID sets the "stage_id" field.
  12754. func (m *SopNodeMutation) SetStageID(u uint64) {
  12755. m.sop_stage = &u
  12756. }
  12757. // StageID returns the value of the "stage_id" field in the mutation.
  12758. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  12759. v := m.sop_stage
  12760. if v == nil {
  12761. return
  12762. }
  12763. return *v, true
  12764. }
  12765. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  12766. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12768. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  12769. if !m.op.Is(OpUpdateOne) {
  12770. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  12771. }
  12772. if m.id == nil || m.oldValue == nil {
  12773. return v, errors.New("OldStageID requires an ID field in the mutation")
  12774. }
  12775. oldValue, err := m.oldValue(ctx)
  12776. if err != nil {
  12777. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  12778. }
  12779. return oldValue.StageID, nil
  12780. }
  12781. // ResetStageID resets all changes to the "stage_id" field.
  12782. func (m *SopNodeMutation) ResetStageID() {
  12783. m.sop_stage = nil
  12784. }
  12785. // SetParentID sets the "parent_id" field.
  12786. func (m *SopNodeMutation) SetParentID(u uint64) {
  12787. m.parent_id = &u
  12788. m.addparent_id = nil
  12789. }
  12790. // ParentID returns the value of the "parent_id" field in the mutation.
  12791. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  12792. v := m.parent_id
  12793. if v == nil {
  12794. return
  12795. }
  12796. return *v, true
  12797. }
  12798. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  12799. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12801. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  12802. if !m.op.Is(OpUpdateOne) {
  12803. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  12804. }
  12805. if m.id == nil || m.oldValue == nil {
  12806. return v, errors.New("OldParentID requires an ID field in the mutation")
  12807. }
  12808. oldValue, err := m.oldValue(ctx)
  12809. if err != nil {
  12810. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  12811. }
  12812. return oldValue.ParentID, nil
  12813. }
  12814. // AddParentID adds u to the "parent_id" field.
  12815. func (m *SopNodeMutation) AddParentID(u int64) {
  12816. if m.addparent_id != nil {
  12817. *m.addparent_id += u
  12818. } else {
  12819. m.addparent_id = &u
  12820. }
  12821. }
  12822. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  12823. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  12824. v := m.addparent_id
  12825. if v == nil {
  12826. return
  12827. }
  12828. return *v, true
  12829. }
  12830. // ResetParentID resets all changes to the "parent_id" field.
  12831. func (m *SopNodeMutation) ResetParentID() {
  12832. m.parent_id = nil
  12833. m.addparent_id = nil
  12834. }
  12835. // SetName sets the "name" field.
  12836. func (m *SopNodeMutation) SetName(s string) {
  12837. m.name = &s
  12838. }
  12839. // Name returns the value of the "name" field in the mutation.
  12840. func (m *SopNodeMutation) Name() (r string, exists bool) {
  12841. v := m.name
  12842. if v == nil {
  12843. return
  12844. }
  12845. return *v, true
  12846. }
  12847. // OldName returns the old "name" field's value of the SopNode entity.
  12848. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12849. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12850. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  12851. if !m.op.Is(OpUpdateOne) {
  12852. return v, errors.New("OldName is only allowed on UpdateOne operations")
  12853. }
  12854. if m.id == nil || m.oldValue == nil {
  12855. return v, errors.New("OldName requires an ID field in the mutation")
  12856. }
  12857. oldValue, err := m.oldValue(ctx)
  12858. if err != nil {
  12859. return v, fmt.Errorf("querying old value for OldName: %w", err)
  12860. }
  12861. return oldValue.Name, nil
  12862. }
  12863. // ResetName resets all changes to the "name" field.
  12864. func (m *SopNodeMutation) ResetName() {
  12865. m.name = nil
  12866. }
  12867. // SetConditionType sets the "condition_type" field.
  12868. func (m *SopNodeMutation) SetConditionType(i int) {
  12869. m.condition_type = &i
  12870. m.addcondition_type = nil
  12871. }
  12872. // ConditionType returns the value of the "condition_type" field in the mutation.
  12873. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  12874. v := m.condition_type
  12875. if v == nil {
  12876. return
  12877. }
  12878. return *v, true
  12879. }
  12880. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  12881. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12882. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12883. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  12884. if !m.op.Is(OpUpdateOne) {
  12885. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  12886. }
  12887. if m.id == nil || m.oldValue == nil {
  12888. return v, errors.New("OldConditionType requires an ID field in the mutation")
  12889. }
  12890. oldValue, err := m.oldValue(ctx)
  12891. if err != nil {
  12892. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  12893. }
  12894. return oldValue.ConditionType, nil
  12895. }
  12896. // AddConditionType adds i to the "condition_type" field.
  12897. func (m *SopNodeMutation) AddConditionType(i int) {
  12898. if m.addcondition_type != nil {
  12899. *m.addcondition_type += i
  12900. } else {
  12901. m.addcondition_type = &i
  12902. }
  12903. }
  12904. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  12905. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  12906. v := m.addcondition_type
  12907. if v == nil {
  12908. return
  12909. }
  12910. return *v, true
  12911. }
  12912. // ResetConditionType resets all changes to the "condition_type" field.
  12913. func (m *SopNodeMutation) ResetConditionType() {
  12914. m.condition_type = nil
  12915. m.addcondition_type = nil
  12916. }
  12917. // SetConditionList sets the "condition_list" field.
  12918. func (m *SopNodeMutation) SetConditionList(s []string) {
  12919. m.condition_list = &s
  12920. m.appendcondition_list = nil
  12921. }
  12922. // ConditionList returns the value of the "condition_list" field in the mutation.
  12923. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  12924. v := m.condition_list
  12925. if v == nil {
  12926. return
  12927. }
  12928. return *v, true
  12929. }
  12930. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  12931. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12933. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  12934. if !m.op.Is(OpUpdateOne) {
  12935. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  12936. }
  12937. if m.id == nil || m.oldValue == nil {
  12938. return v, errors.New("OldConditionList requires an ID field in the mutation")
  12939. }
  12940. oldValue, err := m.oldValue(ctx)
  12941. if err != nil {
  12942. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  12943. }
  12944. return oldValue.ConditionList, nil
  12945. }
  12946. // AppendConditionList adds s to the "condition_list" field.
  12947. func (m *SopNodeMutation) AppendConditionList(s []string) {
  12948. m.appendcondition_list = append(m.appendcondition_list, s...)
  12949. }
  12950. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  12951. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  12952. if len(m.appendcondition_list) == 0 {
  12953. return nil, false
  12954. }
  12955. return m.appendcondition_list, true
  12956. }
  12957. // ClearConditionList clears the value of the "condition_list" field.
  12958. func (m *SopNodeMutation) ClearConditionList() {
  12959. m.condition_list = nil
  12960. m.appendcondition_list = nil
  12961. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  12962. }
  12963. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  12964. func (m *SopNodeMutation) ConditionListCleared() bool {
  12965. _, ok := m.clearedFields[sopnode.FieldConditionList]
  12966. return ok
  12967. }
  12968. // ResetConditionList resets all changes to the "condition_list" field.
  12969. func (m *SopNodeMutation) ResetConditionList() {
  12970. m.condition_list = nil
  12971. m.appendcondition_list = nil
  12972. delete(m.clearedFields, sopnode.FieldConditionList)
  12973. }
  12974. // SetNoReplyCondition sets the "no_reply_condition" field.
  12975. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  12976. m.no_reply_condition = &u
  12977. m.addno_reply_condition = nil
  12978. }
  12979. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  12980. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  12981. v := m.no_reply_condition
  12982. if v == nil {
  12983. return
  12984. }
  12985. return *v, true
  12986. }
  12987. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  12988. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12990. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  12991. if !m.op.Is(OpUpdateOne) {
  12992. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  12993. }
  12994. if m.id == nil || m.oldValue == nil {
  12995. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  12996. }
  12997. oldValue, err := m.oldValue(ctx)
  12998. if err != nil {
  12999. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  13000. }
  13001. return oldValue.NoReplyCondition, nil
  13002. }
  13003. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  13004. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  13005. if m.addno_reply_condition != nil {
  13006. *m.addno_reply_condition += u
  13007. } else {
  13008. m.addno_reply_condition = &u
  13009. }
  13010. }
  13011. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  13012. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  13013. v := m.addno_reply_condition
  13014. if v == nil {
  13015. return
  13016. }
  13017. return *v, true
  13018. }
  13019. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  13020. func (m *SopNodeMutation) ResetNoReplyCondition() {
  13021. m.no_reply_condition = nil
  13022. m.addno_reply_condition = nil
  13023. }
  13024. // SetActionMessage sets the "action_message" field.
  13025. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  13026. m.action_message = &ct
  13027. m.appendaction_message = nil
  13028. }
  13029. // ActionMessage returns the value of the "action_message" field in the mutation.
  13030. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  13031. v := m.action_message
  13032. if v == nil {
  13033. return
  13034. }
  13035. return *v, true
  13036. }
  13037. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  13038. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  13039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13040. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  13041. if !m.op.Is(OpUpdateOne) {
  13042. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  13043. }
  13044. if m.id == nil || m.oldValue == nil {
  13045. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  13046. }
  13047. oldValue, err := m.oldValue(ctx)
  13048. if err != nil {
  13049. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  13050. }
  13051. return oldValue.ActionMessage, nil
  13052. }
  13053. // AppendActionMessage adds ct to the "action_message" field.
  13054. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  13055. m.appendaction_message = append(m.appendaction_message, ct...)
  13056. }
  13057. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  13058. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  13059. if len(m.appendaction_message) == 0 {
  13060. return nil, false
  13061. }
  13062. return m.appendaction_message, true
  13063. }
  13064. // ClearActionMessage clears the value of the "action_message" field.
  13065. func (m *SopNodeMutation) ClearActionMessage() {
  13066. m.action_message = nil
  13067. m.appendaction_message = nil
  13068. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  13069. }
  13070. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  13071. func (m *SopNodeMutation) ActionMessageCleared() bool {
  13072. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  13073. return ok
  13074. }
  13075. // ResetActionMessage resets all changes to the "action_message" field.
  13076. func (m *SopNodeMutation) ResetActionMessage() {
  13077. m.action_message = nil
  13078. m.appendaction_message = nil
  13079. delete(m.clearedFields, sopnode.FieldActionMessage)
  13080. }
  13081. // SetActionLabel sets the "action_label" field.
  13082. func (m *SopNodeMutation) SetActionLabel(u []uint64) {
  13083. m.action_label = &u
  13084. m.appendaction_label = nil
  13085. }
  13086. // ActionLabel returns the value of the "action_label" field in the mutation.
  13087. func (m *SopNodeMutation) ActionLabel() (r []uint64, exists bool) {
  13088. v := m.action_label
  13089. if v == nil {
  13090. return
  13091. }
  13092. return *v, true
  13093. }
  13094. // OldActionLabel returns the old "action_label" field's value of the SopNode entity.
  13095. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  13096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13097. func (m *SopNodeMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  13098. if !m.op.Is(OpUpdateOne) {
  13099. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  13100. }
  13101. if m.id == nil || m.oldValue == nil {
  13102. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  13103. }
  13104. oldValue, err := m.oldValue(ctx)
  13105. if err != nil {
  13106. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  13107. }
  13108. return oldValue.ActionLabel, nil
  13109. }
  13110. // AppendActionLabel adds u to the "action_label" field.
  13111. func (m *SopNodeMutation) AppendActionLabel(u []uint64) {
  13112. m.appendaction_label = append(m.appendaction_label, u...)
  13113. }
  13114. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  13115. func (m *SopNodeMutation) AppendedActionLabel() ([]uint64, bool) {
  13116. if len(m.appendaction_label) == 0 {
  13117. return nil, false
  13118. }
  13119. return m.appendaction_label, true
  13120. }
  13121. // ClearActionLabel clears the value of the "action_label" field.
  13122. func (m *SopNodeMutation) ClearActionLabel() {
  13123. m.action_label = nil
  13124. m.appendaction_label = nil
  13125. m.clearedFields[sopnode.FieldActionLabel] = struct{}{}
  13126. }
  13127. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  13128. func (m *SopNodeMutation) ActionLabelCleared() bool {
  13129. _, ok := m.clearedFields[sopnode.FieldActionLabel]
  13130. return ok
  13131. }
  13132. // ResetActionLabel resets all changes to the "action_label" field.
  13133. func (m *SopNodeMutation) ResetActionLabel() {
  13134. m.action_label = nil
  13135. m.appendaction_label = nil
  13136. delete(m.clearedFields, sopnode.FieldActionLabel)
  13137. }
  13138. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  13139. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  13140. m.sop_stage = &id
  13141. }
  13142. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  13143. func (m *SopNodeMutation) ClearSopStage() {
  13144. m.clearedsop_stage = true
  13145. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  13146. }
  13147. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  13148. func (m *SopNodeMutation) SopStageCleared() bool {
  13149. return m.clearedsop_stage
  13150. }
  13151. // SopStageID returns the "sop_stage" edge ID in the mutation.
  13152. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  13153. if m.sop_stage != nil {
  13154. return *m.sop_stage, true
  13155. }
  13156. return
  13157. }
  13158. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  13159. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13160. // SopStageID instead. It exists only for internal usage by the builders.
  13161. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  13162. if id := m.sop_stage; id != nil {
  13163. ids = append(ids, *id)
  13164. }
  13165. return
  13166. }
  13167. // ResetSopStage resets all changes to the "sop_stage" edge.
  13168. func (m *SopNodeMutation) ResetSopStage() {
  13169. m.sop_stage = nil
  13170. m.clearedsop_stage = false
  13171. }
  13172. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  13173. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  13174. if m.node_messages == nil {
  13175. m.node_messages = make(map[uint64]struct{})
  13176. }
  13177. for i := range ids {
  13178. m.node_messages[ids[i]] = struct{}{}
  13179. }
  13180. }
  13181. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  13182. func (m *SopNodeMutation) ClearNodeMessages() {
  13183. m.clearednode_messages = true
  13184. }
  13185. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  13186. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  13187. return m.clearednode_messages
  13188. }
  13189. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  13190. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  13191. if m.removednode_messages == nil {
  13192. m.removednode_messages = make(map[uint64]struct{})
  13193. }
  13194. for i := range ids {
  13195. delete(m.node_messages, ids[i])
  13196. m.removednode_messages[ids[i]] = struct{}{}
  13197. }
  13198. }
  13199. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  13200. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  13201. for id := range m.removednode_messages {
  13202. ids = append(ids, id)
  13203. }
  13204. return
  13205. }
  13206. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  13207. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  13208. for id := range m.node_messages {
  13209. ids = append(ids, id)
  13210. }
  13211. return
  13212. }
  13213. // ResetNodeMessages resets all changes to the "node_messages" edge.
  13214. func (m *SopNodeMutation) ResetNodeMessages() {
  13215. m.node_messages = nil
  13216. m.clearednode_messages = false
  13217. m.removednode_messages = nil
  13218. }
  13219. // Where appends a list predicates to the SopNodeMutation builder.
  13220. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  13221. m.predicates = append(m.predicates, ps...)
  13222. }
  13223. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  13224. // users can use type-assertion to append predicates that do not depend on any generated package.
  13225. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  13226. p := make([]predicate.SopNode, len(ps))
  13227. for i := range ps {
  13228. p[i] = ps[i]
  13229. }
  13230. m.Where(p...)
  13231. }
  13232. // Op returns the operation name.
  13233. func (m *SopNodeMutation) Op() Op {
  13234. return m.op
  13235. }
  13236. // SetOp allows setting the mutation operation.
  13237. func (m *SopNodeMutation) SetOp(op Op) {
  13238. m.op = op
  13239. }
  13240. // Type returns the node type of this mutation (SopNode).
  13241. func (m *SopNodeMutation) Type() string {
  13242. return m.typ
  13243. }
  13244. // Fields returns all fields that were changed during this mutation. Note that in
  13245. // order to get all numeric fields that were incremented/decremented, call
  13246. // AddedFields().
  13247. func (m *SopNodeMutation) Fields() []string {
  13248. fields := make([]string, 0, 12)
  13249. if m.created_at != nil {
  13250. fields = append(fields, sopnode.FieldCreatedAt)
  13251. }
  13252. if m.updated_at != nil {
  13253. fields = append(fields, sopnode.FieldUpdatedAt)
  13254. }
  13255. if m.status != nil {
  13256. fields = append(fields, sopnode.FieldStatus)
  13257. }
  13258. if m.deleted_at != nil {
  13259. fields = append(fields, sopnode.FieldDeletedAt)
  13260. }
  13261. if m.sop_stage != nil {
  13262. fields = append(fields, sopnode.FieldStageID)
  13263. }
  13264. if m.parent_id != nil {
  13265. fields = append(fields, sopnode.FieldParentID)
  13266. }
  13267. if m.name != nil {
  13268. fields = append(fields, sopnode.FieldName)
  13269. }
  13270. if m.condition_type != nil {
  13271. fields = append(fields, sopnode.FieldConditionType)
  13272. }
  13273. if m.condition_list != nil {
  13274. fields = append(fields, sopnode.FieldConditionList)
  13275. }
  13276. if m.no_reply_condition != nil {
  13277. fields = append(fields, sopnode.FieldNoReplyCondition)
  13278. }
  13279. if m.action_message != nil {
  13280. fields = append(fields, sopnode.FieldActionMessage)
  13281. }
  13282. if m.action_label != nil {
  13283. fields = append(fields, sopnode.FieldActionLabel)
  13284. }
  13285. return fields
  13286. }
  13287. // Field returns the value of a field with the given name. The second boolean
  13288. // return value indicates that this field was not set, or was not defined in the
  13289. // schema.
  13290. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  13291. switch name {
  13292. case sopnode.FieldCreatedAt:
  13293. return m.CreatedAt()
  13294. case sopnode.FieldUpdatedAt:
  13295. return m.UpdatedAt()
  13296. case sopnode.FieldStatus:
  13297. return m.Status()
  13298. case sopnode.FieldDeletedAt:
  13299. return m.DeletedAt()
  13300. case sopnode.FieldStageID:
  13301. return m.StageID()
  13302. case sopnode.FieldParentID:
  13303. return m.ParentID()
  13304. case sopnode.FieldName:
  13305. return m.Name()
  13306. case sopnode.FieldConditionType:
  13307. return m.ConditionType()
  13308. case sopnode.FieldConditionList:
  13309. return m.ConditionList()
  13310. case sopnode.FieldNoReplyCondition:
  13311. return m.NoReplyCondition()
  13312. case sopnode.FieldActionMessage:
  13313. return m.ActionMessage()
  13314. case sopnode.FieldActionLabel:
  13315. return m.ActionLabel()
  13316. }
  13317. return nil, false
  13318. }
  13319. // OldField returns the old value of the field from the database. An error is
  13320. // returned if the mutation operation is not UpdateOne, or the query to the
  13321. // database failed.
  13322. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13323. switch name {
  13324. case sopnode.FieldCreatedAt:
  13325. return m.OldCreatedAt(ctx)
  13326. case sopnode.FieldUpdatedAt:
  13327. return m.OldUpdatedAt(ctx)
  13328. case sopnode.FieldStatus:
  13329. return m.OldStatus(ctx)
  13330. case sopnode.FieldDeletedAt:
  13331. return m.OldDeletedAt(ctx)
  13332. case sopnode.FieldStageID:
  13333. return m.OldStageID(ctx)
  13334. case sopnode.FieldParentID:
  13335. return m.OldParentID(ctx)
  13336. case sopnode.FieldName:
  13337. return m.OldName(ctx)
  13338. case sopnode.FieldConditionType:
  13339. return m.OldConditionType(ctx)
  13340. case sopnode.FieldConditionList:
  13341. return m.OldConditionList(ctx)
  13342. case sopnode.FieldNoReplyCondition:
  13343. return m.OldNoReplyCondition(ctx)
  13344. case sopnode.FieldActionMessage:
  13345. return m.OldActionMessage(ctx)
  13346. case sopnode.FieldActionLabel:
  13347. return m.OldActionLabel(ctx)
  13348. }
  13349. return nil, fmt.Errorf("unknown SopNode field %s", name)
  13350. }
  13351. // SetField sets the value of a field with the given name. It returns an error if
  13352. // the field is not defined in the schema, or if the type mismatched the field
  13353. // type.
  13354. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  13355. switch name {
  13356. case sopnode.FieldCreatedAt:
  13357. v, ok := value.(time.Time)
  13358. if !ok {
  13359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13360. }
  13361. m.SetCreatedAt(v)
  13362. return nil
  13363. case sopnode.FieldUpdatedAt:
  13364. v, ok := value.(time.Time)
  13365. if !ok {
  13366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13367. }
  13368. m.SetUpdatedAt(v)
  13369. return nil
  13370. case sopnode.FieldStatus:
  13371. v, ok := value.(uint8)
  13372. if !ok {
  13373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13374. }
  13375. m.SetStatus(v)
  13376. return nil
  13377. case sopnode.FieldDeletedAt:
  13378. v, ok := value.(time.Time)
  13379. if !ok {
  13380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13381. }
  13382. m.SetDeletedAt(v)
  13383. return nil
  13384. case sopnode.FieldStageID:
  13385. v, ok := value.(uint64)
  13386. if !ok {
  13387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13388. }
  13389. m.SetStageID(v)
  13390. return nil
  13391. case sopnode.FieldParentID:
  13392. v, ok := value.(uint64)
  13393. if !ok {
  13394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13395. }
  13396. m.SetParentID(v)
  13397. return nil
  13398. case sopnode.FieldName:
  13399. v, ok := value.(string)
  13400. if !ok {
  13401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13402. }
  13403. m.SetName(v)
  13404. return nil
  13405. case sopnode.FieldConditionType:
  13406. v, ok := value.(int)
  13407. if !ok {
  13408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13409. }
  13410. m.SetConditionType(v)
  13411. return nil
  13412. case sopnode.FieldConditionList:
  13413. v, ok := value.([]string)
  13414. if !ok {
  13415. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13416. }
  13417. m.SetConditionList(v)
  13418. return nil
  13419. case sopnode.FieldNoReplyCondition:
  13420. v, ok := value.(uint64)
  13421. if !ok {
  13422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13423. }
  13424. m.SetNoReplyCondition(v)
  13425. return nil
  13426. case sopnode.FieldActionMessage:
  13427. v, ok := value.([]custom_types.Action)
  13428. if !ok {
  13429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13430. }
  13431. m.SetActionMessage(v)
  13432. return nil
  13433. case sopnode.FieldActionLabel:
  13434. v, ok := value.([]uint64)
  13435. if !ok {
  13436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13437. }
  13438. m.SetActionLabel(v)
  13439. return nil
  13440. }
  13441. return fmt.Errorf("unknown SopNode field %s", name)
  13442. }
  13443. // AddedFields returns all numeric fields that were incremented/decremented during
  13444. // this mutation.
  13445. func (m *SopNodeMutation) AddedFields() []string {
  13446. var fields []string
  13447. if m.addstatus != nil {
  13448. fields = append(fields, sopnode.FieldStatus)
  13449. }
  13450. if m.addparent_id != nil {
  13451. fields = append(fields, sopnode.FieldParentID)
  13452. }
  13453. if m.addcondition_type != nil {
  13454. fields = append(fields, sopnode.FieldConditionType)
  13455. }
  13456. if m.addno_reply_condition != nil {
  13457. fields = append(fields, sopnode.FieldNoReplyCondition)
  13458. }
  13459. return fields
  13460. }
  13461. // AddedField returns the numeric value that was incremented/decremented on a field
  13462. // with the given name. The second boolean return value indicates that this field
  13463. // was not set, or was not defined in the schema.
  13464. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  13465. switch name {
  13466. case sopnode.FieldStatus:
  13467. return m.AddedStatus()
  13468. case sopnode.FieldParentID:
  13469. return m.AddedParentID()
  13470. case sopnode.FieldConditionType:
  13471. return m.AddedConditionType()
  13472. case sopnode.FieldNoReplyCondition:
  13473. return m.AddedNoReplyCondition()
  13474. }
  13475. return nil, false
  13476. }
  13477. // AddField adds the value to the field with the given name. It returns an error if
  13478. // the field is not defined in the schema, or if the type mismatched the field
  13479. // type.
  13480. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  13481. switch name {
  13482. case sopnode.FieldStatus:
  13483. v, ok := value.(int8)
  13484. if !ok {
  13485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13486. }
  13487. m.AddStatus(v)
  13488. return nil
  13489. case sopnode.FieldParentID:
  13490. v, ok := value.(int64)
  13491. if !ok {
  13492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13493. }
  13494. m.AddParentID(v)
  13495. return nil
  13496. case sopnode.FieldConditionType:
  13497. v, ok := value.(int)
  13498. if !ok {
  13499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13500. }
  13501. m.AddConditionType(v)
  13502. return nil
  13503. case sopnode.FieldNoReplyCondition:
  13504. v, ok := value.(int64)
  13505. if !ok {
  13506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13507. }
  13508. m.AddNoReplyCondition(v)
  13509. return nil
  13510. }
  13511. return fmt.Errorf("unknown SopNode numeric field %s", name)
  13512. }
  13513. // ClearedFields returns all nullable fields that were cleared during this
  13514. // mutation.
  13515. func (m *SopNodeMutation) ClearedFields() []string {
  13516. var fields []string
  13517. if m.FieldCleared(sopnode.FieldStatus) {
  13518. fields = append(fields, sopnode.FieldStatus)
  13519. }
  13520. if m.FieldCleared(sopnode.FieldDeletedAt) {
  13521. fields = append(fields, sopnode.FieldDeletedAt)
  13522. }
  13523. if m.FieldCleared(sopnode.FieldConditionList) {
  13524. fields = append(fields, sopnode.FieldConditionList)
  13525. }
  13526. if m.FieldCleared(sopnode.FieldActionMessage) {
  13527. fields = append(fields, sopnode.FieldActionMessage)
  13528. }
  13529. if m.FieldCleared(sopnode.FieldActionLabel) {
  13530. fields = append(fields, sopnode.FieldActionLabel)
  13531. }
  13532. return fields
  13533. }
  13534. // FieldCleared returns a boolean indicating if a field with the given name was
  13535. // cleared in this mutation.
  13536. func (m *SopNodeMutation) FieldCleared(name string) bool {
  13537. _, ok := m.clearedFields[name]
  13538. return ok
  13539. }
  13540. // ClearField clears the value of the field with the given name. It returns an
  13541. // error if the field is not defined in the schema.
  13542. func (m *SopNodeMutation) ClearField(name string) error {
  13543. switch name {
  13544. case sopnode.FieldStatus:
  13545. m.ClearStatus()
  13546. return nil
  13547. case sopnode.FieldDeletedAt:
  13548. m.ClearDeletedAt()
  13549. return nil
  13550. case sopnode.FieldConditionList:
  13551. m.ClearConditionList()
  13552. return nil
  13553. case sopnode.FieldActionMessage:
  13554. m.ClearActionMessage()
  13555. return nil
  13556. case sopnode.FieldActionLabel:
  13557. m.ClearActionLabel()
  13558. return nil
  13559. }
  13560. return fmt.Errorf("unknown SopNode nullable field %s", name)
  13561. }
  13562. // ResetField resets all changes in the mutation for the field with the given name.
  13563. // It returns an error if the field is not defined in the schema.
  13564. func (m *SopNodeMutation) ResetField(name string) error {
  13565. switch name {
  13566. case sopnode.FieldCreatedAt:
  13567. m.ResetCreatedAt()
  13568. return nil
  13569. case sopnode.FieldUpdatedAt:
  13570. m.ResetUpdatedAt()
  13571. return nil
  13572. case sopnode.FieldStatus:
  13573. m.ResetStatus()
  13574. return nil
  13575. case sopnode.FieldDeletedAt:
  13576. m.ResetDeletedAt()
  13577. return nil
  13578. case sopnode.FieldStageID:
  13579. m.ResetStageID()
  13580. return nil
  13581. case sopnode.FieldParentID:
  13582. m.ResetParentID()
  13583. return nil
  13584. case sopnode.FieldName:
  13585. m.ResetName()
  13586. return nil
  13587. case sopnode.FieldConditionType:
  13588. m.ResetConditionType()
  13589. return nil
  13590. case sopnode.FieldConditionList:
  13591. m.ResetConditionList()
  13592. return nil
  13593. case sopnode.FieldNoReplyCondition:
  13594. m.ResetNoReplyCondition()
  13595. return nil
  13596. case sopnode.FieldActionMessage:
  13597. m.ResetActionMessage()
  13598. return nil
  13599. case sopnode.FieldActionLabel:
  13600. m.ResetActionLabel()
  13601. return nil
  13602. }
  13603. return fmt.Errorf("unknown SopNode field %s", name)
  13604. }
  13605. // AddedEdges returns all edge names that were set/added in this mutation.
  13606. func (m *SopNodeMutation) AddedEdges() []string {
  13607. edges := make([]string, 0, 2)
  13608. if m.sop_stage != nil {
  13609. edges = append(edges, sopnode.EdgeSopStage)
  13610. }
  13611. if m.node_messages != nil {
  13612. edges = append(edges, sopnode.EdgeNodeMessages)
  13613. }
  13614. return edges
  13615. }
  13616. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13617. // name in this mutation.
  13618. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  13619. switch name {
  13620. case sopnode.EdgeSopStage:
  13621. if id := m.sop_stage; id != nil {
  13622. return []ent.Value{*id}
  13623. }
  13624. case sopnode.EdgeNodeMessages:
  13625. ids := make([]ent.Value, 0, len(m.node_messages))
  13626. for id := range m.node_messages {
  13627. ids = append(ids, id)
  13628. }
  13629. return ids
  13630. }
  13631. return nil
  13632. }
  13633. // RemovedEdges returns all edge names that were removed in this mutation.
  13634. func (m *SopNodeMutation) RemovedEdges() []string {
  13635. edges := make([]string, 0, 2)
  13636. if m.removednode_messages != nil {
  13637. edges = append(edges, sopnode.EdgeNodeMessages)
  13638. }
  13639. return edges
  13640. }
  13641. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13642. // the given name in this mutation.
  13643. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  13644. switch name {
  13645. case sopnode.EdgeNodeMessages:
  13646. ids := make([]ent.Value, 0, len(m.removednode_messages))
  13647. for id := range m.removednode_messages {
  13648. ids = append(ids, id)
  13649. }
  13650. return ids
  13651. }
  13652. return nil
  13653. }
  13654. // ClearedEdges returns all edge names that were cleared in this mutation.
  13655. func (m *SopNodeMutation) ClearedEdges() []string {
  13656. edges := make([]string, 0, 2)
  13657. if m.clearedsop_stage {
  13658. edges = append(edges, sopnode.EdgeSopStage)
  13659. }
  13660. if m.clearednode_messages {
  13661. edges = append(edges, sopnode.EdgeNodeMessages)
  13662. }
  13663. return edges
  13664. }
  13665. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13666. // was cleared in this mutation.
  13667. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  13668. switch name {
  13669. case sopnode.EdgeSopStage:
  13670. return m.clearedsop_stage
  13671. case sopnode.EdgeNodeMessages:
  13672. return m.clearednode_messages
  13673. }
  13674. return false
  13675. }
  13676. // ClearEdge clears the value of the edge with the given name. It returns an error
  13677. // if that edge is not defined in the schema.
  13678. func (m *SopNodeMutation) ClearEdge(name string) error {
  13679. switch name {
  13680. case sopnode.EdgeSopStage:
  13681. m.ClearSopStage()
  13682. return nil
  13683. }
  13684. return fmt.Errorf("unknown SopNode unique edge %s", name)
  13685. }
  13686. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13687. // It returns an error if the edge is not defined in the schema.
  13688. func (m *SopNodeMutation) ResetEdge(name string) error {
  13689. switch name {
  13690. case sopnode.EdgeSopStage:
  13691. m.ResetSopStage()
  13692. return nil
  13693. case sopnode.EdgeNodeMessages:
  13694. m.ResetNodeMessages()
  13695. return nil
  13696. }
  13697. return fmt.Errorf("unknown SopNode edge %s", name)
  13698. }
  13699. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  13700. type SopStageMutation struct {
  13701. config
  13702. op Op
  13703. typ string
  13704. id *uint64
  13705. created_at *time.Time
  13706. updated_at *time.Time
  13707. status *uint8
  13708. addstatus *int8
  13709. deleted_at *time.Time
  13710. name *string
  13711. condition_type *int
  13712. addcondition_type *int
  13713. condition_operator *int
  13714. addcondition_operator *int
  13715. condition_list *[]custom_types.Condition
  13716. appendcondition_list []custom_types.Condition
  13717. action_message *[]custom_types.Action
  13718. appendaction_message []custom_types.Action
  13719. action_label *[]uint64
  13720. appendaction_label []uint64
  13721. index_sort *int
  13722. addindex_sort *int
  13723. clearedFields map[string]struct{}
  13724. sop_task *uint64
  13725. clearedsop_task bool
  13726. stage_nodes map[uint64]struct{}
  13727. removedstage_nodes map[uint64]struct{}
  13728. clearedstage_nodes bool
  13729. stage_messages map[uint64]struct{}
  13730. removedstage_messages map[uint64]struct{}
  13731. clearedstage_messages bool
  13732. done bool
  13733. oldValue func(context.Context) (*SopStage, error)
  13734. predicates []predicate.SopStage
  13735. }
  13736. var _ ent.Mutation = (*SopStageMutation)(nil)
  13737. // sopstageOption allows management of the mutation configuration using functional options.
  13738. type sopstageOption func(*SopStageMutation)
  13739. // newSopStageMutation creates new mutation for the SopStage entity.
  13740. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  13741. m := &SopStageMutation{
  13742. config: c,
  13743. op: op,
  13744. typ: TypeSopStage,
  13745. clearedFields: make(map[string]struct{}),
  13746. }
  13747. for _, opt := range opts {
  13748. opt(m)
  13749. }
  13750. return m
  13751. }
  13752. // withSopStageID sets the ID field of the mutation.
  13753. func withSopStageID(id uint64) sopstageOption {
  13754. return func(m *SopStageMutation) {
  13755. var (
  13756. err error
  13757. once sync.Once
  13758. value *SopStage
  13759. )
  13760. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  13761. once.Do(func() {
  13762. if m.done {
  13763. err = errors.New("querying old values post mutation is not allowed")
  13764. } else {
  13765. value, err = m.Client().SopStage.Get(ctx, id)
  13766. }
  13767. })
  13768. return value, err
  13769. }
  13770. m.id = &id
  13771. }
  13772. }
  13773. // withSopStage sets the old SopStage of the mutation.
  13774. func withSopStage(node *SopStage) sopstageOption {
  13775. return func(m *SopStageMutation) {
  13776. m.oldValue = func(context.Context) (*SopStage, error) {
  13777. return node, nil
  13778. }
  13779. m.id = &node.ID
  13780. }
  13781. }
  13782. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13783. // executed in a transaction (ent.Tx), a transactional client is returned.
  13784. func (m SopStageMutation) Client() *Client {
  13785. client := &Client{config: m.config}
  13786. client.init()
  13787. return client
  13788. }
  13789. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13790. // it returns an error otherwise.
  13791. func (m SopStageMutation) Tx() (*Tx, error) {
  13792. if _, ok := m.driver.(*txDriver); !ok {
  13793. return nil, errors.New("ent: mutation is not running in a transaction")
  13794. }
  13795. tx := &Tx{config: m.config}
  13796. tx.init()
  13797. return tx, nil
  13798. }
  13799. // SetID sets the value of the id field. Note that this
  13800. // operation is only accepted on creation of SopStage entities.
  13801. func (m *SopStageMutation) SetID(id uint64) {
  13802. m.id = &id
  13803. }
  13804. // ID returns the ID value in the mutation. Note that the ID is only available
  13805. // if it was provided to the builder or after it was returned from the database.
  13806. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  13807. if m.id == nil {
  13808. return
  13809. }
  13810. return *m.id, true
  13811. }
  13812. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13813. // That means, if the mutation is applied within a transaction with an isolation level such
  13814. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13815. // or updated by the mutation.
  13816. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  13817. switch {
  13818. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13819. id, exists := m.ID()
  13820. if exists {
  13821. return []uint64{id}, nil
  13822. }
  13823. fallthrough
  13824. case m.op.Is(OpUpdate | OpDelete):
  13825. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  13826. default:
  13827. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13828. }
  13829. }
  13830. // SetCreatedAt sets the "created_at" field.
  13831. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  13832. m.created_at = &t
  13833. }
  13834. // CreatedAt returns the value of the "created_at" field in the mutation.
  13835. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  13836. v := m.created_at
  13837. if v == nil {
  13838. return
  13839. }
  13840. return *v, true
  13841. }
  13842. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  13843. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13845. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13846. if !m.op.Is(OpUpdateOne) {
  13847. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13848. }
  13849. if m.id == nil || m.oldValue == nil {
  13850. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13851. }
  13852. oldValue, err := m.oldValue(ctx)
  13853. if err != nil {
  13854. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13855. }
  13856. return oldValue.CreatedAt, nil
  13857. }
  13858. // ResetCreatedAt resets all changes to the "created_at" field.
  13859. func (m *SopStageMutation) ResetCreatedAt() {
  13860. m.created_at = nil
  13861. }
  13862. // SetUpdatedAt sets the "updated_at" field.
  13863. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  13864. m.updated_at = &t
  13865. }
  13866. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13867. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  13868. v := m.updated_at
  13869. if v == nil {
  13870. return
  13871. }
  13872. return *v, true
  13873. }
  13874. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  13875. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13877. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13878. if !m.op.Is(OpUpdateOne) {
  13879. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13880. }
  13881. if m.id == nil || m.oldValue == nil {
  13882. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13883. }
  13884. oldValue, err := m.oldValue(ctx)
  13885. if err != nil {
  13886. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13887. }
  13888. return oldValue.UpdatedAt, nil
  13889. }
  13890. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13891. func (m *SopStageMutation) ResetUpdatedAt() {
  13892. m.updated_at = nil
  13893. }
  13894. // SetStatus sets the "status" field.
  13895. func (m *SopStageMutation) SetStatus(u uint8) {
  13896. m.status = &u
  13897. m.addstatus = nil
  13898. }
  13899. // Status returns the value of the "status" field in the mutation.
  13900. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  13901. v := m.status
  13902. if v == nil {
  13903. return
  13904. }
  13905. return *v, true
  13906. }
  13907. // OldStatus returns the old "status" field's value of the SopStage entity.
  13908. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13910. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13911. if !m.op.Is(OpUpdateOne) {
  13912. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13913. }
  13914. if m.id == nil || m.oldValue == nil {
  13915. return v, errors.New("OldStatus requires an ID field in the mutation")
  13916. }
  13917. oldValue, err := m.oldValue(ctx)
  13918. if err != nil {
  13919. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13920. }
  13921. return oldValue.Status, nil
  13922. }
  13923. // AddStatus adds u to the "status" field.
  13924. func (m *SopStageMutation) AddStatus(u int8) {
  13925. if m.addstatus != nil {
  13926. *m.addstatus += u
  13927. } else {
  13928. m.addstatus = &u
  13929. }
  13930. }
  13931. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13932. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  13933. v := m.addstatus
  13934. if v == nil {
  13935. return
  13936. }
  13937. return *v, true
  13938. }
  13939. // ClearStatus clears the value of the "status" field.
  13940. func (m *SopStageMutation) ClearStatus() {
  13941. m.status = nil
  13942. m.addstatus = nil
  13943. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  13944. }
  13945. // StatusCleared returns if the "status" field was cleared in this mutation.
  13946. func (m *SopStageMutation) StatusCleared() bool {
  13947. _, ok := m.clearedFields[sopstage.FieldStatus]
  13948. return ok
  13949. }
  13950. // ResetStatus resets all changes to the "status" field.
  13951. func (m *SopStageMutation) ResetStatus() {
  13952. m.status = nil
  13953. m.addstatus = nil
  13954. delete(m.clearedFields, sopstage.FieldStatus)
  13955. }
  13956. // SetDeletedAt sets the "deleted_at" field.
  13957. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  13958. m.deleted_at = &t
  13959. }
  13960. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13961. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  13962. v := m.deleted_at
  13963. if v == nil {
  13964. return
  13965. }
  13966. return *v, true
  13967. }
  13968. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  13969. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13971. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13972. if !m.op.Is(OpUpdateOne) {
  13973. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13974. }
  13975. if m.id == nil || m.oldValue == nil {
  13976. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13977. }
  13978. oldValue, err := m.oldValue(ctx)
  13979. if err != nil {
  13980. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13981. }
  13982. return oldValue.DeletedAt, nil
  13983. }
  13984. // ClearDeletedAt clears the value of the "deleted_at" field.
  13985. func (m *SopStageMutation) ClearDeletedAt() {
  13986. m.deleted_at = nil
  13987. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  13988. }
  13989. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13990. func (m *SopStageMutation) DeletedAtCleared() bool {
  13991. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  13992. return ok
  13993. }
  13994. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13995. func (m *SopStageMutation) ResetDeletedAt() {
  13996. m.deleted_at = nil
  13997. delete(m.clearedFields, sopstage.FieldDeletedAt)
  13998. }
  13999. // SetTaskID sets the "task_id" field.
  14000. func (m *SopStageMutation) SetTaskID(u uint64) {
  14001. m.sop_task = &u
  14002. }
  14003. // TaskID returns the value of the "task_id" field in the mutation.
  14004. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  14005. v := m.sop_task
  14006. if v == nil {
  14007. return
  14008. }
  14009. return *v, true
  14010. }
  14011. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  14012. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14013. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14014. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  14015. if !m.op.Is(OpUpdateOne) {
  14016. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  14017. }
  14018. if m.id == nil || m.oldValue == nil {
  14019. return v, errors.New("OldTaskID requires an ID field in the mutation")
  14020. }
  14021. oldValue, err := m.oldValue(ctx)
  14022. if err != nil {
  14023. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  14024. }
  14025. return oldValue.TaskID, nil
  14026. }
  14027. // ResetTaskID resets all changes to the "task_id" field.
  14028. func (m *SopStageMutation) ResetTaskID() {
  14029. m.sop_task = nil
  14030. }
  14031. // SetName sets the "name" field.
  14032. func (m *SopStageMutation) SetName(s string) {
  14033. m.name = &s
  14034. }
  14035. // Name returns the value of the "name" field in the mutation.
  14036. func (m *SopStageMutation) Name() (r string, exists bool) {
  14037. v := m.name
  14038. if v == nil {
  14039. return
  14040. }
  14041. return *v, true
  14042. }
  14043. // OldName returns the old "name" field's value of the SopStage entity.
  14044. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14045. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14046. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  14047. if !m.op.Is(OpUpdateOne) {
  14048. return v, errors.New("OldName is only allowed on UpdateOne operations")
  14049. }
  14050. if m.id == nil || m.oldValue == nil {
  14051. return v, errors.New("OldName requires an ID field in the mutation")
  14052. }
  14053. oldValue, err := m.oldValue(ctx)
  14054. if err != nil {
  14055. return v, fmt.Errorf("querying old value for OldName: %w", err)
  14056. }
  14057. return oldValue.Name, nil
  14058. }
  14059. // ResetName resets all changes to the "name" field.
  14060. func (m *SopStageMutation) ResetName() {
  14061. m.name = nil
  14062. }
  14063. // SetConditionType sets the "condition_type" field.
  14064. func (m *SopStageMutation) SetConditionType(i int) {
  14065. m.condition_type = &i
  14066. m.addcondition_type = nil
  14067. }
  14068. // ConditionType returns the value of the "condition_type" field in the mutation.
  14069. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  14070. v := m.condition_type
  14071. if v == nil {
  14072. return
  14073. }
  14074. return *v, true
  14075. }
  14076. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  14077. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14079. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  14080. if !m.op.Is(OpUpdateOne) {
  14081. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  14082. }
  14083. if m.id == nil || m.oldValue == nil {
  14084. return v, errors.New("OldConditionType requires an ID field in the mutation")
  14085. }
  14086. oldValue, err := m.oldValue(ctx)
  14087. if err != nil {
  14088. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  14089. }
  14090. return oldValue.ConditionType, nil
  14091. }
  14092. // AddConditionType adds i to the "condition_type" field.
  14093. func (m *SopStageMutation) AddConditionType(i int) {
  14094. if m.addcondition_type != nil {
  14095. *m.addcondition_type += i
  14096. } else {
  14097. m.addcondition_type = &i
  14098. }
  14099. }
  14100. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  14101. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  14102. v := m.addcondition_type
  14103. if v == nil {
  14104. return
  14105. }
  14106. return *v, true
  14107. }
  14108. // ResetConditionType resets all changes to the "condition_type" field.
  14109. func (m *SopStageMutation) ResetConditionType() {
  14110. m.condition_type = nil
  14111. m.addcondition_type = nil
  14112. }
  14113. // SetConditionOperator sets the "condition_operator" field.
  14114. func (m *SopStageMutation) SetConditionOperator(i int) {
  14115. m.condition_operator = &i
  14116. m.addcondition_operator = nil
  14117. }
  14118. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  14119. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  14120. v := m.condition_operator
  14121. if v == nil {
  14122. return
  14123. }
  14124. return *v, true
  14125. }
  14126. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  14127. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14128. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14129. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  14130. if !m.op.Is(OpUpdateOne) {
  14131. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  14132. }
  14133. if m.id == nil || m.oldValue == nil {
  14134. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  14135. }
  14136. oldValue, err := m.oldValue(ctx)
  14137. if err != nil {
  14138. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  14139. }
  14140. return oldValue.ConditionOperator, nil
  14141. }
  14142. // AddConditionOperator adds i to the "condition_operator" field.
  14143. func (m *SopStageMutation) AddConditionOperator(i int) {
  14144. if m.addcondition_operator != nil {
  14145. *m.addcondition_operator += i
  14146. } else {
  14147. m.addcondition_operator = &i
  14148. }
  14149. }
  14150. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  14151. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  14152. v := m.addcondition_operator
  14153. if v == nil {
  14154. return
  14155. }
  14156. return *v, true
  14157. }
  14158. // ResetConditionOperator resets all changes to the "condition_operator" field.
  14159. func (m *SopStageMutation) ResetConditionOperator() {
  14160. m.condition_operator = nil
  14161. m.addcondition_operator = nil
  14162. }
  14163. // SetConditionList sets the "condition_list" field.
  14164. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  14165. m.condition_list = &ct
  14166. m.appendcondition_list = nil
  14167. }
  14168. // ConditionList returns the value of the "condition_list" field in the mutation.
  14169. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  14170. v := m.condition_list
  14171. if v == nil {
  14172. return
  14173. }
  14174. return *v, true
  14175. }
  14176. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  14177. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14178. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14179. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  14180. if !m.op.Is(OpUpdateOne) {
  14181. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  14182. }
  14183. if m.id == nil || m.oldValue == nil {
  14184. return v, errors.New("OldConditionList requires an ID field in the mutation")
  14185. }
  14186. oldValue, err := m.oldValue(ctx)
  14187. if err != nil {
  14188. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  14189. }
  14190. return oldValue.ConditionList, nil
  14191. }
  14192. // AppendConditionList adds ct to the "condition_list" field.
  14193. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  14194. m.appendcondition_list = append(m.appendcondition_list, ct...)
  14195. }
  14196. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  14197. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  14198. if len(m.appendcondition_list) == 0 {
  14199. return nil, false
  14200. }
  14201. return m.appendcondition_list, true
  14202. }
  14203. // ResetConditionList resets all changes to the "condition_list" field.
  14204. func (m *SopStageMutation) ResetConditionList() {
  14205. m.condition_list = nil
  14206. m.appendcondition_list = nil
  14207. }
  14208. // SetActionMessage sets the "action_message" field.
  14209. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  14210. m.action_message = &ct
  14211. m.appendaction_message = nil
  14212. }
  14213. // ActionMessage returns the value of the "action_message" field in the mutation.
  14214. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  14215. v := m.action_message
  14216. if v == nil {
  14217. return
  14218. }
  14219. return *v, true
  14220. }
  14221. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  14222. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14224. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  14225. if !m.op.Is(OpUpdateOne) {
  14226. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  14227. }
  14228. if m.id == nil || m.oldValue == nil {
  14229. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  14230. }
  14231. oldValue, err := m.oldValue(ctx)
  14232. if err != nil {
  14233. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  14234. }
  14235. return oldValue.ActionMessage, nil
  14236. }
  14237. // AppendActionMessage adds ct to the "action_message" field.
  14238. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  14239. m.appendaction_message = append(m.appendaction_message, ct...)
  14240. }
  14241. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  14242. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  14243. if len(m.appendaction_message) == 0 {
  14244. return nil, false
  14245. }
  14246. return m.appendaction_message, true
  14247. }
  14248. // ClearActionMessage clears the value of the "action_message" field.
  14249. func (m *SopStageMutation) ClearActionMessage() {
  14250. m.action_message = nil
  14251. m.appendaction_message = nil
  14252. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  14253. }
  14254. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  14255. func (m *SopStageMutation) ActionMessageCleared() bool {
  14256. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  14257. return ok
  14258. }
  14259. // ResetActionMessage resets all changes to the "action_message" field.
  14260. func (m *SopStageMutation) ResetActionMessage() {
  14261. m.action_message = nil
  14262. m.appendaction_message = nil
  14263. delete(m.clearedFields, sopstage.FieldActionMessage)
  14264. }
  14265. // SetActionLabel sets the "action_label" field.
  14266. func (m *SopStageMutation) SetActionLabel(u []uint64) {
  14267. m.action_label = &u
  14268. m.appendaction_label = nil
  14269. }
  14270. // ActionLabel returns the value of the "action_label" field in the mutation.
  14271. func (m *SopStageMutation) ActionLabel() (r []uint64, exists bool) {
  14272. v := m.action_label
  14273. if v == nil {
  14274. return
  14275. }
  14276. return *v, true
  14277. }
  14278. // OldActionLabel returns the old "action_label" field's value of the SopStage entity.
  14279. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14281. func (m *SopStageMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  14282. if !m.op.Is(OpUpdateOne) {
  14283. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  14284. }
  14285. if m.id == nil || m.oldValue == nil {
  14286. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  14287. }
  14288. oldValue, err := m.oldValue(ctx)
  14289. if err != nil {
  14290. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  14291. }
  14292. return oldValue.ActionLabel, nil
  14293. }
  14294. // AppendActionLabel adds u to the "action_label" field.
  14295. func (m *SopStageMutation) AppendActionLabel(u []uint64) {
  14296. m.appendaction_label = append(m.appendaction_label, u...)
  14297. }
  14298. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  14299. func (m *SopStageMutation) AppendedActionLabel() ([]uint64, bool) {
  14300. if len(m.appendaction_label) == 0 {
  14301. return nil, false
  14302. }
  14303. return m.appendaction_label, true
  14304. }
  14305. // ClearActionLabel clears the value of the "action_label" field.
  14306. func (m *SopStageMutation) ClearActionLabel() {
  14307. m.action_label = nil
  14308. m.appendaction_label = nil
  14309. m.clearedFields[sopstage.FieldActionLabel] = struct{}{}
  14310. }
  14311. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  14312. func (m *SopStageMutation) ActionLabelCleared() bool {
  14313. _, ok := m.clearedFields[sopstage.FieldActionLabel]
  14314. return ok
  14315. }
  14316. // ResetActionLabel resets all changes to the "action_label" field.
  14317. func (m *SopStageMutation) ResetActionLabel() {
  14318. m.action_label = nil
  14319. m.appendaction_label = nil
  14320. delete(m.clearedFields, sopstage.FieldActionLabel)
  14321. }
  14322. // SetIndexSort sets the "index_sort" field.
  14323. func (m *SopStageMutation) SetIndexSort(i int) {
  14324. m.index_sort = &i
  14325. m.addindex_sort = nil
  14326. }
  14327. // IndexSort returns the value of the "index_sort" field in the mutation.
  14328. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  14329. v := m.index_sort
  14330. if v == nil {
  14331. return
  14332. }
  14333. return *v, true
  14334. }
  14335. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  14336. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14338. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  14339. if !m.op.Is(OpUpdateOne) {
  14340. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  14341. }
  14342. if m.id == nil || m.oldValue == nil {
  14343. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  14344. }
  14345. oldValue, err := m.oldValue(ctx)
  14346. if err != nil {
  14347. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  14348. }
  14349. return oldValue.IndexSort, nil
  14350. }
  14351. // AddIndexSort adds i to the "index_sort" field.
  14352. func (m *SopStageMutation) AddIndexSort(i int) {
  14353. if m.addindex_sort != nil {
  14354. *m.addindex_sort += i
  14355. } else {
  14356. m.addindex_sort = &i
  14357. }
  14358. }
  14359. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  14360. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  14361. v := m.addindex_sort
  14362. if v == nil {
  14363. return
  14364. }
  14365. return *v, true
  14366. }
  14367. // ClearIndexSort clears the value of the "index_sort" field.
  14368. func (m *SopStageMutation) ClearIndexSort() {
  14369. m.index_sort = nil
  14370. m.addindex_sort = nil
  14371. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  14372. }
  14373. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  14374. func (m *SopStageMutation) IndexSortCleared() bool {
  14375. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  14376. return ok
  14377. }
  14378. // ResetIndexSort resets all changes to the "index_sort" field.
  14379. func (m *SopStageMutation) ResetIndexSort() {
  14380. m.index_sort = nil
  14381. m.addindex_sort = nil
  14382. delete(m.clearedFields, sopstage.FieldIndexSort)
  14383. }
  14384. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  14385. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  14386. m.sop_task = &id
  14387. }
  14388. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  14389. func (m *SopStageMutation) ClearSopTask() {
  14390. m.clearedsop_task = true
  14391. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  14392. }
  14393. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  14394. func (m *SopStageMutation) SopTaskCleared() bool {
  14395. return m.clearedsop_task
  14396. }
  14397. // SopTaskID returns the "sop_task" edge ID in the mutation.
  14398. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  14399. if m.sop_task != nil {
  14400. return *m.sop_task, true
  14401. }
  14402. return
  14403. }
  14404. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  14405. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14406. // SopTaskID instead. It exists only for internal usage by the builders.
  14407. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  14408. if id := m.sop_task; id != nil {
  14409. ids = append(ids, *id)
  14410. }
  14411. return
  14412. }
  14413. // ResetSopTask resets all changes to the "sop_task" edge.
  14414. func (m *SopStageMutation) ResetSopTask() {
  14415. m.sop_task = nil
  14416. m.clearedsop_task = false
  14417. }
  14418. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  14419. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  14420. if m.stage_nodes == nil {
  14421. m.stage_nodes = make(map[uint64]struct{})
  14422. }
  14423. for i := range ids {
  14424. m.stage_nodes[ids[i]] = struct{}{}
  14425. }
  14426. }
  14427. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  14428. func (m *SopStageMutation) ClearStageNodes() {
  14429. m.clearedstage_nodes = true
  14430. }
  14431. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  14432. func (m *SopStageMutation) StageNodesCleared() bool {
  14433. return m.clearedstage_nodes
  14434. }
  14435. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  14436. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  14437. if m.removedstage_nodes == nil {
  14438. m.removedstage_nodes = make(map[uint64]struct{})
  14439. }
  14440. for i := range ids {
  14441. delete(m.stage_nodes, ids[i])
  14442. m.removedstage_nodes[ids[i]] = struct{}{}
  14443. }
  14444. }
  14445. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  14446. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  14447. for id := range m.removedstage_nodes {
  14448. ids = append(ids, id)
  14449. }
  14450. return
  14451. }
  14452. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  14453. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  14454. for id := range m.stage_nodes {
  14455. ids = append(ids, id)
  14456. }
  14457. return
  14458. }
  14459. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  14460. func (m *SopStageMutation) ResetStageNodes() {
  14461. m.stage_nodes = nil
  14462. m.clearedstage_nodes = false
  14463. m.removedstage_nodes = nil
  14464. }
  14465. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  14466. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  14467. if m.stage_messages == nil {
  14468. m.stage_messages = make(map[uint64]struct{})
  14469. }
  14470. for i := range ids {
  14471. m.stage_messages[ids[i]] = struct{}{}
  14472. }
  14473. }
  14474. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  14475. func (m *SopStageMutation) ClearStageMessages() {
  14476. m.clearedstage_messages = true
  14477. }
  14478. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  14479. func (m *SopStageMutation) StageMessagesCleared() bool {
  14480. return m.clearedstage_messages
  14481. }
  14482. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  14483. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  14484. if m.removedstage_messages == nil {
  14485. m.removedstage_messages = make(map[uint64]struct{})
  14486. }
  14487. for i := range ids {
  14488. delete(m.stage_messages, ids[i])
  14489. m.removedstage_messages[ids[i]] = struct{}{}
  14490. }
  14491. }
  14492. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  14493. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  14494. for id := range m.removedstage_messages {
  14495. ids = append(ids, id)
  14496. }
  14497. return
  14498. }
  14499. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  14500. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  14501. for id := range m.stage_messages {
  14502. ids = append(ids, id)
  14503. }
  14504. return
  14505. }
  14506. // ResetStageMessages resets all changes to the "stage_messages" edge.
  14507. func (m *SopStageMutation) ResetStageMessages() {
  14508. m.stage_messages = nil
  14509. m.clearedstage_messages = false
  14510. m.removedstage_messages = nil
  14511. }
  14512. // Where appends a list predicates to the SopStageMutation builder.
  14513. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  14514. m.predicates = append(m.predicates, ps...)
  14515. }
  14516. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  14517. // users can use type-assertion to append predicates that do not depend on any generated package.
  14518. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  14519. p := make([]predicate.SopStage, len(ps))
  14520. for i := range ps {
  14521. p[i] = ps[i]
  14522. }
  14523. m.Where(p...)
  14524. }
  14525. // Op returns the operation name.
  14526. func (m *SopStageMutation) Op() Op {
  14527. return m.op
  14528. }
  14529. // SetOp allows setting the mutation operation.
  14530. func (m *SopStageMutation) SetOp(op Op) {
  14531. m.op = op
  14532. }
  14533. // Type returns the node type of this mutation (SopStage).
  14534. func (m *SopStageMutation) Type() string {
  14535. return m.typ
  14536. }
  14537. // Fields returns all fields that were changed during this mutation. Note that in
  14538. // order to get all numeric fields that were incremented/decremented, call
  14539. // AddedFields().
  14540. func (m *SopStageMutation) Fields() []string {
  14541. fields := make([]string, 0, 12)
  14542. if m.created_at != nil {
  14543. fields = append(fields, sopstage.FieldCreatedAt)
  14544. }
  14545. if m.updated_at != nil {
  14546. fields = append(fields, sopstage.FieldUpdatedAt)
  14547. }
  14548. if m.status != nil {
  14549. fields = append(fields, sopstage.FieldStatus)
  14550. }
  14551. if m.deleted_at != nil {
  14552. fields = append(fields, sopstage.FieldDeletedAt)
  14553. }
  14554. if m.sop_task != nil {
  14555. fields = append(fields, sopstage.FieldTaskID)
  14556. }
  14557. if m.name != nil {
  14558. fields = append(fields, sopstage.FieldName)
  14559. }
  14560. if m.condition_type != nil {
  14561. fields = append(fields, sopstage.FieldConditionType)
  14562. }
  14563. if m.condition_operator != nil {
  14564. fields = append(fields, sopstage.FieldConditionOperator)
  14565. }
  14566. if m.condition_list != nil {
  14567. fields = append(fields, sopstage.FieldConditionList)
  14568. }
  14569. if m.action_message != nil {
  14570. fields = append(fields, sopstage.FieldActionMessage)
  14571. }
  14572. if m.action_label != nil {
  14573. fields = append(fields, sopstage.FieldActionLabel)
  14574. }
  14575. if m.index_sort != nil {
  14576. fields = append(fields, sopstage.FieldIndexSort)
  14577. }
  14578. return fields
  14579. }
  14580. // Field returns the value of a field with the given name. The second boolean
  14581. // return value indicates that this field was not set, or was not defined in the
  14582. // schema.
  14583. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  14584. switch name {
  14585. case sopstage.FieldCreatedAt:
  14586. return m.CreatedAt()
  14587. case sopstage.FieldUpdatedAt:
  14588. return m.UpdatedAt()
  14589. case sopstage.FieldStatus:
  14590. return m.Status()
  14591. case sopstage.FieldDeletedAt:
  14592. return m.DeletedAt()
  14593. case sopstage.FieldTaskID:
  14594. return m.TaskID()
  14595. case sopstage.FieldName:
  14596. return m.Name()
  14597. case sopstage.FieldConditionType:
  14598. return m.ConditionType()
  14599. case sopstage.FieldConditionOperator:
  14600. return m.ConditionOperator()
  14601. case sopstage.FieldConditionList:
  14602. return m.ConditionList()
  14603. case sopstage.FieldActionMessage:
  14604. return m.ActionMessage()
  14605. case sopstage.FieldActionLabel:
  14606. return m.ActionLabel()
  14607. case sopstage.FieldIndexSort:
  14608. return m.IndexSort()
  14609. }
  14610. return nil, false
  14611. }
  14612. // OldField returns the old value of the field from the database. An error is
  14613. // returned if the mutation operation is not UpdateOne, or the query to the
  14614. // database failed.
  14615. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14616. switch name {
  14617. case sopstage.FieldCreatedAt:
  14618. return m.OldCreatedAt(ctx)
  14619. case sopstage.FieldUpdatedAt:
  14620. return m.OldUpdatedAt(ctx)
  14621. case sopstage.FieldStatus:
  14622. return m.OldStatus(ctx)
  14623. case sopstage.FieldDeletedAt:
  14624. return m.OldDeletedAt(ctx)
  14625. case sopstage.FieldTaskID:
  14626. return m.OldTaskID(ctx)
  14627. case sopstage.FieldName:
  14628. return m.OldName(ctx)
  14629. case sopstage.FieldConditionType:
  14630. return m.OldConditionType(ctx)
  14631. case sopstage.FieldConditionOperator:
  14632. return m.OldConditionOperator(ctx)
  14633. case sopstage.FieldConditionList:
  14634. return m.OldConditionList(ctx)
  14635. case sopstage.FieldActionMessage:
  14636. return m.OldActionMessage(ctx)
  14637. case sopstage.FieldActionLabel:
  14638. return m.OldActionLabel(ctx)
  14639. case sopstage.FieldIndexSort:
  14640. return m.OldIndexSort(ctx)
  14641. }
  14642. return nil, fmt.Errorf("unknown SopStage field %s", name)
  14643. }
  14644. // SetField sets the value of a field with the given name. It returns an error if
  14645. // the field is not defined in the schema, or if the type mismatched the field
  14646. // type.
  14647. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  14648. switch name {
  14649. case sopstage.FieldCreatedAt:
  14650. v, ok := value.(time.Time)
  14651. if !ok {
  14652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14653. }
  14654. m.SetCreatedAt(v)
  14655. return nil
  14656. case sopstage.FieldUpdatedAt:
  14657. v, ok := value.(time.Time)
  14658. if !ok {
  14659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14660. }
  14661. m.SetUpdatedAt(v)
  14662. return nil
  14663. case sopstage.FieldStatus:
  14664. v, ok := value.(uint8)
  14665. if !ok {
  14666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14667. }
  14668. m.SetStatus(v)
  14669. return nil
  14670. case sopstage.FieldDeletedAt:
  14671. v, ok := value.(time.Time)
  14672. if !ok {
  14673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14674. }
  14675. m.SetDeletedAt(v)
  14676. return nil
  14677. case sopstage.FieldTaskID:
  14678. v, ok := value.(uint64)
  14679. if !ok {
  14680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14681. }
  14682. m.SetTaskID(v)
  14683. return nil
  14684. case sopstage.FieldName:
  14685. v, ok := value.(string)
  14686. if !ok {
  14687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14688. }
  14689. m.SetName(v)
  14690. return nil
  14691. case sopstage.FieldConditionType:
  14692. v, ok := value.(int)
  14693. if !ok {
  14694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14695. }
  14696. m.SetConditionType(v)
  14697. return nil
  14698. case sopstage.FieldConditionOperator:
  14699. v, ok := value.(int)
  14700. if !ok {
  14701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14702. }
  14703. m.SetConditionOperator(v)
  14704. return nil
  14705. case sopstage.FieldConditionList:
  14706. v, ok := value.([]custom_types.Condition)
  14707. if !ok {
  14708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14709. }
  14710. m.SetConditionList(v)
  14711. return nil
  14712. case sopstage.FieldActionMessage:
  14713. v, ok := value.([]custom_types.Action)
  14714. if !ok {
  14715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14716. }
  14717. m.SetActionMessage(v)
  14718. return nil
  14719. case sopstage.FieldActionLabel:
  14720. v, ok := value.([]uint64)
  14721. if !ok {
  14722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14723. }
  14724. m.SetActionLabel(v)
  14725. return nil
  14726. case sopstage.FieldIndexSort:
  14727. v, ok := value.(int)
  14728. if !ok {
  14729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14730. }
  14731. m.SetIndexSort(v)
  14732. return nil
  14733. }
  14734. return fmt.Errorf("unknown SopStage field %s", name)
  14735. }
  14736. // AddedFields returns all numeric fields that were incremented/decremented during
  14737. // this mutation.
  14738. func (m *SopStageMutation) AddedFields() []string {
  14739. var fields []string
  14740. if m.addstatus != nil {
  14741. fields = append(fields, sopstage.FieldStatus)
  14742. }
  14743. if m.addcondition_type != nil {
  14744. fields = append(fields, sopstage.FieldConditionType)
  14745. }
  14746. if m.addcondition_operator != nil {
  14747. fields = append(fields, sopstage.FieldConditionOperator)
  14748. }
  14749. if m.addindex_sort != nil {
  14750. fields = append(fields, sopstage.FieldIndexSort)
  14751. }
  14752. return fields
  14753. }
  14754. // AddedField returns the numeric value that was incremented/decremented on a field
  14755. // with the given name. The second boolean return value indicates that this field
  14756. // was not set, or was not defined in the schema.
  14757. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  14758. switch name {
  14759. case sopstage.FieldStatus:
  14760. return m.AddedStatus()
  14761. case sopstage.FieldConditionType:
  14762. return m.AddedConditionType()
  14763. case sopstage.FieldConditionOperator:
  14764. return m.AddedConditionOperator()
  14765. case sopstage.FieldIndexSort:
  14766. return m.AddedIndexSort()
  14767. }
  14768. return nil, false
  14769. }
  14770. // AddField adds the value to the field with the given name. It returns an error if
  14771. // the field is not defined in the schema, or if the type mismatched the field
  14772. // type.
  14773. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  14774. switch name {
  14775. case sopstage.FieldStatus:
  14776. v, ok := value.(int8)
  14777. if !ok {
  14778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14779. }
  14780. m.AddStatus(v)
  14781. return nil
  14782. case sopstage.FieldConditionType:
  14783. v, ok := value.(int)
  14784. if !ok {
  14785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14786. }
  14787. m.AddConditionType(v)
  14788. return nil
  14789. case sopstage.FieldConditionOperator:
  14790. v, ok := value.(int)
  14791. if !ok {
  14792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14793. }
  14794. m.AddConditionOperator(v)
  14795. return nil
  14796. case sopstage.FieldIndexSort:
  14797. v, ok := value.(int)
  14798. if !ok {
  14799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14800. }
  14801. m.AddIndexSort(v)
  14802. return nil
  14803. }
  14804. return fmt.Errorf("unknown SopStage numeric field %s", name)
  14805. }
  14806. // ClearedFields returns all nullable fields that were cleared during this
  14807. // mutation.
  14808. func (m *SopStageMutation) ClearedFields() []string {
  14809. var fields []string
  14810. if m.FieldCleared(sopstage.FieldStatus) {
  14811. fields = append(fields, sopstage.FieldStatus)
  14812. }
  14813. if m.FieldCleared(sopstage.FieldDeletedAt) {
  14814. fields = append(fields, sopstage.FieldDeletedAt)
  14815. }
  14816. if m.FieldCleared(sopstage.FieldActionMessage) {
  14817. fields = append(fields, sopstage.FieldActionMessage)
  14818. }
  14819. if m.FieldCleared(sopstage.FieldActionLabel) {
  14820. fields = append(fields, sopstage.FieldActionLabel)
  14821. }
  14822. if m.FieldCleared(sopstage.FieldIndexSort) {
  14823. fields = append(fields, sopstage.FieldIndexSort)
  14824. }
  14825. return fields
  14826. }
  14827. // FieldCleared returns a boolean indicating if a field with the given name was
  14828. // cleared in this mutation.
  14829. func (m *SopStageMutation) FieldCleared(name string) bool {
  14830. _, ok := m.clearedFields[name]
  14831. return ok
  14832. }
  14833. // ClearField clears the value of the field with the given name. It returns an
  14834. // error if the field is not defined in the schema.
  14835. func (m *SopStageMutation) ClearField(name string) error {
  14836. switch name {
  14837. case sopstage.FieldStatus:
  14838. m.ClearStatus()
  14839. return nil
  14840. case sopstage.FieldDeletedAt:
  14841. m.ClearDeletedAt()
  14842. return nil
  14843. case sopstage.FieldActionMessage:
  14844. m.ClearActionMessage()
  14845. return nil
  14846. case sopstage.FieldActionLabel:
  14847. m.ClearActionLabel()
  14848. return nil
  14849. case sopstage.FieldIndexSort:
  14850. m.ClearIndexSort()
  14851. return nil
  14852. }
  14853. return fmt.Errorf("unknown SopStage nullable field %s", name)
  14854. }
  14855. // ResetField resets all changes in the mutation for the field with the given name.
  14856. // It returns an error if the field is not defined in the schema.
  14857. func (m *SopStageMutation) ResetField(name string) error {
  14858. switch name {
  14859. case sopstage.FieldCreatedAt:
  14860. m.ResetCreatedAt()
  14861. return nil
  14862. case sopstage.FieldUpdatedAt:
  14863. m.ResetUpdatedAt()
  14864. return nil
  14865. case sopstage.FieldStatus:
  14866. m.ResetStatus()
  14867. return nil
  14868. case sopstage.FieldDeletedAt:
  14869. m.ResetDeletedAt()
  14870. return nil
  14871. case sopstage.FieldTaskID:
  14872. m.ResetTaskID()
  14873. return nil
  14874. case sopstage.FieldName:
  14875. m.ResetName()
  14876. return nil
  14877. case sopstage.FieldConditionType:
  14878. m.ResetConditionType()
  14879. return nil
  14880. case sopstage.FieldConditionOperator:
  14881. m.ResetConditionOperator()
  14882. return nil
  14883. case sopstage.FieldConditionList:
  14884. m.ResetConditionList()
  14885. return nil
  14886. case sopstage.FieldActionMessage:
  14887. m.ResetActionMessage()
  14888. return nil
  14889. case sopstage.FieldActionLabel:
  14890. m.ResetActionLabel()
  14891. return nil
  14892. case sopstage.FieldIndexSort:
  14893. m.ResetIndexSort()
  14894. return nil
  14895. }
  14896. return fmt.Errorf("unknown SopStage field %s", name)
  14897. }
  14898. // AddedEdges returns all edge names that were set/added in this mutation.
  14899. func (m *SopStageMutation) AddedEdges() []string {
  14900. edges := make([]string, 0, 3)
  14901. if m.sop_task != nil {
  14902. edges = append(edges, sopstage.EdgeSopTask)
  14903. }
  14904. if m.stage_nodes != nil {
  14905. edges = append(edges, sopstage.EdgeStageNodes)
  14906. }
  14907. if m.stage_messages != nil {
  14908. edges = append(edges, sopstage.EdgeStageMessages)
  14909. }
  14910. return edges
  14911. }
  14912. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14913. // name in this mutation.
  14914. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  14915. switch name {
  14916. case sopstage.EdgeSopTask:
  14917. if id := m.sop_task; id != nil {
  14918. return []ent.Value{*id}
  14919. }
  14920. case sopstage.EdgeStageNodes:
  14921. ids := make([]ent.Value, 0, len(m.stage_nodes))
  14922. for id := range m.stage_nodes {
  14923. ids = append(ids, id)
  14924. }
  14925. return ids
  14926. case sopstage.EdgeStageMessages:
  14927. ids := make([]ent.Value, 0, len(m.stage_messages))
  14928. for id := range m.stage_messages {
  14929. ids = append(ids, id)
  14930. }
  14931. return ids
  14932. }
  14933. return nil
  14934. }
  14935. // RemovedEdges returns all edge names that were removed in this mutation.
  14936. func (m *SopStageMutation) RemovedEdges() []string {
  14937. edges := make([]string, 0, 3)
  14938. if m.removedstage_nodes != nil {
  14939. edges = append(edges, sopstage.EdgeStageNodes)
  14940. }
  14941. if m.removedstage_messages != nil {
  14942. edges = append(edges, sopstage.EdgeStageMessages)
  14943. }
  14944. return edges
  14945. }
  14946. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14947. // the given name in this mutation.
  14948. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  14949. switch name {
  14950. case sopstage.EdgeStageNodes:
  14951. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  14952. for id := range m.removedstage_nodes {
  14953. ids = append(ids, id)
  14954. }
  14955. return ids
  14956. case sopstage.EdgeStageMessages:
  14957. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  14958. for id := range m.removedstage_messages {
  14959. ids = append(ids, id)
  14960. }
  14961. return ids
  14962. }
  14963. return nil
  14964. }
  14965. // ClearedEdges returns all edge names that were cleared in this mutation.
  14966. func (m *SopStageMutation) ClearedEdges() []string {
  14967. edges := make([]string, 0, 3)
  14968. if m.clearedsop_task {
  14969. edges = append(edges, sopstage.EdgeSopTask)
  14970. }
  14971. if m.clearedstage_nodes {
  14972. edges = append(edges, sopstage.EdgeStageNodes)
  14973. }
  14974. if m.clearedstage_messages {
  14975. edges = append(edges, sopstage.EdgeStageMessages)
  14976. }
  14977. return edges
  14978. }
  14979. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14980. // was cleared in this mutation.
  14981. func (m *SopStageMutation) EdgeCleared(name string) bool {
  14982. switch name {
  14983. case sopstage.EdgeSopTask:
  14984. return m.clearedsop_task
  14985. case sopstage.EdgeStageNodes:
  14986. return m.clearedstage_nodes
  14987. case sopstage.EdgeStageMessages:
  14988. return m.clearedstage_messages
  14989. }
  14990. return false
  14991. }
  14992. // ClearEdge clears the value of the edge with the given name. It returns an error
  14993. // if that edge is not defined in the schema.
  14994. func (m *SopStageMutation) ClearEdge(name string) error {
  14995. switch name {
  14996. case sopstage.EdgeSopTask:
  14997. m.ClearSopTask()
  14998. return nil
  14999. }
  15000. return fmt.Errorf("unknown SopStage unique edge %s", name)
  15001. }
  15002. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15003. // It returns an error if the edge is not defined in the schema.
  15004. func (m *SopStageMutation) ResetEdge(name string) error {
  15005. switch name {
  15006. case sopstage.EdgeSopTask:
  15007. m.ResetSopTask()
  15008. return nil
  15009. case sopstage.EdgeStageNodes:
  15010. m.ResetStageNodes()
  15011. return nil
  15012. case sopstage.EdgeStageMessages:
  15013. m.ResetStageMessages()
  15014. return nil
  15015. }
  15016. return fmt.Errorf("unknown SopStage edge %s", name)
  15017. }
  15018. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  15019. type SopTaskMutation struct {
  15020. config
  15021. op Op
  15022. typ string
  15023. id *uint64
  15024. created_at *time.Time
  15025. updated_at *time.Time
  15026. status *uint8
  15027. addstatus *int8
  15028. deleted_at *time.Time
  15029. name *string
  15030. bot_wxid_list *[]string
  15031. appendbot_wxid_list []string
  15032. _type *int
  15033. add_type *int
  15034. plan_start_time *time.Time
  15035. plan_end_time *time.Time
  15036. creator_id *string
  15037. organization_id *uint64
  15038. addorganization_id *int64
  15039. clearedFields map[string]struct{}
  15040. task_stages map[uint64]struct{}
  15041. removedtask_stages map[uint64]struct{}
  15042. clearedtask_stages bool
  15043. done bool
  15044. oldValue func(context.Context) (*SopTask, error)
  15045. predicates []predicate.SopTask
  15046. }
  15047. var _ ent.Mutation = (*SopTaskMutation)(nil)
  15048. // soptaskOption allows management of the mutation configuration using functional options.
  15049. type soptaskOption func(*SopTaskMutation)
  15050. // newSopTaskMutation creates new mutation for the SopTask entity.
  15051. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  15052. m := &SopTaskMutation{
  15053. config: c,
  15054. op: op,
  15055. typ: TypeSopTask,
  15056. clearedFields: make(map[string]struct{}),
  15057. }
  15058. for _, opt := range opts {
  15059. opt(m)
  15060. }
  15061. return m
  15062. }
  15063. // withSopTaskID sets the ID field of the mutation.
  15064. func withSopTaskID(id uint64) soptaskOption {
  15065. return func(m *SopTaskMutation) {
  15066. var (
  15067. err error
  15068. once sync.Once
  15069. value *SopTask
  15070. )
  15071. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  15072. once.Do(func() {
  15073. if m.done {
  15074. err = errors.New("querying old values post mutation is not allowed")
  15075. } else {
  15076. value, err = m.Client().SopTask.Get(ctx, id)
  15077. }
  15078. })
  15079. return value, err
  15080. }
  15081. m.id = &id
  15082. }
  15083. }
  15084. // withSopTask sets the old SopTask of the mutation.
  15085. func withSopTask(node *SopTask) soptaskOption {
  15086. return func(m *SopTaskMutation) {
  15087. m.oldValue = func(context.Context) (*SopTask, error) {
  15088. return node, nil
  15089. }
  15090. m.id = &node.ID
  15091. }
  15092. }
  15093. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15094. // executed in a transaction (ent.Tx), a transactional client is returned.
  15095. func (m SopTaskMutation) Client() *Client {
  15096. client := &Client{config: m.config}
  15097. client.init()
  15098. return client
  15099. }
  15100. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15101. // it returns an error otherwise.
  15102. func (m SopTaskMutation) Tx() (*Tx, error) {
  15103. if _, ok := m.driver.(*txDriver); !ok {
  15104. return nil, errors.New("ent: mutation is not running in a transaction")
  15105. }
  15106. tx := &Tx{config: m.config}
  15107. tx.init()
  15108. return tx, nil
  15109. }
  15110. // SetID sets the value of the id field. Note that this
  15111. // operation is only accepted on creation of SopTask entities.
  15112. func (m *SopTaskMutation) SetID(id uint64) {
  15113. m.id = &id
  15114. }
  15115. // ID returns the ID value in the mutation. Note that the ID is only available
  15116. // if it was provided to the builder or after it was returned from the database.
  15117. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  15118. if m.id == nil {
  15119. return
  15120. }
  15121. return *m.id, true
  15122. }
  15123. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15124. // That means, if the mutation is applied within a transaction with an isolation level such
  15125. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15126. // or updated by the mutation.
  15127. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  15128. switch {
  15129. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15130. id, exists := m.ID()
  15131. if exists {
  15132. return []uint64{id}, nil
  15133. }
  15134. fallthrough
  15135. case m.op.Is(OpUpdate | OpDelete):
  15136. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  15137. default:
  15138. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15139. }
  15140. }
  15141. // SetCreatedAt sets the "created_at" field.
  15142. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  15143. m.created_at = &t
  15144. }
  15145. // CreatedAt returns the value of the "created_at" field in the mutation.
  15146. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  15147. v := m.created_at
  15148. if v == nil {
  15149. return
  15150. }
  15151. return *v, true
  15152. }
  15153. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  15154. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15155. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15156. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15157. if !m.op.Is(OpUpdateOne) {
  15158. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15159. }
  15160. if m.id == nil || m.oldValue == nil {
  15161. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15162. }
  15163. oldValue, err := m.oldValue(ctx)
  15164. if err != nil {
  15165. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15166. }
  15167. return oldValue.CreatedAt, nil
  15168. }
  15169. // ResetCreatedAt resets all changes to the "created_at" field.
  15170. func (m *SopTaskMutation) ResetCreatedAt() {
  15171. m.created_at = nil
  15172. }
  15173. // SetUpdatedAt sets the "updated_at" field.
  15174. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  15175. m.updated_at = &t
  15176. }
  15177. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15178. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  15179. v := m.updated_at
  15180. if v == nil {
  15181. return
  15182. }
  15183. return *v, true
  15184. }
  15185. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  15186. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15188. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15189. if !m.op.Is(OpUpdateOne) {
  15190. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15191. }
  15192. if m.id == nil || m.oldValue == nil {
  15193. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15194. }
  15195. oldValue, err := m.oldValue(ctx)
  15196. if err != nil {
  15197. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15198. }
  15199. return oldValue.UpdatedAt, nil
  15200. }
  15201. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15202. func (m *SopTaskMutation) ResetUpdatedAt() {
  15203. m.updated_at = nil
  15204. }
  15205. // SetStatus sets the "status" field.
  15206. func (m *SopTaskMutation) SetStatus(u uint8) {
  15207. m.status = &u
  15208. m.addstatus = nil
  15209. }
  15210. // Status returns the value of the "status" field in the mutation.
  15211. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  15212. v := m.status
  15213. if v == nil {
  15214. return
  15215. }
  15216. return *v, true
  15217. }
  15218. // OldStatus returns the old "status" field's value of the SopTask entity.
  15219. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15221. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15222. if !m.op.Is(OpUpdateOne) {
  15223. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15224. }
  15225. if m.id == nil || m.oldValue == nil {
  15226. return v, errors.New("OldStatus requires an ID field in the mutation")
  15227. }
  15228. oldValue, err := m.oldValue(ctx)
  15229. if err != nil {
  15230. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15231. }
  15232. return oldValue.Status, nil
  15233. }
  15234. // AddStatus adds u to the "status" field.
  15235. func (m *SopTaskMutation) AddStatus(u int8) {
  15236. if m.addstatus != nil {
  15237. *m.addstatus += u
  15238. } else {
  15239. m.addstatus = &u
  15240. }
  15241. }
  15242. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15243. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  15244. v := m.addstatus
  15245. if v == nil {
  15246. return
  15247. }
  15248. return *v, true
  15249. }
  15250. // ClearStatus clears the value of the "status" field.
  15251. func (m *SopTaskMutation) ClearStatus() {
  15252. m.status = nil
  15253. m.addstatus = nil
  15254. m.clearedFields[soptask.FieldStatus] = struct{}{}
  15255. }
  15256. // StatusCleared returns if the "status" field was cleared in this mutation.
  15257. func (m *SopTaskMutation) StatusCleared() bool {
  15258. _, ok := m.clearedFields[soptask.FieldStatus]
  15259. return ok
  15260. }
  15261. // ResetStatus resets all changes to the "status" field.
  15262. func (m *SopTaskMutation) ResetStatus() {
  15263. m.status = nil
  15264. m.addstatus = nil
  15265. delete(m.clearedFields, soptask.FieldStatus)
  15266. }
  15267. // SetDeletedAt sets the "deleted_at" field.
  15268. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  15269. m.deleted_at = &t
  15270. }
  15271. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15272. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  15273. v := m.deleted_at
  15274. if v == nil {
  15275. return
  15276. }
  15277. return *v, true
  15278. }
  15279. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  15280. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15282. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15283. if !m.op.Is(OpUpdateOne) {
  15284. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15285. }
  15286. if m.id == nil || m.oldValue == nil {
  15287. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15288. }
  15289. oldValue, err := m.oldValue(ctx)
  15290. if err != nil {
  15291. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15292. }
  15293. return oldValue.DeletedAt, nil
  15294. }
  15295. // ClearDeletedAt clears the value of the "deleted_at" field.
  15296. func (m *SopTaskMutation) ClearDeletedAt() {
  15297. m.deleted_at = nil
  15298. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  15299. }
  15300. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15301. func (m *SopTaskMutation) DeletedAtCleared() bool {
  15302. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  15303. return ok
  15304. }
  15305. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15306. func (m *SopTaskMutation) ResetDeletedAt() {
  15307. m.deleted_at = nil
  15308. delete(m.clearedFields, soptask.FieldDeletedAt)
  15309. }
  15310. // SetName sets the "name" field.
  15311. func (m *SopTaskMutation) SetName(s string) {
  15312. m.name = &s
  15313. }
  15314. // Name returns the value of the "name" field in the mutation.
  15315. func (m *SopTaskMutation) Name() (r string, exists bool) {
  15316. v := m.name
  15317. if v == nil {
  15318. return
  15319. }
  15320. return *v, true
  15321. }
  15322. // OldName returns the old "name" field's value of the SopTask entity.
  15323. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15325. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  15326. if !m.op.Is(OpUpdateOne) {
  15327. return v, errors.New("OldName is only allowed on UpdateOne operations")
  15328. }
  15329. if m.id == nil || m.oldValue == nil {
  15330. return v, errors.New("OldName requires an ID field in the mutation")
  15331. }
  15332. oldValue, err := m.oldValue(ctx)
  15333. if err != nil {
  15334. return v, fmt.Errorf("querying old value for OldName: %w", err)
  15335. }
  15336. return oldValue.Name, nil
  15337. }
  15338. // ResetName resets all changes to the "name" field.
  15339. func (m *SopTaskMutation) ResetName() {
  15340. m.name = nil
  15341. }
  15342. // SetBotWxidList sets the "bot_wxid_list" field.
  15343. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  15344. m.bot_wxid_list = &s
  15345. m.appendbot_wxid_list = nil
  15346. }
  15347. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  15348. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  15349. v := m.bot_wxid_list
  15350. if v == nil {
  15351. return
  15352. }
  15353. return *v, true
  15354. }
  15355. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  15356. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15358. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  15359. if !m.op.Is(OpUpdateOne) {
  15360. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  15361. }
  15362. if m.id == nil || m.oldValue == nil {
  15363. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  15364. }
  15365. oldValue, err := m.oldValue(ctx)
  15366. if err != nil {
  15367. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  15368. }
  15369. return oldValue.BotWxidList, nil
  15370. }
  15371. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  15372. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  15373. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  15374. }
  15375. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  15376. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  15377. if len(m.appendbot_wxid_list) == 0 {
  15378. return nil, false
  15379. }
  15380. return m.appendbot_wxid_list, true
  15381. }
  15382. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  15383. func (m *SopTaskMutation) ClearBotWxidList() {
  15384. m.bot_wxid_list = nil
  15385. m.appendbot_wxid_list = nil
  15386. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  15387. }
  15388. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  15389. func (m *SopTaskMutation) BotWxidListCleared() bool {
  15390. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  15391. return ok
  15392. }
  15393. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  15394. func (m *SopTaskMutation) ResetBotWxidList() {
  15395. m.bot_wxid_list = nil
  15396. m.appendbot_wxid_list = nil
  15397. delete(m.clearedFields, soptask.FieldBotWxidList)
  15398. }
  15399. // SetType sets the "type" field.
  15400. func (m *SopTaskMutation) SetType(i int) {
  15401. m._type = &i
  15402. m.add_type = nil
  15403. }
  15404. // GetType returns the value of the "type" field in the mutation.
  15405. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  15406. v := m._type
  15407. if v == nil {
  15408. return
  15409. }
  15410. return *v, true
  15411. }
  15412. // OldType returns the old "type" field's value of the SopTask entity.
  15413. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15415. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  15416. if !m.op.Is(OpUpdateOne) {
  15417. return v, errors.New("OldType is only allowed on UpdateOne operations")
  15418. }
  15419. if m.id == nil || m.oldValue == nil {
  15420. return v, errors.New("OldType requires an ID field in the mutation")
  15421. }
  15422. oldValue, err := m.oldValue(ctx)
  15423. if err != nil {
  15424. return v, fmt.Errorf("querying old value for OldType: %w", err)
  15425. }
  15426. return oldValue.Type, nil
  15427. }
  15428. // AddType adds i to the "type" field.
  15429. func (m *SopTaskMutation) AddType(i int) {
  15430. if m.add_type != nil {
  15431. *m.add_type += i
  15432. } else {
  15433. m.add_type = &i
  15434. }
  15435. }
  15436. // AddedType returns the value that was added to the "type" field in this mutation.
  15437. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  15438. v := m.add_type
  15439. if v == nil {
  15440. return
  15441. }
  15442. return *v, true
  15443. }
  15444. // ResetType resets all changes to the "type" field.
  15445. func (m *SopTaskMutation) ResetType() {
  15446. m._type = nil
  15447. m.add_type = nil
  15448. }
  15449. // SetPlanStartTime sets the "plan_start_time" field.
  15450. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  15451. m.plan_start_time = &t
  15452. }
  15453. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  15454. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  15455. v := m.plan_start_time
  15456. if v == nil {
  15457. return
  15458. }
  15459. return *v, true
  15460. }
  15461. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  15462. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15464. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  15465. if !m.op.Is(OpUpdateOne) {
  15466. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  15467. }
  15468. if m.id == nil || m.oldValue == nil {
  15469. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  15470. }
  15471. oldValue, err := m.oldValue(ctx)
  15472. if err != nil {
  15473. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  15474. }
  15475. return oldValue.PlanStartTime, nil
  15476. }
  15477. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  15478. func (m *SopTaskMutation) ClearPlanStartTime() {
  15479. m.plan_start_time = nil
  15480. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  15481. }
  15482. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  15483. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  15484. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  15485. return ok
  15486. }
  15487. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  15488. func (m *SopTaskMutation) ResetPlanStartTime() {
  15489. m.plan_start_time = nil
  15490. delete(m.clearedFields, soptask.FieldPlanStartTime)
  15491. }
  15492. // SetPlanEndTime sets the "plan_end_time" field.
  15493. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  15494. m.plan_end_time = &t
  15495. }
  15496. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  15497. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  15498. v := m.plan_end_time
  15499. if v == nil {
  15500. return
  15501. }
  15502. return *v, true
  15503. }
  15504. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  15505. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15507. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  15508. if !m.op.Is(OpUpdateOne) {
  15509. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  15510. }
  15511. if m.id == nil || m.oldValue == nil {
  15512. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  15513. }
  15514. oldValue, err := m.oldValue(ctx)
  15515. if err != nil {
  15516. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  15517. }
  15518. return oldValue.PlanEndTime, nil
  15519. }
  15520. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  15521. func (m *SopTaskMutation) ClearPlanEndTime() {
  15522. m.plan_end_time = nil
  15523. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  15524. }
  15525. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  15526. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  15527. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  15528. return ok
  15529. }
  15530. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  15531. func (m *SopTaskMutation) ResetPlanEndTime() {
  15532. m.plan_end_time = nil
  15533. delete(m.clearedFields, soptask.FieldPlanEndTime)
  15534. }
  15535. // SetCreatorID sets the "creator_id" field.
  15536. func (m *SopTaskMutation) SetCreatorID(s string) {
  15537. m.creator_id = &s
  15538. }
  15539. // CreatorID returns the value of the "creator_id" field in the mutation.
  15540. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  15541. v := m.creator_id
  15542. if v == nil {
  15543. return
  15544. }
  15545. return *v, true
  15546. }
  15547. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  15548. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15550. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  15551. if !m.op.Is(OpUpdateOne) {
  15552. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  15553. }
  15554. if m.id == nil || m.oldValue == nil {
  15555. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  15556. }
  15557. oldValue, err := m.oldValue(ctx)
  15558. if err != nil {
  15559. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  15560. }
  15561. return oldValue.CreatorID, nil
  15562. }
  15563. // ClearCreatorID clears the value of the "creator_id" field.
  15564. func (m *SopTaskMutation) ClearCreatorID() {
  15565. m.creator_id = nil
  15566. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  15567. }
  15568. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  15569. func (m *SopTaskMutation) CreatorIDCleared() bool {
  15570. _, ok := m.clearedFields[soptask.FieldCreatorID]
  15571. return ok
  15572. }
  15573. // ResetCreatorID resets all changes to the "creator_id" field.
  15574. func (m *SopTaskMutation) ResetCreatorID() {
  15575. m.creator_id = nil
  15576. delete(m.clearedFields, soptask.FieldCreatorID)
  15577. }
  15578. // SetOrganizationID sets the "organization_id" field.
  15579. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  15580. m.organization_id = &u
  15581. m.addorganization_id = nil
  15582. }
  15583. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15584. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  15585. v := m.organization_id
  15586. if v == nil {
  15587. return
  15588. }
  15589. return *v, true
  15590. }
  15591. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  15592. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15593. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15594. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15595. if !m.op.Is(OpUpdateOne) {
  15596. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15597. }
  15598. if m.id == nil || m.oldValue == nil {
  15599. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15600. }
  15601. oldValue, err := m.oldValue(ctx)
  15602. if err != nil {
  15603. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15604. }
  15605. return oldValue.OrganizationID, nil
  15606. }
  15607. // AddOrganizationID adds u to the "organization_id" field.
  15608. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  15609. if m.addorganization_id != nil {
  15610. *m.addorganization_id += u
  15611. } else {
  15612. m.addorganization_id = &u
  15613. }
  15614. }
  15615. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15616. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  15617. v := m.addorganization_id
  15618. if v == nil {
  15619. return
  15620. }
  15621. return *v, true
  15622. }
  15623. // ClearOrganizationID clears the value of the "organization_id" field.
  15624. func (m *SopTaskMutation) ClearOrganizationID() {
  15625. m.organization_id = nil
  15626. m.addorganization_id = nil
  15627. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  15628. }
  15629. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15630. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  15631. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  15632. return ok
  15633. }
  15634. // ResetOrganizationID resets all changes to the "organization_id" field.
  15635. func (m *SopTaskMutation) ResetOrganizationID() {
  15636. m.organization_id = nil
  15637. m.addorganization_id = nil
  15638. delete(m.clearedFields, soptask.FieldOrganizationID)
  15639. }
  15640. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  15641. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  15642. if m.task_stages == nil {
  15643. m.task_stages = make(map[uint64]struct{})
  15644. }
  15645. for i := range ids {
  15646. m.task_stages[ids[i]] = struct{}{}
  15647. }
  15648. }
  15649. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  15650. func (m *SopTaskMutation) ClearTaskStages() {
  15651. m.clearedtask_stages = true
  15652. }
  15653. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  15654. func (m *SopTaskMutation) TaskStagesCleared() bool {
  15655. return m.clearedtask_stages
  15656. }
  15657. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  15658. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  15659. if m.removedtask_stages == nil {
  15660. m.removedtask_stages = make(map[uint64]struct{})
  15661. }
  15662. for i := range ids {
  15663. delete(m.task_stages, ids[i])
  15664. m.removedtask_stages[ids[i]] = struct{}{}
  15665. }
  15666. }
  15667. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  15668. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  15669. for id := range m.removedtask_stages {
  15670. ids = append(ids, id)
  15671. }
  15672. return
  15673. }
  15674. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  15675. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  15676. for id := range m.task_stages {
  15677. ids = append(ids, id)
  15678. }
  15679. return
  15680. }
  15681. // ResetTaskStages resets all changes to the "task_stages" edge.
  15682. func (m *SopTaskMutation) ResetTaskStages() {
  15683. m.task_stages = nil
  15684. m.clearedtask_stages = false
  15685. m.removedtask_stages = nil
  15686. }
  15687. // Where appends a list predicates to the SopTaskMutation builder.
  15688. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  15689. m.predicates = append(m.predicates, ps...)
  15690. }
  15691. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  15692. // users can use type-assertion to append predicates that do not depend on any generated package.
  15693. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  15694. p := make([]predicate.SopTask, len(ps))
  15695. for i := range ps {
  15696. p[i] = ps[i]
  15697. }
  15698. m.Where(p...)
  15699. }
  15700. // Op returns the operation name.
  15701. func (m *SopTaskMutation) Op() Op {
  15702. return m.op
  15703. }
  15704. // SetOp allows setting the mutation operation.
  15705. func (m *SopTaskMutation) SetOp(op Op) {
  15706. m.op = op
  15707. }
  15708. // Type returns the node type of this mutation (SopTask).
  15709. func (m *SopTaskMutation) Type() string {
  15710. return m.typ
  15711. }
  15712. // Fields returns all fields that were changed during this mutation. Note that in
  15713. // order to get all numeric fields that were incremented/decremented, call
  15714. // AddedFields().
  15715. func (m *SopTaskMutation) Fields() []string {
  15716. fields := make([]string, 0, 11)
  15717. if m.created_at != nil {
  15718. fields = append(fields, soptask.FieldCreatedAt)
  15719. }
  15720. if m.updated_at != nil {
  15721. fields = append(fields, soptask.FieldUpdatedAt)
  15722. }
  15723. if m.status != nil {
  15724. fields = append(fields, soptask.FieldStatus)
  15725. }
  15726. if m.deleted_at != nil {
  15727. fields = append(fields, soptask.FieldDeletedAt)
  15728. }
  15729. if m.name != nil {
  15730. fields = append(fields, soptask.FieldName)
  15731. }
  15732. if m.bot_wxid_list != nil {
  15733. fields = append(fields, soptask.FieldBotWxidList)
  15734. }
  15735. if m._type != nil {
  15736. fields = append(fields, soptask.FieldType)
  15737. }
  15738. if m.plan_start_time != nil {
  15739. fields = append(fields, soptask.FieldPlanStartTime)
  15740. }
  15741. if m.plan_end_time != nil {
  15742. fields = append(fields, soptask.FieldPlanEndTime)
  15743. }
  15744. if m.creator_id != nil {
  15745. fields = append(fields, soptask.FieldCreatorID)
  15746. }
  15747. if m.organization_id != nil {
  15748. fields = append(fields, soptask.FieldOrganizationID)
  15749. }
  15750. return fields
  15751. }
  15752. // Field returns the value of a field with the given name. The second boolean
  15753. // return value indicates that this field was not set, or was not defined in the
  15754. // schema.
  15755. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  15756. switch name {
  15757. case soptask.FieldCreatedAt:
  15758. return m.CreatedAt()
  15759. case soptask.FieldUpdatedAt:
  15760. return m.UpdatedAt()
  15761. case soptask.FieldStatus:
  15762. return m.Status()
  15763. case soptask.FieldDeletedAt:
  15764. return m.DeletedAt()
  15765. case soptask.FieldName:
  15766. return m.Name()
  15767. case soptask.FieldBotWxidList:
  15768. return m.BotWxidList()
  15769. case soptask.FieldType:
  15770. return m.GetType()
  15771. case soptask.FieldPlanStartTime:
  15772. return m.PlanStartTime()
  15773. case soptask.FieldPlanEndTime:
  15774. return m.PlanEndTime()
  15775. case soptask.FieldCreatorID:
  15776. return m.CreatorID()
  15777. case soptask.FieldOrganizationID:
  15778. return m.OrganizationID()
  15779. }
  15780. return nil, false
  15781. }
  15782. // OldField returns the old value of the field from the database. An error is
  15783. // returned if the mutation operation is not UpdateOne, or the query to the
  15784. // database failed.
  15785. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15786. switch name {
  15787. case soptask.FieldCreatedAt:
  15788. return m.OldCreatedAt(ctx)
  15789. case soptask.FieldUpdatedAt:
  15790. return m.OldUpdatedAt(ctx)
  15791. case soptask.FieldStatus:
  15792. return m.OldStatus(ctx)
  15793. case soptask.FieldDeletedAt:
  15794. return m.OldDeletedAt(ctx)
  15795. case soptask.FieldName:
  15796. return m.OldName(ctx)
  15797. case soptask.FieldBotWxidList:
  15798. return m.OldBotWxidList(ctx)
  15799. case soptask.FieldType:
  15800. return m.OldType(ctx)
  15801. case soptask.FieldPlanStartTime:
  15802. return m.OldPlanStartTime(ctx)
  15803. case soptask.FieldPlanEndTime:
  15804. return m.OldPlanEndTime(ctx)
  15805. case soptask.FieldCreatorID:
  15806. return m.OldCreatorID(ctx)
  15807. case soptask.FieldOrganizationID:
  15808. return m.OldOrganizationID(ctx)
  15809. }
  15810. return nil, fmt.Errorf("unknown SopTask field %s", name)
  15811. }
  15812. // SetField sets the value of a field with the given name. It returns an error if
  15813. // the field is not defined in the schema, or if the type mismatched the field
  15814. // type.
  15815. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  15816. switch name {
  15817. case soptask.FieldCreatedAt:
  15818. v, ok := value.(time.Time)
  15819. if !ok {
  15820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15821. }
  15822. m.SetCreatedAt(v)
  15823. return nil
  15824. case soptask.FieldUpdatedAt:
  15825. v, ok := value.(time.Time)
  15826. if !ok {
  15827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15828. }
  15829. m.SetUpdatedAt(v)
  15830. return nil
  15831. case soptask.FieldStatus:
  15832. v, ok := value.(uint8)
  15833. if !ok {
  15834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15835. }
  15836. m.SetStatus(v)
  15837. return nil
  15838. case soptask.FieldDeletedAt:
  15839. v, ok := value.(time.Time)
  15840. if !ok {
  15841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15842. }
  15843. m.SetDeletedAt(v)
  15844. return nil
  15845. case soptask.FieldName:
  15846. v, ok := value.(string)
  15847. if !ok {
  15848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15849. }
  15850. m.SetName(v)
  15851. return nil
  15852. case soptask.FieldBotWxidList:
  15853. v, ok := value.([]string)
  15854. if !ok {
  15855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15856. }
  15857. m.SetBotWxidList(v)
  15858. return nil
  15859. case soptask.FieldType:
  15860. v, ok := value.(int)
  15861. if !ok {
  15862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15863. }
  15864. m.SetType(v)
  15865. return nil
  15866. case soptask.FieldPlanStartTime:
  15867. v, ok := value.(time.Time)
  15868. if !ok {
  15869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15870. }
  15871. m.SetPlanStartTime(v)
  15872. return nil
  15873. case soptask.FieldPlanEndTime:
  15874. v, ok := value.(time.Time)
  15875. if !ok {
  15876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15877. }
  15878. m.SetPlanEndTime(v)
  15879. return nil
  15880. case soptask.FieldCreatorID:
  15881. v, ok := value.(string)
  15882. if !ok {
  15883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15884. }
  15885. m.SetCreatorID(v)
  15886. return nil
  15887. case soptask.FieldOrganizationID:
  15888. v, ok := value.(uint64)
  15889. if !ok {
  15890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15891. }
  15892. m.SetOrganizationID(v)
  15893. return nil
  15894. }
  15895. return fmt.Errorf("unknown SopTask field %s", name)
  15896. }
  15897. // AddedFields returns all numeric fields that were incremented/decremented during
  15898. // this mutation.
  15899. func (m *SopTaskMutation) AddedFields() []string {
  15900. var fields []string
  15901. if m.addstatus != nil {
  15902. fields = append(fields, soptask.FieldStatus)
  15903. }
  15904. if m.add_type != nil {
  15905. fields = append(fields, soptask.FieldType)
  15906. }
  15907. if m.addorganization_id != nil {
  15908. fields = append(fields, soptask.FieldOrganizationID)
  15909. }
  15910. return fields
  15911. }
  15912. // AddedField returns the numeric value that was incremented/decremented on a field
  15913. // with the given name. The second boolean return value indicates that this field
  15914. // was not set, or was not defined in the schema.
  15915. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  15916. switch name {
  15917. case soptask.FieldStatus:
  15918. return m.AddedStatus()
  15919. case soptask.FieldType:
  15920. return m.AddedType()
  15921. case soptask.FieldOrganizationID:
  15922. return m.AddedOrganizationID()
  15923. }
  15924. return nil, false
  15925. }
  15926. // AddField adds the value to the field with the given name. It returns an error if
  15927. // the field is not defined in the schema, or if the type mismatched the field
  15928. // type.
  15929. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  15930. switch name {
  15931. case soptask.FieldStatus:
  15932. v, ok := value.(int8)
  15933. if !ok {
  15934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15935. }
  15936. m.AddStatus(v)
  15937. return nil
  15938. case soptask.FieldType:
  15939. v, ok := value.(int)
  15940. if !ok {
  15941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15942. }
  15943. m.AddType(v)
  15944. return nil
  15945. case soptask.FieldOrganizationID:
  15946. v, ok := value.(int64)
  15947. if !ok {
  15948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15949. }
  15950. m.AddOrganizationID(v)
  15951. return nil
  15952. }
  15953. return fmt.Errorf("unknown SopTask numeric field %s", name)
  15954. }
  15955. // ClearedFields returns all nullable fields that were cleared during this
  15956. // mutation.
  15957. func (m *SopTaskMutation) ClearedFields() []string {
  15958. var fields []string
  15959. if m.FieldCleared(soptask.FieldStatus) {
  15960. fields = append(fields, soptask.FieldStatus)
  15961. }
  15962. if m.FieldCleared(soptask.FieldDeletedAt) {
  15963. fields = append(fields, soptask.FieldDeletedAt)
  15964. }
  15965. if m.FieldCleared(soptask.FieldBotWxidList) {
  15966. fields = append(fields, soptask.FieldBotWxidList)
  15967. }
  15968. if m.FieldCleared(soptask.FieldPlanStartTime) {
  15969. fields = append(fields, soptask.FieldPlanStartTime)
  15970. }
  15971. if m.FieldCleared(soptask.FieldPlanEndTime) {
  15972. fields = append(fields, soptask.FieldPlanEndTime)
  15973. }
  15974. if m.FieldCleared(soptask.FieldCreatorID) {
  15975. fields = append(fields, soptask.FieldCreatorID)
  15976. }
  15977. if m.FieldCleared(soptask.FieldOrganizationID) {
  15978. fields = append(fields, soptask.FieldOrganizationID)
  15979. }
  15980. return fields
  15981. }
  15982. // FieldCleared returns a boolean indicating if a field with the given name was
  15983. // cleared in this mutation.
  15984. func (m *SopTaskMutation) FieldCleared(name string) bool {
  15985. _, ok := m.clearedFields[name]
  15986. return ok
  15987. }
  15988. // ClearField clears the value of the field with the given name. It returns an
  15989. // error if the field is not defined in the schema.
  15990. func (m *SopTaskMutation) ClearField(name string) error {
  15991. switch name {
  15992. case soptask.FieldStatus:
  15993. m.ClearStatus()
  15994. return nil
  15995. case soptask.FieldDeletedAt:
  15996. m.ClearDeletedAt()
  15997. return nil
  15998. case soptask.FieldBotWxidList:
  15999. m.ClearBotWxidList()
  16000. return nil
  16001. case soptask.FieldPlanStartTime:
  16002. m.ClearPlanStartTime()
  16003. return nil
  16004. case soptask.FieldPlanEndTime:
  16005. m.ClearPlanEndTime()
  16006. return nil
  16007. case soptask.FieldCreatorID:
  16008. m.ClearCreatorID()
  16009. return nil
  16010. case soptask.FieldOrganizationID:
  16011. m.ClearOrganizationID()
  16012. return nil
  16013. }
  16014. return fmt.Errorf("unknown SopTask nullable field %s", name)
  16015. }
  16016. // ResetField resets all changes in the mutation for the field with the given name.
  16017. // It returns an error if the field is not defined in the schema.
  16018. func (m *SopTaskMutation) ResetField(name string) error {
  16019. switch name {
  16020. case soptask.FieldCreatedAt:
  16021. m.ResetCreatedAt()
  16022. return nil
  16023. case soptask.FieldUpdatedAt:
  16024. m.ResetUpdatedAt()
  16025. return nil
  16026. case soptask.FieldStatus:
  16027. m.ResetStatus()
  16028. return nil
  16029. case soptask.FieldDeletedAt:
  16030. m.ResetDeletedAt()
  16031. return nil
  16032. case soptask.FieldName:
  16033. m.ResetName()
  16034. return nil
  16035. case soptask.FieldBotWxidList:
  16036. m.ResetBotWxidList()
  16037. return nil
  16038. case soptask.FieldType:
  16039. m.ResetType()
  16040. return nil
  16041. case soptask.FieldPlanStartTime:
  16042. m.ResetPlanStartTime()
  16043. return nil
  16044. case soptask.FieldPlanEndTime:
  16045. m.ResetPlanEndTime()
  16046. return nil
  16047. case soptask.FieldCreatorID:
  16048. m.ResetCreatorID()
  16049. return nil
  16050. case soptask.FieldOrganizationID:
  16051. m.ResetOrganizationID()
  16052. return nil
  16053. }
  16054. return fmt.Errorf("unknown SopTask field %s", name)
  16055. }
  16056. // AddedEdges returns all edge names that were set/added in this mutation.
  16057. func (m *SopTaskMutation) AddedEdges() []string {
  16058. edges := make([]string, 0, 1)
  16059. if m.task_stages != nil {
  16060. edges = append(edges, soptask.EdgeTaskStages)
  16061. }
  16062. return edges
  16063. }
  16064. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16065. // name in this mutation.
  16066. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  16067. switch name {
  16068. case soptask.EdgeTaskStages:
  16069. ids := make([]ent.Value, 0, len(m.task_stages))
  16070. for id := range m.task_stages {
  16071. ids = append(ids, id)
  16072. }
  16073. return ids
  16074. }
  16075. return nil
  16076. }
  16077. // RemovedEdges returns all edge names that were removed in this mutation.
  16078. func (m *SopTaskMutation) RemovedEdges() []string {
  16079. edges := make([]string, 0, 1)
  16080. if m.removedtask_stages != nil {
  16081. edges = append(edges, soptask.EdgeTaskStages)
  16082. }
  16083. return edges
  16084. }
  16085. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16086. // the given name in this mutation.
  16087. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  16088. switch name {
  16089. case soptask.EdgeTaskStages:
  16090. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  16091. for id := range m.removedtask_stages {
  16092. ids = append(ids, id)
  16093. }
  16094. return ids
  16095. }
  16096. return nil
  16097. }
  16098. // ClearedEdges returns all edge names that were cleared in this mutation.
  16099. func (m *SopTaskMutation) ClearedEdges() []string {
  16100. edges := make([]string, 0, 1)
  16101. if m.clearedtask_stages {
  16102. edges = append(edges, soptask.EdgeTaskStages)
  16103. }
  16104. return edges
  16105. }
  16106. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16107. // was cleared in this mutation.
  16108. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  16109. switch name {
  16110. case soptask.EdgeTaskStages:
  16111. return m.clearedtask_stages
  16112. }
  16113. return false
  16114. }
  16115. // ClearEdge clears the value of the edge with the given name. It returns an error
  16116. // if that edge is not defined in the schema.
  16117. func (m *SopTaskMutation) ClearEdge(name string) error {
  16118. switch name {
  16119. }
  16120. return fmt.Errorf("unknown SopTask unique edge %s", name)
  16121. }
  16122. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16123. // It returns an error if the edge is not defined in the schema.
  16124. func (m *SopTaskMutation) ResetEdge(name string) error {
  16125. switch name {
  16126. case soptask.EdgeTaskStages:
  16127. m.ResetTaskStages()
  16128. return nil
  16129. }
  16130. return fmt.Errorf("unknown SopTask edge %s", name)
  16131. }
  16132. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  16133. type TokenMutation struct {
  16134. config
  16135. op Op
  16136. typ string
  16137. id *uint64
  16138. created_at *time.Time
  16139. updated_at *time.Time
  16140. deleted_at *time.Time
  16141. expire_at *time.Time
  16142. token *string
  16143. mac *string
  16144. clearedFields map[string]struct{}
  16145. done bool
  16146. oldValue func(context.Context) (*Token, error)
  16147. predicates []predicate.Token
  16148. }
  16149. var _ ent.Mutation = (*TokenMutation)(nil)
  16150. // tokenOption allows management of the mutation configuration using functional options.
  16151. type tokenOption func(*TokenMutation)
  16152. // newTokenMutation creates new mutation for the Token entity.
  16153. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  16154. m := &TokenMutation{
  16155. config: c,
  16156. op: op,
  16157. typ: TypeToken,
  16158. clearedFields: make(map[string]struct{}),
  16159. }
  16160. for _, opt := range opts {
  16161. opt(m)
  16162. }
  16163. return m
  16164. }
  16165. // withTokenID sets the ID field of the mutation.
  16166. func withTokenID(id uint64) tokenOption {
  16167. return func(m *TokenMutation) {
  16168. var (
  16169. err error
  16170. once sync.Once
  16171. value *Token
  16172. )
  16173. m.oldValue = func(ctx context.Context) (*Token, error) {
  16174. once.Do(func() {
  16175. if m.done {
  16176. err = errors.New("querying old values post mutation is not allowed")
  16177. } else {
  16178. value, err = m.Client().Token.Get(ctx, id)
  16179. }
  16180. })
  16181. return value, err
  16182. }
  16183. m.id = &id
  16184. }
  16185. }
  16186. // withToken sets the old Token of the mutation.
  16187. func withToken(node *Token) tokenOption {
  16188. return func(m *TokenMutation) {
  16189. m.oldValue = func(context.Context) (*Token, error) {
  16190. return node, nil
  16191. }
  16192. m.id = &node.ID
  16193. }
  16194. }
  16195. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16196. // executed in a transaction (ent.Tx), a transactional client is returned.
  16197. func (m TokenMutation) Client() *Client {
  16198. client := &Client{config: m.config}
  16199. client.init()
  16200. return client
  16201. }
  16202. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16203. // it returns an error otherwise.
  16204. func (m TokenMutation) Tx() (*Tx, error) {
  16205. if _, ok := m.driver.(*txDriver); !ok {
  16206. return nil, errors.New("ent: mutation is not running in a transaction")
  16207. }
  16208. tx := &Tx{config: m.config}
  16209. tx.init()
  16210. return tx, nil
  16211. }
  16212. // SetID sets the value of the id field. Note that this
  16213. // operation is only accepted on creation of Token entities.
  16214. func (m *TokenMutation) SetID(id uint64) {
  16215. m.id = &id
  16216. }
  16217. // ID returns the ID value in the mutation. Note that the ID is only available
  16218. // if it was provided to the builder or after it was returned from the database.
  16219. func (m *TokenMutation) ID() (id uint64, exists bool) {
  16220. if m.id == nil {
  16221. return
  16222. }
  16223. return *m.id, true
  16224. }
  16225. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16226. // That means, if the mutation is applied within a transaction with an isolation level such
  16227. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16228. // or updated by the mutation.
  16229. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  16230. switch {
  16231. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16232. id, exists := m.ID()
  16233. if exists {
  16234. return []uint64{id}, nil
  16235. }
  16236. fallthrough
  16237. case m.op.Is(OpUpdate | OpDelete):
  16238. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  16239. default:
  16240. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16241. }
  16242. }
  16243. // SetCreatedAt sets the "created_at" field.
  16244. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  16245. m.created_at = &t
  16246. }
  16247. // CreatedAt returns the value of the "created_at" field in the mutation.
  16248. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  16249. v := m.created_at
  16250. if v == nil {
  16251. return
  16252. }
  16253. return *v, true
  16254. }
  16255. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  16256. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16258. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16259. if !m.op.Is(OpUpdateOne) {
  16260. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16261. }
  16262. if m.id == nil || m.oldValue == nil {
  16263. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16264. }
  16265. oldValue, err := m.oldValue(ctx)
  16266. if err != nil {
  16267. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16268. }
  16269. return oldValue.CreatedAt, nil
  16270. }
  16271. // ResetCreatedAt resets all changes to the "created_at" field.
  16272. func (m *TokenMutation) ResetCreatedAt() {
  16273. m.created_at = nil
  16274. }
  16275. // SetUpdatedAt sets the "updated_at" field.
  16276. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  16277. m.updated_at = &t
  16278. }
  16279. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16280. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  16281. v := m.updated_at
  16282. if v == nil {
  16283. return
  16284. }
  16285. return *v, true
  16286. }
  16287. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  16288. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16290. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16291. if !m.op.Is(OpUpdateOne) {
  16292. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16293. }
  16294. if m.id == nil || m.oldValue == nil {
  16295. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16296. }
  16297. oldValue, err := m.oldValue(ctx)
  16298. if err != nil {
  16299. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16300. }
  16301. return oldValue.UpdatedAt, nil
  16302. }
  16303. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16304. func (m *TokenMutation) ResetUpdatedAt() {
  16305. m.updated_at = nil
  16306. }
  16307. // SetDeletedAt sets the "deleted_at" field.
  16308. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  16309. m.deleted_at = &t
  16310. }
  16311. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16312. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  16313. v := m.deleted_at
  16314. if v == nil {
  16315. return
  16316. }
  16317. return *v, true
  16318. }
  16319. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  16320. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16322. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16323. if !m.op.Is(OpUpdateOne) {
  16324. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16325. }
  16326. if m.id == nil || m.oldValue == nil {
  16327. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16328. }
  16329. oldValue, err := m.oldValue(ctx)
  16330. if err != nil {
  16331. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16332. }
  16333. return oldValue.DeletedAt, nil
  16334. }
  16335. // ClearDeletedAt clears the value of the "deleted_at" field.
  16336. func (m *TokenMutation) ClearDeletedAt() {
  16337. m.deleted_at = nil
  16338. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  16339. }
  16340. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16341. func (m *TokenMutation) DeletedAtCleared() bool {
  16342. _, ok := m.clearedFields[token.FieldDeletedAt]
  16343. return ok
  16344. }
  16345. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16346. func (m *TokenMutation) ResetDeletedAt() {
  16347. m.deleted_at = nil
  16348. delete(m.clearedFields, token.FieldDeletedAt)
  16349. }
  16350. // SetExpireAt sets the "expire_at" field.
  16351. func (m *TokenMutation) SetExpireAt(t time.Time) {
  16352. m.expire_at = &t
  16353. }
  16354. // ExpireAt returns the value of the "expire_at" field in the mutation.
  16355. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  16356. v := m.expire_at
  16357. if v == nil {
  16358. return
  16359. }
  16360. return *v, true
  16361. }
  16362. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  16363. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16365. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  16366. if !m.op.Is(OpUpdateOne) {
  16367. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  16368. }
  16369. if m.id == nil || m.oldValue == nil {
  16370. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  16371. }
  16372. oldValue, err := m.oldValue(ctx)
  16373. if err != nil {
  16374. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  16375. }
  16376. return oldValue.ExpireAt, nil
  16377. }
  16378. // ClearExpireAt clears the value of the "expire_at" field.
  16379. func (m *TokenMutation) ClearExpireAt() {
  16380. m.expire_at = nil
  16381. m.clearedFields[token.FieldExpireAt] = struct{}{}
  16382. }
  16383. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  16384. func (m *TokenMutation) ExpireAtCleared() bool {
  16385. _, ok := m.clearedFields[token.FieldExpireAt]
  16386. return ok
  16387. }
  16388. // ResetExpireAt resets all changes to the "expire_at" field.
  16389. func (m *TokenMutation) ResetExpireAt() {
  16390. m.expire_at = nil
  16391. delete(m.clearedFields, token.FieldExpireAt)
  16392. }
  16393. // SetToken sets the "token" field.
  16394. func (m *TokenMutation) SetToken(s string) {
  16395. m.token = &s
  16396. }
  16397. // Token returns the value of the "token" field in the mutation.
  16398. func (m *TokenMutation) Token() (r string, exists bool) {
  16399. v := m.token
  16400. if v == nil {
  16401. return
  16402. }
  16403. return *v, true
  16404. }
  16405. // OldToken returns the old "token" field's value of the Token entity.
  16406. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16408. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  16409. if !m.op.Is(OpUpdateOne) {
  16410. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  16411. }
  16412. if m.id == nil || m.oldValue == nil {
  16413. return v, errors.New("OldToken requires an ID field in the mutation")
  16414. }
  16415. oldValue, err := m.oldValue(ctx)
  16416. if err != nil {
  16417. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  16418. }
  16419. return oldValue.Token, nil
  16420. }
  16421. // ClearToken clears the value of the "token" field.
  16422. func (m *TokenMutation) ClearToken() {
  16423. m.token = nil
  16424. m.clearedFields[token.FieldToken] = struct{}{}
  16425. }
  16426. // TokenCleared returns if the "token" field was cleared in this mutation.
  16427. func (m *TokenMutation) TokenCleared() bool {
  16428. _, ok := m.clearedFields[token.FieldToken]
  16429. return ok
  16430. }
  16431. // ResetToken resets all changes to the "token" field.
  16432. func (m *TokenMutation) ResetToken() {
  16433. m.token = nil
  16434. delete(m.clearedFields, token.FieldToken)
  16435. }
  16436. // SetMAC sets the "mac" field.
  16437. func (m *TokenMutation) SetMAC(s string) {
  16438. m.mac = &s
  16439. }
  16440. // MAC returns the value of the "mac" field in the mutation.
  16441. func (m *TokenMutation) MAC() (r string, exists bool) {
  16442. v := m.mac
  16443. if v == nil {
  16444. return
  16445. }
  16446. return *v, true
  16447. }
  16448. // OldMAC returns the old "mac" field's value of the Token entity.
  16449. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16451. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  16452. if !m.op.Is(OpUpdateOne) {
  16453. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  16454. }
  16455. if m.id == nil || m.oldValue == nil {
  16456. return v, errors.New("OldMAC requires an ID field in the mutation")
  16457. }
  16458. oldValue, err := m.oldValue(ctx)
  16459. if err != nil {
  16460. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  16461. }
  16462. return oldValue.MAC, nil
  16463. }
  16464. // ResetMAC resets all changes to the "mac" field.
  16465. func (m *TokenMutation) ResetMAC() {
  16466. m.mac = nil
  16467. }
  16468. // Where appends a list predicates to the TokenMutation builder.
  16469. func (m *TokenMutation) Where(ps ...predicate.Token) {
  16470. m.predicates = append(m.predicates, ps...)
  16471. }
  16472. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  16473. // users can use type-assertion to append predicates that do not depend on any generated package.
  16474. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  16475. p := make([]predicate.Token, len(ps))
  16476. for i := range ps {
  16477. p[i] = ps[i]
  16478. }
  16479. m.Where(p...)
  16480. }
  16481. // Op returns the operation name.
  16482. func (m *TokenMutation) Op() Op {
  16483. return m.op
  16484. }
  16485. // SetOp allows setting the mutation operation.
  16486. func (m *TokenMutation) SetOp(op Op) {
  16487. m.op = op
  16488. }
  16489. // Type returns the node type of this mutation (Token).
  16490. func (m *TokenMutation) Type() string {
  16491. return m.typ
  16492. }
  16493. // Fields returns all fields that were changed during this mutation. Note that in
  16494. // order to get all numeric fields that were incremented/decremented, call
  16495. // AddedFields().
  16496. func (m *TokenMutation) Fields() []string {
  16497. fields := make([]string, 0, 6)
  16498. if m.created_at != nil {
  16499. fields = append(fields, token.FieldCreatedAt)
  16500. }
  16501. if m.updated_at != nil {
  16502. fields = append(fields, token.FieldUpdatedAt)
  16503. }
  16504. if m.deleted_at != nil {
  16505. fields = append(fields, token.FieldDeletedAt)
  16506. }
  16507. if m.expire_at != nil {
  16508. fields = append(fields, token.FieldExpireAt)
  16509. }
  16510. if m.token != nil {
  16511. fields = append(fields, token.FieldToken)
  16512. }
  16513. if m.mac != nil {
  16514. fields = append(fields, token.FieldMAC)
  16515. }
  16516. return fields
  16517. }
  16518. // Field returns the value of a field with the given name. The second boolean
  16519. // return value indicates that this field was not set, or was not defined in the
  16520. // schema.
  16521. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  16522. switch name {
  16523. case token.FieldCreatedAt:
  16524. return m.CreatedAt()
  16525. case token.FieldUpdatedAt:
  16526. return m.UpdatedAt()
  16527. case token.FieldDeletedAt:
  16528. return m.DeletedAt()
  16529. case token.FieldExpireAt:
  16530. return m.ExpireAt()
  16531. case token.FieldToken:
  16532. return m.Token()
  16533. case token.FieldMAC:
  16534. return m.MAC()
  16535. }
  16536. return nil, false
  16537. }
  16538. // OldField returns the old value of the field from the database. An error is
  16539. // returned if the mutation operation is not UpdateOne, or the query to the
  16540. // database failed.
  16541. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16542. switch name {
  16543. case token.FieldCreatedAt:
  16544. return m.OldCreatedAt(ctx)
  16545. case token.FieldUpdatedAt:
  16546. return m.OldUpdatedAt(ctx)
  16547. case token.FieldDeletedAt:
  16548. return m.OldDeletedAt(ctx)
  16549. case token.FieldExpireAt:
  16550. return m.OldExpireAt(ctx)
  16551. case token.FieldToken:
  16552. return m.OldToken(ctx)
  16553. case token.FieldMAC:
  16554. return m.OldMAC(ctx)
  16555. }
  16556. return nil, fmt.Errorf("unknown Token field %s", name)
  16557. }
  16558. // SetField sets the value of a field with the given name. It returns an error if
  16559. // the field is not defined in the schema, or if the type mismatched the field
  16560. // type.
  16561. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  16562. switch name {
  16563. case token.FieldCreatedAt:
  16564. v, ok := value.(time.Time)
  16565. if !ok {
  16566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16567. }
  16568. m.SetCreatedAt(v)
  16569. return nil
  16570. case token.FieldUpdatedAt:
  16571. v, ok := value.(time.Time)
  16572. if !ok {
  16573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16574. }
  16575. m.SetUpdatedAt(v)
  16576. return nil
  16577. case token.FieldDeletedAt:
  16578. v, ok := value.(time.Time)
  16579. if !ok {
  16580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16581. }
  16582. m.SetDeletedAt(v)
  16583. return nil
  16584. case token.FieldExpireAt:
  16585. v, ok := value.(time.Time)
  16586. if !ok {
  16587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16588. }
  16589. m.SetExpireAt(v)
  16590. return nil
  16591. case token.FieldToken:
  16592. v, ok := value.(string)
  16593. if !ok {
  16594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16595. }
  16596. m.SetToken(v)
  16597. return nil
  16598. case token.FieldMAC:
  16599. v, ok := value.(string)
  16600. if !ok {
  16601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16602. }
  16603. m.SetMAC(v)
  16604. return nil
  16605. }
  16606. return fmt.Errorf("unknown Token field %s", name)
  16607. }
  16608. // AddedFields returns all numeric fields that were incremented/decremented during
  16609. // this mutation.
  16610. func (m *TokenMutation) AddedFields() []string {
  16611. return nil
  16612. }
  16613. // AddedField returns the numeric value that was incremented/decremented on a field
  16614. // with the given name. The second boolean return value indicates that this field
  16615. // was not set, or was not defined in the schema.
  16616. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  16617. return nil, false
  16618. }
  16619. // AddField adds the value to the field with the given name. It returns an error if
  16620. // the field is not defined in the schema, or if the type mismatched the field
  16621. // type.
  16622. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  16623. switch name {
  16624. }
  16625. return fmt.Errorf("unknown Token numeric field %s", name)
  16626. }
  16627. // ClearedFields returns all nullable fields that were cleared during this
  16628. // mutation.
  16629. func (m *TokenMutation) ClearedFields() []string {
  16630. var fields []string
  16631. if m.FieldCleared(token.FieldDeletedAt) {
  16632. fields = append(fields, token.FieldDeletedAt)
  16633. }
  16634. if m.FieldCleared(token.FieldExpireAt) {
  16635. fields = append(fields, token.FieldExpireAt)
  16636. }
  16637. if m.FieldCleared(token.FieldToken) {
  16638. fields = append(fields, token.FieldToken)
  16639. }
  16640. return fields
  16641. }
  16642. // FieldCleared returns a boolean indicating if a field with the given name was
  16643. // cleared in this mutation.
  16644. func (m *TokenMutation) FieldCleared(name string) bool {
  16645. _, ok := m.clearedFields[name]
  16646. return ok
  16647. }
  16648. // ClearField clears the value of the field with the given name. It returns an
  16649. // error if the field is not defined in the schema.
  16650. func (m *TokenMutation) ClearField(name string) error {
  16651. switch name {
  16652. case token.FieldDeletedAt:
  16653. m.ClearDeletedAt()
  16654. return nil
  16655. case token.FieldExpireAt:
  16656. m.ClearExpireAt()
  16657. return nil
  16658. case token.FieldToken:
  16659. m.ClearToken()
  16660. return nil
  16661. }
  16662. return fmt.Errorf("unknown Token nullable field %s", name)
  16663. }
  16664. // ResetField resets all changes in the mutation for the field with the given name.
  16665. // It returns an error if the field is not defined in the schema.
  16666. func (m *TokenMutation) ResetField(name string) error {
  16667. switch name {
  16668. case token.FieldCreatedAt:
  16669. m.ResetCreatedAt()
  16670. return nil
  16671. case token.FieldUpdatedAt:
  16672. m.ResetUpdatedAt()
  16673. return nil
  16674. case token.FieldDeletedAt:
  16675. m.ResetDeletedAt()
  16676. return nil
  16677. case token.FieldExpireAt:
  16678. m.ResetExpireAt()
  16679. return nil
  16680. case token.FieldToken:
  16681. m.ResetToken()
  16682. return nil
  16683. case token.FieldMAC:
  16684. m.ResetMAC()
  16685. return nil
  16686. }
  16687. return fmt.Errorf("unknown Token field %s", name)
  16688. }
  16689. // AddedEdges returns all edge names that were set/added in this mutation.
  16690. func (m *TokenMutation) AddedEdges() []string {
  16691. edges := make([]string, 0, 0)
  16692. return edges
  16693. }
  16694. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16695. // name in this mutation.
  16696. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  16697. return nil
  16698. }
  16699. // RemovedEdges returns all edge names that were removed in this mutation.
  16700. func (m *TokenMutation) RemovedEdges() []string {
  16701. edges := make([]string, 0, 0)
  16702. return edges
  16703. }
  16704. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16705. // the given name in this mutation.
  16706. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  16707. return nil
  16708. }
  16709. // ClearedEdges returns all edge names that were cleared in this mutation.
  16710. func (m *TokenMutation) ClearedEdges() []string {
  16711. edges := make([]string, 0, 0)
  16712. return edges
  16713. }
  16714. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16715. // was cleared in this mutation.
  16716. func (m *TokenMutation) EdgeCleared(name string) bool {
  16717. return false
  16718. }
  16719. // ClearEdge clears the value of the edge with the given name. It returns an error
  16720. // if that edge is not defined in the schema.
  16721. func (m *TokenMutation) ClearEdge(name string) error {
  16722. return fmt.Errorf("unknown Token unique edge %s", name)
  16723. }
  16724. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16725. // It returns an error if the edge is not defined in the schema.
  16726. func (m *TokenMutation) ResetEdge(name string) error {
  16727. return fmt.Errorf("unknown Token edge %s", name)
  16728. }
  16729. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  16730. type TutorialMutation struct {
  16731. config
  16732. op Op
  16733. typ string
  16734. id *uint64
  16735. created_at *time.Time
  16736. updated_at *time.Time
  16737. deleted_at *time.Time
  16738. index *int
  16739. addindex *int
  16740. title *string
  16741. content *string
  16742. organization_id *uint64
  16743. addorganization_id *int64
  16744. clearedFields map[string]struct{}
  16745. employee *uint64
  16746. clearedemployee bool
  16747. done bool
  16748. oldValue func(context.Context) (*Tutorial, error)
  16749. predicates []predicate.Tutorial
  16750. }
  16751. var _ ent.Mutation = (*TutorialMutation)(nil)
  16752. // tutorialOption allows management of the mutation configuration using functional options.
  16753. type tutorialOption func(*TutorialMutation)
  16754. // newTutorialMutation creates new mutation for the Tutorial entity.
  16755. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  16756. m := &TutorialMutation{
  16757. config: c,
  16758. op: op,
  16759. typ: TypeTutorial,
  16760. clearedFields: make(map[string]struct{}),
  16761. }
  16762. for _, opt := range opts {
  16763. opt(m)
  16764. }
  16765. return m
  16766. }
  16767. // withTutorialID sets the ID field of the mutation.
  16768. func withTutorialID(id uint64) tutorialOption {
  16769. return func(m *TutorialMutation) {
  16770. var (
  16771. err error
  16772. once sync.Once
  16773. value *Tutorial
  16774. )
  16775. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  16776. once.Do(func() {
  16777. if m.done {
  16778. err = errors.New("querying old values post mutation is not allowed")
  16779. } else {
  16780. value, err = m.Client().Tutorial.Get(ctx, id)
  16781. }
  16782. })
  16783. return value, err
  16784. }
  16785. m.id = &id
  16786. }
  16787. }
  16788. // withTutorial sets the old Tutorial of the mutation.
  16789. func withTutorial(node *Tutorial) tutorialOption {
  16790. return func(m *TutorialMutation) {
  16791. m.oldValue = func(context.Context) (*Tutorial, error) {
  16792. return node, nil
  16793. }
  16794. m.id = &node.ID
  16795. }
  16796. }
  16797. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16798. // executed in a transaction (ent.Tx), a transactional client is returned.
  16799. func (m TutorialMutation) Client() *Client {
  16800. client := &Client{config: m.config}
  16801. client.init()
  16802. return client
  16803. }
  16804. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16805. // it returns an error otherwise.
  16806. func (m TutorialMutation) Tx() (*Tx, error) {
  16807. if _, ok := m.driver.(*txDriver); !ok {
  16808. return nil, errors.New("ent: mutation is not running in a transaction")
  16809. }
  16810. tx := &Tx{config: m.config}
  16811. tx.init()
  16812. return tx, nil
  16813. }
  16814. // SetID sets the value of the id field. Note that this
  16815. // operation is only accepted on creation of Tutorial entities.
  16816. func (m *TutorialMutation) SetID(id uint64) {
  16817. m.id = &id
  16818. }
  16819. // ID returns the ID value in the mutation. Note that the ID is only available
  16820. // if it was provided to the builder or after it was returned from the database.
  16821. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  16822. if m.id == nil {
  16823. return
  16824. }
  16825. return *m.id, true
  16826. }
  16827. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16828. // That means, if the mutation is applied within a transaction with an isolation level such
  16829. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16830. // or updated by the mutation.
  16831. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  16832. switch {
  16833. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16834. id, exists := m.ID()
  16835. if exists {
  16836. return []uint64{id}, nil
  16837. }
  16838. fallthrough
  16839. case m.op.Is(OpUpdate | OpDelete):
  16840. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  16841. default:
  16842. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16843. }
  16844. }
  16845. // SetCreatedAt sets the "created_at" field.
  16846. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  16847. m.created_at = &t
  16848. }
  16849. // CreatedAt returns the value of the "created_at" field in the mutation.
  16850. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  16851. v := m.created_at
  16852. if v == nil {
  16853. return
  16854. }
  16855. return *v, true
  16856. }
  16857. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  16858. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16860. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16861. if !m.op.Is(OpUpdateOne) {
  16862. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16863. }
  16864. if m.id == nil || m.oldValue == nil {
  16865. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16866. }
  16867. oldValue, err := m.oldValue(ctx)
  16868. if err != nil {
  16869. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16870. }
  16871. return oldValue.CreatedAt, nil
  16872. }
  16873. // ResetCreatedAt resets all changes to the "created_at" field.
  16874. func (m *TutorialMutation) ResetCreatedAt() {
  16875. m.created_at = nil
  16876. }
  16877. // SetUpdatedAt sets the "updated_at" field.
  16878. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  16879. m.updated_at = &t
  16880. }
  16881. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16882. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  16883. v := m.updated_at
  16884. if v == nil {
  16885. return
  16886. }
  16887. return *v, true
  16888. }
  16889. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  16890. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16892. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16893. if !m.op.Is(OpUpdateOne) {
  16894. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16895. }
  16896. if m.id == nil || m.oldValue == nil {
  16897. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16898. }
  16899. oldValue, err := m.oldValue(ctx)
  16900. if err != nil {
  16901. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16902. }
  16903. return oldValue.UpdatedAt, nil
  16904. }
  16905. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16906. func (m *TutorialMutation) ResetUpdatedAt() {
  16907. m.updated_at = nil
  16908. }
  16909. // SetDeletedAt sets the "deleted_at" field.
  16910. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  16911. m.deleted_at = &t
  16912. }
  16913. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16914. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  16915. v := m.deleted_at
  16916. if v == nil {
  16917. return
  16918. }
  16919. return *v, true
  16920. }
  16921. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  16922. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16924. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16925. if !m.op.Is(OpUpdateOne) {
  16926. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16927. }
  16928. if m.id == nil || m.oldValue == nil {
  16929. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16930. }
  16931. oldValue, err := m.oldValue(ctx)
  16932. if err != nil {
  16933. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16934. }
  16935. return oldValue.DeletedAt, nil
  16936. }
  16937. // ClearDeletedAt clears the value of the "deleted_at" field.
  16938. func (m *TutorialMutation) ClearDeletedAt() {
  16939. m.deleted_at = nil
  16940. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  16941. }
  16942. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16943. func (m *TutorialMutation) DeletedAtCleared() bool {
  16944. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  16945. return ok
  16946. }
  16947. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16948. func (m *TutorialMutation) ResetDeletedAt() {
  16949. m.deleted_at = nil
  16950. delete(m.clearedFields, tutorial.FieldDeletedAt)
  16951. }
  16952. // SetEmployeeID sets the "employee_id" field.
  16953. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  16954. m.employee = &u
  16955. }
  16956. // EmployeeID returns the value of the "employee_id" field in the mutation.
  16957. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  16958. v := m.employee
  16959. if v == nil {
  16960. return
  16961. }
  16962. return *v, true
  16963. }
  16964. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  16965. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16967. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  16968. if !m.op.Is(OpUpdateOne) {
  16969. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  16970. }
  16971. if m.id == nil || m.oldValue == nil {
  16972. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  16973. }
  16974. oldValue, err := m.oldValue(ctx)
  16975. if err != nil {
  16976. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  16977. }
  16978. return oldValue.EmployeeID, nil
  16979. }
  16980. // ResetEmployeeID resets all changes to the "employee_id" field.
  16981. func (m *TutorialMutation) ResetEmployeeID() {
  16982. m.employee = nil
  16983. }
  16984. // SetIndex sets the "index" field.
  16985. func (m *TutorialMutation) SetIndex(i int) {
  16986. m.index = &i
  16987. m.addindex = nil
  16988. }
  16989. // Index returns the value of the "index" field in the mutation.
  16990. func (m *TutorialMutation) Index() (r int, exists bool) {
  16991. v := m.index
  16992. if v == nil {
  16993. return
  16994. }
  16995. return *v, true
  16996. }
  16997. // OldIndex returns the old "index" field's value of the Tutorial entity.
  16998. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17000. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  17001. if !m.op.Is(OpUpdateOne) {
  17002. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  17003. }
  17004. if m.id == nil || m.oldValue == nil {
  17005. return v, errors.New("OldIndex requires an ID field in the mutation")
  17006. }
  17007. oldValue, err := m.oldValue(ctx)
  17008. if err != nil {
  17009. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  17010. }
  17011. return oldValue.Index, nil
  17012. }
  17013. // AddIndex adds i to the "index" field.
  17014. func (m *TutorialMutation) AddIndex(i int) {
  17015. if m.addindex != nil {
  17016. *m.addindex += i
  17017. } else {
  17018. m.addindex = &i
  17019. }
  17020. }
  17021. // AddedIndex returns the value that was added to the "index" field in this mutation.
  17022. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  17023. v := m.addindex
  17024. if v == nil {
  17025. return
  17026. }
  17027. return *v, true
  17028. }
  17029. // ResetIndex resets all changes to the "index" field.
  17030. func (m *TutorialMutation) ResetIndex() {
  17031. m.index = nil
  17032. m.addindex = nil
  17033. }
  17034. // SetTitle sets the "title" field.
  17035. func (m *TutorialMutation) SetTitle(s string) {
  17036. m.title = &s
  17037. }
  17038. // Title returns the value of the "title" field in the mutation.
  17039. func (m *TutorialMutation) Title() (r string, exists bool) {
  17040. v := m.title
  17041. if v == nil {
  17042. return
  17043. }
  17044. return *v, true
  17045. }
  17046. // OldTitle returns the old "title" field's value of the Tutorial entity.
  17047. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  17048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17049. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  17050. if !m.op.Is(OpUpdateOne) {
  17051. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  17052. }
  17053. if m.id == nil || m.oldValue == nil {
  17054. return v, errors.New("OldTitle requires an ID field in the mutation")
  17055. }
  17056. oldValue, err := m.oldValue(ctx)
  17057. if err != nil {
  17058. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  17059. }
  17060. return oldValue.Title, nil
  17061. }
  17062. // ResetTitle resets all changes to the "title" field.
  17063. func (m *TutorialMutation) ResetTitle() {
  17064. m.title = nil
  17065. }
  17066. // SetContent sets the "content" field.
  17067. func (m *TutorialMutation) SetContent(s string) {
  17068. m.content = &s
  17069. }
  17070. // Content returns the value of the "content" field in the mutation.
  17071. func (m *TutorialMutation) Content() (r string, exists bool) {
  17072. v := m.content
  17073. if v == nil {
  17074. return
  17075. }
  17076. return *v, true
  17077. }
  17078. // OldContent returns the old "content" field's value of the Tutorial entity.
  17079. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  17080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17081. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  17082. if !m.op.Is(OpUpdateOne) {
  17083. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  17084. }
  17085. if m.id == nil || m.oldValue == nil {
  17086. return v, errors.New("OldContent requires an ID field in the mutation")
  17087. }
  17088. oldValue, err := m.oldValue(ctx)
  17089. if err != nil {
  17090. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  17091. }
  17092. return oldValue.Content, nil
  17093. }
  17094. // ResetContent resets all changes to the "content" field.
  17095. func (m *TutorialMutation) ResetContent() {
  17096. m.content = nil
  17097. }
  17098. // SetOrganizationID sets the "organization_id" field.
  17099. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  17100. m.organization_id = &u
  17101. m.addorganization_id = nil
  17102. }
  17103. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17104. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  17105. v := m.organization_id
  17106. if v == nil {
  17107. return
  17108. }
  17109. return *v, true
  17110. }
  17111. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  17112. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  17113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17114. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17115. if !m.op.Is(OpUpdateOne) {
  17116. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17117. }
  17118. if m.id == nil || m.oldValue == nil {
  17119. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17120. }
  17121. oldValue, err := m.oldValue(ctx)
  17122. if err != nil {
  17123. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17124. }
  17125. return oldValue.OrganizationID, nil
  17126. }
  17127. // AddOrganizationID adds u to the "organization_id" field.
  17128. func (m *TutorialMutation) AddOrganizationID(u int64) {
  17129. if m.addorganization_id != nil {
  17130. *m.addorganization_id += u
  17131. } else {
  17132. m.addorganization_id = &u
  17133. }
  17134. }
  17135. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17136. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  17137. v := m.addorganization_id
  17138. if v == nil {
  17139. return
  17140. }
  17141. return *v, true
  17142. }
  17143. // ResetOrganizationID resets all changes to the "organization_id" field.
  17144. func (m *TutorialMutation) ResetOrganizationID() {
  17145. m.organization_id = nil
  17146. m.addorganization_id = nil
  17147. }
  17148. // ClearEmployee clears the "employee" edge to the Employee entity.
  17149. func (m *TutorialMutation) ClearEmployee() {
  17150. m.clearedemployee = true
  17151. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  17152. }
  17153. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  17154. func (m *TutorialMutation) EmployeeCleared() bool {
  17155. return m.clearedemployee
  17156. }
  17157. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  17158. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17159. // EmployeeID instead. It exists only for internal usage by the builders.
  17160. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  17161. if id := m.employee; id != nil {
  17162. ids = append(ids, *id)
  17163. }
  17164. return
  17165. }
  17166. // ResetEmployee resets all changes to the "employee" edge.
  17167. func (m *TutorialMutation) ResetEmployee() {
  17168. m.employee = nil
  17169. m.clearedemployee = false
  17170. }
  17171. // Where appends a list predicates to the TutorialMutation builder.
  17172. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  17173. m.predicates = append(m.predicates, ps...)
  17174. }
  17175. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  17176. // users can use type-assertion to append predicates that do not depend on any generated package.
  17177. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  17178. p := make([]predicate.Tutorial, len(ps))
  17179. for i := range ps {
  17180. p[i] = ps[i]
  17181. }
  17182. m.Where(p...)
  17183. }
  17184. // Op returns the operation name.
  17185. func (m *TutorialMutation) Op() Op {
  17186. return m.op
  17187. }
  17188. // SetOp allows setting the mutation operation.
  17189. func (m *TutorialMutation) SetOp(op Op) {
  17190. m.op = op
  17191. }
  17192. // Type returns the node type of this mutation (Tutorial).
  17193. func (m *TutorialMutation) Type() string {
  17194. return m.typ
  17195. }
  17196. // Fields returns all fields that were changed during this mutation. Note that in
  17197. // order to get all numeric fields that were incremented/decremented, call
  17198. // AddedFields().
  17199. func (m *TutorialMutation) Fields() []string {
  17200. fields := make([]string, 0, 8)
  17201. if m.created_at != nil {
  17202. fields = append(fields, tutorial.FieldCreatedAt)
  17203. }
  17204. if m.updated_at != nil {
  17205. fields = append(fields, tutorial.FieldUpdatedAt)
  17206. }
  17207. if m.deleted_at != nil {
  17208. fields = append(fields, tutorial.FieldDeletedAt)
  17209. }
  17210. if m.employee != nil {
  17211. fields = append(fields, tutorial.FieldEmployeeID)
  17212. }
  17213. if m.index != nil {
  17214. fields = append(fields, tutorial.FieldIndex)
  17215. }
  17216. if m.title != nil {
  17217. fields = append(fields, tutorial.FieldTitle)
  17218. }
  17219. if m.content != nil {
  17220. fields = append(fields, tutorial.FieldContent)
  17221. }
  17222. if m.organization_id != nil {
  17223. fields = append(fields, tutorial.FieldOrganizationID)
  17224. }
  17225. return fields
  17226. }
  17227. // Field returns the value of a field with the given name. The second boolean
  17228. // return value indicates that this field was not set, or was not defined in the
  17229. // schema.
  17230. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  17231. switch name {
  17232. case tutorial.FieldCreatedAt:
  17233. return m.CreatedAt()
  17234. case tutorial.FieldUpdatedAt:
  17235. return m.UpdatedAt()
  17236. case tutorial.FieldDeletedAt:
  17237. return m.DeletedAt()
  17238. case tutorial.FieldEmployeeID:
  17239. return m.EmployeeID()
  17240. case tutorial.FieldIndex:
  17241. return m.Index()
  17242. case tutorial.FieldTitle:
  17243. return m.Title()
  17244. case tutorial.FieldContent:
  17245. return m.Content()
  17246. case tutorial.FieldOrganizationID:
  17247. return m.OrganizationID()
  17248. }
  17249. return nil, false
  17250. }
  17251. // OldField returns the old value of the field from the database. An error is
  17252. // returned if the mutation operation is not UpdateOne, or the query to the
  17253. // database failed.
  17254. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17255. switch name {
  17256. case tutorial.FieldCreatedAt:
  17257. return m.OldCreatedAt(ctx)
  17258. case tutorial.FieldUpdatedAt:
  17259. return m.OldUpdatedAt(ctx)
  17260. case tutorial.FieldDeletedAt:
  17261. return m.OldDeletedAt(ctx)
  17262. case tutorial.FieldEmployeeID:
  17263. return m.OldEmployeeID(ctx)
  17264. case tutorial.FieldIndex:
  17265. return m.OldIndex(ctx)
  17266. case tutorial.FieldTitle:
  17267. return m.OldTitle(ctx)
  17268. case tutorial.FieldContent:
  17269. return m.OldContent(ctx)
  17270. case tutorial.FieldOrganizationID:
  17271. return m.OldOrganizationID(ctx)
  17272. }
  17273. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  17274. }
  17275. // SetField sets the value of a field with the given name. It returns an error if
  17276. // the field is not defined in the schema, or if the type mismatched the field
  17277. // type.
  17278. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  17279. switch name {
  17280. case tutorial.FieldCreatedAt:
  17281. v, ok := value.(time.Time)
  17282. if !ok {
  17283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17284. }
  17285. m.SetCreatedAt(v)
  17286. return nil
  17287. case tutorial.FieldUpdatedAt:
  17288. v, ok := value.(time.Time)
  17289. if !ok {
  17290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17291. }
  17292. m.SetUpdatedAt(v)
  17293. return nil
  17294. case tutorial.FieldDeletedAt:
  17295. v, ok := value.(time.Time)
  17296. if !ok {
  17297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17298. }
  17299. m.SetDeletedAt(v)
  17300. return nil
  17301. case tutorial.FieldEmployeeID:
  17302. v, ok := value.(uint64)
  17303. if !ok {
  17304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17305. }
  17306. m.SetEmployeeID(v)
  17307. return nil
  17308. case tutorial.FieldIndex:
  17309. v, ok := value.(int)
  17310. if !ok {
  17311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17312. }
  17313. m.SetIndex(v)
  17314. return nil
  17315. case tutorial.FieldTitle:
  17316. v, ok := value.(string)
  17317. if !ok {
  17318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17319. }
  17320. m.SetTitle(v)
  17321. return nil
  17322. case tutorial.FieldContent:
  17323. v, ok := value.(string)
  17324. if !ok {
  17325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17326. }
  17327. m.SetContent(v)
  17328. return nil
  17329. case tutorial.FieldOrganizationID:
  17330. v, ok := value.(uint64)
  17331. if !ok {
  17332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17333. }
  17334. m.SetOrganizationID(v)
  17335. return nil
  17336. }
  17337. return fmt.Errorf("unknown Tutorial field %s", name)
  17338. }
  17339. // AddedFields returns all numeric fields that were incremented/decremented during
  17340. // this mutation.
  17341. func (m *TutorialMutation) AddedFields() []string {
  17342. var fields []string
  17343. if m.addindex != nil {
  17344. fields = append(fields, tutorial.FieldIndex)
  17345. }
  17346. if m.addorganization_id != nil {
  17347. fields = append(fields, tutorial.FieldOrganizationID)
  17348. }
  17349. return fields
  17350. }
  17351. // AddedField returns the numeric value that was incremented/decremented on a field
  17352. // with the given name. The second boolean return value indicates that this field
  17353. // was not set, or was not defined in the schema.
  17354. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  17355. switch name {
  17356. case tutorial.FieldIndex:
  17357. return m.AddedIndex()
  17358. case tutorial.FieldOrganizationID:
  17359. return m.AddedOrganizationID()
  17360. }
  17361. return nil, false
  17362. }
  17363. // AddField adds the value to the field with the given name. It returns an error if
  17364. // the field is not defined in the schema, or if the type mismatched the field
  17365. // type.
  17366. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  17367. switch name {
  17368. case tutorial.FieldIndex:
  17369. v, ok := value.(int)
  17370. if !ok {
  17371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17372. }
  17373. m.AddIndex(v)
  17374. return nil
  17375. case tutorial.FieldOrganizationID:
  17376. v, ok := value.(int64)
  17377. if !ok {
  17378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17379. }
  17380. m.AddOrganizationID(v)
  17381. return nil
  17382. }
  17383. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  17384. }
  17385. // ClearedFields returns all nullable fields that were cleared during this
  17386. // mutation.
  17387. func (m *TutorialMutation) ClearedFields() []string {
  17388. var fields []string
  17389. if m.FieldCleared(tutorial.FieldDeletedAt) {
  17390. fields = append(fields, tutorial.FieldDeletedAt)
  17391. }
  17392. return fields
  17393. }
  17394. // FieldCleared returns a boolean indicating if a field with the given name was
  17395. // cleared in this mutation.
  17396. func (m *TutorialMutation) FieldCleared(name string) bool {
  17397. _, ok := m.clearedFields[name]
  17398. return ok
  17399. }
  17400. // ClearField clears the value of the field with the given name. It returns an
  17401. // error if the field is not defined in the schema.
  17402. func (m *TutorialMutation) ClearField(name string) error {
  17403. switch name {
  17404. case tutorial.FieldDeletedAt:
  17405. m.ClearDeletedAt()
  17406. return nil
  17407. }
  17408. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  17409. }
  17410. // ResetField resets all changes in the mutation for the field with the given name.
  17411. // It returns an error if the field is not defined in the schema.
  17412. func (m *TutorialMutation) ResetField(name string) error {
  17413. switch name {
  17414. case tutorial.FieldCreatedAt:
  17415. m.ResetCreatedAt()
  17416. return nil
  17417. case tutorial.FieldUpdatedAt:
  17418. m.ResetUpdatedAt()
  17419. return nil
  17420. case tutorial.FieldDeletedAt:
  17421. m.ResetDeletedAt()
  17422. return nil
  17423. case tutorial.FieldEmployeeID:
  17424. m.ResetEmployeeID()
  17425. return nil
  17426. case tutorial.FieldIndex:
  17427. m.ResetIndex()
  17428. return nil
  17429. case tutorial.FieldTitle:
  17430. m.ResetTitle()
  17431. return nil
  17432. case tutorial.FieldContent:
  17433. m.ResetContent()
  17434. return nil
  17435. case tutorial.FieldOrganizationID:
  17436. m.ResetOrganizationID()
  17437. return nil
  17438. }
  17439. return fmt.Errorf("unknown Tutorial field %s", name)
  17440. }
  17441. // AddedEdges returns all edge names that were set/added in this mutation.
  17442. func (m *TutorialMutation) AddedEdges() []string {
  17443. edges := make([]string, 0, 1)
  17444. if m.employee != nil {
  17445. edges = append(edges, tutorial.EdgeEmployee)
  17446. }
  17447. return edges
  17448. }
  17449. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17450. // name in this mutation.
  17451. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  17452. switch name {
  17453. case tutorial.EdgeEmployee:
  17454. if id := m.employee; id != nil {
  17455. return []ent.Value{*id}
  17456. }
  17457. }
  17458. return nil
  17459. }
  17460. // RemovedEdges returns all edge names that were removed in this mutation.
  17461. func (m *TutorialMutation) RemovedEdges() []string {
  17462. edges := make([]string, 0, 1)
  17463. return edges
  17464. }
  17465. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17466. // the given name in this mutation.
  17467. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  17468. return nil
  17469. }
  17470. // ClearedEdges returns all edge names that were cleared in this mutation.
  17471. func (m *TutorialMutation) ClearedEdges() []string {
  17472. edges := make([]string, 0, 1)
  17473. if m.clearedemployee {
  17474. edges = append(edges, tutorial.EdgeEmployee)
  17475. }
  17476. return edges
  17477. }
  17478. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17479. // was cleared in this mutation.
  17480. func (m *TutorialMutation) EdgeCleared(name string) bool {
  17481. switch name {
  17482. case tutorial.EdgeEmployee:
  17483. return m.clearedemployee
  17484. }
  17485. return false
  17486. }
  17487. // ClearEdge clears the value of the edge with the given name. It returns an error
  17488. // if that edge is not defined in the schema.
  17489. func (m *TutorialMutation) ClearEdge(name string) error {
  17490. switch name {
  17491. case tutorial.EdgeEmployee:
  17492. m.ClearEmployee()
  17493. return nil
  17494. }
  17495. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  17496. }
  17497. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17498. // It returns an error if the edge is not defined in the schema.
  17499. func (m *TutorialMutation) ResetEdge(name string) error {
  17500. switch name {
  17501. case tutorial.EdgeEmployee:
  17502. m.ResetEmployee()
  17503. return nil
  17504. }
  17505. return fmt.Errorf("unknown Tutorial edge %s", name)
  17506. }
  17507. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  17508. type WorkExperienceMutation struct {
  17509. config
  17510. op Op
  17511. typ string
  17512. id *uint64
  17513. created_at *time.Time
  17514. updated_at *time.Time
  17515. deleted_at *time.Time
  17516. start_date *time.Time
  17517. end_date *time.Time
  17518. company *string
  17519. experience *string
  17520. organization_id *uint64
  17521. addorganization_id *int64
  17522. clearedFields map[string]struct{}
  17523. employee *uint64
  17524. clearedemployee bool
  17525. done bool
  17526. oldValue func(context.Context) (*WorkExperience, error)
  17527. predicates []predicate.WorkExperience
  17528. }
  17529. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  17530. // workexperienceOption allows management of the mutation configuration using functional options.
  17531. type workexperienceOption func(*WorkExperienceMutation)
  17532. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  17533. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  17534. m := &WorkExperienceMutation{
  17535. config: c,
  17536. op: op,
  17537. typ: TypeWorkExperience,
  17538. clearedFields: make(map[string]struct{}),
  17539. }
  17540. for _, opt := range opts {
  17541. opt(m)
  17542. }
  17543. return m
  17544. }
  17545. // withWorkExperienceID sets the ID field of the mutation.
  17546. func withWorkExperienceID(id uint64) workexperienceOption {
  17547. return func(m *WorkExperienceMutation) {
  17548. var (
  17549. err error
  17550. once sync.Once
  17551. value *WorkExperience
  17552. )
  17553. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  17554. once.Do(func() {
  17555. if m.done {
  17556. err = errors.New("querying old values post mutation is not allowed")
  17557. } else {
  17558. value, err = m.Client().WorkExperience.Get(ctx, id)
  17559. }
  17560. })
  17561. return value, err
  17562. }
  17563. m.id = &id
  17564. }
  17565. }
  17566. // withWorkExperience sets the old WorkExperience of the mutation.
  17567. func withWorkExperience(node *WorkExperience) workexperienceOption {
  17568. return func(m *WorkExperienceMutation) {
  17569. m.oldValue = func(context.Context) (*WorkExperience, error) {
  17570. return node, nil
  17571. }
  17572. m.id = &node.ID
  17573. }
  17574. }
  17575. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17576. // executed in a transaction (ent.Tx), a transactional client is returned.
  17577. func (m WorkExperienceMutation) Client() *Client {
  17578. client := &Client{config: m.config}
  17579. client.init()
  17580. return client
  17581. }
  17582. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17583. // it returns an error otherwise.
  17584. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  17585. if _, ok := m.driver.(*txDriver); !ok {
  17586. return nil, errors.New("ent: mutation is not running in a transaction")
  17587. }
  17588. tx := &Tx{config: m.config}
  17589. tx.init()
  17590. return tx, nil
  17591. }
  17592. // SetID sets the value of the id field. Note that this
  17593. // operation is only accepted on creation of WorkExperience entities.
  17594. func (m *WorkExperienceMutation) SetID(id uint64) {
  17595. m.id = &id
  17596. }
  17597. // ID returns the ID value in the mutation. Note that the ID is only available
  17598. // if it was provided to the builder or after it was returned from the database.
  17599. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  17600. if m.id == nil {
  17601. return
  17602. }
  17603. return *m.id, true
  17604. }
  17605. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17606. // That means, if the mutation is applied within a transaction with an isolation level such
  17607. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17608. // or updated by the mutation.
  17609. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  17610. switch {
  17611. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17612. id, exists := m.ID()
  17613. if exists {
  17614. return []uint64{id}, nil
  17615. }
  17616. fallthrough
  17617. case m.op.Is(OpUpdate | OpDelete):
  17618. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  17619. default:
  17620. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17621. }
  17622. }
  17623. // SetCreatedAt sets the "created_at" field.
  17624. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  17625. m.created_at = &t
  17626. }
  17627. // CreatedAt returns the value of the "created_at" field in the mutation.
  17628. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  17629. v := m.created_at
  17630. if v == nil {
  17631. return
  17632. }
  17633. return *v, true
  17634. }
  17635. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  17636. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17638. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17639. if !m.op.Is(OpUpdateOne) {
  17640. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17641. }
  17642. if m.id == nil || m.oldValue == nil {
  17643. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17644. }
  17645. oldValue, err := m.oldValue(ctx)
  17646. if err != nil {
  17647. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17648. }
  17649. return oldValue.CreatedAt, nil
  17650. }
  17651. // ResetCreatedAt resets all changes to the "created_at" field.
  17652. func (m *WorkExperienceMutation) ResetCreatedAt() {
  17653. m.created_at = nil
  17654. }
  17655. // SetUpdatedAt sets the "updated_at" field.
  17656. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  17657. m.updated_at = &t
  17658. }
  17659. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17660. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  17661. v := m.updated_at
  17662. if v == nil {
  17663. return
  17664. }
  17665. return *v, true
  17666. }
  17667. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  17668. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17670. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17671. if !m.op.Is(OpUpdateOne) {
  17672. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17673. }
  17674. if m.id == nil || m.oldValue == nil {
  17675. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17676. }
  17677. oldValue, err := m.oldValue(ctx)
  17678. if err != nil {
  17679. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17680. }
  17681. return oldValue.UpdatedAt, nil
  17682. }
  17683. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17684. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  17685. m.updated_at = nil
  17686. }
  17687. // SetDeletedAt sets the "deleted_at" field.
  17688. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  17689. m.deleted_at = &t
  17690. }
  17691. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17692. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  17693. v := m.deleted_at
  17694. if v == nil {
  17695. return
  17696. }
  17697. return *v, true
  17698. }
  17699. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  17700. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17702. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17703. if !m.op.Is(OpUpdateOne) {
  17704. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17705. }
  17706. if m.id == nil || m.oldValue == nil {
  17707. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17708. }
  17709. oldValue, err := m.oldValue(ctx)
  17710. if err != nil {
  17711. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17712. }
  17713. return oldValue.DeletedAt, nil
  17714. }
  17715. // ClearDeletedAt clears the value of the "deleted_at" field.
  17716. func (m *WorkExperienceMutation) ClearDeletedAt() {
  17717. m.deleted_at = nil
  17718. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  17719. }
  17720. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17721. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  17722. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  17723. return ok
  17724. }
  17725. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17726. func (m *WorkExperienceMutation) ResetDeletedAt() {
  17727. m.deleted_at = nil
  17728. delete(m.clearedFields, workexperience.FieldDeletedAt)
  17729. }
  17730. // SetEmployeeID sets the "employee_id" field.
  17731. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  17732. m.employee = &u
  17733. }
  17734. // EmployeeID returns the value of the "employee_id" field in the mutation.
  17735. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  17736. v := m.employee
  17737. if v == nil {
  17738. return
  17739. }
  17740. return *v, true
  17741. }
  17742. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  17743. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17744. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17745. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  17746. if !m.op.Is(OpUpdateOne) {
  17747. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  17748. }
  17749. if m.id == nil || m.oldValue == nil {
  17750. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  17751. }
  17752. oldValue, err := m.oldValue(ctx)
  17753. if err != nil {
  17754. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  17755. }
  17756. return oldValue.EmployeeID, nil
  17757. }
  17758. // ResetEmployeeID resets all changes to the "employee_id" field.
  17759. func (m *WorkExperienceMutation) ResetEmployeeID() {
  17760. m.employee = nil
  17761. }
  17762. // SetStartDate sets the "start_date" field.
  17763. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  17764. m.start_date = &t
  17765. }
  17766. // StartDate returns the value of the "start_date" field in the mutation.
  17767. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  17768. v := m.start_date
  17769. if v == nil {
  17770. return
  17771. }
  17772. return *v, true
  17773. }
  17774. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  17775. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17777. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  17778. if !m.op.Is(OpUpdateOne) {
  17779. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  17780. }
  17781. if m.id == nil || m.oldValue == nil {
  17782. return v, errors.New("OldStartDate requires an ID field in the mutation")
  17783. }
  17784. oldValue, err := m.oldValue(ctx)
  17785. if err != nil {
  17786. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  17787. }
  17788. return oldValue.StartDate, nil
  17789. }
  17790. // ResetStartDate resets all changes to the "start_date" field.
  17791. func (m *WorkExperienceMutation) ResetStartDate() {
  17792. m.start_date = nil
  17793. }
  17794. // SetEndDate sets the "end_date" field.
  17795. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  17796. m.end_date = &t
  17797. }
  17798. // EndDate returns the value of the "end_date" field in the mutation.
  17799. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  17800. v := m.end_date
  17801. if v == nil {
  17802. return
  17803. }
  17804. return *v, true
  17805. }
  17806. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  17807. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17808. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17809. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  17810. if !m.op.Is(OpUpdateOne) {
  17811. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  17812. }
  17813. if m.id == nil || m.oldValue == nil {
  17814. return v, errors.New("OldEndDate requires an ID field in the mutation")
  17815. }
  17816. oldValue, err := m.oldValue(ctx)
  17817. if err != nil {
  17818. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  17819. }
  17820. return oldValue.EndDate, nil
  17821. }
  17822. // ResetEndDate resets all changes to the "end_date" field.
  17823. func (m *WorkExperienceMutation) ResetEndDate() {
  17824. m.end_date = nil
  17825. }
  17826. // SetCompany sets the "company" field.
  17827. func (m *WorkExperienceMutation) SetCompany(s string) {
  17828. m.company = &s
  17829. }
  17830. // Company returns the value of the "company" field in the mutation.
  17831. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  17832. v := m.company
  17833. if v == nil {
  17834. return
  17835. }
  17836. return *v, true
  17837. }
  17838. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  17839. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17841. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  17842. if !m.op.Is(OpUpdateOne) {
  17843. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  17844. }
  17845. if m.id == nil || m.oldValue == nil {
  17846. return v, errors.New("OldCompany requires an ID field in the mutation")
  17847. }
  17848. oldValue, err := m.oldValue(ctx)
  17849. if err != nil {
  17850. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  17851. }
  17852. return oldValue.Company, nil
  17853. }
  17854. // ResetCompany resets all changes to the "company" field.
  17855. func (m *WorkExperienceMutation) ResetCompany() {
  17856. m.company = nil
  17857. }
  17858. // SetExperience sets the "experience" field.
  17859. func (m *WorkExperienceMutation) SetExperience(s string) {
  17860. m.experience = &s
  17861. }
  17862. // Experience returns the value of the "experience" field in the mutation.
  17863. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  17864. v := m.experience
  17865. if v == nil {
  17866. return
  17867. }
  17868. return *v, true
  17869. }
  17870. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  17871. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17873. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  17874. if !m.op.Is(OpUpdateOne) {
  17875. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  17876. }
  17877. if m.id == nil || m.oldValue == nil {
  17878. return v, errors.New("OldExperience requires an ID field in the mutation")
  17879. }
  17880. oldValue, err := m.oldValue(ctx)
  17881. if err != nil {
  17882. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  17883. }
  17884. return oldValue.Experience, nil
  17885. }
  17886. // ResetExperience resets all changes to the "experience" field.
  17887. func (m *WorkExperienceMutation) ResetExperience() {
  17888. m.experience = nil
  17889. }
  17890. // SetOrganizationID sets the "organization_id" field.
  17891. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  17892. m.organization_id = &u
  17893. m.addorganization_id = nil
  17894. }
  17895. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17896. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  17897. v := m.organization_id
  17898. if v == nil {
  17899. return
  17900. }
  17901. return *v, true
  17902. }
  17903. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  17904. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17906. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17907. if !m.op.Is(OpUpdateOne) {
  17908. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17909. }
  17910. if m.id == nil || m.oldValue == nil {
  17911. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17912. }
  17913. oldValue, err := m.oldValue(ctx)
  17914. if err != nil {
  17915. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17916. }
  17917. return oldValue.OrganizationID, nil
  17918. }
  17919. // AddOrganizationID adds u to the "organization_id" field.
  17920. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  17921. if m.addorganization_id != nil {
  17922. *m.addorganization_id += u
  17923. } else {
  17924. m.addorganization_id = &u
  17925. }
  17926. }
  17927. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17928. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  17929. v := m.addorganization_id
  17930. if v == nil {
  17931. return
  17932. }
  17933. return *v, true
  17934. }
  17935. // ResetOrganizationID resets all changes to the "organization_id" field.
  17936. func (m *WorkExperienceMutation) ResetOrganizationID() {
  17937. m.organization_id = nil
  17938. m.addorganization_id = nil
  17939. }
  17940. // ClearEmployee clears the "employee" edge to the Employee entity.
  17941. func (m *WorkExperienceMutation) ClearEmployee() {
  17942. m.clearedemployee = true
  17943. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  17944. }
  17945. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  17946. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  17947. return m.clearedemployee
  17948. }
  17949. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  17950. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17951. // EmployeeID instead. It exists only for internal usage by the builders.
  17952. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  17953. if id := m.employee; id != nil {
  17954. ids = append(ids, *id)
  17955. }
  17956. return
  17957. }
  17958. // ResetEmployee resets all changes to the "employee" edge.
  17959. func (m *WorkExperienceMutation) ResetEmployee() {
  17960. m.employee = nil
  17961. m.clearedemployee = false
  17962. }
  17963. // Where appends a list predicates to the WorkExperienceMutation builder.
  17964. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  17965. m.predicates = append(m.predicates, ps...)
  17966. }
  17967. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  17968. // users can use type-assertion to append predicates that do not depend on any generated package.
  17969. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  17970. p := make([]predicate.WorkExperience, len(ps))
  17971. for i := range ps {
  17972. p[i] = ps[i]
  17973. }
  17974. m.Where(p...)
  17975. }
  17976. // Op returns the operation name.
  17977. func (m *WorkExperienceMutation) Op() Op {
  17978. return m.op
  17979. }
  17980. // SetOp allows setting the mutation operation.
  17981. func (m *WorkExperienceMutation) SetOp(op Op) {
  17982. m.op = op
  17983. }
  17984. // Type returns the node type of this mutation (WorkExperience).
  17985. func (m *WorkExperienceMutation) Type() string {
  17986. return m.typ
  17987. }
  17988. // Fields returns all fields that were changed during this mutation. Note that in
  17989. // order to get all numeric fields that were incremented/decremented, call
  17990. // AddedFields().
  17991. func (m *WorkExperienceMutation) Fields() []string {
  17992. fields := make([]string, 0, 9)
  17993. if m.created_at != nil {
  17994. fields = append(fields, workexperience.FieldCreatedAt)
  17995. }
  17996. if m.updated_at != nil {
  17997. fields = append(fields, workexperience.FieldUpdatedAt)
  17998. }
  17999. if m.deleted_at != nil {
  18000. fields = append(fields, workexperience.FieldDeletedAt)
  18001. }
  18002. if m.employee != nil {
  18003. fields = append(fields, workexperience.FieldEmployeeID)
  18004. }
  18005. if m.start_date != nil {
  18006. fields = append(fields, workexperience.FieldStartDate)
  18007. }
  18008. if m.end_date != nil {
  18009. fields = append(fields, workexperience.FieldEndDate)
  18010. }
  18011. if m.company != nil {
  18012. fields = append(fields, workexperience.FieldCompany)
  18013. }
  18014. if m.experience != nil {
  18015. fields = append(fields, workexperience.FieldExperience)
  18016. }
  18017. if m.organization_id != nil {
  18018. fields = append(fields, workexperience.FieldOrganizationID)
  18019. }
  18020. return fields
  18021. }
  18022. // Field returns the value of a field with the given name. The second boolean
  18023. // return value indicates that this field was not set, or was not defined in the
  18024. // schema.
  18025. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  18026. switch name {
  18027. case workexperience.FieldCreatedAt:
  18028. return m.CreatedAt()
  18029. case workexperience.FieldUpdatedAt:
  18030. return m.UpdatedAt()
  18031. case workexperience.FieldDeletedAt:
  18032. return m.DeletedAt()
  18033. case workexperience.FieldEmployeeID:
  18034. return m.EmployeeID()
  18035. case workexperience.FieldStartDate:
  18036. return m.StartDate()
  18037. case workexperience.FieldEndDate:
  18038. return m.EndDate()
  18039. case workexperience.FieldCompany:
  18040. return m.Company()
  18041. case workexperience.FieldExperience:
  18042. return m.Experience()
  18043. case workexperience.FieldOrganizationID:
  18044. return m.OrganizationID()
  18045. }
  18046. return nil, false
  18047. }
  18048. // OldField returns the old value of the field from the database. An error is
  18049. // returned if the mutation operation is not UpdateOne, or the query to the
  18050. // database failed.
  18051. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18052. switch name {
  18053. case workexperience.FieldCreatedAt:
  18054. return m.OldCreatedAt(ctx)
  18055. case workexperience.FieldUpdatedAt:
  18056. return m.OldUpdatedAt(ctx)
  18057. case workexperience.FieldDeletedAt:
  18058. return m.OldDeletedAt(ctx)
  18059. case workexperience.FieldEmployeeID:
  18060. return m.OldEmployeeID(ctx)
  18061. case workexperience.FieldStartDate:
  18062. return m.OldStartDate(ctx)
  18063. case workexperience.FieldEndDate:
  18064. return m.OldEndDate(ctx)
  18065. case workexperience.FieldCompany:
  18066. return m.OldCompany(ctx)
  18067. case workexperience.FieldExperience:
  18068. return m.OldExperience(ctx)
  18069. case workexperience.FieldOrganizationID:
  18070. return m.OldOrganizationID(ctx)
  18071. }
  18072. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  18073. }
  18074. // SetField sets the value of a field with the given name. It returns an error if
  18075. // the field is not defined in the schema, or if the type mismatched the field
  18076. // type.
  18077. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  18078. switch name {
  18079. case workexperience.FieldCreatedAt:
  18080. v, ok := value.(time.Time)
  18081. if !ok {
  18082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18083. }
  18084. m.SetCreatedAt(v)
  18085. return nil
  18086. case workexperience.FieldUpdatedAt:
  18087. v, ok := value.(time.Time)
  18088. if !ok {
  18089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18090. }
  18091. m.SetUpdatedAt(v)
  18092. return nil
  18093. case workexperience.FieldDeletedAt:
  18094. v, ok := value.(time.Time)
  18095. if !ok {
  18096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18097. }
  18098. m.SetDeletedAt(v)
  18099. return nil
  18100. case workexperience.FieldEmployeeID:
  18101. v, ok := value.(uint64)
  18102. if !ok {
  18103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18104. }
  18105. m.SetEmployeeID(v)
  18106. return nil
  18107. case workexperience.FieldStartDate:
  18108. v, ok := value.(time.Time)
  18109. if !ok {
  18110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18111. }
  18112. m.SetStartDate(v)
  18113. return nil
  18114. case workexperience.FieldEndDate:
  18115. v, ok := value.(time.Time)
  18116. if !ok {
  18117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18118. }
  18119. m.SetEndDate(v)
  18120. return nil
  18121. case workexperience.FieldCompany:
  18122. v, ok := value.(string)
  18123. if !ok {
  18124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18125. }
  18126. m.SetCompany(v)
  18127. return nil
  18128. case workexperience.FieldExperience:
  18129. v, ok := value.(string)
  18130. if !ok {
  18131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18132. }
  18133. m.SetExperience(v)
  18134. return nil
  18135. case workexperience.FieldOrganizationID:
  18136. v, ok := value.(uint64)
  18137. if !ok {
  18138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18139. }
  18140. m.SetOrganizationID(v)
  18141. return nil
  18142. }
  18143. return fmt.Errorf("unknown WorkExperience field %s", name)
  18144. }
  18145. // AddedFields returns all numeric fields that were incremented/decremented during
  18146. // this mutation.
  18147. func (m *WorkExperienceMutation) AddedFields() []string {
  18148. var fields []string
  18149. if m.addorganization_id != nil {
  18150. fields = append(fields, workexperience.FieldOrganizationID)
  18151. }
  18152. return fields
  18153. }
  18154. // AddedField returns the numeric value that was incremented/decremented on a field
  18155. // with the given name. The second boolean return value indicates that this field
  18156. // was not set, or was not defined in the schema.
  18157. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  18158. switch name {
  18159. case workexperience.FieldOrganizationID:
  18160. return m.AddedOrganizationID()
  18161. }
  18162. return nil, false
  18163. }
  18164. // AddField adds the value to the field with the given name. It returns an error if
  18165. // the field is not defined in the schema, or if the type mismatched the field
  18166. // type.
  18167. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  18168. switch name {
  18169. case workexperience.FieldOrganizationID:
  18170. v, ok := value.(int64)
  18171. if !ok {
  18172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18173. }
  18174. m.AddOrganizationID(v)
  18175. return nil
  18176. }
  18177. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  18178. }
  18179. // ClearedFields returns all nullable fields that were cleared during this
  18180. // mutation.
  18181. func (m *WorkExperienceMutation) ClearedFields() []string {
  18182. var fields []string
  18183. if m.FieldCleared(workexperience.FieldDeletedAt) {
  18184. fields = append(fields, workexperience.FieldDeletedAt)
  18185. }
  18186. return fields
  18187. }
  18188. // FieldCleared returns a boolean indicating if a field with the given name was
  18189. // cleared in this mutation.
  18190. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  18191. _, ok := m.clearedFields[name]
  18192. return ok
  18193. }
  18194. // ClearField clears the value of the field with the given name. It returns an
  18195. // error if the field is not defined in the schema.
  18196. func (m *WorkExperienceMutation) ClearField(name string) error {
  18197. switch name {
  18198. case workexperience.FieldDeletedAt:
  18199. m.ClearDeletedAt()
  18200. return nil
  18201. }
  18202. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  18203. }
  18204. // ResetField resets all changes in the mutation for the field with the given name.
  18205. // It returns an error if the field is not defined in the schema.
  18206. func (m *WorkExperienceMutation) ResetField(name string) error {
  18207. switch name {
  18208. case workexperience.FieldCreatedAt:
  18209. m.ResetCreatedAt()
  18210. return nil
  18211. case workexperience.FieldUpdatedAt:
  18212. m.ResetUpdatedAt()
  18213. return nil
  18214. case workexperience.FieldDeletedAt:
  18215. m.ResetDeletedAt()
  18216. return nil
  18217. case workexperience.FieldEmployeeID:
  18218. m.ResetEmployeeID()
  18219. return nil
  18220. case workexperience.FieldStartDate:
  18221. m.ResetStartDate()
  18222. return nil
  18223. case workexperience.FieldEndDate:
  18224. m.ResetEndDate()
  18225. return nil
  18226. case workexperience.FieldCompany:
  18227. m.ResetCompany()
  18228. return nil
  18229. case workexperience.FieldExperience:
  18230. m.ResetExperience()
  18231. return nil
  18232. case workexperience.FieldOrganizationID:
  18233. m.ResetOrganizationID()
  18234. return nil
  18235. }
  18236. return fmt.Errorf("unknown WorkExperience field %s", name)
  18237. }
  18238. // AddedEdges returns all edge names that were set/added in this mutation.
  18239. func (m *WorkExperienceMutation) AddedEdges() []string {
  18240. edges := make([]string, 0, 1)
  18241. if m.employee != nil {
  18242. edges = append(edges, workexperience.EdgeEmployee)
  18243. }
  18244. return edges
  18245. }
  18246. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18247. // name in this mutation.
  18248. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  18249. switch name {
  18250. case workexperience.EdgeEmployee:
  18251. if id := m.employee; id != nil {
  18252. return []ent.Value{*id}
  18253. }
  18254. }
  18255. return nil
  18256. }
  18257. // RemovedEdges returns all edge names that were removed in this mutation.
  18258. func (m *WorkExperienceMutation) RemovedEdges() []string {
  18259. edges := make([]string, 0, 1)
  18260. return edges
  18261. }
  18262. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18263. // the given name in this mutation.
  18264. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  18265. return nil
  18266. }
  18267. // ClearedEdges returns all edge names that were cleared in this mutation.
  18268. func (m *WorkExperienceMutation) ClearedEdges() []string {
  18269. edges := make([]string, 0, 1)
  18270. if m.clearedemployee {
  18271. edges = append(edges, workexperience.EdgeEmployee)
  18272. }
  18273. return edges
  18274. }
  18275. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18276. // was cleared in this mutation.
  18277. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  18278. switch name {
  18279. case workexperience.EdgeEmployee:
  18280. return m.clearedemployee
  18281. }
  18282. return false
  18283. }
  18284. // ClearEdge clears the value of the edge with the given name. It returns an error
  18285. // if that edge is not defined in the schema.
  18286. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  18287. switch name {
  18288. case workexperience.EdgeEmployee:
  18289. m.ClearEmployee()
  18290. return nil
  18291. }
  18292. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  18293. }
  18294. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18295. // It returns an error if the edge is not defined in the schema.
  18296. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  18297. switch name {
  18298. case workexperience.EdgeEmployee:
  18299. m.ResetEmployee()
  18300. return nil
  18301. }
  18302. return fmt.Errorf("unknown WorkExperience edge %s", name)
  18303. }
  18304. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  18305. type WxMutation struct {
  18306. config
  18307. op Op
  18308. typ string
  18309. id *uint64
  18310. created_at *time.Time
  18311. updated_at *time.Time
  18312. status *uint8
  18313. addstatus *int8
  18314. deleted_at *time.Time
  18315. port *string
  18316. process_id *string
  18317. callback *string
  18318. wxid *string
  18319. account *string
  18320. nickname *string
  18321. tel *string
  18322. head_big *string
  18323. organization_id *uint64
  18324. addorganization_id *int64
  18325. api_base *string
  18326. api_key *string
  18327. allow_list *[]string
  18328. appendallow_list []string
  18329. group_allow_list *[]string
  18330. appendgroup_allow_list []string
  18331. block_list *[]string
  18332. appendblock_list []string
  18333. group_block_list *[]string
  18334. appendgroup_block_list []string
  18335. clearedFields map[string]struct{}
  18336. server *uint64
  18337. clearedserver bool
  18338. agent *uint64
  18339. clearedagent bool
  18340. done bool
  18341. oldValue func(context.Context) (*Wx, error)
  18342. predicates []predicate.Wx
  18343. }
  18344. var _ ent.Mutation = (*WxMutation)(nil)
  18345. // wxOption allows management of the mutation configuration using functional options.
  18346. type wxOption func(*WxMutation)
  18347. // newWxMutation creates new mutation for the Wx entity.
  18348. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  18349. m := &WxMutation{
  18350. config: c,
  18351. op: op,
  18352. typ: TypeWx,
  18353. clearedFields: make(map[string]struct{}),
  18354. }
  18355. for _, opt := range opts {
  18356. opt(m)
  18357. }
  18358. return m
  18359. }
  18360. // withWxID sets the ID field of the mutation.
  18361. func withWxID(id uint64) wxOption {
  18362. return func(m *WxMutation) {
  18363. var (
  18364. err error
  18365. once sync.Once
  18366. value *Wx
  18367. )
  18368. m.oldValue = func(ctx context.Context) (*Wx, error) {
  18369. once.Do(func() {
  18370. if m.done {
  18371. err = errors.New("querying old values post mutation is not allowed")
  18372. } else {
  18373. value, err = m.Client().Wx.Get(ctx, id)
  18374. }
  18375. })
  18376. return value, err
  18377. }
  18378. m.id = &id
  18379. }
  18380. }
  18381. // withWx sets the old Wx of the mutation.
  18382. func withWx(node *Wx) wxOption {
  18383. return func(m *WxMutation) {
  18384. m.oldValue = func(context.Context) (*Wx, error) {
  18385. return node, nil
  18386. }
  18387. m.id = &node.ID
  18388. }
  18389. }
  18390. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18391. // executed in a transaction (ent.Tx), a transactional client is returned.
  18392. func (m WxMutation) Client() *Client {
  18393. client := &Client{config: m.config}
  18394. client.init()
  18395. return client
  18396. }
  18397. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18398. // it returns an error otherwise.
  18399. func (m WxMutation) Tx() (*Tx, error) {
  18400. if _, ok := m.driver.(*txDriver); !ok {
  18401. return nil, errors.New("ent: mutation is not running in a transaction")
  18402. }
  18403. tx := &Tx{config: m.config}
  18404. tx.init()
  18405. return tx, nil
  18406. }
  18407. // SetID sets the value of the id field. Note that this
  18408. // operation is only accepted on creation of Wx entities.
  18409. func (m *WxMutation) SetID(id uint64) {
  18410. m.id = &id
  18411. }
  18412. // ID returns the ID value in the mutation. Note that the ID is only available
  18413. // if it was provided to the builder or after it was returned from the database.
  18414. func (m *WxMutation) ID() (id uint64, exists bool) {
  18415. if m.id == nil {
  18416. return
  18417. }
  18418. return *m.id, true
  18419. }
  18420. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18421. // That means, if the mutation is applied within a transaction with an isolation level such
  18422. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18423. // or updated by the mutation.
  18424. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  18425. switch {
  18426. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18427. id, exists := m.ID()
  18428. if exists {
  18429. return []uint64{id}, nil
  18430. }
  18431. fallthrough
  18432. case m.op.Is(OpUpdate | OpDelete):
  18433. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  18434. default:
  18435. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18436. }
  18437. }
  18438. // SetCreatedAt sets the "created_at" field.
  18439. func (m *WxMutation) SetCreatedAt(t time.Time) {
  18440. m.created_at = &t
  18441. }
  18442. // CreatedAt returns the value of the "created_at" field in the mutation.
  18443. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  18444. v := m.created_at
  18445. if v == nil {
  18446. return
  18447. }
  18448. return *v, true
  18449. }
  18450. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  18451. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18453. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18454. if !m.op.Is(OpUpdateOne) {
  18455. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18456. }
  18457. if m.id == nil || m.oldValue == nil {
  18458. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18459. }
  18460. oldValue, err := m.oldValue(ctx)
  18461. if err != nil {
  18462. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18463. }
  18464. return oldValue.CreatedAt, nil
  18465. }
  18466. // ResetCreatedAt resets all changes to the "created_at" field.
  18467. func (m *WxMutation) ResetCreatedAt() {
  18468. m.created_at = nil
  18469. }
  18470. // SetUpdatedAt sets the "updated_at" field.
  18471. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  18472. m.updated_at = &t
  18473. }
  18474. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18475. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  18476. v := m.updated_at
  18477. if v == nil {
  18478. return
  18479. }
  18480. return *v, true
  18481. }
  18482. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  18483. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18485. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18486. if !m.op.Is(OpUpdateOne) {
  18487. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18488. }
  18489. if m.id == nil || m.oldValue == nil {
  18490. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18491. }
  18492. oldValue, err := m.oldValue(ctx)
  18493. if err != nil {
  18494. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18495. }
  18496. return oldValue.UpdatedAt, nil
  18497. }
  18498. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18499. func (m *WxMutation) ResetUpdatedAt() {
  18500. m.updated_at = nil
  18501. }
  18502. // SetStatus sets the "status" field.
  18503. func (m *WxMutation) SetStatus(u uint8) {
  18504. m.status = &u
  18505. m.addstatus = nil
  18506. }
  18507. // Status returns the value of the "status" field in the mutation.
  18508. func (m *WxMutation) Status() (r uint8, exists bool) {
  18509. v := m.status
  18510. if v == nil {
  18511. return
  18512. }
  18513. return *v, true
  18514. }
  18515. // OldStatus returns the old "status" field's value of the Wx entity.
  18516. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18518. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18519. if !m.op.Is(OpUpdateOne) {
  18520. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18521. }
  18522. if m.id == nil || m.oldValue == nil {
  18523. return v, errors.New("OldStatus requires an ID field in the mutation")
  18524. }
  18525. oldValue, err := m.oldValue(ctx)
  18526. if err != nil {
  18527. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18528. }
  18529. return oldValue.Status, nil
  18530. }
  18531. // AddStatus adds u to the "status" field.
  18532. func (m *WxMutation) AddStatus(u int8) {
  18533. if m.addstatus != nil {
  18534. *m.addstatus += u
  18535. } else {
  18536. m.addstatus = &u
  18537. }
  18538. }
  18539. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18540. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  18541. v := m.addstatus
  18542. if v == nil {
  18543. return
  18544. }
  18545. return *v, true
  18546. }
  18547. // ClearStatus clears the value of the "status" field.
  18548. func (m *WxMutation) ClearStatus() {
  18549. m.status = nil
  18550. m.addstatus = nil
  18551. m.clearedFields[wx.FieldStatus] = struct{}{}
  18552. }
  18553. // StatusCleared returns if the "status" field was cleared in this mutation.
  18554. func (m *WxMutation) StatusCleared() bool {
  18555. _, ok := m.clearedFields[wx.FieldStatus]
  18556. return ok
  18557. }
  18558. // ResetStatus resets all changes to the "status" field.
  18559. func (m *WxMutation) ResetStatus() {
  18560. m.status = nil
  18561. m.addstatus = nil
  18562. delete(m.clearedFields, wx.FieldStatus)
  18563. }
  18564. // SetDeletedAt sets the "deleted_at" field.
  18565. func (m *WxMutation) SetDeletedAt(t time.Time) {
  18566. m.deleted_at = &t
  18567. }
  18568. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18569. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  18570. v := m.deleted_at
  18571. if v == nil {
  18572. return
  18573. }
  18574. return *v, true
  18575. }
  18576. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  18577. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18579. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18580. if !m.op.Is(OpUpdateOne) {
  18581. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18582. }
  18583. if m.id == nil || m.oldValue == nil {
  18584. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18585. }
  18586. oldValue, err := m.oldValue(ctx)
  18587. if err != nil {
  18588. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18589. }
  18590. return oldValue.DeletedAt, nil
  18591. }
  18592. // ClearDeletedAt clears the value of the "deleted_at" field.
  18593. func (m *WxMutation) ClearDeletedAt() {
  18594. m.deleted_at = nil
  18595. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  18596. }
  18597. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18598. func (m *WxMutation) DeletedAtCleared() bool {
  18599. _, ok := m.clearedFields[wx.FieldDeletedAt]
  18600. return ok
  18601. }
  18602. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18603. func (m *WxMutation) ResetDeletedAt() {
  18604. m.deleted_at = nil
  18605. delete(m.clearedFields, wx.FieldDeletedAt)
  18606. }
  18607. // SetServerID sets the "server_id" field.
  18608. func (m *WxMutation) SetServerID(u uint64) {
  18609. m.server = &u
  18610. }
  18611. // ServerID returns the value of the "server_id" field in the mutation.
  18612. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  18613. v := m.server
  18614. if v == nil {
  18615. return
  18616. }
  18617. return *v, true
  18618. }
  18619. // OldServerID returns the old "server_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) OldServerID(ctx context.Context) (v uint64, err error) {
  18623. if !m.op.Is(OpUpdateOne) {
  18624. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  18625. }
  18626. if m.id == nil || m.oldValue == nil {
  18627. return v, errors.New("OldServerID 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 OldServerID: %w", err)
  18632. }
  18633. return oldValue.ServerID, nil
  18634. }
  18635. // ClearServerID clears the value of the "server_id" field.
  18636. func (m *WxMutation) ClearServerID() {
  18637. m.server = nil
  18638. m.clearedFields[wx.FieldServerID] = struct{}{}
  18639. }
  18640. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  18641. func (m *WxMutation) ServerIDCleared() bool {
  18642. _, ok := m.clearedFields[wx.FieldServerID]
  18643. return ok
  18644. }
  18645. // ResetServerID resets all changes to the "server_id" field.
  18646. func (m *WxMutation) ResetServerID() {
  18647. m.server = nil
  18648. delete(m.clearedFields, wx.FieldServerID)
  18649. }
  18650. // SetPort sets the "port" field.
  18651. func (m *WxMutation) SetPort(s string) {
  18652. m.port = &s
  18653. }
  18654. // Port returns the value of the "port" field in the mutation.
  18655. func (m *WxMutation) Port() (r string, exists bool) {
  18656. v := m.port
  18657. if v == nil {
  18658. return
  18659. }
  18660. return *v, true
  18661. }
  18662. // OldPort returns the old "port" field's value of the Wx entity.
  18663. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18665. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  18666. if !m.op.Is(OpUpdateOne) {
  18667. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  18668. }
  18669. if m.id == nil || m.oldValue == nil {
  18670. return v, errors.New("OldPort requires an ID field in the mutation")
  18671. }
  18672. oldValue, err := m.oldValue(ctx)
  18673. if err != nil {
  18674. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  18675. }
  18676. return oldValue.Port, nil
  18677. }
  18678. // ResetPort resets all changes to the "port" field.
  18679. func (m *WxMutation) ResetPort() {
  18680. m.port = nil
  18681. }
  18682. // SetProcessID sets the "process_id" field.
  18683. func (m *WxMutation) SetProcessID(s string) {
  18684. m.process_id = &s
  18685. }
  18686. // ProcessID returns the value of the "process_id" field in the mutation.
  18687. func (m *WxMutation) ProcessID() (r string, exists bool) {
  18688. v := m.process_id
  18689. if v == nil {
  18690. return
  18691. }
  18692. return *v, true
  18693. }
  18694. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  18695. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18697. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  18698. if !m.op.Is(OpUpdateOne) {
  18699. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  18700. }
  18701. if m.id == nil || m.oldValue == nil {
  18702. return v, errors.New("OldProcessID requires an ID field in the mutation")
  18703. }
  18704. oldValue, err := m.oldValue(ctx)
  18705. if err != nil {
  18706. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  18707. }
  18708. return oldValue.ProcessID, nil
  18709. }
  18710. // ResetProcessID resets all changes to the "process_id" field.
  18711. func (m *WxMutation) ResetProcessID() {
  18712. m.process_id = nil
  18713. }
  18714. // SetCallback sets the "callback" field.
  18715. func (m *WxMutation) SetCallback(s string) {
  18716. m.callback = &s
  18717. }
  18718. // Callback returns the value of the "callback" field in the mutation.
  18719. func (m *WxMutation) Callback() (r string, exists bool) {
  18720. v := m.callback
  18721. if v == nil {
  18722. return
  18723. }
  18724. return *v, true
  18725. }
  18726. // OldCallback returns the old "callback" field's value of the Wx entity.
  18727. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18729. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  18730. if !m.op.Is(OpUpdateOne) {
  18731. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  18732. }
  18733. if m.id == nil || m.oldValue == nil {
  18734. return v, errors.New("OldCallback requires an ID field in the mutation")
  18735. }
  18736. oldValue, err := m.oldValue(ctx)
  18737. if err != nil {
  18738. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  18739. }
  18740. return oldValue.Callback, nil
  18741. }
  18742. // ResetCallback resets all changes to the "callback" field.
  18743. func (m *WxMutation) ResetCallback() {
  18744. m.callback = nil
  18745. }
  18746. // SetWxid sets the "wxid" field.
  18747. func (m *WxMutation) SetWxid(s string) {
  18748. m.wxid = &s
  18749. }
  18750. // Wxid returns the value of the "wxid" field in the mutation.
  18751. func (m *WxMutation) Wxid() (r string, exists bool) {
  18752. v := m.wxid
  18753. if v == nil {
  18754. return
  18755. }
  18756. return *v, true
  18757. }
  18758. // OldWxid returns the old "wxid" field's value of the Wx entity.
  18759. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18761. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  18762. if !m.op.Is(OpUpdateOne) {
  18763. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  18764. }
  18765. if m.id == nil || m.oldValue == nil {
  18766. return v, errors.New("OldWxid requires an ID field in the mutation")
  18767. }
  18768. oldValue, err := m.oldValue(ctx)
  18769. if err != nil {
  18770. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  18771. }
  18772. return oldValue.Wxid, nil
  18773. }
  18774. // ResetWxid resets all changes to the "wxid" field.
  18775. func (m *WxMutation) ResetWxid() {
  18776. m.wxid = nil
  18777. }
  18778. // SetAccount sets the "account" field.
  18779. func (m *WxMutation) SetAccount(s string) {
  18780. m.account = &s
  18781. }
  18782. // Account returns the value of the "account" field in the mutation.
  18783. func (m *WxMutation) Account() (r string, exists bool) {
  18784. v := m.account
  18785. if v == nil {
  18786. return
  18787. }
  18788. return *v, true
  18789. }
  18790. // OldAccount returns the old "account" field's value of the Wx entity.
  18791. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18793. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  18794. if !m.op.Is(OpUpdateOne) {
  18795. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  18796. }
  18797. if m.id == nil || m.oldValue == nil {
  18798. return v, errors.New("OldAccount requires an ID field in the mutation")
  18799. }
  18800. oldValue, err := m.oldValue(ctx)
  18801. if err != nil {
  18802. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  18803. }
  18804. return oldValue.Account, nil
  18805. }
  18806. // ResetAccount resets all changes to the "account" field.
  18807. func (m *WxMutation) ResetAccount() {
  18808. m.account = nil
  18809. }
  18810. // SetNickname sets the "nickname" field.
  18811. func (m *WxMutation) SetNickname(s string) {
  18812. m.nickname = &s
  18813. }
  18814. // Nickname returns the value of the "nickname" field in the mutation.
  18815. func (m *WxMutation) Nickname() (r string, exists bool) {
  18816. v := m.nickname
  18817. if v == nil {
  18818. return
  18819. }
  18820. return *v, true
  18821. }
  18822. // OldNickname returns the old "nickname" field's value of the Wx entity.
  18823. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18825. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  18826. if !m.op.Is(OpUpdateOne) {
  18827. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  18828. }
  18829. if m.id == nil || m.oldValue == nil {
  18830. return v, errors.New("OldNickname requires an ID field in the mutation")
  18831. }
  18832. oldValue, err := m.oldValue(ctx)
  18833. if err != nil {
  18834. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  18835. }
  18836. return oldValue.Nickname, nil
  18837. }
  18838. // ResetNickname resets all changes to the "nickname" field.
  18839. func (m *WxMutation) ResetNickname() {
  18840. m.nickname = nil
  18841. }
  18842. // SetTel sets the "tel" field.
  18843. func (m *WxMutation) SetTel(s string) {
  18844. m.tel = &s
  18845. }
  18846. // Tel returns the value of the "tel" field in the mutation.
  18847. func (m *WxMutation) Tel() (r string, exists bool) {
  18848. v := m.tel
  18849. if v == nil {
  18850. return
  18851. }
  18852. return *v, true
  18853. }
  18854. // OldTel returns the old "tel" field's value of the Wx entity.
  18855. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18857. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  18858. if !m.op.Is(OpUpdateOne) {
  18859. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  18860. }
  18861. if m.id == nil || m.oldValue == nil {
  18862. return v, errors.New("OldTel requires an ID field in the mutation")
  18863. }
  18864. oldValue, err := m.oldValue(ctx)
  18865. if err != nil {
  18866. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  18867. }
  18868. return oldValue.Tel, nil
  18869. }
  18870. // ResetTel resets all changes to the "tel" field.
  18871. func (m *WxMutation) ResetTel() {
  18872. m.tel = nil
  18873. }
  18874. // SetHeadBig sets the "head_big" field.
  18875. func (m *WxMutation) SetHeadBig(s string) {
  18876. m.head_big = &s
  18877. }
  18878. // HeadBig returns the value of the "head_big" field in the mutation.
  18879. func (m *WxMutation) HeadBig() (r string, exists bool) {
  18880. v := m.head_big
  18881. if v == nil {
  18882. return
  18883. }
  18884. return *v, true
  18885. }
  18886. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  18887. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18889. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  18890. if !m.op.Is(OpUpdateOne) {
  18891. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  18892. }
  18893. if m.id == nil || m.oldValue == nil {
  18894. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  18895. }
  18896. oldValue, err := m.oldValue(ctx)
  18897. if err != nil {
  18898. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  18899. }
  18900. return oldValue.HeadBig, nil
  18901. }
  18902. // ResetHeadBig resets all changes to the "head_big" field.
  18903. func (m *WxMutation) ResetHeadBig() {
  18904. m.head_big = nil
  18905. }
  18906. // SetOrganizationID sets the "organization_id" field.
  18907. func (m *WxMutation) SetOrganizationID(u uint64) {
  18908. m.organization_id = &u
  18909. m.addorganization_id = nil
  18910. }
  18911. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18912. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  18913. v := m.organization_id
  18914. if v == nil {
  18915. return
  18916. }
  18917. return *v, true
  18918. }
  18919. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  18920. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18922. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18923. if !m.op.Is(OpUpdateOne) {
  18924. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18925. }
  18926. if m.id == nil || m.oldValue == nil {
  18927. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18928. }
  18929. oldValue, err := m.oldValue(ctx)
  18930. if err != nil {
  18931. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18932. }
  18933. return oldValue.OrganizationID, nil
  18934. }
  18935. // AddOrganizationID adds u to the "organization_id" field.
  18936. func (m *WxMutation) AddOrganizationID(u int64) {
  18937. if m.addorganization_id != nil {
  18938. *m.addorganization_id += u
  18939. } else {
  18940. m.addorganization_id = &u
  18941. }
  18942. }
  18943. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18944. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  18945. v := m.addorganization_id
  18946. if v == nil {
  18947. return
  18948. }
  18949. return *v, true
  18950. }
  18951. // ClearOrganizationID clears the value of the "organization_id" field.
  18952. func (m *WxMutation) ClearOrganizationID() {
  18953. m.organization_id = nil
  18954. m.addorganization_id = nil
  18955. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  18956. }
  18957. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18958. func (m *WxMutation) OrganizationIDCleared() bool {
  18959. _, ok := m.clearedFields[wx.FieldOrganizationID]
  18960. return ok
  18961. }
  18962. // ResetOrganizationID resets all changes to the "organization_id" field.
  18963. func (m *WxMutation) ResetOrganizationID() {
  18964. m.organization_id = nil
  18965. m.addorganization_id = nil
  18966. delete(m.clearedFields, wx.FieldOrganizationID)
  18967. }
  18968. // SetAgentID sets the "agent_id" field.
  18969. func (m *WxMutation) SetAgentID(u uint64) {
  18970. m.agent = &u
  18971. }
  18972. // AgentID returns the value of the "agent_id" field in the mutation.
  18973. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  18974. v := m.agent
  18975. if v == nil {
  18976. return
  18977. }
  18978. return *v, true
  18979. }
  18980. // OldAgentID returns the old "agent_id" 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) OldAgentID(ctx context.Context) (v uint64, err error) {
  18984. if !m.op.Is(OpUpdateOne) {
  18985. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  18986. }
  18987. if m.id == nil || m.oldValue == nil {
  18988. return v, errors.New("OldAgentID 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 OldAgentID: %w", err)
  18993. }
  18994. return oldValue.AgentID, nil
  18995. }
  18996. // ResetAgentID resets all changes to the "agent_id" field.
  18997. func (m *WxMutation) ResetAgentID() {
  18998. m.agent = nil
  18999. }
  19000. // SetAPIBase sets the "api_base" field.
  19001. func (m *WxMutation) SetAPIBase(s string) {
  19002. m.api_base = &s
  19003. }
  19004. // APIBase returns the value of the "api_base" field in the mutation.
  19005. func (m *WxMutation) APIBase() (r string, exists bool) {
  19006. v := m.api_base
  19007. if v == nil {
  19008. return
  19009. }
  19010. return *v, true
  19011. }
  19012. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  19013. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19015. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  19016. if !m.op.Is(OpUpdateOne) {
  19017. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  19018. }
  19019. if m.id == nil || m.oldValue == nil {
  19020. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  19021. }
  19022. oldValue, err := m.oldValue(ctx)
  19023. if err != nil {
  19024. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  19025. }
  19026. return oldValue.APIBase, nil
  19027. }
  19028. // ClearAPIBase clears the value of the "api_base" field.
  19029. func (m *WxMutation) ClearAPIBase() {
  19030. m.api_base = nil
  19031. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  19032. }
  19033. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  19034. func (m *WxMutation) APIBaseCleared() bool {
  19035. _, ok := m.clearedFields[wx.FieldAPIBase]
  19036. return ok
  19037. }
  19038. // ResetAPIBase resets all changes to the "api_base" field.
  19039. func (m *WxMutation) ResetAPIBase() {
  19040. m.api_base = nil
  19041. delete(m.clearedFields, wx.FieldAPIBase)
  19042. }
  19043. // SetAPIKey sets the "api_key" field.
  19044. func (m *WxMutation) SetAPIKey(s string) {
  19045. m.api_key = &s
  19046. }
  19047. // APIKey returns the value of the "api_key" field in the mutation.
  19048. func (m *WxMutation) APIKey() (r string, exists bool) {
  19049. v := m.api_key
  19050. if v == nil {
  19051. return
  19052. }
  19053. return *v, true
  19054. }
  19055. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  19056. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19058. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  19059. if !m.op.Is(OpUpdateOne) {
  19060. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  19061. }
  19062. if m.id == nil || m.oldValue == nil {
  19063. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  19064. }
  19065. oldValue, err := m.oldValue(ctx)
  19066. if err != nil {
  19067. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  19068. }
  19069. return oldValue.APIKey, nil
  19070. }
  19071. // ClearAPIKey clears the value of the "api_key" field.
  19072. func (m *WxMutation) ClearAPIKey() {
  19073. m.api_key = nil
  19074. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  19075. }
  19076. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  19077. func (m *WxMutation) APIKeyCleared() bool {
  19078. _, ok := m.clearedFields[wx.FieldAPIKey]
  19079. return ok
  19080. }
  19081. // ResetAPIKey resets all changes to the "api_key" field.
  19082. func (m *WxMutation) ResetAPIKey() {
  19083. m.api_key = nil
  19084. delete(m.clearedFields, wx.FieldAPIKey)
  19085. }
  19086. // SetAllowList sets the "allow_list" field.
  19087. func (m *WxMutation) SetAllowList(s []string) {
  19088. m.allow_list = &s
  19089. m.appendallow_list = nil
  19090. }
  19091. // AllowList returns the value of the "allow_list" field in the mutation.
  19092. func (m *WxMutation) AllowList() (r []string, exists bool) {
  19093. v := m.allow_list
  19094. if v == nil {
  19095. return
  19096. }
  19097. return *v, true
  19098. }
  19099. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  19100. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19102. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  19103. if !m.op.Is(OpUpdateOne) {
  19104. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  19105. }
  19106. if m.id == nil || m.oldValue == nil {
  19107. return v, errors.New("OldAllowList requires an ID field in the mutation")
  19108. }
  19109. oldValue, err := m.oldValue(ctx)
  19110. if err != nil {
  19111. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  19112. }
  19113. return oldValue.AllowList, nil
  19114. }
  19115. // AppendAllowList adds s to the "allow_list" field.
  19116. func (m *WxMutation) AppendAllowList(s []string) {
  19117. m.appendallow_list = append(m.appendallow_list, s...)
  19118. }
  19119. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  19120. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  19121. if len(m.appendallow_list) == 0 {
  19122. return nil, false
  19123. }
  19124. return m.appendallow_list, true
  19125. }
  19126. // ResetAllowList resets all changes to the "allow_list" field.
  19127. func (m *WxMutation) ResetAllowList() {
  19128. m.allow_list = nil
  19129. m.appendallow_list = nil
  19130. }
  19131. // SetGroupAllowList sets the "group_allow_list" field.
  19132. func (m *WxMutation) SetGroupAllowList(s []string) {
  19133. m.group_allow_list = &s
  19134. m.appendgroup_allow_list = nil
  19135. }
  19136. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  19137. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  19138. v := m.group_allow_list
  19139. if v == nil {
  19140. return
  19141. }
  19142. return *v, true
  19143. }
  19144. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  19145. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19147. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  19148. if !m.op.Is(OpUpdateOne) {
  19149. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  19150. }
  19151. if m.id == nil || m.oldValue == nil {
  19152. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  19153. }
  19154. oldValue, err := m.oldValue(ctx)
  19155. if err != nil {
  19156. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  19157. }
  19158. return oldValue.GroupAllowList, nil
  19159. }
  19160. // AppendGroupAllowList adds s to the "group_allow_list" field.
  19161. func (m *WxMutation) AppendGroupAllowList(s []string) {
  19162. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  19163. }
  19164. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  19165. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  19166. if len(m.appendgroup_allow_list) == 0 {
  19167. return nil, false
  19168. }
  19169. return m.appendgroup_allow_list, true
  19170. }
  19171. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  19172. func (m *WxMutation) ResetGroupAllowList() {
  19173. m.group_allow_list = nil
  19174. m.appendgroup_allow_list = nil
  19175. }
  19176. // SetBlockList sets the "block_list" field.
  19177. func (m *WxMutation) SetBlockList(s []string) {
  19178. m.block_list = &s
  19179. m.appendblock_list = nil
  19180. }
  19181. // BlockList returns the value of the "block_list" field in the mutation.
  19182. func (m *WxMutation) BlockList() (r []string, exists bool) {
  19183. v := m.block_list
  19184. if v == nil {
  19185. return
  19186. }
  19187. return *v, true
  19188. }
  19189. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  19190. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19192. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  19193. if !m.op.Is(OpUpdateOne) {
  19194. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  19195. }
  19196. if m.id == nil || m.oldValue == nil {
  19197. return v, errors.New("OldBlockList requires an ID field in the mutation")
  19198. }
  19199. oldValue, err := m.oldValue(ctx)
  19200. if err != nil {
  19201. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  19202. }
  19203. return oldValue.BlockList, nil
  19204. }
  19205. // AppendBlockList adds s to the "block_list" field.
  19206. func (m *WxMutation) AppendBlockList(s []string) {
  19207. m.appendblock_list = append(m.appendblock_list, s...)
  19208. }
  19209. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  19210. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  19211. if len(m.appendblock_list) == 0 {
  19212. return nil, false
  19213. }
  19214. return m.appendblock_list, true
  19215. }
  19216. // ResetBlockList resets all changes to the "block_list" field.
  19217. func (m *WxMutation) ResetBlockList() {
  19218. m.block_list = nil
  19219. m.appendblock_list = nil
  19220. }
  19221. // SetGroupBlockList sets the "group_block_list" field.
  19222. func (m *WxMutation) SetGroupBlockList(s []string) {
  19223. m.group_block_list = &s
  19224. m.appendgroup_block_list = nil
  19225. }
  19226. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  19227. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  19228. v := m.group_block_list
  19229. if v == nil {
  19230. return
  19231. }
  19232. return *v, true
  19233. }
  19234. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  19235. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19237. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  19238. if !m.op.Is(OpUpdateOne) {
  19239. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  19240. }
  19241. if m.id == nil || m.oldValue == nil {
  19242. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  19243. }
  19244. oldValue, err := m.oldValue(ctx)
  19245. if err != nil {
  19246. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  19247. }
  19248. return oldValue.GroupBlockList, nil
  19249. }
  19250. // AppendGroupBlockList adds s to the "group_block_list" field.
  19251. func (m *WxMutation) AppendGroupBlockList(s []string) {
  19252. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  19253. }
  19254. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  19255. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  19256. if len(m.appendgroup_block_list) == 0 {
  19257. return nil, false
  19258. }
  19259. return m.appendgroup_block_list, true
  19260. }
  19261. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  19262. func (m *WxMutation) ResetGroupBlockList() {
  19263. m.group_block_list = nil
  19264. m.appendgroup_block_list = nil
  19265. }
  19266. // ClearServer clears the "server" edge to the Server entity.
  19267. func (m *WxMutation) ClearServer() {
  19268. m.clearedserver = true
  19269. m.clearedFields[wx.FieldServerID] = struct{}{}
  19270. }
  19271. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  19272. func (m *WxMutation) ServerCleared() bool {
  19273. return m.ServerIDCleared() || m.clearedserver
  19274. }
  19275. // ServerIDs returns the "server" edge IDs in the mutation.
  19276. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19277. // ServerID instead. It exists only for internal usage by the builders.
  19278. func (m *WxMutation) ServerIDs() (ids []uint64) {
  19279. if id := m.server; id != nil {
  19280. ids = append(ids, *id)
  19281. }
  19282. return
  19283. }
  19284. // ResetServer resets all changes to the "server" edge.
  19285. func (m *WxMutation) ResetServer() {
  19286. m.server = nil
  19287. m.clearedserver = false
  19288. }
  19289. // ClearAgent clears the "agent" edge to the Agent entity.
  19290. func (m *WxMutation) ClearAgent() {
  19291. m.clearedagent = true
  19292. m.clearedFields[wx.FieldAgentID] = struct{}{}
  19293. }
  19294. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  19295. func (m *WxMutation) AgentCleared() bool {
  19296. return m.clearedagent
  19297. }
  19298. // AgentIDs returns the "agent" edge IDs in the mutation.
  19299. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19300. // AgentID instead. It exists only for internal usage by the builders.
  19301. func (m *WxMutation) AgentIDs() (ids []uint64) {
  19302. if id := m.agent; id != nil {
  19303. ids = append(ids, *id)
  19304. }
  19305. return
  19306. }
  19307. // ResetAgent resets all changes to the "agent" edge.
  19308. func (m *WxMutation) ResetAgent() {
  19309. m.agent = nil
  19310. m.clearedagent = false
  19311. }
  19312. // Where appends a list predicates to the WxMutation builder.
  19313. func (m *WxMutation) Where(ps ...predicate.Wx) {
  19314. m.predicates = append(m.predicates, ps...)
  19315. }
  19316. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  19317. // users can use type-assertion to append predicates that do not depend on any generated package.
  19318. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  19319. p := make([]predicate.Wx, len(ps))
  19320. for i := range ps {
  19321. p[i] = ps[i]
  19322. }
  19323. m.Where(p...)
  19324. }
  19325. // Op returns the operation name.
  19326. func (m *WxMutation) Op() Op {
  19327. return m.op
  19328. }
  19329. // SetOp allows setting the mutation operation.
  19330. func (m *WxMutation) SetOp(op Op) {
  19331. m.op = op
  19332. }
  19333. // Type returns the node type of this mutation (Wx).
  19334. func (m *WxMutation) Type() string {
  19335. return m.typ
  19336. }
  19337. // Fields returns all fields that were changed during this mutation. Note that in
  19338. // order to get all numeric fields that were incremented/decremented, call
  19339. // AddedFields().
  19340. func (m *WxMutation) Fields() []string {
  19341. fields := make([]string, 0, 21)
  19342. if m.created_at != nil {
  19343. fields = append(fields, wx.FieldCreatedAt)
  19344. }
  19345. if m.updated_at != nil {
  19346. fields = append(fields, wx.FieldUpdatedAt)
  19347. }
  19348. if m.status != nil {
  19349. fields = append(fields, wx.FieldStatus)
  19350. }
  19351. if m.deleted_at != nil {
  19352. fields = append(fields, wx.FieldDeletedAt)
  19353. }
  19354. if m.server != nil {
  19355. fields = append(fields, wx.FieldServerID)
  19356. }
  19357. if m.port != nil {
  19358. fields = append(fields, wx.FieldPort)
  19359. }
  19360. if m.process_id != nil {
  19361. fields = append(fields, wx.FieldProcessID)
  19362. }
  19363. if m.callback != nil {
  19364. fields = append(fields, wx.FieldCallback)
  19365. }
  19366. if m.wxid != nil {
  19367. fields = append(fields, wx.FieldWxid)
  19368. }
  19369. if m.account != nil {
  19370. fields = append(fields, wx.FieldAccount)
  19371. }
  19372. if m.nickname != nil {
  19373. fields = append(fields, wx.FieldNickname)
  19374. }
  19375. if m.tel != nil {
  19376. fields = append(fields, wx.FieldTel)
  19377. }
  19378. if m.head_big != nil {
  19379. fields = append(fields, wx.FieldHeadBig)
  19380. }
  19381. if m.organization_id != nil {
  19382. fields = append(fields, wx.FieldOrganizationID)
  19383. }
  19384. if m.agent != nil {
  19385. fields = append(fields, wx.FieldAgentID)
  19386. }
  19387. if m.api_base != nil {
  19388. fields = append(fields, wx.FieldAPIBase)
  19389. }
  19390. if m.api_key != nil {
  19391. fields = append(fields, wx.FieldAPIKey)
  19392. }
  19393. if m.allow_list != nil {
  19394. fields = append(fields, wx.FieldAllowList)
  19395. }
  19396. if m.group_allow_list != nil {
  19397. fields = append(fields, wx.FieldGroupAllowList)
  19398. }
  19399. if m.block_list != nil {
  19400. fields = append(fields, wx.FieldBlockList)
  19401. }
  19402. if m.group_block_list != nil {
  19403. fields = append(fields, wx.FieldGroupBlockList)
  19404. }
  19405. return fields
  19406. }
  19407. // Field returns the value of a field with the given name. The second boolean
  19408. // return value indicates that this field was not set, or was not defined in the
  19409. // schema.
  19410. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  19411. switch name {
  19412. case wx.FieldCreatedAt:
  19413. return m.CreatedAt()
  19414. case wx.FieldUpdatedAt:
  19415. return m.UpdatedAt()
  19416. case wx.FieldStatus:
  19417. return m.Status()
  19418. case wx.FieldDeletedAt:
  19419. return m.DeletedAt()
  19420. case wx.FieldServerID:
  19421. return m.ServerID()
  19422. case wx.FieldPort:
  19423. return m.Port()
  19424. case wx.FieldProcessID:
  19425. return m.ProcessID()
  19426. case wx.FieldCallback:
  19427. return m.Callback()
  19428. case wx.FieldWxid:
  19429. return m.Wxid()
  19430. case wx.FieldAccount:
  19431. return m.Account()
  19432. case wx.FieldNickname:
  19433. return m.Nickname()
  19434. case wx.FieldTel:
  19435. return m.Tel()
  19436. case wx.FieldHeadBig:
  19437. return m.HeadBig()
  19438. case wx.FieldOrganizationID:
  19439. return m.OrganizationID()
  19440. case wx.FieldAgentID:
  19441. return m.AgentID()
  19442. case wx.FieldAPIBase:
  19443. return m.APIBase()
  19444. case wx.FieldAPIKey:
  19445. return m.APIKey()
  19446. case wx.FieldAllowList:
  19447. return m.AllowList()
  19448. case wx.FieldGroupAllowList:
  19449. return m.GroupAllowList()
  19450. case wx.FieldBlockList:
  19451. return m.BlockList()
  19452. case wx.FieldGroupBlockList:
  19453. return m.GroupBlockList()
  19454. }
  19455. return nil, false
  19456. }
  19457. // OldField returns the old value of the field from the database. An error is
  19458. // returned if the mutation operation is not UpdateOne, or the query to the
  19459. // database failed.
  19460. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19461. switch name {
  19462. case wx.FieldCreatedAt:
  19463. return m.OldCreatedAt(ctx)
  19464. case wx.FieldUpdatedAt:
  19465. return m.OldUpdatedAt(ctx)
  19466. case wx.FieldStatus:
  19467. return m.OldStatus(ctx)
  19468. case wx.FieldDeletedAt:
  19469. return m.OldDeletedAt(ctx)
  19470. case wx.FieldServerID:
  19471. return m.OldServerID(ctx)
  19472. case wx.FieldPort:
  19473. return m.OldPort(ctx)
  19474. case wx.FieldProcessID:
  19475. return m.OldProcessID(ctx)
  19476. case wx.FieldCallback:
  19477. return m.OldCallback(ctx)
  19478. case wx.FieldWxid:
  19479. return m.OldWxid(ctx)
  19480. case wx.FieldAccount:
  19481. return m.OldAccount(ctx)
  19482. case wx.FieldNickname:
  19483. return m.OldNickname(ctx)
  19484. case wx.FieldTel:
  19485. return m.OldTel(ctx)
  19486. case wx.FieldHeadBig:
  19487. return m.OldHeadBig(ctx)
  19488. case wx.FieldOrganizationID:
  19489. return m.OldOrganizationID(ctx)
  19490. case wx.FieldAgentID:
  19491. return m.OldAgentID(ctx)
  19492. case wx.FieldAPIBase:
  19493. return m.OldAPIBase(ctx)
  19494. case wx.FieldAPIKey:
  19495. return m.OldAPIKey(ctx)
  19496. case wx.FieldAllowList:
  19497. return m.OldAllowList(ctx)
  19498. case wx.FieldGroupAllowList:
  19499. return m.OldGroupAllowList(ctx)
  19500. case wx.FieldBlockList:
  19501. return m.OldBlockList(ctx)
  19502. case wx.FieldGroupBlockList:
  19503. return m.OldGroupBlockList(ctx)
  19504. }
  19505. return nil, fmt.Errorf("unknown Wx field %s", name)
  19506. }
  19507. // SetField sets the value of a field with the given name. It returns an error if
  19508. // the field is not defined in the schema, or if the type mismatched the field
  19509. // type.
  19510. func (m *WxMutation) SetField(name string, value ent.Value) error {
  19511. switch name {
  19512. case wx.FieldCreatedAt:
  19513. v, ok := value.(time.Time)
  19514. if !ok {
  19515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19516. }
  19517. m.SetCreatedAt(v)
  19518. return nil
  19519. case wx.FieldUpdatedAt:
  19520. v, ok := value.(time.Time)
  19521. if !ok {
  19522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19523. }
  19524. m.SetUpdatedAt(v)
  19525. return nil
  19526. case wx.FieldStatus:
  19527. v, ok := value.(uint8)
  19528. if !ok {
  19529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19530. }
  19531. m.SetStatus(v)
  19532. return nil
  19533. case wx.FieldDeletedAt:
  19534. v, ok := value.(time.Time)
  19535. if !ok {
  19536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19537. }
  19538. m.SetDeletedAt(v)
  19539. return nil
  19540. case wx.FieldServerID:
  19541. v, ok := value.(uint64)
  19542. if !ok {
  19543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19544. }
  19545. m.SetServerID(v)
  19546. return nil
  19547. case wx.FieldPort:
  19548. v, ok := value.(string)
  19549. if !ok {
  19550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19551. }
  19552. m.SetPort(v)
  19553. return nil
  19554. case wx.FieldProcessID:
  19555. v, ok := value.(string)
  19556. if !ok {
  19557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19558. }
  19559. m.SetProcessID(v)
  19560. return nil
  19561. case wx.FieldCallback:
  19562. v, ok := value.(string)
  19563. if !ok {
  19564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19565. }
  19566. m.SetCallback(v)
  19567. return nil
  19568. case wx.FieldWxid:
  19569. v, ok := value.(string)
  19570. if !ok {
  19571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19572. }
  19573. m.SetWxid(v)
  19574. return nil
  19575. case wx.FieldAccount:
  19576. v, ok := value.(string)
  19577. if !ok {
  19578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19579. }
  19580. m.SetAccount(v)
  19581. return nil
  19582. case wx.FieldNickname:
  19583. v, ok := value.(string)
  19584. if !ok {
  19585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19586. }
  19587. m.SetNickname(v)
  19588. return nil
  19589. case wx.FieldTel:
  19590. v, ok := value.(string)
  19591. if !ok {
  19592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19593. }
  19594. m.SetTel(v)
  19595. return nil
  19596. case wx.FieldHeadBig:
  19597. v, ok := value.(string)
  19598. if !ok {
  19599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19600. }
  19601. m.SetHeadBig(v)
  19602. return nil
  19603. case wx.FieldOrganizationID:
  19604. v, ok := value.(uint64)
  19605. if !ok {
  19606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19607. }
  19608. m.SetOrganizationID(v)
  19609. return nil
  19610. case wx.FieldAgentID:
  19611. v, ok := value.(uint64)
  19612. if !ok {
  19613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19614. }
  19615. m.SetAgentID(v)
  19616. return nil
  19617. case wx.FieldAPIBase:
  19618. v, ok := value.(string)
  19619. if !ok {
  19620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19621. }
  19622. m.SetAPIBase(v)
  19623. return nil
  19624. case wx.FieldAPIKey:
  19625. v, ok := value.(string)
  19626. if !ok {
  19627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19628. }
  19629. m.SetAPIKey(v)
  19630. return nil
  19631. case wx.FieldAllowList:
  19632. v, ok := value.([]string)
  19633. if !ok {
  19634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19635. }
  19636. m.SetAllowList(v)
  19637. return nil
  19638. case wx.FieldGroupAllowList:
  19639. v, ok := value.([]string)
  19640. if !ok {
  19641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19642. }
  19643. m.SetGroupAllowList(v)
  19644. return nil
  19645. case wx.FieldBlockList:
  19646. v, ok := value.([]string)
  19647. if !ok {
  19648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19649. }
  19650. m.SetBlockList(v)
  19651. return nil
  19652. case wx.FieldGroupBlockList:
  19653. v, ok := value.([]string)
  19654. if !ok {
  19655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19656. }
  19657. m.SetGroupBlockList(v)
  19658. return nil
  19659. }
  19660. return fmt.Errorf("unknown Wx field %s", name)
  19661. }
  19662. // AddedFields returns all numeric fields that were incremented/decremented during
  19663. // this mutation.
  19664. func (m *WxMutation) AddedFields() []string {
  19665. var fields []string
  19666. if m.addstatus != nil {
  19667. fields = append(fields, wx.FieldStatus)
  19668. }
  19669. if m.addorganization_id != nil {
  19670. fields = append(fields, wx.FieldOrganizationID)
  19671. }
  19672. return fields
  19673. }
  19674. // AddedField returns the numeric value that was incremented/decremented on a field
  19675. // with the given name. The second boolean return value indicates that this field
  19676. // was not set, or was not defined in the schema.
  19677. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  19678. switch name {
  19679. case wx.FieldStatus:
  19680. return m.AddedStatus()
  19681. case wx.FieldOrganizationID:
  19682. return m.AddedOrganizationID()
  19683. }
  19684. return nil, false
  19685. }
  19686. // AddField adds the value to the field with the given name. It returns an error if
  19687. // the field is not defined in the schema, or if the type mismatched the field
  19688. // type.
  19689. func (m *WxMutation) AddField(name string, value ent.Value) error {
  19690. switch name {
  19691. case wx.FieldStatus:
  19692. v, ok := value.(int8)
  19693. if !ok {
  19694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19695. }
  19696. m.AddStatus(v)
  19697. return nil
  19698. case wx.FieldOrganizationID:
  19699. v, ok := value.(int64)
  19700. if !ok {
  19701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19702. }
  19703. m.AddOrganizationID(v)
  19704. return nil
  19705. }
  19706. return fmt.Errorf("unknown Wx numeric field %s", name)
  19707. }
  19708. // ClearedFields returns all nullable fields that were cleared during this
  19709. // mutation.
  19710. func (m *WxMutation) ClearedFields() []string {
  19711. var fields []string
  19712. if m.FieldCleared(wx.FieldStatus) {
  19713. fields = append(fields, wx.FieldStatus)
  19714. }
  19715. if m.FieldCleared(wx.FieldDeletedAt) {
  19716. fields = append(fields, wx.FieldDeletedAt)
  19717. }
  19718. if m.FieldCleared(wx.FieldServerID) {
  19719. fields = append(fields, wx.FieldServerID)
  19720. }
  19721. if m.FieldCleared(wx.FieldOrganizationID) {
  19722. fields = append(fields, wx.FieldOrganizationID)
  19723. }
  19724. if m.FieldCleared(wx.FieldAPIBase) {
  19725. fields = append(fields, wx.FieldAPIBase)
  19726. }
  19727. if m.FieldCleared(wx.FieldAPIKey) {
  19728. fields = append(fields, wx.FieldAPIKey)
  19729. }
  19730. return fields
  19731. }
  19732. // FieldCleared returns a boolean indicating if a field with the given name was
  19733. // cleared in this mutation.
  19734. func (m *WxMutation) FieldCleared(name string) bool {
  19735. _, ok := m.clearedFields[name]
  19736. return ok
  19737. }
  19738. // ClearField clears the value of the field with the given name. It returns an
  19739. // error if the field is not defined in the schema.
  19740. func (m *WxMutation) ClearField(name string) error {
  19741. switch name {
  19742. case wx.FieldStatus:
  19743. m.ClearStatus()
  19744. return nil
  19745. case wx.FieldDeletedAt:
  19746. m.ClearDeletedAt()
  19747. return nil
  19748. case wx.FieldServerID:
  19749. m.ClearServerID()
  19750. return nil
  19751. case wx.FieldOrganizationID:
  19752. m.ClearOrganizationID()
  19753. return nil
  19754. case wx.FieldAPIBase:
  19755. m.ClearAPIBase()
  19756. return nil
  19757. case wx.FieldAPIKey:
  19758. m.ClearAPIKey()
  19759. return nil
  19760. }
  19761. return fmt.Errorf("unknown Wx nullable field %s", name)
  19762. }
  19763. // ResetField resets all changes in the mutation for the field with the given name.
  19764. // It returns an error if the field is not defined in the schema.
  19765. func (m *WxMutation) ResetField(name string) error {
  19766. switch name {
  19767. case wx.FieldCreatedAt:
  19768. m.ResetCreatedAt()
  19769. return nil
  19770. case wx.FieldUpdatedAt:
  19771. m.ResetUpdatedAt()
  19772. return nil
  19773. case wx.FieldStatus:
  19774. m.ResetStatus()
  19775. return nil
  19776. case wx.FieldDeletedAt:
  19777. m.ResetDeletedAt()
  19778. return nil
  19779. case wx.FieldServerID:
  19780. m.ResetServerID()
  19781. return nil
  19782. case wx.FieldPort:
  19783. m.ResetPort()
  19784. return nil
  19785. case wx.FieldProcessID:
  19786. m.ResetProcessID()
  19787. return nil
  19788. case wx.FieldCallback:
  19789. m.ResetCallback()
  19790. return nil
  19791. case wx.FieldWxid:
  19792. m.ResetWxid()
  19793. return nil
  19794. case wx.FieldAccount:
  19795. m.ResetAccount()
  19796. return nil
  19797. case wx.FieldNickname:
  19798. m.ResetNickname()
  19799. return nil
  19800. case wx.FieldTel:
  19801. m.ResetTel()
  19802. return nil
  19803. case wx.FieldHeadBig:
  19804. m.ResetHeadBig()
  19805. return nil
  19806. case wx.FieldOrganizationID:
  19807. m.ResetOrganizationID()
  19808. return nil
  19809. case wx.FieldAgentID:
  19810. m.ResetAgentID()
  19811. return nil
  19812. case wx.FieldAPIBase:
  19813. m.ResetAPIBase()
  19814. return nil
  19815. case wx.FieldAPIKey:
  19816. m.ResetAPIKey()
  19817. return nil
  19818. case wx.FieldAllowList:
  19819. m.ResetAllowList()
  19820. return nil
  19821. case wx.FieldGroupAllowList:
  19822. m.ResetGroupAllowList()
  19823. return nil
  19824. case wx.FieldBlockList:
  19825. m.ResetBlockList()
  19826. return nil
  19827. case wx.FieldGroupBlockList:
  19828. m.ResetGroupBlockList()
  19829. return nil
  19830. }
  19831. return fmt.Errorf("unknown Wx field %s", name)
  19832. }
  19833. // AddedEdges returns all edge names that were set/added in this mutation.
  19834. func (m *WxMutation) AddedEdges() []string {
  19835. edges := make([]string, 0, 2)
  19836. if m.server != nil {
  19837. edges = append(edges, wx.EdgeServer)
  19838. }
  19839. if m.agent != nil {
  19840. edges = append(edges, wx.EdgeAgent)
  19841. }
  19842. return edges
  19843. }
  19844. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19845. // name in this mutation.
  19846. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  19847. switch name {
  19848. case wx.EdgeServer:
  19849. if id := m.server; id != nil {
  19850. return []ent.Value{*id}
  19851. }
  19852. case wx.EdgeAgent:
  19853. if id := m.agent; id != nil {
  19854. return []ent.Value{*id}
  19855. }
  19856. }
  19857. return nil
  19858. }
  19859. // RemovedEdges returns all edge names that were removed in this mutation.
  19860. func (m *WxMutation) RemovedEdges() []string {
  19861. edges := make([]string, 0, 2)
  19862. return edges
  19863. }
  19864. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19865. // the given name in this mutation.
  19866. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  19867. return nil
  19868. }
  19869. // ClearedEdges returns all edge names that were cleared in this mutation.
  19870. func (m *WxMutation) ClearedEdges() []string {
  19871. edges := make([]string, 0, 2)
  19872. if m.clearedserver {
  19873. edges = append(edges, wx.EdgeServer)
  19874. }
  19875. if m.clearedagent {
  19876. edges = append(edges, wx.EdgeAgent)
  19877. }
  19878. return edges
  19879. }
  19880. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19881. // was cleared in this mutation.
  19882. func (m *WxMutation) EdgeCleared(name string) bool {
  19883. switch name {
  19884. case wx.EdgeServer:
  19885. return m.clearedserver
  19886. case wx.EdgeAgent:
  19887. return m.clearedagent
  19888. }
  19889. return false
  19890. }
  19891. // ClearEdge clears the value of the edge with the given name. It returns an error
  19892. // if that edge is not defined in the schema.
  19893. func (m *WxMutation) ClearEdge(name string) error {
  19894. switch name {
  19895. case wx.EdgeServer:
  19896. m.ClearServer()
  19897. return nil
  19898. case wx.EdgeAgent:
  19899. m.ClearAgent()
  19900. return nil
  19901. }
  19902. return fmt.Errorf("unknown Wx unique edge %s", name)
  19903. }
  19904. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19905. // It returns an error if the edge is not defined in the schema.
  19906. func (m *WxMutation) ResetEdge(name string) error {
  19907. switch name {
  19908. case wx.EdgeServer:
  19909. m.ResetServer()
  19910. return nil
  19911. case wx.EdgeAgent:
  19912. m.ResetAgent()
  19913. return nil
  19914. }
  19915. return fmt.Errorf("unknown Wx edge %s", name)
  19916. }