mutation.go 641 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/batchmsg"
  11. "wechat-api/ent/category"
  12. "wechat-api/ent/contact"
  13. "wechat-api/ent/custom_types"
  14. "wechat-api/ent/employee"
  15. "wechat-api/ent/employeeconfig"
  16. "wechat-api/ent/label"
  17. "wechat-api/ent/labelrelationship"
  18. "wechat-api/ent/message"
  19. "wechat-api/ent/messagerecords"
  20. "wechat-api/ent/msg"
  21. "wechat-api/ent/predicate"
  22. "wechat-api/ent/server"
  23. "wechat-api/ent/sopnode"
  24. "wechat-api/ent/sopstage"
  25. "wechat-api/ent/soptask"
  26. "wechat-api/ent/token"
  27. "wechat-api/ent/tutorial"
  28. "wechat-api/ent/workexperience"
  29. "wechat-api/ent/wx"
  30. "entgo.io/ent"
  31. "entgo.io/ent/dialect/sql"
  32. )
  33. const (
  34. // Operation types.
  35. OpCreate = ent.OpCreate
  36. OpDelete = ent.OpDelete
  37. OpDeleteOne = ent.OpDeleteOne
  38. OpUpdate = ent.OpUpdate
  39. OpUpdateOne = ent.OpUpdateOne
  40. // Node types.
  41. TypeAgent = "Agent"
  42. TypeBatchMsg = "BatchMsg"
  43. TypeCategory = "Category"
  44. TypeContact = "Contact"
  45. TypeEmployee = "Employee"
  46. TypeEmployeeConfig = "EmployeeConfig"
  47. TypeLabel = "Label"
  48. TypeLabelRelationship = "LabelRelationship"
  49. TypeMessage = "Message"
  50. TypeMessageRecords = "MessageRecords"
  51. TypeMsg = "Msg"
  52. TypeServer = "Server"
  53. TypeSopNode = "SopNode"
  54. TypeSopStage = "SopStage"
  55. TypeSopTask = "SopTask"
  56. TypeToken = "Token"
  57. TypeTutorial = "Tutorial"
  58. TypeWorkExperience = "WorkExperience"
  59. TypeWx = "Wx"
  60. )
  61. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  62. type AgentMutation struct {
  63. config
  64. op Op
  65. typ string
  66. id *uint64
  67. created_at *time.Time
  68. updated_at *time.Time
  69. deleted_at *time.Time
  70. name *string
  71. role *string
  72. status *int
  73. addstatus *int
  74. background *string
  75. examples *string
  76. organization_id *uint64
  77. addorganization_id *int64
  78. dataset_id *string
  79. collection_id *string
  80. clearedFields map[string]struct{}
  81. wx_agent map[uint64]struct{}
  82. removedwx_agent map[uint64]struct{}
  83. clearedwx_agent bool
  84. done bool
  85. oldValue func(context.Context) (*Agent, error)
  86. predicates []predicate.Agent
  87. }
  88. var _ ent.Mutation = (*AgentMutation)(nil)
  89. // agentOption allows management of the mutation configuration using functional options.
  90. type agentOption func(*AgentMutation)
  91. // newAgentMutation creates new mutation for the Agent entity.
  92. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  93. m := &AgentMutation{
  94. config: c,
  95. op: op,
  96. typ: TypeAgent,
  97. clearedFields: make(map[string]struct{}),
  98. }
  99. for _, opt := range opts {
  100. opt(m)
  101. }
  102. return m
  103. }
  104. // withAgentID sets the ID field of the mutation.
  105. func withAgentID(id uint64) agentOption {
  106. return func(m *AgentMutation) {
  107. var (
  108. err error
  109. once sync.Once
  110. value *Agent
  111. )
  112. m.oldValue = func(ctx context.Context) (*Agent, error) {
  113. once.Do(func() {
  114. if m.done {
  115. err = errors.New("querying old values post mutation is not allowed")
  116. } else {
  117. value, err = m.Client().Agent.Get(ctx, id)
  118. }
  119. })
  120. return value, err
  121. }
  122. m.id = &id
  123. }
  124. }
  125. // withAgent sets the old Agent of the mutation.
  126. func withAgent(node *Agent) agentOption {
  127. return func(m *AgentMutation) {
  128. m.oldValue = func(context.Context) (*Agent, error) {
  129. return node, nil
  130. }
  131. m.id = &node.ID
  132. }
  133. }
  134. // Client returns a new `ent.Client` from the mutation. If the mutation was
  135. // executed in a transaction (ent.Tx), a transactional client is returned.
  136. func (m AgentMutation) Client() *Client {
  137. client := &Client{config: m.config}
  138. client.init()
  139. return client
  140. }
  141. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  142. // it returns an error otherwise.
  143. func (m AgentMutation) Tx() (*Tx, error) {
  144. if _, ok := m.driver.(*txDriver); !ok {
  145. return nil, errors.New("ent: mutation is not running in a transaction")
  146. }
  147. tx := &Tx{config: m.config}
  148. tx.init()
  149. return tx, nil
  150. }
  151. // SetID sets the value of the id field. Note that this
  152. // operation is only accepted on creation of Agent entities.
  153. func (m *AgentMutation) SetID(id uint64) {
  154. m.id = &id
  155. }
  156. // ID returns the ID value in the mutation. Note that the ID is only available
  157. // if it was provided to the builder or after it was returned from the database.
  158. func (m *AgentMutation) ID() (id uint64, exists bool) {
  159. if m.id == nil {
  160. return
  161. }
  162. return *m.id, true
  163. }
  164. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  165. // That means, if the mutation is applied within a transaction with an isolation level such
  166. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  167. // or updated by the mutation.
  168. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  169. switch {
  170. case m.op.Is(OpUpdateOne | OpDeleteOne):
  171. id, exists := m.ID()
  172. if exists {
  173. return []uint64{id}, nil
  174. }
  175. fallthrough
  176. case m.op.Is(OpUpdate | OpDelete):
  177. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  178. default:
  179. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  180. }
  181. }
  182. // SetCreatedAt sets the "created_at" field.
  183. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  184. m.created_at = &t
  185. }
  186. // CreatedAt returns the value of the "created_at" field in the mutation.
  187. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  188. v := m.created_at
  189. if v == nil {
  190. return
  191. }
  192. return *v, true
  193. }
  194. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  195. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  197. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  198. if !m.op.Is(OpUpdateOne) {
  199. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  200. }
  201. if m.id == nil || m.oldValue == nil {
  202. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  203. }
  204. oldValue, err := m.oldValue(ctx)
  205. if err != nil {
  206. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  207. }
  208. return oldValue.CreatedAt, nil
  209. }
  210. // ResetCreatedAt resets all changes to the "created_at" field.
  211. func (m *AgentMutation) ResetCreatedAt() {
  212. m.created_at = nil
  213. }
  214. // SetUpdatedAt sets the "updated_at" field.
  215. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  216. m.updated_at = &t
  217. }
  218. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  219. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  220. v := m.updated_at
  221. if v == nil {
  222. return
  223. }
  224. return *v, true
  225. }
  226. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  227. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  229. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  230. if !m.op.Is(OpUpdateOne) {
  231. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  232. }
  233. if m.id == nil || m.oldValue == nil {
  234. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  235. }
  236. oldValue, err := m.oldValue(ctx)
  237. if err != nil {
  238. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  239. }
  240. return oldValue.UpdatedAt, nil
  241. }
  242. // ResetUpdatedAt resets all changes to the "updated_at" field.
  243. func (m *AgentMutation) ResetUpdatedAt() {
  244. m.updated_at = nil
  245. }
  246. // SetDeletedAt sets the "deleted_at" field.
  247. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  248. m.deleted_at = &t
  249. }
  250. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  251. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  252. v := m.deleted_at
  253. if v == nil {
  254. return
  255. }
  256. return *v, true
  257. }
  258. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  259. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  261. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  262. if !m.op.Is(OpUpdateOne) {
  263. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  264. }
  265. if m.id == nil || m.oldValue == nil {
  266. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  267. }
  268. oldValue, err := m.oldValue(ctx)
  269. if err != nil {
  270. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  271. }
  272. return oldValue.DeletedAt, nil
  273. }
  274. // ClearDeletedAt clears the value of the "deleted_at" field.
  275. func (m *AgentMutation) ClearDeletedAt() {
  276. m.deleted_at = nil
  277. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  278. }
  279. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  280. func (m *AgentMutation) DeletedAtCleared() bool {
  281. _, ok := m.clearedFields[agent.FieldDeletedAt]
  282. return ok
  283. }
  284. // ResetDeletedAt resets all changes to the "deleted_at" field.
  285. func (m *AgentMutation) ResetDeletedAt() {
  286. m.deleted_at = nil
  287. delete(m.clearedFields, agent.FieldDeletedAt)
  288. }
  289. // SetName sets the "name" field.
  290. func (m *AgentMutation) SetName(s string) {
  291. m.name = &s
  292. }
  293. // Name returns the value of the "name" field in the mutation.
  294. func (m *AgentMutation) Name() (r string, exists bool) {
  295. v := m.name
  296. if v == nil {
  297. return
  298. }
  299. return *v, true
  300. }
  301. // OldName returns the old "name" field's value of the Agent entity.
  302. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  304. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  305. if !m.op.Is(OpUpdateOne) {
  306. return v, errors.New("OldName is only allowed on UpdateOne operations")
  307. }
  308. if m.id == nil || m.oldValue == nil {
  309. return v, errors.New("OldName requires an ID field in the mutation")
  310. }
  311. oldValue, err := m.oldValue(ctx)
  312. if err != nil {
  313. return v, fmt.Errorf("querying old value for OldName: %w", err)
  314. }
  315. return oldValue.Name, nil
  316. }
  317. // ResetName resets all changes to the "name" field.
  318. func (m *AgentMutation) ResetName() {
  319. m.name = nil
  320. }
  321. // SetRole sets the "role" field.
  322. func (m *AgentMutation) SetRole(s string) {
  323. m.role = &s
  324. }
  325. // Role returns the value of the "role" field in the mutation.
  326. func (m *AgentMutation) Role() (r string, exists bool) {
  327. v := m.role
  328. if v == nil {
  329. return
  330. }
  331. return *v, true
  332. }
  333. // OldRole returns the old "role" field's value of the Agent entity.
  334. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  336. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  337. if !m.op.Is(OpUpdateOne) {
  338. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  339. }
  340. if m.id == nil || m.oldValue == nil {
  341. return v, errors.New("OldRole requires an ID field in the mutation")
  342. }
  343. oldValue, err := m.oldValue(ctx)
  344. if err != nil {
  345. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  346. }
  347. return oldValue.Role, nil
  348. }
  349. // ResetRole resets all changes to the "role" field.
  350. func (m *AgentMutation) ResetRole() {
  351. m.role = nil
  352. }
  353. // SetStatus sets the "status" field.
  354. func (m *AgentMutation) SetStatus(i int) {
  355. m.status = &i
  356. m.addstatus = nil
  357. }
  358. // Status returns the value of the "status" field in the mutation.
  359. func (m *AgentMutation) Status() (r int, exists bool) {
  360. v := m.status
  361. if v == nil {
  362. return
  363. }
  364. return *v, true
  365. }
  366. // OldStatus returns the old "status" field's value of the Agent entity.
  367. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  369. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  370. if !m.op.Is(OpUpdateOne) {
  371. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  372. }
  373. if m.id == nil || m.oldValue == nil {
  374. return v, errors.New("OldStatus requires an ID field in the mutation")
  375. }
  376. oldValue, err := m.oldValue(ctx)
  377. if err != nil {
  378. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  379. }
  380. return oldValue.Status, nil
  381. }
  382. // AddStatus adds i to the "status" field.
  383. func (m *AgentMutation) AddStatus(i int) {
  384. if m.addstatus != nil {
  385. *m.addstatus += i
  386. } else {
  387. m.addstatus = &i
  388. }
  389. }
  390. // AddedStatus returns the value that was added to the "status" field in this mutation.
  391. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  392. v := m.addstatus
  393. if v == nil {
  394. return
  395. }
  396. return *v, true
  397. }
  398. // ClearStatus clears the value of the "status" field.
  399. func (m *AgentMutation) ClearStatus() {
  400. m.status = nil
  401. m.addstatus = nil
  402. m.clearedFields[agent.FieldStatus] = struct{}{}
  403. }
  404. // StatusCleared returns if the "status" field was cleared in this mutation.
  405. func (m *AgentMutation) StatusCleared() bool {
  406. _, ok := m.clearedFields[agent.FieldStatus]
  407. return ok
  408. }
  409. // ResetStatus resets all changes to the "status" field.
  410. func (m *AgentMutation) ResetStatus() {
  411. m.status = nil
  412. m.addstatus = nil
  413. delete(m.clearedFields, agent.FieldStatus)
  414. }
  415. // SetBackground sets the "background" field.
  416. func (m *AgentMutation) SetBackground(s string) {
  417. m.background = &s
  418. }
  419. // Background returns the value of the "background" field in the mutation.
  420. func (m *AgentMutation) Background() (r string, exists bool) {
  421. v := m.background
  422. if v == nil {
  423. return
  424. }
  425. return *v, true
  426. }
  427. // OldBackground returns the old "background" field's value of the Agent entity.
  428. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  430. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  431. if !m.op.Is(OpUpdateOne) {
  432. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  433. }
  434. if m.id == nil || m.oldValue == nil {
  435. return v, errors.New("OldBackground requires an ID field in the mutation")
  436. }
  437. oldValue, err := m.oldValue(ctx)
  438. if err != nil {
  439. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  440. }
  441. return oldValue.Background, nil
  442. }
  443. // ClearBackground clears the value of the "background" field.
  444. func (m *AgentMutation) ClearBackground() {
  445. m.background = nil
  446. m.clearedFields[agent.FieldBackground] = struct{}{}
  447. }
  448. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  449. func (m *AgentMutation) BackgroundCleared() bool {
  450. _, ok := m.clearedFields[agent.FieldBackground]
  451. return ok
  452. }
  453. // ResetBackground resets all changes to the "background" field.
  454. func (m *AgentMutation) ResetBackground() {
  455. m.background = nil
  456. delete(m.clearedFields, agent.FieldBackground)
  457. }
  458. // SetExamples sets the "examples" field.
  459. func (m *AgentMutation) SetExamples(s string) {
  460. m.examples = &s
  461. }
  462. // Examples returns the value of the "examples" field in the mutation.
  463. func (m *AgentMutation) Examples() (r string, exists bool) {
  464. v := m.examples
  465. if v == nil {
  466. return
  467. }
  468. return *v, true
  469. }
  470. // OldExamples returns the old "examples" field's value of the Agent entity.
  471. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  473. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  474. if !m.op.Is(OpUpdateOne) {
  475. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  476. }
  477. if m.id == nil || m.oldValue == nil {
  478. return v, errors.New("OldExamples requires an ID field in the mutation")
  479. }
  480. oldValue, err := m.oldValue(ctx)
  481. if err != nil {
  482. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  483. }
  484. return oldValue.Examples, nil
  485. }
  486. // ClearExamples clears the value of the "examples" field.
  487. func (m *AgentMutation) ClearExamples() {
  488. m.examples = nil
  489. m.clearedFields[agent.FieldExamples] = struct{}{}
  490. }
  491. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  492. func (m *AgentMutation) ExamplesCleared() bool {
  493. _, ok := m.clearedFields[agent.FieldExamples]
  494. return ok
  495. }
  496. // ResetExamples resets all changes to the "examples" field.
  497. func (m *AgentMutation) ResetExamples() {
  498. m.examples = nil
  499. delete(m.clearedFields, agent.FieldExamples)
  500. }
  501. // SetOrganizationID sets the "organization_id" field.
  502. func (m *AgentMutation) SetOrganizationID(u uint64) {
  503. m.organization_id = &u
  504. m.addorganization_id = nil
  505. }
  506. // OrganizationID returns the value of the "organization_id" field in the mutation.
  507. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  508. v := m.organization_id
  509. if v == nil {
  510. return
  511. }
  512. return *v, true
  513. }
  514. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  515. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  516. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  517. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  518. if !m.op.Is(OpUpdateOne) {
  519. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  520. }
  521. if m.id == nil || m.oldValue == nil {
  522. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  523. }
  524. oldValue, err := m.oldValue(ctx)
  525. if err != nil {
  526. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  527. }
  528. return oldValue.OrganizationID, nil
  529. }
  530. // AddOrganizationID adds u to the "organization_id" field.
  531. func (m *AgentMutation) AddOrganizationID(u int64) {
  532. if m.addorganization_id != nil {
  533. *m.addorganization_id += u
  534. } else {
  535. m.addorganization_id = &u
  536. }
  537. }
  538. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  539. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  540. v := m.addorganization_id
  541. if v == nil {
  542. return
  543. }
  544. return *v, true
  545. }
  546. // ResetOrganizationID resets all changes to the "organization_id" field.
  547. func (m *AgentMutation) ResetOrganizationID() {
  548. m.organization_id = nil
  549. m.addorganization_id = nil
  550. }
  551. // SetDatasetID sets the "dataset_id" field.
  552. func (m *AgentMutation) SetDatasetID(s string) {
  553. m.dataset_id = &s
  554. }
  555. // DatasetID returns the value of the "dataset_id" field in the mutation.
  556. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  557. v := m.dataset_id
  558. if v == nil {
  559. return
  560. }
  561. return *v, true
  562. }
  563. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  564. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  566. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  567. if !m.op.Is(OpUpdateOne) {
  568. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  569. }
  570. if m.id == nil || m.oldValue == nil {
  571. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  572. }
  573. oldValue, err := m.oldValue(ctx)
  574. if err != nil {
  575. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  576. }
  577. return oldValue.DatasetID, nil
  578. }
  579. // ResetDatasetID resets all changes to the "dataset_id" field.
  580. func (m *AgentMutation) ResetDatasetID() {
  581. m.dataset_id = nil
  582. }
  583. // SetCollectionID sets the "collection_id" field.
  584. func (m *AgentMutation) SetCollectionID(s string) {
  585. m.collection_id = &s
  586. }
  587. // CollectionID returns the value of the "collection_id" field in the mutation.
  588. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  589. v := m.collection_id
  590. if v == nil {
  591. return
  592. }
  593. return *v, true
  594. }
  595. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  596. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  598. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  599. if !m.op.Is(OpUpdateOne) {
  600. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  601. }
  602. if m.id == nil || m.oldValue == nil {
  603. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  604. }
  605. oldValue, err := m.oldValue(ctx)
  606. if err != nil {
  607. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  608. }
  609. return oldValue.CollectionID, nil
  610. }
  611. // ResetCollectionID resets all changes to the "collection_id" field.
  612. func (m *AgentMutation) ResetCollectionID() {
  613. m.collection_id = nil
  614. }
  615. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  616. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  617. if m.wx_agent == nil {
  618. m.wx_agent = make(map[uint64]struct{})
  619. }
  620. for i := range ids {
  621. m.wx_agent[ids[i]] = struct{}{}
  622. }
  623. }
  624. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  625. func (m *AgentMutation) ClearWxAgent() {
  626. m.clearedwx_agent = true
  627. }
  628. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  629. func (m *AgentMutation) WxAgentCleared() bool {
  630. return m.clearedwx_agent
  631. }
  632. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  633. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  634. if m.removedwx_agent == nil {
  635. m.removedwx_agent = make(map[uint64]struct{})
  636. }
  637. for i := range ids {
  638. delete(m.wx_agent, ids[i])
  639. m.removedwx_agent[ids[i]] = struct{}{}
  640. }
  641. }
  642. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  643. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  644. for id := range m.removedwx_agent {
  645. ids = append(ids, id)
  646. }
  647. return
  648. }
  649. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  650. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  651. for id := range m.wx_agent {
  652. ids = append(ids, id)
  653. }
  654. return
  655. }
  656. // ResetWxAgent resets all changes to the "wx_agent" edge.
  657. func (m *AgentMutation) ResetWxAgent() {
  658. m.wx_agent = nil
  659. m.clearedwx_agent = false
  660. m.removedwx_agent = nil
  661. }
  662. // Where appends a list predicates to the AgentMutation builder.
  663. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  664. m.predicates = append(m.predicates, ps...)
  665. }
  666. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  667. // users can use type-assertion to append predicates that do not depend on any generated package.
  668. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  669. p := make([]predicate.Agent, len(ps))
  670. for i := range ps {
  671. p[i] = ps[i]
  672. }
  673. m.Where(p...)
  674. }
  675. // Op returns the operation name.
  676. func (m *AgentMutation) Op() Op {
  677. return m.op
  678. }
  679. // SetOp allows setting the mutation operation.
  680. func (m *AgentMutation) SetOp(op Op) {
  681. m.op = op
  682. }
  683. // Type returns the node type of this mutation (Agent).
  684. func (m *AgentMutation) Type() string {
  685. return m.typ
  686. }
  687. // Fields returns all fields that were changed during this mutation. Note that in
  688. // order to get all numeric fields that were incremented/decremented, call
  689. // AddedFields().
  690. func (m *AgentMutation) Fields() []string {
  691. fields := make([]string, 0, 11)
  692. if m.created_at != nil {
  693. fields = append(fields, agent.FieldCreatedAt)
  694. }
  695. if m.updated_at != nil {
  696. fields = append(fields, agent.FieldUpdatedAt)
  697. }
  698. if m.deleted_at != nil {
  699. fields = append(fields, agent.FieldDeletedAt)
  700. }
  701. if m.name != nil {
  702. fields = append(fields, agent.FieldName)
  703. }
  704. if m.role != nil {
  705. fields = append(fields, agent.FieldRole)
  706. }
  707. if m.status != nil {
  708. fields = append(fields, agent.FieldStatus)
  709. }
  710. if m.background != nil {
  711. fields = append(fields, agent.FieldBackground)
  712. }
  713. if m.examples != nil {
  714. fields = append(fields, agent.FieldExamples)
  715. }
  716. if m.organization_id != nil {
  717. fields = append(fields, agent.FieldOrganizationID)
  718. }
  719. if m.dataset_id != nil {
  720. fields = append(fields, agent.FieldDatasetID)
  721. }
  722. if m.collection_id != nil {
  723. fields = append(fields, agent.FieldCollectionID)
  724. }
  725. return fields
  726. }
  727. // Field returns the value of a field with the given name. The second boolean
  728. // return value indicates that this field was not set, or was not defined in the
  729. // schema.
  730. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  731. switch name {
  732. case agent.FieldCreatedAt:
  733. return m.CreatedAt()
  734. case agent.FieldUpdatedAt:
  735. return m.UpdatedAt()
  736. case agent.FieldDeletedAt:
  737. return m.DeletedAt()
  738. case agent.FieldName:
  739. return m.Name()
  740. case agent.FieldRole:
  741. return m.Role()
  742. case agent.FieldStatus:
  743. return m.Status()
  744. case agent.FieldBackground:
  745. return m.Background()
  746. case agent.FieldExamples:
  747. return m.Examples()
  748. case agent.FieldOrganizationID:
  749. return m.OrganizationID()
  750. case agent.FieldDatasetID:
  751. return m.DatasetID()
  752. case agent.FieldCollectionID:
  753. return m.CollectionID()
  754. }
  755. return nil, false
  756. }
  757. // OldField returns the old value of the field from the database. An error is
  758. // returned if the mutation operation is not UpdateOne, or the query to the
  759. // database failed.
  760. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  761. switch name {
  762. case agent.FieldCreatedAt:
  763. return m.OldCreatedAt(ctx)
  764. case agent.FieldUpdatedAt:
  765. return m.OldUpdatedAt(ctx)
  766. case agent.FieldDeletedAt:
  767. return m.OldDeletedAt(ctx)
  768. case agent.FieldName:
  769. return m.OldName(ctx)
  770. case agent.FieldRole:
  771. return m.OldRole(ctx)
  772. case agent.FieldStatus:
  773. return m.OldStatus(ctx)
  774. case agent.FieldBackground:
  775. return m.OldBackground(ctx)
  776. case agent.FieldExamples:
  777. return m.OldExamples(ctx)
  778. case agent.FieldOrganizationID:
  779. return m.OldOrganizationID(ctx)
  780. case agent.FieldDatasetID:
  781. return m.OldDatasetID(ctx)
  782. case agent.FieldCollectionID:
  783. return m.OldCollectionID(ctx)
  784. }
  785. return nil, fmt.Errorf("unknown Agent field %s", name)
  786. }
  787. // SetField sets the value of a field with the given name. It returns an error if
  788. // the field is not defined in the schema, or if the type mismatched the field
  789. // type.
  790. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  791. switch name {
  792. case agent.FieldCreatedAt:
  793. v, ok := value.(time.Time)
  794. if !ok {
  795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  796. }
  797. m.SetCreatedAt(v)
  798. return nil
  799. case agent.FieldUpdatedAt:
  800. v, ok := value.(time.Time)
  801. if !ok {
  802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  803. }
  804. m.SetUpdatedAt(v)
  805. return nil
  806. case agent.FieldDeletedAt:
  807. v, ok := value.(time.Time)
  808. if !ok {
  809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  810. }
  811. m.SetDeletedAt(v)
  812. return nil
  813. case agent.FieldName:
  814. v, ok := value.(string)
  815. if !ok {
  816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  817. }
  818. m.SetName(v)
  819. return nil
  820. case agent.FieldRole:
  821. v, ok := value.(string)
  822. if !ok {
  823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  824. }
  825. m.SetRole(v)
  826. return nil
  827. case agent.FieldStatus:
  828. v, ok := value.(int)
  829. if !ok {
  830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  831. }
  832. m.SetStatus(v)
  833. return nil
  834. case agent.FieldBackground:
  835. v, ok := value.(string)
  836. if !ok {
  837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  838. }
  839. m.SetBackground(v)
  840. return nil
  841. case agent.FieldExamples:
  842. v, ok := value.(string)
  843. if !ok {
  844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  845. }
  846. m.SetExamples(v)
  847. return nil
  848. case agent.FieldOrganizationID:
  849. v, ok := value.(uint64)
  850. if !ok {
  851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  852. }
  853. m.SetOrganizationID(v)
  854. return nil
  855. case agent.FieldDatasetID:
  856. v, ok := value.(string)
  857. if !ok {
  858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  859. }
  860. m.SetDatasetID(v)
  861. return nil
  862. case agent.FieldCollectionID:
  863. v, ok := value.(string)
  864. if !ok {
  865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  866. }
  867. m.SetCollectionID(v)
  868. return nil
  869. }
  870. return fmt.Errorf("unknown Agent field %s", name)
  871. }
  872. // AddedFields returns all numeric fields that were incremented/decremented during
  873. // this mutation.
  874. func (m *AgentMutation) AddedFields() []string {
  875. var fields []string
  876. if m.addstatus != nil {
  877. fields = append(fields, agent.FieldStatus)
  878. }
  879. if m.addorganization_id != nil {
  880. fields = append(fields, agent.FieldOrganizationID)
  881. }
  882. return fields
  883. }
  884. // AddedField returns the numeric value that was incremented/decremented on a field
  885. // with the given name. The second boolean return value indicates that this field
  886. // was not set, or was not defined in the schema.
  887. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  888. switch name {
  889. case agent.FieldStatus:
  890. return m.AddedStatus()
  891. case agent.FieldOrganizationID:
  892. return m.AddedOrganizationID()
  893. }
  894. return nil, false
  895. }
  896. // AddField adds the value to the field with the given name. It returns an error if
  897. // the field is not defined in the schema, or if the type mismatched the field
  898. // type.
  899. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  900. switch name {
  901. case agent.FieldStatus:
  902. v, ok := value.(int)
  903. if !ok {
  904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  905. }
  906. m.AddStatus(v)
  907. return nil
  908. case agent.FieldOrganizationID:
  909. v, ok := value.(int64)
  910. if !ok {
  911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  912. }
  913. m.AddOrganizationID(v)
  914. return nil
  915. }
  916. return fmt.Errorf("unknown Agent numeric field %s", name)
  917. }
  918. // ClearedFields returns all nullable fields that were cleared during this
  919. // mutation.
  920. func (m *AgentMutation) ClearedFields() []string {
  921. var fields []string
  922. if m.FieldCleared(agent.FieldDeletedAt) {
  923. fields = append(fields, agent.FieldDeletedAt)
  924. }
  925. if m.FieldCleared(agent.FieldStatus) {
  926. fields = append(fields, agent.FieldStatus)
  927. }
  928. if m.FieldCleared(agent.FieldBackground) {
  929. fields = append(fields, agent.FieldBackground)
  930. }
  931. if m.FieldCleared(agent.FieldExamples) {
  932. fields = append(fields, agent.FieldExamples)
  933. }
  934. return fields
  935. }
  936. // FieldCleared returns a boolean indicating if a field with the given name was
  937. // cleared in this mutation.
  938. func (m *AgentMutation) FieldCleared(name string) bool {
  939. _, ok := m.clearedFields[name]
  940. return ok
  941. }
  942. // ClearField clears the value of the field with the given name. It returns an
  943. // error if the field is not defined in the schema.
  944. func (m *AgentMutation) ClearField(name string) error {
  945. switch name {
  946. case agent.FieldDeletedAt:
  947. m.ClearDeletedAt()
  948. return nil
  949. case agent.FieldStatus:
  950. m.ClearStatus()
  951. return nil
  952. case agent.FieldBackground:
  953. m.ClearBackground()
  954. return nil
  955. case agent.FieldExamples:
  956. m.ClearExamples()
  957. return nil
  958. }
  959. return fmt.Errorf("unknown Agent nullable field %s", name)
  960. }
  961. // ResetField resets all changes in the mutation for the field with the given name.
  962. // It returns an error if the field is not defined in the schema.
  963. func (m *AgentMutation) ResetField(name string) error {
  964. switch name {
  965. case agent.FieldCreatedAt:
  966. m.ResetCreatedAt()
  967. return nil
  968. case agent.FieldUpdatedAt:
  969. m.ResetUpdatedAt()
  970. return nil
  971. case agent.FieldDeletedAt:
  972. m.ResetDeletedAt()
  973. return nil
  974. case agent.FieldName:
  975. m.ResetName()
  976. return nil
  977. case agent.FieldRole:
  978. m.ResetRole()
  979. return nil
  980. case agent.FieldStatus:
  981. m.ResetStatus()
  982. return nil
  983. case agent.FieldBackground:
  984. m.ResetBackground()
  985. return nil
  986. case agent.FieldExamples:
  987. m.ResetExamples()
  988. return nil
  989. case agent.FieldOrganizationID:
  990. m.ResetOrganizationID()
  991. return nil
  992. case agent.FieldDatasetID:
  993. m.ResetDatasetID()
  994. return nil
  995. case agent.FieldCollectionID:
  996. m.ResetCollectionID()
  997. return nil
  998. }
  999. return fmt.Errorf("unknown Agent field %s", name)
  1000. }
  1001. // AddedEdges returns all edge names that were set/added in this mutation.
  1002. func (m *AgentMutation) AddedEdges() []string {
  1003. edges := make([]string, 0, 1)
  1004. if m.wx_agent != nil {
  1005. edges = append(edges, agent.EdgeWxAgent)
  1006. }
  1007. return edges
  1008. }
  1009. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1010. // name in this mutation.
  1011. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1012. switch name {
  1013. case agent.EdgeWxAgent:
  1014. ids := make([]ent.Value, 0, len(m.wx_agent))
  1015. for id := range m.wx_agent {
  1016. ids = append(ids, id)
  1017. }
  1018. return ids
  1019. }
  1020. return nil
  1021. }
  1022. // RemovedEdges returns all edge names that were removed in this mutation.
  1023. func (m *AgentMutation) RemovedEdges() []string {
  1024. edges := make([]string, 0, 1)
  1025. if m.removedwx_agent != nil {
  1026. edges = append(edges, agent.EdgeWxAgent)
  1027. }
  1028. return edges
  1029. }
  1030. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1031. // the given name in this mutation.
  1032. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1033. switch name {
  1034. case agent.EdgeWxAgent:
  1035. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1036. for id := range m.removedwx_agent {
  1037. ids = append(ids, id)
  1038. }
  1039. return ids
  1040. }
  1041. return nil
  1042. }
  1043. // ClearedEdges returns all edge names that were cleared in this mutation.
  1044. func (m *AgentMutation) ClearedEdges() []string {
  1045. edges := make([]string, 0, 1)
  1046. if m.clearedwx_agent {
  1047. edges = append(edges, agent.EdgeWxAgent)
  1048. }
  1049. return edges
  1050. }
  1051. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1052. // was cleared in this mutation.
  1053. func (m *AgentMutation) EdgeCleared(name string) bool {
  1054. switch name {
  1055. case agent.EdgeWxAgent:
  1056. return m.clearedwx_agent
  1057. }
  1058. return false
  1059. }
  1060. // ClearEdge clears the value of the edge with the given name. It returns an error
  1061. // if that edge is not defined in the schema.
  1062. func (m *AgentMutation) ClearEdge(name string) error {
  1063. switch name {
  1064. }
  1065. return fmt.Errorf("unknown Agent unique edge %s", name)
  1066. }
  1067. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1068. // It returns an error if the edge is not defined in the schema.
  1069. func (m *AgentMutation) ResetEdge(name string) error {
  1070. switch name {
  1071. case agent.EdgeWxAgent:
  1072. m.ResetWxAgent()
  1073. return nil
  1074. }
  1075. return fmt.Errorf("unknown Agent edge %s", name)
  1076. }
  1077. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  1078. type BatchMsgMutation struct {
  1079. config
  1080. op Op
  1081. typ string
  1082. id *uint64
  1083. created_at *time.Time
  1084. updated_at *time.Time
  1085. deleted_at *time.Time
  1086. status *uint8
  1087. addstatus *int8
  1088. batch_no *string
  1089. task_name *string
  1090. fromwxid *string
  1091. msg *string
  1092. tag *string
  1093. total *int32
  1094. addtotal *int32
  1095. success *int32
  1096. addsuccess *int32
  1097. fail *int32
  1098. addfail *int32
  1099. start_time *time.Time
  1100. stop_time *time.Time
  1101. _type *int32
  1102. add_type *int32
  1103. organization_id *uint64
  1104. addorganization_id *int64
  1105. clearedFields map[string]struct{}
  1106. done bool
  1107. oldValue func(context.Context) (*BatchMsg, error)
  1108. predicates []predicate.BatchMsg
  1109. }
  1110. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  1111. // batchmsgOption allows management of the mutation configuration using functional options.
  1112. type batchmsgOption func(*BatchMsgMutation)
  1113. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  1114. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  1115. m := &BatchMsgMutation{
  1116. config: c,
  1117. op: op,
  1118. typ: TypeBatchMsg,
  1119. clearedFields: make(map[string]struct{}),
  1120. }
  1121. for _, opt := range opts {
  1122. opt(m)
  1123. }
  1124. return m
  1125. }
  1126. // withBatchMsgID sets the ID field of the mutation.
  1127. func withBatchMsgID(id uint64) batchmsgOption {
  1128. return func(m *BatchMsgMutation) {
  1129. var (
  1130. err error
  1131. once sync.Once
  1132. value *BatchMsg
  1133. )
  1134. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  1135. once.Do(func() {
  1136. if m.done {
  1137. err = errors.New("querying old values post mutation is not allowed")
  1138. } else {
  1139. value, err = m.Client().BatchMsg.Get(ctx, id)
  1140. }
  1141. })
  1142. return value, err
  1143. }
  1144. m.id = &id
  1145. }
  1146. }
  1147. // withBatchMsg sets the old BatchMsg of the mutation.
  1148. func withBatchMsg(node *BatchMsg) batchmsgOption {
  1149. return func(m *BatchMsgMutation) {
  1150. m.oldValue = func(context.Context) (*BatchMsg, error) {
  1151. return node, nil
  1152. }
  1153. m.id = &node.ID
  1154. }
  1155. }
  1156. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1157. // executed in a transaction (ent.Tx), a transactional client is returned.
  1158. func (m BatchMsgMutation) Client() *Client {
  1159. client := &Client{config: m.config}
  1160. client.init()
  1161. return client
  1162. }
  1163. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1164. // it returns an error otherwise.
  1165. func (m BatchMsgMutation) Tx() (*Tx, error) {
  1166. if _, ok := m.driver.(*txDriver); !ok {
  1167. return nil, errors.New("ent: mutation is not running in a transaction")
  1168. }
  1169. tx := &Tx{config: m.config}
  1170. tx.init()
  1171. return tx, nil
  1172. }
  1173. // SetID sets the value of the id field. Note that this
  1174. // operation is only accepted on creation of BatchMsg entities.
  1175. func (m *BatchMsgMutation) SetID(id uint64) {
  1176. m.id = &id
  1177. }
  1178. // ID returns the ID value in the mutation. Note that the ID is only available
  1179. // if it was provided to the builder or after it was returned from the database.
  1180. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  1181. if m.id == nil {
  1182. return
  1183. }
  1184. return *m.id, true
  1185. }
  1186. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1187. // That means, if the mutation is applied within a transaction with an isolation level such
  1188. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1189. // or updated by the mutation.
  1190. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  1191. switch {
  1192. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1193. id, exists := m.ID()
  1194. if exists {
  1195. return []uint64{id}, nil
  1196. }
  1197. fallthrough
  1198. case m.op.Is(OpUpdate | OpDelete):
  1199. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  1200. default:
  1201. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1202. }
  1203. }
  1204. // SetCreatedAt sets the "created_at" field.
  1205. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  1206. m.created_at = &t
  1207. }
  1208. // CreatedAt returns the value of the "created_at" field in the mutation.
  1209. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  1210. v := m.created_at
  1211. if v == nil {
  1212. return
  1213. }
  1214. return *v, true
  1215. }
  1216. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  1217. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1219. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  1220. if !m.op.Is(OpUpdateOne) {
  1221. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  1222. }
  1223. if m.id == nil || m.oldValue == nil {
  1224. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  1225. }
  1226. oldValue, err := m.oldValue(ctx)
  1227. if err != nil {
  1228. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  1229. }
  1230. return oldValue.CreatedAt, nil
  1231. }
  1232. // ResetCreatedAt resets all changes to the "created_at" field.
  1233. func (m *BatchMsgMutation) ResetCreatedAt() {
  1234. m.created_at = nil
  1235. }
  1236. // SetUpdatedAt sets the "updated_at" field.
  1237. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  1238. m.updated_at = &t
  1239. }
  1240. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  1241. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  1242. v := m.updated_at
  1243. if v == nil {
  1244. return
  1245. }
  1246. return *v, true
  1247. }
  1248. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  1249. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1251. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  1252. if !m.op.Is(OpUpdateOne) {
  1253. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  1254. }
  1255. if m.id == nil || m.oldValue == nil {
  1256. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  1257. }
  1258. oldValue, err := m.oldValue(ctx)
  1259. if err != nil {
  1260. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  1261. }
  1262. return oldValue.UpdatedAt, nil
  1263. }
  1264. // ResetUpdatedAt resets all changes to the "updated_at" field.
  1265. func (m *BatchMsgMutation) ResetUpdatedAt() {
  1266. m.updated_at = nil
  1267. }
  1268. // SetDeletedAt sets the "deleted_at" field.
  1269. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  1270. m.deleted_at = &t
  1271. }
  1272. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  1273. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  1274. v := m.deleted_at
  1275. if v == nil {
  1276. return
  1277. }
  1278. return *v, true
  1279. }
  1280. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  1281. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1282. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1283. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  1284. if !m.op.Is(OpUpdateOne) {
  1285. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  1286. }
  1287. if m.id == nil || m.oldValue == nil {
  1288. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  1289. }
  1290. oldValue, err := m.oldValue(ctx)
  1291. if err != nil {
  1292. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  1293. }
  1294. return oldValue.DeletedAt, nil
  1295. }
  1296. // ClearDeletedAt clears the value of the "deleted_at" field.
  1297. func (m *BatchMsgMutation) ClearDeletedAt() {
  1298. m.deleted_at = nil
  1299. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  1300. }
  1301. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  1302. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  1303. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  1304. return ok
  1305. }
  1306. // ResetDeletedAt resets all changes to the "deleted_at" field.
  1307. func (m *BatchMsgMutation) ResetDeletedAt() {
  1308. m.deleted_at = nil
  1309. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  1310. }
  1311. // SetStatus sets the "status" field.
  1312. func (m *BatchMsgMutation) SetStatus(u uint8) {
  1313. m.status = &u
  1314. m.addstatus = nil
  1315. }
  1316. // Status returns the value of the "status" field in the mutation.
  1317. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  1318. v := m.status
  1319. if v == nil {
  1320. return
  1321. }
  1322. return *v, true
  1323. }
  1324. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  1325. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1327. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  1328. if !m.op.Is(OpUpdateOne) {
  1329. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  1330. }
  1331. if m.id == nil || m.oldValue == nil {
  1332. return v, errors.New("OldStatus requires an ID field in the mutation")
  1333. }
  1334. oldValue, err := m.oldValue(ctx)
  1335. if err != nil {
  1336. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  1337. }
  1338. return oldValue.Status, nil
  1339. }
  1340. // AddStatus adds u to the "status" field.
  1341. func (m *BatchMsgMutation) AddStatus(u int8) {
  1342. if m.addstatus != nil {
  1343. *m.addstatus += u
  1344. } else {
  1345. m.addstatus = &u
  1346. }
  1347. }
  1348. // AddedStatus returns the value that was added to the "status" field in this mutation.
  1349. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  1350. v := m.addstatus
  1351. if v == nil {
  1352. return
  1353. }
  1354. return *v, true
  1355. }
  1356. // ClearStatus clears the value of the "status" field.
  1357. func (m *BatchMsgMutation) ClearStatus() {
  1358. m.status = nil
  1359. m.addstatus = nil
  1360. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  1361. }
  1362. // StatusCleared returns if the "status" field was cleared in this mutation.
  1363. func (m *BatchMsgMutation) StatusCleared() bool {
  1364. _, ok := m.clearedFields[batchmsg.FieldStatus]
  1365. return ok
  1366. }
  1367. // ResetStatus resets all changes to the "status" field.
  1368. func (m *BatchMsgMutation) ResetStatus() {
  1369. m.status = nil
  1370. m.addstatus = nil
  1371. delete(m.clearedFields, batchmsg.FieldStatus)
  1372. }
  1373. // SetBatchNo sets the "batch_no" field.
  1374. func (m *BatchMsgMutation) SetBatchNo(s string) {
  1375. m.batch_no = &s
  1376. }
  1377. // BatchNo returns the value of the "batch_no" field in the mutation.
  1378. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  1379. v := m.batch_no
  1380. if v == nil {
  1381. return
  1382. }
  1383. return *v, true
  1384. }
  1385. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  1386. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1388. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  1389. if !m.op.Is(OpUpdateOne) {
  1390. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  1391. }
  1392. if m.id == nil || m.oldValue == nil {
  1393. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  1394. }
  1395. oldValue, err := m.oldValue(ctx)
  1396. if err != nil {
  1397. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  1398. }
  1399. return oldValue.BatchNo, nil
  1400. }
  1401. // ClearBatchNo clears the value of the "batch_no" field.
  1402. func (m *BatchMsgMutation) ClearBatchNo() {
  1403. m.batch_no = nil
  1404. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  1405. }
  1406. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  1407. func (m *BatchMsgMutation) BatchNoCleared() bool {
  1408. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  1409. return ok
  1410. }
  1411. // ResetBatchNo resets all changes to the "batch_no" field.
  1412. func (m *BatchMsgMutation) ResetBatchNo() {
  1413. m.batch_no = nil
  1414. delete(m.clearedFields, batchmsg.FieldBatchNo)
  1415. }
  1416. // SetTaskName sets the "task_name" field.
  1417. func (m *BatchMsgMutation) SetTaskName(s string) {
  1418. m.task_name = &s
  1419. }
  1420. // TaskName returns the value of the "task_name" field in the mutation.
  1421. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  1422. v := m.task_name
  1423. if v == nil {
  1424. return
  1425. }
  1426. return *v, true
  1427. }
  1428. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  1429. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1430. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1431. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  1432. if !m.op.Is(OpUpdateOne) {
  1433. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  1434. }
  1435. if m.id == nil || m.oldValue == nil {
  1436. return v, errors.New("OldTaskName requires an ID field in the mutation")
  1437. }
  1438. oldValue, err := m.oldValue(ctx)
  1439. if err != nil {
  1440. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  1441. }
  1442. return oldValue.TaskName, nil
  1443. }
  1444. // ClearTaskName clears the value of the "task_name" field.
  1445. func (m *BatchMsgMutation) ClearTaskName() {
  1446. m.task_name = nil
  1447. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  1448. }
  1449. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  1450. func (m *BatchMsgMutation) TaskNameCleared() bool {
  1451. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  1452. return ok
  1453. }
  1454. // ResetTaskName resets all changes to the "task_name" field.
  1455. func (m *BatchMsgMutation) ResetTaskName() {
  1456. m.task_name = nil
  1457. delete(m.clearedFields, batchmsg.FieldTaskName)
  1458. }
  1459. // SetFromwxid sets the "fromwxid" field.
  1460. func (m *BatchMsgMutation) SetFromwxid(s string) {
  1461. m.fromwxid = &s
  1462. }
  1463. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  1464. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  1465. v := m.fromwxid
  1466. if v == nil {
  1467. return
  1468. }
  1469. return *v, true
  1470. }
  1471. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  1472. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1474. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  1475. if !m.op.Is(OpUpdateOne) {
  1476. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  1477. }
  1478. if m.id == nil || m.oldValue == nil {
  1479. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  1480. }
  1481. oldValue, err := m.oldValue(ctx)
  1482. if err != nil {
  1483. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  1484. }
  1485. return oldValue.Fromwxid, nil
  1486. }
  1487. // ClearFromwxid clears the value of the "fromwxid" field.
  1488. func (m *BatchMsgMutation) ClearFromwxid() {
  1489. m.fromwxid = nil
  1490. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  1491. }
  1492. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  1493. func (m *BatchMsgMutation) FromwxidCleared() bool {
  1494. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  1495. return ok
  1496. }
  1497. // ResetFromwxid resets all changes to the "fromwxid" field.
  1498. func (m *BatchMsgMutation) ResetFromwxid() {
  1499. m.fromwxid = nil
  1500. delete(m.clearedFields, batchmsg.FieldFromwxid)
  1501. }
  1502. // SetMsg sets the "msg" field.
  1503. func (m *BatchMsgMutation) SetMsg(s string) {
  1504. m.msg = &s
  1505. }
  1506. // Msg returns the value of the "msg" field in the mutation.
  1507. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  1508. v := m.msg
  1509. if v == nil {
  1510. return
  1511. }
  1512. return *v, true
  1513. }
  1514. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  1515. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1516. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1517. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  1518. if !m.op.Is(OpUpdateOne) {
  1519. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  1520. }
  1521. if m.id == nil || m.oldValue == nil {
  1522. return v, errors.New("OldMsg requires an ID field in the mutation")
  1523. }
  1524. oldValue, err := m.oldValue(ctx)
  1525. if err != nil {
  1526. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  1527. }
  1528. return oldValue.Msg, nil
  1529. }
  1530. // ClearMsg clears the value of the "msg" field.
  1531. func (m *BatchMsgMutation) ClearMsg() {
  1532. m.msg = nil
  1533. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  1534. }
  1535. // MsgCleared returns if the "msg" field was cleared in this mutation.
  1536. func (m *BatchMsgMutation) MsgCleared() bool {
  1537. _, ok := m.clearedFields[batchmsg.FieldMsg]
  1538. return ok
  1539. }
  1540. // ResetMsg resets all changes to the "msg" field.
  1541. func (m *BatchMsgMutation) ResetMsg() {
  1542. m.msg = nil
  1543. delete(m.clearedFields, batchmsg.FieldMsg)
  1544. }
  1545. // SetTag sets the "tag" field.
  1546. func (m *BatchMsgMutation) SetTag(s string) {
  1547. m.tag = &s
  1548. }
  1549. // Tag returns the value of the "tag" field in the mutation.
  1550. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  1551. v := m.tag
  1552. if v == nil {
  1553. return
  1554. }
  1555. return *v, true
  1556. }
  1557. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  1558. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1560. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  1561. if !m.op.Is(OpUpdateOne) {
  1562. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  1563. }
  1564. if m.id == nil || m.oldValue == nil {
  1565. return v, errors.New("OldTag requires an ID field in the mutation")
  1566. }
  1567. oldValue, err := m.oldValue(ctx)
  1568. if err != nil {
  1569. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  1570. }
  1571. return oldValue.Tag, nil
  1572. }
  1573. // ClearTag clears the value of the "tag" field.
  1574. func (m *BatchMsgMutation) ClearTag() {
  1575. m.tag = nil
  1576. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  1577. }
  1578. // TagCleared returns if the "tag" field was cleared in this mutation.
  1579. func (m *BatchMsgMutation) TagCleared() bool {
  1580. _, ok := m.clearedFields[batchmsg.FieldTag]
  1581. return ok
  1582. }
  1583. // ResetTag resets all changes to the "tag" field.
  1584. func (m *BatchMsgMutation) ResetTag() {
  1585. m.tag = nil
  1586. delete(m.clearedFields, batchmsg.FieldTag)
  1587. }
  1588. // SetTotal sets the "total" field.
  1589. func (m *BatchMsgMutation) SetTotal(i int32) {
  1590. m.total = &i
  1591. m.addtotal = nil
  1592. }
  1593. // Total returns the value of the "total" field in the mutation.
  1594. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  1595. v := m.total
  1596. if v == nil {
  1597. return
  1598. }
  1599. return *v, true
  1600. }
  1601. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  1602. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1604. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  1605. if !m.op.Is(OpUpdateOne) {
  1606. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  1607. }
  1608. if m.id == nil || m.oldValue == nil {
  1609. return v, errors.New("OldTotal requires an ID field in the mutation")
  1610. }
  1611. oldValue, err := m.oldValue(ctx)
  1612. if err != nil {
  1613. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  1614. }
  1615. return oldValue.Total, nil
  1616. }
  1617. // AddTotal adds i to the "total" field.
  1618. func (m *BatchMsgMutation) AddTotal(i int32) {
  1619. if m.addtotal != nil {
  1620. *m.addtotal += i
  1621. } else {
  1622. m.addtotal = &i
  1623. }
  1624. }
  1625. // AddedTotal returns the value that was added to the "total" field in this mutation.
  1626. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  1627. v := m.addtotal
  1628. if v == nil {
  1629. return
  1630. }
  1631. return *v, true
  1632. }
  1633. // ClearTotal clears the value of the "total" field.
  1634. func (m *BatchMsgMutation) ClearTotal() {
  1635. m.total = nil
  1636. m.addtotal = nil
  1637. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  1638. }
  1639. // TotalCleared returns if the "total" field was cleared in this mutation.
  1640. func (m *BatchMsgMutation) TotalCleared() bool {
  1641. _, ok := m.clearedFields[batchmsg.FieldTotal]
  1642. return ok
  1643. }
  1644. // ResetTotal resets all changes to the "total" field.
  1645. func (m *BatchMsgMutation) ResetTotal() {
  1646. m.total = nil
  1647. m.addtotal = nil
  1648. delete(m.clearedFields, batchmsg.FieldTotal)
  1649. }
  1650. // SetSuccess sets the "success" field.
  1651. func (m *BatchMsgMutation) SetSuccess(i int32) {
  1652. m.success = &i
  1653. m.addsuccess = nil
  1654. }
  1655. // Success returns the value of the "success" field in the mutation.
  1656. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  1657. v := m.success
  1658. if v == nil {
  1659. return
  1660. }
  1661. return *v, true
  1662. }
  1663. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  1664. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1666. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  1667. if !m.op.Is(OpUpdateOne) {
  1668. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  1669. }
  1670. if m.id == nil || m.oldValue == nil {
  1671. return v, errors.New("OldSuccess requires an ID field in the mutation")
  1672. }
  1673. oldValue, err := m.oldValue(ctx)
  1674. if err != nil {
  1675. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  1676. }
  1677. return oldValue.Success, nil
  1678. }
  1679. // AddSuccess adds i to the "success" field.
  1680. func (m *BatchMsgMutation) AddSuccess(i int32) {
  1681. if m.addsuccess != nil {
  1682. *m.addsuccess += i
  1683. } else {
  1684. m.addsuccess = &i
  1685. }
  1686. }
  1687. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  1688. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  1689. v := m.addsuccess
  1690. if v == nil {
  1691. return
  1692. }
  1693. return *v, true
  1694. }
  1695. // ClearSuccess clears the value of the "success" field.
  1696. func (m *BatchMsgMutation) ClearSuccess() {
  1697. m.success = nil
  1698. m.addsuccess = nil
  1699. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  1700. }
  1701. // SuccessCleared returns if the "success" field was cleared in this mutation.
  1702. func (m *BatchMsgMutation) SuccessCleared() bool {
  1703. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  1704. return ok
  1705. }
  1706. // ResetSuccess resets all changes to the "success" field.
  1707. func (m *BatchMsgMutation) ResetSuccess() {
  1708. m.success = nil
  1709. m.addsuccess = nil
  1710. delete(m.clearedFields, batchmsg.FieldSuccess)
  1711. }
  1712. // SetFail sets the "fail" field.
  1713. func (m *BatchMsgMutation) SetFail(i int32) {
  1714. m.fail = &i
  1715. m.addfail = nil
  1716. }
  1717. // Fail returns the value of the "fail" field in the mutation.
  1718. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  1719. v := m.fail
  1720. if v == nil {
  1721. return
  1722. }
  1723. return *v, true
  1724. }
  1725. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  1726. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1728. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  1729. if !m.op.Is(OpUpdateOne) {
  1730. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  1731. }
  1732. if m.id == nil || m.oldValue == nil {
  1733. return v, errors.New("OldFail requires an ID field in the mutation")
  1734. }
  1735. oldValue, err := m.oldValue(ctx)
  1736. if err != nil {
  1737. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  1738. }
  1739. return oldValue.Fail, nil
  1740. }
  1741. // AddFail adds i to the "fail" field.
  1742. func (m *BatchMsgMutation) AddFail(i int32) {
  1743. if m.addfail != nil {
  1744. *m.addfail += i
  1745. } else {
  1746. m.addfail = &i
  1747. }
  1748. }
  1749. // AddedFail returns the value that was added to the "fail" field in this mutation.
  1750. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  1751. v := m.addfail
  1752. if v == nil {
  1753. return
  1754. }
  1755. return *v, true
  1756. }
  1757. // ClearFail clears the value of the "fail" field.
  1758. func (m *BatchMsgMutation) ClearFail() {
  1759. m.fail = nil
  1760. m.addfail = nil
  1761. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  1762. }
  1763. // FailCleared returns if the "fail" field was cleared in this mutation.
  1764. func (m *BatchMsgMutation) FailCleared() bool {
  1765. _, ok := m.clearedFields[batchmsg.FieldFail]
  1766. return ok
  1767. }
  1768. // ResetFail resets all changes to the "fail" field.
  1769. func (m *BatchMsgMutation) ResetFail() {
  1770. m.fail = nil
  1771. m.addfail = nil
  1772. delete(m.clearedFields, batchmsg.FieldFail)
  1773. }
  1774. // SetStartTime sets the "start_time" field.
  1775. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  1776. m.start_time = &t
  1777. }
  1778. // StartTime returns the value of the "start_time" field in the mutation.
  1779. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  1780. v := m.start_time
  1781. if v == nil {
  1782. return
  1783. }
  1784. return *v, true
  1785. }
  1786. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  1787. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1789. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  1790. if !m.op.Is(OpUpdateOne) {
  1791. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  1792. }
  1793. if m.id == nil || m.oldValue == nil {
  1794. return v, errors.New("OldStartTime requires an ID field in the mutation")
  1795. }
  1796. oldValue, err := m.oldValue(ctx)
  1797. if err != nil {
  1798. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  1799. }
  1800. return oldValue.StartTime, nil
  1801. }
  1802. // ClearStartTime clears the value of the "start_time" field.
  1803. func (m *BatchMsgMutation) ClearStartTime() {
  1804. m.start_time = nil
  1805. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  1806. }
  1807. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  1808. func (m *BatchMsgMutation) StartTimeCleared() bool {
  1809. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  1810. return ok
  1811. }
  1812. // ResetStartTime resets all changes to the "start_time" field.
  1813. func (m *BatchMsgMutation) ResetStartTime() {
  1814. m.start_time = nil
  1815. delete(m.clearedFields, batchmsg.FieldStartTime)
  1816. }
  1817. // SetStopTime sets the "stop_time" field.
  1818. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  1819. m.stop_time = &t
  1820. }
  1821. // StopTime returns the value of the "stop_time" field in the mutation.
  1822. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  1823. v := m.stop_time
  1824. if v == nil {
  1825. return
  1826. }
  1827. return *v, true
  1828. }
  1829. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  1830. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1832. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  1833. if !m.op.Is(OpUpdateOne) {
  1834. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  1835. }
  1836. if m.id == nil || m.oldValue == nil {
  1837. return v, errors.New("OldStopTime requires an ID field in the mutation")
  1838. }
  1839. oldValue, err := m.oldValue(ctx)
  1840. if err != nil {
  1841. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  1842. }
  1843. return oldValue.StopTime, nil
  1844. }
  1845. // ClearStopTime clears the value of the "stop_time" field.
  1846. func (m *BatchMsgMutation) ClearStopTime() {
  1847. m.stop_time = nil
  1848. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  1849. }
  1850. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  1851. func (m *BatchMsgMutation) StopTimeCleared() bool {
  1852. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  1853. return ok
  1854. }
  1855. // ResetStopTime resets all changes to the "stop_time" field.
  1856. func (m *BatchMsgMutation) ResetStopTime() {
  1857. m.stop_time = nil
  1858. delete(m.clearedFields, batchmsg.FieldStopTime)
  1859. }
  1860. // SetType sets the "type" field.
  1861. func (m *BatchMsgMutation) SetType(i int32) {
  1862. m._type = &i
  1863. m.add_type = nil
  1864. }
  1865. // GetType returns the value of the "type" field in the mutation.
  1866. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  1867. v := m._type
  1868. if v == nil {
  1869. return
  1870. }
  1871. return *v, true
  1872. }
  1873. // OldType returns the old "type" field's value of the BatchMsg entity.
  1874. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1876. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  1877. if !m.op.Is(OpUpdateOne) {
  1878. return v, errors.New("OldType is only allowed on UpdateOne operations")
  1879. }
  1880. if m.id == nil || m.oldValue == nil {
  1881. return v, errors.New("OldType requires an ID field in the mutation")
  1882. }
  1883. oldValue, err := m.oldValue(ctx)
  1884. if err != nil {
  1885. return v, fmt.Errorf("querying old value for OldType: %w", err)
  1886. }
  1887. return oldValue.Type, nil
  1888. }
  1889. // AddType adds i to the "type" field.
  1890. func (m *BatchMsgMutation) AddType(i int32) {
  1891. if m.add_type != nil {
  1892. *m.add_type += i
  1893. } else {
  1894. m.add_type = &i
  1895. }
  1896. }
  1897. // AddedType returns the value that was added to the "type" field in this mutation.
  1898. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  1899. v := m.add_type
  1900. if v == nil {
  1901. return
  1902. }
  1903. return *v, true
  1904. }
  1905. // ClearType clears the value of the "type" field.
  1906. func (m *BatchMsgMutation) ClearType() {
  1907. m._type = nil
  1908. m.add_type = nil
  1909. m.clearedFields[batchmsg.FieldType] = struct{}{}
  1910. }
  1911. // TypeCleared returns if the "type" field was cleared in this mutation.
  1912. func (m *BatchMsgMutation) TypeCleared() bool {
  1913. _, ok := m.clearedFields[batchmsg.FieldType]
  1914. return ok
  1915. }
  1916. // ResetType resets all changes to the "type" field.
  1917. func (m *BatchMsgMutation) ResetType() {
  1918. m._type = nil
  1919. m.add_type = nil
  1920. delete(m.clearedFields, batchmsg.FieldType)
  1921. }
  1922. // SetOrganizationID sets the "organization_id" field.
  1923. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  1924. m.organization_id = &u
  1925. m.addorganization_id = nil
  1926. }
  1927. // OrganizationID returns the value of the "organization_id" field in the mutation.
  1928. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  1929. v := m.organization_id
  1930. if v == nil {
  1931. return
  1932. }
  1933. return *v, true
  1934. }
  1935. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  1936. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1938. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  1939. if !m.op.Is(OpUpdateOne) {
  1940. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  1941. }
  1942. if m.id == nil || m.oldValue == nil {
  1943. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  1944. }
  1945. oldValue, err := m.oldValue(ctx)
  1946. if err != nil {
  1947. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  1948. }
  1949. return oldValue.OrganizationID, nil
  1950. }
  1951. // AddOrganizationID adds u to the "organization_id" field.
  1952. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  1953. if m.addorganization_id != nil {
  1954. *m.addorganization_id += u
  1955. } else {
  1956. m.addorganization_id = &u
  1957. }
  1958. }
  1959. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  1960. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  1961. v := m.addorganization_id
  1962. if v == nil {
  1963. return
  1964. }
  1965. return *v, true
  1966. }
  1967. // ResetOrganizationID resets all changes to the "organization_id" field.
  1968. func (m *BatchMsgMutation) ResetOrganizationID() {
  1969. m.organization_id = nil
  1970. m.addorganization_id = nil
  1971. }
  1972. // Where appends a list predicates to the BatchMsgMutation builder.
  1973. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  1974. m.predicates = append(m.predicates, ps...)
  1975. }
  1976. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  1977. // users can use type-assertion to append predicates that do not depend on any generated package.
  1978. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  1979. p := make([]predicate.BatchMsg, len(ps))
  1980. for i := range ps {
  1981. p[i] = ps[i]
  1982. }
  1983. m.Where(p...)
  1984. }
  1985. // Op returns the operation name.
  1986. func (m *BatchMsgMutation) Op() Op {
  1987. return m.op
  1988. }
  1989. // SetOp allows setting the mutation operation.
  1990. func (m *BatchMsgMutation) SetOp(op Op) {
  1991. m.op = op
  1992. }
  1993. // Type returns the node type of this mutation (BatchMsg).
  1994. func (m *BatchMsgMutation) Type() string {
  1995. return m.typ
  1996. }
  1997. // Fields returns all fields that were changed during this mutation. Note that in
  1998. // order to get all numeric fields that were incremented/decremented, call
  1999. // AddedFields().
  2000. func (m *BatchMsgMutation) Fields() []string {
  2001. fields := make([]string, 0, 16)
  2002. if m.created_at != nil {
  2003. fields = append(fields, batchmsg.FieldCreatedAt)
  2004. }
  2005. if m.updated_at != nil {
  2006. fields = append(fields, batchmsg.FieldUpdatedAt)
  2007. }
  2008. if m.deleted_at != nil {
  2009. fields = append(fields, batchmsg.FieldDeletedAt)
  2010. }
  2011. if m.status != nil {
  2012. fields = append(fields, batchmsg.FieldStatus)
  2013. }
  2014. if m.batch_no != nil {
  2015. fields = append(fields, batchmsg.FieldBatchNo)
  2016. }
  2017. if m.task_name != nil {
  2018. fields = append(fields, batchmsg.FieldTaskName)
  2019. }
  2020. if m.fromwxid != nil {
  2021. fields = append(fields, batchmsg.FieldFromwxid)
  2022. }
  2023. if m.msg != nil {
  2024. fields = append(fields, batchmsg.FieldMsg)
  2025. }
  2026. if m.tag != nil {
  2027. fields = append(fields, batchmsg.FieldTag)
  2028. }
  2029. if m.total != nil {
  2030. fields = append(fields, batchmsg.FieldTotal)
  2031. }
  2032. if m.success != nil {
  2033. fields = append(fields, batchmsg.FieldSuccess)
  2034. }
  2035. if m.fail != nil {
  2036. fields = append(fields, batchmsg.FieldFail)
  2037. }
  2038. if m.start_time != nil {
  2039. fields = append(fields, batchmsg.FieldStartTime)
  2040. }
  2041. if m.stop_time != nil {
  2042. fields = append(fields, batchmsg.FieldStopTime)
  2043. }
  2044. if m._type != nil {
  2045. fields = append(fields, batchmsg.FieldType)
  2046. }
  2047. if m.organization_id != nil {
  2048. fields = append(fields, batchmsg.FieldOrganizationID)
  2049. }
  2050. return fields
  2051. }
  2052. // Field returns the value of a field with the given name. The second boolean
  2053. // return value indicates that this field was not set, or was not defined in the
  2054. // schema.
  2055. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  2056. switch name {
  2057. case batchmsg.FieldCreatedAt:
  2058. return m.CreatedAt()
  2059. case batchmsg.FieldUpdatedAt:
  2060. return m.UpdatedAt()
  2061. case batchmsg.FieldDeletedAt:
  2062. return m.DeletedAt()
  2063. case batchmsg.FieldStatus:
  2064. return m.Status()
  2065. case batchmsg.FieldBatchNo:
  2066. return m.BatchNo()
  2067. case batchmsg.FieldTaskName:
  2068. return m.TaskName()
  2069. case batchmsg.FieldFromwxid:
  2070. return m.Fromwxid()
  2071. case batchmsg.FieldMsg:
  2072. return m.Msg()
  2073. case batchmsg.FieldTag:
  2074. return m.Tag()
  2075. case batchmsg.FieldTotal:
  2076. return m.Total()
  2077. case batchmsg.FieldSuccess:
  2078. return m.Success()
  2079. case batchmsg.FieldFail:
  2080. return m.Fail()
  2081. case batchmsg.FieldStartTime:
  2082. return m.StartTime()
  2083. case batchmsg.FieldStopTime:
  2084. return m.StopTime()
  2085. case batchmsg.FieldType:
  2086. return m.GetType()
  2087. case batchmsg.FieldOrganizationID:
  2088. return m.OrganizationID()
  2089. }
  2090. return nil, false
  2091. }
  2092. // OldField returns the old value of the field from the database. An error is
  2093. // returned if the mutation operation is not UpdateOne, or the query to the
  2094. // database failed.
  2095. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2096. switch name {
  2097. case batchmsg.FieldCreatedAt:
  2098. return m.OldCreatedAt(ctx)
  2099. case batchmsg.FieldUpdatedAt:
  2100. return m.OldUpdatedAt(ctx)
  2101. case batchmsg.FieldDeletedAt:
  2102. return m.OldDeletedAt(ctx)
  2103. case batchmsg.FieldStatus:
  2104. return m.OldStatus(ctx)
  2105. case batchmsg.FieldBatchNo:
  2106. return m.OldBatchNo(ctx)
  2107. case batchmsg.FieldTaskName:
  2108. return m.OldTaskName(ctx)
  2109. case batchmsg.FieldFromwxid:
  2110. return m.OldFromwxid(ctx)
  2111. case batchmsg.FieldMsg:
  2112. return m.OldMsg(ctx)
  2113. case batchmsg.FieldTag:
  2114. return m.OldTag(ctx)
  2115. case batchmsg.FieldTotal:
  2116. return m.OldTotal(ctx)
  2117. case batchmsg.FieldSuccess:
  2118. return m.OldSuccess(ctx)
  2119. case batchmsg.FieldFail:
  2120. return m.OldFail(ctx)
  2121. case batchmsg.FieldStartTime:
  2122. return m.OldStartTime(ctx)
  2123. case batchmsg.FieldStopTime:
  2124. return m.OldStopTime(ctx)
  2125. case batchmsg.FieldType:
  2126. return m.OldType(ctx)
  2127. case batchmsg.FieldOrganizationID:
  2128. return m.OldOrganizationID(ctx)
  2129. }
  2130. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  2131. }
  2132. // SetField sets the value of a field with the given name. It returns an error if
  2133. // the field is not defined in the schema, or if the type mismatched the field
  2134. // type.
  2135. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  2136. switch name {
  2137. case batchmsg.FieldCreatedAt:
  2138. v, ok := value.(time.Time)
  2139. if !ok {
  2140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2141. }
  2142. m.SetCreatedAt(v)
  2143. return nil
  2144. case batchmsg.FieldUpdatedAt:
  2145. v, ok := value.(time.Time)
  2146. if !ok {
  2147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2148. }
  2149. m.SetUpdatedAt(v)
  2150. return nil
  2151. case batchmsg.FieldDeletedAt:
  2152. v, ok := value.(time.Time)
  2153. if !ok {
  2154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2155. }
  2156. m.SetDeletedAt(v)
  2157. return nil
  2158. case batchmsg.FieldStatus:
  2159. v, ok := value.(uint8)
  2160. if !ok {
  2161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2162. }
  2163. m.SetStatus(v)
  2164. return nil
  2165. case batchmsg.FieldBatchNo:
  2166. v, ok := value.(string)
  2167. if !ok {
  2168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2169. }
  2170. m.SetBatchNo(v)
  2171. return nil
  2172. case batchmsg.FieldTaskName:
  2173. v, ok := value.(string)
  2174. if !ok {
  2175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2176. }
  2177. m.SetTaskName(v)
  2178. return nil
  2179. case batchmsg.FieldFromwxid:
  2180. v, ok := value.(string)
  2181. if !ok {
  2182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2183. }
  2184. m.SetFromwxid(v)
  2185. return nil
  2186. case batchmsg.FieldMsg:
  2187. v, ok := value.(string)
  2188. if !ok {
  2189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2190. }
  2191. m.SetMsg(v)
  2192. return nil
  2193. case batchmsg.FieldTag:
  2194. v, ok := value.(string)
  2195. if !ok {
  2196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2197. }
  2198. m.SetTag(v)
  2199. return nil
  2200. case batchmsg.FieldTotal:
  2201. v, ok := value.(int32)
  2202. if !ok {
  2203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2204. }
  2205. m.SetTotal(v)
  2206. return nil
  2207. case batchmsg.FieldSuccess:
  2208. v, ok := value.(int32)
  2209. if !ok {
  2210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2211. }
  2212. m.SetSuccess(v)
  2213. return nil
  2214. case batchmsg.FieldFail:
  2215. v, ok := value.(int32)
  2216. if !ok {
  2217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2218. }
  2219. m.SetFail(v)
  2220. return nil
  2221. case batchmsg.FieldStartTime:
  2222. v, ok := value.(time.Time)
  2223. if !ok {
  2224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2225. }
  2226. m.SetStartTime(v)
  2227. return nil
  2228. case batchmsg.FieldStopTime:
  2229. v, ok := value.(time.Time)
  2230. if !ok {
  2231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2232. }
  2233. m.SetStopTime(v)
  2234. return nil
  2235. case batchmsg.FieldType:
  2236. v, ok := value.(int32)
  2237. if !ok {
  2238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2239. }
  2240. m.SetType(v)
  2241. return nil
  2242. case batchmsg.FieldOrganizationID:
  2243. v, ok := value.(uint64)
  2244. if !ok {
  2245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2246. }
  2247. m.SetOrganizationID(v)
  2248. return nil
  2249. }
  2250. return fmt.Errorf("unknown BatchMsg field %s", name)
  2251. }
  2252. // AddedFields returns all numeric fields that were incremented/decremented during
  2253. // this mutation.
  2254. func (m *BatchMsgMutation) AddedFields() []string {
  2255. var fields []string
  2256. if m.addstatus != nil {
  2257. fields = append(fields, batchmsg.FieldStatus)
  2258. }
  2259. if m.addtotal != nil {
  2260. fields = append(fields, batchmsg.FieldTotal)
  2261. }
  2262. if m.addsuccess != nil {
  2263. fields = append(fields, batchmsg.FieldSuccess)
  2264. }
  2265. if m.addfail != nil {
  2266. fields = append(fields, batchmsg.FieldFail)
  2267. }
  2268. if m.add_type != nil {
  2269. fields = append(fields, batchmsg.FieldType)
  2270. }
  2271. if m.addorganization_id != nil {
  2272. fields = append(fields, batchmsg.FieldOrganizationID)
  2273. }
  2274. return fields
  2275. }
  2276. // AddedField returns the numeric value that was incremented/decremented on a field
  2277. // with the given name. The second boolean return value indicates that this field
  2278. // was not set, or was not defined in the schema.
  2279. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  2280. switch name {
  2281. case batchmsg.FieldStatus:
  2282. return m.AddedStatus()
  2283. case batchmsg.FieldTotal:
  2284. return m.AddedTotal()
  2285. case batchmsg.FieldSuccess:
  2286. return m.AddedSuccess()
  2287. case batchmsg.FieldFail:
  2288. return m.AddedFail()
  2289. case batchmsg.FieldType:
  2290. return m.AddedType()
  2291. case batchmsg.FieldOrganizationID:
  2292. return m.AddedOrganizationID()
  2293. }
  2294. return nil, false
  2295. }
  2296. // AddField adds the value to the field with the given name. It returns an error if
  2297. // the field is not defined in the schema, or if the type mismatched the field
  2298. // type.
  2299. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  2300. switch name {
  2301. case batchmsg.FieldStatus:
  2302. v, ok := value.(int8)
  2303. if !ok {
  2304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2305. }
  2306. m.AddStatus(v)
  2307. return nil
  2308. case batchmsg.FieldTotal:
  2309. v, ok := value.(int32)
  2310. if !ok {
  2311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2312. }
  2313. m.AddTotal(v)
  2314. return nil
  2315. case batchmsg.FieldSuccess:
  2316. v, ok := value.(int32)
  2317. if !ok {
  2318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2319. }
  2320. m.AddSuccess(v)
  2321. return nil
  2322. case batchmsg.FieldFail:
  2323. v, ok := value.(int32)
  2324. if !ok {
  2325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2326. }
  2327. m.AddFail(v)
  2328. return nil
  2329. case batchmsg.FieldType:
  2330. v, ok := value.(int32)
  2331. if !ok {
  2332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2333. }
  2334. m.AddType(v)
  2335. return nil
  2336. case batchmsg.FieldOrganizationID:
  2337. v, ok := value.(int64)
  2338. if !ok {
  2339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2340. }
  2341. m.AddOrganizationID(v)
  2342. return nil
  2343. }
  2344. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  2345. }
  2346. // ClearedFields returns all nullable fields that were cleared during this
  2347. // mutation.
  2348. func (m *BatchMsgMutation) ClearedFields() []string {
  2349. var fields []string
  2350. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  2351. fields = append(fields, batchmsg.FieldDeletedAt)
  2352. }
  2353. if m.FieldCleared(batchmsg.FieldStatus) {
  2354. fields = append(fields, batchmsg.FieldStatus)
  2355. }
  2356. if m.FieldCleared(batchmsg.FieldBatchNo) {
  2357. fields = append(fields, batchmsg.FieldBatchNo)
  2358. }
  2359. if m.FieldCleared(batchmsg.FieldTaskName) {
  2360. fields = append(fields, batchmsg.FieldTaskName)
  2361. }
  2362. if m.FieldCleared(batchmsg.FieldFromwxid) {
  2363. fields = append(fields, batchmsg.FieldFromwxid)
  2364. }
  2365. if m.FieldCleared(batchmsg.FieldMsg) {
  2366. fields = append(fields, batchmsg.FieldMsg)
  2367. }
  2368. if m.FieldCleared(batchmsg.FieldTag) {
  2369. fields = append(fields, batchmsg.FieldTag)
  2370. }
  2371. if m.FieldCleared(batchmsg.FieldTotal) {
  2372. fields = append(fields, batchmsg.FieldTotal)
  2373. }
  2374. if m.FieldCleared(batchmsg.FieldSuccess) {
  2375. fields = append(fields, batchmsg.FieldSuccess)
  2376. }
  2377. if m.FieldCleared(batchmsg.FieldFail) {
  2378. fields = append(fields, batchmsg.FieldFail)
  2379. }
  2380. if m.FieldCleared(batchmsg.FieldStartTime) {
  2381. fields = append(fields, batchmsg.FieldStartTime)
  2382. }
  2383. if m.FieldCleared(batchmsg.FieldStopTime) {
  2384. fields = append(fields, batchmsg.FieldStopTime)
  2385. }
  2386. if m.FieldCleared(batchmsg.FieldType) {
  2387. fields = append(fields, batchmsg.FieldType)
  2388. }
  2389. return fields
  2390. }
  2391. // FieldCleared returns a boolean indicating if a field with the given name was
  2392. // cleared in this mutation.
  2393. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  2394. _, ok := m.clearedFields[name]
  2395. return ok
  2396. }
  2397. // ClearField clears the value of the field with the given name. It returns an
  2398. // error if the field is not defined in the schema.
  2399. func (m *BatchMsgMutation) ClearField(name string) error {
  2400. switch name {
  2401. case batchmsg.FieldDeletedAt:
  2402. m.ClearDeletedAt()
  2403. return nil
  2404. case batchmsg.FieldStatus:
  2405. m.ClearStatus()
  2406. return nil
  2407. case batchmsg.FieldBatchNo:
  2408. m.ClearBatchNo()
  2409. return nil
  2410. case batchmsg.FieldTaskName:
  2411. m.ClearTaskName()
  2412. return nil
  2413. case batchmsg.FieldFromwxid:
  2414. m.ClearFromwxid()
  2415. return nil
  2416. case batchmsg.FieldMsg:
  2417. m.ClearMsg()
  2418. return nil
  2419. case batchmsg.FieldTag:
  2420. m.ClearTag()
  2421. return nil
  2422. case batchmsg.FieldTotal:
  2423. m.ClearTotal()
  2424. return nil
  2425. case batchmsg.FieldSuccess:
  2426. m.ClearSuccess()
  2427. return nil
  2428. case batchmsg.FieldFail:
  2429. m.ClearFail()
  2430. return nil
  2431. case batchmsg.FieldStartTime:
  2432. m.ClearStartTime()
  2433. return nil
  2434. case batchmsg.FieldStopTime:
  2435. m.ClearStopTime()
  2436. return nil
  2437. case batchmsg.FieldType:
  2438. m.ClearType()
  2439. return nil
  2440. }
  2441. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  2442. }
  2443. // ResetField resets all changes in the mutation for the field with the given name.
  2444. // It returns an error if the field is not defined in the schema.
  2445. func (m *BatchMsgMutation) ResetField(name string) error {
  2446. switch name {
  2447. case batchmsg.FieldCreatedAt:
  2448. m.ResetCreatedAt()
  2449. return nil
  2450. case batchmsg.FieldUpdatedAt:
  2451. m.ResetUpdatedAt()
  2452. return nil
  2453. case batchmsg.FieldDeletedAt:
  2454. m.ResetDeletedAt()
  2455. return nil
  2456. case batchmsg.FieldStatus:
  2457. m.ResetStatus()
  2458. return nil
  2459. case batchmsg.FieldBatchNo:
  2460. m.ResetBatchNo()
  2461. return nil
  2462. case batchmsg.FieldTaskName:
  2463. m.ResetTaskName()
  2464. return nil
  2465. case batchmsg.FieldFromwxid:
  2466. m.ResetFromwxid()
  2467. return nil
  2468. case batchmsg.FieldMsg:
  2469. m.ResetMsg()
  2470. return nil
  2471. case batchmsg.FieldTag:
  2472. m.ResetTag()
  2473. return nil
  2474. case batchmsg.FieldTotal:
  2475. m.ResetTotal()
  2476. return nil
  2477. case batchmsg.FieldSuccess:
  2478. m.ResetSuccess()
  2479. return nil
  2480. case batchmsg.FieldFail:
  2481. m.ResetFail()
  2482. return nil
  2483. case batchmsg.FieldStartTime:
  2484. m.ResetStartTime()
  2485. return nil
  2486. case batchmsg.FieldStopTime:
  2487. m.ResetStopTime()
  2488. return nil
  2489. case batchmsg.FieldType:
  2490. m.ResetType()
  2491. return nil
  2492. case batchmsg.FieldOrganizationID:
  2493. m.ResetOrganizationID()
  2494. return nil
  2495. }
  2496. return fmt.Errorf("unknown BatchMsg field %s", name)
  2497. }
  2498. // AddedEdges returns all edge names that were set/added in this mutation.
  2499. func (m *BatchMsgMutation) AddedEdges() []string {
  2500. edges := make([]string, 0, 0)
  2501. return edges
  2502. }
  2503. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2504. // name in this mutation.
  2505. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  2506. return nil
  2507. }
  2508. // RemovedEdges returns all edge names that were removed in this mutation.
  2509. func (m *BatchMsgMutation) RemovedEdges() []string {
  2510. edges := make([]string, 0, 0)
  2511. return edges
  2512. }
  2513. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2514. // the given name in this mutation.
  2515. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  2516. return nil
  2517. }
  2518. // ClearedEdges returns all edge names that were cleared in this mutation.
  2519. func (m *BatchMsgMutation) ClearedEdges() []string {
  2520. edges := make([]string, 0, 0)
  2521. return edges
  2522. }
  2523. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2524. // was cleared in this mutation.
  2525. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  2526. return false
  2527. }
  2528. // ClearEdge clears the value of the edge with the given name. It returns an error
  2529. // if that edge is not defined in the schema.
  2530. func (m *BatchMsgMutation) ClearEdge(name string) error {
  2531. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  2532. }
  2533. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2534. // It returns an error if the edge is not defined in the schema.
  2535. func (m *BatchMsgMutation) ResetEdge(name string) error {
  2536. return fmt.Errorf("unknown BatchMsg edge %s", name)
  2537. }
  2538. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  2539. type CategoryMutation struct {
  2540. config
  2541. op Op
  2542. typ string
  2543. id *uint64
  2544. created_at *time.Time
  2545. updated_at *time.Time
  2546. deleted_at *time.Time
  2547. name *string
  2548. organization_id *uint64
  2549. addorganization_id *int64
  2550. clearedFields map[string]struct{}
  2551. done bool
  2552. oldValue func(context.Context) (*Category, error)
  2553. predicates []predicate.Category
  2554. }
  2555. var _ ent.Mutation = (*CategoryMutation)(nil)
  2556. // categoryOption allows management of the mutation configuration using functional options.
  2557. type categoryOption func(*CategoryMutation)
  2558. // newCategoryMutation creates new mutation for the Category entity.
  2559. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  2560. m := &CategoryMutation{
  2561. config: c,
  2562. op: op,
  2563. typ: TypeCategory,
  2564. clearedFields: make(map[string]struct{}),
  2565. }
  2566. for _, opt := range opts {
  2567. opt(m)
  2568. }
  2569. return m
  2570. }
  2571. // withCategoryID sets the ID field of the mutation.
  2572. func withCategoryID(id uint64) categoryOption {
  2573. return func(m *CategoryMutation) {
  2574. var (
  2575. err error
  2576. once sync.Once
  2577. value *Category
  2578. )
  2579. m.oldValue = func(ctx context.Context) (*Category, error) {
  2580. once.Do(func() {
  2581. if m.done {
  2582. err = errors.New("querying old values post mutation is not allowed")
  2583. } else {
  2584. value, err = m.Client().Category.Get(ctx, id)
  2585. }
  2586. })
  2587. return value, err
  2588. }
  2589. m.id = &id
  2590. }
  2591. }
  2592. // withCategory sets the old Category of the mutation.
  2593. func withCategory(node *Category) categoryOption {
  2594. return func(m *CategoryMutation) {
  2595. m.oldValue = func(context.Context) (*Category, error) {
  2596. return node, nil
  2597. }
  2598. m.id = &node.ID
  2599. }
  2600. }
  2601. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2602. // executed in a transaction (ent.Tx), a transactional client is returned.
  2603. func (m CategoryMutation) Client() *Client {
  2604. client := &Client{config: m.config}
  2605. client.init()
  2606. return client
  2607. }
  2608. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2609. // it returns an error otherwise.
  2610. func (m CategoryMutation) Tx() (*Tx, error) {
  2611. if _, ok := m.driver.(*txDriver); !ok {
  2612. return nil, errors.New("ent: mutation is not running in a transaction")
  2613. }
  2614. tx := &Tx{config: m.config}
  2615. tx.init()
  2616. return tx, nil
  2617. }
  2618. // SetID sets the value of the id field. Note that this
  2619. // operation is only accepted on creation of Category entities.
  2620. func (m *CategoryMutation) SetID(id uint64) {
  2621. m.id = &id
  2622. }
  2623. // ID returns the ID value in the mutation. Note that the ID is only available
  2624. // if it was provided to the builder or after it was returned from the database.
  2625. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  2626. if m.id == nil {
  2627. return
  2628. }
  2629. return *m.id, true
  2630. }
  2631. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2632. // That means, if the mutation is applied within a transaction with an isolation level such
  2633. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2634. // or updated by the mutation.
  2635. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  2636. switch {
  2637. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2638. id, exists := m.ID()
  2639. if exists {
  2640. return []uint64{id}, nil
  2641. }
  2642. fallthrough
  2643. case m.op.Is(OpUpdate | OpDelete):
  2644. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  2645. default:
  2646. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2647. }
  2648. }
  2649. // SetCreatedAt sets the "created_at" field.
  2650. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  2651. m.created_at = &t
  2652. }
  2653. // CreatedAt returns the value of the "created_at" field in the mutation.
  2654. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  2655. v := m.created_at
  2656. if v == nil {
  2657. return
  2658. }
  2659. return *v, true
  2660. }
  2661. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  2662. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  2663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2664. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2665. if !m.op.Is(OpUpdateOne) {
  2666. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2667. }
  2668. if m.id == nil || m.oldValue == nil {
  2669. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2670. }
  2671. oldValue, err := m.oldValue(ctx)
  2672. if err != nil {
  2673. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2674. }
  2675. return oldValue.CreatedAt, nil
  2676. }
  2677. // ResetCreatedAt resets all changes to the "created_at" field.
  2678. func (m *CategoryMutation) ResetCreatedAt() {
  2679. m.created_at = nil
  2680. }
  2681. // SetUpdatedAt sets the "updated_at" field.
  2682. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  2683. m.updated_at = &t
  2684. }
  2685. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2686. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  2687. v := m.updated_at
  2688. if v == nil {
  2689. return
  2690. }
  2691. return *v, true
  2692. }
  2693. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  2694. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  2695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2696. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2697. if !m.op.Is(OpUpdateOne) {
  2698. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2699. }
  2700. if m.id == nil || m.oldValue == nil {
  2701. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2702. }
  2703. oldValue, err := m.oldValue(ctx)
  2704. if err != nil {
  2705. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2706. }
  2707. return oldValue.UpdatedAt, nil
  2708. }
  2709. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2710. func (m *CategoryMutation) ResetUpdatedAt() {
  2711. m.updated_at = nil
  2712. }
  2713. // SetDeletedAt sets the "deleted_at" field.
  2714. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  2715. m.deleted_at = &t
  2716. }
  2717. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2718. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  2719. v := m.deleted_at
  2720. if v == nil {
  2721. return
  2722. }
  2723. return *v, true
  2724. }
  2725. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  2726. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  2727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2728. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2729. if !m.op.Is(OpUpdateOne) {
  2730. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2731. }
  2732. if m.id == nil || m.oldValue == nil {
  2733. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2734. }
  2735. oldValue, err := m.oldValue(ctx)
  2736. if err != nil {
  2737. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2738. }
  2739. return oldValue.DeletedAt, nil
  2740. }
  2741. // ClearDeletedAt clears the value of the "deleted_at" field.
  2742. func (m *CategoryMutation) ClearDeletedAt() {
  2743. m.deleted_at = nil
  2744. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  2745. }
  2746. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2747. func (m *CategoryMutation) DeletedAtCleared() bool {
  2748. _, ok := m.clearedFields[category.FieldDeletedAt]
  2749. return ok
  2750. }
  2751. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2752. func (m *CategoryMutation) ResetDeletedAt() {
  2753. m.deleted_at = nil
  2754. delete(m.clearedFields, category.FieldDeletedAt)
  2755. }
  2756. // SetName sets the "name" field.
  2757. func (m *CategoryMutation) SetName(s string) {
  2758. m.name = &s
  2759. }
  2760. // Name returns the value of the "name" field in the mutation.
  2761. func (m *CategoryMutation) Name() (r string, exists bool) {
  2762. v := m.name
  2763. if v == nil {
  2764. return
  2765. }
  2766. return *v, true
  2767. }
  2768. // OldName returns the old "name" field's value of the Category entity.
  2769. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  2770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2771. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  2772. if !m.op.Is(OpUpdateOne) {
  2773. return v, errors.New("OldName is only allowed on UpdateOne operations")
  2774. }
  2775. if m.id == nil || m.oldValue == nil {
  2776. return v, errors.New("OldName requires an ID field in the mutation")
  2777. }
  2778. oldValue, err := m.oldValue(ctx)
  2779. if err != nil {
  2780. return v, fmt.Errorf("querying old value for OldName: %w", err)
  2781. }
  2782. return oldValue.Name, nil
  2783. }
  2784. // ResetName resets all changes to the "name" field.
  2785. func (m *CategoryMutation) ResetName() {
  2786. m.name = nil
  2787. }
  2788. // SetOrganizationID sets the "organization_id" field.
  2789. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  2790. m.organization_id = &u
  2791. m.addorganization_id = nil
  2792. }
  2793. // OrganizationID returns the value of the "organization_id" field in the mutation.
  2794. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  2795. v := m.organization_id
  2796. if v == nil {
  2797. return
  2798. }
  2799. return *v, true
  2800. }
  2801. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  2802. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  2803. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2804. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  2805. if !m.op.Is(OpUpdateOne) {
  2806. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  2807. }
  2808. if m.id == nil || m.oldValue == nil {
  2809. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  2810. }
  2811. oldValue, err := m.oldValue(ctx)
  2812. if err != nil {
  2813. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  2814. }
  2815. return oldValue.OrganizationID, nil
  2816. }
  2817. // AddOrganizationID adds u to the "organization_id" field.
  2818. func (m *CategoryMutation) AddOrganizationID(u int64) {
  2819. if m.addorganization_id != nil {
  2820. *m.addorganization_id += u
  2821. } else {
  2822. m.addorganization_id = &u
  2823. }
  2824. }
  2825. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  2826. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  2827. v := m.addorganization_id
  2828. if v == nil {
  2829. return
  2830. }
  2831. return *v, true
  2832. }
  2833. // ResetOrganizationID resets all changes to the "organization_id" field.
  2834. func (m *CategoryMutation) ResetOrganizationID() {
  2835. m.organization_id = nil
  2836. m.addorganization_id = nil
  2837. }
  2838. // Where appends a list predicates to the CategoryMutation builder.
  2839. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  2840. m.predicates = append(m.predicates, ps...)
  2841. }
  2842. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  2843. // users can use type-assertion to append predicates that do not depend on any generated package.
  2844. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  2845. p := make([]predicate.Category, len(ps))
  2846. for i := range ps {
  2847. p[i] = ps[i]
  2848. }
  2849. m.Where(p...)
  2850. }
  2851. // Op returns the operation name.
  2852. func (m *CategoryMutation) Op() Op {
  2853. return m.op
  2854. }
  2855. // SetOp allows setting the mutation operation.
  2856. func (m *CategoryMutation) SetOp(op Op) {
  2857. m.op = op
  2858. }
  2859. // Type returns the node type of this mutation (Category).
  2860. func (m *CategoryMutation) Type() string {
  2861. return m.typ
  2862. }
  2863. // Fields returns all fields that were changed during this mutation. Note that in
  2864. // order to get all numeric fields that were incremented/decremented, call
  2865. // AddedFields().
  2866. func (m *CategoryMutation) Fields() []string {
  2867. fields := make([]string, 0, 5)
  2868. if m.created_at != nil {
  2869. fields = append(fields, category.FieldCreatedAt)
  2870. }
  2871. if m.updated_at != nil {
  2872. fields = append(fields, category.FieldUpdatedAt)
  2873. }
  2874. if m.deleted_at != nil {
  2875. fields = append(fields, category.FieldDeletedAt)
  2876. }
  2877. if m.name != nil {
  2878. fields = append(fields, category.FieldName)
  2879. }
  2880. if m.organization_id != nil {
  2881. fields = append(fields, category.FieldOrganizationID)
  2882. }
  2883. return fields
  2884. }
  2885. // Field returns the value of a field with the given name. The second boolean
  2886. // return value indicates that this field was not set, or was not defined in the
  2887. // schema.
  2888. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  2889. switch name {
  2890. case category.FieldCreatedAt:
  2891. return m.CreatedAt()
  2892. case category.FieldUpdatedAt:
  2893. return m.UpdatedAt()
  2894. case category.FieldDeletedAt:
  2895. return m.DeletedAt()
  2896. case category.FieldName:
  2897. return m.Name()
  2898. case category.FieldOrganizationID:
  2899. return m.OrganizationID()
  2900. }
  2901. return nil, false
  2902. }
  2903. // OldField returns the old value of the field from the database. An error is
  2904. // returned if the mutation operation is not UpdateOne, or the query to the
  2905. // database failed.
  2906. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2907. switch name {
  2908. case category.FieldCreatedAt:
  2909. return m.OldCreatedAt(ctx)
  2910. case category.FieldUpdatedAt:
  2911. return m.OldUpdatedAt(ctx)
  2912. case category.FieldDeletedAt:
  2913. return m.OldDeletedAt(ctx)
  2914. case category.FieldName:
  2915. return m.OldName(ctx)
  2916. case category.FieldOrganizationID:
  2917. return m.OldOrganizationID(ctx)
  2918. }
  2919. return nil, fmt.Errorf("unknown Category field %s", name)
  2920. }
  2921. // SetField sets the value of a field with the given name. It returns an error if
  2922. // the field is not defined in the schema, or if the type mismatched the field
  2923. // type.
  2924. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  2925. switch name {
  2926. case category.FieldCreatedAt:
  2927. v, ok := value.(time.Time)
  2928. if !ok {
  2929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2930. }
  2931. m.SetCreatedAt(v)
  2932. return nil
  2933. case category.FieldUpdatedAt:
  2934. v, ok := value.(time.Time)
  2935. if !ok {
  2936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2937. }
  2938. m.SetUpdatedAt(v)
  2939. return nil
  2940. case category.FieldDeletedAt:
  2941. v, ok := value.(time.Time)
  2942. if !ok {
  2943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2944. }
  2945. m.SetDeletedAt(v)
  2946. return nil
  2947. case category.FieldName:
  2948. v, ok := value.(string)
  2949. if !ok {
  2950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2951. }
  2952. m.SetName(v)
  2953. return nil
  2954. case category.FieldOrganizationID:
  2955. v, ok := value.(uint64)
  2956. if !ok {
  2957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2958. }
  2959. m.SetOrganizationID(v)
  2960. return nil
  2961. }
  2962. return fmt.Errorf("unknown Category field %s", name)
  2963. }
  2964. // AddedFields returns all numeric fields that were incremented/decremented during
  2965. // this mutation.
  2966. func (m *CategoryMutation) AddedFields() []string {
  2967. var fields []string
  2968. if m.addorganization_id != nil {
  2969. fields = append(fields, category.FieldOrganizationID)
  2970. }
  2971. return fields
  2972. }
  2973. // AddedField returns the numeric value that was incremented/decremented on a field
  2974. // with the given name. The second boolean return value indicates that this field
  2975. // was not set, or was not defined in the schema.
  2976. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  2977. switch name {
  2978. case category.FieldOrganizationID:
  2979. return m.AddedOrganizationID()
  2980. }
  2981. return nil, false
  2982. }
  2983. // AddField adds the value to the field with the given name. It returns an error if
  2984. // the field is not defined in the schema, or if the type mismatched the field
  2985. // type.
  2986. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  2987. switch name {
  2988. case category.FieldOrganizationID:
  2989. v, ok := value.(int64)
  2990. if !ok {
  2991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2992. }
  2993. m.AddOrganizationID(v)
  2994. return nil
  2995. }
  2996. return fmt.Errorf("unknown Category numeric field %s", name)
  2997. }
  2998. // ClearedFields returns all nullable fields that were cleared during this
  2999. // mutation.
  3000. func (m *CategoryMutation) ClearedFields() []string {
  3001. var fields []string
  3002. if m.FieldCleared(category.FieldDeletedAt) {
  3003. fields = append(fields, category.FieldDeletedAt)
  3004. }
  3005. return fields
  3006. }
  3007. // FieldCleared returns a boolean indicating if a field with the given name was
  3008. // cleared in this mutation.
  3009. func (m *CategoryMutation) FieldCleared(name string) bool {
  3010. _, ok := m.clearedFields[name]
  3011. return ok
  3012. }
  3013. // ClearField clears the value of the field with the given name. It returns an
  3014. // error if the field is not defined in the schema.
  3015. func (m *CategoryMutation) ClearField(name string) error {
  3016. switch name {
  3017. case category.FieldDeletedAt:
  3018. m.ClearDeletedAt()
  3019. return nil
  3020. }
  3021. return fmt.Errorf("unknown Category nullable field %s", name)
  3022. }
  3023. // ResetField resets all changes in the mutation for the field with the given name.
  3024. // It returns an error if the field is not defined in the schema.
  3025. func (m *CategoryMutation) ResetField(name string) error {
  3026. switch name {
  3027. case category.FieldCreatedAt:
  3028. m.ResetCreatedAt()
  3029. return nil
  3030. case category.FieldUpdatedAt:
  3031. m.ResetUpdatedAt()
  3032. return nil
  3033. case category.FieldDeletedAt:
  3034. m.ResetDeletedAt()
  3035. return nil
  3036. case category.FieldName:
  3037. m.ResetName()
  3038. return nil
  3039. case category.FieldOrganizationID:
  3040. m.ResetOrganizationID()
  3041. return nil
  3042. }
  3043. return fmt.Errorf("unknown Category field %s", name)
  3044. }
  3045. // AddedEdges returns all edge names that were set/added in this mutation.
  3046. func (m *CategoryMutation) AddedEdges() []string {
  3047. edges := make([]string, 0, 0)
  3048. return edges
  3049. }
  3050. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3051. // name in this mutation.
  3052. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  3053. return nil
  3054. }
  3055. // RemovedEdges returns all edge names that were removed in this mutation.
  3056. func (m *CategoryMutation) RemovedEdges() []string {
  3057. edges := make([]string, 0, 0)
  3058. return edges
  3059. }
  3060. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3061. // the given name in this mutation.
  3062. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  3063. return nil
  3064. }
  3065. // ClearedEdges returns all edge names that were cleared in this mutation.
  3066. func (m *CategoryMutation) ClearedEdges() []string {
  3067. edges := make([]string, 0, 0)
  3068. return edges
  3069. }
  3070. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3071. // was cleared in this mutation.
  3072. func (m *CategoryMutation) EdgeCleared(name string) bool {
  3073. return false
  3074. }
  3075. // ClearEdge clears the value of the edge with the given name. It returns an error
  3076. // if that edge is not defined in the schema.
  3077. func (m *CategoryMutation) ClearEdge(name string) error {
  3078. return fmt.Errorf("unknown Category unique edge %s", name)
  3079. }
  3080. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3081. // It returns an error if the edge is not defined in the schema.
  3082. func (m *CategoryMutation) ResetEdge(name string) error {
  3083. return fmt.Errorf("unknown Category edge %s", name)
  3084. }
  3085. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  3086. type ContactMutation struct {
  3087. config
  3088. op Op
  3089. typ string
  3090. id *uint64
  3091. created_at *time.Time
  3092. updated_at *time.Time
  3093. status *uint8
  3094. addstatus *int8
  3095. deleted_at *time.Time
  3096. wx_wxid *string
  3097. _type *int
  3098. add_type *int
  3099. wxid *string
  3100. account *string
  3101. nickname *string
  3102. markname *string
  3103. headimg *string
  3104. sex *int
  3105. addsex *int
  3106. starrole *string
  3107. dontseeit *int
  3108. adddontseeit *int
  3109. dontseeme *int
  3110. adddontseeme *int
  3111. lag *string
  3112. gid *string
  3113. gname *string
  3114. v3 *string
  3115. organization_id *uint64
  3116. addorganization_id *int64
  3117. clearedFields map[string]struct{}
  3118. contact_relationships map[uint64]struct{}
  3119. removedcontact_relationships map[uint64]struct{}
  3120. clearedcontact_relationships bool
  3121. contact_messages map[uint64]struct{}
  3122. removedcontact_messages map[uint64]struct{}
  3123. clearedcontact_messages bool
  3124. done bool
  3125. oldValue func(context.Context) (*Contact, error)
  3126. predicates []predicate.Contact
  3127. }
  3128. var _ ent.Mutation = (*ContactMutation)(nil)
  3129. // contactOption allows management of the mutation configuration using functional options.
  3130. type contactOption func(*ContactMutation)
  3131. // newContactMutation creates new mutation for the Contact entity.
  3132. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  3133. m := &ContactMutation{
  3134. config: c,
  3135. op: op,
  3136. typ: TypeContact,
  3137. clearedFields: make(map[string]struct{}),
  3138. }
  3139. for _, opt := range opts {
  3140. opt(m)
  3141. }
  3142. return m
  3143. }
  3144. // withContactID sets the ID field of the mutation.
  3145. func withContactID(id uint64) contactOption {
  3146. return func(m *ContactMutation) {
  3147. var (
  3148. err error
  3149. once sync.Once
  3150. value *Contact
  3151. )
  3152. m.oldValue = func(ctx context.Context) (*Contact, error) {
  3153. once.Do(func() {
  3154. if m.done {
  3155. err = errors.New("querying old values post mutation is not allowed")
  3156. } else {
  3157. value, err = m.Client().Contact.Get(ctx, id)
  3158. }
  3159. })
  3160. return value, err
  3161. }
  3162. m.id = &id
  3163. }
  3164. }
  3165. // withContact sets the old Contact of the mutation.
  3166. func withContact(node *Contact) contactOption {
  3167. return func(m *ContactMutation) {
  3168. m.oldValue = func(context.Context) (*Contact, error) {
  3169. return node, nil
  3170. }
  3171. m.id = &node.ID
  3172. }
  3173. }
  3174. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3175. // executed in a transaction (ent.Tx), a transactional client is returned.
  3176. func (m ContactMutation) Client() *Client {
  3177. client := &Client{config: m.config}
  3178. client.init()
  3179. return client
  3180. }
  3181. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3182. // it returns an error otherwise.
  3183. func (m ContactMutation) Tx() (*Tx, error) {
  3184. if _, ok := m.driver.(*txDriver); !ok {
  3185. return nil, errors.New("ent: mutation is not running in a transaction")
  3186. }
  3187. tx := &Tx{config: m.config}
  3188. tx.init()
  3189. return tx, nil
  3190. }
  3191. // SetID sets the value of the id field. Note that this
  3192. // operation is only accepted on creation of Contact entities.
  3193. func (m *ContactMutation) SetID(id uint64) {
  3194. m.id = &id
  3195. }
  3196. // ID returns the ID value in the mutation. Note that the ID is only available
  3197. // if it was provided to the builder or after it was returned from the database.
  3198. func (m *ContactMutation) ID() (id uint64, exists bool) {
  3199. if m.id == nil {
  3200. return
  3201. }
  3202. return *m.id, true
  3203. }
  3204. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3205. // That means, if the mutation is applied within a transaction with an isolation level such
  3206. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3207. // or updated by the mutation.
  3208. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  3209. switch {
  3210. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3211. id, exists := m.ID()
  3212. if exists {
  3213. return []uint64{id}, nil
  3214. }
  3215. fallthrough
  3216. case m.op.Is(OpUpdate | OpDelete):
  3217. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  3218. default:
  3219. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3220. }
  3221. }
  3222. // SetCreatedAt sets the "created_at" field.
  3223. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  3224. m.created_at = &t
  3225. }
  3226. // CreatedAt returns the value of the "created_at" field in the mutation.
  3227. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  3228. v := m.created_at
  3229. if v == nil {
  3230. return
  3231. }
  3232. return *v, true
  3233. }
  3234. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  3235. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3237. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3238. if !m.op.Is(OpUpdateOne) {
  3239. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3240. }
  3241. if m.id == nil || m.oldValue == nil {
  3242. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3243. }
  3244. oldValue, err := m.oldValue(ctx)
  3245. if err != nil {
  3246. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3247. }
  3248. return oldValue.CreatedAt, nil
  3249. }
  3250. // ResetCreatedAt resets all changes to the "created_at" field.
  3251. func (m *ContactMutation) ResetCreatedAt() {
  3252. m.created_at = nil
  3253. }
  3254. // SetUpdatedAt sets the "updated_at" field.
  3255. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  3256. m.updated_at = &t
  3257. }
  3258. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3259. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  3260. v := m.updated_at
  3261. if v == nil {
  3262. return
  3263. }
  3264. return *v, true
  3265. }
  3266. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  3267. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3269. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3270. if !m.op.Is(OpUpdateOne) {
  3271. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3272. }
  3273. if m.id == nil || m.oldValue == nil {
  3274. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3275. }
  3276. oldValue, err := m.oldValue(ctx)
  3277. if err != nil {
  3278. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3279. }
  3280. return oldValue.UpdatedAt, nil
  3281. }
  3282. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3283. func (m *ContactMutation) ResetUpdatedAt() {
  3284. m.updated_at = nil
  3285. }
  3286. // SetStatus sets the "status" field.
  3287. func (m *ContactMutation) SetStatus(u uint8) {
  3288. m.status = &u
  3289. m.addstatus = nil
  3290. }
  3291. // Status returns the value of the "status" field in the mutation.
  3292. func (m *ContactMutation) Status() (r uint8, exists bool) {
  3293. v := m.status
  3294. if v == nil {
  3295. return
  3296. }
  3297. return *v, true
  3298. }
  3299. // OldStatus returns the old "status" field's value of the Contact entity.
  3300. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3302. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  3303. if !m.op.Is(OpUpdateOne) {
  3304. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3305. }
  3306. if m.id == nil || m.oldValue == nil {
  3307. return v, errors.New("OldStatus requires an ID field in the mutation")
  3308. }
  3309. oldValue, err := m.oldValue(ctx)
  3310. if err != nil {
  3311. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3312. }
  3313. return oldValue.Status, nil
  3314. }
  3315. // AddStatus adds u to the "status" field.
  3316. func (m *ContactMutation) AddStatus(u int8) {
  3317. if m.addstatus != nil {
  3318. *m.addstatus += u
  3319. } else {
  3320. m.addstatus = &u
  3321. }
  3322. }
  3323. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3324. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  3325. v := m.addstatus
  3326. if v == nil {
  3327. return
  3328. }
  3329. return *v, true
  3330. }
  3331. // ClearStatus clears the value of the "status" field.
  3332. func (m *ContactMutation) ClearStatus() {
  3333. m.status = nil
  3334. m.addstatus = nil
  3335. m.clearedFields[contact.FieldStatus] = struct{}{}
  3336. }
  3337. // StatusCleared returns if the "status" field was cleared in this mutation.
  3338. func (m *ContactMutation) StatusCleared() bool {
  3339. _, ok := m.clearedFields[contact.FieldStatus]
  3340. return ok
  3341. }
  3342. // ResetStatus resets all changes to the "status" field.
  3343. func (m *ContactMutation) ResetStatus() {
  3344. m.status = nil
  3345. m.addstatus = nil
  3346. delete(m.clearedFields, contact.FieldStatus)
  3347. }
  3348. // SetDeletedAt sets the "deleted_at" field.
  3349. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  3350. m.deleted_at = &t
  3351. }
  3352. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3353. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  3354. v := m.deleted_at
  3355. if v == nil {
  3356. return
  3357. }
  3358. return *v, true
  3359. }
  3360. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  3361. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3363. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3364. if !m.op.Is(OpUpdateOne) {
  3365. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3366. }
  3367. if m.id == nil || m.oldValue == nil {
  3368. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3369. }
  3370. oldValue, err := m.oldValue(ctx)
  3371. if err != nil {
  3372. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3373. }
  3374. return oldValue.DeletedAt, nil
  3375. }
  3376. // ClearDeletedAt clears the value of the "deleted_at" field.
  3377. func (m *ContactMutation) ClearDeletedAt() {
  3378. m.deleted_at = nil
  3379. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  3380. }
  3381. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3382. func (m *ContactMutation) DeletedAtCleared() bool {
  3383. _, ok := m.clearedFields[contact.FieldDeletedAt]
  3384. return ok
  3385. }
  3386. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3387. func (m *ContactMutation) ResetDeletedAt() {
  3388. m.deleted_at = nil
  3389. delete(m.clearedFields, contact.FieldDeletedAt)
  3390. }
  3391. // SetWxWxid sets the "wx_wxid" field.
  3392. func (m *ContactMutation) SetWxWxid(s string) {
  3393. m.wx_wxid = &s
  3394. }
  3395. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  3396. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  3397. v := m.wx_wxid
  3398. if v == nil {
  3399. return
  3400. }
  3401. return *v, true
  3402. }
  3403. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  3404. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3406. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  3407. if !m.op.Is(OpUpdateOne) {
  3408. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  3409. }
  3410. if m.id == nil || m.oldValue == nil {
  3411. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  3412. }
  3413. oldValue, err := m.oldValue(ctx)
  3414. if err != nil {
  3415. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  3416. }
  3417. return oldValue.WxWxid, nil
  3418. }
  3419. // ClearWxWxid clears the value of the "wx_wxid" field.
  3420. func (m *ContactMutation) ClearWxWxid() {
  3421. m.wx_wxid = nil
  3422. m.clearedFields[contact.FieldWxWxid] = struct{}{}
  3423. }
  3424. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  3425. func (m *ContactMutation) WxWxidCleared() bool {
  3426. _, ok := m.clearedFields[contact.FieldWxWxid]
  3427. return ok
  3428. }
  3429. // ResetWxWxid resets all changes to the "wx_wxid" field.
  3430. func (m *ContactMutation) ResetWxWxid() {
  3431. m.wx_wxid = nil
  3432. delete(m.clearedFields, contact.FieldWxWxid)
  3433. }
  3434. // SetType sets the "type" field.
  3435. func (m *ContactMutation) SetType(i int) {
  3436. m._type = &i
  3437. m.add_type = nil
  3438. }
  3439. // GetType returns the value of the "type" field in the mutation.
  3440. func (m *ContactMutation) GetType() (r int, exists bool) {
  3441. v := m._type
  3442. if v == nil {
  3443. return
  3444. }
  3445. return *v, true
  3446. }
  3447. // OldType returns the old "type" field's value of the Contact entity.
  3448. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3450. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  3451. if !m.op.Is(OpUpdateOne) {
  3452. return v, errors.New("OldType is only allowed on UpdateOne operations")
  3453. }
  3454. if m.id == nil || m.oldValue == nil {
  3455. return v, errors.New("OldType requires an ID field in the mutation")
  3456. }
  3457. oldValue, err := m.oldValue(ctx)
  3458. if err != nil {
  3459. return v, fmt.Errorf("querying old value for OldType: %w", err)
  3460. }
  3461. return oldValue.Type, nil
  3462. }
  3463. // AddType adds i to the "type" field.
  3464. func (m *ContactMutation) AddType(i int) {
  3465. if m.add_type != nil {
  3466. *m.add_type += i
  3467. } else {
  3468. m.add_type = &i
  3469. }
  3470. }
  3471. // AddedType returns the value that was added to the "type" field in this mutation.
  3472. func (m *ContactMutation) AddedType() (r int, exists bool) {
  3473. v := m.add_type
  3474. if v == nil {
  3475. return
  3476. }
  3477. return *v, true
  3478. }
  3479. // ClearType clears the value of the "type" field.
  3480. func (m *ContactMutation) ClearType() {
  3481. m._type = nil
  3482. m.add_type = nil
  3483. m.clearedFields[contact.FieldType] = struct{}{}
  3484. }
  3485. // TypeCleared returns if the "type" field was cleared in this mutation.
  3486. func (m *ContactMutation) TypeCleared() bool {
  3487. _, ok := m.clearedFields[contact.FieldType]
  3488. return ok
  3489. }
  3490. // ResetType resets all changes to the "type" field.
  3491. func (m *ContactMutation) ResetType() {
  3492. m._type = nil
  3493. m.add_type = nil
  3494. delete(m.clearedFields, contact.FieldType)
  3495. }
  3496. // SetWxid sets the "wxid" field.
  3497. func (m *ContactMutation) SetWxid(s string) {
  3498. m.wxid = &s
  3499. }
  3500. // Wxid returns the value of the "wxid" field in the mutation.
  3501. func (m *ContactMutation) Wxid() (r string, exists bool) {
  3502. v := m.wxid
  3503. if v == nil {
  3504. return
  3505. }
  3506. return *v, true
  3507. }
  3508. // OldWxid returns the old "wxid" field's value of the Contact entity.
  3509. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3511. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  3512. if !m.op.Is(OpUpdateOne) {
  3513. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  3514. }
  3515. if m.id == nil || m.oldValue == nil {
  3516. return v, errors.New("OldWxid requires an ID field in the mutation")
  3517. }
  3518. oldValue, err := m.oldValue(ctx)
  3519. if err != nil {
  3520. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  3521. }
  3522. return oldValue.Wxid, nil
  3523. }
  3524. // ResetWxid resets all changes to the "wxid" field.
  3525. func (m *ContactMutation) ResetWxid() {
  3526. m.wxid = nil
  3527. }
  3528. // SetAccount sets the "account" field.
  3529. func (m *ContactMutation) SetAccount(s string) {
  3530. m.account = &s
  3531. }
  3532. // Account returns the value of the "account" field in the mutation.
  3533. func (m *ContactMutation) Account() (r string, exists bool) {
  3534. v := m.account
  3535. if v == nil {
  3536. return
  3537. }
  3538. return *v, true
  3539. }
  3540. // OldAccount returns the old "account" field's value of the Contact entity.
  3541. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3543. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  3544. if !m.op.Is(OpUpdateOne) {
  3545. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  3546. }
  3547. if m.id == nil || m.oldValue == nil {
  3548. return v, errors.New("OldAccount requires an ID field in the mutation")
  3549. }
  3550. oldValue, err := m.oldValue(ctx)
  3551. if err != nil {
  3552. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  3553. }
  3554. return oldValue.Account, nil
  3555. }
  3556. // ResetAccount resets all changes to the "account" field.
  3557. func (m *ContactMutation) ResetAccount() {
  3558. m.account = nil
  3559. }
  3560. // SetNickname sets the "nickname" field.
  3561. func (m *ContactMutation) SetNickname(s string) {
  3562. m.nickname = &s
  3563. }
  3564. // Nickname returns the value of the "nickname" field in the mutation.
  3565. func (m *ContactMutation) Nickname() (r string, exists bool) {
  3566. v := m.nickname
  3567. if v == nil {
  3568. return
  3569. }
  3570. return *v, true
  3571. }
  3572. // OldNickname returns the old "nickname" field's value of the Contact entity.
  3573. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3574. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3575. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  3576. if !m.op.Is(OpUpdateOne) {
  3577. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  3578. }
  3579. if m.id == nil || m.oldValue == nil {
  3580. return v, errors.New("OldNickname requires an ID field in the mutation")
  3581. }
  3582. oldValue, err := m.oldValue(ctx)
  3583. if err != nil {
  3584. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  3585. }
  3586. return oldValue.Nickname, nil
  3587. }
  3588. // ResetNickname resets all changes to the "nickname" field.
  3589. func (m *ContactMutation) ResetNickname() {
  3590. m.nickname = nil
  3591. }
  3592. // SetMarkname sets the "markname" field.
  3593. func (m *ContactMutation) SetMarkname(s string) {
  3594. m.markname = &s
  3595. }
  3596. // Markname returns the value of the "markname" field in the mutation.
  3597. func (m *ContactMutation) Markname() (r string, exists bool) {
  3598. v := m.markname
  3599. if v == nil {
  3600. return
  3601. }
  3602. return *v, true
  3603. }
  3604. // OldMarkname returns the old "markname" field's value of the Contact entity.
  3605. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3607. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  3608. if !m.op.Is(OpUpdateOne) {
  3609. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  3610. }
  3611. if m.id == nil || m.oldValue == nil {
  3612. return v, errors.New("OldMarkname requires an ID field in the mutation")
  3613. }
  3614. oldValue, err := m.oldValue(ctx)
  3615. if err != nil {
  3616. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  3617. }
  3618. return oldValue.Markname, nil
  3619. }
  3620. // ResetMarkname resets all changes to the "markname" field.
  3621. func (m *ContactMutation) ResetMarkname() {
  3622. m.markname = nil
  3623. }
  3624. // SetHeadimg sets the "headimg" field.
  3625. func (m *ContactMutation) SetHeadimg(s string) {
  3626. m.headimg = &s
  3627. }
  3628. // Headimg returns the value of the "headimg" field in the mutation.
  3629. func (m *ContactMutation) Headimg() (r string, exists bool) {
  3630. v := m.headimg
  3631. if v == nil {
  3632. return
  3633. }
  3634. return *v, true
  3635. }
  3636. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  3637. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3639. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  3640. if !m.op.Is(OpUpdateOne) {
  3641. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  3642. }
  3643. if m.id == nil || m.oldValue == nil {
  3644. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  3645. }
  3646. oldValue, err := m.oldValue(ctx)
  3647. if err != nil {
  3648. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  3649. }
  3650. return oldValue.Headimg, nil
  3651. }
  3652. // ResetHeadimg resets all changes to the "headimg" field.
  3653. func (m *ContactMutation) ResetHeadimg() {
  3654. m.headimg = nil
  3655. }
  3656. // SetSex sets the "sex" field.
  3657. func (m *ContactMutation) SetSex(i int) {
  3658. m.sex = &i
  3659. m.addsex = nil
  3660. }
  3661. // Sex returns the value of the "sex" field in the mutation.
  3662. func (m *ContactMutation) Sex() (r int, exists bool) {
  3663. v := m.sex
  3664. if v == nil {
  3665. return
  3666. }
  3667. return *v, true
  3668. }
  3669. // OldSex returns the old "sex" field's value of the Contact entity.
  3670. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3672. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  3673. if !m.op.Is(OpUpdateOne) {
  3674. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  3675. }
  3676. if m.id == nil || m.oldValue == nil {
  3677. return v, errors.New("OldSex requires an ID field in the mutation")
  3678. }
  3679. oldValue, err := m.oldValue(ctx)
  3680. if err != nil {
  3681. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  3682. }
  3683. return oldValue.Sex, nil
  3684. }
  3685. // AddSex adds i to the "sex" field.
  3686. func (m *ContactMutation) AddSex(i int) {
  3687. if m.addsex != nil {
  3688. *m.addsex += i
  3689. } else {
  3690. m.addsex = &i
  3691. }
  3692. }
  3693. // AddedSex returns the value that was added to the "sex" field in this mutation.
  3694. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  3695. v := m.addsex
  3696. if v == nil {
  3697. return
  3698. }
  3699. return *v, true
  3700. }
  3701. // ResetSex resets all changes to the "sex" field.
  3702. func (m *ContactMutation) ResetSex() {
  3703. m.sex = nil
  3704. m.addsex = nil
  3705. }
  3706. // SetStarrole sets the "starrole" field.
  3707. func (m *ContactMutation) SetStarrole(s string) {
  3708. m.starrole = &s
  3709. }
  3710. // Starrole returns the value of the "starrole" field in the mutation.
  3711. func (m *ContactMutation) Starrole() (r string, exists bool) {
  3712. v := m.starrole
  3713. if v == nil {
  3714. return
  3715. }
  3716. return *v, true
  3717. }
  3718. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  3719. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3721. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  3722. if !m.op.Is(OpUpdateOne) {
  3723. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  3724. }
  3725. if m.id == nil || m.oldValue == nil {
  3726. return v, errors.New("OldStarrole requires an ID field in the mutation")
  3727. }
  3728. oldValue, err := m.oldValue(ctx)
  3729. if err != nil {
  3730. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  3731. }
  3732. return oldValue.Starrole, nil
  3733. }
  3734. // ResetStarrole resets all changes to the "starrole" field.
  3735. func (m *ContactMutation) ResetStarrole() {
  3736. m.starrole = nil
  3737. }
  3738. // SetDontseeit sets the "dontseeit" field.
  3739. func (m *ContactMutation) SetDontseeit(i int) {
  3740. m.dontseeit = &i
  3741. m.adddontseeit = nil
  3742. }
  3743. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  3744. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  3745. v := m.dontseeit
  3746. if v == nil {
  3747. return
  3748. }
  3749. return *v, true
  3750. }
  3751. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  3752. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3754. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  3755. if !m.op.Is(OpUpdateOne) {
  3756. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  3757. }
  3758. if m.id == nil || m.oldValue == nil {
  3759. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  3760. }
  3761. oldValue, err := m.oldValue(ctx)
  3762. if err != nil {
  3763. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  3764. }
  3765. return oldValue.Dontseeit, nil
  3766. }
  3767. // AddDontseeit adds i to the "dontseeit" field.
  3768. func (m *ContactMutation) AddDontseeit(i int) {
  3769. if m.adddontseeit != nil {
  3770. *m.adddontseeit += i
  3771. } else {
  3772. m.adddontseeit = &i
  3773. }
  3774. }
  3775. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  3776. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  3777. v := m.adddontseeit
  3778. if v == nil {
  3779. return
  3780. }
  3781. return *v, true
  3782. }
  3783. // ResetDontseeit resets all changes to the "dontseeit" field.
  3784. func (m *ContactMutation) ResetDontseeit() {
  3785. m.dontseeit = nil
  3786. m.adddontseeit = nil
  3787. }
  3788. // SetDontseeme sets the "dontseeme" field.
  3789. func (m *ContactMutation) SetDontseeme(i int) {
  3790. m.dontseeme = &i
  3791. m.adddontseeme = nil
  3792. }
  3793. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  3794. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  3795. v := m.dontseeme
  3796. if v == nil {
  3797. return
  3798. }
  3799. return *v, true
  3800. }
  3801. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  3802. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3803. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3804. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  3805. if !m.op.Is(OpUpdateOne) {
  3806. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  3807. }
  3808. if m.id == nil || m.oldValue == nil {
  3809. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  3810. }
  3811. oldValue, err := m.oldValue(ctx)
  3812. if err != nil {
  3813. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  3814. }
  3815. return oldValue.Dontseeme, nil
  3816. }
  3817. // AddDontseeme adds i to the "dontseeme" field.
  3818. func (m *ContactMutation) AddDontseeme(i int) {
  3819. if m.adddontseeme != nil {
  3820. *m.adddontseeme += i
  3821. } else {
  3822. m.adddontseeme = &i
  3823. }
  3824. }
  3825. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  3826. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  3827. v := m.adddontseeme
  3828. if v == nil {
  3829. return
  3830. }
  3831. return *v, true
  3832. }
  3833. // ResetDontseeme resets all changes to the "dontseeme" field.
  3834. func (m *ContactMutation) ResetDontseeme() {
  3835. m.dontseeme = nil
  3836. m.adddontseeme = nil
  3837. }
  3838. // SetLag sets the "lag" field.
  3839. func (m *ContactMutation) SetLag(s string) {
  3840. m.lag = &s
  3841. }
  3842. // Lag returns the value of the "lag" field in the mutation.
  3843. func (m *ContactMutation) Lag() (r string, exists bool) {
  3844. v := m.lag
  3845. if v == nil {
  3846. return
  3847. }
  3848. return *v, true
  3849. }
  3850. // OldLag returns the old "lag" field's value of the Contact entity.
  3851. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3853. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  3854. if !m.op.Is(OpUpdateOne) {
  3855. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  3856. }
  3857. if m.id == nil || m.oldValue == nil {
  3858. return v, errors.New("OldLag requires an ID field in the mutation")
  3859. }
  3860. oldValue, err := m.oldValue(ctx)
  3861. if err != nil {
  3862. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  3863. }
  3864. return oldValue.Lag, nil
  3865. }
  3866. // ResetLag resets all changes to the "lag" field.
  3867. func (m *ContactMutation) ResetLag() {
  3868. m.lag = nil
  3869. }
  3870. // SetGid sets the "gid" field.
  3871. func (m *ContactMutation) SetGid(s string) {
  3872. m.gid = &s
  3873. }
  3874. // Gid returns the value of the "gid" field in the mutation.
  3875. func (m *ContactMutation) Gid() (r string, exists bool) {
  3876. v := m.gid
  3877. if v == nil {
  3878. return
  3879. }
  3880. return *v, true
  3881. }
  3882. // OldGid returns the old "gid" field's value of the Contact entity.
  3883. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3884. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3885. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  3886. if !m.op.Is(OpUpdateOne) {
  3887. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  3888. }
  3889. if m.id == nil || m.oldValue == nil {
  3890. return v, errors.New("OldGid requires an ID field in the mutation")
  3891. }
  3892. oldValue, err := m.oldValue(ctx)
  3893. if err != nil {
  3894. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  3895. }
  3896. return oldValue.Gid, nil
  3897. }
  3898. // ResetGid resets all changes to the "gid" field.
  3899. func (m *ContactMutation) ResetGid() {
  3900. m.gid = nil
  3901. }
  3902. // SetGname sets the "gname" field.
  3903. func (m *ContactMutation) SetGname(s string) {
  3904. m.gname = &s
  3905. }
  3906. // Gname returns the value of the "gname" field in the mutation.
  3907. func (m *ContactMutation) Gname() (r string, exists bool) {
  3908. v := m.gname
  3909. if v == nil {
  3910. return
  3911. }
  3912. return *v, true
  3913. }
  3914. // OldGname returns the old "gname" field's value of the Contact entity.
  3915. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3917. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  3918. if !m.op.Is(OpUpdateOne) {
  3919. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  3920. }
  3921. if m.id == nil || m.oldValue == nil {
  3922. return v, errors.New("OldGname requires an ID field in the mutation")
  3923. }
  3924. oldValue, err := m.oldValue(ctx)
  3925. if err != nil {
  3926. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  3927. }
  3928. return oldValue.Gname, nil
  3929. }
  3930. // ResetGname resets all changes to the "gname" field.
  3931. func (m *ContactMutation) ResetGname() {
  3932. m.gname = nil
  3933. }
  3934. // SetV3 sets the "v3" field.
  3935. func (m *ContactMutation) SetV3(s string) {
  3936. m.v3 = &s
  3937. }
  3938. // V3 returns the value of the "v3" field in the mutation.
  3939. func (m *ContactMutation) V3() (r string, exists bool) {
  3940. v := m.v3
  3941. if v == nil {
  3942. return
  3943. }
  3944. return *v, true
  3945. }
  3946. // OldV3 returns the old "v3" field's value of the Contact entity.
  3947. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3949. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  3950. if !m.op.Is(OpUpdateOne) {
  3951. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  3952. }
  3953. if m.id == nil || m.oldValue == nil {
  3954. return v, errors.New("OldV3 requires an ID field in the mutation")
  3955. }
  3956. oldValue, err := m.oldValue(ctx)
  3957. if err != nil {
  3958. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  3959. }
  3960. return oldValue.V3, nil
  3961. }
  3962. // ResetV3 resets all changes to the "v3" field.
  3963. func (m *ContactMutation) ResetV3() {
  3964. m.v3 = nil
  3965. }
  3966. // SetOrganizationID sets the "organization_id" field.
  3967. func (m *ContactMutation) SetOrganizationID(u uint64) {
  3968. m.organization_id = &u
  3969. m.addorganization_id = nil
  3970. }
  3971. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3972. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  3973. v := m.organization_id
  3974. if v == nil {
  3975. return
  3976. }
  3977. return *v, true
  3978. }
  3979. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  3980. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3981. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3982. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3983. if !m.op.Is(OpUpdateOne) {
  3984. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3985. }
  3986. if m.id == nil || m.oldValue == nil {
  3987. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3988. }
  3989. oldValue, err := m.oldValue(ctx)
  3990. if err != nil {
  3991. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3992. }
  3993. return oldValue.OrganizationID, nil
  3994. }
  3995. // AddOrganizationID adds u to the "organization_id" field.
  3996. func (m *ContactMutation) AddOrganizationID(u int64) {
  3997. if m.addorganization_id != nil {
  3998. *m.addorganization_id += u
  3999. } else {
  4000. m.addorganization_id = &u
  4001. }
  4002. }
  4003. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4004. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  4005. v := m.addorganization_id
  4006. if v == nil {
  4007. return
  4008. }
  4009. return *v, true
  4010. }
  4011. // ClearOrganizationID clears the value of the "organization_id" field.
  4012. func (m *ContactMutation) ClearOrganizationID() {
  4013. m.organization_id = nil
  4014. m.addorganization_id = nil
  4015. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  4016. }
  4017. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  4018. func (m *ContactMutation) OrganizationIDCleared() bool {
  4019. _, ok := m.clearedFields[contact.FieldOrganizationID]
  4020. return ok
  4021. }
  4022. // ResetOrganizationID resets all changes to the "organization_id" field.
  4023. func (m *ContactMutation) ResetOrganizationID() {
  4024. m.organization_id = nil
  4025. m.addorganization_id = nil
  4026. delete(m.clearedFields, contact.FieldOrganizationID)
  4027. }
  4028. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  4029. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  4030. if m.contact_relationships == nil {
  4031. m.contact_relationships = make(map[uint64]struct{})
  4032. }
  4033. for i := range ids {
  4034. m.contact_relationships[ids[i]] = struct{}{}
  4035. }
  4036. }
  4037. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  4038. func (m *ContactMutation) ClearContactRelationships() {
  4039. m.clearedcontact_relationships = true
  4040. }
  4041. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  4042. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  4043. return m.clearedcontact_relationships
  4044. }
  4045. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  4046. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  4047. if m.removedcontact_relationships == nil {
  4048. m.removedcontact_relationships = make(map[uint64]struct{})
  4049. }
  4050. for i := range ids {
  4051. delete(m.contact_relationships, ids[i])
  4052. m.removedcontact_relationships[ids[i]] = struct{}{}
  4053. }
  4054. }
  4055. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  4056. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  4057. for id := range m.removedcontact_relationships {
  4058. ids = append(ids, id)
  4059. }
  4060. return
  4061. }
  4062. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  4063. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  4064. for id := range m.contact_relationships {
  4065. ids = append(ids, id)
  4066. }
  4067. return
  4068. }
  4069. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  4070. func (m *ContactMutation) ResetContactRelationships() {
  4071. m.contact_relationships = nil
  4072. m.clearedcontact_relationships = false
  4073. m.removedcontact_relationships = nil
  4074. }
  4075. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  4076. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  4077. if m.contact_messages == nil {
  4078. m.contact_messages = make(map[uint64]struct{})
  4079. }
  4080. for i := range ids {
  4081. m.contact_messages[ids[i]] = struct{}{}
  4082. }
  4083. }
  4084. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  4085. func (m *ContactMutation) ClearContactMessages() {
  4086. m.clearedcontact_messages = true
  4087. }
  4088. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  4089. func (m *ContactMutation) ContactMessagesCleared() bool {
  4090. return m.clearedcontact_messages
  4091. }
  4092. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  4093. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  4094. if m.removedcontact_messages == nil {
  4095. m.removedcontact_messages = make(map[uint64]struct{})
  4096. }
  4097. for i := range ids {
  4098. delete(m.contact_messages, ids[i])
  4099. m.removedcontact_messages[ids[i]] = struct{}{}
  4100. }
  4101. }
  4102. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  4103. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  4104. for id := range m.removedcontact_messages {
  4105. ids = append(ids, id)
  4106. }
  4107. return
  4108. }
  4109. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  4110. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  4111. for id := range m.contact_messages {
  4112. ids = append(ids, id)
  4113. }
  4114. return
  4115. }
  4116. // ResetContactMessages resets all changes to the "contact_messages" edge.
  4117. func (m *ContactMutation) ResetContactMessages() {
  4118. m.contact_messages = nil
  4119. m.clearedcontact_messages = false
  4120. m.removedcontact_messages = nil
  4121. }
  4122. // Where appends a list predicates to the ContactMutation builder.
  4123. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  4124. m.predicates = append(m.predicates, ps...)
  4125. }
  4126. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  4127. // users can use type-assertion to append predicates that do not depend on any generated package.
  4128. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  4129. p := make([]predicate.Contact, len(ps))
  4130. for i := range ps {
  4131. p[i] = ps[i]
  4132. }
  4133. m.Where(p...)
  4134. }
  4135. // Op returns the operation name.
  4136. func (m *ContactMutation) Op() Op {
  4137. return m.op
  4138. }
  4139. // SetOp allows setting the mutation operation.
  4140. func (m *ContactMutation) SetOp(op Op) {
  4141. m.op = op
  4142. }
  4143. // Type returns the node type of this mutation (Contact).
  4144. func (m *ContactMutation) Type() string {
  4145. return m.typ
  4146. }
  4147. // Fields returns all fields that were changed during this mutation. Note that in
  4148. // order to get all numeric fields that were incremented/decremented, call
  4149. // AddedFields().
  4150. func (m *ContactMutation) Fields() []string {
  4151. fields := make([]string, 0, 20)
  4152. if m.created_at != nil {
  4153. fields = append(fields, contact.FieldCreatedAt)
  4154. }
  4155. if m.updated_at != nil {
  4156. fields = append(fields, contact.FieldUpdatedAt)
  4157. }
  4158. if m.status != nil {
  4159. fields = append(fields, contact.FieldStatus)
  4160. }
  4161. if m.deleted_at != nil {
  4162. fields = append(fields, contact.FieldDeletedAt)
  4163. }
  4164. if m.wx_wxid != nil {
  4165. fields = append(fields, contact.FieldWxWxid)
  4166. }
  4167. if m._type != nil {
  4168. fields = append(fields, contact.FieldType)
  4169. }
  4170. if m.wxid != nil {
  4171. fields = append(fields, contact.FieldWxid)
  4172. }
  4173. if m.account != nil {
  4174. fields = append(fields, contact.FieldAccount)
  4175. }
  4176. if m.nickname != nil {
  4177. fields = append(fields, contact.FieldNickname)
  4178. }
  4179. if m.markname != nil {
  4180. fields = append(fields, contact.FieldMarkname)
  4181. }
  4182. if m.headimg != nil {
  4183. fields = append(fields, contact.FieldHeadimg)
  4184. }
  4185. if m.sex != nil {
  4186. fields = append(fields, contact.FieldSex)
  4187. }
  4188. if m.starrole != nil {
  4189. fields = append(fields, contact.FieldStarrole)
  4190. }
  4191. if m.dontseeit != nil {
  4192. fields = append(fields, contact.FieldDontseeit)
  4193. }
  4194. if m.dontseeme != nil {
  4195. fields = append(fields, contact.FieldDontseeme)
  4196. }
  4197. if m.lag != nil {
  4198. fields = append(fields, contact.FieldLag)
  4199. }
  4200. if m.gid != nil {
  4201. fields = append(fields, contact.FieldGid)
  4202. }
  4203. if m.gname != nil {
  4204. fields = append(fields, contact.FieldGname)
  4205. }
  4206. if m.v3 != nil {
  4207. fields = append(fields, contact.FieldV3)
  4208. }
  4209. if m.organization_id != nil {
  4210. fields = append(fields, contact.FieldOrganizationID)
  4211. }
  4212. return fields
  4213. }
  4214. // Field returns the value of a field with the given name. The second boolean
  4215. // return value indicates that this field was not set, or was not defined in the
  4216. // schema.
  4217. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  4218. switch name {
  4219. case contact.FieldCreatedAt:
  4220. return m.CreatedAt()
  4221. case contact.FieldUpdatedAt:
  4222. return m.UpdatedAt()
  4223. case contact.FieldStatus:
  4224. return m.Status()
  4225. case contact.FieldDeletedAt:
  4226. return m.DeletedAt()
  4227. case contact.FieldWxWxid:
  4228. return m.WxWxid()
  4229. case contact.FieldType:
  4230. return m.GetType()
  4231. case contact.FieldWxid:
  4232. return m.Wxid()
  4233. case contact.FieldAccount:
  4234. return m.Account()
  4235. case contact.FieldNickname:
  4236. return m.Nickname()
  4237. case contact.FieldMarkname:
  4238. return m.Markname()
  4239. case contact.FieldHeadimg:
  4240. return m.Headimg()
  4241. case contact.FieldSex:
  4242. return m.Sex()
  4243. case contact.FieldStarrole:
  4244. return m.Starrole()
  4245. case contact.FieldDontseeit:
  4246. return m.Dontseeit()
  4247. case contact.FieldDontseeme:
  4248. return m.Dontseeme()
  4249. case contact.FieldLag:
  4250. return m.Lag()
  4251. case contact.FieldGid:
  4252. return m.Gid()
  4253. case contact.FieldGname:
  4254. return m.Gname()
  4255. case contact.FieldV3:
  4256. return m.V3()
  4257. case contact.FieldOrganizationID:
  4258. return m.OrganizationID()
  4259. }
  4260. return nil, false
  4261. }
  4262. // OldField returns the old value of the field from the database. An error is
  4263. // returned if the mutation operation is not UpdateOne, or the query to the
  4264. // database failed.
  4265. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4266. switch name {
  4267. case contact.FieldCreatedAt:
  4268. return m.OldCreatedAt(ctx)
  4269. case contact.FieldUpdatedAt:
  4270. return m.OldUpdatedAt(ctx)
  4271. case contact.FieldStatus:
  4272. return m.OldStatus(ctx)
  4273. case contact.FieldDeletedAt:
  4274. return m.OldDeletedAt(ctx)
  4275. case contact.FieldWxWxid:
  4276. return m.OldWxWxid(ctx)
  4277. case contact.FieldType:
  4278. return m.OldType(ctx)
  4279. case contact.FieldWxid:
  4280. return m.OldWxid(ctx)
  4281. case contact.FieldAccount:
  4282. return m.OldAccount(ctx)
  4283. case contact.FieldNickname:
  4284. return m.OldNickname(ctx)
  4285. case contact.FieldMarkname:
  4286. return m.OldMarkname(ctx)
  4287. case contact.FieldHeadimg:
  4288. return m.OldHeadimg(ctx)
  4289. case contact.FieldSex:
  4290. return m.OldSex(ctx)
  4291. case contact.FieldStarrole:
  4292. return m.OldStarrole(ctx)
  4293. case contact.FieldDontseeit:
  4294. return m.OldDontseeit(ctx)
  4295. case contact.FieldDontseeme:
  4296. return m.OldDontseeme(ctx)
  4297. case contact.FieldLag:
  4298. return m.OldLag(ctx)
  4299. case contact.FieldGid:
  4300. return m.OldGid(ctx)
  4301. case contact.FieldGname:
  4302. return m.OldGname(ctx)
  4303. case contact.FieldV3:
  4304. return m.OldV3(ctx)
  4305. case contact.FieldOrganizationID:
  4306. return m.OldOrganizationID(ctx)
  4307. }
  4308. return nil, fmt.Errorf("unknown Contact field %s", name)
  4309. }
  4310. // SetField sets the value of a field with the given name. It returns an error if
  4311. // the field is not defined in the schema, or if the type mismatched the field
  4312. // type.
  4313. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  4314. switch name {
  4315. case contact.FieldCreatedAt:
  4316. v, ok := value.(time.Time)
  4317. if !ok {
  4318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4319. }
  4320. m.SetCreatedAt(v)
  4321. return nil
  4322. case contact.FieldUpdatedAt:
  4323. v, ok := value.(time.Time)
  4324. if !ok {
  4325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4326. }
  4327. m.SetUpdatedAt(v)
  4328. return nil
  4329. case contact.FieldStatus:
  4330. v, ok := value.(uint8)
  4331. if !ok {
  4332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4333. }
  4334. m.SetStatus(v)
  4335. return nil
  4336. case contact.FieldDeletedAt:
  4337. v, ok := value.(time.Time)
  4338. if !ok {
  4339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4340. }
  4341. m.SetDeletedAt(v)
  4342. return nil
  4343. case contact.FieldWxWxid:
  4344. v, ok := value.(string)
  4345. if !ok {
  4346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4347. }
  4348. m.SetWxWxid(v)
  4349. return nil
  4350. case contact.FieldType:
  4351. v, ok := value.(int)
  4352. if !ok {
  4353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4354. }
  4355. m.SetType(v)
  4356. return nil
  4357. case contact.FieldWxid:
  4358. v, ok := value.(string)
  4359. if !ok {
  4360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4361. }
  4362. m.SetWxid(v)
  4363. return nil
  4364. case contact.FieldAccount:
  4365. v, ok := value.(string)
  4366. if !ok {
  4367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4368. }
  4369. m.SetAccount(v)
  4370. return nil
  4371. case contact.FieldNickname:
  4372. v, ok := value.(string)
  4373. if !ok {
  4374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4375. }
  4376. m.SetNickname(v)
  4377. return nil
  4378. case contact.FieldMarkname:
  4379. v, ok := value.(string)
  4380. if !ok {
  4381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4382. }
  4383. m.SetMarkname(v)
  4384. return nil
  4385. case contact.FieldHeadimg:
  4386. v, ok := value.(string)
  4387. if !ok {
  4388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4389. }
  4390. m.SetHeadimg(v)
  4391. return nil
  4392. case contact.FieldSex:
  4393. v, ok := value.(int)
  4394. if !ok {
  4395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4396. }
  4397. m.SetSex(v)
  4398. return nil
  4399. case contact.FieldStarrole:
  4400. v, ok := value.(string)
  4401. if !ok {
  4402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4403. }
  4404. m.SetStarrole(v)
  4405. return nil
  4406. case contact.FieldDontseeit:
  4407. v, ok := value.(int)
  4408. if !ok {
  4409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4410. }
  4411. m.SetDontseeit(v)
  4412. return nil
  4413. case contact.FieldDontseeme:
  4414. v, ok := value.(int)
  4415. if !ok {
  4416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4417. }
  4418. m.SetDontseeme(v)
  4419. return nil
  4420. case contact.FieldLag:
  4421. v, ok := value.(string)
  4422. if !ok {
  4423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4424. }
  4425. m.SetLag(v)
  4426. return nil
  4427. case contact.FieldGid:
  4428. v, ok := value.(string)
  4429. if !ok {
  4430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4431. }
  4432. m.SetGid(v)
  4433. return nil
  4434. case contact.FieldGname:
  4435. v, ok := value.(string)
  4436. if !ok {
  4437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4438. }
  4439. m.SetGname(v)
  4440. return nil
  4441. case contact.FieldV3:
  4442. v, ok := value.(string)
  4443. if !ok {
  4444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4445. }
  4446. m.SetV3(v)
  4447. return nil
  4448. case contact.FieldOrganizationID:
  4449. v, ok := value.(uint64)
  4450. if !ok {
  4451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4452. }
  4453. m.SetOrganizationID(v)
  4454. return nil
  4455. }
  4456. return fmt.Errorf("unknown Contact field %s", name)
  4457. }
  4458. // AddedFields returns all numeric fields that were incremented/decremented during
  4459. // this mutation.
  4460. func (m *ContactMutation) AddedFields() []string {
  4461. var fields []string
  4462. if m.addstatus != nil {
  4463. fields = append(fields, contact.FieldStatus)
  4464. }
  4465. if m.add_type != nil {
  4466. fields = append(fields, contact.FieldType)
  4467. }
  4468. if m.addsex != nil {
  4469. fields = append(fields, contact.FieldSex)
  4470. }
  4471. if m.adddontseeit != nil {
  4472. fields = append(fields, contact.FieldDontseeit)
  4473. }
  4474. if m.adddontseeme != nil {
  4475. fields = append(fields, contact.FieldDontseeme)
  4476. }
  4477. if m.addorganization_id != nil {
  4478. fields = append(fields, contact.FieldOrganizationID)
  4479. }
  4480. return fields
  4481. }
  4482. // AddedField returns the numeric value that was incremented/decremented on a field
  4483. // with the given name. The second boolean return value indicates that this field
  4484. // was not set, or was not defined in the schema.
  4485. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  4486. switch name {
  4487. case contact.FieldStatus:
  4488. return m.AddedStatus()
  4489. case contact.FieldType:
  4490. return m.AddedType()
  4491. case contact.FieldSex:
  4492. return m.AddedSex()
  4493. case contact.FieldDontseeit:
  4494. return m.AddedDontseeit()
  4495. case contact.FieldDontseeme:
  4496. return m.AddedDontseeme()
  4497. case contact.FieldOrganizationID:
  4498. return m.AddedOrganizationID()
  4499. }
  4500. return nil, false
  4501. }
  4502. // AddField adds the value to the field with the given name. It returns an error if
  4503. // the field is not defined in the schema, or if the type mismatched the field
  4504. // type.
  4505. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  4506. switch name {
  4507. case contact.FieldStatus:
  4508. v, ok := value.(int8)
  4509. if !ok {
  4510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4511. }
  4512. m.AddStatus(v)
  4513. return nil
  4514. case contact.FieldType:
  4515. v, ok := value.(int)
  4516. if !ok {
  4517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4518. }
  4519. m.AddType(v)
  4520. return nil
  4521. case contact.FieldSex:
  4522. v, ok := value.(int)
  4523. if !ok {
  4524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4525. }
  4526. m.AddSex(v)
  4527. return nil
  4528. case contact.FieldDontseeit:
  4529. v, ok := value.(int)
  4530. if !ok {
  4531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4532. }
  4533. m.AddDontseeit(v)
  4534. return nil
  4535. case contact.FieldDontseeme:
  4536. v, ok := value.(int)
  4537. if !ok {
  4538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4539. }
  4540. m.AddDontseeme(v)
  4541. return nil
  4542. case contact.FieldOrganizationID:
  4543. v, ok := value.(int64)
  4544. if !ok {
  4545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4546. }
  4547. m.AddOrganizationID(v)
  4548. return nil
  4549. }
  4550. return fmt.Errorf("unknown Contact numeric field %s", name)
  4551. }
  4552. // ClearedFields returns all nullable fields that were cleared during this
  4553. // mutation.
  4554. func (m *ContactMutation) ClearedFields() []string {
  4555. var fields []string
  4556. if m.FieldCleared(contact.FieldStatus) {
  4557. fields = append(fields, contact.FieldStatus)
  4558. }
  4559. if m.FieldCleared(contact.FieldDeletedAt) {
  4560. fields = append(fields, contact.FieldDeletedAt)
  4561. }
  4562. if m.FieldCleared(contact.FieldWxWxid) {
  4563. fields = append(fields, contact.FieldWxWxid)
  4564. }
  4565. if m.FieldCleared(contact.FieldType) {
  4566. fields = append(fields, contact.FieldType)
  4567. }
  4568. if m.FieldCleared(contact.FieldOrganizationID) {
  4569. fields = append(fields, contact.FieldOrganizationID)
  4570. }
  4571. return fields
  4572. }
  4573. // FieldCleared returns a boolean indicating if a field with the given name was
  4574. // cleared in this mutation.
  4575. func (m *ContactMutation) FieldCleared(name string) bool {
  4576. _, ok := m.clearedFields[name]
  4577. return ok
  4578. }
  4579. // ClearField clears the value of the field with the given name. It returns an
  4580. // error if the field is not defined in the schema.
  4581. func (m *ContactMutation) ClearField(name string) error {
  4582. switch name {
  4583. case contact.FieldStatus:
  4584. m.ClearStatus()
  4585. return nil
  4586. case contact.FieldDeletedAt:
  4587. m.ClearDeletedAt()
  4588. return nil
  4589. case contact.FieldWxWxid:
  4590. m.ClearWxWxid()
  4591. return nil
  4592. case contact.FieldType:
  4593. m.ClearType()
  4594. return nil
  4595. case contact.FieldOrganizationID:
  4596. m.ClearOrganizationID()
  4597. return nil
  4598. }
  4599. return fmt.Errorf("unknown Contact nullable field %s", name)
  4600. }
  4601. // ResetField resets all changes in the mutation for the field with the given name.
  4602. // It returns an error if the field is not defined in the schema.
  4603. func (m *ContactMutation) ResetField(name string) error {
  4604. switch name {
  4605. case contact.FieldCreatedAt:
  4606. m.ResetCreatedAt()
  4607. return nil
  4608. case contact.FieldUpdatedAt:
  4609. m.ResetUpdatedAt()
  4610. return nil
  4611. case contact.FieldStatus:
  4612. m.ResetStatus()
  4613. return nil
  4614. case contact.FieldDeletedAt:
  4615. m.ResetDeletedAt()
  4616. return nil
  4617. case contact.FieldWxWxid:
  4618. m.ResetWxWxid()
  4619. return nil
  4620. case contact.FieldType:
  4621. m.ResetType()
  4622. return nil
  4623. case contact.FieldWxid:
  4624. m.ResetWxid()
  4625. return nil
  4626. case contact.FieldAccount:
  4627. m.ResetAccount()
  4628. return nil
  4629. case contact.FieldNickname:
  4630. m.ResetNickname()
  4631. return nil
  4632. case contact.FieldMarkname:
  4633. m.ResetMarkname()
  4634. return nil
  4635. case contact.FieldHeadimg:
  4636. m.ResetHeadimg()
  4637. return nil
  4638. case contact.FieldSex:
  4639. m.ResetSex()
  4640. return nil
  4641. case contact.FieldStarrole:
  4642. m.ResetStarrole()
  4643. return nil
  4644. case contact.FieldDontseeit:
  4645. m.ResetDontseeit()
  4646. return nil
  4647. case contact.FieldDontseeme:
  4648. m.ResetDontseeme()
  4649. return nil
  4650. case contact.FieldLag:
  4651. m.ResetLag()
  4652. return nil
  4653. case contact.FieldGid:
  4654. m.ResetGid()
  4655. return nil
  4656. case contact.FieldGname:
  4657. m.ResetGname()
  4658. return nil
  4659. case contact.FieldV3:
  4660. m.ResetV3()
  4661. return nil
  4662. case contact.FieldOrganizationID:
  4663. m.ResetOrganizationID()
  4664. return nil
  4665. }
  4666. return fmt.Errorf("unknown Contact field %s", name)
  4667. }
  4668. // AddedEdges returns all edge names that were set/added in this mutation.
  4669. func (m *ContactMutation) AddedEdges() []string {
  4670. edges := make([]string, 0, 2)
  4671. if m.contact_relationships != nil {
  4672. edges = append(edges, contact.EdgeContactRelationships)
  4673. }
  4674. if m.contact_messages != nil {
  4675. edges = append(edges, contact.EdgeContactMessages)
  4676. }
  4677. return edges
  4678. }
  4679. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4680. // name in this mutation.
  4681. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  4682. switch name {
  4683. case contact.EdgeContactRelationships:
  4684. ids := make([]ent.Value, 0, len(m.contact_relationships))
  4685. for id := range m.contact_relationships {
  4686. ids = append(ids, id)
  4687. }
  4688. return ids
  4689. case contact.EdgeContactMessages:
  4690. ids := make([]ent.Value, 0, len(m.contact_messages))
  4691. for id := range m.contact_messages {
  4692. ids = append(ids, id)
  4693. }
  4694. return ids
  4695. }
  4696. return nil
  4697. }
  4698. // RemovedEdges returns all edge names that were removed in this mutation.
  4699. func (m *ContactMutation) RemovedEdges() []string {
  4700. edges := make([]string, 0, 2)
  4701. if m.removedcontact_relationships != nil {
  4702. edges = append(edges, contact.EdgeContactRelationships)
  4703. }
  4704. if m.removedcontact_messages != nil {
  4705. edges = append(edges, contact.EdgeContactMessages)
  4706. }
  4707. return edges
  4708. }
  4709. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4710. // the given name in this mutation.
  4711. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  4712. switch name {
  4713. case contact.EdgeContactRelationships:
  4714. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  4715. for id := range m.removedcontact_relationships {
  4716. ids = append(ids, id)
  4717. }
  4718. return ids
  4719. case contact.EdgeContactMessages:
  4720. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  4721. for id := range m.removedcontact_messages {
  4722. ids = append(ids, id)
  4723. }
  4724. return ids
  4725. }
  4726. return nil
  4727. }
  4728. // ClearedEdges returns all edge names that were cleared in this mutation.
  4729. func (m *ContactMutation) ClearedEdges() []string {
  4730. edges := make([]string, 0, 2)
  4731. if m.clearedcontact_relationships {
  4732. edges = append(edges, contact.EdgeContactRelationships)
  4733. }
  4734. if m.clearedcontact_messages {
  4735. edges = append(edges, contact.EdgeContactMessages)
  4736. }
  4737. return edges
  4738. }
  4739. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4740. // was cleared in this mutation.
  4741. func (m *ContactMutation) EdgeCleared(name string) bool {
  4742. switch name {
  4743. case contact.EdgeContactRelationships:
  4744. return m.clearedcontact_relationships
  4745. case contact.EdgeContactMessages:
  4746. return m.clearedcontact_messages
  4747. }
  4748. return false
  4749. }
  4750. // ClearEdge clears the value of the edge with the given name. It returns an error
  4751. // if that edge is not defined in the schema.
  4752. func (m *ContactMutation) ClearEdge(name string) error {
  4753. switch name {
  4754. }
  4755. return fmt.Errorf("unknown Contact unique edge %s", name)
  4756. }
  4757. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4758. // It returns an error if the edge is not defined in the schema.
  4759. func (m *ContactMutation) ResetEdge(name string) error {
  4760. switch name {
  4761. case contact.EdgeContactRelationships:
  4762. m.ResetContactRelationships()
  4763. return nil
  4764. case contact.EdgeContactMessages:
  4765. m.ResetContactMessages()
  4766. return nil
  4767. }
  4768. return fmt.Errorf("unknown Contact edge %s", name)
  4769. }
  4770. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  4771. type EmployeeMutation struct {
  4772. config
  4773. op Op
  4774. typ string
  4775. id *uint64
  4776. created_at *time.Time
  4777. updated_at *time.Time
  4778. deleted_at *time.Time
  4779. title *string
  4780. avatar *string
  4781. tags *string
  4782. hire_count *int
  4783. addhire_count *int
  4784. service_count *int
  4785. addservice_count *int
  4786. achievement_count *int
  4787. addachievement_count *int
  4788. intro *string
  4789. estimate *string
  4790. skill *string
  4791. ability_type *string
  4792. scene *string
  4793. switch_in *string
  4794. video_url *string
  4795. organization_id *uint64
  4796. addorganization_id *int64
  4797. category_id *uint64
  4798. addcategory_id *int64
  4799. clearedFields map[string]struct{}
  4800. em_work_experiences map[uint64]struct{}
  4801. removedem_work_experiences map[uint64]struct{}
  4802. clearedem_work_experiences bool
  4803. em_tutorial map[uint64]struct{}
  4804. removedem_tutorial map[uint64]struct{}
  4805. clearedem_tutorial bool
  4806. done bool
  4807. oldValue func(context.Context) (*Employee, error)
  4808. predicates []predicate.Employee
  4809. }
  4810. var _ ent.Mutation = (*EmployeeMutation)(nil)
  4811. // employeeOption allows management of the mutation configuration using functional options.
  4812. type employeeOption func(*EmployeeMutation)
  4813. // newEmployeeMutation creates new mutation for the Employee entity.
  4814. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  4815. m := &EmployeeMutation{
  4816. config: c,
  4817. op: op,
  4818. typ: TypeEmployee,
  4819. clearedFields: make(map[string]struct{}),
  4820. }
  4821. for _, opt := range opts {
  4822. opt(m)
  4823. }
  4824. return m
  4825. }
  4826. // withEmployeeID sets the ID field of the mutation.
  4827. func withEmployeeID(id uint64) employeeOption {
  4828. return func(m *EmployeeMutation) {
  4829. var (
  4830. err error
  4831. once sync.Once
  4832. value *Employee
  4833. )
  4834. m.oldValue = func(ctx context.Context) (*Employee, error) {
  4835. once.Do(func() {
  4836. if m.done {
  4837. err = errors.New("querying old values post mutation is not allowed")
  4838. } else {
  4839. value, err = m.Client().Employee.Get(ctx, id)
  4840. }
  4841. })
  4842. return value, err
  4843. }
  4844. m.id = &id
  4845. }
  4846. }
  4847. // withEmployee sets the old Employee of the mutation.
  4848. func withEmployee(node *Employee) employeeOption {
  4849. return func(m *EmployeeMutation) {
  4850. m.oldValue = func(context.Context) (*Employee, error) {
  4851. return node, nil
  4852. }
  4853. m.id = &node.ID
  4854. }
  4855. }
  4856. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4857. // executed in a transaction (ent.Tx), a transactional client is returned.
  4858. func (m EmployeeMutation) Client() *Client {
  4859. client := &Client{config: m.config}
  4860. client.init()
  4861. return client
  4862. }
  4863. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4864. // it returns an error otherwise.
  4865. func (m EmployeeMutation) Tx() (*Tx, error) {
  4866. if _, ok := m.driver.(*txDriver); !ok {
  4867. return nil, errors.New("ent: mutation is not running in a transaction")
  4868. }
  4869. tx := &Tx{config: m.config}
  4870. tx.init()
  4871. return tx, nil
  4872. }
  4873. // SetID sets the value of the id field. Note that this
  4874. // operation is only accepted on creation of Employee entities.
  4875. func (m *EmployeeMutation) SetID(id uint64) {
  4876. m.id = &id
  4877. }
  4878. // ID returns the ID value in the mutation. Note that the ID is only available
  4879. // if it was provided to the builder or after it was returned from the database.
  4880. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  4881. if m.id == nil {
  4882. return
  4883. }
  4884. return *m.id, true
  4885. }
  4886. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4887. // That means, if the mutation is applied within a transaction with an isolation level such
  4888. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4889. // or updated by the mutation.
  4890. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  4891. switch {
  4892. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4893. id, exists := m.ID()
  4894. if exists {
  4895. return []uint64{id}, nil
  4896. }
  4897. fallthrough
  4898. case m.op.Is(OpUpdate | OpDelete):
  4899. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  4900. default:
  4901. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4902. }
  4903. }
  4904. // SetCreatedAt sets the "created_at" field.
  4905. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  4906. m.created_at = &t
  4907. }
  4908. // CreatedAt returns the value of the "created_at" field in the mutation.
  4909. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  4910. v := m.created_at
  4911. if v == nil {
  4912. return
  4913. }
  4914. return *v, true
  4915. }
  4916. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  4917. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4919. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4920. if !m.op.Is(OpUpdateOne) {
  4921. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4922. }
  4923. if m.id == nil || m.oldValue == nil {
  4924. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4925. }
  4926. oldValue, err := m.oldValue(ctx)
  4927. if err != nil {
  4928. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4929. }
  4930. return oldValue.CreatedAt, nil
  4931. }
  4932. // ResetCreatedAt resets all changes to the "created_at" field.
  4933. func (m *EmployeeMutation) ResetCreatedAt() {
  4934. m.created_at = nil
  4935. }
  4936. // SetUpdatedAt sets the "updated_at" field.
  4937. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  4938. m.updated_at = &t
  4939. }
  4940. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4941. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  4942. v := m.updated_at
  4943. if v == nil {
  4944. return
  4945. }
  4946. return *v, true
  4947. }
  4948. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  4949. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4951. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4952. if !m.op.Is(OpUpdateOne) {
  4953. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4954. }
  4955. if m.id == nil || m.oldValue == nil {
  4956. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4957. }
  4958. oldValue, err := m.oldValue(ctx)
  4959. if err != nil {
  4960. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4961. }
  4962. return oldValue.UpdatedAt, nil
  4963. }
  4964. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4965. func (m *EmployeeMutation) ResetUpdatedAt() {
  4966. m.updated_at = nil
  4967. }
  4968. // SetDeletedAt sets the "deleted_at" field.
  4969. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  4970. m.deleted_at = &t
  4971. }
  4972. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4973. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  4974. v := m.deleted_at
  4975. if v == nil {
  4976. return
  4977. }
  4978. return *v, true
  4979. }
  4980. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  4981. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4983. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4984. if !m.op.Is(OpUpdateOne) {
  4985. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4986. }
  4987. if m.id == nil || m.oldValue == nil {
  4988. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4989. }
  4990. oldValue, err := m.oldValue(ctx)
  4991. if err != nil {
  4992. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4993. }
  4994. return oldValue.DeletedAt, nil
  4995. }
  4996. // ClearDeletedAt clears the value of the "deleted_at" field.
  4997. func (m *EmployeeMutation) ClearDeletedAt() {
  4998. m.deleted_at = nil
  4999. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  5000. }
  5001. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5002. func (m *EmployeeMutation) DeletedAtCleared() bool {
  5003. _, ok := m.clearedFields[employee.FieldDeletedAt]
  5004. return ok
  5005. }
  5006. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5007. func (m *EmployeeMutation) ResetDeletedAt() {
  5008. m.deleted_at = nil
  5009. delete(m.clearedFields, employee.FieldDeletedAt)
  5010. }
  5011. // SetTitle sets the "title" field.
  5012. func (m *EmployeeMutation) SetTitle(s string) {
  5013. m.title = &s
  5014. }
  5015. // Title returns the value of the "title" field in the mutation.
  5016. func (m *EmployeeMutation) Title() (r string, exists bool) {
  5017. v := m.title
  5018. if v == nil {
  5019. return
  5020. }
  5021. return *v, true
  5022. }
  5023. // OldTitle returns the old "title" field's value of the Employee entity.
  5024. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5026. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  5027. if !m.op.Is(OpUpdateOne) {
  5028. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  5029. }
  5030. if m.id == nil || m.oldValue == nil {
  5031. return v, errors.New("OldTitle requires an ID field in the mutation")
  5032. }
  5033. oldValue, err := m.oldValue(ctx)
  5034. if err != nil {
  5035. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  5036. }
  5037. return oldValue.Title, nil
  5038. }
  5039. // ResetTitle resets all changes to the "title" field.
  5040. func (m *EmployeeMutation) ResetTitle() {
  5041. m.title = nil
  5042. }
  5043. // SetAvatar sets the "avatar" field.
  5044. func (m *EmployeeMutation) SetAvatar(s string) {
  5045. m.avatar = &s
  5046. }
  5047. // Avatar returns the value of the "avatar" field in the mutation.
  5048. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  5049. v := m.avatar
  5050. if v == nil {
  5051. return
  5052. }
  5053. return *v, true
  5054. }
  5055. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  5056. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5058. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  5059. if !m.op.Is(OpUpdateOne) {
  5060. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  5061. }
  5062. if m.id == nil || m.oldValue == nil {
  5063. return v, errors.New("OldAvatar requires an ID field in the mutation")
  5064. }
  5065. oldValue, err := m.oldValue(ctx)
  5066. if err != nil {
  5067. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  5068. }
  5069. return oldValue.Avatar, nil
  5070. }
  5071. // ResetAvatar resets all changes to the "avatar" field.
  5072. func (m *EmployeeMutation) ResetAvatar() {
  5073. m.avatar = nil
  5074. }
  5075. // SetTags sets the "tags" field.
  5076. func (m *EmployeeMutation) SetTags(s string) {
  5077. m.tags = &s
  5078. }
  5079. // Tags returns the value of the "tags" field in the mutation.
  5080. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  5081. v := m.tags
  5082. if v == nil {
  5083. return
  5084. }
  5085. return *v, true
  5086. }
  5087. // OldTags returns the old "tags" field's value of the Employee entity.
  5088. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5090. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  5091. if !m.op.Is(OpUpdateOne) {
  5092. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  5093. }
  5094. if m.id == nil || m.oldValue == nil {
  5095. return v, errors.New("OldTags requires an ID field in the mutation")
  5096. }
  5097. oldValue, err := m.oldValue(ctx)
  5098. if err != nil {
  5099. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  5100. }
  5101. return oldValue.Tags, nil
  5102. }
  5103. // ResetTags resets all changes to the "tags" field.
  5104. func (m *EmployeeMutation) ResetTags() {
  5105. m.tags = nil
  5106. }
  5107. // SetHireCount sets the "hire_count" field.
  5108. func (m *EmployeeMutation) SetHireCount(i int) {
  5109. m.hire_count = &i
  5110. m.addhire_count = nil
  5111. }
  5112. // HireCount returns the value of the "hire_count" field in the mutation.
  5113. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  5114. v := m.hire_count
  5115. if v == nil {
  5116. return
  5117. }
  5118. return *v, true
  5119. }
  5120. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  5121. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5122. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5123. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  5124. if !m.op.Is(OpUpdateOne) {
  5125. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  5126. }
  5127. if m.id == nil || m.oldValue == nil {
  5128. return v, errors.New("OldHireCount requires an ID field in the mutation")
  5129. }
  5130. oldValue, err := m.oldValue(ctx)
  5131. if err != nil {
  5132. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  5133. }
  5134. return oldValue.HireCount, nil
  5135. }
  5136. // AddHireCount adds i to the "hire_count" field.
  5137. func (m *EmployeeMutation) AddHireCount(i int) {
  5138. if m.addhire_count != nil {
  5139. *m.addhire_count += i
  5140. } else {
  5141. m.addhire_count = &i
  5142. }
  5143. }
  5144. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  5145. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  5146. v := m.addhire_count
  5147. if v == nil {
  5148. return
  5149. }
  5150. return *v, true
  5151. }
  5152. // ResetHireCount resets all changes to the "hire_count" field.
  5153. func (m *EmployeeMutation) ResetHireCount() {
  5154. m.hire_count = nil
  5155. m.addhire_count = nil
  5156. }
  5157. // SetServiceCount sets the "service_count" field.
  5158. func (m *EmployeeMutation) SetServiceCount(i int) {
  5159. m.service_count = &i
  5160. m.addservice_count = nil
  5161. }
  5162. // ServiceCount returns the value of the "service_count" field in the mutation.
  5163. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  5164. v := m.service_count
  5165. if v == nil {
  5166. return
  5167. }
  5168. return *v, true
  5169. }
  5170. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  5171. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5173. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  5174. if !m.op.Is(OpUpdateOne) {
  5175. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  5176. }
  5177. if m.id == nil || m.oldValue == nil {
  5178. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  5179. }
  5180. oldValue, err := m.oldValue(ctx)
  5181. if err != nil {
  5182. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  5183. }
  5184. return oldValue.ServiceCount, nil
  5185. }
  5186. // AddServiceCount adds i to the "service_count" field.
  5187. func (m *EmployeeMutation) AddServiceCount(i int) {
  5188. if m.addservice_count != nil {
  5189. *m.addservice_count += i
  5190. } else {
  5191. m.addservice_count = &i
  5192. }
  5193. }
  5194. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  5195. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  5196. v := m.addservice_count
  5197. if v == nil {
  5198. return
  5199. }
  5200. return *v, true
  5201. }
  5202. // ResetServiceCount resets all changes to the "service_count" field.
  5203. func (m *EmployeeMutation) ResetServiceCount() {
  5204. m.service_count = nil
  5205. m.addservice_count = nil
  5206. }
  5207. // SetAchievementCount sets the "achievement_count" field.
  5208. func (m *EmployeeMutation) SetAchievementCount(i int) {
  5209. m.achievement_count = &i
  5210. m.addachievement_count = nil
  5211. }
  5212. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  5213. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  5214. v := m.achievement_count
  5215. if v == nil {
  5216. return
  5217. }
  5218. return *v, true
  5219. }
  5220. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  5221. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5223. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  5224. if !m.op.Is(OpUpdateOne) {
  5225. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  5226. }
  5227. if m.id == nil || m.oldValue == nil {
  5228. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  5229. }
  5230. oldValue, err := m.oldValue(ctx)
  5231. if err != nil {
  5232. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  5233. }
  5234. return oldValue.AchievementCount, nil
  5235. }
  5236. // AddAchievementCount adds i to the "achievement_count" field.
  5237. func (m *EmployeeMutation) AddAchievementCount(i int) {
  5238. if m.addachievement_count != nil {
  5239. *m.addachievement_count += i
  5240. } else {
  5241. m.addachievement_count = &i
  5242. }
  5243. }
  5244. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  5245. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  5246. v := m.addachievement_count
  5247. if v == nil {
  5248. return
  5249. }
  5250. return *v, true
  5251. }
  5252. // ResetAchievementCount resets all changes to the "achievement_count" field.
  5253. func (m *EmployeeMutation) ResetAchievementCount() {
  5254. m.achievement_count = nil
  5255. m.addachievement_count = nil
  5256. }
  5257. // SetIntro sets the "intro" field.
  5258. func (m *EmployeeMutation) SetIntro(s string) {
  5259. m.intro = &s
  5260. }
  5261. // Intro returns the value of the "intro" field in the mutation.
  5262. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  5263. v := m.intro
  5264. if v == nil {
  5265. return
  5266. }
  5267. return *v, true
  5268. }
  5269. // OldIntro returns the old "intro" field's value of the Employee entity.
  5270. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5272. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  5273. if !m.op.Is(OpUpdateOne) {
  5274. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  5275. }
  5276. if m.id == nil || m.oldValue == nil {
  5277. return v, errors.New("OldIntro requires an ID field in the mutation")
  5278. }
  5279. oldValue, err := m.oldValue(ctx)
  5280. if err != nil {
  5281. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  5282. }
  5283. return oldValue.Intro, nil
  5284. }
  5285. // ResetIntro resets all changes to the "intro" field.
  5286. func (m *EmployeeMutation) ResetIntro() {
  5287. m.intro = nil
  5288. }
  5289. // SetEstimate sets the "estimate" field.
  5290. func (m *EmployeeMutation) SetEstimate(s string) {
  5291. m.estimate = &s
  5292. }
  5293. // Estimate returns the value of the "estimate" field in the mutation.
  5294. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  5295. v := m.estimate
  5296. if v == nil {
  5297. return
  5298. }
  5299. return *v, true
  5300. }
  5301. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  5302. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5304. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  5305. if !m.op.Is(OpUpdateOne) {
  5306. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  5307. }
  5308. if m.id == nil || m.oldValue == nil {
  5309. return v, errors.New("OldEstimate requires an ID field in the mutation")
  5310. }
  5311. oldValue, err := m.oldValue(ctx)
  5312. if err != nil {
  5313. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  5314. }
  5315. return oldValue.Estimate, nil
  5316. }
  5317. // ResetEstimate resets all changes to the "estimate" field.
  5318. func (m *EmployeeMutation) ResetEstimate() {
  5319. m.estimate = nil
  5320. }
  5321. // SetSkill sets the "skill" field.
  5322. func (m *EmployeeMutation) SetSkill(s string) {
  5323. m.skill = &s
  5324. }
  5325. // Skill returns the value of the "skill" field in the mutation.
  5326. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  5327. v := m.skill
  5328. if v == nil {
  5329. return
  5330. }
  5331. return *v, true
  5332. }
  5333. // OldSkill returns the old "skill" field's value of the Employee entity.
  5334. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5336. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  5337. if !m.op.Is(OpUpdateOne) {
  5338. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  5339. }
  5340. if m.id == nil || m.oldValue == nil {
  5341. return v, errors.New("OldSkill requires an ID field in the mutation")
  5342. }
  5343. oldValue, err := m.oldValue(ctx)
  5344. if err != nil {
  5345. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  5346. }
  5347. return oldValue.Skill, nil
  5348. }
  5349. // ResetSkill resets all changes to the "skill" field.
  5350. func (m *EmployeeMutation) ResetSkill() {
  5351. m.skill = nil
  5352. }
  5353. // SetAbilityType sets the "ability_type" field.
  5354. func (m *EmployeeMutation) SetAbilityType(s string) {
  5355. m.ability_type = &s
  5356. }
  5357. // AbilityType returns the value of the "ability_type" field in the mutation.
  5358. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  5359. v := m.ability_type
  5360. if v == nil {
  5361. return
  5362. }
  5363. return *v, true
  5364. }
  5365. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  5366. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5368. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  5369. if !m.op.Is(OpUpdateOne) {
  5370. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  5371. }
  5372. if m.id == nil || m.oldValue == nil {
  5373. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  5374. }
  5375. oldValue, err := m.oldValue(ctx)
  5376. if err != nil {
  5377. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  5378. }
  5379. return oldValue.AbilityType, nil
  5380. }
  5381. // ResetAbilityType resets all changes to the "ability_type" field.
  5382. func (m *EmployeeMutation) ResetAbilityType() {
  5383. m.ability_type = nil
  5384. }
  5385. // SetScene sets the "scene" field.
  5386. func (m *EmployeeMutation) SetScene(s string) {
  5387. m.scene = &s
  5388. }
  5389. // Scene returns the value of the "scene" field in the mutation.
  5390. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  5391. v := m.scene
  5392. if v == nil {
  5393. return
  5394. }
  5395. return *v, true
  5396. }
  5397. // OldScene returns the old "scene" field's value of the Employee entity.
  5398. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5400. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  5401. if !m.op.Is(OpUpdateOne) {
  5402. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  5403. }
  5404. if m.id == nil || m.oldValue == nil {
  5405. return v, errors.New("OldScene requires an ID field in the mutation")
  5406. }
  5407. oldValue, err := m.oldValue(ctx)
  5408. if err != nil {
  5409. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  5410. }
  5411. return oldValue.Scene, nil
  5412. }
  5413. // ResetScene resets all changes to the "scene" field.
  5414. func (m *EmployeeMutation) ResetScene() {
  5415. m.scene = nil
  5416. }
  5417. // SetSwitchIn sets the "switch_in" field.
  5418. func (m *EmployeeMutation) SetSwitchIn(s string) {
  5419. m.switch_in = &s
  5420. }
  5421. // SwitchIn returns the value of the "switch_in" field in the mutation.
  5422. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  5423. v := m.switch_in
  5424. if v == nil {
  5425. return
  5426. }
  5427. return *v, true
  5428. }
  5429. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  5430. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5432. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  5433. if !m.op.Is(OpUpdateOne) {
  5434. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  5435. }
  5436. if m.id == nil || m.oldValue == nil {
  5437. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  5438. }
  5439. oldValue, err := m.oldValue(ctx)
  5440. if err != nil {
  5441. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  5442. }
  5443. return oldValue.SwitchIn, nil
  5444. }
  5445. // ResetSwitchIn resets all changes to the "switch_in" field.
  5446. func (m *EmployeeMutation) ResetSwitchIn() {
  5447. m.switch_in = nil
  5448. }
  5449. // SetVideoURL sets the "video_url" field.
  5450. func (m *EmployeeMutation) SetVideoURL(s string) {
  5451. m.video_url = &s
  5452. }
  5453. // VideoURL returns the value of the "video_url" field in the mutation.
  5454. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  5455. v := m.video_url
  5456. if v == nil {
  5457. return
  5458. }
  5459. return *v, true
  5460. }
  5461. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  5462. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5464. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  5465. if !m.op.Is(OpUpdateOne) {
  5466. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  5467. }
  5468. if m.id == nil || m.oldValue == nil {
  5469. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  5470. }
  5471. oldValue, err := m.oldValue(ctx)
  5472. if err != nil {
  5473. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  5474. }
  5475. return oldValue.VideoURL, nil
  5476. }
  5477. // ResetVideoURL resets all changes to the "video_url" field.
  5478. func (m *EmployeeMutation) ResetVideoURL() {
  5479. m.video_url = nil
  5480. }
  5481. // SetOrganizationID sets the "organization_id" field.
  5482. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  5483. m.organization_id = &u
  5484. m.addorganization_id = nil
  5485. }
  5486. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5487. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  5488. v := m.organization_id
  5489. if v == nil {
  5490. return
  5491. }
  5492. return *v, true
  5493. }
  5494. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  5495. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5497. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5498. if !m.op.Is(OpUpdateOne) {
  5499. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5500. }
  5501. if m.id == nil || m.oldValue == nil {
  5502. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5503. }
  5504. oldValue, err := m.oldValue(ctx)
  5505. if err != nil {
  5506. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5507. }
  5508. return oldValue.OrganizationID, nil
  5509. }
  5510. // AddOrganizationID adds u to the "organization_id" field.
  5511. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  5512. if m.addorganization_id != nil {
  5513. *m.addorganization_id += u
  5514. } else {
  5515. m.addorganization_id = &u
  5516. }
  5517. }
  5518. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5519. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  5520. v := m.addorganization_id
  5521. if v == nil {
  5522. return
  5523. }
  5524. return *v, true
  5525. }
  5526. // ResetOrganizationID resets all changes to the "organization_id" field.
  5527. func (m *EmployeeMutation) ResetOrganizationID() {
  5528. m.organization_id = nil
  5529. m.addorganization_id = nil
  5530. }
  5531. // SetCategoryID sets the "category_id" field.
  5532. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  5533. m.category_id = &u
  5534. m.addcategory_id = nil
  5535. }
  5536. // CategoryID returns the value of the "category_id" field in the mutation.
  5537. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  5538. v := m.category_id
  5539. if v == nil {
  5540. return
  5541. }
  5542. return *v, true
  5543. }
  5544. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  5545. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  5546. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5547. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  5548. if !m.op.Is(OpUpdateOne) {
  5549. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  5550. }
  5551. if m.id == nil || m.oldValue == nil {
  5552. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  5553. }
  5554. oldValue, err := m.oldValue(ctx)
  5555. if err != nil {
  5556. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  5557. }
  5558. return oldValue.CategoryID, nil
  5559. }
  5560. // AddCategoryID adds u to the "category_id" field.
  5561. func (m *EmployeeMutation) AddCategoryID(u int64) {
  5562. if m.addcategory_id != nil {
  5563. *m.addcategory_id += u
  5564. } else {
  5565. m.addcategory_id = &u
  5566. }
  5567. }
  5568. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  5569. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  5570. v := m.addcategory_id
  5571. if v == nil {
  5572. return
  5573. }
  5574. return *v, true
  5575. }
  5576. // ResetCategoryID resets all changes to the "category_id" field.
  5577. func (m *EmployeeMutation) ResetCategoryID() {
  5578. m.category_id = nil
  5579. m.addcategory_id = nil
  5580. }
  5581. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  5582. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  5583. if m.em_work_experiences == nil {
  5584. m.em_work_experiences = make(map[uint64]struct{})
  5585. }
  5586. for i := range ids {
  5587. m.em_work_experiences[ids[i]] = struct{}{}
  5588. }
  5589. }
  5590. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  5591. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  5592. m.clearedem_work_experiences = true
  5593. }
  5594. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  5595. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  5596. return m.clearedem_work_experiences
  5597. }
  5598. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  5599. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  5600. if m.removedem_work_experiences == nil {
  5601. m.removedem_work_experiences = make(map[uint64]struct{})
  5602. }
  5603. for i := range ids {
  5604. delete(m.em_work_experiences, ids[i])
  5605. m.removedem_work_experiences[ids[i]] = struct{}{}
  5606. }
  5607. }
  5608. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  5609. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  5610. for id := range m.removedem_work_experiences {
  5611. ids = append(ids, id)
  5612. }
  5613. return
  5614. }
  5615. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  5616. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  5617. for id := range m.em_work_experiences {
  5618. ids = append(ids, id)
  5619. }
  5620. return
  5621. }
  5622. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  5623. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  5624. m.em_work_experiences = nil
  5625. m.clearedem_work_experiences = false
  5626. m.removedem_work_experiences = nil
  5627. }
  5628. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  5629. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  5630. if m.em_tutorial == nil {
  5631. m.em_tutorial = make(map[uint64]struct{})
  5632. }
  5633. for i := range ids {
  5634. m.em_tutorial[ids[i]] = struct{}{}
  5635. }
  5636. }
  5637. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  5638. func (m *EmployeeMutation) ClearEmTutorial() {
  5639. m.clearedem_tutorial = true
  5640. }
  5641. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  5642. func (m *EmployeeMutation) EmTutorialCleared() bool {
  5643. return m.clearedem_tutorial
  5644. }
  5645. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  5646. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  5647. if m.removedem_tutorial == nil {
  5648. m.removedem_tutorial = make(map[uint64]struct{})
  5649. }
  5650. for i := range ids {
  5651. delete(m.em_tutorial, ids[i])
  5652. m.removedem_tutorial[ids[i]] = struct{}{}
  5653. }
  5654. }
  5655. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  5656. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  5657. for id := range m.removedem_tutorial {
  5658. ids = append(ids, id)
  5659. }
  5660. return
  5661. }
  5662. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  5663. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  5664. for id := range m.em_tutorial {
  5665. ids = append(ids, id)
  5666. }
  5667. return
  5668. }
  5669. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  5670. func (m *EmployeeMutation) ResetEmTutorial() {
  5671. m.em_tutorial = nil
  5672. m.clearedem_tutorial = false
  5673. m.removedem_tutorial = nil
  5674. }
  5675. // Where appends a list predicates to the EmployeeMutation builder.
  5676. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  5677. m.predicates = append(m.predicates, ps...)
  5678. }
  5679. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  5680. // users can use type-assertion to append predicates that do not depend on any generated package.
  5681. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  5682. p := make([]predicate.Employee, len(ps))
  5683. for i := range ps {
  5684. p[i] = ps[i]
  5685. }
  5686. m.Where(p...)
  5687. }
  5688. // Op returns the operation name.
  5689. func (m *EmployeeMutation) Op() Op {
  5690. return m.op
  5691. }
  5692. // SetOp allows setting the mutation operation.
  5693. func (m *EmployeeMutation) SetOp(op Op) {
  5694. m.op = op
  5695. }
  5696. // Type returns the node type of this mutation (Employee).
  5697. func (m *EmployeeMutation) Type() string {
  5698. return m.typ
  5699. }
  5700. // Fields returns all fields that were changed during this mutation. Note that in
  5701. // order to get all numeric fields that were incremented/decremented, call
  5702. // AddedFields().
  5703. func (m *EmployeeMutation) Fields() []string {
  5704. fields := make([]string, 0, 18)
  5705. if m.created_at != nil {
  5706. fields = append(fields, employee.FieldCreatedAt)
  5707. }
  5708. if m.updated_at != nil {
  5709. fields = append(fields, employee.FieldUpdatedAt)
  5710. }
  5711. if m.deleted_at != nil {
  5712. fields = append(fields, employee.FieldDeletedAt)
  5713. }
  5714. if m.title != nil {
  5715. fields = append(fields, employee.FieldTitle)
  5716. }
  5717. if m.avatar != nil {
  5718. fields = append(fields, employee.FieldAvatar)
  5719. }
  5720. if m.tags != nil {
  5721. fields = append(fields, employee.FieldTags)
  5722. }
  5723. if m.hire_count != nil {
  5724. fields = append(fields, employee.FieldHireCount)
  5725. }
  5726. if m.service_count != nil {
  5727. fields = append(fields, employee.FieldServiceCount)
  5728. }
  5729. if m.achievement_count != nil {
  5730. fields = append(fields, employee.FieldAchievementCount)
  5731. }
  5732. if m.intro != nil {
  5733. fields = append(fields, employee.FieldIntro)
  5734. }
  5735. if m.estimate != nil {
  5736. fields = append(fields, employee.FieldEstimate)
  5737. }
  5738. if m.skill != nil {
  5739. fields = append(fields, employee.FieldSkill)
  5740. }
  5741. if m.ability_type != nil {
  5742. fields = append(fields, employee.FieldAbilityType)
  5743. }
  5744. if m.scene != nil {
  5745. fields = append(fields, employee.FieldScene)
  5746. }
  5747. if m.switch_in != nil {
  5748. fields = append(fields, employee.FieldSwitchIn)
  5749. }
  5750. if m.video_url != nil {
  5751. fields = append(fields, employee.FieldVideoURL)
  5752. }
  5753. if m.organization_id != nil {
  5754. fields = append(fields, employee.FieldOrganizationID)
  5755. }
  5756. if m.category_id != nil {
  5757. fields = append(fields, employee.FieldCategoryID)
  5758. }
  5759. return fields
  5760. }
  5761. // Field returns the value of a field with the given name. The second boolean
  5762. // return value indicates that this field was not set, or was not defined in the
  5763. // schema.
  5764. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  5765. switch name {
  5766. case employee.FieldCreatedAt:
  5767. return m.CreatedAt()
  5768. case employee.FieldUpdatedAt:
  5769. return m.UpdatedAt()
  5770. case employee.FieldDeletedAt:
  5771. return m.DeletedAt()
  5772. case employee.FieldTitle:
  5773. return m.Title()
  5774. case employee.FieldAvatar:
  5775. return m.Avatar()
  5776. case employee.FieldTags:
  5777. return m.Tags()
  5778. case employee.FieldHireCount:
  5779. return m.HireCount()
  5780. case employee.FieldServiceCount:
  5781. return m.ServiceCount()
  5782. case employee.FieldAchievementCount:
  5783. return m.AchievementCount()
  5784. case employee.FieldIntro:
  5785. return m.Intro()
  5786. case employee.FieldEstimate:
  5787. return m.Estimate()
  5788. case employee.FieldSkill:
  5789. return m.Skill()
  5790. case employee.FieldAbilityType:
  5791. return m.AbilityType()
  5792. case employee.FieldScene:
  5793. return m.Scene()
  5794. case employee.FieldSwitchIn:
  5795. return m.SwitchIn()
  5796. case employee.FieldVideoURL:
  5797. return m.VideoURL()
  5798. case employee.FieldOrganizationID:
  5799. return m.OrganizationID()
  5800. case employee.FieldCategoryID:
  5801. return m.CategoryID()
  5802. }
  5803. return nil, false
  5804. }
  5805. // OldField returns the old value of the field from the database. An error is
  5806. // returned if the mutation operation is not UpdateOne, or the query to the
  5807. // database failed.
  5808. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5809. switch name {
  5810. case employee.FieldCreatedAt:
  5811. return m.OldCreatedAt(ctx)
  5812. case employee.FieldUpdatedAt:
  5813. return m.OldUpdatedAt(ctx)
  5814. case employee.FieldDeletedAt:
  5815. return m.OldDeletedAt(ctx)
  5816. case employee.FieldTitle:
  5817. return m.OldTitle(ctx)
  5818. case employee.FieldAvatar:
  5819. return m.OldAvatar(ctx)
  5820. case employee.FieldTags:
  5821. return m.OldTags(ctx)
  5822. case employee.FieldHireCount:
  5823. return m.OldHireCount(ctx)
  5824. case employee.FieldServiceCount:
  5825. return m.OldServiceCount(ctx)
  5826. case employee.FieldAchievementCount:
  5827. return m.OldAchievementCount(ctx)
  5828. case employee.FieldIntro:
  5829. return m.OldIntro(ctx)
  5830. case employee.FieldEstimate:
  5831. return m.OldEstimate(ctx)
  5832. case employee.FieldSkill:
  5833. return m.OldSkill(ctx)
  5834. case employee.FieldAbilityType:
  5835. return m.OldAbilityType(ctx)
  5836. case employee.FieldScene:
  5837. return m.OldScene(ctx)
  5838. case employee.FieldSwitchIn:
  5839. return m.OldSwitchIn(ctx)
  5840. case employee.FieldVideoURL:
  5841. return m.OldVideoURL(ctx)
  5842. case employee.FieldOrganizationID:
  5843. return m.OldOrganizationID(ctx)
  5844. case employee.FieldCategoryID:
  5845. return m.OldCategoryID(ctx)
  5846. }
  5847. return nil, fmt.Errorf("unknown Employee field %s", name)
  5848. }
  5849. // SetField sets the value of a field with the given name. It returns an error if
  5850. // the field is not defined in the schema, or if the type mismatched the field
  5851. // type.
  5852. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  5853. switch name {
  5854. case employee.FieldCreatedAt:
  5855. v, ok := value.(time.Time)
  5856. if !ok {
  5857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5858. }
  5859. m.SetCreatedAt(v)
  5860. return nil
  5861. case employee.FieldUpdatedAt:
  5862. v, ok := value.(time.Time)
  5863. if !ok {
  5864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5865. }
  5866. m.SetUpdatedAt(v)
  5867. return nil
  5868. case employee.FieldDeletedAt:
  5869. v, ok := value.(time.Time)
  5870. if !ok {
  5871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5872. }
  5873. m.SetDeletedAt(v)
  5874. return nil
  5875. case employee.FieldTitle:
  5876. v, ok := value.(string)
  5877. if !ok {
  5878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5879. }
  5880. m.SetTitle(v)
  5881. return nil
  5882. case employee.FieldAvatar:
  5883. v, ok := value.(string)
  5884. if !ok {
  5885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5886. }
  5887. m.SetAvatar(v)
  5888. return nil
  5889. case employee.FieldTags:
  5890. v, ok := value.(string)
  5891. if !ok {
  5892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5893. }
  5894. m.SetTags(v)
  5895. return nil
  5896. case employee.FieldHireCount:
  5897. v, ok := value.(int)
  5898. if !ok {
  5899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5900. }
  5901. m.SetHireCount(v)
  5902. return nil
  5903. case employee.FieldServiceCount:
  5904. v, ok := value.(int)
  5905. if !ok {
  5906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5907. }
  5908. m.SetServiceCount(v)
  5909. return nil
  5910. case employee.FieldAchievementCount:
  5911. v, ok := value.(int)
  5912. if !ok {
  5913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5914. }
  5915. m.SetAchievementCount(v)
  5916. return nil
  5917. case employee.FieldIntro:
  5918. v, ok := value.(string)
  5919. if !ok {
  5920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5921. }
  5922. m.SetIntro(v)
  5923. return nil
  5924. case employee.FieldEstimate:
  5925. v, ok := value.(string)
  5926. if !ok {
  5927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5928. }
  5929. m.SetEstimate(v)
  5930. return nil
  5931. case employee.FieldSkill:
  5932. v, ok := value.(string)
  5933. if !ok {
  5934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5935. }
  5936. m.SetSkill(v)
  5937. return nil
  5938. case employee.FieldAbilityType:
  5939. v, ok := value.(string)
  5940. if !ok {
  5941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5942. }
  5943. m.SetAbilityType(v)
  5944. return nil
  5945. case employee.FieldScene:
  5946. v, ok := value.(string)
  5947. if !ok {
  5948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5949. }
  5950. m.SetScene(v)
  5951. return nil
  5952. case employee.FieldSwitchIn:
  5953. v, ok := value.(string)
  5954. if !ok {
  5955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5956. }
  5957. m.SetSwitchIn(v)
  5958. return nil
  5959. case employee.FieldVideoURL:
  5960. v, ok := value.(string)
  5961. if !ok {
  5962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5963. }
  5964. m.SetVideoURL(v)
  5965. return nil
  5966. case employee.FieldOrganizationID:
  5967. v, ok := value.(uint64)
  5968. if !ok {
  5969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5970. }
  5971. m.SetOrganizationID(v)
  5972. return nil
  5973. case employee.FieldCategoryID:
  5974. v, ok := value.(uint64)
  5975. if !ok {
  5976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5977. }
  5978. m.SetCategoryID(v)
  5979. return nil
  5980. }
  5981. return fmt.Errorf("unknown Employee field %s", name)
  5982. }
  5983. // AddedFields returns all numeric fields that were incremented/decremented during
  5984. // this mutation.
  5985. func (m *EmployeeMutation) AddedFields() []string {
  5986. var fields []string
  5987. if m.addhire_count != nil {
  5988. fields = append(fields, employee.FieldHireCount)
  5989. }
  5990. if m.addservice_count != nil {
  5991. fields = append(fields, employee.FieldServiceCount)
  5992. }
  5993. if m.addachievement_count != nil {
  5994. fields = append(fields, employee.FieldAchievementCount)
  5995. }
  5996. if m.addorganization_id != nil {
  5997. fields = append(fields, employee.FieldOrganizationID)
  5998. }
  5999. if m.addcategory_id != nil {
  6000. fields = append(fields, employee.FieldCategoryID)
  6001. }
  6002. return fields
  6003. }
  6004. // AddedField returns the numeric value that was incremented/decremented on a field
  6005. // with the given name. The second boolean return value indicates that this field
  6006. // was not set, or was not defined in the schema.
  6007. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  6008. switch name {
  6009. case employee.FieldHireCount:
  6010. return m.AddedHireCount()
  6011. case employee.FieldServiceCount:
  6012. return m.AddedServiceCount()
  6013. case employee.FieldAchievementCount:
  6014. return m.AddedAchievementCount()
  6015. case employee.FieldOrganizationID:
  6016. return m.AddedOrganizationID()
  6017. case employee.FieldCategoryID:
  6018. return m.AddedCategoryID()
  6019. }
  6020. return nil, false
  6021. }
  6022. // AddField adds the value to the field with the given name. It returns an error if
  6023. // the field is not defined in the schema, or if the type mismatched the field
  6024. // type.
  6025. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  6026. switch name {
  6027. case employee.FieldHireCount:
  6028. v, ok := value.(int)
  6029. if !ok {
  6030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6031. }
  6032. m.AddHireCount(v)
  6033. return nil
  6034. case employee.FieldServiceCount:
  6035. v, ok := value.(int)
  6036. if !ok {
  6037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6038. }
  6039. m.AddServiceCount(v)
  6040. return nil
  6041. case employee.FieldAchievementCount:
  6042. v, ok := value.(int)
  6043. if !ok {
  6044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6045. }
  6046. m.AddAchievementCount(v)
  6047. return nil
  6048. case employee.FieldOrganizationID:
  6049. v, ok := value.(int64)
  6050. if !ok {
  6051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6052. }
  6053. m.AddOrganizationID(v)
  6054. return nil
  6055. case employee.FieldCategoryID:
  6056. v, ok := value.(int64)
  6057. if !ok {
  6058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6059. }
  6060. m.AddCategoryID(v)
  6061. return nil
  6062. }
  6063. return fmt.Errorf("unknown Employee numeric field %s", name)
  6064. }
  6065. // ClearedFields returns all nullable fields that were cleared during this
  6066. // mutation.
  6067. func (m *EmployeeMutation) ClearedFields() []string {
  6068. var fields []string
  6069. if m.FieldCleared(employee.FieldDeletedAt) {
  6070. fields = append(fields, employee.FieldDeletedAt)
  6071. }
  6072. return fields
  6073. }
  6074. // FieldCleared returns a boolean indicating if a field with the given name was
  6075. // cleared in this mutation.
  6076. func (m *EmployeeMutation) FieldCleared(name string) bool {
  6077. _, ok := m.clearedFields[name]
  6078. return ok
  6079. }
  6080. // ClearField clears the value of the field with the given name. It returns an
  6081. // error if the field is not defined in the schema.
  6082. func (m *EmployeeMutation) ClearField(name string) error {
  6083. switch name {
  6084. case employee.FieldDeletedAt:
  6085. m.ClearDeletedAt()
  6086. return nil
  6087. }
  6088. return fmt.Errorf("unknown Employee nullable field %s", name)
  6089. }
  6090. // ResetField resets all changes in the mutation for the field with the given name.
  6091. // It returns an error if the field is not defined in the schema.
  6092. func (m *EmployeeMutation) ResetField(name string) error {
  6093. switch name {
  6094. case employee.FieldCreatedAt:
  6095. m.ResetCreatedAt()
  6096. return nil
  6097. case employee.FieldUpdatedAt:
  6098. m.ResetUpdatedAt()
  6099. return nil
  6100. case employee.FieldDeletedAt:
  6101. m.ResetDeletedAt()
  6102. return nil
  6103. case employee.FieldTitle:
  6104. m.ResetTitle()
  6105. return nil
  6106. case employee.FieldAvatar:
  6107. m.ResetAvatar()
  6108. return nil
  6109. case employee.FieldTags:
  6110. m.ResetTags()
  6111. return nil
  6112. case employee.FieldHireCount:
  6113. m.ResetHireCount()
  6114. return nil
  6115. case employee.FieldServiceCount:
  6116. m.ResetServiceCount()
  6117. return nil
  6118. case employee.FieldAchievementCount:
  6119. m.ResetAchievementCount()
  6120. return nil
  6121. case employee.FieldIntro:
  6122. m.ResetIntro()
  6123. return nil
  6124. case employee.FieldEstimate:
  6125. m.ResetEstimate()
  6126. return nil
  6127. case employee.FieldSkill:
  6128. m.ResetSkill()
  6129. return nil
  6130. case employee.FieldAbilityType:
  6131. m.ResetAbilityType()
  6132. return nil
  6133. case employee.FieldScene:
  6134. m.ResetScene()
  6135. return nil
  6136. case employee.FieldSwitchIn:
  6137. m.ResetSwitchIn()
  6138. return nil
  6139. case employee.FieldVideoURL:
  6140. m.ResetVideoURL()
  6141. return nil
  6142. case employee.FieldOrganizationID:
  6143. m.ResetOrganizationID()
  6144. return nil
  6145. case employee.FieldCategoryID:
  6146. m.ResetCategoryID()
  6147. return nil
  6148. }
  6149. return fmt.Errorf("unknown Employee field %s", name)
  6150. }
  6151. // AddedEdges returns all edge names that were set/added in this mutation.
  6152. func (m *EmployeeMutation) AddedEdges() []string {
  6153. edges := make([]string, 0, 2)
  6154. if m.em_work_experiences != nil {
  6155. edges = append(edges, employee.EdgeEmWorkExperiences)
  6156. }
  6157. if m.em_tutorial != nil {
  6158. edges = append(edges, employee.EdgeEmTutorial)
  6159. }
  6160. return edges
  6161. }
  6162. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6163. // name in this mutation.
  6164. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  6165. switch name {
  6166. case employee.EdgeEmWorkExperiences:
  6167. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  6168. for id := range m.em_work_experiences {
  6169. ids = append(ids, id)
  6170. }
  6171. return ids
  6172. case employee.EdgeEmTutorial:
  6173. ids := make([]ent.Value, 0, len(m.em_tutorial))
  6174. for id := range m.em_tutorial {
  6175. ids = append(ids, id)
  6176. }
  6177. return ids
  6178. }
  6179. return nil
  6180. }
  6181. // RemovedEdges returns all edge names that were removed in this mutation.
  6182. func (m *EmployeeMutation) RemovedEdges() []string {
  6183. edges := make([]string, 0, 2)
  6184. if m.removedem_work_experiences != nil {
  6185. edges = append(edges, employee.EdgeEmWorkExperiences)
  6186. }
  6187. if m.removedem_tutorial != nil {
  6188. edges = append(edges, employee.EdgeEmTutorial)
  6189. }
  6190. return edges
  6191. }
  6192. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6193. // the given name in this mutation.
  6194. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  6195. switch name {
  6196. case employee.EdgeEmWorkExperiences:
  6197. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  6198. for id := range m.removedem_work_experiences {
  6199. ids = append(ids, id)
  6200. }
  6201. return ids
  6202. case employee.EdgeEmTutorial:
  6203. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  6204. for id := range m.removedem_tutorial {
  6205. ids = append(ids, id)
  6206. }
  6207. return ids
  6208. }
  6209. return nil
  6210. }
  6211. // ClearedEdges returns all edge names that were cleared in this mutation.
  6212. func (m *EmployeeMutation) ClearedEdges() []string {
  6213. edges := make([]string, 0, 2)
  6214. if m.clearedem_work_experiences {
  6215. edges = append(edges, employee.EdgeEmWorkExperiences)
  6216. }
  6217. if m.clearedem_tutorial {
  6218. edges = append(edges, employee.EdgeEmTutorial)
  6219. }
  6220. return edges
  6221. }
  6222. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6223. // was cleared in this mutation.
  6224. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  6225. switch name {
  6226. case employee.EdgeEmWorkExperiences:
  6227. return m.clearedem_work_experiences
  6228. case employee.EdgeEmTutorial:
  6229. return m.clearedem_tutorial
  6230. }
  6231. return false
  6232. }
  6233. // ClearEdge clears the value of the edge with the given name. It returns an error
  6234. // if that edge is not defined in the schema.
  6235. func (m *EmployeeMutation) ClearEdge(name string) error {
  6236. switch name {
  6237. }
  6238. return fmt.Errorf("unknown Employee unique edge %s", name)
  6239. }
  6240. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6241. // It returns an error if the edge is not defined in the schema.
  6242. func (m *EmployeeMutation) ResetEdge(name string) error {
  6243. switch name {
  6244. case employee.EdgeEmWorkExperiences:
  6245. m.ResetEmWorkExperiences()
  6246. return nil
  6247. case employee.EdgeEmTutorial:
  6248. m.ResetEmTutorial()
  6249. return nil
  6250. }
  6251. return fmt.Errorf("unknown Employee edge %s", name)
  6252. }
  6253. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  6254. type EmployeeConfigMutation struct {
  6255. config
  6256. op Op
  6257. typ string
  6258. id *uint64
  6259. created_at *time.Time
  6260. updated_at *time.Time
  6261. deleted_at *time.Time
  6262. stype *string
  6263. title *string
  6264. photo *string
  6265. organization_id *uint64
  6266. addorganization_id *int64
  6267. clearedFields map[string]struct{}
  6268. done bool
  6269. oldValue func(context.Context) (*EmployeeConfig, error)
  6270. predicates []predicate.EmployeeConfig
  6271. }
  6272. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  6273. // employeeconfigOption allows management of the mutation configuration using functional options.
  6274. type employeeconfigOption func(*EmployeeConfigMutation)
  6275. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  6276. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  6277. m := &EmployeeConfigMutation{
  6278. config: c,
  6279. op: op,
  6280. typ: TypeEmployeeConfig,
  6281. clearedFields: make(map[string]struct{}),
  6282. }
  6283. for _, opt := range opts {
  6284. opt(m)
  6285. }
  6286. return m
  6287. }
  6288. // withEmployeeConfigID sets the ID field of the mutation.
  6289. func withEmployeeConfigID(id uint64) employeeconfigOption {
  6290. return func(m *EmployeeConfigMutation) {
  6291. var (
  6292. err error
  6293. once sync.Once
  6294. value *EmployeeConfig
  6295. )
  6296. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  6297. once.Do(func() {
  6298. if m.done {
  6299. err = errors.New("querying old values post mutation is not allowed")
  6300. } else {
  6301. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  6302. }
  6303. })
  6304. return value, err
  6305. }
  6306. m.id = &id
  6307. }
  6308. }
  6309. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  6310. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  6311. return func(m *EmployeeConfigMutation) {
  6312. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  6313. return node, nil
  6314. }
  6315. m.id = &node.ID
  6316. }
  6317. }
  6318. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6319. // executed in a transaction (ent.Tx), a transactional client is returned.
  6320. func (m EmployeeConfigMutation) Client() *Client {
  6321. client := &Client{config: m.config}
  6322. client.init()
  6323. return client
  6324. }
  6325. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6326. // it returns an error otherwise.
  6327. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  6328. if _, ok := m.driver.(*txDriver); !ok {
  6329. return nil, errors.New("ent: mutation is not running in a transaction")
  6330. }
  6331. tx := &Tx{config: m.config}
  6332. tx.init()
  6333. return tx, nil
  6334. }
  6335. // SetID sets the value of the id field. Note that this
  6336. // operation is only accepted on creation of EmployeeConfig entities.
  6337. func (m *EmployeeConfigMutation) SetID(id uint64) {
  6338. m.id = &id
  6339. }
  6340. // ID returns the ID value in the mutation. Note that the ID is only available
  6341. // if it was provided to the builder or after it was returned from the database.
  6342. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  6343. if m.id == nil {
  6344. return
  6345. }
  6346. return *m.id, true
  6347. }
  6348. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6349. // That means, if the mutation is applied within a transaction with an isolation level such
  6350. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6351. // or updated by the mutation.
  6352. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  6353. switch {
  6354. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6355. id, exists := m.ID()
  6356. if exists {
  6357. return []uint64{id}, nil
  6358. }
  6359. fallthrough
  6360. case m.op.Is(OpUpdate | OpDelete):
  6361. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  6362. default:
  6363. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6364. }
  6365. }
  6366. // SetCreatedAt sets the "created_at" field.
  6367. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  6368. m.created_at = &t
  6369. }
  6370. // CreatedAt returns the value of the "created_at" field in the mutation.
  6371. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  6372. v := m.created_at
  6373. if v == nil {
  6374. return
  6375. }
  6376. return *v, true
  6377. }
  6378. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  6379. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6381. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6382. if !m.op.Is(OpUpdateOne) {
  6383. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6384. }
  6385. if m.id == nil || m.oldValue == nil {
  6386. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6387. }
  6388. oldValue, err := m.oldValue(ctx)
  6389. if err != nil {
  6390. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6391. }
  6392. return oldValue.CreatedAt, nil
  6393. }
  6394. // ResetCreatedAt resets all changes to the "created_at" field.
  6395. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  6396. m.created_at = nil
  6397. }
  6398. // SetUpdatedAt sets the "updated_at" field.
  6399. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  6400. m.updated_at = &t
  6401. }
  6402. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6403. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  6404. v := m.updated_at
  6405. if v == nil {
  6406. return
  6407. }
  6408. return *v, true
  6409. }
  6410. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  6411. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6413. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6414. if !m.op.Is(OpUpdateOne) {
  6415. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6416. }
  6417. if m.id == nil || m.oldValue == nil {
  6418. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6419. }
  6420. oldValue, err := m.oldValue(ctx)
  6421. if err != nil {
  6422. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6423. }
  6424. return oldValue.UpdatedAt, nil
  6425. }
  6426. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6427. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  6428. m.updated_at = nil
  6429. }
  6430. // SetDeletedAt sets the "deleted_at" field.
  6431. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  6432. m.deleted_at = &t
  6433. }
  6434. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6435. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  6436. v := m.deleted_at
  6437. if v == nil {
  6438. return
  6439. }
  6440. return *v, true
  6441. }
  6442. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  6443. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6445. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6446. if !m.op.Is(OpUpdateOne) {
  6447. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6448. }
  6449. if m.id == nil || m.oldValue == nil {
  6450. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6451. }
  6452. oldValue, err := m.oldValue(ctx)
  6453. if err != nil {
  6454. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6455. }
  6456. return oldValue.DeletedAt, nil
  6457. }
  6458. // ClearDeletedAt clears the value of the "deleted_at" field.
  6459. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  6460. m.deleted_at = nil
  6461. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  6462. }
  6463. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6464. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  6465. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  6466. return ok
  6467. }
  6468. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6469. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  6470. m.deleted_at = nil
  6471. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  6472. }
  6473. // SetStype sets the "stype" field.
  6474. func (m *EmployeeConfigMutation) SetStype(s string) {
  6475. m.stype = &s
  6476. }
  6477. // Stype returns the value of the "stype" field in the mutation.
  6478. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  6479. v := m.stype
  6480. if v == nil {
  6481. return
  6482. }
  6483. return *v, true
  6484. }
  6485. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  6486. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6488. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  6489. if !m.op.Is(OpUpdateOne) {
  6490. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  6491. }
  6492. if m.id == nil || m.oldValue == nil {
  6493. return v, errors.New("OldStype requires an ID field in the mutation")
  6494. }
  6495. oldValue, err := m.oldValue(ctx)
  6496. if err != nil {
  6497. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  6498. }
  6499. return oldValue.Stype, nil
  6500. }
  6501. // ResetStype resets all changes to the "stype" field.
  6502. func (m *EmployeeConfigMutation) ResetStype() {
  6503. m.stype = nil
  6504. }
  6505. // SetTitle sets the "title" field.
  6506. func (m *EmployeeConfigMutation) SetTitle(s string) {
  6507. m.title = &s
  6508. }
  6509. // Title returns the value of the "title" field in the mutation.
  6510. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  6511. v := m.title
  6512. if v == nil {
  6513. return
  6514. }
  6515. return *v, true
  6516. }
  6517. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  6518. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6520. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  6521. if !m.op.Is(OpUpdateOne) {
  6522. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  6523. }
  6524. if m.id == nil || m.oldValue == nil {
  6525. return v, errors.New("OldTitle requires an ID field in the mutation")
  6526. }
  6527. oldValue, err := m.oldValue(ctx)
  6528. if err != nil {
  6529. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  6530. }
  6531. return oldValue.Title, nil
  6532. }
  6533. // ResetTitle resets all changes to the "title" field.
  6534. func (m *EmployeeConfigMutation) ResetTitle() {
  6535. m.title = nil
  6536. }
  6537. // SetPhoto sets the "photo" field.
  6538. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  6539. m.photo = &s
  6540. }
  6541. // Photo returns the value of the "photo" field in the mutation.
  6542. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  6543. v := m.photo
  6544. if v == nil {
  6545. return
  6546. }
  6547. return *v, true
  6548. }
  6549. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  6550. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6552. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  6553. if !m.op.Is(OpUpdateOne) {
  6554. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  6555. }
  6556. if m.id == nil || m.oldValue == nil {
  6557. return v, errors.New("OldPhoto requires an ID field in the mutation")
  6558. }
  6559. oldValue, err := m.oldValue(ctx)
  6560. if err != nil {
  6561. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  6562. }
  6563. return oldValue.Photo, nil
  6564. }
  6565. // ResetPhoto resets all changes to the "photo" field.
  6566. func (m *EmployeeConfigMutation) ResetPhoto() {
  6567. m.photo = nil
  6568. }
  6569. // SetOrganizationID sets the "organization_id" field.
  6570. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  6571. m.organization_id = &u
  6572. m.addorganization_id = nil
  6573. }
  6574. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6575. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  6576. v := m.organization_id
  6577. if v == nil {
  6578. return
  6579. }
  6580. return *v, true
  6581. }
  6582. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  6583. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  6584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6585. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6586. if !m.op.Is(OpUpdateOne) {
  6587. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6588. }
  6589. if m.id == nil || m.oldValue == nil {
  6590. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6591. }
  6592. oldValue, err := m.oldValue(ctx)
  6593. if err != nil {
  6594. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6595. }
  6596. return oldValue.OrganizationID, nil
  6597. }
  6598. // AddOrganizationID adds u to the "organization_id" field.
  6599. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  6600. if m.addorganization_id != nil {
  6601. *m.addorganization_id += u
  6602. } else {
  6603. m.addorganization_id = &u
  6604. }
  6605. }
  6606. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6607. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  6608. v := m.addorganization_id
  6609. if v == nil {
  6610. return
  6611. }
  6612. return *v, true
  6613. }
  6614. // ClearOrganizationID clears the value of the "organization_id" field.
  6615. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  6616. m.organization_id = nil
  6617. m.addorganization_id = nil
  6618. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  6619. }
  6620. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  6621. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  6622. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  6623. return ok
  6624. }
  6625. // ResetOrganizationID resets all changes to the "organization_id" field.
  6626. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  6627. m.organization_id = nil
  6628. m.addorganization_id = nil
  6629. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  6630. }
  6631. // Where appends a list predicates to the EmployeeConfigMutation builder.
  6632. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  6633. m.predicates = append(m.predicates, ps...)
  6634. }
  6635. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  6636. // users can use type-assertion to append predicates that do not depend on any generated package.
  6637. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  6638. p := make([]predicate.EmployeeConfig, len(ps))
  6639. for i := range ps {
  6640. p[i] = ps[i]
  6641. }
  6642. m.Where(p...)
  6643. }
  6644. // Op returns the operation name.
  6645. func (m *EmployeeConfigMutation) Op() Op {
  6646. return m.op
  6647. }
  6648. // SetOp allows setting the mutation operation.
  6649. func (m *EmployeeConfigMutation) SetOp(op Op) {
  6650. m.op = op
  6651. }
  6652. // Type returns the node type of this mutation (EmployeeConfig).
  6653. func (m *EmployeeConfigMutation) Type() string {
  6654. return m.typ
  6655. }
  6656. // Fields returns all fields that were changed during this mutation. Note that in
  6657. // order to get all numeric fields that were incremented/decremented, call
  6658. // AddedFields().
  6659. func (m *EmployeeConfigMutation) Fields() []string {
  6660. fields := make([]string, 0, 7)
  6661. if m.created_at != nil {
  6662. fields = append(fields, employeeconfig.FieldCreatedAt)
  6663. }
  6664. if m.updated_at != nil {
  6665. fields = append(fields, employeeconfig.FieldUpdatedAt)
  6666. }
  6667. if m.deleted_at != nil {
  6668. fields = append(fields, employeeconfig.FieldDeletedAt)
  6669. }
  6670. if m.stype != nil {
  6671. fields = append(fields, employeeconfig.FieldStype)
  6672. }
  6673. if m.title != nil {
  6674. fields = append(fields, employeeconfig.FieldTitle)
  6675. }
  6676. if m.photo != nil {
  6677. fields = append(fields, employeeconfig.FieldPhoto)
  6678. }
  6679. if m.organization_id != nil {
  6680. fields = append(fields, employeeconfig.FieldOrganizationID)
  6681. }
  6682. return fields
  6683. }
  6684. // Field returns the value of a field with the given name. The second boolean
  6685. // return value indicates that this field was not set, or was not defined in the
  6686. // schema.
  6687. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  6688. switch name {
  6689. case employeeconfig.FieldCreatedAt:
  6690. return m.CreatedAt()
  6691. case employeeconfig.FieldUpdatedAt:
  6692. return m.UpdatedAt()
  6693. case employeeconfig.FieldDeletedAt:
  6694. return m.DeletedAt()
  6695. case employeeconfig.FieldStype:
  6696. return m.Stype()
  6697. case employeeconfig.FieldTitle:
  6698. return m.Title()
  6699. case employeeconfig.FieldPhoto:
  6700. return m.Photo()
  6701. case employeeconfig.FieldOrganizationID:
  6702. return m.OrganizationID()
  6703. }
  6704. return nil, false
  6705. }
  6706. // OldField returns the old value of the field from the database. An error is
  6707. // returned if the mutation operation is not UpdateOne, or the query to the
  6708. // database failed.
  6709. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6710. switch name {
  6711. case employeeconfig.FieldCreatedAt:
  6712. return m.OldCreatedAt(ctx)
  6713. case employeeconfig.FieldUpdatedAt:
  6714. return m.OldUpdatedAt(ctx)
  6715. case employeeconfig.FieldDeletedAt:
  6716. return m.OldDeletedAt(ctx)
  6717. case employeeconfig.FieldStype:
  6718. return m.OldStype(ctx)
  6719. case employeeconfig.FieldTitle:
  6720. return m.OldTitle(ctx)
  6721. case employeeconfig.FieldPhoto:
  6722. return m.OldPhoto(ctx)
  6723. case employeeconfig.FieldOrganizationID:
  6724. return m.OldOrganizationID(ctx)
  6725. }
  6726. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  6727. }
  6728. // SetField sets the value of a field with the given name. It returns an error if
  6729. // the field is not defined in the schema, or if the type mismatched the field
  6730. // type.
  6731. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  6732. switch name {
  6733. case employeeconfig.FieldCreatedAt:
  6734. v, ok := value.(time.Time)
  6735. if !ok {
  6736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6737. }
  6738. m.SetCreatedAt(v)
  6739. return nil
  6740. case employeeconfig.FieldUpdatedAt:
  6741. v, ok := value.(time.Time)
  6742. if !ok {
  6743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6744. }
  6745. m.SetUpdatedAt(v)
  6746. return nil
  6747. case employeeconfig.FieldDeletedAt:
  6748. v, ok := value.(time.Time)
  6749. if !ok {
  6750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6751. }
  6752. m.SetDeletedAt(v)
  6753. return nil
  6754. case employeeconfig.FieldStype:
  6755. v, ok := value.(string)
  6756. if !ok {
  6757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6758. }
  6759. m.SetStype(v)
  6760. return nil
  6761. case employeeconfig.FieldTitle:
  6762. v, ok := value.(string)
  6763. if !ok {
  6764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6765. }
  6766. m.SetTitle(v)
  6767. return nil
  6768. case employeeconfig.FieldPhoto:
  6769. v, ok := value.(string)
  6770. if !ok {
  6771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6772. }
  6773. m.SetPhoto(v)
  6774. return nil
  6775. case employeeconfig.FieldOrganizationID:
  6776. v, ok := value.(uint64)
  6777. if !ok {
  6778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6779. }
  6780. m.SetOrganizationID(v)
  6781. return nil
  6782. }
  6783. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  6784. }
  6785. // AddedFields returns all numeric fields that were incremented/decremented during
  6786. // this mutation.
  6787. func (m *EmployeeConfigMutation) AddedFields() []string {
  6788. var fields []string
  6789. if m.addorganization_id != nil {
  6790. fields = append(fields, employeeconfig.FieldOrganizationID)
  6791. }
  6792. return fields
  6793. }
  6794. // AddedField returns the numeric value that was incremented/decremented on a field
  6795. // with the given name. The second boolean return value indicates that this field
  6796. // was not set, or was not defined in the schema.
  6797. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  6798. switch name {
  6799. case employeeconfig.FieldOrganizationID:
  6800. return m.AddedOrganizationID()
  6801. }
  6802. return nil, false
  6803. }
  6804. // AddField adds the value to the field with the given name. It returns an error if
  6805. // the field is not defined in the schema, or if the type mismatched the field
  6806. // type.
  6807. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  6808. switch name {
  6809. case employeeconfig.FieldOrganizationID:
  6810. v, ok := value.(int64)
  6811. if !ok {
  6812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6813. }
  6814. m.AddOrganizationID(v)
  6815. return nil
  6816. }
  6817. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  6818. }
  6819. // ClearedFields returns all nullable fields that were cleared during this
  6820. // mutation.
  6821. func (m *EmployeeConfigMutation) ClearedFields() []string {
  6822. var fields []string
  6823. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  6824. fields = append(fields, employeeconfig.FieldDeletedAt)
  6825. }
  6826. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  6827. fields = append(fields, employeeconfig.FieldOrganizationID)
  6828. }
  6829. return fields
  6830. }
  6831. // FieldCleared returns a boolean indicating if a field with the given name was
  6832. // cleared in this mutation.
  6833. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  6834. _, ok := m.clearedFields[name]
  6835. return ok
  6836. }
  6837. // ClearField clears the value of the field with the given name. It returns an
  6838. // error if the field is not defined in the schema.
  6839. func (m *EmployeeConfigMutation) ClearField(name string) error {
  6840. switch name {
  6841. case employeeconfig.FieldDeletedAt:
  6842. m.ClearDeletedAt()
  6843. return nil
  6844. case employeeconfig.FieldOrganizationID:
  6845. m.ClearOrganizationID()
  6846. return nil
  6847. }
  6848. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  6849. }
  6850. // ResetField resets all changes in the mutation for the field with the given name.
  6851. // It returns an error if the field is not defined in the schema.
  6852. func (m *EmployeeConfigMutation) ResetField(name string) error {
  6853. switch name {
  6854. case employeeconfig.FieldCreatedAt:
  6855. m.ResetCreatedAt()
  6856. return nil
  6857. case employeeconfig.FieldUpdatedAt:
  6858. m.ResetUpdatedAt()
  6859. return nil
  6860. case employeeconfig.FieldDeletedAt:
  6861. m.ResetDeletedAt()
  6862. return nil
  6863. case employeeconfig.FieldStype:
  6864. m.ResetStype()
  6865. return nil
  6866. case employeeconfig.FieldTitle:
  6867. m.ResetTitle()
  6868. return nil
  6869. case employeeconfig.FieldPhoto:
  6870. m.ResetPhoto()
  6871. return nil
  6872. case employeeconfig.FieldOrganizationID:
  6873. m.ResetOrganizationID()
  6874. return nil
  6875. }
  6876. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  6877. }
  6878. // AddedEdges returns all edge names that were set/added in this mutation.
  6879. func (m *EmployeeConfigMutation) AddedEdges() []string {
  6880. edges := make([]string, 0, 0)
  6881. return edges
  6882. }
  6883. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6884. // name in this mutation.
  6885. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  6886. return nil
  6887. }
  6888. // RemovedEdges returns all edge names that were removed in this mutation.
  6889. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  6890. edges := make([]string, 0, 0)
  6891. return edges
  6892. }
  6893. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6894. // the given name in this mutation.
  6895. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  6896. return nil
  6897. }
  6898. // ClearedEdges returns all edge names that were cleared in this mutation.
  6899. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  6900. edges := make([]string, 0, 0)
  6901. return edges
  6902. }
  6903. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6904. // was cleared in this mutation.
  6905. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  6906. return false
  6907. }
  6908. // ClearEdge clears the value of the edge with the given name. It returns an error
  6909. // if that edge is not defined in the schema.
  6910. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  6911. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  6912. }
  6913. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6914. // It returns an error if the edge is not defined in the schema.
  6915. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  6916. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  6917. }
  6918. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  6919. type LabelMutation struct {
  6920. config
  6921. op Op
  6922. typ string
  6923. id *uint64
  6924. created_at *time.Time
  6925. updated_at *time.Time
  6926. status *uint8
  6927. addstatus *int8
  6928. _type *int
  6929. add_type *int
  6930. name *string
  6931. from *int
  6932. addfrom *int
  6933. mode *int
  6934. addmode *int
  6935. conditions *string
  6936. organization_id *uint64
  6937. addorganization_id *int64
  6938. clearedFields map[string]struct{}
  6939. label_relationships map[uint64]struct{}
  6940. removedlabel_relationships map[uint64]struct{}
  6941. clearedlabel_relationships bool
  6942. done bool
  6943. oldValue func(context.Context) (*Label, error)
  6944. predicates []predicate.Label
  6945. }
  6946. var _ ent.Mutation = (*LabelMutation)(nil)
  6947. // labelOption allows management of the mutation configuration using functional options.
  6948. type labelOption func(*LabelMutation)
  6949. // newLabelMutation creates new mutation for the Label entity.
  6950. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  6951. m := &LabelMutation{
  6952. config: c,
  6953. op: op,
  6954. typ: TypeLabel,
  6955. clearedFields: make(map[string]struct{}),
  6956. }
  6957. for _, opt := range opts {
  6958. opt(m)
  6959. }
  6960. return m
  6961. }
  6962. // withLabelID sets the ID field of the mutation.
  6963. func withLabelID(id uint64) labelOption {
  6964. return func(m *LabelMutation) {
  6965. var (
  6966. err error
  6967. once sync.Once
  6968. value *Label
  6969. )
  6970. m.oldValue = func(ctx context.Context) (*Label, error) {
  6971. once.Do(func() {
  6972. if m.done {
  6973. err = errors.New("querying old values post mutation is not allowed")
  6974. } else {
  6975. value, err = m.Client().Label.Get(ctx, id)
  6976. }
  6977. })
  6978. return value, err
  6979. }
  6980. m.id = &id
  6981. }
  6982. }
  6983. // withLabel sets the old Label of the mutation.
  6984. func withLabel(node *Label) labelOption {
  6985. return func(m *LabelMutation) {
  6986. m.oldValue = func(context.Context) (*Label, error) {
  6987. return node, nil
  6988. }
  6989. m.id = &node.ID
  6990. }
  6991. }
  6992. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6993. // executed in a transaction (ent.Tx), a transactional client is returned.
  6994. func (m LabelMutation) Client() *Client {
  6995. client := &Client{config: m.config}
  6996. client.init()
  6997. return client
  6998. }
  6999. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7000. // it returns an error otherwise.
  7001. func (m LabelMutation) Tx() (*Tx, error) {
  7002. if _, ok := m.driver.(*txDriver); !ok {
  7003. return nil, errors.New("ent: mutation is not running in a transaction")
  7004. }
  7005. tx := &Tx{config: m.config}
  7006. tx.init()
  7007. return tx, nil
  7008. }
  7009. // SetID sets the value of the id field. Note that this
  7010. // operation is only accepted on creation of Label entities.
  7011. func (m *LabelMutation) SetID(id uint64) {
  7012. m.id = &id
  7013. }
  7014. // ID returns the ID value in the mutation. Note that the ID is only available
  7015. // if it was provided to the builder or after it was returned from the database.
  7016. func (m *LabelMutation) ID() (id uint64, exists bool) {
  7017. if m.id == nil {
  7018. return
  7019. }
  7020. return *m.id, true
  7021. }
  7022. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7023. // That means, if the mutation is applied within a transaction with an isolation level such
  7024. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7025. // or updated by the mutation.
  7026. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  7027. switch {
  7028. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7029. id, exists := m.ID()
  7030. if exists {
  7031. return []uint64{id}, nil
  7032. }
  7033. fallthrough
  7034. case m.op.Is(OpUpdate | OpDelete):
  7035. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  7036. default:
  7037. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7038. }
  7039. }
  7040. // SetCreatedAt sets the "created_at" field.
  7041. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  7042. m.created_at = &t
  7043. }
  7044. // CreatedAt returns the value of the "created_at" field in the mutation.
  7045. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  7046. v := m.created_at
  7047. if v == nil {
  7048. return
  7049. }
  7050. return *v, true
  7051. }
  7052. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  7053. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7055. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7056. if !m.op.Is(OpUpdateOne) {
  7057. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7058. }
  7059. if m.id == nil || m.oldValue == nil {
  7060. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7061. }
  7062. oldValue, err := m.oldValue(ctx)
  7063. if err != nil {
  7064. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7065. }
  7066. return oldValue.CreatedAt, nil
  7067. }
  7068. // ResetCreatedAt resets all changes to the "created_at" field.
  7069. func (m *LabelMutation) ResetCreatedAt() {
  7070. m.created_at = nil
  7071. }
  7072. // SetUpdatedAt sets the "updated_at" field.
  7073. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  7074. m.updated_at = &t
  7075. }
  7076. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7077. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  7078. v := m.updated_at
  7079. if v == nil {
  7080. return
  7081. }
  7082. return *v, true
  7083. }
  7084. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  7085. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7087. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7088. if !m.op.Is(OpUpdateOne) {
  7089. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7090. }
  7091. if m.id == nil || m.oldValue == nil {
  7092. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7093. }
  7094. oldValue, err := m.oldValue(ctx)
  7095. if err != nil {
  7096. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7097. }
  7098. return oldValue.UpdatedAt, nil
  7099. }
  7100. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7101. func (m *LabelMutation) ResetUpdatedAt() {
  7102. m.updated_at = nil
  7103. }
  7104. // SetStatus sets the "status" field.
  7105. func (m *LabelMutation) SetStatus(u uint8) {
  7106. m.status = &u
  7107. m.addstatus = nil
  7108. }
  7109. // Status returns the value of the "status" field in the mutation.
  7110. func (m *LabelMutation) Status() (r uint8, exists bool) {
  7111. v := m.status
  7112. if v == nil {
  7113. return
  7114. }
  7115. return *v, true
  7116. }
  7117. // OldStatus returns the old "status" field's value of the Label entity.
  7118. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7120. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7121. if !m.op.Is(OpUpdateOne) {
  7122. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7123. }
  7124. if m.id == nil || m.oldValue == nil {
  7125. return v, errors.New("OldStatus requires an ID field in the mutation")
  7126. }
  7127. oldValue, err := m.oldValue(ctx)
  7128. if err != nil {
  7129. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7130. }
  7131. return oldValue.Status, nil
  7132. }
  7133. // AddStatus adds u to the "status" field.
  7134. func (m *LabelMutation) AddStatus(u int8) {
  7135. if m.addstatus != nil {
  7136. *m.addstatus += u
  7137. } else {
  7138. m.addstatus = &u
  7139. }
  7140. }
  7141. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7142. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  7143. v := m.addstatus
  7144. if v == nil {
  7145. return
  7146. }
  7147. return *v, true
  7148. }
  7149. // ClearStatus clears the value of the "status" field.
  7150. func (m *LabelMutation) ClearStatus() {
  7151. m.status = nil
  7152. m.addstatus = nil
  7153. m.clearedFields[label.FieldStatus] = struct{}{}
  7154. }
  7155. // StatusCleared returns if the "status" field was cleared in this mutation.
  7156. func (m *LabelMutation) StatusCleared() bool {
  7157. _, ok := m.clearedFields[label.FieldStatus]
  7158. return ok
  7159. }
  7160. // ResetStatus resets all changes to the "status" field.
  7161. func (m *LabelMutation) ResetStatus() {
  7162. m.status = nil
  7163. m.addstatus = nil
  7164. delete(m.clearedFields, label.FieldStatus)
  7165. }
  7166. // SetType sets the "type" field.
  7167. func (m *LabelMutation) SetType(i int) {
  7168. m._type = &i
  7169. m.add_type = nil
  7170. }
  7171. // GetType returns the value of the "type" field in the mutation.
  7172. func (m *LabelMutation) GetType() (r int, exists bool) {
  7173. v := m._type
  7174. if v == nil {
  7175. return
  7176. }
  7177. return *v, true
  7178. }
  7179. // OldType returns the old "type" field's value of the Label entity.
  7180. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7182. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  7183. if !m.op.Is(OpUpdateOne) {
  7184. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7185. }
  7186. if m.id == nil || m.oldValue == nil {
  7187. return v, errors.New("OldType requires an ID field in the mutation")
  7188. }
  7189. oldValue, err := m.oldValue(ctx)
  7190. if err != nil {
  7191. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7192. }
  7193. return oldValue.Type, nil
  7194. }
  7195. // AddType adds i to the "type" field.
  7196. func (m *LabelMutation) AddType(i int) {
  7197. if m.add_type != nil {
  7198. *m.add_type += i
  7199. } else {
  7200. m.add_type = &i
  7201. }
  7202. }
  7203. // AddedType returns the value that was added to the "type" field in this mutation.
  7204. func (m *LabelMutation) AddedType() (r int, exists bool) {
  7205. v := m.add_type
  7206. if v == nil {
  7207. return
  7208. }
  7209. return *v, true
  7210. }
  7211. // ResetType resets all changes to the "type" field.
  7212. func (m *LabelMutation) ResetType() {
  7213. m._type = nil
  7214. m.add_type = nil
  7215. }
  7216. // SetName sets the "name" field.
  7217. func (m *LabelMutation) SetName(s string) {
  7218. m.name = &s
  7219. }
  7220. // Name returns the value of the "name" field in the mutation.
  7221. func (m *LabelMutation) Name() (r string, exists bool) {
  7222. v := m.name
  7223. if v == nil {
  7224. return
  7225. }
  7226. return *v, true
  7227. }
  7228. // OldName returns the old "name" field's value of the Label entity.
  7229. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7231. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  7232. if !m.op.Is(OpUpdateOne) {
  7233. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7234. }
  7235. if m.id == nil || m.oldValue == nil {
  7236. return v, errors.New("OldName requires an ID field in the mutation")
  7237. }
  7238. oldValue, err := m.oldValue(ctx)
  7239. if err != nil {
  7240. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7241. }
  7242. return oldValue.Name, nil
  7243. }
  7244. // ResetName resets all changes to the "name" field.
  7245. func (m *LabelMutation) ResetName() {
  7246. m.name = nil
  7247. }
  7248. // SetFrom sets the "from" field.
  7249. func (m *LabelMutation) SetFrom(i int) {
  7250. m.from = &i
  7251. m.addfrom = nil
  7252. }
  7253. // From returns the value of the "from" field in the mutation.
  7254. func (m *LabelMutation) From() (r int, exists bool) {
  7255. v := m.from
  7256. if v == nil {
  7257. return
  7258. }
  7259. return *v, true
  7260. }
  7261. // OldFrom returns the old "from" field's value of the Label entity.
  7262. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7264. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  7265. if !m.op.Is(OpUpdateOne) {
  7266. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  7267. }
  7268. if m.id == nil || m.oldValue == nil {
  7269. return v, errors.New("OldFrom requires an ID field in the mutation")
  7270. }
  7271. oldValue, err := m.oldValue(ctx)
  7272. if err != nil {
  7273. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  7274. }
  7275. return oldValue.From, nil
  7276. }
  7277. // AddFrom adds i to the "from" field.
  7278. func (m *LabelMutation) AddFrom(i int) {
  7279. if m.addfrom != nil {
  7280. *m.addfrom += i
  7281. } else {
  7282. m.addfrom = &i
  7283. }
  7284. }
  7285. // AddedFrom returns the value that was added to the "from" field in this mutation.
  7286. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  7287. v := m.addfrom
  7288. if v == nil {
  7289. return
  7290. }
  7291. return *v, true
  7292. }
  7293. // ResetFrom resets all changes to the "from" field.
  7294. func (m *LabelMutation) ResetFrom() {
  7295. m.from = nil
  7296. m.addfrom = nil
  7297. }
  7298. // SetMode sets the "mode" field.
  7299. func (m *LabelMutation) SetMode(i int) {
  7300. m.mode = &i
  7301. m.addmode = nil
  7302. }
  7303. // Mode returns the value of the "mode" field in the mutation.
  7304. func (m *LabelMutation) Mode() (r int, exists bool) {
  7305. v := m.mode
  7306. if v == nil {
  7307. return
  7308. }
  7309. return *v, true
  7310. }
  7311. // OldMode returns the old "mode" field's value of the Label entity.
  7312. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7314. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  7315. if !m.op.Is(OpUpdateOne) {
  7316. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  7317. }
  7318. if m.id == nil || m.oldValue == nil {
  7319. return v, errors.New("OldMode requires an ID field in the mutation")
  7320. }
  7321. oldValue, err := m.oldValue(ctx)
  7322. if err != nil {
  7323. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  7324. }
  7325. return oldValue.Mode, nil
  7326. }
  7327. // AddMode adds i to the "mode" field.
  7328. func (m *LabelMutation) AddMode(i int) {
  7329. if m.addmode != nil {
  7330. *m.addmode += i
  7331. } else {
  7332. m.addmode = &i
  7333. }
  7334. }
  7335. // AddedMode returns the value that was added to the "mode" field in this mutation.
  7336. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  7337. v := m.addmode
  7338. if v == nil {
  7339. return
  7340. }
  7341. return *v, true
  7342. }
  7343. // ResetMode resets all changes to the "mode" field.
  7344. func (m *LabelMutation) ResetMode() {
  7345. m.mode = nil
  7346. m.addmode = nil
  7347. }
  7348. // SetConditions sets the "conditions" field.
  7349. func (m *LabelMutation) SetConditions(s string) {
  7350. m.conditions = &s
  7351. }
  7352. // Conditions returns the value of the "conditions" field in the mutation.
  7353. func (m *LabelMutation) Conditions() (r string, exists bool) {
  7354. v := m.conditions
  7355. if v == nil {
  7356. return
  7357. }
  7358. return *v, true
  7359. }
  7360. // OldConditions returns the old "conditions" field's value of the Label entity.
  7361. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7363. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  7364. if !m.op.Is(OpUpdateOne) {
  7365. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  7366. }
  7367. if m.id == nil || m.oldValue == nil {
  7368. return v, errors.New("OldConditions requires an ID field in the mutation")
  7369. }
  7370. oldValue, err := m.oldValue(ctx)
  7371. if err != nil {
  7372. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  7373. }
  7374. return oldValue.Conditions, nil
  7375. }
  7376. // ClearConditions clears the value of the "conditions" field.
  7377. func (m *LabelMutation) ClearConditions() {
  7378. m.conditions = nil
  7379. m.clearedFields[label.FieldConditions] = struct{}{}
  7380. }
  7381. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  7382. func (m *LabelMutation) ConditionsCleared() bool {
  7383. _, ok := m.clearedFields[label.FieldConditions]
  7384. return ok
  7385. }
  7386. // ResetConditions resets all changes to the "conditions" field.
  7387. func (m *LabelMutation) ResetConditions() {
  7388. m.conditions = nil
  7389. delete(m.clearedFields, label.FieldConditions)
  7390. }
  7391. // SetOrganizationID sets the "organization_id" field.
  7392. func (m *LabelMutation) SetOrganizationID(u uint64) {
  7393. m.organization_id = &u
  7394. m.addorganization_id = nil
  7395. }
  7396. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7397. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  7398. v := m.organization_id
  7399. if v == nil {
  7400. return
  7401. }
  7402. return *v, true
  7403. }
  7404. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  7405. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  7406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7407. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7408. if !m.op.Is(OpUpdateOne) {
  7409. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7410. }
  7411. if m.id == nil || m.oldValue == nil {
  7412. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7413. }
  7414. oldValue, err := m.oldValue(ctx)
  7415. if err != nil {
  7416. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7417. }
  7418. return oldValue.OrganizationID, nil
  7419. }
  7420. // AddOrganizationID adds u to the "organization_id" field.
  7421. func (m *LabelMutation) AddOrganizationID(u int64) {
  7422. if m.addorganization_id != nil {
  7423. *m.addorganization_id += u
  7424. } else {
  7425. m.addorganization_id = &u
  7426. }
  7427. }
  7428. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7429. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  7430. v := m.addorganization_id
  7431. if v == nil {
  7432. return
  7433. }
  7434. return *v, true
  7435. }
  7436. // ClearOrganizationID clears the value of the "organization_id" field.
  7437. func (m *LabelMutation) ClearOrganizationID() {
  7438. m.organization_id = nil
  7439. m.addorganization_id = nil
  7440. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  7441. }
  7442. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  7443. func (m *LabelMutation) OrganizationIDCleared() bool {
  7444. _, ok := m.clearedFields[label.FieldOrganizationID]
  7445. return ok
  7446. }
  7447. // ResetOrganizationID resets all changes to the "organization_id" field.
  7448. func (m *LabelMutation) ResetOrganizationID() {
  7449. m.organization_id = nil
  7450. m.addorganization_id = nil
  7451. delete(m.clearedFields, label.FieldOrganizationID)
  7452. }
  7453. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  7454. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  7455. if m.label_relationships == nil {
  7456. m.label_relationships = make(map[uint64]struct{})
  7457. }
  7458. for i := range ids {
  7459. m.label_relationships[ids[i]] = struct{}{}
  7460. }
  7461. }
  7462. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  7463. func (m *LabelMutation) ClearLabelRelationships() {
  7464. m.clearedlabel_relationships = true
  7465. }
  7466. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  7467. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  7468. return m.clearedlabel_relationships
  7469. }
  7470. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  7471. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  7472. if m.removedlabel_relationships == nil {
  7473. m.removedlabel_relationships = make(map[uint64]struct{})
  7474. }
  7475. for i := range ids {
  7476. delete(m.label_relationships, ids[i])
  7477. m.removedlabel_relationships[ids[i]] = struct{}{}
  7478. }
  7479. }
  7480. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  7481. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  7482. for id := range m.removedlabel_relationships {
  7483. ids = append(ids, id)
  7484. }
  7485. return
  7486. }
  7487. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  7488. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  7489. for id := range m.label_relationships {
  7490. ids = append(ids, id)
  7491. }
  7492. return
  7493. }
  7494. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  7495. func (m *LabelMutation) ResetLabelRelationships() {
  7496. m.label_relationships = nil
  7497. m.clearedlabel_relationships = false
  7498. m.removedlabel_relationships = nil
  7499. }
  7500. // Where appends a list predicates to the LabelMutation builder.
  7501. func (m *LabelMutation) Where(ps ...predicate.Label) {
  7502. m.predicates = append(m.predicates, ps...)
  7503. }
  7504. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  7505. // users can use type-assertion to append predicates that do not depend on any generated package.
  7506. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  7507. p := make([]predicate.Label, len(ps))
  7508. for i := range ps {
  7509. p[i] = ps[i]
  7510. }
  7511. m.Where(p...)
  7512. }
  7513. // Op returns the operation name.
  7514. func (m *LabelMutation) Op() Op {
  7515. return m.op
  7516. }
  7517. // SetOp allows setting the mutation operation.
  7518. func (m *LabelMutation) SetOp(op Op) {
  7519. m.op = op
  7520. }
  7521. // Type returns the node type of this mutation (Label).
  7522. func (m *LabelMutation) Type() string {
  7523. return m.typ
  7524. }
  7525. // Fields returns all fields that were changed during this mutation. Note that in
  7526. // order to get all numeric fields that were incremented/decremented, call
  7527. // AddedFields().
  7528. func (m *LabelMutation) Fields() []string {
  7529. fields := make([]string, 0, 9)
  7530. if m.created_at != nil {
  7531. fields = append(fields, label.FieldCreatedAt)
  7532. }
  7533. if m.updated_at != nil {
  7534. fields = append(fields, label.FieldUpdatedAt)
  7535. }
  7536. if m.status != nil {
  7537. fields = append(fields, label.FieldStatus)
  7538. }
  7539. if m._type != nil {
  7540. fields = append(fields, label.FieldType)
  7541. }
  7542. if m.name != nil {
  7543. fields = append(fields, label.FieldName)
  7544. }
  7545. if m.from != nil {
  7546. fields = append(fields, label.FieldFrom)
  7547. }
  7548. if m.mode != nil {
  7549. fields = append(fields, label.FieldMode)
  7550. }
  7551. if m.conditions != nil {
  7552. fields = append(fields, label.FieldConditions)
  7553. }
  7554. if m.organization_id != nil {
  7555. fields = append(fields, label.FieldOrganizationID)
  7556. }
  7557. return fields
  7558. }
  7559. // Field returns the value of a field with the given name. The second boolean
  7560. // return value indicates that this field was not set, or was not defined in the
  7561. // schema.
  7562. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  7563. switch name {
  7564. case label.FieldCreatedAt:
  7565. return m.CreatedAt()
  7566. case label.FieldUpdatedAt:
  7567. return m.UpdatedAt()
  7568. case label.FieldStatus:
  7569. return m.Status()
  7570. case label.FieldType:
  7571. return m.GetType()
  7572. case label.FieldName:
  7573. return m.Name()
  7574. case label.FieldFrom:
  7575. return m.From()
  7576. case label.FieldMode:
  7577. return m.Mode()
  7578. case label.FieldConditions:
  7579. return m.Conditions()
  7580. case label.FieldOrganizationID:
  7581. return m.OrganizationID()
  7582. }
  7583. return nil, false
  7584. }
  7585. // OldField returns the old value of the field from the database. An error is
  7586. // returned if the mutation operation is not UpdateOne, or the query to the
  7587. // database failed.
  7588. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7589. switch name {
  7590. case label.FieldCreatedAt:
  7591. return m.OldCreatedAt(ctx)
  7592. case label.FieldUpdatedAt:
  7593. return m.OldUpdatedAt(ctx)
  7594. case label.FieldStatus:
  7595. return m.OldStatus(ctx)
  7596. case label.FieldType:
  7597. return m.OldType(ctx)
  7598. case label.FieldName:
  7599. return m.OldName(ctx)
  7600. case label.FieldFrom:
  7601. return m.OldFrom(ctx)
  7602. case label.FieldMode:
  7603. return m.OldMode(ctx)
  7604. case label.FieldConditions:
  7605. return m.OldConditions(ctx)
  7606. case label.FieldOrganizationID:
  7607. return m.OldOrganizationID(ctx)
  7608. }
  7609. return nil, fmt.Errorf("unknown Label field %s", name)
  7610. }
  7611. // SetField sets the value of a field with the given name. It returns an error if
  7612. // the field is not defined in the schema, or if the type mismatched the field
  7613. // type.
  7614. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  7615. switch name {
  7616. case label.FieldCreatedAt:
  7617. v, ok := value.(time.Time)
  7618. if !ok {
  7619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7620. }
  7621. m.SetCreatedAt(v)
  7622. return nil
  7623. case label.FieldUpdatedAt:
  7624. v, ok := value.(time.Time)
  7625. if !ok {
  7626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7627. }
  7628. m.SetUpdatedAt(v)
  7629. return nil
  7630. case label.FieldStatus:
  7631. v, ok := value.(uint8)
  7632. if !ok {
  7633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7634. }
  7635. m.SetStatus(v)
  7636. return nil
  7637. case label.FieldType:
  7638. v, ok := value.(int)
  7639. if !ok {
  7640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7641. }
  7642. m.SetType(v)
  7643. return nil
  7644. case label.FieldName:
  7645. v, ok := value.(string)
  7646. if !ok {
  7647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7648. }
  7649. m.SetName(v)
  7650. return nil
  7651. case label.FieldFrom:
  7652. v, ok := value.(int)
  7653. if !ok {
  7654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7655. }
  7656. m.SetFrom(v)
  7657. return nil
  7658. case label.FieldMode:
  7659. v, ok := value.(int)
  7660. if !ok {
  7661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7662. }
  7663. m.SetMode(v)
  7664. return nil
  7665. case label.FieldConditions:
  7666. v, ok := value.(string)
  7667. if !ok {
  7668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7669. }
  7670. m.SetConditions(v)
  7671. return nil
  7672. case label.FieldOrganizationID:
  7673. v, ok := value.(uint64)
  7674. if !ok {
  7675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7676. }
  7677. m.SetOrganizationID(v)
  7678. return nil
  7679. }
  7680. return fmt.Errorf("unknown Label field %s", name)
  7681. }
  7682. // AddedFields returns all numeric fields that were incremented/decremented during
  7683. // this mutation.
  7684. func (m *LabelMutation) AddedFields() []string {
  7685. var fields []string
  7686. if m.addstatus != nil {
  7687. fields = append(fields, label.FieldStatus)
  7688. }
  7689. if m.add_type != nil {
  7690. fields = append(fields, label.FieldType)
  7691. }
  7692. if m.addfrom != nil {
  7693. fields = append(fields, label.FieldFrom)
  7694. }
  7695. if m.addmode != nil {
  7696. fields = append(fields, label.FieldMode)
  7697. }
  7698. if m.addorganization_id != nil {
  7699. fields = append(fields, label.FieldOrganizationID)
  7700. }
  7701. return fields
  7702. }
  7703. // AddedField returns the numeric value that was incremented/decremented on a field
  7704. // with the given name. The second boolean return value indicates that this field
  7705. // was not set, or was not defined in the schema.
  7706. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  7707. switch name {
  7708. case label.FieldStatus:
  7709. return m.AddedStatus()
  7710. case label.FieldType:
  7711. return m.AddedType()
  7712. case label.FieldFrom:
  7713. return m.AddedFrom()
  7714. case label.FieldMode:
  7715. return m.AddedMode()
  7716. case label.FieldOrganizationID:
  7717. return m.AddedOrganizationID()
  7718. }
  7719. return nil, false
  7720. }
  7721. // AddField adds the value to the field with the given name. It returns an error if
  7722. // the field is not defined in the schema, or if the type mismatched the field
  7723. // type.
  7724. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  7725. switch name {
  7726. case label.FieldStatus:
  7727. v, ok := value.(int8)
  7728. if !ok {
  7729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7730. }
  7731. m.AddStatus(v)
  7732. return nil
  7733. case label.FieldType:
  7734. v, ok := value.(int)
  7735. if !ok {
  7736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7737. }
  7738. m.AddType(v)
  7739. return nil
  7740. case label.FieldFrom:
  7741. v, ok := value.(int)
  7742. if !ok {
  7743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7744. }
  7745. m.AddFrom(v)
  7746. return nil
  7747. case label.FieldMode:
  7748. v, ok := value.(int)
  7749. if !ok {
  7750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7751. }
  7752. m.AddMode(v)
  7753. return nil
  7754. case label.FieldOrganizationID:
  7755. v, ok := value.(int64)
  7756. if !ok {
  7757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7758. }
  7759. m.AddOrganizationID(v)
  7760. return nil
  7761. }
  7762. return fmt.Errorf("unknown Label numeric field %s", name)
  7763. }
  7764. // ClearedFields returns all nullable fields that were cleared during this
  7765. // mutation.
  7766. func (m *LabelMutation) ClearedFields() []string {
  7767. var fields []string
  7768. if m.FieldCleared(label.FieldStatus) {
  7769. fields = append(fields, label.FieldStatus)
  7770. }
  7771. if m.FieldCleared(label.FieldConditions) {
  7772. fields = append(fields, label.FieldConditions)
  7773. }
  7774. if m.FieldCleared(label.FieldOrganizationID) {
  7775. fields = append(fields, label.FieldOrganizationID)
  7776. }
  7777. return fields
  7778. }
  7779. // FieldCleared returns a boolean indicating if a field with the given name was
  7780. // cleared in this mutation.
  7781. func (m *LabelMutation) FieldCleared(name string) bool {
  7782. _, ok := m.clearedFields[name]
  7783. return ok
  7784. }
  7785. // ClearField clears the value of the field with the given name. It returns an
  7786. // error if the field is not defined in the schema.
  7787. func (m *LabelMutation) ClearField(name string) error {
  7788. switch name {
  7789. case label.FieldStatus:
  7790. m.ClearStatus()
  7791. return nil
  7792. case label.FieldConditions:
  7793. m.ClearConditions()
  7794. return nil
  7795. case label.FieldOrganizationID:
  7796. m.ClearOrganizationID()
  7797. return nil
  7798. }
  7799. return fmt.Errorf("unknown Label nullable field %s", name)
  7800. }
  7801. // ResetField resets all changes in the mutation for the field with the given name.
  7802. // It returns an error if the field is not defined in the schema.
  7803. func (m *LabelMutation) ResetField(name string) error {
  7804. switch name {
  7805. case label.FieldCreatedAt:
  7806. m.ResetCreatedAt()
  7807. return nil
  7808. case label.FieldUpdatedAt:
  7809. m.ResetUpdatedAt()
  7810. return nil
  7811. case label.FieldStatus:
  7812. m.ResetStatus()
  7813. return nil
  7814. case label.FieldType:
  7815. m.ResetType()
  7816. return nil
  7817. case label.FieldName:
  7818. m.ResetName()
  7819. return nil
  7820. case label.FieldFrom:
  7821. m.ResetFrom()
  7822. return nil
  7823. case label.FieldMode:
  7824. m.ResetMode()
  7825. return nil
  7826. case label.FieldConditions:
  7827. m.ResetConditions()
  7828. return nil
  7829. case label.FieldOrganizationID:
  7830. m.ResetOrganizationID()
  7831. return nil
  7832. }
  7833. return fmt.Errorf("unknown Label field %s", name)
  7834. }
  7835. // AddedEdges returns all edge names that were set/added in this mutation.
  7836. func (m *LabelMutation) AddedEdges() []string {
  7837. edges := make([]string, 0, 1)
  7838. if m.label_relationships != nil {
  7839. edges = append(edges, label.EdgeLabelRelationships)
  7840. }
  7841. return edges
  7842. }
  7843. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7844. // name in this mutation.
  7845. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  7846. switch name {
  7847. case label.EdgeLabelRelationships:
  7848. ids := make([]ent.Value, 0, len(m.label_relationships))
  7849. for id := range m.label_relationships {
  7850. ids = append(ids, id)
  7851. }
  7852. return ids
  7853. }
  7854. return nil
  7855. }
  7856. // RemovedEdges returns all edge names that were removed in this mutation.
  7857. func (m *LabelMutation) RemovedEdges() []string {
  7858. edges := make([]string, 0, 1)
  7859. if m.removedlabel_relationships != nil {
  7860. edges = append(edges, label.EdgeLabelRelationships)
  7861. }
  7862. return edges
  7863. }
  7864. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7865. // the given name in this mutation.
  7866. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  7867. switch name {
  7868. case label.EdgeLabelRelationships:
  7869. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  7870. for id := range m.removedlabel_relationships {
  7871. ids = append(ids, id)
  7872. }
  7873. return ids
  7874. }
  7875. return nil
  7876. }
  7877. // ClearedEdges returns all edge names that were cleared in this mutation.
  7878. func (m *LabelMutation) ClearedEdges() []string {
  7879. edges := make([]string, 0, 1)
  7880. if m.clearedlabel_relationships {
  7881. edges = append(edges, label.EdgeLabelRelationships)
  7882. }
  7883. return edges
  7884. }
  7885. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7886. // was cleared in this mutation.
  7887. func (m *LabelMutation) EdgeCleared(name string) bool {
  7888. switch name {
  7889. case label.EdgeLabelRelationships:
  7890. return m.clearedlabel_relationships
  7891. }
  7892. return false
  7893. }
  7894. // ClearEdge clears the value of the edge with the given name. It returns an error
  7895. // if that edge is not defined in the schema.
  7896. func (m *LabelMutation) ClearEdge(name string) error {
  7897. switch name {
  7898. }
  7899. return fmt.Errorf("unknown Label unique edge %s", name)
  7900. }
  7901. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7902. // It returns an error if the edge is not defined in the schema.
  7903. func (m *LabelMutation) ResetEdge(name string) error {
  7904. switch name {
  7905. case label.EdgeLabelRelationships:
  7906. m.ResetLabelRelationships()
  7907. return nil
  7908. }
  7909. return fmt.Errorf("unknown Label edge %s", name)
  7910. }
  7911. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  7912. type LabelRelationshipMutation struct {
  7913. config
  7914. op Op
  7915. typ string
  7916. id *uint64
  7917. created_at *time.Time
  7918. updated_at *time.Time
  7919. status *uint8
  7920. addstatus *int8
  7921. deleted_at *time.Time
  7922. organization_id *uint64
  7923. addorganization_id *int64
  7924. clearedFields map[string]struct{}
  7925. contacts *uint64
  7926. clearedcontacts bool
  7927. labels *uint64
  7928. clearedlabels bool
  7929. done bool
  7930. oldValue func(context.Context) (*LabelRelationship, error)
  7931. predicates []predicate.LabelRelationship
  7932. }
  7933. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  7934. // labelrelationshipOption allows management of the mutation configuration using functional options.
  7935. type labelrelationshipOption func(*LabelRelationshipMutation)
  7936. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  7937. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  7938. m := &LabelRelationshipMutation{
  7939. config: c,
  7940. op: op,
  7941. typ: TypeLabelRelationship,
  7942. clearedFields: make(map[string]struct{}),
  7943. }
  7944. for _, opt := range opts {
  7945. opt(m)
  7946. }
  7947. return m
  7948. }
  7949. // withLabelRelationshipID sets the ID field of the mutation.
  7950. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  7951. return func(m *LabelRelationshipMutation) {
  7952. var (
  7953. err error
  7954. once sync.Once
  7955. value *LabelRelationship
  7956. )
  7957. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  7958. once.Do(func() {
  7959. if m.done {
  7960. err = errors.New("querying old values post mutation is not allowed")
  7961. } else {
  7962. value, err = m.Client().LabelRelationship.Get(ctx, id)
  7963. }
  7964. })
  7965. return value, err
  7966. }
  7967. m.id = &id
  7968. }
  7969. }
  7970. // withLabelRelationship sets the old LabelRelationship of the mutation.
  7971. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  7972. return func(m *LabelRelationshipMutation) {
  7973. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  7974. return node, nil
  7975. }
  7976. m.id = &node.ID
  7977. }
  7978. }
  7979. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7980. // executed in a transaction (ent.Tx), a transactional client is returned.
  7981. func (m LabelRelationshipMutation) Client() *Client {
  7982. client := &Client{config: m.config}
  7983. client.init()
  7984. return client
  7985. }
  7986. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7987. // it returns an error otherwise.
  7988. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  7989. if _, ok := m.driver.(*txDriver); !ok {
  7990. return nil, errors.New("ent: mutation is not running in a transaction")
  7991. }
  7992. tx := &Tx{config: m.config}
  7993. tx.init()
  7994. return tx, nil
  7995. }
  7996. // SetID sets the value of the id field. Note that this
  7997. // operation is only accepted on creation of LabelRelationship entities.
  7998. func (m *LabelRelationshipMutation) SetID(id uint64) {
  7999. m.id = &id
  8000. }
  8001. // ID returns the ID value in the mutation. Note that the ID is only available
  8002. // if it was provided to the builder or after it was returned from the database.
  8003. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  8004. if m.id == nil {
  8005. return
  8006. }
  8007. return *m.id, true
  8008. }
  8009. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8010. // That means, if the mutation is applied within a transaction with an isolation level such
  8011. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8012. // or updated by the mutation.
  8013. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  8014. switch {
  8015. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8016. id, exists := m.ID()
  8017. if exists {
  8018. return []uint64{id}, nil
  8019. }
  8020. fallthrough
  8021. case m.op.Is(OpUpdate | OpDelete):
  8022. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  8023. default:
  8024. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8025. }
  8026. }
  8027. // SetCreatedAt sets the "created_at" field.
  8028. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  8029. m.created_at = &t
  8030. }
  8031. // CreatedAt returns the value of the "created_at" field in the mutation.
  8032. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  8033. v := m.created_at
  8034. if v == nil {
  8035. return
  8036. }
  8037. return *v, true
  8038. }
  8039. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  8040. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8042. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8043. if !m.op.Is(OpUpdateOne) {
  8044. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8045. }
  8046. if m.id == nil || m.oldValue == nil {
  8047. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8048. }
  8049. oldValue, err := m.oldValue(ctx)
  8050. if err != nil {
  8051. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8052. }
  8053. return oldValue.CreatedAt, nil
  8054. }
  8055. // ResetCreatedAt resets all changes to the "created_at" field.
  8056. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  8057. m.created_at = nil
  8058. }
  8059. // SetUpdatedAt sets the "updated_at" field.
  8060. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  8061. m.updated_at = &t
  8062. }
  8063. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8064. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  8065. v := m.updated_at
  8066. if v == nil {
  8067. return
  8068. }
  8069. return *v, true
  8070. }
  8071. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  8072. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8074. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8075. if !m.op.Is(OpUpdateOne) {
  8076. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8077. }
  8078. if m.id == nil || m.oldValue == nil {
  8079. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8080. }
  8081. oldValue, err := m.oldValue(ctx)
  8082. if err != nil {
  8083. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8084. }
  8085. return oldValue.UpdatedAt, nil
  8086. }
  8087. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8088. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  8089. m.updated_at = nil
  8090. }
  8091. // SetStatus sets the "status" field.
  8092. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  8093. m.status = &u
  8094. m.addstatus = nil
  8095. }
  8096. // Status returns the value of the "status" field in the mutation.
  8097. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  8098. v := m.status
  8099. if v == nil {
  8100. return
  8101. }
  8102. return *v, true
  8103. }
  8104. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  8105. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8107. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  8108. if !m.op.Is(OpUpdateOne) {
  8109. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  8110. }
  8111. if m.id == nil || m.oldValue == nil {
  8112. return v, errors.New("OldStatus requires an ID field in the mutation")
  8113. }
  8114. oldValue, err := m.oldValue(ctx)
  8115. if err != nil {
  8116. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  8117. }
  8118. return oldValue.Status, nil
  8119. }
  8120. // AddStatus adds u to the "status" field.
  8121. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  8122. if m.addstatus != nil {
  8123. *m.addstatus += u
  8124. } else {
  8125. m.addstatus = &u
  8126. }
  8127. }
  8128. // AddedStatus returns the value that was added to the "status" field in this mutation.
  8129. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  8130. v := m.addstatus
  8131. if v == nil {
  8132. return
  8133. }
  8134. return *v, true
  8135. }
  8136. // ClearStatus clears the value of the "status" field.
  8137. func (m *LabelRelationshipMutation) ClearStatus() {
  8138. m.status = nil
  8139. m.addstatus = nil
  8140. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  8141. }
  8142. // StatusCleared returns if the "status" field was cleared in this mutation.
  8143. func (m *LabelRelationshipMutation) StatusCleared() bool {
  8144. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  8145. return ok
  8146. }
  8147. // ResetStatus resets all changes to the "status" field.
  8148. func (m *LabelRelationshipMutation) ResetStatus() {
  8149. m.status = nil
  8150. m.addstatus = nil
  8151. delete(m.clearedFields, labelrelationship.FieldStatus)
  8152. }
  8153. // SetDeletedAt sets the "deleted_at" field.
  8154. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  8155. m.deleted_at = &t
  8156. }
  8157. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8158. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  8159. v := m.deleted_at
  8160. if v == nil {
  8161. return
  8162. }
  8163. return *v, true
  8164. }
  8165. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  8166. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8167. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8168. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8169. if !m.op.Is(OpUpdateOne) {
  8170. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8171. }
  8172. if m.id == nil || m.oldValue == nil {
  8173. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8174. }
  8175. oldValue, err := m.oldValue(ctx)
  8176. if err != nil {
  8177. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8178. }
  8179. return oldValue.DeletedAt, nil
  8180. }
  8181. // ClearDeletedAt clears the value of the "deleted_at" field.
  8182. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  8183. m.deleted_at = nil
  8184. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  8185. }
  8186. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8187. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  8188. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  8189. return ok
  8190. }
  8191. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8192. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  8193. m.deleted_at = nil
  8194. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  8195. }
  8196. // SetLabelID sets the "label_id" field.
  8197. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  8198. m.labels = &u
  8199. }
  8200. // LabelID returns the value of the "label_id" field in the mutation.
  8201. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  8202. v := m.labels
  8203. if v == nil {
  8204. return
  8205. }
  8206. return *v, true
  8207. }
  8208. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  8209. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8211. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  8212. if !m.op.Is(OpUpdateOne) {
  8213. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  8214. }
  8215. if m.id == nil || m.oldValue == nil {
  8216. return v, errors.New("OldLabelID requires an ID field in the mutation")
  8217. }
  8218. oldValue, err := m.oldValue(ctx)
  8219. if err != nil {
  8220. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  8221. }
  8222. return oldValue.LabelID, nil
  8223. }
  8224. // ResetLabelID resets all changes to the "label_id" field.
  8225. func (m *LabelRelationshipMutation) ResetLabelID() {
  8226. m.labels = nil
  8227. }
  8228. // SetContactID sets the "contact_id" field.
  8229. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  8230. m.contacts = &u
  8231. }
  8232. // ContactID returns the value of the "contact_id" field in the mutation.
  8233. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  8234. v := m.contacts
  8235. if v == nil {
  8236. return
  8237. }
  8238. return *v, true
  8239. }
  8240. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  8241. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8243. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  8244. if !m.op.Is(OpUpdateOne) {
  8245. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  8246. }
  8247. if m.id == nil || m.oldValue == nil {
  8248. return v, errors.New("OldContactID requires an ID field in the mutation")
  8249. }
  8250. oldValue, err := m.oldValue(ctx)
  8251. if err != nil {
  8252. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  8253. }
  8254. return oldValue.ContactID, nil
  8255. }
  8256. // ResetContactID resets all changes to the "contact_id" field.
  8257. func (m *LabelRelationshipMutation) ResetContactID() {
  8258. m.contacts = nil
  8259. }
  8260. // SetOrganizationID sets the "organization_id" field.
  8261. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  8262. m.organization_id = &u
  8263. m.addorganization_id = nil
  8264. }
  8265. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8266. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  8267. v := m.organization_id
  8268. if v == nil {
  8269. return
  8270. }
  8271. return *v, true
  8272. }
  8273. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  8274. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  8275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8276. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8277. if !m.op.Is(OpUpdateOne) {
  8278. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8279. }
  8280. if m.id == nil || m.oldValue == nil {
  8281. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8282. }
  8283. oldValue, err := m.oldValue(ctx)
  8284. if err != nil {
  8285. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8286. }
  8287. return oldValue.OrganizationID, nil
  8288. }
  8289. // AddOrganizationID adds u to the "organization_id" field.
  8290. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  8291. if m.addorganization_id != nil {
  8292. *m.addorganization_id += u
  8293. } else {
  8294. m.addorganization_id = &u
  8295. }
  8296. }
  8297. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8298. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  8299. v := m.addorganization_id
  8300. if v == nil {
  8301. return
  8302. }
  8303. return *v, true
  8304. }
  8305. // ClearOrganizationID clears the value of the "organization_id" field.
  8306. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  8307. m.organization_id = nil
  8308. m.addorganization_id = nil
  8309. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  8310. }
  8311. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  8312. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  8313. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  8314. return ok
  8315. }
  8316. // ResetOrganizationID resets all changes to the "organization_id" field.
  8317. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  8318. m.organization_id = nil
  8319. m.addorganization_id = nil
  8320. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  8321. }
  8322. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  8323. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  8324. m.contacts = &id
  8325. }
  8326. // ClearContacts clears the "contacts" edge to the Contact entity.
  8327. func (m *LabelRelationshipMutation) ClearContacts() {
  8328. m.clearedcontacts = true
  8329. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  8330. }
  8331. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  8332. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  8333. return m.clearedcontacts
  8334. }
  8335. // ContactsID returns the "contacts" edge ID in the mutation.
  8336. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  8337. if m.contacts != nil {
  8338. return *m.contacts, true
  8339. }
  8340. return
  8341. }
  8342. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  8343. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  8344. // ContactsID instead. It exists only for internal usage by the builders.
  8345. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  8346. if id := m.contacts; id != nil {
  8347. ids = append(ids, *id)
  8348. }
  8349. return
  8350. }
  8351. // ResetContacts resets all changes to the "contacts" edge.
  8352. func (m *LabelRelationshipMutation) ResetContacts() {
  8353. m.contacts = nil
  8354. m.clearedcontacts = false
  8355. }
  8356. // SetLabelsID sets the "labels" edge to the Label entity by id.
  8357. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  8358. m.labels = &id
  8359. }
  8360. // ClearLabels clears the "labels" edge to the Label entity.
  8361. func (m *LabelRelationshipMutation) ClearLabels() {
  8362. m.clearedlabels = true
  8363. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  8364. }
  8365. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  8366. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  8367. return m.clearedlabels
  8368. }
  8369. // LabelsID returns the "labels" edge ID in the mutation.
  8370. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  8371. if m.labels != nil {
  8372. return *m.labels, true
  8373. }
  8374. return
  8375. }
  8376. // LabelsIDs returns the "labels" edge IDs in the mutation.
  8377. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  8378. // LabelsID instead. It exists only for internal usage by the builders.
  8379. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  8380. if id := m.labels; id != nil {
  8381. ids = append(ids, *id)
  8382. }
  8383. return
  8384. }
  8385. // ResetLabels resets all changes to the "labels" edge.
  8386. func (m *LabelRelationshipMutation) ResetLabels() {
  8387. m.labels = nil
  8388. m.clearedlabels = false
  8389. }
  8390. // Where appends a list predicates to the LabelRelationshipMutation builder.
  8391. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  8392. m.predicates = append(m.predicates, ps...)
  8393. }
  8394. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  8395. // users can use type-assertion to append predicates that do not depend on any generated package.
  8396. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  8397. p := make([]predicate.LabelRelationship, len(ps))
  8398. for i := range ps {
  8399. p[i] = ps[i]
  8400. }
  8401. m.Where(p...)
  8402. }
  8403. // Op returns the operation name.
  8404. func (m *LabelRelationshipMutation) Op() Op {
  8405. return m.op
  8406. }
  8407. // SetOp allows setting the mutation operation.
  8408. func (m *LabelRelationshipMutation) SetOp(op Op) {
  8409. m.op = op
  8410. }
  8411. // Type returns the node type of this mutation (LabelRelationship).
  8412. func (m *LabelRelationshipMutation) Type() string {
  8413. return m.typ
  8414. }
  8415. // Fields returns all fields that were changed during this mutation. Note that in
  8416. // order to get all numeric fields that were incremented/decremented, call
  8417. // AddedFields().
  8418. func (m *LabelRelationshipMutation) Fields() []string {
  8419. fields := make([]string, 0, 7)
  8420. if m.created_at != nil {
  8421. fields = append(fields, labelrelationship.FieldCreatedAt)
  8422. }
  8423. if m.updated_at != nil {
  8424. fields = append(fields, labelrelationship.FieldUpdatedAt)
  8425. }
  8426. if m.status != nil {
  8427. fields = append(fields, labelrelationship.FieldStatus)
  8428. }
  8429. if m.deleted_at != nil {
  8430. fields = append(fields, labelrelationship.FieldDeletedAt)
  8431. }
  8432. if m.labels != nil {
  8433. fields = append(fields, labelrelationship.FieldLabelID)
  8434. }
  8435. if m.contacts != nil {
  8436. fields = append(fields, labelrelationship.FieldContactID)
  8437. }
  8438. if m.organization_id != nil {
  8439. fields = append(fields, labelrelationship.FieldOrganizationID)
  8440. }
  8441. return fields
  8442. }
  8443. // Field returns the value of a field with the given name. The second boolean
  8444. // return value indicates that this field was not set, or was not defined in the
  8445. // schema.
  8446. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  8447. switch name {
  8448. case labelrelationship.FieldCreatedAt:
  8449. return m.CreatedAt()
  8450. case labelrelationship.FieldUpdatedAt:
  8451. return m.UpdatedAt()
  8452. case labelrelationship.FieldStatus:
  8453. return m.Status()
  8454. case labelrelationship.FieldDeletedAt:
  8455. return m.DeletedAt()
  8456. case labelrelationship.FieldLabelID:
  8457. return m.LabelID()
  8458. case labelrelationship.FieldContactID:
  8459. return m.ContactID()
  8460. case labelrelationship.FieldOrganizationID:
  8461. return m.OrganizationID()
  8462. }
  8463. return nil, false
  8464. }
  8465. // OldField returns the old value of the field from the database. An error is
  8466. // returned if the mutation operation is not UpdateOne, or the query to the
  8467. // database failed.
  8468. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8469. switch name {
  8470. case labelrelationship.FieldCreatedAt:
  8471. return m.OldCreatedAt(ctx)
  8472. case labelrelationship.FieldUpdatedAt:
  8473. return m.OldUpdatedAt(ctx)
  8474. case labelrelationship.FieldStatus:
  8475. return m.OldStatus(ctx)
  8476. case labelrelationship.FieldDeletedAt:
  8477. return m.OldDeletedAt(ctx)
  8478. case labelrelationship.FieldLabelID:
  8479. return m.OldLabelID(ctx)
  8480. case labelrelationship.FieldContactID:
  8481. return m.OldContactID(ctx)
  8482. case labelrelationship.FieldOrganizationID:
  8483. return m.OldOrganizationID(ctx)
  8484. }
  8485. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  8486. }
  8487. // SetField sets the value of a field with the given name. It returns an error if
  8488. // the field is not defined in the schema, or if the type mismatched the field
  8489. // type.
  8490. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  8491. switch name {
  8492. case labelrelationship.FieldCreatedAt:
  8493. v, ok := value.(time.Time)
  8494. if !ok {
  8495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8496. }
  8497. m.SetCreatedAt(v)
  8498. return nil
  8499. case labelrelationship.FieldUpdatedAt:
  8500. v, ok := value.(time.Time)
  8501. if !ok {
  8502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8503. }
  8504. m.SetUpdatedAt(v)
  8505. return nil
  8506. case labelrelationship.FieldStatus:
  8507. v, ok := value.(uint8)
  8508. if !ok {
  8509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8510. }
  8511. m.SetStatus(v)
  8512. return nil
  8513. case labelrelationship.FieldDeletedAt:
  8514. v, ok := value.(time.Time)
  8515. if !ok {
  8516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8517. }
  8518. m.SetDeletedAt(v)
  8519. return nil
  8520. case labelrelationship.FieldLabelID:
  8521. v, ok := value.(uint64)
  8522. if !ok {
  8523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8524. }
  8525. m.SetLabelID(v)
  8526. return nil
  8527. case labelrelationship.FieldContactID:
  8528. v, ok := value.(uint64)
  8529. if !ok {
  8530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8531. }
  8532. m.SetContactID(v)
  8533. return nil
  8534. case labelrelationship.FieldOrganizationID:
  8535. v, ok := value.(uint64)
  8536. if !ok {
  8537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8538. }
  8539. m.SetOrganizationID(v)
  8540. return nil
  8541. }
  8542. return fmt.Errorf("unknown LabelRelationship field %s", name)
  8543. }
  8544. // AddedFields returns all numeric fields that were incremented/decremented during
  8545. // this mutation.
  8546. func (m *LabelRelationshipMutation) AddedFields() []string {
  8547. var fields []string
  8548. if m.addstatus != nil {
  8549. fields = append(fields, labelrelationship.FieldStatus)
  8550. }
  8551. if m.addorganization_id != nil {
  8552. fields = append(fields, labelrelationship.FieldOrganizationID)
  8553. }
  8554. return fields
  8555. }
  8556. // AddedField returns the numeric value that was incremented/decremented on a field
  8557. // with the given name. The second boolean return value indicates that this field
  8558. // was not set, or was not defined in the schema.
  8559. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  8560. switch name {
  8561. case labelrelationship.FieldStatus:
  8562. return m.AddedStatus()
  8563. case labelrelationship.FieldOrganizationID:
  8564. return m.AddedOrganizationID()
  8565. }
  8566. return nil, false
  8567. }
  8568. // AddField adds the value to the field with the given name. It returns an error if
  8569. // the field is not defined in the schema, or if the type mismatched the field
  8570. // type.
  8571. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  8572. switch name {
  8573. case labelrelationship.FieldStatus:
  8574. v, ok := value.(int8)
  8575. if !ok {
  8576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8577. }
  8578. m.AddStatus(v)
  8579. return nil
  8580. case labelrelationship.FieldOrganizationID:
  8581. v, ok := value.(int64)
  8582. if !ok {
  8583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8584. }
  8585. m.AddOrganizationID(v)
  8586. return nil
  8587. }
  8588. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  8589. }
  8590. // ClearedFields returns all nullable fields that were cleared during this
  8591. // mutation.
  8592. func (m *LabelRelationshipMutation) ClearedFields() []string {
  8593. var fields []string
  8594. if m.FieldCleared(labelrelationship.FieldStatus) {
  8595. fields = append(fields, labelrelationship.FieldStatus)
  8596. }
  8597. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  8598. fields = append(fields, labelrelationship.FieldDeletedAt)
  8599. }
  8600. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  8601. fields = append(fields, labelrelationship.FieldOrganizationID)
  8602. }
  8603. return fields
  8604. }
  8605. // FieldCleared returns a boolean indicating if a field with the given name was
  8606. // cleared in this mutation.
  8607. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  8608. _, ok := m.clearedFields[name]
  8609. return ok
  8610. }
  8611. // ClearField clears the value of the field with the given name. It returns an
  8612. // error if the field is not defined in the schema.
  8613. func (m *LabelRelationshipMutation) ClearField(name string) error {
  8614. switch name {
  8615. case labelrelationship.FieldStatus:
  8616. m.ClearStatus()
  8617. return nil
  8618. case labelrelationship.FieldDeletedAt:
  8619. m.ClearDeletedAt()
  8620. return nil
  8621. case labelrelationship.FieldOrganizationID:
  8622. m.ClearOrganizationID()
  8623. return nil
  8624. }
  8625. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  8626. }
  8627. // ResetField resets all changes in the mutation for the field with the given name.
  8628. // It returns an error if the field is not defined in the schema.
  8629. func (m *LabelRelationshipMutation) ResetField(name string) error {
  8630. switch name {
  8631. case labelrelationship.FieldCreatedAt:
  8632. m.ResetCreatedAt()
  8633. return nil
  8634. case labelrelationship.FieldUpdatedAt:
  8635. m.ResetUpdatedAt()
  8636. return nil
  8637. case labelrelationship.FieldStatus:
  8638. m.ResetStatus()
  8639. return nil
  8640. case labelrelationship.FieldDeletedAt:
  8641. m.ResetDeletedAt()
  8642. return nil
  8643. case labelrelationship.FieldLabelID:
  8644. m.ResetLabelID()
  8645. return nil
  8646. case labelrelationship.FieldContactID:
  8647. m.ResetContactID()
  8648. return nil
  8649. case labelrelationship.FieldOrganizationID:
  8650. m.ResetOrganizationID()
  8651. return nil
  8652. }
  8653. return fmt.Errorf("unknown LabelRelationship field %s", name)
  8654. }
  8655. // AddedEdges returns all edge names that were set/added in this mutation.
  8656. func (m *LabelRelationshipMutation) AddedEdges() []string {
  8657. edges := make([]string, 0, 2)
  8658. if m.contacts != nil {
  8659. edges = append(edges, labelrelationship.EdgeContacts)
  8660. }
  8661. if m.labels != nil {
  8662. edges = append(edges, labelrelationship.EdgeLabels)
  8663. }
  8664. return edges
  8665. }
  8666. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8667. // name in this mutation.
  8668. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  8669. switch name {
  8670. case labelrelationship.EdgeContacts:
  8671. if id := m.contacts; id != nil {
  8672. return []ent.Value{*id}
  8673. }
  8674. case labelrelationship.EdgeLabels:
  8675. if id := m.labels; id != nil {
  8676. return []ent.Value{*id}
  8677. }
  8678. }
  8679. return nil
  8680. }
  8681. // RemovedEdges returns all edge names that were removed in this mutation.
  8682. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  8683. edges := make([]string, 0, 2)
  8684. return edges
  8685. }
  8686. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8687. // the given name in this mutation.
  8688. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  8689. return nil
  8690. }
  8691. // ClearedEdges returns all edge names that were cleared in this mutation.
  8692. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  8693. edges := make([]string, 0, 2)
  8694. if m.clearedcontacts {
  8695. edges = append(edges, labelrelationship.EdgeContacts)
  8696. }
  8697. if m.clearedlabels {
  8698. edges = append(edges, labelrelationship.EdgeLabels)
  8699. }
  8700. return edges
  8701. }
  8702. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8703. // was cleared in this mutation.
  8704. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  8705. switch name {
  8706. case labelrelationship.EdgeContacts:
  8707. return m.clearedcontacts
  8708. case labelrelationship.EdgeLabels:
  8709. return m.clearedlabels
  8710. }
  8711. return false
  8712. }
  8713. // ClearEdge clears the value of the edge with the given name. It returns an error
  8714. // if that edge is not defined in the schema.
  8715. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  8716. switch name {
  8717. case labelrelationship.EdgeContacts:
  8718. m.ClearContacts()
  8719. return nil
  8720. case labelrelationship.EdgeLabels:
  8721. m.ClearLabels()
  8722. return nil
  8723. }
  8724. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  8725. }
  8726. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8727. // It returns an error if the edge is not defined in the schema.
  8728. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  8729. switch name {
  8730. case labelrelationship.EdgeContacts:
  8731. m.ResetContacts()
  8732. return nil
  8733. case labelrelationship.EdgeLabels:
  8734. m.ResetLabels()
  8735. return nil
  8736. }
  8737. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  8738. }
  8739. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  8740. type MessageMutation struct {
  8741. config
  8742. op Op
  8743. typ string
  8744. id *int
  8745. wx_wxid *string
  8746. wxid *string
  8747. content *string
  8748. clearedFields map[string]struct{}
  8749. done bool
  8750. oldValue func(context.Context) (*Message, error)
  8751. predicates []predicate.Message
  8752. }
  8753. var _ ent.Mutation = (*MessageMutation)(nil)
  8754. // messageOption allows management of the mutation configuration using functional options.
  8755. type messageOption func(*MessageMutation)
  8756. // newMessageMutation creates new mutation for the Message entity.
  8757. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  8758. m := &MessageMutation{
  8759. config: c,
  8760. op: op,
  8761. typ: TypeMessage,
  8762. clearedFields: make(map[string]struct{}),
  8763. }
  8764. for _, opt := range opts {
  8765. opt(m)
  8766. }
  8767. return m
  8768. }
  8769. // withMessageID sets the ID field of the mutation.
  8770. func withMessageID(id int) messageOption {
  8771. return func(m *MessageMutation) {
  8772. var (
  8773. err error
  8774. once sync.Once
  8775. value *Message
  8776. )
  8777. m.oldValue = func(ctx context.Context) (*Message, error) {
  8778. once.Do(func() {
  8779. if m.done {
  8780. err = errors.New("querying old values post mutation is not allowed")
  8781. } else {
  8782. value, err = m.Client().Message.Get(ctx, id)
  8783. }
  8784. })
  8785. return value, err
  8786. }
  8787. m.id = &id
  8788. }
  8789. }
  8790. // withMessage sets the old Message of the mutation.
  8791. func withMessage(node *Message) messageOption {
  8792. return func(m *MessageMutation) {
  8793. m.oldValue = func(context.Context) (*Message, error) {
  8794. return node, nil
  8795. }
  8796. m.id = &node.ID
  8797. }
  8798. }
  8799. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8800. // executed in a transaction (ent.Tx), a transactional client is returned.
  8801. func (m MessageMutation) Client() *Client {
  8802. client := &Client{config: m.config}
  8803. client.init()
  8804. return client
  8805. }
  8806. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8807. // it returns an error otherwise.
  8808. func (m MessageMutation) Tx() (*Tx, error) {
  8809. if _, ok := m.driver.(*txDriver); !ok {
  8810. return nil, errors.New("ent: mutation is not running in a transaction")
  8811. }
  8812. tx := &Tx{config: m.config}
  8813. tx.init()
  8814. return tx, nil
  8815. }
  8816. // ID returns the ID value in the mutation. Note that the ID is only available
  8817. // if it was provided to the builder or after it was returned from the database.
  8818. func (m *MessageMutation) ID() (id int, exists bool) {
  8819. if m.id == nil {
  8820. return
  8821. }
  8822. return *m.id, true
  8823. }
  8824. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8825. // That means, if the mutation is applied within a transaction with an isolation level such
  8826. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8827. // or updated by the mutation.
  8828. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  8829. switch {
  8830. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8831. id, exists := m.ID()
  8832. if exists {
  8833. return []int{id}, nil
  8834. }
  8835. fallthrough
  8836. case m.op.Is(OpUpdate | OpDelete):
  8837. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  8838. default:
  8839. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8840. }
  8841. }
  8842. // SetWxWxid sets the "wx_wxid" field.
  8843. func (m *MessageMutation) SetWxWxid(s string) {
  8844. m.wx_wxid = &s
  8845. }
  8846. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  8847. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  8848. v := m.wx_wxid
  8849. if v == nil {
  8850. return
  8851. }
  8852. return *v, true
  8853. }
  8854. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  8855. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  8856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8857. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  8858. if !m.op.Is(OpUpdateOne) {
  8859. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  8860. }
  8861. if m.id == nil || m.oldValue == nil {
  8862. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  8863. }
  8864. oldValue, err := m.oldValue(ctx)
  8865. if err != nil {
  8866. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  8867. }
  8868. return oldValue.WxWxid, nil
  8869. }
  8870. // ClearWxWxid clears the value of the "wx_wxid" field.
  8871. func (m *MessageMutation) ClearWxWxid() {
  8872. m.wx_wxid = nil
  8873. m.clearedFields[message.FieldWxWxid] = struct{}{}
  8874. }
  8875. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  8876. func (m *MessageMutation) WxWxidCleared() bool {
  8877. _, ok := m.clearedFields[message.FieldWxWxid]
  8878. return ok
  8879. }
  8880. // ResetWxWxid resets all changes to the "wx_wxid" field.
  8881. func (m *MessageMutation) ResetWxWxid() {
  8882. m.wx_wxid = nil
  8883. delete(m.clearedFields, message.FieldWxWxid)
  8884. }
  8885. // SetWxid sets the "wxid" field.
  8886. func (m *MessageMutation) SetWxid(s string) {
  8887. m.wxid = &s
  8888. }
  8889. // Wxid returns the value of the "wxid" field in the mutation.
  8890. func (m *MessageMutation) Wxid() (r string, exists bool) {
  8891. v := m.wxid
  8892. if v == nil {
  8893. return
  8894. }
  8895. return *v, true
  8896. }
  8897. // OldWxid returns the old "wxid" field's value of the Message entity.
  8898. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  8899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8900. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  8901. if !m.op.Is(OpUpdateOne) {
  8902. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  8903. }
  8904. if m.id == nil || m.oldValue == nil {
  8905. return v, errors.New("OldWxid requires an ID field in the mutation")
  8906. }
  8907. oldValue, err := m.oldValue(ctx)
  8908. if err != nil {
  8909. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  8910. }
  8911. return oldValue.Wxid, nil
  8912. }
  8913. // ResetWxid resets all changes to the "wxid" field.
  8914. func (m *MessageMutation) ResetWxid() {
  8915. m.wxid = nil
  8916. }
  8917. // SetContent sets the "content" field.
  8918. func (m *MessageMutation) SetContent(s string) {
  8919. m.content = &s
  8920. }
  8921. // Content returns the value of the "content" field in the mutation.
  8922. func (m *MessageMutation) Content() (r string, exists bool) {
  8923. v := m.content
  8924. if v == nil {
  8925. return
  8926. }
  8927. return *v, true
  8928. }
  8929. // OldContent returns the old "content" field's value of the Message entity.
  8930. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  8931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8932. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  8933. if !m.op.Is(OpUpdateOne) {
  8934. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  8935. }
  8936. if m.id == nil || m.oldValue == nil {
  8937. return v, errors.New("OldContent requires an ID field in the mutation")
  8938. }
  8939. oldValue, err := m.oldValue(ctx)
  8940. if err != nil {
  8941. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  8942. }
  8943. return oldValue.Content, nil
  8944. }
  8945. // ResetContent resets all changes to the "content" field.
  8946. func (m *MessageMutation) ResetContent() {
  8947. m.content = nil
  8948. }
  8949. // Where appends a list predicates to the MessageMutation builder.
  8950. func (m *MessageMutation) Where(ps ...predicate.Message) {
  8951. m.predicates = append(m.predicates, ps...)
  8952. }
  8953. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  8954. // users can use type-assertion to append predicates that do not depend on any generated package.
  8955. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  8956. p := make([]predicate.Message, len(ps))
  8957. for i := range ps {
  8958. p[i] = ps[i]
  8959. }
  8960. m.Where(p...)
  8961. }
  8962. // Op returns the operation name.
  8963. func (m *MessageMutation) Op() Op {
  8964. return m.op
  8965. }
  8966. // SetOp allows setting the mutation operation.
  8967. func (m *MessageMutation) SetOp(op Op) {
  8968. m.op = op
  8969. }
  8970. // Type returns the node type of this mutation (Message).
  8971. func (m *MessageMutation) Type() string {
  8972. return m.typ
  8973. }
  8974. // Fields returns all fields that were changed during this mutation. Note that in
  8975. // order to get all numeric fields that were incremented/decremented, call
  8976. // AddedFields().
  8977. func (m *MessageMutation) Fields() []string {
  8978. fields := make([]string, 0, 3)
  8979. if m.wx_wxid != nil {
  8980. fields = append(fields, message.FieldWxWxid)
  8981. }
  8982. if m.wxid != nil {
  8983. fields = append(fields, message.FieldWxid)
  8984. }
  8985. if m.content != nil {
  8986. fields = append(fields, message.FieldContent)
  8987. }
  8988. return fields
  8989. }
  8990. // Field returns the value of a field with the given name. The second boolean
  8991. // return value indicates that this field was not set, or was not defined in the
  8992. // schema.
  8993. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  8994. switch name {
  8995. case message.FieldWxWxid:
  8996. return m.WxWxid()
  8997. case message.FieldWxid:
  8998. return m.Wxid()
  8999. case message.FieldContent:
  9000. return m.Content()
  9001. }
  9002. return nil, false
  9003. }
  9004. // OldField returns the old value of the field from the database. An error is
  9005. // returned if the mutation operation is not UpdateOne, or the query to the
  9006. // database failed.
  9007. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9008. switch name {
  9009. case message.FieldWxWxid:
  9010. return m.OldWxWxid(ctx)
  9011. case message.FieldWxid:
  9012. return m.OldWxid(ctx)
  9013. case message.FieldContent:
  9014. return m.OldContent(ctx)
  9015. }
  9016. return nil, fmt.Errorf("unknown Message field %s", name)
  9017. }
  9018. // SetField sets the value of a field with the given name. It returns an error if
  9019. // the field is not defined in the schema, or if the type mismatched the field
  9020. // type.
  9021. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  9022. switch name {
  9023. case message.FieldWxWxid:
  9024. v, ok := value.(string)
  9025. if !ok {
  9026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9027. }
  9028. m.SetWxWxid(v)
  9029. return nil
  9030. case message.FieldWxid:
  9031. v, ok := value.(string)
  9032. if !ok {
  9033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9034. }
  9035. m.SetWxid(v)
  9036. return nil
  9037. case message.FieldContent:
  9038. v, ok := value.(string)
  9039. if !ok {
  9040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9041. }
  9042. m.SetContent(v)
  9043. return nil
  9044. }
  9045. return fmt.Errorf("unknown Message field %s", name)
  9046. }
  9047. // AddedFields returns all numeric fields that were incremented/decremented during
  9048. // this mutation.
  9049. func (m *MessageMutation) AddedFields() []string {
  9050. return nil
  9051. }
  9052. // AddedField returns the numeric value that was incremented/decremented on a field
  9053. // with the given name. The second boolean return value indicates that this field
  9054. // was not set, or was not defined in the schema.
  9055. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  9056. return nil, false
  9057. }
  9058. // AddField adds the value to the field with the given name. It returns an error if
  9059. // the field is not defined in the schema, or if the type mismatched the field
  9060. // type.
  9061. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  9062. switch name {
  9063. }
  9064. return fmt.Errorf("unknown Message numeric field %s", name)
  9065. }
  9066. // ClearedFields returns all nullable fields that were cleared during this
  9067. // mutation.
  9068. func (m *MessageMutation) ClearedFields() []string {
  9069. var fields []string
  9070. if m.FieldCleared(message.FieldWxWxid) {
  9071. fields = append(fields, message.FieldWxWxid)
  9072. }
  9073. return fields
  9074. }
  9075. // FieldCleared returns a boolean indicating if a field with the given name was
  9076. // cleared in this mutation.
  9077. func (m *MessageMutation) FieldCleared(name string) bool {
  9078. _, ok := m.clearedFields[name]
  9079. return ok
  9080. }
  9081. // ClearField clears the value of the field with the given name. It returns an
  9082. // error if the field is not defined in the schema.
  9083. func (m *MessageMutation) ClearField(name string) error {
  9084. switch name {
  9085. case message.FieldWxWxid:
  9086. m.ClearWxWxid()
  9087. return nil
  9088. }
  9089. return fmt.Errorf("unknown Message nullable field %s", name)
  9090. }
  9091. // ResetField resets all changes in the mutation for the field with the given name.
  9092. // It returns an error if the field is not defined in the schema.
  9093. func (m *MessageMutation) ResetField(name string) error {
  9094. switch name {
  9095. case message.FieldWxWxid:
  9096. m.ResetWxWxid()
  9097. return nil
  9098. case message.FieldWxid:
  9099. m.ResetWxid()
  9100. return nil
  9101. case message.FieldContent:
  9102. m.ResetContent()
  9103. return nil
  9104. }
  9105. return fmt.Errorf("unknown Message field %s", name)
  9106. }
  9107. // AddedEdges returns all edge names that were set/added in this mutation.
  9108. func (m *MessageMutation) AddedEdges() []string {
  9109. edges := make([]string, 0, 0)
  9110. return edges
  9111. }
  9112. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9113. // name in this mutation.
  9114. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  9115. return nil
  9116. }
  9117. // RemovedEdges returns all edge names that were removed in this mutation.
  9118. func (m *MessageMutation) RemovedEdges() []string {
  9119. edges := make([]string, 0, 0)
  9120. return edges
  9121. }
  9122. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9123. // the given name in this mutation.
  9124. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  9125. return nil
  9126. }
  9127. // ClearedEdges returns all edge names that were cleared in this mutation.
  9128. func (m *MessageMutation) ClearedEdges() []string {
  9129. edges := make([]string, 0, 0)
  9130. return edges
  9131. }
  9132. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9133. // was cleared in this mutation.
  9134. func (m *MessageMutation) EdgeCleared(name string) bool {
  9135. return false
  9136. }
  9137. // ClearEdge clears the value of the edge with the given name. It returns an error
  9138. // if that edge is not defined in the schema.
  9139. func (m *MessageMutation) ClearEdge(name string) error {
  9140. return fmt.Errorf("unknown Message unique edge %s", name)
  9141. }
  9142. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9143. // It returns an error if the edge is not defined in the schema.
  9144. func (m *MessageMutation) ResetEdge(name string) error {
  9145. return fmt.Errorf("unknown Message edge %s", name)
  9146. }
  9147. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  9148. type MessageRecordsMutation struct {
  9149. config
  9150. op Op
  9151. typ string
  9152. id *uint64
  9153. created_at *time.Time
  9154. updated_at *time.Time
  9155. status *uint8
  9156. addstatus *int8
  9157. deleted_at *time.Time
  9158. bot_wxid *string
  9159. contact_type *int
  9160. addcontact_type *int
  9161. contact_wxid *string
  9162. content_type *int
  9163. addcontent_type *int
  9164. content *string
  9165. meta *custom_types.Meta
  9166. error_detail *string
  9167. send_time *time.Time
  9168. source_type *int
  9169. addsource_type *int
  9170. organization_id *uint64
  9171. addorganization_id *int64
  9172. clearedFields map[string]struct{}
  9173. sop_stage *uint64
  9174. clearedsop_stage bool
  9175. sop_node *uint64
  9176. clearedsop_node bool
  9177. message_contact *uint64
  9178. clearedmessage_contact bool
  9179. done bool
  9180. oldValue func(context.Context) (*MessageRecords, error)
  9181. predicates []predicate.MessageRecords
  9182. }
  9183. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  9184. // messagerecordsOption allows management of the mutation configuration using functional options.
  9185. type messagerecordsOption func(*MessageRecordsMutation)
  9186. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  9187. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  9188. m := &MessageRecordsMutation{
  9189. config: c,
  9190. op: op,
  9191. typ: TypeMessageRecords,
  9192. clearedFields: make(map[string]struct{}),
  9193. }
  9194. for _, opt := range opts {
  9195. opt(m)
  9196. }
  9197. return m
  9198. }
  9199. // withMessageRecordsID sets the ID field of the mutation.
  9200. func withMessageRecordsID(id uint64) messagerecordsOption {
  9201. return func(m *MessageRecordsMutation) {
  9202. var (
  9203. err error
  9204. once sync.Once
  9205. value *MessageRecords
  9206. )
  9207. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  9208. once.Do(func() {
  9209. if m.done {
  9210. err = errors.New("querying old values post mutation is not allowed")
  9211. } else {
  9212. value, err = m.Client().MessageRecords.Get(ctx, id)
  9213. }
  9214. })
  9215. return value, err
  9216. }
  9217. m.id = &id
  9218. }
  9219. }
  9220. // withMessageRecords sets the old MessageRecords of the mutation.
  9221. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  9222. return func(m *MessageRecordsMutation) {
  9223. m.oldValue = func(context.Context) (*MessageRecords, error) {
  9224. return node, nil
  9225. }
  9226. m.id = &node.ID
  9227. }
  9228. }
  9229. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9230. // executed in a transaction (ent.Tx), a transactional client is returned.
  9231. func (m MessageRecordsMutation) Client() *Client {
  9232. client := &Client{config: m.config}
  9233. client.init()
  9234. return client
  9235. }
  9236. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9237. // it returns an error otherwise.
  9238. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  9239. if _, ok := m.driver.(*txDriver); !ok {
  9240. return nil, errors.New("ent: mutation is not running in a transaction")
  9241. }
  9242. tx := &Tx{config: m.config}
  9243. tx.init()
  9244. return tx, nil
  9245. }
  9246. // SetID sets the value of the id field. Note that this
  9247. // operation is only accepted on creation of MessageRecords entities.
  9248. func (m *MessageRecordsMutation) SetID(id uint64) {
  9249. m.id = &id
  9250. }
  9251. // ID returns the ID value in the mutation. Note that the ID is only available
  9252. // if it was provided to the builder or after it was returned from the database.
  9253. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  9254. if m.id == nil {
  9255. return
  9256. }
  9257. return *m.id, true
  9258. }
  9259. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9260. // That means, if the mutation is applied within a transaction with an isolation level such
  9261. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9262. // or updated by the mutation.
  9263. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  9264. switch {
  9265. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9266. id, exists := m.ID()
  9267. if exists {
  9268. return []uint64{id}, nil
  9269. }
  9270. fallthrough
  9271. case m.op.Is(OpUpdate | OpDelete):
  9272. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  9273. default:
  9274. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9275. }
  9276. }
  9277. // SetCreatedAt sets the "created_at" field.
  9278. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  9279. m.created_at = &t
  9280. }
  9281. // CreatedAt returns the value of the "created_at" field in the mutation.
  9282. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  9283. v := m.created_at
  9284. if v == nil {
  9285. return
  9286. }
  9287. return *v, true
  9288. }
  9289. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  9290. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9292. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9293. if !m.op.Is(OpUpdateOne) {
  9294. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9295. }
  9296. if m.id == nil || m.oldValue == nil {
  9297. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9298. }
  9299. oldValue, err := m.oldValue(ctx)
  9300. if err != nil {
  9301. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9302. }
  9303. return oldValue.CreatedAt, nil
  9304. }
  9305. // ResetCreatedAt resets all changes to the "created_at" field.
  9306. func (m *MessageRecordsMutation) ResetCreatedAt() {
  9307. m.created_at = nil
  9308. }
  9309. // SetUpdatedAt sets the "updated_at" field.
  9310. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  9311. m.updated_at = &t
  9312. }
  9313. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9314. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  9315. v := m.updated_at
  9316. if v == nil {
  9317. return
  9318. }
  9319. return *v, true
  9320. }
  9321. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  9322. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9324. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9325. if !m.op.Is(OpUpdateOne) {
  9326. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9327. }
  9328. if m.id == nil || m.oldValue == nil {
  9329. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9330. }
  9331. oldValue, err := m.oldValue(ctx)
  9332. if err != nil {
  9333. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9334. }
  9335. return oldValue.UpdatedAt, nil
  9336. }
  9337. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9338. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  9339. m.updated_at = nil
  9340. }
  9341. // SetStatus sets the "status" field.
  9342. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  9343. m.status = &u
  9344. m.addstatus = nil
  9345. }
  9346. // Status returns the value of the "status" field in the mutation.
  9347. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  9348. v := m.status
  9349. if v == nil {
  9350. return
  9351. }
  9352. return *v, true
  9353. }
  9354. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  9355. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9357. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9358. if !m.op.Is(OpUpdateOne) {
  9359. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9360. }
  9361. if m.id == nil || m.oldValue == nil {
  9362. return v, errors.New("OldStatus requires an ID field in the mutation")
  9363. }
  9364. oldValue, err := m.oldValue(ctx)
  9365. if err != nil {
  9366. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9367. }
  9368. return oldValue.Status, nil
  9369. }
  9370. // AddStatus adds u to the "status" field.
  9371. func (m *MessageRecordsMutation) AddStatus(u int8) {
  9372. if m.addstatus != nil {
  9373. *m.addstatus += u
  9374. } else {
  9375. m.addstatus = &u
  9376. }
  9377. }
  9378. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9379. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  9380. v := m.addstatus
  9381. if v == nil {
  9382. return
  9383. }
  9384. return *v, true
  9385. }
  9386. // ClearStatus clears the value of the "status" field.
  9387. func (m *MessageRecordsMutation) ClearStatus() {
  9388. m.status = nil
  9389. m.addstatus = nil
  9390. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  9391. }
  9392. // StatusCleared returns if the "status" field was cleared in this mutation.
  9393. func (m *MessageRecordsMutation) StatusCleared() bool {
  9394. _, ok := m.clearedFields[messagerecords.FieldStatus]
  9395. return ok
  9396. }
  9397. // ResetStatus resets all changes to the "status" field.
  9398. func (m *MessageRecordsMutation) ResetStatus() {
  9399. m.status = nil
  9400. m.addstatus = nil
  9401. delete(m.clearedFields, messagerecords.FieldStatus)
  9402. }
  9403. // SetDeletedAt sets the "deleted_at" field.
  9404. func (m *MessageRecordsMutation) SetDeletedAt(t time.Time) {
  9405. m.deleted_at = &t
  9406. }
  9407. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9408. func (m *MessageRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  9409. v := m.deleted_at
  9410. if v == nil {
  9411. return
  9412. }
  9413. return *v, true
  9414. }
  9415. // OldDeletedAt returns the old "deleted_at" field's value of the MessageRecords entity.
  9416. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9418. func (m *MessageRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9419. if !m.op.Is(OpUpdateOne) {
  9420. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9421. }
  9422. if m.id == nil || m.oldValue == nil {
  9423. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9424. }
  9425. oldValue, err := m.oldValue(ctx)
  9426. if err != nil {
  9427. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9428. }
  9429. return oldValue.DeletedAt, nil
  9430. }
  9431. // ClearDeletedAt clears the value of the "deleted_at" field.
  9432. func (m *MessageRecordsMutation) ClearDeletedAt() {
  9433. m.deleted_at = nil
  9434. m.clearedFields[messagerecords.FieldDeletedAt] = struct{}{}
  9435. }
  9436. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9437. func (m *MessageRecordsMutation) DeletedAtCleared() bool {
  9438. _, ok := m.clearedFields[messagerecords.FieldDeletedAt]
  9439. return ok
  9440. }
  9441. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9442. func (m *MessageRecordsMutation) ResetDeletedAt() {
  9443. m.deleted_at = nil
  9444. delete(m.clearedFields, messagerecords.FieldDeletedAt)
  9445. }
  9446. // SetBotWxid sets the "bot_wxid" field.
  9447. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  9448. m.bot_wxid = &s
  9449. }
  9450. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  9451. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  9452. v := m.bot_wxid
  9453. if v == nil {
  9454. return
  9455. }
  9456. return *v, true
  9457. }
  9458. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  9459. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9461. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  9462. if !m.op.Is(OpUpdateOne) {
  9463. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  9464. }
  9465. if m.id == nil || m.oldValue == nil {
  9466. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  9467. }
  9468. oldValue, err := m.oldValue(ctx)
  9469. if err != nil {
  9470. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  9471. }
  9472. return oldValue.BotWxid, nil
  9473. }
  9474. // ResetBotWxid resets all changes to the "bot_wxid" field.
  9475. func (m *MessageRecordsMutation) ResetBotWxid() {
  9476. m.bot_wxid = nil
  9477. }
  9478. // SetContactID sets the "contact_id" field.
  9479. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  9480. m.message_contact = &u
  9481. }
  9482. // ContactID returns the value of the "contact_id" field in the mutation.
  9483. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  9484. v := m.message_contact
  9485. if v == nil {
  9486. return
  9487. }
  9488. return *v, true
  9489. }
  9490. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  9491. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9493. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  9494. if !m.op.Is(OpUpdateOne) {
  9495. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  9496. }
  9497. if m.id == nil || m.oldValue == nil {
  9498. return v, errors.New("OldContactID requires an ID field in the mutation")
  9499. }
  9500. oldValue, err := m.oldValue(ctx)
  9501. if err != nil {
  9502. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  9503. }
  9504. return oldValue.ContactID, nil
  9505. }
  9506. // ClearContactID clears the value of the "contact_id" field.
  9507. func (m *MessageRecordsMutation) ClearContactID() {
  9508. m.message_contact = nil
  9509. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  9510. }
  9511. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  9512. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  9513. _, ok := m.clearedFields[messagerecords.FieldContactID]
  9514. return ok
  9515. }
  9516. // ResetContactID resets all changes to the "contact_id" field.
  9517. func (m *MessageRecordsMutation) ResetContactID() {
  9518. m.message_contact = nil
  9519. delete(m.clearedFields, messagerecords.FieldContactID)
  9520. }
  9521. // SetContactType sets the "contact_type" field.
  9522. func (m *MessageRecordsMutation) SetContactType(i int) {
  9523. m.contact_type = &i
  9524. m.addcontact_type = nil
  9525. }
  9526. // ContactType returns the value of the "contact_type" field in the mutation.
  9527. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  9528. v := m.contact_type
  9529. if v == nil {
  9530. return
  9531. }
  9532. return *v, true
  9533. }
  9534. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  9535. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9537. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  9538. if !m.op.Is(OpUpdateOne) {
  9539. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  9540. }
  9541. if m.id == nil || m.oldValue == nil {
  9542. return v, errors.New("OldContactType requires an ID field in the mutation")
  9543. }
  9544. oldValue, err := m.oldValue(ctx)
  9545. if err != nil {
  9546. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  9547. }
  9548. return oldValue.ContactType, nil
  9549. }
  9550. // AddContactType adds i to the "contact_type" field.
  9551. func (m *MessageRecordsMutation) AddContactType(i int) {
  9552. if m.addcontact_type != nil {
  9553. *m.addcontact_type += i
  9554. } else {
  9555. m.addcontact_type = &i
  9556. }
  9557. }
  9558. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  9559. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  9560. v := m.addcontact_type
  9561. if v == nil {
  9562. return
  9563. }
  9564. return *v, true
  9565. }
  9566. // ResetContactType resets all changes to the "contact_type" field.
  9567. func (m *MessageRecordsMutation) ResetContactType() {
  9568. m.contact_type = nil
  9569. m.addcontact_type = nil
  9570. }
  9571. // SetContactWxid sets the "contact_wxid" field.
  9572. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  9573. m.contact_wxid = &s
  9574. }
  9575. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  9576. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  9577. v := m.contact_wxid
  9578. if v == nil {
  9579. return
  9580. }
  9581. return *v, true
  9582. }
  9583. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  9584. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9586. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  9587. if !m.op.Is(OpUpdateOne) {
  9588. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  9589. }
  9590. if m.id == nil || m.oldValue == nil {
  9591. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  9592. }
  9593. oldValue, err := m.oldValue(ctx)
  9594. if err != nil {
  9595. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  9596. }
  9597. return oldValue.ContactWxid, nil
  9598. }
  9599. // ResetContactWxid resets all changes to the "contact_wxid" field.
  9600. func (m *MessageRecordsMutation) ResetContactWxid() {
  9601. m.contact_wxid = nil
  9602. }
  9603. // SetContentType sets the "content_type" field.
  9604. func (m *MessageRecordsMutation) SetContentType(i int) {
  9605. m.content_type = &i
  9606. m.addcontent_type = nil
  9607. }
  9608. // ContentType returns the value of the "content_type" field in the mutation.
  9609. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  9610. v := m.content_type
  9611. if v == nil {
  9612. return
  9613. }
  9614. return *v, true
  9615. }
  9616. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  9617. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9619. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  9620. if !m.op.Is(OpUpdateOne) {
  9621. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  9622. }
  9623. if m.id == nil || m.oldValue == nil {
  9624. return v, errors.New("OldContentType requires an ID field in the mutation")
  9625. }
  9626. oldValue, err := m.oldValue(ctx)
  9627. if err != nil {
  9628. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  9629. }
  9630. return oldValue.ContentType, nil
  9631. }
  9632. // AddContentType adds i to the "content_type" field.
  9633. func (m *MessageRecordsMutation) AddContentType(i int) {
  9634. if m.addcontent_type != nil {
  9635. *m.addcontent_type += i
  9636. } else {
  9637. m.addcontent_type = &i
  9638. }
  9639. }
  9640. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  9641. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  9642. v := m.addcontent_type
  9643. if v == nil {
  9644. return
  9645. }
  9646. return *v, true
  9647. }
  9648. // ResetContentType resets all changes to the "content_type" field.
  9649. func (m *MessageRecordsMutation) ResetContentType() {
  9650. m.content_type = nil
  9651. m.addcontent_type = nil
  9652. }
  9653. // SetContent sets the "content" field.
  9654. func (m *MessageRecordsMutation) SetContent(s string) {
  9655. m.content = &s
  9656. }
  9657. // Content returns the value of the "content" field in the mutation.
  9658. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  9659. v := m.content
  9660. if v == nil {
  9661. return
  9662. }
  9663. return *v, true
  9664. }
  9665. // OldContent returns the old "content" field's value of the MessageRecords entity.
  9666. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9668. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  9669. if !m.op.Is(OpUpdateOne) {
  9670. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  9671. }
  9672. if m.id == nil || m.oldValue == nil {
  9673. return v, errors.New("OldContent requires an ID field in the mutation")
  9674. }
  9675. oldValue, err := m.oldValue(ctx)
  9676. if err != nil {
  9677. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  9678. }
  9679. return oldValue.Content, nil
  9680. }
  9681. // ResetContent resets all changes to the "content" field.
  9682. func (m *MessageRecordsMutation) ResetContent() {
  9683. m.content = nil
  9684. }
  9685. // SetMeta sets the "meta" field.
  9686. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  9687. m.meta = &ct
  9688. }
  9689. // Meta returns the value of the "meta" field in the mutation.
  9690. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  9691. v := m.meta
  9692. if v == nil {
  9693. return
  9694. }
  9695. return *v, true
  9696. }
  9697. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  9698. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9700. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  9701. if !m.op.Is(OpUpdateOne) {
  9702. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  9703. }
  9704. if m.id == nil || m.oldValue == nil {
  9705. return v, errors.New("OldMeta requires an ID field in the mutation")
  9706. }
  9707. oldValue, err := m.oldValue(ctx)
  9708. if err != nil {
  9709. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  9710. }
  9711. return oldValue.Meta, nil
  9712. }
  9713. // ClearMeta clears the value of the "meta" field.
  9714. func (m *MessageRecordsMutation) ClearMeta() {
  9715. m.meta = nil
  9716. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  9717. }
  9718. // MetaCleared returns if the "meta" field was cleared in this mutation.
  9719. func (m *MessageRecordsMutation) MetaCleared() bool {
  9720. _, ok := m.clearedFields[messagerecords.FieldMeta]
  9721. return ok
  9722. }
  9723. // ResetMeta resets all changes to the "meta" field.
  9724. func (m *MessageRecordsMutation) ResetMeta() {
  9725. m.meta = nil
  9726. delete(m.clearedFields, messagerecords.FieldMeta)
  9727. }
  9728. // SetErrorDetail sets the "error_detail" field.
  9729. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  9730. m.error_detail = &s
  9731. }
  9732. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  9733. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  9734. v := m.error_detail
  9735. if v == nil {
  9736. return
  9737. }
  9738. return *v, true
  9739. }
  9740. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  9741. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9743. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  9744. if !m.op.Is(OpUpdateOne) {
  9745. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  9746. }
  9747. if m.id == nil || m.oldValue == nil {
  9748. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  9749. }
  9750. oldValue, err := m.oldValue(ctx)
  9751. if err != nil {
  9752. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  9753. }
  9754. return oldValue.ErrorDetail, nil
  9755. }
  9756. // ResetErrorDetail resets all changes to the "error_detail" field.
  9757. func (m *MessageRecordsMutation) ResetErrorDetail() {
  9758. m.error_detail = nil
  9759. }
  9760. // SetSendTime sets the "send_time" field.
  9761. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  9762. m.send_time = &t
  9763. }
  9764. // SendTime returns the value of the "send_time" field in the mutation.
  9765. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  9766. v := m.send_time
  9767. if v == nil {
  9768. return
  9769. }
  9770. return *v, true
  9771. }
  9772. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  9773. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9774. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9775. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  9776. if !m.op.Is(OpUpdateOne) {
  9777. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  9778. }
  9779. if m.id == nil || m.oldValue == nil {
  9780. return v, errors.New("OldSendTime requires an ID field in the mutation")
  9781. }
  9782. oldValue, err := m.oldValue(ctx)
  9783. if err != nil {
  9784. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  9785. }
  9786. return oldValue.SendTime, nil
  9787. }
  9788. // ClearSendTime clears the value of the "send_time" field.
  9789. func (m *MessageRecordsMutation) ClearSendTime() {
  9790. m.send_time = nil
  9791. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  9792. }
  9793. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  9794. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  9795. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  9796. return ok
  9797. }
  9798. // ResetSendTime resets all changes to the "send_time" field.
  9799. func (m *MessageRecordsMutation) ResetSendTime() {
  9800. m.send_time = nil
  9801. delete(m.clearedFields, messagerecords.FieldSendTime)
  9802. }
  9803. // SetSourceType sets the "source_type" field.
  9804. func (m *MessageRecordsMutation) SetSourceType(i int) {
  9805. m.source_type = &i
  9806. m.addsource_type = nil
  9807. }
  9808. // SourceType returns the value of the "source_type" field in the mutation.
  9809. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  9810. v := m.source_type
  9811. if v == nil {
  9812. return
  9813. }
  9814. return *v, true
  9815. }
  9816. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  9817. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9819. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  9820. if !m.op.Is(OpUpdateOne) {
  9821. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  9822. }
  9823. if m.id == nil || m.oldValue == nil {
  9824. return v, errors.New("OldSourceType requires an ID field in the mutation")
  9825. }
  9826. oldValue, err := m.oldValue(ctx)
  9827. if err != nil {
  9828. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  9829. }
  9830. return oldValue.SourceType, nil
  9831. }
  9832. // AddSourceType adds i to the "source_type" field.
  9833. func (m *MessageRecordsMutation) AddSourceType(i int) {
  9834. if m.addsource_type != nil {
  9835. *m.addsource_type += i
  9836. } else {
  9837. m.addsource_type = &i
  9838. }
  9839. }
  9840. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  9841. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  9842. v := m.addsource_type
  9843. if v == nil {
  9844. return
  9845. }
  9846. return *v, true
  9847. }
  9848. // ResetSourceType resets all changes to the "source_type" field.
  9849. func (m *MessageRecordsMutation) ResetSourceType() {
  9850. m.source_type = nil
  9851. m.addsource_type = nil
  9852. }
  9853. // SetSourceID sets the "source_id" field.
  9854. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  9855. m.sop_stage = &u
  9856. }
  9857. // SourceID returns the value of the "source_id" field in the mutation.
  9858. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  9859. v := m.sop_stage
  9860. if v == nil {
  9861. return
  9862. }
  9863. return *v, true
  9864. }
  9865. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  9866. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9868. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  9869. if !m.op.Is(OpUpdateOne) {
  9870. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  9871. }
  9872. if m.id == nil || m.oldValue == nil {
  9873. return v, errors.New("OldSourceID requires an ID field in the mutation")
  9874. }
  9875. oldValue, err := m.oldValue(ctx)
  9876. if err != nil {
  9877. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  9878. }
  9879. return oldValue.SourceID, nil
  9880. }
  9881. // ClearSourceID clears the value of the "source_id" field.
  9882. func (m *MessageRecordsMutation) ClearSourceID() {
  9883. m.sop_stage = nil
  9884. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  9885. }
  9886. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  9887. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  9888. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  9889. return ok
  9890. }
  9891. // ResetSourceID resets all changes to the "source_id" field.
  9892. func (m *MessageRecordsMutation) ResetSourceID() {
  9893. m.sop_stage = nil
  9894. delete(m.clearedFields, messagerecords.FieldSourceID)
  9895. }
  9896. // SetSubSourceID sets the "sub_source_id" field.
  9897. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  9898. m.sop_node = &u
  9899. }
  9900. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  9901. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  9902. v := m.sop_node
  9903. if v == nil {
  9904. return
  9905. }
  9906. return *v, true
  9907. }
  9908. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  9909. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9910. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9911. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  9912. if !m.op.Is(OpUpdateOne) {
  9913. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  9914. }
  9915. if m.id == nil || m.oldValue == nil {
  9916. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  9917. }
  9918. oldValue, err := m.oldValue(ctx)
  9919. if err != nil {
  9920. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  9921. }
  9922. return oldValue.SubSourceID, nil
  9923. }
  9924. // ClearSubSourceID clears the value of the "sub_source_id" field.
  9925. func (m *MessageRecordsMutation) ClearSubSourceID() {
  9926. m.sop_node = nil
  9927. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  9928. }
  9929. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  9930. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  9931. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  9932. return ok
  9933. }
  9934. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  9935. func (m *MessageRecordsMutation) ResetSubSourceID() {
  9936. m.sop_node = nil
  9937. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  9938. }
  9939. // SetOrganizationID sets the "organization_id" field.
  9940. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  9941. m.organization_id = &u
  9942. m.addorganization_id = nil
  9943. }
  9944. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9945. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  9946. v := m.organization_id
  9947. if v == nil {
  9948. return
  9949. }
  9950. return *v, true
  9951. }
  9952. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  9953. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9955. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9956. if !m.op.Is(OpUpdateOne) {
  9957. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9958. }
  9959. if m.id == nil || m.oldValue == nil {
  9960. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9961. }
  9962. oldValue, err := m.oldValue(ctx)
  9963. if err != nil {
  9964. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9965. }
  9966. return oldValue.OrganizationID, nil
  9967. }
  9968. // AddOrganizationID adds u to the "organization_id" field.
  9969. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  9970. if m.addorganization_id != nil {
  9971. *m.addorganization_id += u
  9972. } else {
  9973. m.addorganization_id = &u
  9974. }
  9975. }
  9976. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9977. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  9978. v := m.addorganization_id
  9979. if v == nil {
  9980. return
  9981. }
  9982. return *v, true
  9983. }
  9984. // ClearOrganizationID clears the value of the "organization_id" field.
  9985. func (m *MessageRecordsMutation) ClearOrganizationID() {
  9986. m.organization_id = nil
  9987. m.addorganization_id = nil
  9988. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  9989. }
  9990. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  9991. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  9992. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  9993. return ok
  9994. }
  9995. // ResetOrganizationID resets all changes to the "organization_id" field.
  9996. func (m *MessageRecordsMutation) ResetOrganizationID() {
  9997. m.organization_id = nil
  9998. m.addorganization_id = nil
  9999. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  10000. }
  10001. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  10002. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  10003. m.sop_stage = &id
  10004. }
  10005. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  10006. func (m *MessageRecordsMutation) ClearSopStage() {
  10007. m.clearedsop_stage = true
  10008. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  10009. }
  10010. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  10011. func (m *MessageRecordsMutation) SopStageCleared() bool {
  10012. return m.SourceIDCleared() || m.clearedsop_stage
  10013. }
  10014. // SopStageID returns the "sop_stage" edge ID in the mutation.
  10015. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  10016. if m.sop_stage != nil {
  10017. return *m.sop_stage, true
  10018. }
  10019. return
  10020. }
  10021. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  10022. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  10023. // SopStageID instead. It exists only for internal usage by the builders.
  10024. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  10025. if id := m.sop_stage; id != nil {
  10026. ids = append(ids, *id)
  10027. }
  10028. return
  10029. }
  10030. // ResetSopStage resets all changes to the "sop_stage" edge.
  10031. func (m *MessageRecordsMutation) ResetSopStage() {
  10032. m.sop_stage = nil
  10033. m.clearedsop_stage = false
  10034. }
  10035. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  10036. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  10037. m.sop_node = &id
  10038. }
  10039. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  10040. func (m *MessageRecordsMutation) ClearSopNode() {
  10041. m.clearedsop_node = true
  10042. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  10043. }
  10044. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  10045. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  10046. return m.SubSourceIDCleared() || m.clearedsop_node
  10047. }
  10048. // SopNodeID returns the "sop_node" edge ID in the mutation.
  10049. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  10050. if m.sop_node != nil {
  10051. return *m.sop_node, true
  10052. }
  10053. return
  10054. }
  10055. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  10056. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  10057. // SopNodeID instead. It exists only for internal usage by the builders.
  10058. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  10059. if id := m.sop_node; id != nil {
  10060. ids = append(ids, *id)
  10061. }
  10062. return
  10063. }
  10064. // ResetSopNode resets all changes to the "sop_node" edge.
  10065. func (m *MessageRecordsMutation) ResetSopNode() {
  10066. m.sop_node = nil
  10067. m.clearedsop_node = false
  10068. }
  10069. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  10070. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  10071. m.message_contact = &id
  10072. }
  10073. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  10074. func (m *MessageRecordsMutation) ClearMessageContact() {
  10075. m.clearedmessage_contact = true
  10076. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  10077. }
  10078. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  10079. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  10080. return m.ContactIDCleared() || m.clearedmessage_contact
  10081. }
  10082. // MessageContactID returns the "message_contact" edge ID in the mutation.
  10083. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  10084. if m.message_contact != nil {
  10085. return *m.message_contact, true
  10086. }
  10087. return
  10088. }
  10089. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  10090. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  10091. // MessageContactID instead. It exists only for internal usage by the builders.
  10092. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  10093. if id := m.message_contact; id != nil {
  10094. ids = append(ids, *id)
  10095. }
  10096. return
  10097. }
  10098. // ResetMessageContact resets all changes to the "message_contact" edge.
  10099. func (m *MessageRecordsMutation) ResetMessageContact() {
  10100. m.message_contact = nil
  10101. m.clearedmessage_contact = false
  10102. }
  10103. // Where appends a list predicates to the MessageRecordsMutation builder.
  10104. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  10105. m.predicates = append(m.predicates, ps...)
  10106. }
  10107. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  10108. // users can use type-assertion to append predicates that do not depend on any generated package.
  10109. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  10110. p := make([]predicate.MessageRecords, len(ps))
  10111. for i := range ps {
  10112. p[i] = ps[i]
  10113. }
  10114. m.Where(p...)
  10115. }
  10116. // Op returns the operation name.
  10117. func (m *MessageRecordsMutation) Op() Op {
  10118. return m.op
  10119. }
  10120. // SetOp allows setting the mutation operation.
  10121. func (m *MessageRecordsMutation) SetOp(op Op) {
  10122. m.op = op
  10123. }
  10124. // Type returns the node type of this mutation (MessageRecords).
  10125. func (m *MessageRecordsMutation) Type() string {
  10126. return m.typ
  10127. }
  10128. // Fields returns all fields that were changed during this mutation. Note that in
  10129. // order to get all numeric fields that were incremented/decremented, call
  10130. // AddedFields().
  10131. func (m *MessageRecordsMutation) Fields() []string {
  10132. fields := make([]string, 0, 17)
  10133. if m.created_at != nil {
  10134. fields = append(fields, messagerecords.FieldCreatedAt)
  10135. }
  10136. if m.updated_at != nil {
  10137. fields = append(fields, messagerecords.FieldUpdatedAt)
  10138. }
  10139. if m.status != nil {
  10140. fields = append(fields, messagerecords.FieldStatus)
  10141. }
  10142. if m.deleted_at != nil {
  10143. fields = append(fields, messagerecords.FieldDeletedAt)
  10144. }
  10145. if m.bot_wxid != nil {
  10146. fields = append(fields, messagerecords.FieldBotWxid)
  10147. }
  10148. if m.message_contact != nil {
  10149. fields = append(fields, messagerecords.FieldContactID)
  10150. }
  10151. if m.contact_type != nil {
  10152. fields = append(fields, messagerecords.FieldContactType)
  10153. }
  10154. if m.contact_wxid != nil {
  10155. fields = append(fields, messagerecords.FieldContactWxid)
  10156. }
  10157. if m.content_type != nil {
  10158. fields = append(fields, messagerecords.FieldContentType)
  10159. }
  10160. if m.content != nil {
  10161. fields = append(fields, messagerecords.FieldContent)
  10162. }
  10163. if m.meta != nil {
  10164. fields = append(fields, messagerecords.FieldMeta)
  10165. }
  10166. if m.error_detail != nil {
  10167. fields = append(fields, messagerecords.FieldErrorDetail)
  10168. }
  10169. if m.send_time != nil {
  10170. fields = append(fields, messagerecords.FieldSendTime)
  10171. }
  10172. if m.source_type != nil {
  10173. fields = append(fields, messagerecords.FieldSourceType)
  10174. }
  10175. if m.sop_stage != nil {
  10176. fields = append(fields, messagerecords.FieldSourceID)
  10177. }
  10178. if m.sop_node != nil {
  10179. fields = append(fields, messagerecords.FieldSubSourceID)
  10180. }
  10181. if m.organization_id != nil {
  10182. fields = append(fields, messagerecords.FieldOrganizationID)
  10183. }
  10184. return fields
  10185. }
  10186. // Field returns the value of a field with the given name. The second boolean
  10187. // return value indicates that this field was not set, or was not defined in the
  10188. // schema.
  10189. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  10190. switch name {
  10191. case messagerecords.FieldCreatedAt:
  10192. return m.CreatedAt()
  10193. case messagerecords.FieldUpdatedAt:
  10194. return m.UpdatedAt()
  10195. case messagerecords.FieldStatus:
  10196. return m.Status()
  10197. case messagerecords.FieldDeletedAt:
  10198. return m.DeletedAt()
  10199. case messagerecords.FieldBotWxid:
  10200. return m.BotWxid()
  10201. case messagerecords.FieldContactID:
  10202. return m.ContactID()
  10203. case messagerecords.FieldContactType:
  10204. return m.ContactType()
  10205. case messagerecords.FieldContactWxid:
  10206. return m.ContactWxid()
  10207. case messagerecords.FieldContentType:
  10208. return m.ContentType()
  10209. case messagerecords.FieldContent:
  10210. return m.Content()
  10211. case messagerecords.FieldMeta:
  10212. return m.Meta()
  10213. case messagerecords.FieldErrorDetail:
  10214. return m.ErrorDetail()
  10215. case messagerecords.FieldSendTime:
  10216. return m.SendTime()
  10217. case messagerecords.FieldSourceType:
  10218. return m.SourceType()
  10219. case messagerecords.FieldSourceID:
  10220. return m.SourceID()
  10221. case messagerecords.FieldSubSourceID:
  10222. return m.SubSourceID()
  10223. case messagerecords.FieldOrganizationID:
  10224. return m.OrganizationID()
  10225. }
  10226. return nil, false
  10227. }
  10228. // OldField returns the old value of the field from the database. An error is
  10229. // returned if the mutation operation is not UpdateOne, or the query to the
  10230. // database failed.
  10231. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10232. switch name {
  10233. case messagerecords.FieldCreatedAt:
  10234. return m.OldCreatedAt(ctx)
  10235. case messagerecords.FieldUpdatedAt:
  10236. return m.OldUpdatedAt(ctx)
  10237. case messagerecords.FieldStatus:
  10238. return m.OldStatus(ctx)
  10239. case messagerecords.FieldDeletedAt:
  10240. return m.OldDeletedAt(ctx)
  10241. case messagerecords.FieldBotWxid:
  10242. return m.OldBotWxid(ctx)
  10243. case messagerecords.FieldContactID:
  10244. return m.OldContactID(ctx)
  10245. case messagerecords.FieldContactType:
  10246. return m.OldContactType(ctx)
  10247. case messagerecords.FieldContactWxid:
  10248. return m.OldContactWxid(ctx)
  10249. case messagerecords.FieldContentType:
  10250. return m.OldContentType(ctx)
  10251. case messagerecords.FieldContent:
  10252. return m.OldContent(ctx)
  10253. case messagerecords.FieldMeta:
  10254. return m.OldMeta(ctx)
  10255. case messagerecords.FieldErrorDetail:
  10256. return m.OldErrorDetail(ctx)
  10257. case messagerecords.FieldSendTime:
  10258. return m.OldSendTime(ctx)
  10259. case messagerecords.FieldSourceType:
  10260. return m.OldSourceType(ctx)
  10261. case messagerecords.FieldSourceID:
  10262. return m.OldSourceID(ctx)
  10263. case messagerecords.FieldSubSourceID:
  10264. return m.OldSubSourceID(ctx)
  10265. case messagerecords.FieldOrganizationID:
  10266. return m.OldOrganizationID(ctx)
  10267. }
  10268. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  10269. }
  10270. // SetField sets the value of a field with the given name. It returns an error if
  10271. // the field is not defined in the schema, or if the type mismatched the field
  10272. // type.
  10273. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  10274. switch name {
  10275. case messagerecords.FieldCreatedAt:
  10276. v, ok := value.(time.Time)
  10277. if !ok {
  10278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10279. }
  10280. m.SetCreatedAt(v)
  10281. return nil
  10282. case messagerecords.FieldUpdatedAt:
  10283. v, ok := value.(time.Time)
  10284. if !ok {
  10285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10286. }
  10287. m.SetUpdatedAt(v)
  10288. return nil
  10289. case messagerecords.FieldStatus:
  10290. v, ok := value.(uint8)
  10291. if !ok {
  10292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10293. }
  10294. m.SetStatus(v)
  10295. return nil
  10296. case messagerecords.FieldDeletedAt:
  10297. v, ok := value.(time.Time)
  10298. if !ok {
  10299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10300. }
  10301. m.SetDeletedAt(v)
  10302. return nil
  10303. case messagerecords.FieldBotWxid:
  10304. v, ok := value.(string)
  10305. if !ok {
  10306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10307. }
  10308. m.SetBotWxid(v)
  10309. return nil
  10310. case messagerecords.FieldContactID:
  10311. v, ok := value.(uint64)
  10312. if !ok {
  10313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10314. }
  10315. m.SetContactID(v)
  10316. return nil
  10317. case messagerecords.FieldContactType:
  10318. v, ok := value.(int)
  10319. if !ok {
  10320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10321. }
  10322. m.SetContactType(v)
  10323. return nil
  10324. case messagerecords.FieldContactWxid:
  10325. v, ok := value.(string)
  10326. if !ok {
  10327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10328. }
  10329. m.SetContactWxid(v)
  10330. return nil
  10331. case messagerecords.FieldContentType:
  10332. v, ok := value.(int)
  10333. if !ok {
  10334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10335. }
  10336. m.SetContentType(v)
  10337. return nil
  10338. case messagerecords.FieldContent:
  10339. v, ok := value.(string)
  10340. if !ok {
  10341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10342. }
  10343. m.SetContent(v)
  10344. return nil
  10345. case messagerecords.FieldMeta:
  10346. v, ok := value.(custom_types.Meta)
  10347. if !ok {
  10348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10349. }
  10350. m.SetMeta(v)
  10351. return nil
  10352. case messagerecords.FieldErrorDetail:
  10353. v, ok := value.(string)
  10354. if !ok {
  10355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10356. }
  10357. m.SetErrorDetail(v)
  10358. return nil
  10359. case messagerecords.FieldSendTime:
  10360. v, ok := value.(time.Time)
  10361. if !ok {
  10362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10363. }
  10364. m.SetSendTime(v)
  10365. return nil
  10366. case messagerecords.FieldSourceType:
  10367. v, ok := value.(int)
  10368. if !ok {
  10369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10370. }
  10371. m.SetSourceType(v)
  10372. return nil
  10373. case messagerecords.FieldSourceID:
  10374. v, ok := value.(uint64)
  10375. if !ok {
  10376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10377. }
  10378. m.SetSourceID(v)
  10379. return nil
  10380. case messagerecords.FieldSubSourceID:
  10381. v, ok := value.(uint64)
  10382. if !ok {
  10383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10384. }
  10385. m.SetSubSourceID(v)
  10386. return nil
  10387. case messagerecords.FieldOrganizationID:
  10388. v, ok := value.(uint64)
  10389. if !ok {
  10390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10391. }
  10392. m.SetOrganizationID(v)
  10393. return nil
  10394. }
  10395. return fmt.Errorf("unknown MessageRecords field %s", name)
  10396. }
  10397. // AddedFields returns all numeric fields that were incremented/decremented during
  10398. // this mutation.
  10399. func (m *MessageRecordsMutation) AddedFields() []string {
  10400. var fields []string
  10401. if m.addstatus != nil {
  10402. fields = append(fields, messagerecords.FieldStatus)
  10403. }
  10404. if m.addcontact_type != nil {
  10405. fields = append(fields, messagerecords.FieldContactType)
  10406. }
  10407. if m.addcontent_type != nil {
  10408. fields = append(fields, messagerecords.FieldContentType)
  10409. }
  10410. if m.addsource_type != nil {
  10411. fields = append(fields, messagerecords.FieldSourceType)
  10412. }
  10413. if m.addorganization_id != nil {
  10414. fields = append(fields, messagerecords.FieldOrganizationID)
  10415. }
  10416. return fields
  10417. }
  10418. // AddedField returns the numeric value that was incremented/decremented on a field
  10419. // with the given name. The second boolean return value indicates that this field
  10420. // was not set, or was not defined in the schema.
  10421. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  10422. switch name {
  10423. case messagerecords.FieldStatus:
  10424. return m.AddedStatus()
  10425. case messagerecords.FieldContactType:
  10426. return m.AddedContactType()
  10427. case messagerecords.FieldContentType:
  10428. return m.AddedContentType()
  10429. case messagerecords.FieldSourceType:
  10430. return m.AddedSourceType()
  10431. case messagerecords.FieldOrganizationID:
  10432. return m.AddedOrganizationID()
  10433. }
  10434. return nil, false
  10435. }
  10436. // AddField adds the value to the field with the given name. It returns an error if
  10437. // the field is not defined in the schema, or if the type mismatched the field
  10438. // type.
  10439. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  10440. switch name {
  10441. case messagerecords.FieldStatus:
  10442. v, ok := value.(int8)
  10443. if !ok {
  10444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10445. }
  10446. m.AddStatus(v)
  10447. return nil
  10448. case messagerecords.FieldContactType:
  10449. v, ok := value.(int)
  10450. if !ok {
  10451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10452. }
  10453. m.AddContactType(v)
  10454. return nil
  10455. case messagerecords.FieldContentType:
  10456. v, ok := value.(int)
  10457. if !ok {
  10458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10459. }
  10460. m.AddContentType(v)
  10461. return nil
  10462. case messagerecords.FieldSourceType:
  10463. v, ok := value.(int)
  10464. if !ok {
  10465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10466. }
  10467. m.AddSourceType(v)
  10468. return nil
  10469. case messagerecords.FieldOrganizationID:
  10470. v, ok := value.(int64)
  10471. if !ok {
  10472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10473. }
  10474. m.AddOrganizationID(v)
  10475. return nil
  10476. }
  10477. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  10478. }
  10479. // ClearedFields returns all nullable fields that were cleared during this
  10480. // mutation.
  10481. func (m *MessageRecordsMutation) ClearedFields() []string {
  10482. var fields []string
  10483. if m.FieldCleared(messagerecords.FieldStatus) {
  10484. fields = append(fields, messagerecords.FieldStatus)
  10485. }
  10486. if m.FieldCleared(messagerecords.FieldDeletedAt) {
  10487. fields = append(fields, messagerecords.FieldDeletedAt)
  10488. }
  10489. if m.FieldCleared(messagerecords.FieldContactID) {
  10490. fields = append(fields, messagerecords.FieldContactID)
  10491. }
  10492. if m.FieldCleared(messagerecords.FieldMeta) {
  10493. fields = append(fields, messagerecords.FieldMeta)
  10494. }
  10495. if m.FieldCleared(messagerecords.FieldSendTime) {
  10496. fields = append(fields, messagerecords.FieldSendTime)
  10497. }
  10498. if m.FieldCleared(messagerecords.FieldSourceID) {
  10499. fields = append(fields, messagerecords.FieldSourceID)
  10500. }
  10501. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  10502. fields = append(fields, messagerecords.FieldSubSourceID)
  10503. }
  10504. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  10505. fields = append(fields, messagerecords.FieldOrganizationID)
  10506. }
  10507. return fields
  10508. }
  10509. // FieldCleared returns a boolean indicating if a field with the given name was
  10510. // cleared in this mutation.
  10511. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  10512. _, ok := m.clearedFields[name]
  10513. return ok
  10514. }
  10515. // ClearField clears the value of the field with the given name. It returns an
  10516. // error if the field is not defined in the schema.
  10517. func (m *MessageRecordsMutation) ClearField(name string) error {
  10518. switch name {
  10519. case messagerecords.FieldStatus:
  10520. m.ClearStatus()
  10521. return nil
  10522. case messagerecords.FieldDeletedAt:
  10523. m.ClearDeletedAt()
  10524. return nil
  10525. case messagerecords.FieldContactID:
  10526. m.ClearContactID()
  10527. return nil
  10528. case messagerecords.FieldMeta:
  10529. m.ClearMeta()
  10530. return nil
  10531. case messagerecords.FieldSendTime:
  10532. m.ClearSendTime()
  10533. return nil
  10534. case messagerecords.FieldSourceID:
  10535. m.ClearSourceID()
  10536. return nil
  10537. case messagerecords.FieldSubSourceID:
  10538. m.ClearSubSourceID()
  10539. return nil
  10540. case messagerecords.FieldOrganizationID:
  10541. m.ClearOrganizationID()
  10542. return nil
  10543. }
  10544. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  10545. }
  10546. // ResetField resets all changes in the mutation for the field with the given name.
  10547. // It returns an error if the field is not defined in the schema.
  10548. func (m *MessageRecordsMutation) ResetField(name string) error {
  10549. switch name {
  10550. case messagerecords.FieldCreatedAt:
  10551. m.ResetCreatedAt()
  10552. return nil
  10553. case messagerecords.FieldUpdatedAt:
  10554. m.ResetUpdatedAt()
  10555. return nil
  10556. case messagerecords.FieldStatus:
  10557. m.ResetStatus()
  10558. return nil
  10559. case messagerecords.FieldDeletedAt:
  10560. m.ResetDeletedAt()
  10561. return nil
  10562. case messagerecords.FieldBotWxid:
  10563. m.ResetBotWxid()
  10564. return nil
  10565. case messagerecords.FieldContactID:
  10566. m.ResetContactID()
  10567. return nil
  10568. case messagerecords.FieldContactType:
  10569. m.ResetContactType()
  10570. return nil
  10571. case messagerecords.FieldContactWxid:
  10572. m.ResetContactWxid()
  10573. return nil
  10574. case messagerecords.FieldContentType:
  10575. m.ResetContentType()
  10576. return nil
  10577. case messagerecords.FieldContent:
  10578. m.ResetContent()
  10579. return nil
  10580. case messagerecords.FieldMeta:
  10581. m.ResetMeta()
  10582. return nil
  10583. case messagerecords.FieldErrorDetail:
  10584. m.ResetErrorDetail()
  10585. return nil
  10586. case messagerecords.FieldSendTime:
  10587. m.ResetSendTime()
  10588. return nil
  10589. case messagerecords.FieldSourceType:
  10590. m.ResetSourceType()
  10591. return nil
  10592. case messagerecords.FieldSourceID:
  10593. m.ResetSourceID()
  10594. return nil
  10595. case messagerecords.FieldSubSourceID:
  10596. m.ResetSubSourceID()
  10597. return nil
  10598. case messagerecords.FieldOrganizationID:
  10599. m.ResetOrganizationID()
  10600. return nil
  10601. }
  10602. return fmt.Errorf("unknown MessageRecords field %s", name)
  10603. }
  10604. // AddedEdges returns all edge names that were set/added in this mutation.
  10605. func (m *MessageRecordsMutation) AddedEdges() []string {
  10606. edges := make([]string, 0, 3)
  10607. if m.sop_stage != nil {
  10608. edges = append(edges, messagerecords.EdgeSopStage)
  10609. }
  10610. if m.sop_node != nil {
  10611. edges = append(edges, messagerecords.EdgeSopNode)
  10612. }
  10613. if m.message_contact != nil {
  10614. edges = append(edges, messagerecords.EdgeMessageContact)
  10615. }
  10616. return edges
  10617. }
  10618. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10619. // name in this mutation.
  10620. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  10621. switch name {
  10622. case messagerecords.EdgeSopStage:
  10623. if id := m.sop_stage; id != nil {
  10624. return []ent.Value{*id}
  10625. }
  10626. case messagerecords.EdgeSopNode:
  10627. if id := m.sop_node; id != nil {
  10628. return []ent.Value{*id}
  10629. }
  10630. case messagerecords.EdgeMessageContact:
  10631. if id := m.message_contact; id != nil {
  10632. return []ent.Value{*id}
  10633. }
  10634. }
  10635. return nil
  10636. }
  10637. // RemovedEdges returns all edge names that were removed in this mutation.
  10638. func (m *MessageRecordsMutation) RemovedEdges() []string {
  10639. edges := make([]string, 0, 3)
  10640. return edges
  10641. }
  10642. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10643. // the given name in this mutation.
  10644. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  10645. return nil
  10646. }
  10647. // ClearedEdges returns all edge names that were cleared in this mutation.
  10648. func (m *MessageRecordsMutation) ClearedEdges() []string {
  10649. edges := make([]string, 0, 3)
  10650. if m.clearedsop_stage {
  10651. edges = append(edges, messagerecords.EdgeSopStage)
  10652. }
  10653. if m.clearedsop_node {
  10654. edges = append(edges, messagerecords.EdgeSopNode)
  10655. }
  10656. if m.clearedmessage_contact {
  10657. edges = append(edges, messagerecords.EdgeMessageContact)
  10658. }
  10659. return edges
  10660. }
  10661. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10662. // was cleared in this mutation.
  10663. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  10664. switch name {
  10665. case messagerecords.EdgeSopStage:
  10666. return m.clearedsop_stage
  10667. case messagerecords.EdgeSopNode:
  10668. return m.clearedsop_node
  10669. case messagerecords.EdgeMessageContact:
  10670. return m.clearedmessage_contact
  10671. }
  10672. return false
  10673. }
  10674. // ClearEdge clears the value of the edge with the given name. It returns an error
  10675. // if that edge is not defined in the schema.
  10676. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  10677. switch name {
  10678. case messagerecords.EdgeSopStage:
  10679. m.ClearSopStage()
  10680. return nil
  10681. case messagerecords.EdgeSopNode:
  10682. m.ClearSopNode()
  10683. return nil
  10684. case messagerecords.EdgeMessageContact:
  10685. m.ClearMessageContact()
  10686. return nil
  10687. }
  10688. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  10689. }
  10690. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10691. // It returns an error if the edge is not defined in the schema.
  10692. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  10693. switch name {
  10694. case messagerecords.EdgeSopStage:
  10695. m.ResetSopStage()
  10696. return nil
  10697. case messagerecords.EdgeSopNode:
  10698. m.ResetSopNode()
  10699. return nil
  10700. case messagerecords.EdgeMessageContact:
  10701. m.ResetMessageContact()
  10702. return nil
  10703. }
  10704. return fmt.Errorf("unknown MessageRecords edge %s", name)
  10705. }
  10706. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  10707. type MsgMutation struct {
  10708. config
  10709. op Op
  10710. typ string
  10711. id *uint64
  10712. created_at *time.Time
  10713. updated_at *time.Time
  10714. deleted_at *time.Time
  10715. status *uint8
  10716. addstatus *int8
  10717. fromwxid *string
  10718. toid *string
  10719. msgtype *int32
  10720. addmsgtype *int32
  10721. msg *string
  10722. batch_no *string
  10723. clearedFields map[string]struct{}
  10724. done bool
  10725. oldValue func(context.Context) (*Msg, error)
  10726. predicates []predicate.Msg
  10727. }
  10728. var _ ent.Mutation = (*MsgMutation)(nil)
  10729. // msgOption allows management of the mutation configuration using functional options.
  10730. type msgOption func(*MsgMutation)
  10731. // newMsgMutation creates new mutation for the Msg entity.
  10732. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  10733. m := &MsgMutation{
  10734. config: c,
  10735. op: op,
  10736. typ: TypeMsg,
  10737. clearedFields: make(map[string]struct{}),
  10738. }
  10739. for _, opt := range opts {
  10740. opt(m)
  10741. }
  10742. return m
  10743. }
  10744. // withMsgID sets the ID field of the mutation.
  10745. func withMsgID(id uint64) msgOption {
  10746. return func(m *MsgMutation) {
  10747. var (
  10748. err error
  10749. once sync.Once
  10750. value *Msg
  10751. )
  10752. m.oldValue = func(ctx context.Context) (*Msg, error) {
  10753. once.Do(func() {
  10754. if m.done {
  10755. err = errors.New("querying old values post mutation is not allowed")
  10756. } else {
  10757. value, err = m.Client().Msg.Get(ctx, id)
  10758. }
  10759. })
  10760. return value, err
  10761. }
  10762. m.id = &id
  10763. }
  10764. }
  10765. // withMsg sets the old Msg of the mutation.
  10766. func withMsg(node *Msg) msgOption {
  10767. return func(m *MsgMutation) {
  10768. m.oldValue = func(context.Context) (*Msg, error) {
  10769. return node, nil
  10770. }
  10771. m.id = &node.ID
  10772. }
  10773. }
  10774. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10775. // executed in a transaction (ent.Tx), a transactional client is returned.
  10776. func (m MsgMutation) Client() *Client {
  10777. client := &Client{config: m.config}
  10778. client.init()
  10779. return client
  10780. }
  10781. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10782. // it returns an error otherwise.
  10783. func (m MsgMutation) Tx() (*Tx, error) {
  10784. if _, ok := m.driver.(*txDriver); !ok {
  10785. return nil, errors.New("ent: mutation is not running in a transaction")
  10786. }
  10787. tx := &Tx{config: m.config}
  10788. tx.init()
  10789. return tx, nil
  10790. }
  10791. // SetID sets the value of the id field. Note that this
  10792. // operation is only accepted on creation of Msg entities.
  10793. func (m *MsgMutation) SetID(id uint64) {
  10794. m.id = &id
  10795. }
  10796. // ID returns the ID value in the mutation. Note that the ID is only available
  10797. // if it was provided to the builder or after it was returned from the database.
  10798. func (m *MsgMutation) ID() (id uint64, exists bool) {
  10799. if m.id == nil {
  10800. return
  10801. }
  10802. return *m.id, true
  10803. }
  10804. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10805. // That means, if the mutation is applied within a transaction with an isolation level such
  10806. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10807. // or updated by the mutation.
  10808. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  10809. switch {
  10810. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10811. id, exists := m.ID()
  10812. if exists {
  10813. return []uint64{id}, nil
  10814. }
  10815. fallthrough
  10816. case m.op.Is(OpUpdate | OpDelete):
  10817. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  10818. default:
  10819. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10820. }
  10821. }
  10822. // SetCreatedAt sets the "created_at" field.
  10823. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  10824. m.created_at = &t
  10825. }
  10826. // CreatedAt returns the value of the "created_at" field in the mutation.
  10827. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  10828. v := m.created_at
  10829. if v == nil {
  10830. return
  10831. }
  10832. return *v, true
  10833. }
  10834. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  10835. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10837. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10838. if !m.op.Is(OpUpdateOne) {
  10839. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10840. }
  10841. if m.id == nil || m.oldValue == nil {
  10842. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10843. }
  10844. oldValue, err := m.oldValue(ctx)
  10845. if err != nil {
  10846. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10847. }
  10848. return oldValue.CreatedAt, nil
  10849. }
  10850. // ResetCreatedAt resets all changes to the "created_at" field.
  10851. func (m *MsgMutation) ResetCreatedAt() {
  10852. m.created_at = nil
  10853. }
  10854. // SetUpdatedAt sets the "updated_at" field.
  10855. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  10856. m.updated_at = &t
  10857. }
  10858. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10859. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  10860. v := m.updated_at
  10861. if v == nil {
  10862. return
  10863. }
  10864. return *v, true
  10865. }
  10866. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  10867. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10869. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10870. if !m.op.Is(OpUpdateOne) {
  10871. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10872. }
  10873. if m.id == nil || m.oldValue == nil {
  10874. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10875. }
  10876. oldValue, err := m.oldValue(ctx)
  10877. if err != nil {
  10878. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10879. }
  10880. return oldValue.UpdatedAt, nil
  10881. }
  10882. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10883. func (m *MsgMutation) ResetUpdatedAt() {
  10884. m.updated_at = nil
  10885. }
  10886. // SetDeletedAt sets the "deleted_at" field.
  10887. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  10888. m.deleted_at = &t
  10889. }
  10890. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10891. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  10892. v := m.deleted_at
  10893. if v == nil {
  10894. return
  10895. }
  10896. return *v, true
  10897. }
  10898. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  10899. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10901. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10902. if !m.op.Is(OpUpdateOne) {
  10903. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10904. }
  10905. if m.id == nil || m.oldValue == nil {
  10906. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10907. }
  10908. oldValue, err := m.oldValue(ctx)
  10909. if err != nil {
  10910. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10911. }
  10912. return oldValue.DeletedAt, nil
  10913. }
  10914. // ClearDeletedAt clears the value of the "deleted_at" field.
  10915. func (m *MsgMutation) ClearDeletedAt() {
  10916. m.deleted_at = nil
  10917. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  10918. }
  10919. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10920. func (m *MsgMutation) DeletedAtCleared() bool {
  10921. _, ok := m.clearedFields[msg.FieldDeletedAt]
  10922. return ok
  10923. }
  10924. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10925. func (m *MsgMutation) ResetDeletedAt() {
  10926. m.deleted_at = nil
  10927. delete(m.clearedFields, msg.FieldDeletedAt)
  10928. }
  10929. // SetStatus sets the "status" field.
  10930. func (m *MsgMutation) SetStatus(u uint8) {
  10931. m.status = &u
  10932. m.addstatus = nil
  10933. }
  10934. // Status returns the value of the "status" field in the mutation.
  10935. func (m *MsgMutation) Status() (r uint8, exists bool) {
  10936. v := m.status
  10937. if v == nil {
  10938. return
  10939. }
  10940. return *v, true
  10941. }
  10942. // OldStatus returns the old "status" field's value of the Msg entity.
  10943. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10945. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  10946. if !m.op.Is(OpUpdateOne) {
  10947. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10948. }
  10949. if m.id == nil || m.oldValue == nil {
  10950. return v, errors.New("OldStatus requires an ID field in the mutation")
  10951. }
  10952. oldValue, err := m.oldValue(ctx)
  10953. if err != nil {
  10954. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10955. }
  10956. return oldValue.Status, nil
  10957. }
  10958. // AddStatus adds u to the "status" field.
  10959. func (m *MsgMutation) AddStatus(u int8) {
  10960. if m.addstatus != nil {
  10961. *m.addstatus += u
  10962. } else {
  10963. m.addstatus = &u
  10964. }
  10965. }
  10966. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10967. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  10968. v := m.addstatus
  10969. if v == nil {
  10970. return
  10971. }
  10972. return *v, true
  10973. }
  10974. // ClearStatus clears the value of the "status" field.
  10975. func (m *MsgMutation) ClearStatus() {
  10976. m.status = nil
  10977. m.addstatus = nil
  10978. m.clearedFields[msg.FieldStatus] = struct{}{}
  10979. }
  10980. // StatusCleared returns if the "status" field was cleared in this mutation.
  10981. func (m *MsgMutation) StatusCleared() bool {
  10982. _, ok := m.clearedFields[msg.FieldStatus]
  10983. return ok
  10984. }
  10985. // ResetStatus resets all changes to the "status" field.
  10986. func (m *MsgMutation) ResetStatus() {
  10987. m.status = nil
  10988. m.addstatus = nil
  10989. delete(m.clearedFields, msg.FieldStatus)
  10990. }
  10991. // SetFromwxid sets the "fromwxid" field.
  10992. func (m *MsgMutation) SetFromwxid(s string) {
  10993. m.fromwxid = &s
  10994. }
  10995. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  10996. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  10997. v := m.fromwxid
  10998. if v == nil {
  10999. return
  11000. }
  11001. return *v, true
  11002. }
  11003. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  11004. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11006. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  11007. if !m.op.Is(OpUpdateOne) {
  11008. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  11009. }
  11010. if m.id == nil || m.oldValue == nil {
  11011. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  11012. }
  11013. oldValue, err := m.oldValue(ctx)
  11014. if err != nil {
  11015. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  11016. }
  11017. return oldValue.Fromwxid, nil
  11018. }
  11019. // ClearFromwxid clears the value of the "fromwxid" field.
  11020. func (m *MsgMutation) ClearFromwxid() {
  11021. m.fromwxid = nil
  11022. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  11023. }
  11024. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  11025. func (m *MsgMutation) FromwxidCleared() bool {
  11026. _, ok := m.clearedFields[msg.FieldFromwxid]
  11027. return ok
  11028. }
  11029. // ResetFromwxid resets all changes to the "fromwxid" field.
  11030. func (m *MsgMutation) ResetFromwxid() {
  11031. m.fromwxid = nil
  11032. delete(m.clearedFields, msg.FieldFromwxid)
  11033. }
  11034. // SetToid sets the "toid" field.
  11035. func (m *MsgMutation) SetToid(s string) {
  11036. m.toid = &s
  11037. }
  11038. // Toid returns the value of the "toid" field in the mutation.
  11039. func (m *MsgMutation) Toid() (r string, exists bool) {
  11040. v := m.toid
  11041. if v == nil {
  11042. return
  11043. }
  11044. return *v, true
  11045. }
  11046. // OldToid returns the old "toid" field's value of the Msg entity.
  11047. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11049. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  11050. if !m.op.Is(OpUpdateOne) {
  11051. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  11052. }
  11053. if m.id == nil || m.oldValue == nil {
  11054. return v, errors.New("OldToid requires an ID field in the mutation")
  11055. }
  11056. oldValue, err := m.oldValue(ctx)
  11057. if err != nil {
  11058. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  11059. }
  11060. return oldValue.Toid, nil
  11061. }
  11062. // ClearToid clears the value of the "toid" field.
  11063. func (m *MsgMutation) ClearToid() {
  11064. m.toid = nil
  11065. m.clearedFields[msg.FieldToid] = struct{}{}
  11066. }
  11067. // ToidCleared returns if the "toid" field was cleared in this mutation.
  11068. func (m *MsgMutation) ToidCleared() bool {
  11069. _, ok := m.clearedFields[msg.FieldToid]
  11070. return ok
  11071. }
  11072. // ResetToid resets all changes to the "toid" field.
  11073. func (m *MsgMutation) ResetToid() {
  11074. m.toid = nil
  11075. delete(m.clearedFields, msg.FieldToid)
  11076. }
  11077. // SetMsgtype sets the "msgtype" field.
  11078. func (m *MsgMutation) SetMsgtype(i int32) {
  11079. m.msgtype = &i
  11080. m.addmsgtype = nil
  11081. }
  11082. // Msgtype returns the value of the "msgtype" field in the mutation.
  11083. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  11084. v := m.msgtype
  11085. if v == nil {
  11086. return
  11087. }
  11088. return *v, true
  11089. }
  11090. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  11091. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11093. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  11094. if !m.op.Is(OpUpdateOne) {
  11095. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  11096. }
  11097. if m.id == nil || m.oldValue == nil {
  11098. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  11099. }
  11100. oldValue, err := m.oldValue(ctx)
  11101. if err != nil {
  11102. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  11103. }
  11104. return oldValue.Msgtype, nil
  11105. }
  11106. // AddMsgtype adds i to the "msgtype" field.
  11107. func (m *MsgMutation) AddMsgtype(i int32) {
  11108. if m.addmsgtype != nil {
  11109. *m.addmsgtype += i
  11110. } else {
  11111. m.addmsgtype = &i
  11112. }
  11113. }
  11114. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  11115. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  11116. v := m.addmsgtype
  11117. if v == nil {
  11118. return
  11119. }
  11120. return *v, true
  11121. }
  11122. // ClearMsgtype clears the value of the "msgtype" field.
  11123. func (m *MsgMutation) ClearMsgtype() {
  11124. m.msgtype = nil
  11125. m.addmsgtype = nil
  11126. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  11127. }
  11128. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  11129. func (m *MsgMutation) MsgtypeCleared() bool {
  11130. _, ok := m.clearedFields[msg.FieldMsgtype]
  11131. return ok
  11132. }
  11133. // ResetMsgtype resets all changes to the "msgtype" field.
  11134. func (m *MsgMutation) ResetMsgtype() {
  11135. m.msgtype = nil
  11136. m.addmsgtype = nil
  11137. delete(m.clearedFields, msg.FieldMsgtype)
  11138. }
  11139. // SetMsg sets the "msg" field.
  11140. func (m *MsgMutation) SetMsg(s string) {
  11141. m.msg = &s
  11142. }
  11143. // Msg returns the value of the "msg" field in the mutation.
  11144. func (m *MsgMutation) Msg() (r string, exists bool) {
  11145. v := m.msg
  11146. if v == nil {
  11147. return
  11148. }
  11149. return *v, true
  11150. }
  11151. // OldMsg returns the old "msg" field's value of the Msg entity.
  11152. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11154. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  11155. if !m.op.Is(OpUpdateOne) {
  11156. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  11157. }
  11158. if m.id == nil || m.oldValue == nil {
  11159. return v, errors.New("OldMsg requires an ID field in the mutation")
  11160. }
  11161. oldValue, err := m.oldValue(ctx)
  11162. if err != nil {
  11163. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  11164. }
  11165. return oldValue.Msg, nil
  11166. }
  11167. // ClearMsg clears the value of the "msg" field.
  11168. func (m *MsgMutation) ClearMsg() {
  11169. m.msg = nil
  11170. m.clearedFields[msg.FieldMsg] = struct{}{}
  11171. }
  11172. // MsgCleared returns if the "msg" field was cleared in this mutation.
  11173. func (m *MsgMutation) MsgCleared() bool {
  11174. _, ok := m.clearedFields[msg.FieldMsg]
  11175. return ok
  11176. }
  11177. // ResetMsg resets all changes to the "msg" field.
  11178. func (m *MsgMutation) ResetMsg() {
  11179. m.msg = nil
  11180. delete(m.clearedFields, msg.FieldMsg)
  11181. }
  11182. // SetBatchNo sets the "batch_no" field.
  11183. func (m *MsgMutation) SetBatchNo(s string) {
  11184. m.batch_no = &s
  11185. }
  11186. // BatchNo returns the value of the "batch_no" field in the mutation.
  11187. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  11188. v := m.batch_no
  11189. if v == nil {
  11190. return
  11191. }
  11192. return *v, true
  11193. }
  11194. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  11195. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11197. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  11198. if !m.op.Is(OpUpdateOne) {
  11199. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  11200. }
  11201. if m.id == nil || m.oldValue == nil {
  11202. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  11203. }
  11204. oldValue, err := m.oldValue(ctx)
  11205. if err != nil {
  11206. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  11207. }
  11208. return oldValue.BatchNo, nil
  11209. }
  11210. // ClearBatchNo clears the value of the "batch_no" field.
  11211. func (m *MsgMutation) ClearBatchNo() {
  11212. m.batch_no = nil
  11213. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  11214. }
  11215. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  11216. func (m *MsgMutation) BatchNoCleared() bool {
  11217. _, ok := m.clearedFields[msg.FieldBatchNo]
  11218. return ok
  11219. }
  11220. // ResetBatchNo resets all changes to the "batch_no" field.
  11221. func (m *MsgMutation) ResetBatchNo() {
  11222. m.batch_no = nil
  11223. delete(m.clearedFields, msg.FieldBatchNo)
  11224. }
  11225. // Where appends a list predicates to the MsgMutation builder.
  11226. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  11227. m.predicates = append(m.predicates, ps...)
  11228. }
  11229. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  11230. // users can use type-assertion to append predicates that do not depend on any generated package.
  11231. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  11232. p := make([]predicate.Msg, len(ps))
  11233. for i := range ps {
  11234. p[i] = ps[i]
  11235. }
  11236. m.Where(p...)
  11237. }
  11238. // Op returns the operation name.
  11239. func (m *MsgMutation) Op() Op {
  11240. return m.op
  11241. }
  11242. // SetOp allows setting the mutation operation.
  11243. func (m *MsgMutation) SetOp(op Op) {
  11244. m.op = op
  11245. }
  11246. // Type returns the node type of this mutation (Msg).
  11247. func (m *MsgMutation) Type() string {
  11248. return m.typ
  11249. }
  11250. // Fields returns all fields that were changed during this mutation. Note that in
  11251. // order to get all numeric fields that were incremented/decremented, call
  11252. // AddedFields().
  11253. func (m *MsgMutation) Fields() []string {
  11254. fields := make([]string, 0, 9)
  11255. if m.created_at != nil {
  11256. fields = append(fields, msg.FieldCreatedAt)
  11257. }
  11258. if m.updated_at != nil {
  11259. fields = append(fields, msg.FieldUpdatedAt)
  11260. }
  11261. if m.deleted_at != nil {
  11262. fields = append(fields, msg.FieldDeletedAt)
  11263. }
  11264. if m.status != nil {
  11265. fields = append(fields, msg.FieldStatus)
  11266. }
  11267. if m.fromwxid != nil {
  11268. fields = append(fields, msg.FieldFromwxid)
  11269. }
  11270. if m.toid != nil {
  11271. fields = append(fields, msg.FieldToid)
  11272. }
  11273. if m.msgtype != nil {
  11274. fields = append(fields, msg.FieldMsgtype)
  11275. }
  11276. if m.msg != nil {
  11277. fields = append(fields, msg.FieldMsg)
  11278. }
  11279. if m.batch_no != nil {
  11280. fields = append(fields, msg.FieldBatchNo)
  11281. }
  11282. return fields
  11283. }
  11284. // Field returns the value of a field with the given name. The second boolean
  11285. // return value indicates that this field was not set, or was not defined in the
  11286. // schema.
  11287. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  11288. switch name {
  11289. case msg.FieldCreatedAt:
  11290. return m.CreatedAt()
  11291. case msg.FieldUpdatedAt:
  11292. return m.UpdatedAt()
  11293. case msg.FieldDeletedAt:
  11294. return m.DeletedAt()
  11295. case msg.FieldStatus:
  11296. return m.Status()
  11297. case msg.FieldFromwxid:
  11298. return m.Fromwxid()
  11299. case msg.FieldToid:
  11300. return m.Toid()
  11301. case msg.FieldMsgtype:
  11302. return m.Msgtype()
  11303. case msg.FieldMsg:
  11304. return m.Msg()
  11305. case msg.FieldBatchNo:
  11306. return m.BatchNo()
  11307. }
  11308. return nil, false
  11309. }
  11310. // OldField returns the old value of the field from the database. An error is
  11311. // returned if the mutation operation is not UpdateOne, or the query to the
  11312. // database failed.
  11313. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11314. switch name {
  11315. case msg.FieldCreatedAt:
  11316. return m.OldCreatedAt(ctx)
  11317. case msg.FieldUpdatedAt:
  11318. return m.OldUpdatedAt(ctx)
  11319. case msg.FieldDeletedAt:
  11320. return m.OldDeletedAt(ctx)
  11321. case msg.FieldStatus:
  11322. return m.OldStatus(ctx)
  11323. case msg.FieldFromwxid:
  11324. return m.OldFromwxid(ctx)
  11325. case msg.FieldToid:
  11326. return m.OldToid(ctx)
  11327. case msg.FieldMsgtype:
  11328. return m.OldMsgtype(ctx)
  11329. case msg.FieldMsg:
  11330. return m.OldMsg(ctx)
  11331. case msg.FieldBatchNo:
  11332. return m.OldBatchNo(ctx)
  11333. }
  11334. return nil, fmt.Errorf("unknown Msg field %s", name)
  11335. }
  11336. // SetField sets the value of a field with the given name. It returns an error if
  11337. // the field is not defined in the schema, or if the type mismatched the field
  11338. // type.
  11339. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  11340. switch name {
  11341. case msg.FieldCreatedAt:
  11342. v, ok := value.(time.Time)
  11343. if !ok {
  11344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11345. }
  11346. m.SetCreatedAt(v)
  11347. return nil
  11348. case msg.FieldUpdatedAt:
  11349. v, ok := value.(time.Time)
  11350. if !ok {
  11351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11352. }
  11353. m.SetUpdatedAt(v)
  11354. return nil
  11355. case msg.FieldDeletedAt:
  11356. v, ok := value.(time.Time)
  11357. if !ok {
  11358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11359. }
  11360. m.SetDeletedAt(v)
  11361. return nil
  11362. case msg.FieldStatus:
  11363. v, ok := value.(uint8)
  11364. if !ok {
  11365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11366. }
  11367. m.SetStatus(v)
  11368. return nil
  11369. case msg.FieldFromwxid:
  11370. v, ok := value.(string)
  11371. if !ok {
  11372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11373. }
  11374. m.SetFromwxid(v)
  11375. return nil
  11376. case msg.FieldToid:
  11377. v, ok := value.(string)
  11378. if !ok {
  11379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11380. }
  11381. m.SetToid(v)
  11382. return nil
  11383. case msg.FieldMsgtype:
  11384. v, ok := value.(int32)
  11385. if !ok {
  11386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11387. }
  11388. m.SetMsgtype(v)
  11389. return nil
  11390. case msg.FieldMsg:
  11391. v, ok := value.(string)
  11392. if !ok {
  11393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11394. }
  11395. m.SetMsg(v)
  11396. return nil
  11397. case msg.FieldBatchNo:
  11398. v, ok := value.(string)
  11399. if !ok {
  11400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11401. }
  11402. m.SetBatchNo(v)
  11403. return nil
  11404. }
  11405. return fmt.Errorf("unknown Msg field %s", name)
  11406. }
  11407. // AddedFields returns all numeric fields that were incremented/decremented during
  11408. // this mutation.
  11409. func (m *MsgMutation) AddedFields() []string {
  11410. var fields []string
  11411. if m.addstatus != nil {
  11412. fields = append(fields, msg.FieldStatus)
  11413. }
  11414. if m.addmsgtype != nil {
  11415. fields = append(fields, msg.FieldMsgtype)
  11416. }
  11417. return fields
  11418. }
  11419. // AddedField returns the numeric value that was incremented/decremented on a field
  11420. // with the given name. The second boolean return value indicates that this field
  11421. // was not set, or was not defined in the schema.
  11422. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  11423. switch name {
  11424. case msg.FieldStatus:
  11425. return m.AddedStatus()
  11426. case msg.FieldMsgtype:
  11427. return m.AddedMsgtype()
  11428. }
  11429. return nil, false
  11430. }
  11431. // AddField adds the value to the field with the given name. It returns an error if
  11432. // the field is not defined in the schema, or if the type mismatched the field
  11433. // type.
  11434. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  11435. switch name {
  11436. case msg.FieldStatus:
  11437. v, ok := value.(int8)
  11438. if !ok {
  11439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11440. }
  11441. m.AddStatus(v)
  11442. return nil
  11443. case msg.FieldMsgtype:
  11444. v, ok := value.(int32)
  11445. if !ok {
  11446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11447. }
  11448. m.AddMsgtype(v)
  11449. return nil
  11450. }
  11451. return fmt.Errorf("unknown Msg numeric field %s", name)
  11452. }
  11453. // ClearedFields returns all nullable fields that were cleared during this
  11454. // mutation.
  11455. func (m *MsgMutation) ClearedFields() []string {
  11456. var fields []string
  11457. if m.FieldCleared(msg.FieldDeletedAt) {
  11458. fields = append(fields, msg.FieldDeletedAt)
  11459. }
  11460. if m.FieldCleared(msg.FieldStatus) {
  11461. fields = append(fields, msg.FieldStatus)
  11462. }
  11463. if m.FieldCleared(msg.FieldFromwxid) {
  11464. fields = append(fields, msg.FieldFromwxid)
  11465. }
  11466. if m.FieldCleared(msg.FieldToid) {
  11467. fields = append(fields, msg.FieldToid)
  11468. }
  11469. if m.FieldCleared(msg.FieldMsgtype) {
  11470. fields = append(fields, msg.FieldMsgtype)
  11471. }
  11472. if m.FieldCleared(msg.FieldMsg) {
  11473. fields = append(fields, msg.FieldMsg)
  11474. }
  11475. if m.FieldCleared(msg.FieldBatchNo) {
  11476. fields = append(fields, msg.FieldBatchNo)
  11477. }
  11478. return fields
  11479. }
  11480. // FieldCleared returns a boolean indicating if a field with the given name was
  11481. // cleared in this mutation.
  11482. func (m *MsgMutation) FieldCleared(name string) bool {
  11483. _, ok := m.clearedFields[name]
  11484. return ok
  11485. }
  11486. // ClearField clears the value of the field with the given name. It returns an
  11487. // error if the field is not defined in the schema.
  11488. func (m *MsgMutation) ClearField(name string) error {
  11489. switch name {
  11490. case msg.FieldDeletedAt:
  11491. m.ClearDeletedAt()
  11492. return nil
  11493. case msg.FieldStatus:
  11494. m.ClearStatus()
  11495. return nil
  11496. case msg.FieldFromwxid:
  11497. m.ClearFromwxid()
  11498. return nil
  11499. case msg.FieldToid:
  11500. m.ClearToid()
  11501. return nil
  11502. case msg.FieldMsgtype:
  11503. m.ClearMsgtype()
  11504. return nil
  11505. case msg.FieldMsg:
  11506. m.ClearMsg()
  11507. return nil
  11508. case msg.FieldBatchNo:
  11509. m.ClearBatchNo()
  11510. return nil
  11511. }
  11512. return fmt.Errorf("unknown Msg nullable field %s", name)
  11513. }
  11514. // ResetField resets all changes in the mutation for the field with the given name.
  11515. // It returns an error if the field is not defined in the schema.
  11516. func (m *MsgMutation) ResetField(name string) error {
  11517. switch name {
  11518. case msg.FieldCreatedAt:
  11519. m.ResetCreatedAt()
  11520. return nil
  11521. case msg.FieldUpdatedAt:
  11522. m.ResetUpdatedAt()
  11523. return nil
  11524. case msg.FieldDeletedAt:
  11525. m.ResetDeletedAt()
  11526. return nil
  11527. case msg.FieldStatus:
  11528. m.ResetStatus()
  11529. return nil
  11530. case msg.FieldFromwxid:
  11531. m.ResetFromwxid()
  11532. return nil
  11533. case msg.FieldToid:
  11534. m.ResetToid()
  11535. return nil
  11536. case msg.FieldMsgtype:
  11537. m.ResetMsgtype()
  11538. return nil
  11539. case msg.FieldMsg:
  11540. m.ResetMsg()
  11541. return nil
  11542. case msg.FieldBatchNo:
  11543. m.ResetBatchNo()
  11544. return nil
  11545. }
  11546. return fmt.Errorf("unknown Msg field %s", name)
  11547. }
  11548. // AddedEdges returns all edge names that were set/added in this mutation.
  11549. func (m *MsgMutation) AddedEdges() []string {
  11550. edges := make([]string, 0, 0)
  11551. return edges
  11552. }
  11553. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11554. // name in this mutation.
  11555. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  11556. return nil
  11557. }
  11558. // RemovedEdges returns all edge names that were removed in this mutation.
  11559. func (m *MsgMutation) RemovedEdges() []string {
  11560. edges := make([]string, 0, 0)
  11561. return edges
  11562. }
  11563. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11564. // the given name in this mutation.
  11565. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  11566. return nil
  11567. }
  11568. // ClearedEdges returns all edge names that were cleared in this mutation.
  11569. func (m *MsgMutation) ClearedEdges() []string {
  11570. edges := make([]string, 0, 0)
  11571. return edges
  11572. }
  11573. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11574. // was cleared in this mutation.
  11575. func (m *MsgMutation) EdgeCleared(name string) bool {
  11576. return false
  11577. }
  11578. // ClearEdge clears the value of the edge with the given name. It returns an error
  11579. // if that edge is not defined in the schema.
  11580. func (m *MsgMutation) ClearEdge(name string) error {
  11581. return fmt.Errorf("unknown Msg unique edge %s", name)
  11582. }
  11583. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11584. // It returns an error if the edge is not defined in the schema.
  11585. func (m *MsgMutation) ResetEdge(name string) error {
  11586. return fmt.Errorf("unknown Msg edge %s", name)
  11587. }
  11588. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  11589. type ServerMutation struct {
  11590. config
  11591. op Op
  11592. typ string
  11593. id *uint64
  11594. created_at *time.Time
  11595. updated_at *time.Time
  11596. status *uint8
  11597. addstatus *int8
  11598. deleted_at *time.Time
  11599. name *string
  11600. public_ip *string
  11601. private_ip *string
  11602. admin_port *string
  11603. clearedFields map[string]struct{}
  11604. wxs map[uint64]struct{}
  11605. removedwxs map[uint64]struct{}
  11606. clearedwxs bool
  11607. done bool
  11608. oldValue func(context.Context) (*Server, error)
  11609. predicates []predicate.Server
  11610. }
  11611. var _ ent.Mutation = (*ServerMutation)(nil)
  11612. // serverOption allows management of the mutation configuration using functional options.
  11613. type serverOption func(*ServerMutation)
  11614. // newServerMutation creates new mutation for the Server entity.
  11615. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  11616. m := &ServerMutation{
  11617. config: c,
  11618. op: op,
  11619. typ: TypeServer,
  11620. clearedFields: make(map[string]struct{}),
  11621. }
  11622. for _, opt := range opts {
  11623. opt(m)
  11624. }
  11625. return m
  11626. }
  11627. // withServerID sets the ID field of the mutation.
  11628. func withServerID(id uint64) serverOption {
  11629. return func(m *ServerMutation) {
  11630. var (
  11631. err error
  11632. once sync.Once
  11633. value *Server
  11634. )
  11635. m.oldValue = func(ctx context.Context) (*Server, error) {
  11636. once.Do(func() {
  11637. if m.done {
  11638. err = errors.New("querying old values post mutation is not allowed")
  11639. } else {
  11640. value, err = m.Client().Server.Get(ctx, id)
  11641. }
  11642. })
  11643. return value, err
  11644. }
  11645. m.id = &id
  11646. }
  11647. }
  11648. // withServer sets the old Server of the mutation.
  11649. func withServer(node *Server) serverOption {
  11650. return func(m *ServerMutation) {
  11651. m.oldValue = func(context.Context) (*Server, error) {
  11652. return node, nil
  11653. }
  11654. m.id = &node.ID
  11655. }
  11656. }
  11657. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11658. // executed in a transaction (ent.Tx), a transactional client is returned.
  11659. func (m ServerMutation) Client() *Client {
  11660. client := &Client{config: m.config}
  11661. client.init()
  11662. return client
  11663. }
  11664. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11665. // it returns an error otherwise.
  11666. func (m ServerMutation) Tx() (*Tx, error) {
  11667. if _, ok := m.driver.(*txDriver); !ok {
  11668. return nil, errors.New("ent: mutation is not running in a transaction")
  11669. }
  11670. tx := &Tx{config: m.config}
  11671. tx.init()
  11672. return tx, nil
  11673. }
  11674. // SetID sets the value of the id field. Note that this
  11675. // operation is only accepted on creation of Server entities.
  11676. func (m *ServerMutation) SetID(id uint64) {
  11677. m.id = &id
  11678. }
  11679. // ID returns the ID value in the mutation. Note that the ID is only available
  11680. // if it was provided to the builder or after it was returned from the database.
  11681. func (m *ServerMutation) ID() (id uint64, exists bool) {
  11682. if m.id == nil {
  11683. return
  11684. }
  11685. return *m.id, true
  11686. }
  11687. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11688. // That means, if the mutation is applied within a transaction with an isolation level such
  11689. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11690. // or updated by the mutation.
  11691. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  11692. switch {
  11693. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11694. id, exists := m.ID()
  11695. if exists {
  11696. return []uint64{id}, nil
  11697. }
  11698. fallthrough
  11699. case m.op.Is(OpUpdate | OpDelete):
  11700. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  11701. default:
  11702. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11703. }
  11704. }
  11705. // SetCreatedAt sets the "created_at" field.
  11706. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  11707. m.created_at = &t
  11708. }
  11709. // CreatedAt returns the value of the "created_at" field in the mutation.
  11710. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  11711. v := m.created_at
  11712. if v == nil {
  11713. return
  11714. }
  11715. return *v, true
  11716. }
  11717. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  11718. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11720. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11721. if !m.op.Is(OpUpdateOne) {
  11722. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11723. }
  11724. if m.id == nil || m.oldValue == nil {
  11725. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11726. }
  11727. oldValue, err := m.oldValue(ctx)
  11728. if err != nil {
  11729. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11730. }
  11731. return oldValue.CreatedAt, nil
  11732. }
  11733. // ResetCreatedAt resets all changes to the "created_at" field.
  11734. func (m *ServerMutation) ResetCreatedAt() {
  11735. m.created_at = nil
  11736. }
  11737. // SetUpdatedAt sets the "updated_at" field.
  11738. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  11739. m.updated_at = &t
  11740. }
  11741. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11742. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  11743. v := m.updated_at
  11744. if v == nil {
  11745. return
  11746. }
  11747. return *v, true
  11748. }
  11749. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  11750. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11751. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11752. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11753. if !m.op.Is(OpUpdateOne) {
  11754. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11755. }
  11756. if m.id == nil || m.oldValue == nil {
  11757. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11758. }
  11759. oldValue, err := m.oldValue(ctx)
  11760. if err != nil {
  11761. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11762. }
  11763. return oldValue.UpdatedAt, nil
  11764. }
  11765. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11766. func (m *ServerMutation) ResetUpdatedAt() {
  11767. m.updated_at = nil
  11768. }
  11769. // SetStatus sets the "status" field.
  11770. func (m *ServerMutation) SetStatus(u uint8) {
  11771. m.status = &u
  11772. m.addstatus = nil
  11773. }
  11774. // Status returns the value of the "status" field in the mutation.
  11775. func (m *ServerMutation) Status() (r uint8, exists bool) {
  11776. v := m.status
  11777. if v == nil {
  11778. return
  11779. }
  11780. return *v, true
  11781. }
  11782. // OldStatus returns the old "status" field's value of the Server entity.
  11783. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11785. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11786. if !m.op.Is(OpUpdateOne) {
  11787. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11788. }
  11789. if m.id == nil || m.oldValue == nil {
  11790. return v, errors.New("OldStatus requires an ID field in the mutation")
  11791. }
  11792. oldValue, err := m.oldValue(ctx)
  11793. if err != nil {
  11794. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11795. }
  11796. return oldValue.Status, nil
  11797. }
  11798. // AddStatus adds u to the "status" field.
  11799. func (m *ServerMutation) AddStatus(u int8) {
  11800. if m.addstatus != nil {
  11801. *m.addstatus += u
  11802. } else {
  11803. m.addstatus = &u
  11804. }
  11805. }
  11806. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11807. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  11808. v := m.addstatus
  11809. if v == nil {
  11810. return
  11811. }
  11812. return *v, true
  11813. }
  11814. // ClearStatus clears the value of the "status" field.
  11815. func (m *ServerMutation) ClearStatus() {
  11816. m.status = nil
  11817. m.addstatus = nil
  11818. m.clearedFields[server.FieldStatus] = struct{}{}
  11819. }
  11820. // StatusCleared returns if the "status" field was cleared in this mutation.
  11821. func (m *ServerMutation) StatusCleared() bool {
  11822. _, ok := m.clearedFields[server.FieldStatus]
  11823. return ok
  11824. }
  11825. // ResetStatus resets all changes to the "status" field.
  11826. func (m *ServerMutation) ResetStatus() {
  11827. m.status = nil
  11828. m.addstatus = nil
  11829. delete(m.clearedFields, server.FieldStatus)
  11830. }
  11831. // SetDeletedAt sets the "deleted_at" field.
  11832. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  11833. m.deleted_at = &t
  11834. }
  11835. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11836. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  11837. v := m.deleted_at
  11838. if v == nil {
  11839. return
  11840. }
  11841. return *v, true
  11842. }
  11843. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  11844. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11846. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11847. if !m.op.Is(OpUpdateOne) {
  11848. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11849. }
  11850. if m.id == nil || m.oldValue == nil {
  11851. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11852. }
  11853. oldValue, err := m.oldValue(ctx)
  11854. if err != nil {
  11855. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11856. }
  11857. return oldValue.DeletedAt, nil
  11858. }
  11859. // ClearDeletedAt clears the value of the "deleted_at" field.
  11860. func (m *ServerMutation) ClearDeletedAt() {
  11861. m.deleted_at = nil
  11862. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  11863. }
  11864. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11865. func (m *ServerMutation) DeletedAtCleared() bool {
  11866. _, ok := m.clearedFields[server.FieldDeletedAt]
  11867. return ok
  11868. }
  11869. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11870. func (m *ServerMutation) ResetDeletedAt() {
  11871. m.deleted_at = nil
  11872. delete(m.clearedFields, server.FieldDeletedAt)
  11873. }
  11874. // SetName sets the "name" field.
  11875. func (m *ServerMutation) SetName(s string) {
  11876. m.name = &s
  11877. }
  11878. // Name returns the value of the "name" field in the mutation.
  11879. func (m *ServerMutation) Name() (r string, exists bool) {
  11880. v := m.name
  11881. if v == nil {
  11882. return
  11883. }
  11884. return *v, true
  11885. }
  11886. // OldName returns the old "name" field's value of the Server entity.
  11887. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11889. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  11890. if !m.op.Is(OpUpdateOne) {
  11891. return v, errors.New("OldName is only allowed on UpdateOne operations")
  11892. }
  11893. if m.id == nil || m.oldValue == nil {
  11894. return v, errors.New("OldName requires an ID field in the mutation")
  11895. }
  11896. oldValue, err := m.oldValue(ctx)
  11897. if err != nil {
  11898. return v, fmt.Errorf("querying old value for OldName: %w", err)
  11899. }
  11900. return oldValue.Name, nil
  11901. }
  11902. // ResetName resets all changes to the "name" field.
  11903. func (m *ServerMutation) ResetName() {
  11904. m.name = nil
  11905. }
  11906. // SetPublicIP sets the "public_ip" field.
  11907. func (m *ServerMutation) SetPublicIP(s string) {
  11908. m.public_ip = &s
  11909. }
  11910. // PublicIP returns the value of the "public_ip" field in the mutation.
  11911. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  11912. v := m.public_ip
  11913. if v == nil {
  11914. return
  11915. }
  11916. return *v, true
  11917. }
  11918. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  11919. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11921. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  11922. if !m.op.Is(OpUpdateOne) {
  11923. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  11924. }
  11925. if m.id == nil || m.oldValue == nil {
  11926. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  11927. }
  11928. oldValue, err := m.oldValue(ctx)
  11929. if err != nil {
  11930. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  11931. }
  11932. return oldValue.PublicIP, nil
  11933. }
  11934. // ResetPublicIP resets all changes to the "public_ip" field.
  11935. func (m *ServerMutation) ResetPublicIP() {
  11936. m.public_ip = nil
  11937. }
  11938. // SetPrivateIP sets the "private_ip" field.
  11939. func (m *ServerMutation) SetPrivateIP(s string) {
  11940. m.private_ip = &s
  11941. }
  11942. // PrivateIP returns the value of the "private_ip" field in the mutation.
  11943. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  11944. v := m.private_ip
  11945. if v == nil {
  11946. return
  11947. }
  11948. return *v, true
  11949. }
  11950. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  11951. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11953. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  11954. if !m.op.Is(OpUpdateOne) {
  11955. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  11956. }
  11957. if m.id == nil || m.oldValue == nil {
  11958. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  11959. }
  11960. oldValue, err := m.oldValue(ctx)
  11961. if err != nil {
  11962. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  11963. }
  11964. return oldValue.PrivateIP, nil
  11965. }
  11966. // ResetPrivateIP resets all changes to the "private_ip" field.
  11967. func (m *ServerMutation) ResetPrivateIP() {
  11968. m.private_ip = nil
  11969. }
  11970. // SetAdminPort sets the "admin_port" field.
  11971. func (m *ServerMutation) SetAdminPort(s string) {
  11972. m.admin_port = &s
  11973. }
  11974. // AdminPort returns the value of the "admin_port" field in the mutation.
  11975. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  11976. v := m.admin_port
  11977. if v == nil {
  11978. return
  11979. }
  11980. return *v, true
  11981. }
  11982. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  11983. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11984. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11985. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  11986. if !m.op.Is(OpUpdateOne) {
  11987. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  11988. }
  11989. if m.id == nil || m.oldValue == nil {
  11990. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  11991. }
  11992. oldValue, err := m.oldValue(ctx)
  11993. if err != nil {
  11994. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  11995. }
  11996. return oldValue.AdminPort, nil
  11997. }
  11998. // ResetAdminPort resets all changes to the "admin_port" field.
  11999. func (m *ServerMutation) ResetAdminPort() {
  12000. m.admin_port = nil
  12001. }
  12002. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  12003. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  12004. if m.wxs == nil {
  12005. m.wxs = make(map[uint64]struct{})
  12006. }
  12007. for i := range ids {
  12008. m.wxs[ids[i]] = struct{}{}
  12009. }
  12010. }
  12011. // ClearWxs clears the "wxs" edge to the Wx entity.
  12012. func (m *ServerMutation) ClearWxs() {
  12013. m.clearedwxs = true
  12014. }
  12015. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  12016. func (m *ServerMutation) WxsCleared() bool {
  12017. return m.clearedwxs
  12018. }
  12019. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  12020. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  12021. if m.removedwxs == nil {
  12022. m.removedwxs = make(map[uint64]struct{})
  12023. }
  12024. for i := range ids {
  12025. delete(m.wxs, ids[i])
  12026. m.removedwxs[ids[i]] = struct{}{}
  12027. }
  12028. }
  12029. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  12030. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  12031. for id := range m.removedwxs {
  12032. ids = append(ids, id)
  12033. }
  12034. return
  12035. }
  12036. // WxsIDs returns the "wxs" edge IDs in the mutation.
  12037. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  12038. for id := range m.wxs {
  12039. ids = append(ids, id)
  12040. }
  12041. return
  12042. }
  12043. // ResetWxs resets all changes to the "wxs" edge.
  12044. func (m *ServerMutation) ResetWxs() {
  12045. m.wxs = nil
  12046. m.clearedwxs = false
  12047. m.removedwxs = nil
  12048. }
  12049. // Where appends a list predicates to the ServerMutation builder.
  12050. func (m *ServerMutation) Where(ps ...predicate.Server) {
  12051. m.predicates = append(m.predicates, ps...)
  12052. }
  12053. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  12054. // users can use type-assertion to append predicates that do not depend on any generated package.
  12055. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  12056. p := make([]predicate.Server, len(ps))
  12057. for i := range ps {
  12058. p[i] = ps[i]
  12059. }
  12060. m.Where(p...)
  12061. }
  12062. // Op returns the operation name.
  12063. func (m *ServerMutation) Op() Op {
  12064. return m.op
  12065. }
  12066. // SetOp allows setting the mutation operation.
  12067. func (m *ServerMutation) SetOp(op Op) {
  12068. m.op = op
  12069. }
  12070. // Type returns the node type of this mutation (Server).
  12071. func (m *ServerMutation) Type() string {
  12072. return m.typ
  12073. }
  12074. // Fields returns all fields that were changed during this mutation. Note that in
  12075. // order to get all numeric fields that were incremented/decremented, call
  12076. // AddedFields().
  12077. func (m *ServerMutation) Fields() []string {
  12078. fields := make([]string, 0, 8)
  12079. if m.created_at != nil {
  12080. fields = append(fields, server.FieldCreatedAt)
  12081. }
  12082. if m.updated_at != nil {
  12083. fields = append(fields, server.FieldUpdatedAt)
  12084. }
  12085. if m.status != nil {
  12086. fields = append(fields, server.FieldStatus)
  12087. }
  12088. if m.deleted_at != nil {
  12089. fields = append(fields, server.FieldDeletedAt)
  12090. }
  12091. if m.name != nil {
  12092. fields = append(fields, server.FieldName)
  12093. }
  12094. if m.public_ip != nil {
  12095. fields = append(fields, server.FieldPublicIP)
  12096. }
  12097. if m.private_ip != nil {
  12098. fields = append(fields, server.FieldPrivateIP)
  12099. }
  12100. if m.admin_port != nil {
  12101. fields = append(fields, server.FieldAdminPort)
  12102. }
  12103. return fields
  12104. }
  12105. // Field returns the value of a field with the given name. The second boolean
  12106. // return value indicates that this field was not set, or was not defined in the
  12107. // schema.
  12108. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  12109. switch name {
  12110. case server.FieldCreatedAt:
  12111. return m.CreatedAt()
  12112. case server.FieldUpdatedAt:
  12113. return m.UpdatedAt()
  12114. case server.FieldStatus:
  12115. return m.Status()
  12116. case server.FieldDeletedAt:
  12117. return m.DeletedAt()
  12118. case server.FieldName:
  12119. return m.Name()
  12120. case server.FieldPublicIP:
  12121. return m.PublicIP()
  12122. case server.FieldPrivateIP:
  12123. return m.PrivateIP()
  12124. case server.FieldAdminPort:
  12125. return m.AdminPort()
  12126. }
  12127. return nil, false
  12128. }
  12129. // OldField returns the old value of the field from the database. An error is
  12130. // returned if the mutation operation is not UpdateOne, or the query to the
  12131. // database failed.
  12132. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12133. switch name {
  12134. case server.FieldCreatedAt:
  12135. return m.OldCreatedAt(ctx)
  12136. case server.FieldUpdatedAt:
  12137. return m.OldUpdatedAt(ctx)
  12138. case server.FieldStatus:
  12139. return m.OldStatus(ctx)
  12140. case server.FieldDeletedAt:
  12141. return m.OldDeletedAt(ctx)
  12142. case server.FieldName:
  12143. return m.OldName(ctx)
  12144. case server.FieldPublicIP:
  12145. return m.OldPublicIP(ctx)
  12146. case server.FieldPrivateIP:
  12147. return m.OldPrivateIP(ctx)
  12148. case server.FieldAdminPort:
  12149. return m.OldAdminPort(ctx)
  12150. }
  12151. return nil, fmt.Errorf("unknown Server field %s", name)
  12152. }
  12153. // SetField sets the value of a field with the given name. It returns an error if
  12154. // the field is not defined in the schema, or if the type mismatched the field
  12155. // type.
  12156. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  12157. switch name {
  12158. case server.FieldCreatedAt:
  12159. v, ok := value.(time.Time)
  12160. if !ok {
  12161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12162. }
  12163. m.SetCreatedAt(v)
  12164. return nil
  12165. case server.FieldUpdatedAt:
  12166. v, ok := value.(time.Time)
  12167. if !ok {
  12168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12169. }
  12170. m.SetUpdatedAt(v)
  12171. return nil
  12172. case server.FieldStatus:
  12173. v, ok := value.(uint8)
  12174. if !ok {
  12175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12176. }
  12177. m.SetStatus(v)
  12178. return nil
  12179. case server.FieldDeletedAt:
  12180. v, ok := value.(time.Time)
  12181. if !ok {
  12182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12183. }
  12184. m.SetDeletedAt(v)
  12185. return nil
  12186. case server.FieldName:
  12187. v, ok := value.(string)
  12188. if !ok {
  12189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12190. }
  12191. m.SetName(v)
  12192. return nil
  12193. case server.FieldPublicIP:
  12194. v, ok := value.(string)
  12195. if !ok {
  12196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12197. }
  12198. m.SetPublicIP(v)
  12199. return nil
  12200. case server.FieldPrivateIP:
  12201. v, ok := value.(string)
  12202. if !ok {
  12203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12204. }
  12205. m.SetPrivateIP(v)
  12206. return nil
  12207. case server.FieldAdminPort:
  12208. v, ok := value.(string)
  12209. if !ok {
  12210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12211. }
  12212. m.SetAdminPort(v)
  12213. return nil
  12214. }
  12215. return fmt.Errorf("unknown Server field %s", name)
  12216. }
  12217. // AddedFields returns all numeric fields that were incremented/decremented during
  12218. // this mutation.
  12219. func (m *ServerMutation) AddedFields() []string {
  12220. var fields []string
  12221. if m.addstatus != nil {
  12222. fields = append(fields, server.FieldStatus)
  12223. }
  12224. return fields
  12225. }
  12226. // AddedField returns the numeric value that was incremented/decremented on a field
  12227. // with the given name. The second boolean return value indicates that this field
  12228. // was not set, or was not defined in the schema.
  12229. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  12230. switch name {
  12231. case server.FieldStatus:
  12232. return m.AddedStatus()
  12233. }
  12234. return nil, false
  12235. }
  12236. // AddField adds the value to the field with the given name. It returns an error if
  12237. // the field is not defined in the schema, or if the type mismatched the field
  12238. // type.
  12239. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  12240. switch name {
  12241. case server.FieldStatus:
  12242. v, ok := value.(int8)
  12243. if !ok {
  12244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12245. }
  12246. m.AddStatus(v)
  12247. return nil
  12248. }
  12249. return fmt.Errorf("unknown Server numeric field %s", name)
  12250. }
  12251. // ClearedFields returns all nullable fields that were cleared during this
  12252. // mutation.
  12253. func (m *ServerMutation) ClearedFields() []string {
  12254. var fields []string
  12255. if m.FieldCleared(server.FieldStatus) {
  12256. fields = append(fields, server.FieldStatus)
  12257. }
  12258. if m.FieldCleared(server.FieldDeletedAt) {
  12259. fields = append(fields, server.FieldDeletedAt)
  12260. }
  12261. return fields
  12262. }
  12263. // FieldCleared returns a boolean indicating if a field with the given name was
  12264. // cleared in this mutation.
  12265. func (m *ServerMutation) FieldCleared(name string) bool {
  12266. _, ok := m.clearedFields[name]
  12267. return ok
  12268. }
  12269. // ClearField clears the value of the field with the given name. It returns an
  12270. // error if the field is not defined in the schema.
  12271. func (m *ServerMutation) ClearField(name string) error {
  12272. switch name {
  12273. case server.FieldStatus:
  12274. m.ClearStatus()
  12275. return nil
  12276. case server.FieldDeletedAt:
  12277. m.ClearDeletedAt()
  12278. return nil
  12279. }
  12280. return fmt.Errorf("unknown Server nullable field %s", name)
  12281. }
  12282. // ResetField resets all changes in the mutation for the field with the given name.
  12283. // It returns an error if the field is not defined in the schema.
  12284. func (m *ServerMutation) ResetField(name string) error {
  12285. switch name {
  12286. case server.FieldCreatedAt:
  12287. m.ResetCreatedAt()
  12288. return nil
  12289. case server.FieldUpdatedAt:
  12290. m.ResetUpdatedAt()
  12291. return nil
  12292. case server.FieldStatus:
  12293. m.ResetStatus()
  12294. return nil
  12295. case server.FieldDeletedAt:
  12296. m.ResetDeletedAt()
  12297. return nil
  12298. case server.FieldName:
  12299. m.ResetName()
  12300. return nil
  12301. case server.FieldPublicIP:
  12302. m.ResetPublicIP()
  12303. return nil
  12304. case server.FieldPrivateIP:
  12305. m.ResetPrivateIP()
  12306. return nil
  12307. case server.FieldAdminPort:
  12308. m.ResetAdminPort()
  12309. return nil
  12310. }
  12311. return fmt.Errorf("unknown Server field %s", name)
  12312. }
  12313. // AddedEdges returns all edge names that were set/added in this mutation.
  12314. func (m *ServerMutation) AddedEdges() []string {
  12315. edges := make([]string, 0, 1)
  12316. if m.wxs != nil {
  12317. edges = append(edges, server.EdgeWxs)
  12318. }
  12319. return edges
  12320. }
  12321. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12322. // name in this mutation.
  12323. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  12324. switch name {
  12325. case server.EdgeWxs:
  12326. ids := make([]ent.Value, 0, len(m.wxs))
  12327. for id := range m.wxs {
  12328. ids = append(ids, id)
  12329. }
  12330. return ids
  12331. }
  12332. return nil
  12333. }
  12334. // RemovedEdges returns all edge names that were removed in this mutation.
  12335. func (m *ServerMutation) RemovedEdges() []string {
  12336. edges := make([]string, 0, 1)
  12337. if m.removedwxs != nil {
  12338. edges = append(edges, server.EdgeWxs)
  12339. }
  12340. return edges
  12341. }
  12342. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12343. // the given name in this mutation.
  12344. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  12345. switch name {
  12346. case server.EdgeWxs:
  12347. ids := make([]ent.Value, 0, len(m.removedwxs))
  12348. for id := range m.removedwxs {
  12349. ids = append(ids, id)
  12350. }
  12351. return ids
  12352. }
  12353. return nil
  12354. }
  12355. // ClearedEdges returns all edge names that were cleared in this mutation.
  12356. func (m *ServerMutation) ClearedEdges() []string {
  12357. edges := make([]string, 0, 1)
  12358. if m.clearedwxs {
  12359. edges = append(edges, server.EdgeWxs)
  12360. }
  12361. return edges
  12362. }
  12363. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12364. // was cleared in this mutation.
  12365. func (m *ServerMutation) EdgeCleared(name string) bool {
  12366. switch name {
  12367. case server.EdgeWxs:
  12368. return m.clearedwxs
  12369. }
  12370. return false
  12371. }
  12372. // ClearEdge clears the value of the edge with the given name. It returns an error
  12373. // if that edge is not defined in the schema.
  12374. func (m *ServerMutation) ClearEdge(name string) error {
  12375. switch name {
  12376. }
  12377. return fmt.Errorf("unknown Server unique edge %s", name)
  12378. }
  12379. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12380. // It returns an error if the edge is not defined in the schema.
  12381. func (m *ServerMutation) ResetEdge(name string) error {
  12382. switch name {
  12383. case server.EdgeWxs:
  12384. m.ResetWxs()
  12385. return nil
  12386. }
  12387. return fmt.Errorf("unknown Server edge %s", name)
  12388. }
  12389. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  12390. type SopNodeMutation struct {
  12391. config
  12392. op Op
  12393. typ string
  12394. id *uint64
  12395. created_at *time.Time
  12396. updated_at *time.Time
  12397. status *uint8
  12398. addstatus *int8
  12399. deleted_at *time.Time
  12400. parent_id *uint64
  12401. addparent_id *int64
  12402. name *string
  12403. condition_type *int
  12404. addcondition_type *int
  12405. condition_list *[]string
  12406. appendcondition_list []string
  12407. no_reply_condition *uint64
  12408. addno_reply_condition *int64
  12409. action_message *[]custom_types.Action
  12410. appendaction_message []custom_types.Action
  12411. action_label *[]uint64
  12412. appendaction_label []uint64
  12413. clearedFields map[string]struct{}
  12414. sop_stage *uint64
  12415. clearedsop_stage bool
  12416. node_messages map[uint64]struct{}
  12417. removednode_messages map[uint64]struct{}
  12418. clearednode_messages bool
  12419. done bool
  12420. oldValue func(context.Context) (*SopNode, error)
  12421. predicates []predicate.SopNode
  12422. }
  12423. var _ ent.Mutation = (*SopNodeMutation)(nil)
  12424. // sopnodeOption allows management of the mutation configuration using functional options.
  12425. type sopnodeOption func(*SopNodeMutation)
  12426. // newSopNodeMutation creates new mutation for the SopNode entity.
  12427. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  12428. m := &SopNodeMutation{
  12429. config: c,
  12430. op: op,
  12431. typ: TypeSopNode,
  12432. clearedFields: make(map[string]struct{}),
  12433. }
  12434. for _, opt := range opts {
  12435. opt(m)
  12436. }
  12437. return m
  12438. }
  12439. // withSopNodeID sets the ID field of the mutation.
  12440. func withSopNodeID(id uint64) sopnodeOption {
  12441. return func(m *SopNodeMutation) {
  12442. var (
  12443. err error
  12444. once sync.Once
  12445. value *SopNode
  12446. )
  12447. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  12448. once.Do(func() {
  12449. if m.done {
  12450. err = errors.New("querying old values post mutation is not allowed")
  12451. } else {
  12452. value, err = m.Client().SopNode.Get(ctx, id)
  12453. }
  12454. })
  12455. return value, err
  12456. }
  12457. m.id = &id
  12458. }
  12459. }
  12460. // withSopNode sets the old SopNode of the mutation.
  12461. func withSopNode(node *SopNode) sopnodeOption {
  12462. return func(m *SopNodeMutation) {
  12463. m.oldValue = func(context.Context) (*SopNode, error) {
  12464. return node, nil
  12465. }
  12466. m.id = &node.ID
  12467. }
  12468. }
  12469. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12470. // executed in a transaction (ent.Tx), a transactional client is returned.
  12471. func (m SopNodeMutation) Client() *Client {
  12472. client := &Client{config: m.config}
  12473. client.init()
  12474. return client
  12475. }
  12476. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12477. // it returns an error otherwise.
  12478. func (m SopNodeMutation) Tx() (*Tx, error) {
  12479. if _, ok := m.driver.(*txDriver); !ok {
  12480. return nil, errors.New("ent: mutation is not running in a transaction")
  12481. }
  12482. tx := &Tx{config: m.config}
  12483. tx.init()
  12484. return tx, nil
  12485. }
  12486. // SetID sets the value of the id field. Note that this
  12487. // operation is only accepted on creation of SopNode entities.
  12488. func (m *SopNodeMutation) SetID(id uint64) {
  12489. m.id = &id
  12490. }
  12491. // ID returns the ID value in the mutation. Note that the ID is only available
  12492. // if it was provided to the builder or after it was returned from the database.
  12493. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  12494. if m.id == nil {
  12495. return
  12496. }
  12497. return *m.id, true
  12498. }
  12499. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12500. // That means, if the mutation is applied within a transaction with an isolation level such
  12501. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12502. // or updated by the mutation.
  12503. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  12504. switch {
  12505. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12506. id, exists := m.ID()
  12507. if exists {
  12508. return []uint64{id}, nil
  12509. }
  12510. fallthrough
  12511. case m.op.Is(OpUpdate | OpDelete):
  12512. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  12513. default:
  12514. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12515. }
  12516. }
  12517. // SetCreatedAt sets the "created_at" field.
  12518. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  12519. m.created_at = &t
  12520. }
  12521. // CreatedAt returns the value of the "created_at" field in the mutation.
  12522. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  12523. v := m.created_at
  12524. if v == nil {
  12525. return
  12526. }
  12527. return *v, true
  12528. }
  12529. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  12530. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12532. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12533. if !m.op.Is(OpUpdateOne) {
  12534. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12535. }
  12536. if m.id == nil || m.oldValue == nil {
  12537. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12538. }
  12539. oldValue, err := m.oldValue(ctx)
  12540. if err != nil {
  12541. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12542. }
  12543. return oldValue.CreatedAt, nil
  12544. }
  12545. // ResetCreatedAt resets all changes to the "created_at" field.
  12546. func (m *SopNodeMutation) ResetCreatedAt() {
  12547. m.created_at = nil
  12548. }
  12549. // SetUpdatedAt sets the "updated_at" field.
  12550. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  12551. m.updated_at = &t
  12552. }
  12553. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12554. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  12555. v := m.updated_at
  12556. if v == nil {
  12557. return
  12558. }
  12559. return *v, true
  12560. }
  12561. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  12562. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12564. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12565. if !m.op.Is(OpUpdateOne) {
  12566. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12567. }
  12568. if m.id == nil || m.oldValue == nil {
  12569. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12570. }
  12571. oldValue, err := m.oldValue(ctx)
  12572. if err != nil {
  12573. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12574. }
  12575. return oldValue.UpdatedAt, nil
  12576. }
  12577. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12578. func (m *SopNodeMutation) ResetUpdatedAt() {
  12579. m.updated_at = nil
  12580. }
  12581. // SetStatus sets the "status" field.
  12582. func (m *SopNodeMutation) SetStatus(u uint8) {
  12583. m.status = &u
  12584. m.addstatus = nil
  12585. }
  12586. // Status returns the value of the "status" field in the mutation.
  12587. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  12588. v := m.status
  12589. if v == nil {
  12590. return
  12591. }
  12592. return *v, true
  12593. }
  12594. // OldStatus returns the old "status" field's value of the SopNode entity.
  12595. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12597. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12598. if !m.op.Is(OpUpdateOne) {
  12599. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12600. }
  12601. if m.id == nil || m.oldValue == nil {
  12602. return v, errors.New("OldStatus requires an ID field in the mutation")
  12603. }
  12604. oldValue, err := m.oldValue(ctx)
  12605. if err != nil {
  12606. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12607. }
  12608. return oldValue.Status, nil
  12609. }
  12610. // AddStatus adds u to the "status" field.
  12611. func (m *SopNodeMutation) AddStatus(u int8) {
  12612. if m.addstatus != nil {
  12613. *m.addstatus += u
  12614. } else {
  12615. m.addstatus = &u
  12616. }
  12617. }
  12618. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12619. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  12620. v := m.addstatus
  12621. if v == nil {
  12622. return
  12623. }
  12624. return *v, true
  12625. }
  12626. // ClearStatus clears the value of the "status" field.
  12627. func (m *SopNodeMutation) ClearStatus() {
  12628. m.status = nil
  12629. m.addstatus = nil
  12630. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  12631. }
  12632. // StatusCleared returns if the "status" field was cleared in this mutation.
  12633. func (m *SopNodeMutation) StatusCleared() bool {
  12634. _, ok := m.clearedFields[sopnode.FieldStatus]
  12635. return ok
  12636. }
  12637. // ResetStatus resets all changes to the "status" field.
  12638. func (m *SopNodeMutation) ResetStatus() {
  12639. m.status = nil
  12640. m.addstatus = nil
  12641. delete(m.clearedFields, sopnode.FieldStatus)
  12642. }
  12643. // SetDeletedAt sets the "deleted_at" field.
  12644. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  12645. m.deleted_at = &t
  12646. }
  12647. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12648. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  12649. v := m.deleted_at
  12650. if v == nil {
  12651. return
  12652. }
  12653. return *v, true
  12654. }
  12655. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  12656. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12658. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12659. if !m.op.Is(OpUpdateOne) {
  12660. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12661. }
  12662. if m.id == nil || m.oldValue == nil {
  12663. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12664. }
  12665. oldValue, err := m.oldValue(ctx)
  12666. if err != nil {
  12667. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12668. }
  12669. return oldValue.DeletedAt, nil
  12670. }
  12671. // ClearDeletedAt clears the value of the "deleted_at" field.
  12672. func (m *SopNodeMutation) ClearDeletedAt() {
  12673. m.deleted_at = nil
  12674. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  12675. }
  12676. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12677. func (m *SopNodeMutation) DeletedAtCleared() bool {
  12678. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  12679. return ok
  12680. }
  12681. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12682. func (m *SopNodeMutation) ResetDeletedAt() {
  12683. m.deleted_at = nil
  12684. delete(m.clearedFields, sopnode.FieldDeletedAt)
  12685. }
  12686. // SetStageID sets the "stage_id" field.
  12687. func (m *SopNodeMutation) SetStageID(u uint64) {
  12688. m.sop_stage = &u
  12689. }
  12690. // StageID returns the value of the "stage_id" field in the mutation.
  12691. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  12692. v := m.sop_stage
  12693. if v == nil {
  12694. return
  12695. }
  12696. return *v, true
  12697. }
  12698. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  12699. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12701. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  12702. if !m.op.Is(OpUpdateOne) {
  12703. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  12704. }
  12705. if m.id == nil || m.oldValue == nil {
  12706. return v, errors.New("OldStageID requires an ID field in the mutation")
  12707. }
  12708. oldValue, err := m.oldValue(ctx)
  12709. if err != nil {
  12710. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  12711. }
  12712. return oldValue.StageID, nil
  12713. }
  12714. // ResetStageID resets all changes to the "stage_id" field.
  12715. func (m *SopNodeMutation) ResetStageID() {
  12716. m.sop_stage = nil
  12717. }
  12718. // SetParentID sets the "parent_id" field.
  12719. func (m *SopNodeMutation) SetParentID(u uint64) {
  12720. m.parent_id = &u
  12721. m.addparent_id = nil
  12722. }
  12723. // ParentID returns the value of the "parent_id" field in the mutation.
  12724. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  12725. v := m.parent_id
  12726. if v == nil {
  12727. return
  12728. }
  12729. return *v, true
  12730. }
  12731. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  12732. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12734. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  12735. if !m.op.Is(OpUpdateOne) {
  12736. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  12737. }
  12738. if m.id == nil || m.oldValue == nil {
  12739. return v, errors.New("OldParentID requires an ID field in the mutation")
  12740. }
  12741. oldValue, err := m.oldValue(ctx)
  12742. if err != nil {
  12743. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  12744. }
  12745. return oldValue.ParentID, nil
  12746. }
  12747. // AddParentID adds u to the "parent_id" field.
  12748. func (m *SopNodeMutation) AddParentID(u int64) {
  12749. if m.addparent_id != nil {
  12750. *m.addparent_id += u
  12751. } else {
  12752. m.addparent_id = &u
  12753. }
  12754. }
  12755. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  12756. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  12757. v := m.addparent_id
  12758. if v == nil {
  12759. return
  12760. }
  12761. return *v, true
  12762. }
  12763. // ResetParentID resets all changes to the "parent_id" field.
  12764. func (m *SopNodeMutation) ResetParentID() {
  12765. m.parent_id = nil
  12766. m.addparent_id = nil
  12767. }
  12768. // SetName sets the "name" field.
  12769. func (m *SopNodeMutation) SetName(s string) {
  12770. m.name = &s
  12771. }
  12772. // Name returns the value of the "name" field in the mutation.
  12773. func (m *SopNodeMutation) Name() (r string, exists bool) {
  12774. v := m.name
  12775. if v == nil {
  12776. return
  12777. }
  12778. return *v, true
  12779. }
  12780. // OldName returns the old "name" field's value of the SopNode entity.
  12781. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12783. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  12784. if !m.op.Is(OpUpdateOne) {
  12785. return v, errors.New("OldName is only allowed on UpdateOne operations")
  12786. }
  12787. if m.id == nil || m.oldValue == nil {
  12788. return v, errors.New("OldName requires an ID field in the mutation")
  12789. }
  12790. oldValue, err := m.oldValue(ctx)
  12791. if err != nil {
  12792. return v, fmt.Errorf("querying old value for OldName: %w", err)
  12793. }
  12794. return oldValue.Name, nil
  12795. }
  12796. // ResetName resets all changes to the "name" field.
  12797. func (m *SopNodeMutation) ResetName() {
  12798. m.name = nil
  12799. }
  12800. // SetConditionType sets the "condition_type" field.
  12801. func (m *SopNodeMutation) SetConditionType(i int) {
  12802. m.condition_type = &i
  12803. m.addcondition_type = nil
  12804. }
  12805. // ConditionType returns the value of the "condition_type" field in the mutation.
  12806. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  12807. v := m.condition_type
  12808. if v == nil {
  12809. return
  12810. }
  12811. return *v, true
  12812. }
  12813. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  12814. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12815. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12816. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  12817. if !m.op.Is(OpUpdateOne) {
  12818. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  12819. }
  12820. if m.id == nil || m.oldValue == nil {
  12821. return v, errors.New("OldConditionType requires an ID field in the mutation")
  12822. }
  12823. oldValue, err := m.oldValue(ctx)
  12824. if err != nil {
  12825. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  12826. }
  12827. return oldValue.ConditionType, nil
  12828. }
  12829. // AddConditionType adds i to the "condition_type" field.
  12830. func (m *SopNodeMutation) AddConditionType(i int) {
  12831. if m.addcondition_type != nil {
  12832. *m.addcondition_type += i
  12833. } else {
  12834. m.addcondition_type = &i
  12835. }
  12836. }
  12837. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  12838. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  12839. v := m.addcondition_type
  12840. if v == nil {
  12841. return
  12842. }
  12843. return *v, true
  12844. }
  12845. // ResetConditionType resets all changes to the "condition_type" field.
  12846. func (m *SopNodeMutation) ResetConditionType() {
  12847. m.condition_type = nil
  12848. m.addcondition_type = nil
  12849. }
  12850. // SetConditionList sets the "condition_list" field.
  12851. func (m *SopNodeMutation) SetConditionList(s []string) {
  12852. m.condition_list = &s
  12853. m.appendcondition_list = nil
  12854. }
  12855. // ConditionList returns the value of the "condition_list" field in the mutation.
  12856. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  12857. v := m.condition_list
  12858. if v == nil {
  12859. return
  12860. }
  12861. return *v, true
  12862. }
  12863. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  12864. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12865. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12866. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  12867. if !m.op.Is(OpUpdateOne) {
  12868. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  12869. }
  12870. if m.id == nil || m.oldValue == nil {
  12871. return v, errors.New("OldConditionList requires an ID field in the mutation")
  12872. }
  12873. oldValue, err := m.oldValue(ctx)
  12874. if err != nil {
  12875. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  12876. }
  12877. return oldValue.ConditionList, nil
  12878. }
  12879. // AppendConditionList adds s to the "condition_list" field.
  12880. func (m *SopNodeMutation) AppendConditionList(s []string) {
  12881. m.appendcondition_list = append(m.appendcondition_list, s...)
  12882. }
  12883. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  12884. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  12885. if len(m.appendcondition_list) == 0 {
  12886. return nil, false
  12887. }
  12888. return m.appendcondition_list, true
  12889. }
  12890. // ClearConditionList clears the value of the "condition_list" field.
  12891. func (m *SopNodeMutation) ClearConditionList() {
  12892. m.condition_list = nil
  12893. m.appendcondition_list = nil
  12894. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  12895. }
  12896. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  12897. func (m *SopNodeMutation) ConditionListCleared() bool {
  12898. _, ok := m.clearedFields[sopnode.FieldConditionList]
  12899. return ok
  12900. }
  12901. // ResetConditionList resets all changes to the "condition_list" field.
  12902. func (m *SopNodeMutation) ResetConditionList() {
  12903. m.condition_list = nil
  12904. m.appendcondition_list = nil
  12905. delete(m.clearedFields, sopnode.FieldConditionList)
  12906. }
  12907. // SetNoReplyCondition sets the "no_reply_condition" field.
  12908. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  12909. m.no_reply_condition = &u
  12910. m.addno_reply_condition = nil
  12911. }
  12912. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  12913. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  12914. v := m.no_reply_condition
  12915. if v == nil {
  12916. return
  12917. }
  12918. return *v, true
  12919. }
  12920. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  12921. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12923. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  12924. if !m.op.Is(OpUpdateOne) {
  12925. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  12926. }
  12927. if m.id == nil || m.oldValue == nil {
  12928. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  12929. }
  12930. oldValue, err := m.oldValue(ctx)
  12931. if err != nil {
  12932. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  12933. }
  12934. return oldValue.NoReplyCondition, nil
  12935. }
  12936. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  12937. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  12938. if m.addno_reply_condition != nil {
  12939. *m.addno_reply_condition += u
  12940. } else {
  12941. m.addno_reply_condition = &u
  12942. }
  12943. }
  12944. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  12945. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  12946. v := m.addno_reply_condition
  12947. if v == nil {
  12948. return
  12949. }
  12950. return *v, true
  12951. }
  12952. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  12953. func (m *SopNodeMutation) ResetNoReplyCondition() {
  12954. m.no_reply_condition = nil
  12955. m.addno_reply_condition = nil
  12956. }
  12957. // SetActionMessage sets the "action_message" field.
  12958. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  12959. m.action_message = &ct
  12960. m.appendaction_message = nil
  12961. }
  12962. // ActionMessage returns the value of the "action_message" field in the mutation.
  12963. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  12964. v := m.action_message
  12965. if v == nil {
  12966. return
  12967. }
  12968. return *v, true
  12969. }
  12970. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  12971. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12973. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  12974. if !m.op.Is(OpUpdateOne) {
  12975. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  12976. }
  12977. if m.id == nil || m.oldValue == nil {
  12978. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  12979. }
  12980. oldValue, err := m.oldValue(ctx)
  12981. if err != nil {
  12982. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  12983. }
  12984. return oldValue.ActionMessage, nil
  12985. }
  12986. // AppendActionMessage adds ct to the "action_message" field.
  12987. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  12988. m.appendaction_message = append(m.appendaction_message, ct...)
  12989. }
  12990. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  12991. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  12992. if len(m.appendaction_message) == 0 {
  12993. return nil, false
  12994. }
  12995. return m.appendaction_message, true
  12996. }
  12997. // ClearActionMessage clears the value of the "action_message" field.
  12998. func (m *SopNodeMutation) ClearActionMessage() {
  12999. m.action_message = nil
  13000. m.appendaction_message = nil
  13001. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  13002. }
  13003. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  13004. func (m *SopNodeMutation) ActionMessageCleared() bool {
  13005. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  13006. return ok
  13007. }
  13008. // ResetActionMessage resets all changes to the "action_message" field.
  13009. func (m *SopNodeMutation) ResetActionMessage() {
  13010. m.action_message = nil
  13011. m.appendaction_message = nil
  13012. delete(m.clearedFields, sopnode.FieldActionMessage)
  13013. }
  13014. // SetActionLabel sets the "action_label" field.
  13015. func (m *SopNodeMutation) SetActionLabel(u []uint64) {
  13016. m.action_label = &u
  13017. m.appendaction_label = nil
  13018. }
  13019. // ActionLabel returns the value of the "action_label" field in the mutation.
  13020. func (m *SopNodeMutation) ActionLabel() (r []uint64, exists bool) {
  13021. v := m.action_label
  13022. if v == nil {
  13023. return
  13024. }
  13025. return *v, true
  13026. }
  13027. // OldActionLabel returns the old "action_label" field's value of the SopNode entity.
  13028. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  13029. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13030. func (m *SopNodeMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  13031. if !m.op.Is(OpUpdateOne) {
  13032. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  13033. }
  13034. if m.id == nil || m.oldValue == nil {
  13035. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  13036. }
  13037. oldValue, err := m.oldValue(ctx)
  13038. if err != nil {
  13039. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  13040. }
  13041. return oldValue.ActionLabel, nil
  13042. }
  13043. // AppendActionLabel adds u to the "action_label" field.
  13044. func (m *SopNodeMutation) AppendActionLabel(u []uint64) {
  13045. m.appendaction_label = append(m.appendaction_label, u...)
  13046. }
  13047. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  13048. func (m *SopNodeMutation) AppendedActionLabel() ([]uint64, bool) {
  13049. if len(m.appendaction_label) == 0 {
  13050. return nil, false
  13051. }
  13052. return m.appendaction_label, true
  13053. }
  13054. // ClearActionLabel clears the value of the "action_label" field.
  13055. func (m *SopNodeMutation) ClearActionLabel() {
  13056. m.action_label = nil
  13057. m.appendaction_label = nil
  13058. m.clearedFields[sopnode.FieldActionLabel] = struct{}{}
  13059. }
  13060. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  13061. func (m *SopNodeMutation) ActionLabelCleared() bool {
  13062. _, ok := m.clearedFields[sopnode.FieldActionLabel]
  13063. return ok
  13064. }
  13065. // ResetActionLabel resets all changes to the "action_label" field.
  13066. func (m *SopNodeMutation) ResetActionLabel() {
  13067. m.action_label = nil
  13068. m.appendaction_label = nil
  13069. delete(m.clearedFields, sopnode.FieldActionLabel)
  13070. }
  13071. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  13072. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  13073. m.sop_stage = &id
  13074. }
  13075. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  13076. func (m *SopNodeMutation) ClearSopStage() {
  13077. m.clearedsop_stage = true
  13078. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  13079. }
  13080. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  13081. func (m *SopNodeMutation) SopStageCleared() bool {
  13082. return m.clearedsop_stage
  13083. }
  13084. // SopStageID returns the "sop_stage" edge ID in the mutation.
  13085. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  13086. if m.sop_stage != nil {
  13087. return *m.sop_stage, true
  13088. }
  13089. return
  13090. }
  13091. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  13092. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13093. // SopStageID instead. It exists only for internal usage by the builders.
  13094. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  13095. if id := m.sop_stage; id != nil {
  13096. ids = append(ids, *id)
  13097. }
  13098. return
  13099. }
  13100. // ResetSopStage resets all changes to the "sop_stage" edge.
  13101. func (m *SopNodeMutation) ResetSopStage() {
  13102. m.sop_stage = nil
  13103. m.clearedsop_stage = false
  13104. }
  13105. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  13106. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  13107. if m.node_messages == nil {
  13108. m.node_messages = make(map[uint64]struct{})
  13109. }
  13110. for i := range ids {
  13111. m.node_messages[ids[i]] = struct{}{}
  13112. }
  13113. }
  13114. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  13115. func (m *SopNodeMutation) ClearNodeMessages() {
  13116. m.clearednode_messages = true
  13117. }
  13118. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  13119. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  13120. return m.clearednode_messages
  13121. }
  13122. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  13123. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  13124. if m.removednode_messages == nil {
  13125. m.removednode_messages = make(map[uint64]struct{})
  13126. }
  13127. for i := range ids {
  13128. delete(m.node_messages, ids[i])
  13129. m.removednode_messages[ids[i]] = struct{}{}
  13130. }
  13131. }
  13132. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  13133. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  13134. for id := range m.removednode_messages {
  13135. ids = append(ids, id)
  13136. }
  13137. return
  13138. }
  13139. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  13140. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  13141. for id := range m.node_messages {
  13142. ids = append(ids, id)
  13143. }
  13144. return
  13145. }
  13146. // ResetNodeMessages resets all changes to the "node_messages" edge.
  13147. func (m *SopNodeMutation) ResetNodeMessages() {
  13148. m.node_messages = nil
  13149. m.clearednode_messages = false
  13150. m.removednode_messages = nil
  13151. }
  13152. // Where appends a list predicates to the SopNodeMutation builder.
  13153. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  13154. m.predicates = append(m.predicates, ps...)
  13155. }
  13156. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  13157. // users can use type-assertion to append predicates that do not depend on any generated package.
  13158. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  13159. p := make([]predicate.SopNode, len(ps))
  13160. for i := range ps {
  13161. p[i] = ps[i]
  13162. }
  13163. m.Where(p...)
  13164. }
  13165. // Op returns the operation name.
  13166. func (m *SopNodeMutation) Op() Op {
  13167. return m.op
  13168. }
  13169. // SetOp allows setting the mutation operation.
  13170. func (m *SopNodeMutation) SetOp(op Op) {
  13171. m.op = op
  13172. }
  13173. // Type returns the node type of this mutation (SopNode).
  13174. func (m *SopNodeMutation) Type() string {
  13175. return m.typ
  13176. }
  13177. // Fields returns all fields that were changed during this mutation. Note that in
  13178. // order to get all numeric fields that were incremented/decremented, call
  13179. // AddedFields().
  13180. func (m *SopNodeMutation) Fields() []string {
  13181. fields := make([]string, 0, 12)
  13182. if m.created_at != nil {
  13183. fields = append(fields, sopnode.FieldCreatedAt)
  13184. }
  13185. if m.updated_at != nil {
  13186. fields = append(fields, sopnode.FieldUpdatedAt)
  13187. }
  13188. if m.status != nil {
  13189. fields = append(fields, sopnode.FieldStatus)
  13190. }
  13191. if m.deleted_at != nil {
  13192. fields = append(fields, sopnode.FieldDeletedAt)
  13193. }
  13194. if m.sop_stage != nil {
  13195. fields = append(fields, sopnode.FieldStageID)
  13196. }
  13197. if m.parent_id != nil {
  13198. fields = append(fields, sopnode.FieldParentID)
  13199. }
  13200. if m.name != nil {
  13201. fields = append(fields, sopnode.FieldName)
  13202. }
  13203. if m.condition_type != nil {
  13204. fields = append(fields, sopnode.FieldConditionType)
  13205. }
  13206. if m.condition_list != nil {
  13207. fields = append(fields, sopnode.FieldConditionList)
  13208. }
  13209. if m.no_reply_condition != nil {
  13210. fields = append(fields, sopnode.FieldNoReplyCondition)
  13211. }
  13212. if m.action_message != nil {
  13213. fields = append(fields, sopnode.FieldActionMessage)
  13214. }
  13215. if m.action_label != nil {
  13216. fields = append(fields, sopnode.FieldActionLabel)
  13217. }
  13218. return fields
  13219. }
  13220. // Field returns the value of a field with the given name. The second boolean
  13221. // return value indicates that this field was not set, or was not defined in the
  13222. // schema.
  13223. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  13224. switch name {
  13225. case sopnode.FieldCreatedAt:
  13226. return m.CreatedAt()
  13227. case sopnode.FieldUpdatedAt:
  13228. return m.UpdatedAt()
  13229. case sopnode.FieldStatus:
  13230. return m.Status()
  13231. case sopnode.FieldDeletedAt:
  13232. return m.DeletedAt()
  13233. case sopnode.FieldStageID:
  13234. return m.StageID()
  13235. case sopnode.FieldParentID:
  13236. return m.ParentID()
  13237. case sopnode.FieldName:
  13238. return m.Name()
  13239. case sopnode.FieldConditionType:
  13240. return m.ConditionType()
  13241. case sopnode.FieldConditionList:
  13242. return m.ConditionList()
  13243. case sopnode.FieldNoReplyCondition:
  13244. return m.NoReplyCondition()
  13245. case sopnode.FieldActionMessage:
  13246. return m.ActionMessage()
  13247. case sopnode.FieldActionLabel:
  13248. return m.ActionLabel()
  13249. }
  13250. return nil, false
  13251. }
  13252. // OldField returns the old value of the field from the database. An error is
  13253. // returned if the mutation operation is not UpdateOne, or the query to the
  13254. // database failed.
  13255. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13256. switch name {
  13257. case sopnode.FieldCreatedAt:
  13258. return m.OldCreatedAt(ctx)
  13259. case sopnode.FieldUpdatedAt:
  13260. return m.OldUpdatedAt(ctx)
  13261. case sopnode.FieldStatus:
  13262. return m.OldStatus(ctx)
  13263. case sopnode.FieldDeletedAt:
  13264. return m.OldDeletedAt(ctx)
  13265. case sopnode.FieldStageID:
  13266. return m.OldStageID(ctx)
  13267. case sopnode.FieldParentID:
  13268. return m.OldParentID(ctx)
  13269. case sopnode.FieldName:
  13270. return m.OldName(ctx)
  13271. case sopnode.FieldConditionType:
  13272. return m.OldConditionType(ctx)
  13273. case sopnode.FieldConditionList:
  13274. return m.OldConditionList(ctx)
  13275. case sopnode.FieldNoReplyCondition:
  13276. return m.OldNoReplyCondition(ctx)
  13277. case sopnode.FieldActionMessage:
  13278. return m.OldActionMessage(ctx)
  13279. case sopnode.FieldActionLabel:
  13280. return m.OldActionLabel(ctx)
  13281. }
  13282. return nil, fmt.Errorf("unknown SopNode field %s", name)
  13283. }
  13284. // SetField sets the value of a field with the given name. It returns an error if
  13285. // the field is not defined in the schema, or if the type mismatched the field
  13286. // type.
  13287. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  13288. switch name {
  13289. case sopnode.FieldCreatedAt:
  13290. v, ok := value.(time.Time)
  13291. if !ok {
  13292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13293. }
  13294. m.SetCreatedAt(v)
  13295. return nil
  13296. case sopnode.FieldUpdatedAt:
  13297. v, ok := value.(time.Time)
  13298. if !ok {
  13299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13300. }
  13301. m.SetUpdatedAt(v)
  13302. return nil
  13303. case sopnode.FieldStatus:
  13304. v, ok := value.(uint8)
  13305. if !ok {
  13306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13307. }
  13308. m.SetStatus(v)
  13309. return nil
  13310. case sopnode.FieldDeletedAt:
  13311. v, ok := value.(time.Time)
  13312. if !ok {
  13313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13314. }
  13315. m.SetDeletedAt(v)
  13316. return nil
  13317. case sopnode.FieldStageID:
  13318. v, ok := value.(uint64)
  13319. if !ok {
  13320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13321. }
  13322. m.SetStageID(v)
  13323. return nil
  13324. case sopnode.FieldParentID:
  13325. v, ok := value.(uint64)
  13326. if !ok {
  13327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13328. }
  13329. m.SetParentID(v)
  13330. return nil
  13331. case sopnode.FieldName:
  13332. v, ok := value.(string)
  13333. if !ok {
  13334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13335. }
  13336. m.SetName(v)
  13337. return nil
  13338. case sopnode.FieldConditionType:
  13339. v, ok := value.(int)
  13340. if !ok {
  13341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13342. }
  13343. m.SetConditionType(v)
  13344. return nil
  13345. case sopnode.FieldConditionList:
  13346. v, ok := value.([]string)
  13347. if !ok {
  13348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13349. }
  13350. m.SetConditionList(v)
  13351. return nil
  13352. case sopnode.FieldNoReplyCondition:
  13353. v, ok := value.(uint64)
  13354. if !ok {
  13355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13356. }
  13357. m.SetNoReplyCondition(v)
  13358. return nil
  13359. case sopnode.FieldActionMessage:
  13360. v, ok := value.([]custom_types.Action)
  13361. if !ok {
  13362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13363. }
  13364. m.SetActionMessage(v)
  13365. return nil
  13366. case sopnode.FieldActionLabel:
  13367. v, ok := value.([]uint64)
  13368. if !ok {
  13369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13370. }
  13371. m.SetActionLabel(v)
  13372. return nil
  13373. }
  13374. return fmt.Errorf("unknown SopNode field %s", name)
  13375. }
  13376. // AddedFields returns all numeric fields that were incremented/decremented during
  13377. // this mutation.
  13378. func (m *SopNodeMutation) AddedFields() []string {
  13379. var fields []string
  13380. if m.addstatus != nil {
  13381. fields = append(fields, sopnode.FieldStatus)
  13382. }
  13383. if m.addparent_id != nil {
  13384. fields = append(fields, sopnode.FieldParentID)
  13385. }
  13386. if m.addcondition_type != nil {
  13387. fields = append(fields, sopnode.FieldConditionType)
  13388. }
  13389. if m.addno_reply_condition != nil {
  13390. fields = append(fields, sopnode.FieldNoReplyCondition)
  13391. }
  13392. return fields
  13393. }
  13394. // AddedField returns the numeric value that was incremented/decremented on a field
  13395. // with the given name. The second boolean return value indicates that this field
  13396. // was not set, or was not defined in the schema.
  13397. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  13398. switch name {
  13399. case sopnode.FieldStatus:
  13400. return m.AddedStatus()
  13401. case sopnode.FieldParentID:
  13402. return m.AddedParentID()
  13403. case sopnode.FieldConditionType:
  13404. return m.AddedConditionType()
  13405. case sopnode.FieldNoReplyCondition:
  13406. return m.AddedNoReplyCondition()
  13407. }
  13408. return nil, false
  13409. }
  13410. // AddField adds the value to the field with the given name. It returns an error if
  13411. // the field is not defined in the schema, or if the type mismatched the field
  13412. // type.
  13413. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  13414. switch name {
  13415. case sopnode.FieldStatus:
  13416. v, ok := value.(int8)
  13417. if !ok {
  13418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13419. }
  13420. m.AddStatus(v)
  13421. return nil
  13422. case sopnode.FieldParentID:
  13423. v, ok := value.(int64)
  13424. if !ok {
  13425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13426. }
  13427. m.AddParentID(v)
  13428. return nil
  13429. case sopnode.FieldConditionType:
  13430. v, ok := value.(int)
  13431. if !ok {
  13432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13433. }
  13434. m.AddConditionType(v)
  13435. return nil
  13436. case sopnode.FieldNoReplyCondition:
  13437. v, ok := value.(int64)
  13438. if !ok {
  13439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13440. }
  13441. m.AddNoReplyCondition(v)
  13442. return nil
  13443. }
  13444. return fmt.Errorf("unknown SopNode numeric field %s", name)
  13445. }
  13446. // ClearedFields returns all nullable fields that were cleared during this
  13447. // mutation.
  13448. func (m *SopNodeMutation) ClearedFields() []string {
  13449. var fields []string
  13450. if m.FieldCleared(sopnode.FieldStatus) {
  13451. fields = append(fields, sopnode.FieldStatus)
  13452. }
  13453. if m.FieldCleared(sopnode.FieldDeletedAt) {
  13454. fields = append(fields, sopnode.FieldDeletedAt)
  13455. }
  13456. if m.FieldCleared(sopnode.FieldConditionList) {
  13457. fields = append(fields, sopnode.FieldConditionList)
  13458. }
  13459. if m.FieldCleared(sopnode.FieldActionMessage) {
  13460. fields = append(fields, sopnode.FieldActionMessage)
  13461. }
  13462. if m.FieldCleared(sopnode.FieldActionLabel) {
  13463. fields = append(fields, sopnode.FieldActionLabel)
  13464. }
  13465. return fields
  13466. }
  13467. // FieldCleared returns a boolean indicating if a field with the given name was
  13468. // cleared in this mutation.
  13469. func (m *SopNodeMutation) FieldCleared(name string) bool {
  13470. _, ok := m.clearedFields[name]
  13471. return ok
  13472. }
  13473. // ClearField clears the value of the field with the given name. It returns an
  13474. // error if the field is not defined in the schema.
  13475. func (m *SopNodeMutation) ClearField(name string) error {
  13476. switch name {
  13477. case sopnode.FieldStatus:
  13478. m.ClearStatus()
  13479. return nil
  13480. case sopnode.FieldDeletedAt:
  13481. m.ClearDeletedAt()
  13482. return nil
  13483. case sopnode.FieldConditionList:
  13484. m.ClearConditionList()
  13485. return nil
  13486. case sopnode.FieldActionMessage:
  13487. m.ClearActionMessage()
  13488. return nil
  13489. case sopnode.FieldActionLabel:
  13490. m.ClearActionLabel()
  13491. return nil
  13492. }
  13493. return fmt.Errorf("unknown SopNode nullable field %s", name)
  13494. }
  13495. // ResetField resets all changes in the mutation for the field with the given name.
  13496. // It returns an error if the field is not defined in the schema.
  13497. func (m *SopNodeMutation) ResetField(name string) error {
  13498. switch name {
  13499. case sopnode.FieldCreatedAt:
  13500. m.ResetCreatedAt()
  13501. return nil
  13502. case sopnode.FieldUpdatedAt:
  13503. m.ResetUpdatedAt()
  13504. return nil
  13505. case sopnode.FieldStatus:
  13506. m.ResetStatus()
  13507. return nil
  13508. case sopnode.FieldDeletedAt:
  13509. m.ResetDeletedAt()
  13510. return nil
  13511. case sopnode.FieldStageID:
  13512. m.ResetStageID()
  13513. return nil
  13514. case sopnode.FieldParentID:
  13515. m.ResetParentID()
  13516. return nil
  13517. case sopnode.FieldName:
  13518. m.ResetName()
  13519. return nil
  13520. case sopnode.FieldConditionType:
  13521. m.ResetConditionType()
  13522. return nil
  13523. case sopnode.FieldConditionList:
  13524. m.ResetConditionList()
  13525. return nil
  13526. case sopnode.FieldNoReplyCondition:
  13527. m.ResetNoReplyCondition()
  13528. return nil
  13529. case sopnode.FieldActionMessage:
  13530. m.ResetActionMessage()
  13531. return nil
  13532. case sopnode.FieldActionLabel:
  13533. m.ResetActionLabel()
  13534. return nil
  13535. }
  13536. return fmt.Errorf("unknown SopNode field %s", name)
  13537. }
  13538. // AddedEdges returns all edge names that were set/added in this mutation.
  13539. func (m *SopNodeMutation) AddedEdges() []string {
  13540. edges := make([]string, 0, 2)
  13541. if m.sop_stage != nil {
  13542. edges = append(edges, sopnode.EdgeSopStage)
  13543. }
  13544. if m.node_messages != nil {
  13545. edges = append(edges, sopnode.EdgeNodeMessages)
  13546. }
  13547. return edges
  13548. }
  13549. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13550. // name in this mutation.
  13551. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  13552. switch name {
  13553. case sopnode.EdgeSopStage:
  13554. if id := m.sop_stage; id != nil {
  13555. return []ent.Value{*id}
  13556. }
  13557. case sopnode.EdgeNodeMessages:
  13558. ids := make([]ent.Value, 0, len(m.node_messages))
  13559. for id := range m.node_messages {
  13560. ids = append(ids, id)
  13561. }
  13562. return ids
  13563. }
  13564. return nil
  13565. }
  13566. // RemovedEdges returns all edge names that were removed in this mutation.
  13567. func (m *SopNodeMutation) RemovedEdges() []string {
  13568. edges := make([]string, 0, 2)
  13569. if m.removednode_messages != nil {
  13570. edges = append(edges, sopnode.EdgeNodeMessages)
  13571. }
  13572. return edges
  13573. }
  13574. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13575. // the given name in this mutation.
  13576. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  13577. switch name {
  13578. case sopnode.EdgeNodeMessages:
  13579. ids := make([]ent.Value, 0, len(m.removednode_messages))
  13580. for id := range m.removednode_messages {
  13581. ids = append(ids, id)
  13582. }
  13583. return ids
  13584. }
  13585. return nil
  13586. }
  13587. // ClearedEdges returns all edge names that were cleared in this mutation.
  13588. func (m *SopNodeMutation) ClearedEdges() []string {
  13589. edges := make([]string, 0, 2)
  13590. if m.clearedsop_stage {
  13591. edges = append(edges, sopnode.EdgeSopStage)
  13592. }
  13593. if m.clearednode_messages {
  13594. edges = append(edges, sopnode.EdgeNodeMessages)
  13595. }
  13596. return edges
  13597. }
  13598. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13599. // was cleared in this mutation.
  13600. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  13601. switch name {
  13602. case sopnode.EdgeSopStage:
  13603. return m.clearedsop_stage
  13604. case sopnode.EdgeNodeMessages:
  13605. return m.clearednode_messages
  13606. }
  13607. return false
  13608. }
  13609. // ClearEdge clears the value of the edge with the given name. It returns an error
  13610. // if that edge is not defined in the schema.
  13611. func (m *SopNodeMutation) ClearEdge(name string) error {
  13612. switch name {
  13613. case sopnode.EdgeSopStage:
  13614. m.ClearSopStage()
  13615. return nil
  13616. }
  13617. return fmt.Errorf("unknown SopNode unique edge %s", name)
  13618. }
  13619. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13620. // It returns an error if the edge is not defined in the schema.
  13621. func (m *SopNodeMutation) ResetEdge(name string) error {
  13622. switch name {
  13623. case sopnode.EdgeSopStage:
  13624. m.ResetSopStage()
  13625. return nil
  13626. case sopnode.EdgeNodeMessages:
  13627. m.ResetNodeMessages()
  13628. return nil
  13629. }
  13630. return fmt.Errorf("unknown SopNode edge %s", name)
  13631. }
  13632. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  13633. type SopStageMutation struct {
  13634. config
  13635. op Op
  13636. typ string
  13637. id *uint64
  13638. created_at *time.Time
  13639. updated_at *time.Time
  13640. status *uint8
  13641. addstatus *int8
  13642. deleted_at *time.Time
  13643. name *string
  13644. condition_type *int
  13645. addcondition_type *int
  13646. condition_operator *int
  13647. addcondition_operator *int
  13648. condition_list *[]custom_types.Condition
  13649. appendcondition_list []custom_types.Condition
  13650. action_message *[]custom_types.Action
  13651. appendaction_message []custom_types.Action
  13652. action_label *[]uint64
  13653. appendaction_label []uint64
  13654. index_sort *int
  13655. addindex_sort *int
  13656. clearedFields map[string]struct{}
  13657. sop_task *uint64
  13658. clearedsop_task bool
  13659. stage_nodes map[uint64]struct{}
  13660. removedstage_nodes map[uint64]struct{}
  13661. clearedstage_nodes bool
  13662. stage_messages map[uint64]struct{}
  13663. removedstage_messages map[uint64]struct{}
  13664. clearedstage_messages bool
  13665. done bool
  13666. oldValue func(context.Context) (*SopStage, error)
  13667. predicates []predicate.SopStage
  13668. }
  13669. var _ ent.Mutation = (*SopStageMutation)(nil)
  13670. // sopstageOption allows management of the mutation configuration using functional options.
  13671. type sopstageOption func(*SopStageMutation)
  13672. // newSopStageMutation creates new mutation for the SopStage entity.
  13673. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  13674. m := &SopStageMutation{
  13675. config: c,
  13676. op: op,
  13677. typ: TypeSopStage,
  13678. clearedFields: make(map[string]struct{}),
  13679. }
  13680. for _, opt := range opts {
  13681. opt(m)
  13682. }
  13683. return m
  13684. }
  13685. // withSopStageID sets the ID field of the mutation.
  13686. func withSopStageID(id uint64) sopstageOption {
  13687. return func(m *SopStageMutation) {
  13688. var (
  13689. err error
  13690. once sync.Once
  13691. value *SopStage
  13692. )
  13693. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  13694. once.Do(func() {
  13695. if m.done {
  13696. err = errors.New("querying old values post mutation is not allowed")
  13697. } else {
  13698. value, err = m.Client().SopStage.Get(ctx, id)
  13699. }
  13700. })
  13701. return value, err
  13702. }
  13703. m.id = &id
  13704. }
  13705. }
  13706. // withSopStage sets the old SopStage of the mutation.
  13707. func withSopStage(node *SopStage) sopstageOption {
  13708. return func(m *SopStageMutation) {
  13709. m.oldValue = func(context.Context) (*SopStage, error) {
  13710. return node, nil
  13711. }
  13712. m.id = &node.ID
  13713. }
  13714. }
  13715. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13716. // executed in a transaction (ent.Tx), a transactional client is returned.
  13717. func (m SopStageMutation) Client() *Client {
  13718. client := &Client{config: m.config}
  13719. client.init()
  13720. return client
  13721. }
  13722. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13723. // it returns an error otherwise.
  13724. func (m SopStageMutation) Tx() (*Tx, error) {
  13725. if _, ok := m.driver.(*txDriver); !ok {
  13726. return nil, errors.New("ent: mutation is not running in a transaction")
  13727. }
  13728. tx := &Tx{config: m.config}
  13729. tx.init()
  13730. return tx, nil
  13731. }
  13732. // SetID sets the value of the id field. Note that this
  13733. // operation is only accepted on creation of SopStage entities.
  13734. func (m *SopStageMutation) SetID(id uint64) {
  13735. m.id = &id
  13736. }
  13737. // ID returns the ID value in the mutation. Note that the ID is only available
  13738. // if it was provided to the builder or after it was returned from the database.
  13739. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  13740. if m.id == nil {
  13741. return
  13742. }
  13743. return *m.id, true
  13744. }
  13745. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13746. // That means, if the mutation is applied within a transaction with an isolation level such
  13747. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13748. // or updated by the mutation.
  13749. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  13750. switch {
  13751. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13752. id, exists := m.ID()
  13753. if exists {
  13754. return []uint64{id}, nil
  13755. }
  13756. fallthrough
  13757. case m.op.Is(OpUpdate | OpDelete):
  13758. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  13759. default:
  13760. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13761. }
  13762. }
  13763. // SetCreatedAt sets the "created_at" field.
  13764. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  13765. m.created_at = &t
  13766. }
  13767. // CreatedAt returns the value of the "created_at" field in the mutation.
  13768. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  13769. v := m.created_at
  13770. if v == nil {
  13771. return
  13772. }
  13773. return *v, true
  13774. }
  13775. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  13776. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13778. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13779. if !m.op.Is(OpUpdateOne) {
  13780. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13781. }
  13782. if m.id == nil || m.oldValue == nil {
  13783. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13784. }
  13785. oldValue, err := m.oldValue(ctx)
  13786. if err != nil {
  13787. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13788. }
  13789. return oldValue.CreatedAt, nil
  13790. }
  13791. // ResetCreatedAt resets all changes to the "created_at" field.
  13792. func (m *SopStageMutation) ResetCreatedAt() {
  13793. m.created_at = nil
  13794. }
  13795. // SetUpdatedAt sets the "updated_at" field.
  13796. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  13797. m.updated_at = &t
  13798. }
  13799. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13800. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  13801. v := m.updated_at
  13802. if v == nil {
  13803. return
  13804. }
  13805. return *v, true
  13806. }
  13807. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  13808. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13810. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13811. if !m.op.Is(OpUpdateOne) {
  13812. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13813. }
  13814. if m.id == nil || m.oldValue == nil {
  13815. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13816. }
  13817. oldValue, err := m.oldValue(ctx)
  13818. if err != nil {
  13819. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13820. }
  13821. return oldValue.UpdatedAt, nil
  13822. }
  13823. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13824. func (m *SopStageMutation) ResetUpdatedAt() {
  13825. m.updated_at = nil
  13826. }
  13827. // SetStatus sets the "status" field.
  13828. func (m *SopStageMutation) SetStatus(u uint8) {
  13829. m.status = &u
  13830. m.addstatus = nil
  13831. }
  13832. // Status returns the value of the "status" field in the mutation.
  13833. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  13834. v := m.status
  13835. if v == nil {
  13836. return
  13837. }
  13838. return *v, true
  13839. }
  13840. // OldStatus returns the old "status" field's value of the SopStage entity.
  13841. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13843. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13844. if !m.op.Is(OpUpdateOne) {
  13845. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13846. }
  13847. if m.id == nil || m.oldValue == nil {
  13848. return v, errors.New("OldStatus requires an ID field in the mutation")
  13849. }
  13850. oldValue, err := m.oldValue(ctx)
  13851. if err != nil {
  13852. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13853. }
  13854. return oldValue.Status, nil
  13855. }
  13856. // AddStatus adds u to the "status" field.
  13857. func (m *SopStageMutation) AddStatus(u int8) {
  13858. if m.addstatus != nil {
  13859. *m.addstatus += u
  13860. } else {
  13861. m.addstatus = &u
  13862. }
  13863. }
  13864. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13865. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  13866. v := m.addstatus
  13867. if v == nil {
  13868. return
  13869. }
  13870. return *v, true
  13871. }
  13872. // ClearStatus clears the value of the "status" field.
  13873. func (m *SopStageMutation) ClearStatus() {
  13874. m.status = nil
  13875. m.addstatus = nil
  13876. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  13877. }
  13878. // StatusCleared returns if the "status" field was cleared in this mutation.
  13879. func (m *SopStageMutation) StatusCleared() bool {
  13880. _, ok := m.clearedFields[sopstage.FieldStatus]
  13881. return ok
  13882. }
  13883. // ResetStatus resets all changes to the "status" field.
  13884. func (m *SopStageMutation) ResetStatus() {
  13885. m.status = nil
  13886. m.addstatus = nil
  13887. delete(m.clearedFields, sopstage.FieldStatus)
  13888. }
  13889. // SetDeletedAt sets the "deleted_at" field.
  13890. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  13891. m.deleted_at = &t
  13892. }
  13893. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13894. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  13895. v := m.deleted_at
  13896. if v == nil {
  13897. return
  13898. }
  13899. return *v, true
  13900. }
  13901. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  13902. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13903. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13904. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13905. if !m.op.Is(OpUpdateOne) {
  13906. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13907. }
  13908. if m.id == nil || m.oldValue == nil {
  13909. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13910. }
  13911. oldValue, err := m.oldValue(ctx)
  13912. if err != nil {
  13913. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13914. }
  13915. return oldValue.DeletedAt, nil
  13916. }
  13917. // ClearDeletedAt clears the value of the "deleted_at" field.
  13918. func (m *SopStageMutation) ClearDeletedAt() {
  13919. m.deleted_at = nil
  13920. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  13921. }
  13922. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13923. func (m *SopStageMutation) DeletedAtCleared() bool {
  13924. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  13925. return ok
  13926. }
  13927. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13928. func (m *SopStageMutation) ResetDeletedAt() {
  13929. m.deleted_at = nil
  13930. delete(m.clearedFields, sopstage.FieldDeletedAt)
  13931. }
  13932. // SetTaskID sets the "task_id" field.
  13933. func (m *SopStageMutation) SetTaskID(u uint64) {
  13934. m.sop_task = &u
  13935. }
  13936. // TaskID returns the value of the "task_id" field in the mutation.
  13937. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  13938. v := m.sop_task
  13939. if v == nil {
  13940. return
  13941. }
  13942. return *v, true
  13943. }
  13944. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  13945. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13947. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  13948. if !m.op.Is(OpUpdateOne) {
  13949. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  13950. }
  13951. if m.id == nil || m.oldValue == nil {
  13952. return v, errors.New("OldTaskID requires an ID field in the mutation")
  13953. }
  13954. oldValue, err := m.oldValue(ctx)
  13955. if err != nil {
  13956. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  13957. }
  13958. return oldValue.TaskID, nil
  13959. }
  13960. // ResetTaskID resets all changes to the "task_id" field.
  13961. func (m *SopStageMutation) ResetTaskID() {
  13962. m.sop_task = nil
  13963. }
  13964. // SetName sets the "name" field.
  13965. func (m *SopStageMutation) SetName(s string) {
  13966. m.name = &s
  13967. }
  13968. // Name returns the value of the "name" field in the mutation.
  13969. func (m *SopStageMutation) Name() (r string, exists bool) {
  13970. v := m.name
  13971. if v == nil {
  13972. return
  13973. }
  13974. return *v, true
  13975. }
  13976. // OldName returns the old "name" field's value of the SopStage entity.
  13977. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13978. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13979. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  13980. if !m.op.Is(OpUpdateOne) {
  13981. return v, errors.New("OldName is only allowed on UpdateOne operations")
  13982. }
  13983. if m.id == nil || m.oldValue == nil {
  13984. return v, errors.New("OldName requires an ID field in the mutation")
  13985. }
  13986. oldValue, err := m.oldValue(ctx)
  13987. if err != nil {
  13988. return v, fmt.Errorf("querying old value for OldName: %w", err)
  13989. }
  13990. return oldValue.Name, nil
  13991. }
  13992. // ResetName resets all changes to the "name" field.
  13993. func (m *SopStageMutation) ResetName() {
  13994. m.name = nil
  13995. }
  13996. // SetConditionType sets the "condition_type" field.
  13997. func (m *SopStageMutation) SetConditionType(i int) {
  13998. m.condition_type = &i
  13999. m.addcondition_type = nil
  14000. }
  14001. // ConditionType returns the value of the "condition_type" field in the mutation.
  14002. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  14003. v := m.condition_type
  14004. if v == nil {
  14005. return
  14006. }
  14007. return *v, true
  14008. }
  14009. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  14010. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14012. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  14013. if !m.op.Is(OpUpdateOne) {
  14014. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  14015. }
  14016. if m.id == nil || m.oldValue == nil {
  14017. return v, errors.New("OldConditionType requires an ID field in the mutation")
  14018. }
  14019. oldValue, err := m.oldValue(ctx)
  14020. if err != nil {
  14021. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  14022. }
  14023. return oldValue.ConditionType, nil
  14024. }
  14025. // AddConditionType adds i to the "condition_type" field.
  14026. func (m *SopStageMutation) AddConditionType(i int) {
  14027. if m.addcondition_type != nil {
  14028. *m.addcondition_type += i
  14029. } else {
  14030. m.addcondition_type = &i
  14031. }
  14032. }
  14033. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  14034. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  14035. v := m.addcondition_type
  14036. if v == nil {
  14037. return
  14038. }
  14039. return *v, true
  14040. }
  14041. // ResetConditionType resets all changes to the "condition_type" field.
  14042. func (m *SopStageMutation) ResetConditionType() {
  14043. m.condition_type = nil
  14044. m.addcondition_type = nil
  14045. }
  14046. // SetConditionOperator sets the "condition_operator" field.
  14047. func (m *SopStageMutation) SetConditionOperator(i int) {
  14048. m.condition_operator = &i
  14049. m.addcondition_operator = nil
  14050. }
  14051. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  14052. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  14053. v := m.condition_operator
  14054. if v == nil {
  14055. return
  14056. }
  14057. return *v, true
  14058. }
  14059. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  14060. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14061. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14062. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  14063. if !m.op.Is(OpUpdateOne) {
  14064. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  14065. }
  14066. if m.id == nil || m.oldValue == nil {
  14067. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  14068. }
  14069. oldValue, err := m.oldValue(ctx)
  14070. if err != nil {
  14071. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  14072. }
  14073. return oldValue.ConditionOperator, nil
  14074. }
  14075. // AddConditionOperator adds i to the "condition_operator" field.
  14076. func (m *SopStageMutation) AddConditionOperator(i int) {
  14077. if m.addcondition_operator != nil {
  14078. *m.addcondition_operator += i
  14079. } else {
  14080. m.addcondition_operator = &i
  14081. }
  14082. }
  14083. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  14084. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  14085. v := m.addcondition_operator
  14086. if v == nil {
  14087. return
  14088. }
  14089. return *v, true
  14090. }
  14091. // ResetConditionOperator resets all changes to the "condition_operator" field.
  14092. func (m *SopStageMutation) ResetConditionOperator() {
  14093. m.condition_operator = nil
  14094. m.addcondition_operator = nil
  14095. }
  14096. // SetConditionList sets the "condition_list" field.
  14097. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  14098. m.condition_list = &ct
  14099. m.appendcondition_list = nil
  14100. }
  14101. // ConditionList returns the value of the "condition_list" field in the mutation.
  14102. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  14103. v := m.condition_list
  14104. if v == nil {
  14105. return
  14106. }
  14107. return *v, true
  14108. }
  14109. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  14110. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14112. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  14113. if !m.op.Is(OpUpdateOne) {
  14114. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  14115. }
  14116. if m.id == nil || m.oldValue == nil {
  14117. return v, errors.New("OldConditionList requires an ID field in the mutation")
  14118. }
  14119. oldValue, err := m.oldValue(ctx)
  14120. if err != nil {
  14121. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  14122. }
  14123. return oldValue.ConditionList, nil
  14124. }
  14125. // AppendConditionList adds ct to the "condition_list" field.
  14126. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  14127. m.appendcondition_list = append(m.appendcondition_list, ct...)
  14128. }
  14129. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  14130. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  14131. if len(m.appendcondition_list) == 0 {
  14132. return nil, false
  14133. }
  14134. return m.appendcondition_list, true
  14135. }
  14136. // ResetConditionList resets all changes to the "condition_list" field.
  14137. func (m *SopStageMutation) ResetConditionList() {
  14138. m.condition_list = nil
  14139. m.appendcondition_list = nil
  14140. }
  14141. // SetActionMessage sets the "action_message" field.
  14142. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  14143. m.action_message = &ct
  14144. m.appendaction_message = nil
  14145. }
  14146. // ActionMessage returns the value of the "action_message" field in the mutation.
  14147. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  14148. v := m.action_message
  14149. if v == nil {
  14150. return
  14151. }
  14152. return *v, true
  14153. }
  14154. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  14155. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14157. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  14158. if !m.op.Is(OpUpdateOne) {
  14159. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  14160. }
  14161. if m.id == nil || m.oldValue == nil {
  14162. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  14163. }
  14164. oldValue, err := m.oldValue(ctx)
  14165. if err != nil {
  14166. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  14167. }
  14168. return oldValue.ActionMessage, nil
  14169. }
  14170. // AppendActionMessage adds ct to the "action_message" field.
  14171. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  14172. m.appendaction_message = append(m.appendaction_message, ct...)
  14173. }
  14174. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  14175. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  14176. if len(m.appendaction_message) == 0 {
  14177. return nil, false
  14178. }
  14179. return m.appendaction_message, true
  14180. }
  14181. // ClearActionMessage clears the value of the "action_message" field.
  14182. func (m *SopStageMutation) ClearActionMessage() {
  14183. m.action_message = nil
  14184. m.appendaction_message = nil
  14185. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  14186. }
  14187. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  14188. func (m *SopStageMutation) ActionMessageCleared() bool {
  14189. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  14190. return ok
  14191. }
  14192. // ResetActionMessage resets all changes to the "action_message" field.
  14193. func (m *SopStageMutation) ResetActionMessage() {
  14194. m.action_message = nil
  14195. m.appendaction_message = nil
  14196. delete(m.clearedFields, sopstage.FieldActionMessage)
  14197. }
  14198. // SetActionLabel sets the "action_label" field.
  14199. func (m *SopStageMutation) SetActionLabel(u []uint64) {
  14200. m.action_label = &u
  14201. m.appendaction_label = nil
  14202. }
  14203. // ActionLabel returns the value of the "action_label" field in the mutation.
  14204. func (m *SopStageMutation) ActionLabel() (r []uint64, exists bool) {
  14205. v := m.action_label
  14206. if v == nil {
  14207. return
  14208. }
  14209. return *v, true
  14210. }
  14211. // OldActionLabel returns the old "action_label" field's value of the SopStage entity.
  14212. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14214. func (m *SopStageMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  14215. if !m.op.Is(OpUpdateOne) {
  14216. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  14217. }
  14218. if m.id == nil || m.oldValue == nil {
  14219. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  14220. }
  14221. oldValue, err := m.oldValue(ctx)
  14222. if err != nil {
  14223. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  14224. }
  14225. return oldValue.ActionLabel, nil
  14226. }
  14227. // AppendActionLabel adds u to the "action_label" field.
  14228. func (m *SopStageMutation) AppendActionLabel(u []uint64) {
  14229. m.appendaction_label = append(m.appendaction_label, u...)
  14230. }
  14231. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  14232. func (m *SopStageMutation) AppendedActionLabel() ([]uint64, bool) {
  14233. if len(m.appendaction_label) == 0 {
  14234. return nil, false
  14235. }
  14236. return m.appendaction_label, true
  14237. }
  14238. // ClearActionLabel clears the value of the "action_label" field.
  14239. func (m *SopStageMutation) ClearActionLabel() {
  14240. m.action_label = nil
  14241. m.appendaction_label = nil
  14242. m.clearedFields[sopstage.FieldActionLabel] = struct{}{}
  14243. }
  14244. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  14245. func (m *SopStageMutation) ActionLabelCleared() bool {
  14246. _, ok := m.clearedFields[sopstage.FieldActionLabel]
  14247. return ok
  14248. }
  14249. // ResetActionLabel resets all changes to the "action_label" field.
  14250. func (m *SopStageMutation) ResetActionLabel() {
  14251. m.action_label = nil
  14252. m.appendaction_label = nil
  14253. delete(m.clearedFields, sopstage.FieldActionLabel)
  14254. }
  14255. // SetIndexSort sets the "index_sort" field.
  14256. func (m *SopStageMutation) SetIndexSort(i int) {
  14257. m.index_sort = &i
  14258. m.addindex_sort = nil
  14259. }
  14260. // IndexSort returns the value of the "index_sort" field in the mutation.
  14261. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  14262. v := m.index_sort
  14263. if v == nil {
  14264. return
  14265. }
  14266. return *v, true
  14267. }
  14268. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  14269. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14271. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  14272. if !m.op.Is(OpUpdateOne) {
  14273. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  14274. }
  14275. if m.id == nil || m.oldValue == nil {
  14276. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  14277. }
  14278. oldValue, err := m.oldValue(ctx)
  14279. if err != nil {
  14280. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  14281. }
  14282. return oldValue.IndexSort, nil
  14283. }
  14284. // AddIndexSort adds i to the "index_sort" field.
  14285. func (m *SopStageMutation) AddIndexSort(i int) {
  14286. if m.addindex_sort != nil {
  14287. *m.addindex_sort += i
  14288. } else {
  14289. m.addindex_sort = &i
  14290. }
  14291. }
  14292. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  14293. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  14294. v := m.addindex_sort
  14295. if v == nil {
  14296. return
  14297. }
  14298. return *v, true
  14299. }
  14300. // ClearIndexSort clears the value of the "index_sort" field.
  14301. func (m *SopStageMutation) ClearIndexSort() {
  14302. m.index_sort = nil
  14303. m.addindex_sort = nil
  14304. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  14305. }
  14306. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  14307. func (m *SopStageMutation) IndexSortCleared() bool {
  14308. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  14309. return ok
  14310. }
  14311. // ResetIndexSort resets all changes to the "index_sort" field.
  14312. func (m *SopStageMutation) ResetIndexSort() {
  14313. m.index_sort = nil
  14314. m.addindex_sort = nil
  14315. delete(m.clearedFields, sopstage.FieldIndexSort)
  14316. }
  14317. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  14318. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  14319. m.sop_task = &id
  14320. }
  14321. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  14322. func (m *SopStageMutation) ClearSopTask() {
  14323. m.clearedsop_task = true
  14324. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  14325. }
  14326. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  14327. func (m *SopStageMutation) SopTaskCleared() bool {
  14328. return m.clearedsop_task
  14329. }
  14330. // SopTaskID returns the "sop_task" edge ID in the mutation.
  14331. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  14332. if m.sop_task != nil {
  14333. return *m.sop_task, true
  14334. }
  14335. return
  14336. }
  14337. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  14338. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14339. // SopTaskID instead. It exists only for internal usage by the builders.
  14340. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  14341. if id := m.sop_task; id != nil {
  14342. ids = append(ids, *id)
  14343. }
  14344. return
  14345. }
  14346. // ResetSopTask resets all changes to the "sop_task" edge.
  14347. func (m *SopStageMutation) ResetSopTask() {
  14348. m.sop_task = nil
  14349. m.clearedsop_task = false
  14350. }
  14351. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  14352. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  14353. if m.stage_nodes == nil {
  14354. m.stage_nodes = make(map[uint64]struct{})
  14355. }
  14356. for i := range ids {
  14357. m.stage_nodes[ids[i]] = struct{}{}
  14358. }
  14359. }
  14360. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  14361. func (m *SopStageMutation) ClearStageNodes() {
  14362. m.clearedstage_nodes = true
  14363. }
  14364. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  14365. func (m *SopStageMutation) StageNodesCleared() bool {
  14366. return m.clearedstage_nodes
  14367. }
  14368. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  14369. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  14370. if m.removedstage_nodes == nil {
  14371. m.removedstage_nodes = make(map[uint64]struct{})
  14372. }
  14373. for i := range ids {
  14374. delete(m.stage_nodes, ids[i])
  14375. m.removedstage_nodes[ids[i]] = struct{}{}
  14376. }
  14377. }
  14378. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  14379. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  14380. for id := range m.removedstage_nodes {
  14381. ids = append(ids, id)
  14382. }
  14383. return
  14384. }
  14385. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  14386. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  14387. for id := range m.stage_nodes {
  14388. ids = append(ids, id)
  14389. }
  14390. return
  14391. }
  14392. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  14393. func (m *SopStageMutation) ResetStageNodes() {
  14394. m.stage_nodes = nil
  14395. m.clearedstage_nodes = false
  14396. m.removedstage_nodes = nil
  14397. }
  14398. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  14399. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  14400. if m.stage_messages == nil {
  14401. m.stage_messages = make(map[uint64]struct{})
  14402. }
  14403. for i := range ids {
  14404. m.stage_messages[ids[i]] = struct{}{}
  14405. }
  14406. }
  14407. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  14408. func (m *SopStageMutation) ClearStageMessages() {
  14409. m.clearedstage_messages = true
  14410. }
  14411. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  14412. func (m *SopStageMutation) StageMessagesCleared() bool {
  14413. return m.clearedstage_messages
  14414. }
  14415. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  14416. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  14417. if m.removedstage_messages == nil {
  14418. m.removedstage_messages = make(map[uint64]struct{})
  14419. }
  14420. for i := range ids {
  14421. delete(m.stage_messages, ids[i])
  14422. m.removedstage_messages[ids[i]] = struct{}{}
  14423. }
  14424. }
  14425. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  14426. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  14427. for id := range m.removedstage_messages {
  14428. ids = append(ids, id)
  14429. }
  14430. return
  14431. }
  14432. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  14433. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  14434. for id := range m.stage_messages {
  14435. ids = append(ids, id)
  14436. }
  14437. return
  14438. }
  14439. // ResetStageMessages resets all changes to the "stage_messages" edge.
  14440. func (m *SopStageMutation) ResetStageMessages() {
  14441. m.stage_messages = nil
  14442. m.clearedstage_messages = false
  14443. m.removedstage_messages = nil
  14444. }
  14445. // Where appends a list predicates to the SopStageMutation builder.
  14446. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  14447. m.predicates = append(m.predicates, ps...)
  14448. }
  14449. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  14450. // users can use type-assertion to append predicates that do not depend on any generated package.
  14451. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  14452. p := make([]predicate.SopStage, len(ps))
  14453. for i := range ps {
  14454. p[i] = ps[i]
  14455. }
  14456. m.Where(p...)
  14457. }
  14458. // Op returns the operation name.
  14459. func (m *SopStageMutation) Op() Op {
  14460. return m.op
  14461. }
  14462. // SetOp allows setting the mutation operation.
  14463. func (m *SopStageMutation) SetOp(op Op) {
  14464. m.op = op
  14465. }
  14466. // Type returns the node type of this mutation (SopStage).
  14467. func (m *SopStageMutation) Type() string {
  14468. return m.typ
  14469. }
  14470. // Fields returns all fields that were changed during this mutation. Note that in
  14471. // order to get all numeric fields that were incremented/decremented, call
  14472. // AddedFields().
  14473. func (m *SopStageMutation) Fields() []string {
  14474. fields := make([]string, 0, 12)
  14475. if m.created_at != nil {
  14476. fields = append(fields, sopstage.FieldCreatedAt)
  14477. }
  14478. if m.updated_at != nil {
  14479. fields = append(fields, sopstage.FieldUpdatedAt)
  14480. }
  14481. if m.status != nil {
  14482. fields = append(fields, sopstage.FieldStatus)
  14483. }
  14484. if m.deleted_at != nil {
  14485. fields = append(fields, sopstage.FieldDeletedAt)
  14486. }
  14487. if m.sop_task != nil {
  14488. fields = append(fields, sopstage.FieldTaskID)
  14489. }
  14490. if m.name != nil {
  14491. fields = append(fields, sopstage.FieldName)
  14492. }
  14493. if m.condition_type != nil {
  14494. fields = append(fields, sopstage.FieldConditionType)
  14495. }
  14496. if m.condition_operator != nil {
  14497. fields = append(fields, sopstage.FieldConditionOperator)
  14498. }
  14499. if m.condition_list != nil {
  14500. fields = append(fields, sopstage.FieldConditionList)
  14501. }
  14502. if m.action_message != nil {
  14503. fields = append(fields, sopstage.FieldActionMessage)
  14504. }
  14505. if m.action_label != nil {
  14506. fields = append(fields, sopstage.FieldActionLabel)
  14507. }
  14508. if m.index_sort != nil {
  14509. fields = append(fields, sopstage.FieldIndexSort)
  14510. }
  14511. return fields
  14512. }
  14513. // Field returns the value of a field with the given name. The second boolean
  14514. // return value indicates that this field was not set, or was not defined in the
  14515. // schema.
  14516. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  14517. switch name {
  14518. case sopstage.FieldCreatedAt:
  14519. return m.CreatedAt()
  14520. case sopstage.FieldUpdatedAt:
  14521. return m.UpdatedAt()
  14522. case sopstage.FieldStatus:
  14523. return m.Status()
  14524. case sopstage.FieldDeletedAt:
  14525. return m.DeletedAt()
  14526. case sopstage.FieldTaskID:
  14527. return m.TaskID()
  14528. case sopstage.FieldName:
  14529. return m.Name()
  14530. case sopstage.FieldConditionType:
  14531. return m.ConditionType()
  14532. case sopstage.FieldConditionOperator:
  14533. return m.ConditionOperator()
  14534. case sopstage.FieldConditionList:
  14535. return m.ConditionList()
  14536. case sopstage.FieldActionMessage:
  14537. return m.ActionMessage()
  14538. case sopstage.FieldActionLabel:
  14539. return m.ActionLabel()
  14540. case sopstage.FieldIndexSort:
  14541. return m.IndexSort()
  14542. }
  14543. return nil, false
  14544. }
  14545. // OldField returns the old value of the field from the database. An error is
  14546. // returned if the mutation operation is not UpdateOne, or the query to the
  14547. // database failed.
  14548. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14549. switch name {
  14550. case sopstage.FieldCreatedAt:
  14551. return m.OldCreatedAt(ctx)
  14552. case sopstage.FieldUpdatedAt:
  14553. return m.OldUpdatedAt(ctx)
  14554. case sopstage.FieldStatus:
  14555. return m.OldStatus(ctx)
  14556. case sopstage.FieldDeletedAt:
  14557. return m.OldDeletedAt(ctx)
  14558. case sopstage.FieldTaskID:
  14559. return m.OldTaskID(ctx)
  14560. case sopstage.FieldName:
  14561. return m.OldName(ctx)
  14562. case sopstage.FieldConditionType:
  14563. return m.OldConditionType(ctx)
  14564. case sopstage.FieldConditionOperator:
  14565. return m.OldConditionOperator(ctx)
  14566. case sopstage.FieldConditionList:
  14567. return m.OldConditionList(ctx)
  14568. case sopstage.FieldActionMessage:
  14569. return m.OldActionMessage(ctx)
  14570. case sopstage.FieldActionLabel:
  14571. return m.OldActionLabel(ctx)
  14572. case sopstage.FieldIndexSort:
  14573. return m.OldIndexSort(ctx)
  14574. }
  14575. return nil, fmt.Errorf("unknown SopStage field %s", name)
  14576. }
  14577. // SetField sets the value of a field with the given name. It returns an error if
  14578. // the field is not defined in the schema, or if the type mismatched the field
  14579. // type.
  14580. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  14581. switch name {
  14582. case sopstage.FieldCreatedAt:
  14583. v, ok := value.(time.Time)
  14584. if !ok {
  14585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14586. }
  14587. m.SetCreatedAt(v)
  14588. return nil
  14589. case sopstage.FieldUpdatedAt:
  14590. v, ok := value.(time.Time)
  14591. if !ok {
  14592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14593. }
  14594. m.SetUpdatedAt(v)
  14595. return nil
  14596. case sopstage.FieldStatus:
  14597. v, ok := value.(uint8)
  14598. if !ok {
  14599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14600. }
  14601. m.SetStatus(v)
  14602. return nil
  14603. case sopstage.FieldDeletedAt:
  14604. v, ok := value.(time.Time)
  14605. if !ok {
  14606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14607. }
  14608. m.SetDeletedAt(v)
  14609. return nil
  14610. case sopstage.FieldTaskID:
  14611. v, ok := value.(uint64)
  14612. if !ok {
  14613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14614. }
  14615. m.SetTaskID(v)
  14616. return nil
  14617. case sopstage.FieldName:
  14618. v, ok := value.(string)
  14619. if !ok {
  14620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14621. }
  14622. m.SetName(v)
  14623. return nil
  14624. case sopstage.FieldConditionType:
  14625. v, ok := value.(int)
  14626. if !ok {
  14627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14628. }
  14629. m.SetConditionType(v)
  14630. return nil
  14631. case sopstage.FieldConditionOperator:
  14632. v, ok := value.(int)
  14633. if !ok {
  14634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14635. }
  14636. m.SetConditionOperator(v)
  14637. return nil
  14638. case sopstage.FieldConditionList:
  14639. v, ok := value.([]custom_types.Condition)
  14640. if !ok {
  14641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14642. }
  14643. m.SetConditionList(v)
  14644. return nil
  14645. case sopstage.FieldActionMessage:
  14646. v, ok := value.([]custom_types.Action)
  14647. if !ok {
  14648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14649. }
  14650. m.SetActionMessage(v)
  14651. return nil
  14652. case sopstage.FieldActionLabel:
  14653. v, ok := value.([]uint64)
  14654. if !ok {
  14655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14656. }
  14657. m.SetActionLabel(v)
  14658. return nil
  14659. case sopstage.FieldIndexSort:
  14660. v, ok := value.(int)
  14661. if !ok {
  14662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14663. }
  14664. m.SetIndexSort(v)
  14665. return nil
  14666. }
  14667. return fmt.Errorf("unknown SopStage field %s", name)
  14668. }
  14669. // AddedFields returns all numeric fields that were incremented/decremented during
  14670. // this mutation.
  14671. func (m *SopStageMutation) AddedFields() []string {
  14672. var fields []string
  14673. if m.addstatus != nil {
  14674. fields = append(fields, sopstage.FieldStatus)
  14675. }
  14676. if m.addcondition_type != nil {
  14677. fields = append(fields, sopstage.FieldConditionType)
  14678. }
  14679. if m.addcondition_operator != nil {
  14680. fields = append(fields, sopstage.FieldConditionOperator)
  14681. }
  14682. if m.addindex_sort != nil {
  14683. fields = append(fields, sopstage.FieldIndexSort)
  14684. }
  14685. return fields
  14686. }
  14687. // AddedField returns the numeric value that was incremented/decremented on a field
  14688. // with the given name. The second boolean return value indicates that this field
  14689. // was not set, or was not defined in the schema.
  14690. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  14691. switch name {
  14692. case sopstage.FieldStatus:
  14693. return m.AddedStatus()
  14694. case sopstage.FieldConditionType:
  14695. return m.AddedConditionType()
  14696. case sopstage.FieldConditionOperator:
  14697. return m.AddedConditionOperator()
  14698. case sopstage.FieldIndexSort:
  14699. return m.AddedIndexSort()
  14700. }
  14701. return nil, false
  14702. }
  14703. // AddField adds the value to the field with the given name. It returns an error if
  14704. // the field is not defined in the schema, or if the type mismatched the field
  14705. // type.
  14706. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  14707. switch name {
  14708. case sopstage.FieldStatus:
  14709. v, ok := value.(int8)
  14710. if !ok {
  14711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14712. }
  14713. m.AddStatus(v)
  14714. return nil
  14715. case sopstage.FieldConditionType:
  14716. v, ok := value.(int)
  14717. if !ok {
  14718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14719. }
  14720. m.AddConditionType(v)
  14721. return nil
  14722. case sopstage.FieldConditionOperator:
  14723. v, ok := value.(int)
  14724. if !ok {
  14725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14726. }
  14727. m.AddConditionOperator(v)
  14728. return nil
  14729. case sopstage.FieldIndexSort:
  14730. v, ok := value.(int)
  14731. if !ok {
  14732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14733. }
  14734. m.AddIndexSort(v)
  14735. return nil
  14736. }
  14737. return fmt.Errorf("unknown SopStage numeric field %s", name)
  14738. }
  14739. // ClearedFields returns all nullable fields that were cleared during this
  14740. // mutation.
  14741. func (m *SopStageMutation) ClearedFields() []string {
  14742. var fields []string
  14743. if m.FieldCleared(sopstage.FieldStatus) {
  14744. fields = append(fields, sopstage.FieldStatus)
  14745. }
  14746. if m.FieldCleared(sopstage.FieldDeletedAt) {
  14747. fields = append(fields, sopstage.FieldDeletedAt)
  14748. }
  14749. if m.FieldCleared(sopstage.FieldActionMessage) {
  14750. fields = append(fields, sopstage.FieldActionMessage)
  14751. }
  14752. if m.FieldCleared(sopstage.FieldActionLabel) {
  14753. fields = append(fields, sopstage.FieldActionLabel)
  14754. }
  14755. if m.FieldCleared(sopstage.FieldIndexSort) {
  14756. fields = append(fields, sopstage.FieldIndexSort)
  14757. }
  14758. return fields
  14759. }
  14760. // FieldCleared returns a boolean indicating if a field with the given name was
  14761. // cleared in this mutation.
  14762. func (m *SopStageMutation) FieldCleared(name string) bool {
  14763. _, ok := m.clearedFields[name]
  14764. return ok
  14765. }
  14766. // ClearField clears the value of the field with the given name. It returns an
  14767. // error if the field is not defined in the schema.
  14768. func (m *SopStageMutation) ClearField(name string) error {
  14769. switch name {
  14770. case sopstage.FieldStatus:
  14771. m.ClearStatus()
  14772. return nil
  14773. case sopstage.FieldDeletedAt:
  14774. m.ClearDeletedAt()
  14775. return nil
  14776. case sopstage.FieldActionMessage:
  14777. m.ClearActionMessage()
  14778. return nil
  14779. case sopstage.FieldActionLabel:
  14780. m.ClearActionLabel()
  14781. return nil
  14782. case sopstage.FieldIndexSort:
  14783. m.ClearIndexSort()
  14784. return nil
  14785. }
  14786. return fmt.Errorf("unknown SopStage nullable field %s", name)
  14787. }
  14788. // ResetField resets all changes in the mutation for the field with the given name.
  14789. // It returns an error if the field is not defined in the schema.
  14790. func (m *SopStageMutation) ResetField(name string) error {
  14791. switch name {
  14792. case sopstage.FieldCreatedAt:
  14793. m.ResetCreatedAt()
  14794. return nil
  14795. case sopstage.FieldUpdatedAt:
  14796. m.ResetUpdatedAt()
  14797. return nil
  14798. case sopstage.FieldStatus:
  14799. m.ResetStatus()
  14800. return nil
  14801. case sopstage.FieldDeletedAt:
  14802. m.ResetDeletedAt()
  14803. return nil
  14804. case sopstage.FieldTaskID:
  14805. m.ResetTaskID()
  14806. return nil
  14807. case sopstage.FieldName:
  14808. m.ResetName()
  14809. return nil
  14810. case sopstage.FieldConditionType:
  14811. m.ResetConditionType()
  14812. return nil
  14813. case sopstage.FieldConditionOperator:
  14814. m.ResetConditionOperator()
  14815. return nil
  14816. case sopstage.FieldConditionList:
  14817. m.ResetConditionList()
  14818. return nil
  14819. case sopstage.FieldActionMessage:
  14820. m.ResetActionMessage()
  14821. return nil
  14822. case sopstage.FieldActionLabel:
  14823. m.ResetActionLabel()
  14824. return nil
  14825. case sopstage.FieldIndexSort:
  14826. m.ResetIndexSort()
  14827. return nil
  14828. }
  14829. return fmt.Errorf("unknown SopStage field %s", name)
  14830. }
  14831. // AddedEdges returns all edge names that were set/added in this mutation.
  14832. func (m *SopStageMutation) AddedEdges() []string {
  14833. edges := make([]string, 0, 3)
  14834. if m.sop_task != nil {
  14835. edges = append(edges, sopstage.EdgeSopTask)
  14836. }
  14837. if m.stage_nodes != nil {
  14838. edges = append(edges, sopstage.EdgeStageNodes)
  14839. }
  14840. if m.stage_messages != nil {
  14841. edges = append(edges, sopstage.EdgeStageMessages)
  14842. }
  14843. return edges
  14844. }
  14845. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14846. // name in this mutation.
  14847. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  14848. switch name {
  14849. case sopstage.EdgeSopTask:
  14850. if id := m.sop_task; id != nil {
  14851. return []ent.Value{*id}
  14852. }
  14853. case sopstage.EdgeStageNodes:
  14854. ids := make([]ent.Value, 0, len(m.stage_nodes))
  14855. for id := range m.stage_nodes {
  14856. ids = append(ids, id)
  14857. }
  14858. return ids
  14859. case sopstage.EdgeStageMessages:
  14860. ids := make([]ent.Value, 0, len(m.stage_messages))
  14861. for id := range m.stage_messages {
  14862. ids = append(ids, id)
  14863. }
  14864. return ids
  14865. }
  14866. return nil
  14867. }
  14868. // RemovedEdges returns all edge names that were removed in this mutation.
  14869. func (m *SopStageMutation) RemovedEdges() []string {
  14870. edges := make([]string, 0, 3)
  14871. if m.removedstage_nodes != nil {
  14872. edges = append(edges, sopstage.EdgeStageNodes)
  14873. }
  14874. if m.removedstage_messages != nil {
  14875. edges = append(edges, sopstage.EdgeStageMessages)
  14876. }
  14877. return edges
  14878. }
  14879. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14880. // the given name in this mutation.
  14881. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  14882. switch name {
  14883. case sopstage.EdgeStageNodes:
  14884. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  14885. for id := range m.removedstage_nodes {
  14886. ids = append(ids, id)
  14887. }
  14888. return ids
  14889. case sopstage.EdgeStageMessages:
  14890. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  14891. for id := range m.removedstage_messages {
  14892. ids = append(ids, id)
  14893. }
  14894. return ids
  14895. }
  14896. return nil
  14897. }
  14898. // ClearedEdges returns all edge names that were cleared in this mutation.
  14899. func (m *SopStageMutation) ClearedEdges() []string {
  14900. edges := make([]string, 0, 3)
  14901. if m.clearedsop_task {
  14902. edges = append(edges, sopstage.EdgeSopTask)
  14903. }
  14904. if m.clearedstage_nodes {
  14905. edges = append(edges, sopstage.EdgeStageNodes)
  14906. }
  14907. if m.clearedstage_messages {
  14908. edges = append(edges, sopstage.EdgeStageMessages)
  14909. }
  14910. return edges
  14911. }
  14912. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14913. // was cleared in this mutation.
  14914. func (m *SopStageMutation) EdgeCleared(name string) bool {
  14915. switch name {
  14916. case sopstage.EdgeSopTask:
  14917. return m.clearedsop_task
  14918. case sopstage.EdgeStageNodes:
  14919. return m.clearedstage_nodes
  14920. case sopstage.EdgeStageMessages:
  14921. return m.clearedstage_messages
  14922. }
  14923. return false
  14924. }
  14925. // ClearEdge clears the value of the edge with the given name. It returns an error
  14926. // if that edge is not defined in the schema.
  14927. func (m *SopStageMutation) ClearEdge(name string) error {
  14928. switch name {
  14929. case sopstage.EdgeSopTask:
  14930. m.ClearSopTask()
  14931. return nil
  14932. }
  14933. return fmt.Errorf("unknown SopStage unique edge %s", name)
  14934. }
  14935. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14936. // It returns an error if the edge is not defined in the schema.
  14937. func (m *SopStageMutation) ResetEdge(name string) error {
  14938. switch name {
  14939. case sopstage.EdgeSopTask:
  14940. m.ResetSopTask()
  14941. return nil
  14942. case sopstage.EdgeStageNodes:
  14943. m.ResetStageNodes()
  14944. return nil
  14945. case sopstage.EdgeStageMessages:
  14946. m.ResetStageMessages()
  14947. return nil
  14948. }
  14949. return fmt.Errorf("unknown SopStage edge %s", name)
  14950. }
  14951. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  14952. type SopTaskMutation struct {
  14953. config
  14954. op Op
  14955. typ string
  14956. id *uint64
  14957. created_at *time.Time
  14958. updated_at *time.Time
  14959. status *uint8
  14960. addstatus *int8
  14961. deleted_at *time.Time
  14962. name *string
  14963. bot_wxid_list *[]string
  14964. appendbot_wxid_list []string
  14965. _type *int
  14966. add_type *int
  14967. plan_start_time *time.Time
  14968. plan_end_time *time.Time
  14969. creator_id *string
  14970. organization_id *uint64
  14971. addorganization_id *int64
  14972. clearedFields map[string]struct{}
  14973. task_stages map[uint64]struct{}
  14974. removedtask_stages map[uint64]struct{}
  14975. clearedtask_stages bool
  14976. done bool
  14977. oldValue func(context.Context) (*SopTask, error)
  14978. predicates []predicate.SopTask
  14979. }
  14980. var _ ent.Mutation = (*SopTaskMutation)(nil)
  14981. // soptaskOption allows management of the mutation configuration using functional options.
  14982. type soptaskOption func(*SopTaskMutation)
  14983. // newSopTaskMutation creates new mutation for the SopTask entity.
  14984. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  14985. m := &SopTaskMutation{
  14986. config: c,
  14987. op: op,
  14988. typ: TypeSopTask,
  14989. clearedFields: make(map[string]struct{}),
  14990. }
  14991. for _, opt := range opts {
  14992. opt(m)
  14993. }
  14994. return m
  14995. }
  14996. // withSopTaskID sets the ID field of the mutation.
  14997. func withSopTaskID(id uint64) soptaskOption {
  14998. return func(m *SopTaskMutation) {
  14999. var (
  15000. err error
  15001. once sync.Once
  15002. value *SopTask
  15003. )
  15004. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  15005. once.Do(func() {
  15006. if m.done {
  15007. err = errors.New("querying old values post mutation is not allowed")
  15008. } else {
  15009. value, err = m.Client().SopTask.Get(ctx, id)
  15010. }
  15011. })
  15012. return value, err
  15013. }
  15014. m.id = &id
  15015. }
  15016. }
  15017. // withSopTask sets the old SopTask of the mutation.
  15018. func withSopTask(node *SopTask) soptaskOption {
  15019. return func(m *SopTaskMutation) {
  15020. m.oldValue = func(context.Context) (*SopTask, error) {
  15021. return node, nil
  15022. }
  15023. m.id = &node.ID
  15024. }
  15025. }
  15026. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15027. // executed in a transaction (ent.Tx), a transactional client is returned.
  15028. func (m SopTaskMutation) Client() *Client {
  15029. client := &Client{config: m.config}
  15030. client.init()
  15031. return client
  15032. }
  15033. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15034. // it returns an error otherwise.
  15035. func (m SopTaskMutation) Tx() (*Tx, error) {
  15036. if _, ok := m.driver.(*txDriver); !ok {
  15037. return nil, errors.New("ent: mutation is not running in a transaction")
  15038. }
  15039. tx := &Tx{config: m.config}
  15040. tx.init()
  15041. return tx, nil
  15042. }
  15043. // SetID sets the value of the id field. Note that this
  15044. // operation is only accepted on creation of SopTask entities.
  15045. func (m *SopTaskMutation) SetID(id uint64) {
  15046. m.id = &id
  15047. }
  15048. // ID returns the ID value in the mutation. Note that the ID is only available
  15049. // if it was provided to the builder or after it was returned from the database.
  15050. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  15051. if m.id == nil {
  15052. return
  15053. }
  15054. return *m.id, true
  15055. }
  15056. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15057. // That means, if the mutation is applied within a transaction with an isolation level such
  15058. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15059. // or updated by the mutation.
  15060. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  15061. switch {
  15062. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15063. id, exists := m.ID()
  15064. if exists {
  15065. return []uint64{id}, nil
  15066. }
  15067. fallthrough
  15068. case m.op.Is(OpUpdate | OpDelete):
  15069. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  15070. default:
  15071. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15072. }
  15073. }
  15074. // SetCreatedAt sets the "created_at" field.
  15075. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  15076. m.created_at = &t
  15077. }
  15078. // CreatedAt returns the value of the "created_at" field in the mutation.
  15079. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  15080. v := m.created_at
  15081. if v == nil {
  15082. return
  15083. }
  15084. return *v, true
  15085. }
  15086. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  15087. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15089. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15090. if !m.op.Is(OpUpdateOne) {
  15091. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15092. }
  15093. if m.id == nil || m.oldValue == nil {
  15094. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15095. }
  15096. oldValue, err := m.oldValue(ctx)
  15097. if err != nil {
  15098. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15099. }
  15100. return oldValue.CreatedAt, nil
  15101. }
  15102. // ResetCreatedAt resets all changes to the "created_at" field.
  15103. func (m *SopTaskMutation) ResetCreatedAt() {
  15104. m.created_at = nil
  15105. }
  15106. // SetUpdatedAt sets the "updated_at" field.
  15107. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  15108. m.updated_at = &t
  15109. }
  15110. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15111. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  15112. v := m.updated_at
  15113. if v == nil {
  15114. return
  15115. }
  15116. return *v, true
  15117. }
  15118. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  15119. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15121. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15122. if !m.op.Is(OpUpdateOne) {
  15123. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15124. }
  15125. if m.id == nil || m.oldValue == nil {
  15126. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15127. }
  15128. oldValue, err := m.oldValue(ctx)
  15129. if err != nil {
  15130. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15131. }
  15132. return oldValue.UpdatedAt, nil
  15133. }
  15134. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15135. func (m *SopTaskMutation) ResetUpdatedAt() {
  15136. m.updated_at = nil
  15137. }
  15138. // SetStatus sets the "status" field.
  15139. func (m *SopTaskMutation) SetStatus(u uint8) {
  15140. m.status = &u
  15141. m.addstatus = nil
  15142. }
  15143. // Status returns the value of the "status" field in the mutation.
  15144. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  15145. v := m.status
  15146. if v == nil {
  15147. return
  15148. }
  15149. return *v, true
  15150. }
  15151. // OldStatus returns the old "status" field's value of the SopTask entity.
  15152. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15154. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15155. if !m.op.Is(OpUpdateOne) {
  15156. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15157. }
  15158. if m.id == nil || m.oldValue == nil {
  15159. return v, errors.New("OldStatus requires an ID field in the mutation")
  15160. }
  15161. oldValue, err := m.oldValue(ctx)
  15162. if err != nil {
  15163. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15164. }
  15165. return oldValue.Status, nil
  15166. }
  15167. // AddStatus adds u to the "status" field.
  15168. func (m *SopTaskMutation) AddStatus(u int8) {
  15169. if m.addstatus != nil {
  15170. *m.addstatus += u
  15171. } else {
  15172. m.addstatus = &u
  15173. }
  15174. }
  15175. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15176. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  15177. v := m.addstatus
  15178. if v == nil {
  15179. return
  15180. }
  15181. return *v, true
  15182. }
  15183. // ClearStatus clears the value of the "status" field.
  15184. func (m *SopTaskMutation) ClearStatus() {
  15185. m.status = nil
  15186. m.addstatus = nil
  15187. m.clearedFields[soptask.FieldStatus] = struct{}{}
  15188. }
  15189. // StatusCleared returns if the "status" field was cleared in this mutation.
  15190. func (m *SopTaskMutation) StatusCleared() bool {
  15191. _, ok := m.clearedFields[soptask.FieldStatus]
  15192. return ok
  15193. }
  15194. // ResetStatus resets all changes to the "status" field.
  15195. func (m *SopTaskMutation) ResetStatus() {
  15196. m.status = nil
  15197. m.addstatus = nil
  15198. delete(m.clearedFields, soptask.FieldStatus)
  15199. }
  15200. // SetDeletedAt sets the "deleted_at" field.
  15201. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  15202. m.deleted_at = &t
  15203. }
  15204. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15205. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  15206. v := m.deleted_at
  15207. if v == nil {
  15208. return
  15209. }
  15210. return *v, true
  15211. }
  15212. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  15213. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15215. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15216. if !m.op.Is(OpUpdateOne) {
  15217. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15218. }
  15219. if m.id == nil || m.oldValue == nil {
  15220. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15221. }
  15222. oldValue, err := m.oldValue(ctx)
  15223. if err != nil {
  15224. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15225. }
  15226. return oldValue.DeletedAt, nil
  15227. }
  15228. // ClearDeletedAt clears the value of the "deleted_at" field.
  15229. func (m *SopTaskMutation) ClearDeletedAt() {
  15230. m.deleted_at = nil
  15231. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  15232. }
  15233. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15234. func (m *SopTaskMutation) DeletedAtCleared() bool {
  15235. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  15236. return ok
  15237. }
  15238. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15239. func (m *SopTaskMutation) ResetDeletedAt() {
  15240. m.deleted_at = nil
  15241. delete(m.clearedFields, soptask.FieldDeletedAt)
  15242. }
  15243. // SetName sets the "name" field.
  15244. func (m *SopTaskMutation) SetName(s string) {
  15245. m.name = &s
  15246. }
  15247. // Name returns the value of the "name" field in the mutation.
  15248. func (m *SopTaskMutation) Name() (r string, exists bool) {
  15249. v := m.name
  15250. if v == nil {
  15251. return
  15252. }
  15253. return *v, true
  15254. }
  15255. // OldName returns the old "name" field's value of the SopTask entity.
  15256. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15258. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  15259. if !m.op.Is(OpUpdateOne) {
  15260. return v, errors.New("OldName is only allowed on UpdateOne operations")
  15261. }
  15262. if m.id == nil || m.oldValue == nil {
  15263. return v, errors.New("OldName requires an ID field in the mutation")
  15264. }
  15265. oldValue, err := m.oldValue(ctx)
  15266. if err != nil {
  15267. return v, fmt.Errorf("querying old value for OldName: %w", err)
  15268. }
  15269. return oldValue.Name, nil
  15270. }
  15271. // ResetName resets all changes to the "name" field.
  15272. func (m *SopTaskMutation) ResetName() {
  15273. m.name = nil
  15274. }
  15275. // SetBotWxidList sets the "bot_wxid_list" field.
  15276. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  15277. m.bot_wxid_list = &s
  15278. m.appendbot_wxid_list = nil
  15279. }
  15280. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  15281. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  15282. v := m.bot_wxid_list
  15283. if v == nil {
  15284. return
  15285. }
  15286. return *v, true
  15287. }
  15288. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  15289. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15291. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  15292. if !m.op.Is(OpUpdateOne) {
  15293. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  15294. }
  15295. if m.id == nil || m.oldValue == nil {
  15296. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  15297. }
  15298. oldValue, err := m.oldValue(ctx)
  15299. if err != nil {
  15300. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  15301. }
  15302. return oldValue.BotWxidList, nil
  15303. }
  15304. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  15305. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  15306. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  15307. }
  15308. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  15309. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  15310. if len(m.appendbot_wxid_list) == 0 {
  15311. return nil, false
  15312. }
  15313. return m.appendbot_wxid_list, true
  15314. }
  15315. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  15316. func (m *SopTaskMutation) ClearBotWxidList() {
  15317. m.bot_wxid_list = nil
  15318. m.appendbot_wxid_list = nil
  15319. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  15320. }
  15321. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  15322. func (m *SopTaskMutation) BotWxidListCleared() bool {
  15323. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  15324. return ok
  15325. }
  15326. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  15327. func (m *SopTaskMutation) ResetBotWxidList() {
  15328. m.bot_wxid_list = nil
  15329. m.appendbot_wxid_list = nil
  15330. delete(m.clearedFields, soptask.FieldBotWxidList)
  15331. }
  15332. // SetType sets the "type" field.
  15333. func (m *SopTaskMutation) SetType(i int) {
  15334. m._type = &i
  15335. m.add_type = nil
  15336. }
  15337. // GetType returns the value of the "type" field in the mutation.
  15338. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  15339. v := m._type
  15340. if v == nil {
  15341. return
  15342. }
  15343. return *v, true
  15344. }
  15345. // OldType returns the old "type" field's value of the SopTask entity.
  15346. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15348. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  15349. if !m.op.Is(OpUpdateOne) {
  15350. return v, errors.New("OldType is only allowed on UpdateOne operations")
  15351. }
  15352. if m.id == nil || m.oldValue == nil {
  15353. return v, errors.New("OldType requires an ID field in the mutation")
  15354. }
  15355. oldValue, err := m.oldValue(ctx)
  15356. if err != nil {
  15357. return v, fmt.Errorf("querying old value for OldType: %w", err)
  15358. }
  15359. return oldValue.Type, nil
  15360. }
  15361. // AddType adds i to the "type" field.
  15362. func (m *SopTaskMutation) AddType(i int) {
  15363. if m.add_type != nil {
  15364. *m.add_type += i
  15365. } else {
  15366. m.add_type = &i
  15367. }
  15368. }
  15369. // AddedType returns the value that was added to the "type" field in this mutation.
  15370. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  15371. v := m.add_type
  15372. if v == nil {
  15373. return
  15374. }
  15375. return *v, true
  15376. }
  15377. // ResetType resets all changes to the "type" field.
  15378. func (m *SopTaskMutation) ResetType() {
  15379. m._type = nil
  15380. m.add_type = nil
  15381. }
  15382. // SetPlanStartTime sets the "plan_start_time" field.
  15383. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  15384. m.plan_start_time = &t
  15385. }
  15386. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  15387. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  15388. v := m.plan_start_time
  15389. if v == nil {
  15390. return
  15391. }
  15392. return *v, true
  15393. }
  15394. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  15395. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15397. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  15398. if !m.op.Is(OpUpdateOne) {
  15399. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  15400. }
  15401. if m.id == nil || m.oldValue == nil {
  15402. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  15403. }
  15404. oldValue, err := m.oldValue(ctx)
  15405. if err != nil {
  15406. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  15407. }
  15408. return oldValue.PlanStartTime, nil
  15409. }
  15410. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  15411. func (m *SopTaskMutation) ClearPlanStartTime() {
  15412. m.plan_start_time = nil
  15413. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  15414. }
  15415. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  15416. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  15417. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  15418. return ok
  15419. }
  15420. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  15421. func (m *SopTaskMutation) ResetPlanStartTime() {
  15422. m.plan_start_time = nil
  15423. delete(m.clearedFields, soptask.FieldPlanStartTime)
  15424. }
  15425. // SetPlanEndTime sets the "plan_end_time" field.
  15426. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  15427. m.plan_end_time = &t
  15428. }
  15429. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  15430. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  15431. v := m.plan_end_time
  15432. if v == nil {
  15433. return
  15434. }
  15435. return *v, true
  15436. }
  15437. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  15438. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15440. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  15441. if !m.op.Is(OpUpdateOne) {
  15442. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  15443. }
  15444. if m.id == nil || m.oldValue == nil {
  15445. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  15446. }
  15447. oldValue, err := m.oldValue(ctx)
  15448. if err != nil {
  15449. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  15450. }
  15451. return oldValue.PlanEndTime, nil
  15452. }
  15453. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  15454. func (m *SopTaskMutation) ClearPlanEndTime() {
  15455. m.plan_end_time = nil
  15456. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  15457. }
  15458. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  15459. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  15460. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  15461. return ok
  15462. }
  15463. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  15464. func (m *SopTaskMutation) ResetPlanEndTime() {
  15465. m.plan_end_time = nil
  15466. delete(m.clearedFields, soptask.FieldPlanEndTime)
  15467. }
  15468. // SetCreatorID sets the "creator_id" field.
  15469. func (m *SopTaskMutation) SetCreatorID(s string) {
  15470. m.creator_id = &s
  15471. }
  15472. // CreatorID returns the value of the "creator_id" field in the mutation.
  15473. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  15474. v := m.creator_id
  15475. if v == nil {
  15476. return
  15477. }
  15478. return *v, true
  15479. }
  15480. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  15481. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15482. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15483. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  15484. if !m.op.Is(OpUpdateOne) {
  15485. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  15486. }
  15487. if m.id == nil || m.oldValue == nil {
  15488. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  15489. }
  15490. oldValue, err := m.oldValue(ctx)
  15491. if err != nil {
  15492. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  15493. }
  15494. return oldValue.CreatorID, nil
  15495. }
  15496. // ClearCreatorID clears the value of the "creator_id" field.
  15497. func (m *SopTaskMutation) ClearCreatorID() {
  15498. m.creator_id = nil
  15499. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  15500. }
  15501. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  15502. func (m *SopTaskMutation) CreatorIDCleared() bool {
  15503. _, ok := m.clearedFields[soptask.FieldCreatorID]
  15504. return ok
  15505. }
  15506. // ResetCreatorID resets all changes to the "creator_id" field.
  15507. func (m *SopTaskMutation) ResetCreatorID() {
  15508. m.creator_id = nil
  15509. delete(m.clearedFields, soptask.FieldCreatorID)
  15510. }
  15511. // SetOrganizationID sets the "organization_id" field.
  15512. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  15513. m.organization_id = &u
  15514. m.addorganization_id = nil
  15515. }
  15516. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15517. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  15518. v := m.organization_id
  15519. if v == nil {
  15520. return
  15521. }
  15522. return *v, true
  15523. }
  15524. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  15525. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  15526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15527. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15528. if !m.op.Is(OpUpdateOne) {
  15529. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15530. }
  15531. if m.id == nil || m.oldValue == nil {
  15532. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15533. }
  15534. oldValue, err := m.oldValue(ctx)
  15535. if err != nil {
  15536. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15537. }
  15538. return oldValue.OrganizationID, nil
  15539. }
  15540. // AddOrganizationID adds u to the "organization_id" field.
  15541. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  15542. if m.addorganization_id != nil {
  15543. *m.addorganization_id += u
  15544. } else {
  15545. m.addorganization_id = &u
  15546. }
  15547. }
  15548. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15549. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  15550. v := m.addorganization_id
  15551. if v == nil {
  15552. return
  15553. }
  15554. return *v, true
  15555. }
  15556. // ClearOrganizationID clears the value of the "organization_id" field.
  15557. func (m *SopTaskMutation) ClearOrganizationID() {
  15558. m.organization_id = nil
  15559. m.addorganization_id = nil
  15560. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  15561. }
  15562. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15563. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  15564. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  15565. return ok
  15566. }
  15567. // ResetOrganizationID resets all changes to the "organization_id" field.
  15568. func (m *SopTaskMutation) ResetOrganizationID() {
  15569. m.organization_id = nil
  15570. m.addorganization_id = nil
  15571. delete(m.clearedFields, soptask.FieldOrganizationID)
  15572. }
  15573. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  15574. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  15575. if m.task_stages == nil {
  15576. m.task_stages = make(map[uint64]struct{})
  15577. }
  15578. for i := range ids {
  15579. m.task_stages[ids[i]] = struct{}{}
  15580. }
  15581. }
  15582. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  15583. func (m *SopTaskMutation) ClearTaskStages() {
  15584. m.clearedtask_stages = true
  15585. }
  15586. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  15587. func (m *SopTaskMutation) TaskStagesCleared() bool {
  15588. return m.clearedtask_stages
  15589. }
  15590. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  15591. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  15592. if m.removedtask_stages == nil {
  15593. m.removedtask_stages = make(map[uint64]struct{})
  15594. }
  15595. for i := range ids {
  15596. delete(m.task_stages, ids[i])
  15597. m.removedtask_stages[ids[i]] = struct{}{}
  15598. }
  15599. }
  15600. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  15601. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  15602. for id := range m.removedtask_stages {
  15603. ids = append(ids, id)
  15604. }
  15605. return
  15606. }
  15607. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  15608. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  15609. for id := range m.task_stages {
  15610. ids = append(ids, id)
  15611. }
  15612. return
  15613. }
  15614. // ResetTaskStages resets all changes to the "task_stages" edge.
  15615. func (m *SopTaskMutation) ResetTaskStages() {
  15616. m.task_stages = nil
  15617. m.clearedtask_stages = false
  15618. m.removedtask_stages = nil
  15619. }
  15620. // Where appends a list predicates to the SopTaskMutation builder.
  15621. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  15622. m.predicates = append(m.predicates, ps...)
  15623. }
  15624. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  15625. // users can use type-assertion to append predicates that do not depend on any generated package.
  15626. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  15627. p := make([]predicate.SopTask, len(ps))
  15628. for i := range ps {
  15629. p[i] = ps[i]
  15630. }
  15631. m.Where(p...)
  15632. }
  15633. // Op returns the operation name.
  15634. func (m *SopTaskMutation) Op() Op {
  15635. return m.op
  15636. }
  15637. // SetOp allows setting the mutation operation.
  15638. func (m *SopTaskMutation) SetOp(op Op) {
  15639. m.op = op
  15640. }
  15641. // Type returns the node type of this mutation (SopTask).
  15642. func (m *SopTaskMutation) Type() string {
  15643. return m.typ
  15644. }
  15645. // Fields returns all fields that were changed during this mutation. Note that in
  15646. // order to get all numeric fields that were incremented/decremented, call
  15647. // AddedFields().
  15648. func (m *SopTaskMutation) Fields() []string {
  15649. fields := make([]string, 0, 11)
  15650. if m.created_at != nil {
  15651. fields = append(fields, soptask.FieldCreatedAt)
  15652. }
  15653. if m.updated_at != nil {
  15654. fields = append(fields, soptask.FieldUpdatedAt)
  15655. }
  15656. if m.status != nil {
  15657. fields = append(fields, soptask.FieldStatus)
  15658. }
  15659. if m.deleted_at != nil {
  15660. fields = append(fields, soptask.FieldDeletedAt)
  15661. }
  15662. if m.name != nil {
  15663. fields = append(fields, soptask.FieldName)
  15664. }
  15665. if m.bot_wxid_list != nil {
  15666. fields = append(fields, soptask.FieldBotWxidList)
  15667. }
  15668. if m._type != nil {
  15669. fields = append(fields, soptask.FieldType)
  15670. }
  15671. if m.plan_start_time != nil {
  15672. fields = append(fields, soptask.FieldPlanStartTime)
  15673. }
  15674. if m.plan_end_time != nil {
  15675. fields = append(fields, soptask.FieldPlanEndTime)
  15676. }
  15677. if m.creator_id != nil {
  15678. fields = append(fields, soptask.FieldCreatorID)
  15679. }
  15680. if m.organization_id != nil {
  15681. fields = append(fields, soptask.FieldOrganizationID)
  15682. }
  15683. return fields
  15684. }
  15685. // Field returns the value of a field with the given name. The second boolean
  15686. // return value indicates that this field was not set, or was not defined in the
  15687. // schema.
  15688. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  15689. switch name {
  15690. case soptask.FieldCreatedAt:
  15691. return m.CreatedAt()
  15692. case soptask.FieldUpdatedAt:
  15693. return m.UpdatedAt()
  15694. case soptask.FieldStatus:
  15695. return m.Status()
  15696. case soptask.FieldDeletedAt:
  15697. return m.DeletedAt()
  15698. case soptask.FieldName:
  15699. return m.Name()
  15700. case soptask.FieldBotWxidList:
  15701. return m.BotWxidList()
  15702. case soptask.FieldType:
  15703. return m.GetType()
  15704. case soptask.FieldPlanStartTime:
  15705. return m.PlanStartTime()
  15706. case soptask.FieldPlanEndTime:
  15707. return m.PlanEndTime()
  15708. case soptask.FieldCreatorID:
  15709. return m.CreatorID()
  15710. case soptask.FieldOrganizationID:
  15711. return m.OrganizationID()
  15712. }
  15713. return nil, false
  15714. }
  15715. // OldField returns the old value of the field from the database. An error is
  15716. // returned if the mutation operation is not UpdateOne, or the query to the
  15717. // database failed.
  15718. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15719. switch name {
  15720. case soptask.FieldCreatedAt:
  15721. return m.OldCreatedAt(ctx)
  15722. case soptask.FieldUpdatedAt:
  15723. return m.OldUpdatedAt(ctx)
  15724. case soptask.FieldStatus:
  15725. return m.OldStatus(ctx)
  15726. case soptask.FieldDeletedAt:
  15727. return m.OldDeletedAt(ctx)
  15728. case soptask.FieldName:
  15729. return m.OldName(ctx)
  15730. case soptask.FieldBotWxidList:
  15731. return m.OldBotWxidList(ctx)
  15732. case soptask.FieldType:
  15733. return m.OldType(ctx)
  15734. case soptask.FieldPlanStartTime:
  15735. return m.OldPlanStartTime(ctx)
  15736. case soptask.FieldPlanEndTime:
  15737. return m.OldPlanEndTime(ctx)
  15738. case soptask.FieldCreatorID:
  15739. return m.OldCreatorID(ctx)
  15740. case soptask.FieldOrganizationID:
  15741. return m.OldOrganizationID(ctx)
  15742. }
  15743. return nil, fmt.Errorf("unknown SopTask field %s", name)
  15744. }
  15745. // SetField sets the value of a field with the given name. It returns an error if
  15746. // the field is not defined in the schema, or if the type mismatched the field
  15747. // type.
  15748. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  15749. switch name {
  15750. case soptask.FieldCreatedAt:
  15751. v, ok := value.(time.Time)
  15752. if !ok {
  15753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15754. }
  15755. m.SetCreatedAt(v)
  15756. return nil
  15757. case soptask.FieldUpdatedAt:
  15758. v, ok := value.(time.Time)
  15759. if !ok {
  15760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15761. }
  15762. m.SetUpdatedAt(v)
  15763. return nil
  15764. case soptask.FieldStatus:
  15765. v, ok := value.(uint8)
  15766. if !ok {
  15767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15768. }
  15769. m.SetStatus(v)
  15770. return nil
  15771. case soptask.FieldDeletedAt:
  15772. v, ok := value.(time.Time)
  15773. if !ok {
  15774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15775. }
  15776. m.SetDeletedAt(v)
  15777. return nil
  15778. case soptask.FieldName:
  15779. v, ok := value.(string)
  15780. if !ok {
  15781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15782. }
  15783. m.SetName(v)
  15784. return nil
  15785. case soptask.FieldBotWxidList:
  15786. v, ok := value.([]string)
  15787. if !ok {
  15788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15789. }
  15790. m.SetBotWxidList(v)
  15791. return nil
  15792. case soptask.FieldType:
  15793. v, ok := value.(int)
  15794. if !ok {
  15795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15796. }
  15797. m.SetType(v)
  15798. return nil
  15799. case soptask.FieldPlanStartTime:
  15800. v, ok := value.(time.Time)
  15801. if !ok {
  15802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15803. }
  15804. m.SetPlanStartTime(v)
  15805. return nil
  15806. case soptask.FieldPlanEndTime:
  15807. v, ok := value.(time.Time)
  15808. if !ok {
  15809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15810. }
  15811. m.SetPlanEndTime(v)
  15812. return nil
  15813. case soptask.FieldCreatorID:
  15814. v, ok := value.(string)
  15815. if !ok {
  15816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15817. }
  15818. m.SetCreatorID(v)
  15819. return nil
  15820. case soptask.FieldOrganizationID:
  15821. v, ok := value.(uint64)
  15822. if !ok {
  15823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15824. }
  15825. m.SetOrganizationID(v)
  15826. return nil
  15827. }
  15828. return fmt.Errorf("unknown SopTask field %s", name)
  15829. }
  15830. // AddedFields returns all numeric fields that were incremented/decremented during
  15831. // this mutation.
  15832. func (m *SopTaskMutation) AddedFields() []string {
  15833. var fields []string
  15834. if m.addstatus != nil {
  15835. fields = append(fields, soptask.FieldStatus)
  15836. }
  15837. if m.add_type != nil {
  15838. fields = append(fields, soptask.FieldType)
  15839. }
  15840. if m.addorganization_id != nil {
  15841. fields = append(fields, soptask.FieldOrganizationID)
  15842. }
  15843. return fields
  15844. }
  15845. // AddedField returns the numeric value that was incremented/decremented on a field
  15846. // with the given name. The second boolean return value indicates that this field
  15847. // was not set, or was not defined in the schema.
  15848. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  15849. switch name {
  15850. case soptask.FieldStatus:
  15851. return m.AddedStatus()
  15852. case soptask.FieldType:
  15853. return m.AddedType()
  15854. case soptask.FieldOrganizationID:
  15855. return m.AddedOrganizationID()
  15856. }
  15857. return nil, false
  15858. }
  15859. // AddField adds the value to the field with the given name. It returns an error if
  15860. // the field is not defined in the schema, or if the type mismatched the field
  15861. // type.
  15862. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  15863. switch name {
  15864. case soptask.FieldStatus:
  15865. v, ok := value.(int8)
  15866. if !ok {
  15867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15868. }
  15869. m.AddStatus(v)
  15870. return nil
  15871. case soptask.FieldType:
  15872. v, ok := value.(int)
  15873. if !ok {
  15874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15875. }
  15876. m.AddType(v)
  15877. return nil
  15878. case soptask.FieldOrganizationID:
  15879. v, ok := value.(int64)
  15880. if !ok {
  15881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15882. }
  15883. m.AddOrganizationID(v)
  15884. return nil
  15885. }
  15886. return fmt.Errorf("unknown SopTask numeric field %s", name)
  15887. }
  15888. // ClearedFields returns all nullable fields that were cleared during this
  15889. // mutation.
  15890. func (m *SopTaskMutation) ClearedFields() []string {
  15891. var fields []string
  15892. if m.FieldCleared(soptask.FieldStatus) {
  15893. fields = append(fields, soptask.FieldStatus)
  15894. }
  15895. if m.FieldCleared(soptask.FieldDeletedAt) {
  15896. fields = append(fields, soptask.FieldDeletedAt)
  15897. }
  15898. if m.FieldCleared(soptask.FieldBotWxidList) {
  15899. fields = append(fields, soptask.FieldBotWxidList)
  15900. }
  15901. if m.FieldCleared(soptask.FieldPlanStartTime) {
  15902. fields = append(fields, soptask.FieldPlanStartTime)
  15903. }
  15904. if m.FieldCleared(soptask.FieldPlanEndTime) {
  15905. fields = append(fields, soptask.FieldPlanEndTime)
  15906. }
  15907. if m.FieldCleared(soptask.FieldCreatorID) {
  15908. fields = append(fields, soptask.FieldCreatorID)
  15909. }
  15910. if m.FieldCleared(soptask.FieldOrganizationID) {
  15911. fields = append(fields, soptask.FieldOrganizationID)
  15912. }
  15913. return fields
  15914. }
  15915. // FieldCleared returns a boolean indicating if a field with the given name was
  15916. // cleared in this mutation.
  15917. func (m *SopTaskMutation) FieldCleared(name string) bool {
  15918. _, ok := m.clearedFields[name]
  15919. return ok
  15920. }
  15921. // ClearField clears the value of the field with the given name. It returns an
  15922. // error if the field is not defined in the schema.
  15923. func (m *SopTaskMutation) ClearField(name string) error {
  15924. switch name {
  15925. case soptask.FieldStatus:
  15926. m.ClearStatus()
  15927. return nil
  15928. case soptask.FieldDeletedAt:
  15929. m.ClearDeletedAt()
  15930. return nil
  15931. case soptask.FieldBotWxidList:
  15932. m.ClearBotWxidList()
  15933. return nil
  15934. case soptask.FieldPlanStartTime:
  15935. m.ClearPlanStartTime()
  15936. return nil
  15937. case soptask.FieldPlanEndTime:
  15938. m.ClearPlanEndTime()
  15939. return nil
  15940. case soptask.FieldCreatorID:
  15941. m.ClearCreatorID()
  15942. return nil
  15943. case soptask.FieldOrganizationID:
  15944. m.ClearOrganizationID()
  15945. return nil
  15946. }
  15947. return fmt.Errorf("unknown SopTask nullable field %s", name)
  15948. }
  15949. // ResetField resets all changes in the mutation for the field with the given name.
  15950. // It returns an error if the field is not defined in the schema.
  15951. func (m *SopTaskMutation) ResetField(name string) error {
  15952. switch name {
  15953. case soptask.FieldCreatedAt:
  15954. m.ResetCreatedAt()
  15955. return nil
  15956. case soptask.FieldUpdatedAt:
  15957. m.ResetUpdatedAt()
  15958. return nil
  15959. case soptask.FieldStatus:
  15960. m.ResetStatus()
  15961. return nil
  15962. case soptask.FieldDeletedAt:
  15963. m.ResetDeletedAt()
  15964. return nil
  15965. case soptask.FieldName:
  15966. m.ResetName()
  15967. return nil
  15968. case soptask.FieldBotWxidList:
  15969. m.ResetBotWxidList()
  15970. return nil
  15971. case soptask.FieldType:
  15972. m.ResetType()
  15973. return nil
  15974. case soptask.FieldPlanStartTime:
  15975. m.ResetPlanStartTime()
  15976. return nil
  15977. case soptask.FieldPlanEndTime:
  15978. m.ResetPlanEndTime()
  15979. return nil
  15980. case soptask.FieldCreatorID:
  15981. m.ResetCreatorID()
  15982. return nil
  15983. case soptask.FieldOrganizationID:
  15984. m.ResetOrganizationID()
  15985. return nil
  15986. }
  15987. return fmt.Errorf("unknown SopTask field %s", name)
  15988. }
  15989. // AddedEdges returns all edge names that were set/added in this mutation.
  15990. func (m *SopTaskMutation) AddedEdges() []string {
  15991. edges := make([]string, 0, 1)
  15992. if m.task_stages != nil {
  15993. edges = append(edges, soptask.EdgeTaskStages)
  15994. }
  15995. return edges
  15996. }
  15997. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15998. // name in this mutation.
  15999. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  16000. switch name {
  16001. case soptask.EdgeTaskStages:
  16002. ids := make([]ent.Value, 0, len(m.task_stages))
  16003. for id := range m.task_stages {
  16004. ids = append(ids, id)
  16005. }
  16006. return ids
  16007. }
  16008. return nil
  16009. }
  16010. // RemovedEdges returns all edge names that were removed in this mutation.
  16011. func (m *SopTaskMutation) RemovedEdges() []string {
  16012. edges := make([]string, 0, 1)
  16013. if m.removedtask_stages != nil {
  16014. edges = append(edges, soptask.EdgeTaskStages)
  16015. }
  16016. return edges
  16017. }
  16018. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16019. // the given name in this mutation.
  16020. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  16021. switch name {
  16022. case soptask.EdgeTaskStages:
  16023. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  16024. for id := range m.removedtask_stages {
  16025. ids = append(ids, id)
  16026. }
  16027. return ids
  16028. }
  16029. return nil
  16030. }
  16031. // ClearedEdges returns all edge names that were cleared in this mutation.
  16032. func (m *SopTaskMutation) ClearedEdges() []string {
  16033. edges := make([]string, 0, 1)
  16034. if m.clearedtask_stages {
  16035. edges = append(edges, soptask.EdgeTaskStages)
  16036. }
  16037. return edges
  16038. }
  16039. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16040. // was cleared in this mutation.
  16041. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  16042. switch name {
  16043. case soptask.EdgeTaskStages:
  16044. return m.clearedtask_stages
  16045. }
  16046. return false
  16047. }
  16048. // ClearEdge clears the value of the edge with the given name. It returns an error
  16049. // if that edge is not defined in the schema.
  16050. func (m *SopTaskMutation) ClearEdge(name string) error {
  16051. switch name {
  16052. }
  16053. return fmt.Errorf("unknown SopTask unique edge %s", name)
  16054. }
  16055. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16056. // It returns an error if the edge is not defined in the schema.
  16057. func (m *SopTaskMutation) ResetEdge(name string) error {
  16058. switch name {
  16059. case soptask.EdgeTaskStages:
  16060. m.ResetTaskStages()
  16061. return nil
  16062. }
  16063. return fmt.Errorf("unknown SopTask edge %s", name)
  16064. }
  16065. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  16066. type TokenMutation struct {
  16067. config
  16068. op Op
  16069. typ string
  16070. id *uint64
  16071. created_at *time.Time
  16072. updated_at *time.Time
  16073. deleted_at *time.Time
  16074. expire_at *time.Time
  16075. token *string
  16076. mac *string
  16077. clearedFields map[string]struct{}
  16078. done bool
  16079. oldValue func(context.Context) (*Token, error)
  16080. predicates []predicate.Token
  16081. }
  16082. var _ ent.Mutation = (*TokenMutation)(nil)
  16083. // tokenOption allows management of the mutation configuration using functional options.
  16084. type tokenOption func(*TokenMutation)
  16085. // newTokenMutation creates new mutation for the Token entity.
  16086. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  16087. m := &TokenMutation{
  16088. config: c,
  16089. op: op,
  16090. typ: TypeToken,
  16091. clearedFields: make(map[string]struct{}),
  16092. }
  16093. for _, opt := range opts {
  16094. opt(m)
  16095. }
  16096. return m
  16097. }
  16098. // withTokenID sets the ID field of the mutation.
  16099. func withTokenID(id uint64) tokenOption {
  16100. return func(m *TokenMutation) {
  16101. var (
  16102. err error
  16103. once sync.Once
  16104. value *Token
  16105. )
  16106. m.oldValue = func(ctx context.Context) (*Token, error) {
  16107. once.Do(func() {
  16108. if m.done {
  16109. err = errors.New("querying old values post mutation is not allowed")
  16110. } else {
  16111. value, err = m.Client().Token.Get(ctx, id)
  16112. }
  16113. })
  16114. return value, err
  16115. }
  16116. m.id = &id
  16117. }
  16118. }
  16119. // withToken sets the old Token of the mutation.
  16120. func withToken(node *Token) tokenOption {
  16121. return func(m *TokenMutation) {
  16122. m.oldValue = func(context.Context) (*Token, error) {
  16123. return node, nil
  16124. }
  16125. m.id = &node.ID
  16126. }
  16127. }
  16128. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16129. // executed in a transaction (ent.Tx), a transactional client is returned.
  16130. func (m TokenMutation) Client() *Client {
  16131. client := &Client{config: m.config}
  16132. client.init()
  16133. return client
  16134. }
  16135. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16136. // it returns an error otherwise.
  16137. func (m TokenMutation) Tx() (*Tx, error) {
  16138. if _, ok := m.driver.(*txDriver); !ok {
  16139. return nil, errors.New("ent: mutation is not running in a transaction")
  16140. }
  16141. tx := &Tx{config: m.config}
  16142. tx.init()
  16143. return tx, nil
  16144. }
  16145. // SetID sets the value of the id field. Note that this
  16146. // operation is only accepted on creation of Token entities.
  16147. func (m *TokenMutation) SetID(id uint64) {
  16148. m.id = &id
  16149. }
  16150. // ID returns the ID value in the mutation. Note that the ID is only available
  16151. // if it was provided to the builder or after it was returned from the database.
  16152. func (m *TokenMutation) ID() (id uint64, exists bool) {
  16153. if m.id == nil {
  16154. return
  16155. }
  16156. return *m.id, true
  16157. }
  16158. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16159. // That means, if the mutation is applied within a transaction with an isolation level such
  16160. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16161. // or updated by the mutation.
  16162. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  16163. switch {
  16164. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16165. id, exists := m.ID()
  16166. if exists {
  16167. return []uint64{id}, nil
  16168. }
  16169. fallthrough
  16170. case m.op.Is(OpUpdate | OpDelete):
  16171. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  16172. default:
  16173. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16174. }
  16175. }
  16176. // SetCreatedAt sets the "created_at" field.
  16177. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  16178. m.created_at = &t
  16179. }
  16180. // CreatedAt returns the value of the "created_at" field in the mutation.
  16181. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  16182. v := m.created_at
  16183. if v == nil {
  16184. return
  16185. }
  16186. return *v, true
  16187. }
  16188. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  16189. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16191. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16192. if !m.op.Is(OpUpdateOne) {
  16193. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16194. }
  16195. if m.id == nil || m.oldValue == nil {
  16196. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16197. }
  16198. oldValue, err := m.oldValue(ctx)
  16199. if err != nil {
  16200. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16201. }
  16202. return oldValue.CreatedAt, nil
  16203. }
  16204. // ResetCreatedAt resets all changes to the "created_at" field.
  16205. func (m *TokenMutation) ResetCreatedAt() {
  16206. m.created_at = nil
  16207. }
  16208. // SetUpdatedAt sets the "updated_at" field.
  16209. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  16210. m.updated_at = &t
  16211. }
  16212. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16213. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  16214. v := m.updated_at
  16215. if v == nil {
  16216. return
  16217. }
  16218. return *v, true
  16219. }
  16220. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  16221. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16223. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16224. if !m.op.Is(OpUpdateOne) {
  16225. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16226. }
  16227. if m.id == nil || m.oldValue == nil {
  16228. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16229. }
  16230. oldValue, err := m.oldValue(ctx)
  16231. if err != nil {
  16232. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16233. }
  16234. return oldValue.UpdatedAt, nil
  16235. }
  16236. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16237. func (m *TokenMutation) ResetUpdatedAt() {
  16238. m.updated_at = nil
  16239. }
  16240. // SetDeletedAt sets the "deleted_at" field.
  16241. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  16242. m.deleted_at = &t
  16243. }
  16244. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16245. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  16246. v := m.deleted_at
  16247. if v == nil {
  16248. return
  16249. }
  16250. return *v, true
  16251. }
  16252. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  16253. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16255. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16256. if !m.op.Is(OpUpdateOne) {
  16257. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16258. }
  16259. if m.id == nil || m.oldValue == nil {
  16260. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16261. }
  16262. oldValue, err := m.oldValue(ctx)
  16263. if err != nil {
  16264. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16265. }
  16266. return oldValue.DeletedAt, nil
  16267. }
  16268. // ClearDeletedAt clears the value of the "deleted_at" field.
  16269. func (m *TokenMutation) ClearDeletedAt() {
  16270. m.deleted_at = nil
  16271. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  16272. }
  16273. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16274. func (m *TokenMutation) DeletedAtCleared() bool {
  16275. _, ok := m.clearedFields[token.FieldDeletedAt]
  16276. return ok
  16277. }
  16278. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16279. func (m *TokenMutation) ResetDeletedAt() {
  16280. m.deleted_at = nil
  16281. delete(m.clearedFields, token.FieldDeletedAt)
  16282. }
  16283. // SetExpireAt sets the "expire_at" field.
  16284. func (m *TokenMutation) SetExpireAt(t time.Time) {
  16285. m.expire_at = &t
  16286. }
  16287. // ExpireAt returns the value of the "expire_at" field in the mutation.
  16288. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  16289. v := m.expire_at
  16290. if v == nil {
  16291. return
  16292. }
  16293. return *v, true
  16294. }
  16295. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  16296. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16298. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  16299. if !m.op.Is(OpUpdateOne) {
  16300. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  16301. }
  16302. if m.id == nil || m.oldValue == nil {
  16303. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  16304. }
  16305. oldValue, err := m.oldValue(ctx)
  16306. if err != nil {
  16307. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  16308. }
  16309. return oldValue.ExpireAt, nil
  16310. }
  16311. // ClearExpireAt clears the value of the "expire_at" field.
  16312. func (m *TokenMutation) ClearExpireAt() {
  16313. m.expire_at = nil
  16314. m.clearedFields[token.FieldExpireAt] = struct{}{}
  16315. }
  16316. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  16317. func (m *TokenMutation) ExpireAtCleared() bool {
  16318. _, ok := m.clearedFields[token.FieldExpireAt]
  16319. return ok
  16320. }
  16321. // ResetExpireAt resets all changes to the "expire_at" field.
  16322. func (m *TokenMutation) ResetExpireAt() {
  16323. m.expire_at = nil
  16324. delete(m.clearedFields, token.FieldExpireAt)
  16325. }
  16326. // SetToken sets the "token" field.
  16327. func (m *TokenMutation) SetToken(s string) {
  16328. m.token = &s
  16329. }
  16330. // Token returns the value of the "token" field in the mutation.
  16331. func (m *TokenMutation) Token() (r string, exists bool) {
  16332. v := m.token
  16333. if v == nil {
  16334. return
  16335. }
  16336. return *v, true
  16337. }
  16338. // OldToken returns the old "token" field's value of the Token entity.
  16339. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16340. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16341. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  16342. if !m.op.Is(OpUpdateOne) {
  16343. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  16344. }
  16345. if m.id == nil || m.oldValue == nil {
  16346. return v, errors.New("OldToken requires an ID field in the mutation")
  16347. }
  16348. oldValue, err := m.oldValue(ctx)
  16349. if err != nil {
  16350. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  16351. }
  16352. return oldValue.Token, nil
  16353. }
  16354. // ClearToken clears the value of the "token" field.
  16355. func (m *TokenMutation) ClearToken() {
  16356. m.token = nil
  16357. m.clearedFields[token.FieldToken] = struct{}{}
  16358. }
  16359. // TokenCleared returns if the "token" field was cleared in this mutation.
  16360. func (m *TokenMutation) TokenCleared() bool {
  16361. _, ok := m.clearedFields[token.FieldToken]
  16362. return ok
  16363. }
  16364. // ResetToken resets all changes to the "token" field.
  16365. func (m *TokenMutation) ResetToken() {
  16366. m.token = nil
  16367. delete(m.clearedFields, token.FieldToken)
  16368. }
  16369. // SetMAC sets the "mac" field.
  16370. func (m *TokenMutation) SetMAC(s string) {
  16371. m.mac = &s
  16372. }
  16373. // MAC returns the value of the "mac" field in the mutation.
  16374. func (m *TokenMutation) MAC() (r string, exists bool) {
  16375. v := m.mac
  16376. if v == nil {
  16377. return
  16378. }
  16379. return *v, true
  16380. }
  16381. // OldMAC returns the old "mac" field's value of the Token entity.
  16382. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  16383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16384. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  16385. if !m.op.Is(OpUpdateOne) {
  16386. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  16387. }
  16388. if m.id == nil || m.oldValue == nil {
  16389. return v, errors.New("OldMAC requires an ID field in the mutation")
  16390. }
  16391. oldValue, err := m.oldValue(ctx)
  16392. if err != nil {
  16393. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  16394. }
  16395. return oldValue.MAC, nil
  16396. }
  16397. // ResetMAC resets all changes to the "mac" field.
  16398. func (m *TokenMutation) ResetMAC() {
  16399. m.mac = nil
  16400. }
  16401. // Where appends a list predicates to the TokenMutation builder.
  16402. func (m *TokenMutation) Where(ps ...predicate.Token) {
  16403. m.predicates = append(m.predicates, ps...)
  16404. }
  16405. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  16406. // users can use type-assertion to append predicates that do not depend on any generated package.
  16407. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  16408. p := make([]predicate.Token, len(ps))
  16409. for i := range ps {
  16410. p[i] = ps[i]
  16411. }
  16412. m.Where(p...)
  16413. }
  16414. // Op returns the operation name.
  16415. func (m *TokenMutation) Op() Op {
  16416. return m.op
  16417. }
  16418. // SetOp allows setting the mutation operation.
  16419. func (m *TokenMutation) SetOp(op Op) {
  16420. m.op = op
  16421. }
  16422. // Type returns the node type of this mutation (Token).
  16423. func (m *TokenMutation) Type() string {
  16424. return m.typ
  16425. }
  16426. // Fields returns all fields that were changed during this mutation. Note that in
  16427. // order to get all numeric fields that were incremented/decremented, call
  16428. // AddedFields().
  16429. func (m *TokenMutation) Fields() []string {
  16430. fields := make([]string, 0, 6)
  16431. if m.created_at != nil {
  16432. fields = append(fields, token.FieldCreatedAt)
  16433. }
  16434. if m.updated_at != nil {
  16435. fields = append(fields, token.FieldUpdatedAt)
  16436. }
  16437. if m.deleted_at != nil {
  16438. fields = append(fields, token.FieldDeletedAt)
  16439. }
  16440. if m.expire_at != nil {
  16441. fields = append(fields, token.FieldExpireAt)
  16442. }
  16443. if m.token != nil {
  16444. fields = append(fields, token.FieldToken)
  16445. }
  16446. if m.mac != nil {
  16447. fields = append(fields, token.FieldMAC)
  16448. }
  16449. return fields
  16450. }
  16451. // Field returns the value of a field with the given name. The second boolean
  16452. // return value indicates that this field was not set, or was not defined in the
  16453. // schema.
  16454. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  16455. switch name {
  16456. case token.FieldCreatedAt:
  16457. return m.CreatedAt()
  16458. case token.FieldUpdatedAt:
  16459. return m.UpdatedAt()
  16460. case token.FieldDeletedAt:
  16461. return m.DeletedAt()
  16462. case token.FieldExpireAt:
  16463. return m.ExpireAt()
  16464. case token.FieldToken:
  16465. return m.Token()
  16466. case token.FieldMAC:
  16467. return m.MAC()
  16468. }
  16469. return nil, false
  16470. }
  16471. // OldField returns the old value of the field from the database. An error is
  16472. // returned if the mutation operation is not UpdateOne, or the query to the
  16473. // database failed.
  16474. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16475. switch name {
  16476. case token.FieldCreatedAt:
  16477. return m.OldCreatedAt(ctx)
  16478. case token.FieldUpdatedAt:
  16479. return m.OldUpdatedAt(ctx)
  16480. case token.FieldDeletedAt:
  16481. return m.OldDeletedAt(ctx)
  16482. case token.FieldExpireAt:
  16483. return m.OldExpireAt(ctx)
  16484. case token.FieldToken:
  16485. return m.OldToken(ctx)
  16486. case token.FieldMAC:
  16487. return m.OldMAC(ctx)
  16488. }
  16489. return nil, fmt.Errorf("unknown Token field %s", name)
  16490. }
  16491. // SetField sets the value of a field with the given name. It returns an error if
  16492. // the field is not defined in the schema, or if the type mismatched the field
  16493. // type.
  16494. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  16495. switch name {
  16496. case token.FieldCreatedAt:
  16497. v, ok := value.(time.Time)
  16498. if !ok {
  16499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16500. }
  16501. m.SetCreatedAt(v)
  16502. return nil
  16503. case token.FieldUpdatedAt:
  16504. v, ok := value.(time.Time)
  16505. if !ok {
  16506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16507. }
  16508. m.SetUpdatedAt(v)
  16509. return nil
  16510. case token.FieldDeletedAt:
  16511. v, ok := value.(time.Time)
  16512. if !ok {
  16513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16514. }
  16515. m.SetDeletedAt(v)
  16516. return nil
  16517. case token.FieldExpireAt:
  16518. v, ok := value.(time.Time)
  16519. if !ok {
  16520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16521. }
  16522. m.SetExpireAt(v)
  16523. return nil
  16524. case token.FieldToken:
  16525. v, ok := value.(string)
  16526. if !ok {
  16527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16528. }
  16529. m.SetToken(v)
  16530. return nil
  16531. case token.FieldMAC:
  16532. v, ok := value.(string)
  16533. if !ok {
  16534. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16535. }
  16536. m.SetMAC(v)
  16537. return nil
  16538. }
  16539. return fmt.Errorf("unknown Token field %s", name)
  16540. }
  16541. // AddedFields returns all numeric fields that were incremented/decremented during
  16542. // this mutation.
  16543. func (m *TokenMutation) AddedFields() []string {
  16544. return nil
  16545. }
  16546. // AddedField returns the numeric value that was incremented/decremented on a field
  16547. // with the given name. The second boolean return value indicates that this field
  16548. // was not set, or was not defined in the schema.
  16549. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  16550. return nil, false
  16551. }
  16552. // AddField adds the value to the field with the given name. It returns an error if
  16553. // the field is not defined in the schema, or if the type mismatched the field
  16554. // type.
  16555. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  16556. switch name {
  16557. }
  16558. return fmt.Errorf("unknown Token numeric field %s", name)
  16559. }
  16560. // ClearedFields returns all nullable fields that were cleared during this
  16561. // mutation.
  16562. func (m *TokenMutation) ClearedFields() []string {
  16563. var fields []string
  16564. if m.FieldCleared(token.FieldDeletedAt) {
  16565. fields = append(fields, token.FieldDeletedAt)
  16566. }
  16567. if m.FieldCleared(token.FieldExpireAt) {
  16568. fields = append(fields, token.FieldExpireAt)
  16569. }
  16570. if m.FieldCleared(token.FieldToken) {
  16571. fields = append(fields, token.FieldToken)
  16572. }
  16573. return fields
  16574. }
  16575. // FieldCleared returns a boolean indicating if a field with the given name was
  16576. // cleared in this mutation.
  16577. func (m *TokenMutation) FieldCleared(name string) bool {
  16578. _, ok := m.clearedFields[name]
  16579. return ok
  16580. }
  16581. // ClearField clears the value of the field with the given name. It returns an
  16582. // error if the field is not defined in the schema.
  16583. func (m *TokenMutation) ClearField(name string) error {
  16584. switch name {
  16585. case token.FieldDeletedAt:
  16586. m.ClearDeletedAt()
  16587. return nil
  16588. case token.FieldExpireAt:
  16589. m.ClearExpireAt()
  16590. return nil
  16591. case token.FieldToken:
  16592. m.ClearToken()
  16593. return nil
  16594. }
  16595. return fmt.Errorf("unknown Token nullable field %s", name)
  16596. }
  16597. // ResetField resets all changes in the mutation for the field with the given name.
  16598. // It returns an error if the field is not defined in the schema.
  16599. func (m *TokenMutation) ResetField(name string) error {
  16600. switch name {
  16601. case token.FieldCreatedAt:
  16602. m.ResetCreatedAt()
  16603. return nil
  16604. case token.FieldUpdatedAt:
  16605. m.ResetUpdatedAt()
  16606. return nil
  16607. case token.FieldDeletedAt:
  16608. m.ResetDeletedAt()
  16609. return nil
  16610. case token.FieldExpireAt:
  16611. m.ResetExpireAt()
  16612. return nil
  16613. case token.FieldToken:
  16614. m.ResetToken()
  16615. return nil
  16616. case token.FieldMAC:
  16617. m.ResetMAC()
  16618. return nil
  16619. }
  16620. return fmt.Errorf("unknown Token field %s", name)
  16621. }
  16622. // AddedEdges returns all edge names that were set/added in this mutation.
  16623. func (m *TokenMutation) AddedEdges() []string {
  16624. edges := make([]string, 0, 0)
  16625. return edges
  16626. }
  16627. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16628. // name in this mutation.
  16629. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  16630. return nil
  16631. }
  16632. // RemovedEdges returns all edge names that were removed in this mutation.
  16633. func (m *TokenMutation) RemovedEdges() []string {
  16634. edges := make([]string, 0, 0)
  16635. return edges
  16636. }
  16637. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16638. // the given name in this mutation.
  16639. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  16640. return nil
  16641. }
  16642. // ClearedEdges returns all edge names that were cleared in this mutation.
  16643. func (m *TokenMutation) ClearedEdges() []string {
  16644. edges := make([]string, 0, 0)
  16645. return edges
  16646. }
  16647. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16648. // was cleared in this mutation.
  16649. func (m *TokenMutation) EdgeCleared(name string) bool {
  16650. return false
  16651. }
  16652. // ClearEdge clears the value of the edge with the given name. It returns an error
  16653. // if that edge is not defined in the schema.
  16654. func (m *TokenMutation) ClearEdge(name string) error {
  16655. return fmt.Errorf("unknown Token unique edge %s", name)
  16656. }
  16657. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16658. // It returns an error if the edge is not defined in the schema.
  16659. func (m *TokenMutation) ResetEdge(name string) error {
  16660. return fmt.Errorf("unknown Token edge %s", name)
  16661. }
  16662. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  16663. type TutorialMutation struct {
  16664. config
  16665. op Op
  16666. typ string
  16667. id *uint64
  16668. created_at *time.Time
  16669. updated_at *time.Time
  16670. deleted_at *time.Time
  16671. index *int
  16672. addindex *int
  16673. title *string
  16674. content *string
  16675. organization_id *uint64
  16676. addorganization_id *int64
  16677. clearedFields map[string]struct{}
  16678. employee *uint64
  16679. clearedemployee bool
  16680. done bool
  16681. oldValue func(context.Context) (*Tutorial, error)
  16682. predicates []predicate.Tutorial
  16683. }
  16684. var _ ent.Mutation = (*TutorialMutation)(nil)
  16685. // tutorialOption allows management of the mutation configuration using functional options.
  16686. type tutorialOption func(*TutorialMutation)
  16687. // newTutorialMutation creates new mutation for the Tutorial entity.
  16688. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  16689. m := &TutorialMutation{
  16690. config: c,
  16691. op: op,
  16692. typ: TypeTutorial,
  16693. clearedFields: make(map[string]struct{}),
  16694. }
  16695. for _, opt := range opts {
  16696. opt(m)
  16697. }
  16698. return m
  16699. }
  16700. // withTutorialID sets the ID field of the mutation.
  16701. func withTutorialID(id uint64) tutorialOption {
  16702. return func(m *TutorialMutation) {
  16703. var (
  16704. err error
  16705. once sync.Once
  16706. value *Tutorial
  16707. )
  16708. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  16709. once.Do(func() {
  16710. if m.done {
  16711. err = errors.New("querying old values post mutation is not allowed")
  16712. } else {
  16713. value, err = m.Client().Tutorial.Get(ctx, id)
  16714. }
  16715. })
  16716. return value, err
  16717. }
  16718. m.id = &id
  16719. }
  16720. }
  16721. // withTutorial sets the old Tutorial of the mutation.
  16722. func withTutorial(node *Tutorial) tutorialOption {
  16723. return func(m *TutorialMutation) {
  16724. m.oldValue = func(context.Context) (*Tutorial, error) {
  16725. return node, nil
  16726. }
  16727. m.id = &node.ID
  16728. }
  16729. }
  16730. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16731. // executed in a transaction (ent.Tx), a transactional client is returned.
  16732. func (m TutorialMutation) Client() *Client {
  16733. client := &Client{config: m.config}
  16734. client.init()
  16735. return client
  16736. }
  16737. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16738. // it returns an error otherwise.
  16739. func (m TutorialMutation) Tx() (*Tx, error) {
  16740. if _, ok := m.driver.(*txDriver); !ok {
  16741. return nil, errors.New("ent: mutation is not running in a transaction")
  16742. }
  16743. tx := &Tx{config: m.config}
  16744. tx.init()
  16745. return tx, nil
  16746. }
  16747. // SetID sets the value of the id field. Note that this
  16748. // operation is only accepted on creation of Tutorial entities.
  16749. func (m *TutorialMutation) SetID(id uint64) {
  16750. m.id = &id
  16751. }
  16752. // ID returns the ID value in the mutation. Note that the ID is only available
  16753. // if it was provided to the builder or after it was returned from the database.
  16754. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  16755. if m.id == nil {
  16756. return
  16757. }
  16758. return *m.id, true
  16759. }
  16760. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16761. // That means, if the mutation is applied within a transaction with an isolation level such
  16762. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16763. // or updated by the mutation.
  16764. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  16765. switch {
  16766. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16767. id, exists := m.ID()
  16768. if exists {
  16769. return []uint64{id}, nil
  16770. }
  16771. fallthrough
  16772. case m.op.Is(OpUpdate | OpDelete):
  16773. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  16774. default:
  16775. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16776. }
  16777. }
  16778. // SetCreatedAt sets the "created_at" field.
  16779. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  16780. m.created_at = &t
  16781. }
  16782. // CreatedAt returns the value of the "created_at" field in the mutation.
  16783. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  16784. v := m.created_at
  16785. if v == nil {
  16786. return
  16787. }
  16788. return *v, true
  16789. }
  16790. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  16791. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16793. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16794. if !m.op.Is(OpUpdateOne) {
  16795. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16796. }
  16797. if m.id == nil || m.oldValue == nil {
  16798. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16799. }
  16800. oldValue, err := m.oldValue(ctx)
  16801. if err != nil {
  16802. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16803. }
  16804. return oldValue.CreatedAt, nil
  16805. }
  16806. // ResetCreatedAt resets all changes to the "created_at" field.
  16807. func (m *TutorialMutation) ResetCreatedAt() {
  16808. m.created_at = nil
  16809. }
  16810. // SetUpdatedAt sets the "updated_at" field.
  16811. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  16812. m.updated_at = &t
  16813. }
  16814. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16815. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  16816. v := m.updated_at
  16817. if v == nil {
  16818. return
  16819. }
  16820. return *v, true
  16821. }
  16822. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  16823. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16825. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16826. if !m.op.Is(OpUpdateOne) {
  16827. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16828. }
  16829. if m.id == nil || m.oldValue == nil {
  16830. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16831. }
  16832. oldValue, err := m.oldValue(ctx)
  16833. if err != nil {
  16834. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16835. }
  16836. return oldValue.UpdatedAt, nil
  16837. }
  16838. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16839. func (m *TutorialMutation) ResetUpdatedAt() {
  16840. m.updated_at = nil
  16841. }
  16842. // SetDeletedAt sets the "deleted_at" field.
  16843. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  16844. m.deleted_at = &t
  16845. }
  16846. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16847. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  16848. v := m.deleted_at
  16849. if v == nil {
  16850. return
  16851. }
  16852. return *v, true
  16853. }
  16854. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  16855. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16857. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16858. if !m.op.Is(OpUpdateOne) {
  16859. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16860. }
  16861. if m.id == nil || m.oldValue == nil {
  16862. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16863. }
  16864. oldValue, err := m.oldValue(ctx)
  16865. if err != nil {
  16866. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16867. }
  16868. return oldValue.DeletedAt, nil
  16869. }
  16870. // ClearDeletedAt clears the value of the "deleted_at" field.
  16871. func (m *TutorialMutation) ClearDeletedAt() {
  16872. m.deleted_at = nil
  16873. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  16874. }
  16875. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16876. func (m *TutorialMutation) DeletedAtCleared() bool {
  16877. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  16878. return ok
  16879. }
  16880. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16881. func (m *TutorialMutation) ResetDeletedAt() {
  16882. m.deleted_at = nil
  16883. delete(m.clearedFields, tutorial.FieldDeletedAt)
  16884. }
  16885. // SetEmployeeID sets the "employee_id" field.
  16886. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  16887. m.employee = &u
  16888. }
  16889. // EmployeeID returns the value of the "employee_id" field in the mutation.
  16890. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  16891. v := m.employee
  16892. if v == nil {
  16893. return
  16894. }
  16895. return *v, true
  16896. }
  16897. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  16898. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16900. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  16901. if !m.op.Is(OpUpdateOne) {
  16902. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  16903. }
  16904. if m.id == nil || m.oldValue == nil {
  16905. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  16906. }
  16907. oldValue, err := m.oldValue(ctx)
  16908. if err != nil {
  16909. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  16910. }
  16911. return oldValue.EmployeeID, nil
  16912. }
  16913. // ResetEmployeeID resets all changes to the "employee_id" field.
  16914. func (m *TutorialMutation) ResetEmployeeID() {
  16915. m.employee = nil
  16916. }
  16917. // SetIndex sets the "index" field.
  16918. func (m *TutorialMutation) SetIndex(i int) {
  16919. m.index = &i
  16920. m.addindex = nil
  16921. }
  16922. // Index returns the value of the "index" field in the mutation.
  16923. func (m *TutorialMutation) Index() (r int, exists bool) {
  16924. v := m.index
  16925. if v == nil {
  16926. return
  16927. }
  16928. return *v, true
  16929. }
  16930. // OldIndex returns the old "index" field's value of the Tutorial entity.
  16931. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16933. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  16934. if !m.op.Is(OpUpdateOne) {
  16935. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  16936. }
  16937. if m.id == nil || m.oldValue == nil {
  16938. return v, errors.New("OldIndex requires an ID field in the mutation")
  16939. }
  16940. oldValue, err := m.oldValue(ctx)
  16941. if err != nil {
  16942. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  16943. }
  16944. return oldValue.Index, nil
  16945. }
  16946. // AddIndex adds i to the "index" field.
  16947. func (m *TutorialMutation) AddIndex(i int) {
  16948. if m.addindex != nil {
  16949. *m.addindex += i
  16950. } else {
  16951. m.addindex = &i
  16952. }
  16953. }
  16954. // AddedIndex returns the value that was added to the "index" field in this mutation.
  16955. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  16956. v := m.addindex
  16957. if v == nil {
  16958. return
  16959. }
  16960. return *v, true
  16961. }
  16962. // ResetIndex resets all changes to the "index" field.
  16963. func (m *TutorialMutation) ResetIndex() {
  16964. m.index = nil
  16965. m.addindex = nil
  16966. }
  16967. // SetTitle sets the "title" field.
  16968. func (m *TutorialMutation) SetTitle(s string) {
  16969. m.title = &s
  16970. }
  16971. // Title returns the value of the "title" field in the mutation.
  16972. func (m *TutorialMutation) Title() (r string, exists bool) {
  16973. v := m.title
  16974. if v == nil {
  16975. return
  16976. }
  16977. return *v, true
  16978. }
  16979. // OldTitle returns the old "title" field's value of the Tutorial entity.
  16980. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16981. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16982. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  16983. if !m.op.Is(OpUpdateOne) {
  16984. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  16985. }
  16986. if m.id == nil || m.oldValue == nil {
  16987. return v, errors.New("OldTitle requires an ID field in the mutation")
  16988. }
  16989. oldValue, err := m.oldValue(ctx)
  16990. if err != nil {
  16991. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  16992. }
  16993. return oldValue.Title, nil
  16994. }
  16995. // ResetTitle resets all changes to the "title" field.
  16996. func (m *TutorialMutation) ResetTitle() {
  16997. m.title = nil
  16998. }
  16999. // SetContent sets the "content" field.
  17000. func (m *TutorialMutation) SetContent(s string) {
  17001. m.content = &s
  17002. }
  17003. // Content returns the value of the "content" field in the mutation.
  17004. func (m *TutorialMutation) Content() (r string, exists bool) {
  17005. v := m.content
  17006. if v == nil {
  17007. return
  17008. }
  17009. return *v, true
  17010. }
  17011. // OldContent returns the old "content" field's value of the Tutorial entity.
  17012. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  17013. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17014. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  17015. if !m.op.Is(OpUpdateOne) {
  17016. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  17017. }
  17018. if m.id == nil || m.oldValue == nil {
  17019. return v, errors.New("OldContent requires an ID field in the mutation")
  17020. }
  17021. oldValue, err := m.oldValue(ctx)
  17022. if err != nil {
  17023. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  17024. }
  17025. return oldValue.Content, nil
  17026. }
  17027. // ResetContent resets all changes to the "content" field.
  17028. func (m *TutorialMutation) ResetContent() {
  17029. m.content = nil
  17030. }
  17031. // SetOrganizationID sets the "organization_id" field.
  17032. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  17033. m.organization_id = &u
  17034. m.addorganization_id = nil
  17035. }
  17036. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17037. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  17038. v := m.organization_id
  17039. if v == nil {
  17040. return
  17041. }
  17042. return *v, true
  17043. }
  17044. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  17045. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  17046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17047. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17048. if !m.op.Is(OpUpdateOne) {
  17049. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17050. }
  17051. if m.id == nil || m.oldValue == nil {
  17052. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17053. }
  17054. oldValue, err := m.oldValue(ctx)
  17055. if err != nil {
  17056. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17057. }
  17058. return oldValue.OrganizationID, nil
  17059. }
  17060. // AddOrganizationID adds u to the "organization_id" field.
  17061. func (m *TutorialMutation) AddOrganizationID(u int64) {
  17062. if m.addorganization_id != nil {
  17063. *m.addorganization_id += u
  17064. } else {
  17065. m.addorganization_id = &u
  17066. }
  17067. }
  17068. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17069. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  17070. v := m.addorganization_id
  17071. if v == nil {
  17072. return
  17073. }
  17074. return *v, true
  17075. }
  17076. // ResetOrganizationID resets all changes to the "organization_id" field.
  17077. func (m *TutorialMutation) ResetOrganizationID() {
  17078. m.organization_id = nil
  17079. m.addorganization_id = nil
  17080. }
  17081. // ClearEmployee clears the "employee" edge to the Employee entity.
  17082. func (m *TutorialMutation) ClearEmployee() {
  17083. m.clearedemployee = true
  17084. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  17085. }
  17086. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  17087. func (m *TutorialMutation) EmployeeCleared() bool {
  17088. return m.clearedemployee
  17089. }
  17090. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  17091. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17092. // EmployeeID instead. It exists only for internal usage by the builders.
  17093. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  17094. if id := m.employee; id != nil {
  17095. ids = append(ids, *id)
  17096. }
  17097. return
  17098. }
  17099. // ResetEmployee resets all changes to the "employee" edge.
  17100. func (m *TutorialMutation) ResetEmployee() {
  17101. m.employee = nil
  17102. m.clearedemployee = false
  17103. }
  17104. // Where appends a list predicates to the TutorialMutation builder.
  17105. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  17106. m.predicates = append(m.predicates, ps...)
  17107. }
  17108. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  17109. // users can use type-assertion to append predicates that do not depend on any generated package.
  17110. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  17111. p := make([]predicate.Tutorial, len(ps))
  17112. for i := range ps {
  17113. p[i] = ps[i]
  17114. }
  17115. m.Where(p...)
  17116. }
  17117. // Op returns the operation name.
  17118. func (m *TutorialMutation) Op() Op {
  17119. return m.op
  17120. }
  17121. // SetOp allows setting the mutation operation.
  17122. func (m *TutorialMutation) SetOp(op Op) {
  17123. m.op = op
  17124. }
  17125. // Type returns the node type of this mutation (Tutorial).
  17126. func (m *TutorialMutation) Type() string {
  17127. return m.typ
  17128. }
  17129. // Fields returns all fields that were changed during this mutation. Note that in
  17130. // order to get all numeric fields that were incremented/decremented, call
  17131. // AddedFields().
  17132. func (m *TutorialMutation) Fields() []string {
  17133. fields := make([]string, 0, 8)
  17134. if m.created_at != nil {
  17135. fields = append(fields, tutorial.FieldCreatedAt)
  17136. }
  17137. if m.updated_at != nil {
  17138. fields = append(fields, tutorial.FieldUpdatedAt)
  17139. }
  17140. if m.deleted_at != nil {
  17141. fields = append(fields, tutorial.FieldDeletedAt)
  17142. }
  17143. if m.employee != nil {
  17144. fields = append(fields, tutorial.FieldEmployeeID)
  17145. }
  17146. if m.index != nil {
  17147. fields = append(fields, tutorial.FieldIndex)
  17148. }
  17149. if m.title != nil {
  17150. fields = append(fields, tutorial.FieldTitle)
  17151. }
  17152. if m.content != nil {
  17153. fields = append(fields, tutorial.FieldContent)
  17154. }
  17155. if m.organization_id != nil {
  17156. fields = append(fields, tutorial.FieldOrganizationID)
  17157. }
  17158. return fields
  17159. }
  17160. // Field returns the value of a field with the given name. The second boolean
  17161. // return value indicates that this field was not set, or was not defined in the
  17162. // schema.
  17163. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  17164. switch name {
  17165. case tutorial.FieldCreatedAt:
  17166. return m.CreatedAt()
  17167. case tutorial.FieldUpdatedAt:
  17168. return m.UpdatedAt()
  17169. case tutorial.FieldDeletedAt:
  17170. return m.DeletedAt()
  17171. case tutorial.FieldEmployeeID:
  17172. return m.EmployeeID()
  17173. case tutorial.FieldIndex:
  17174. return m.Index()
  17175. case tutorial.FieldTitle:
  17176. return m.Title()
  17177. case tutorial.FieldContent:
  17178. return m.Content()
  17179. case tutorial.FieldOrganizationID:
  17180. return m.OrganizationID()
  17181. }
  17182. return nil, false
  17183. }
  17184. // OldField returns the old value of the field from the database. An error is
  17185. // returned if the mutation operation is not UpdateOne, or the query to the
  17186. // database failed.
  17187. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17188. switch name {
  17189. case tutorial.FieldCreatedAt:
  17190. return m.OldCreatedAt(ctx)
  17191. case tutorial.FieldUpdatedAt:
  17192. return m.OldUpdatedAt(ctx)
  17193. case tutorial.FieldDeletedAt:
  17194. return m.OldDeletedAt(ctx)
  17195. case tutorial.FieldEmployeeID:
  17196. return m.OldEmployeeID(ctx)
  17197. case tutorial.FieldIndex:
  17198. return m.OldIndex(ctx)
  17199. case tutorial.FieldTitle:
  17200. return m.OldTitle(ctx)
  17201. case tutorial.FieldContent:
  17202. return m.OldContent(ctx)
  17203. case tutorial.FieldOrganizationID:
  17204. return m.OldOrganizationID(ctx)
  17205. }
  17206. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  17207. }
  17208. // SetField sets the value of a field with the given name. It returns an error if
  17209. // the field is not defined in the schema, or if the type mismatched the field
  17210. // type.
  17211. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  17212. switch name {
  17213. case tutorial.FieldCreatedAt:
  17214. v, ok := value.(time.Time)
  17215. if !ok {
  17216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17217. }
  17218. m.SetCreatedAt(v)
  17219. return nil
  17220. case tutorial.FieldUpdatedAt:
  17221. v, ok := value.(time.Time)
  17222. if !ok {
  17223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17224. }
  17225. m.SetUpdatedAt(v)
  17226. return nil
  17227. case tutorial.FieldDeletedAt:
  17228. v, ok := value.(time.Time)
  17229. if !ok {
  17230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17231. }
  17232. m.SetDeletedAt(v)
  17233. return nil
  17234. case tutorial.FieldEmployeeID:
  17235. v, ok := value.(uint64)
  17236. if !ok {
  17237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17238. }
  17239. m.SetEmployeeID(v)
  17240. return nil
  17241. case tutorial.FieldIndex:
  17242. v, ok := value.(int)
  17243. if !ok {
  17244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17245. }
  17246. m.SetIndex(v)
  17247. return nil
  17248. case tutorial.FieldTitle:
  17249. v, ok := value.(string)
  17250. if !ok {
  17251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17252. }
  17253. m.SetTitle(v)
  17254. return nil
  17255. case tutorial.FieldContent:
  17256. v, ok := value.(string)
  17257. if !ok {
  17258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17259. }
  17260. m.SetContent(v)
  17261. return nil
  17262. case tutorial.FieldOrganizationID:
  17263. v, ok := value.(uint64)
  17264. if !ok {
  17265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17266. }
  17267. m.SetOrganizationID(v)
  17268. return nil
  17269. }
  17270. return fmt.Errorf("unknown Tutorial field %s", name)
  17271. }
  17272. // AddedFields returns all numeric fields that were incremented/decremented during
  17273. // this mutation.
  17274. func (m *TutorialMutation) AddedFields() []string {
  17275. var fields []string
  17276. if m.addindex != nil {
  17277. fields = append(fields, tutorial.FieldIndex)
  17278. }
  17279. if m.addorganization_id != nil {
  17280. fields = append(fields, tutorial.FieldOrganizationID)
  17281. }
  17282. return fields
  17283. }
  17284. // AddedField returns the numeric value that was incremented/decremented on a field
  17285. // with the given name. The second boolean return value indicates that this field
  17286. // was not set, or was not defined in the schema.
  17287. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  17288. switch name {
  17289. case tutorial.FieldIndex:
  17290. return m.AddedIndex()
  17291. case tutorial.FieldOrganizationID:
  17292. return m.AddedOrganizationID()
  17293. }
  17294. return nil, false
  17295. }
  17296. // AddField adds the value to the field with the given name. It returns an error if
  17297. // the field is not defined in the schema, or if the type mismatched the field
  17298. // type.
  17299. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  17300. switch name {
  17301. case tutorial.FieldIndex:
  17302. v, ok := value.(int)
  17303. if !ok {
  17304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17305. }
  17306. m.AddIndex(v)
  17307. return nil
  17308. case tutorial.FieldOrganizationID:
  17309. v, ok := value.(int64)
  17310. if !ok {
  17311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17312. }
  17313. m.AddOrganizationID(v)
  17314. return nil
  17315. }
  17316. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  17317. }
  17318. // ClearedFields returns all nullable fields that were cleared during this
  17319. // mutation.
  17320. func (m *TutorialMutation) ClearedFields() []string {
  17321. var fields []string
  17322. if m.FieldCleared(tutorial.FieldDeletedAt) {
  17323. fields = append(fields, tutorial.FieldDeletedAt)
  17324. }
  17325. return fields
  17326. }
  17327. // FieldCleared returns a boolean indicating if a field with the given name was
  17328. // cleared in this mutation.
  17329. func (m *TutorialMutation) FieldCleared(name string) bool {
  17330. _, ok := m.clearedFields[name]
  17331. return ok
  17332. }
  17333. // ClearField clears the value of the field with the given name. It returns an
  17334. // error if the field is not defined in the schema.
  17335. func (m *TutorialMutation) ClearField(name string) error {
  17336. switch name {
  17337. case tutorial.FieldDeletedAt:
  17338. m.ClearDeletedAt()
  17339. return nil
  17340. }
  17341. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  17342. }
  17343. // ResetField resets all changes in the mutation for the field with the given name.
  17344. // It returns an error if the field is not defined in the schema.
  17345. func (m *TutorialMutation) ResetField(name string) error {
  17346. switch name {
  17347. case tutorial.FieldCreatedAt:
  17348. m.ResetCreatedAt()
  17349. return nil
  17350. case tutorial.FieldUpdatedAt:
  17351. m.ResetUpdatedAt()
  17352. return nil
  17353. case tutorial.FieldDeletedAt:
  17354. m.ResetDeletedAt()
  17355. return nil
  17356. case tutorial.FieldEmployeeID:
  17357. m.ResetEmployeeID()
  17358. return nil
  17359. case tutorial.FieldIndex:
  17360. m.ResetIndex()
  17361. return nil
  17362. case tutorial.FieldTitle:
  17363. m.ResetTitle()
  17364. return nil
  17365. case tutorial.FieldContent:
  17366. m.ResetContent()
  17367. return nil
  17368. case tutorial.FieldOrganizationID:
  17369. m.ResetOrganizationID()
  17370. return nil
  17371. }
  17372. return fmt.Errorf("unknown Tutorial field %s", name)
  17373. }
  17374. // AddedEdges returns all edge names that were set/added in this mutation.
  17375. func (m *TutorialMutation) AddedEdges() []string {
  17376. edges := make([]string, 0, 1)
  17377. if m.employee != nil {
  17378. edges = append(edges, tutorial.EdgeEmployee)
  17379. }
  17380. return edges
  17381. }
  17382. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17383. // name in this mutation.
  17384. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  17385. switch name {
  17386. case tutorial.EdgeEmployee:
  17387. if id := m.employee; id != nil {
  17388. return []ent.Value{*id}
  17389. }
  17390. }
  17391. return nil
  17392. }
  17393. // RemovedEdges returns all edge names that were removed in this mutation.
  17394. func (m *TutorialMutation) RemovedEdges() []string {
  17395. edges := make([]string, 0, 1)
  17396. return edges
  17397. }
  17398. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17399. // the given name in this mutation.
  17400. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  17401. return nil
  17402. }
  17403. // ClearedEdges returns all edge names that were cleared in this mutation.
  17404. func (m *TutorialMutation) ClearedEdges() []string {
  17405. edges := make([]string, 0, 1)
  17406. if m.clearedemployee {
  17407. edges = append(edges, tutorial.EdgeEmployee)
  17408. }
  17409. return edges
  17410. }
  17411. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17412. // was cleared in this mutation.
  17413. func (m *TutorialMutation) EdgeCleared(name string) bool {
  17414. switch name {
  17415. case tutorial.EdgeEmployee:
  17416. return m.clearedemployee
  17417. }
  17418. return false
  17419. }
  17420. // ClearEdge clears the value of the edge with the given name. It returns an error
  17421. // if that edge is not defined in the schema.
  17422. func (m *TutorialMutation) ClearEdge(name string) error {
  17423. switch name {
  17424. case tutorial.EdgeEmployee:
  17425. m.ClearEmployee()
  17426. return nil
  17427. }
  17428. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  17429. }
  17430. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17431. // It returns an error if the edge is not defined in the schema.
  17432. func (m *TutorialMutation) ResetEdge(name string) error {
  17433. switch name {
  17434. case tutorial.EdgeEmployee:
  17435. m.ResetEmployee()
  17436. return nil
  17437. }
  17438. return fmt.Errorf("unknown Tutorial edge %s", name)
  17439. }
  17440. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  17441. type WorkExperienceMutation struct {
  17442. config
  17443. op Op
  17444. typ string
  17445. id *uint64
  17446. created_at *time.Time
  17447. updated_at *time.Time
  17448. deleted_at *time.Time
  17449. start_date *time.Time
  17450. end_date *time.Time
  17451. company *string
  17452. experience *string
  17453. organization_id *uint64
  17454. addorganization_id *int64
  17455. clearedFields map[string]struct{}
  17456. employee *uint64
  17457. clearedemployee bool
  17458. done bool
  17459. oldValue func(context.Context) (*WorkExperience, error)
  17460. predicates []predicate.WorkExperience
  17461. }
  17462. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  17463. // workexperienceOption allows management of the mutation configuration using functional options.
  17464. type workexperienceOption func(*WorkExperienceMutation)
  17465. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  17466. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  17467. m := &WorkExperienceMutation{
  17468. config: c,
  17469. op: op,
  17470. typ: TypeWorkExperience,
  17471. clearedFields: make(map[string]struct{}),
  17472. }
  17473. for _, opt := range opts {
  17474. opt(m)
  17475. }
  17476. return m
  17477. }
  17478. // withWorkExperienceID sets the ID field of the mutation.
  17479. func withWorkExperienceID(id uint64) workexperienceOption {
  17480. return func(m *WorkExperienceMutation) {
  17481. var (
  17482. err error
  17483. once sync.Once
  17484. value *WorkExperience
  17485. )
  17486. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  17487. once.Do(func() {
  17488. if m.done {
  17489. err = errors.New("querying old values post mutation is not allowed")
  17490. } else {
  17491. value, err = m.Client().WorkExperience.Get(ctx, id)
  17492. }
  17493. })
  17494. return value, err
  17495. }
  17496. m.id = &id
  17497. }
  17498. }
  17499. // withWorkExperience sets the old WorkExperience of the mutation.
  17500. func withWorkExperience(node *WorkExperience) workexperienceOption {
  17501. return func(m *WorkExperienceMutation) {
  17502. m.oldValue = func(context.Context) (*WorkExperience, error) {
  17503. return node, nil
  17504. }
  17505. m.id = &node.ID
  17506. }
  17507. }
  17508. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17509. // executed in a transaction (ent.Tx), a transactional client is returned.
  17510. func (m WorkExperienceMutation) Client() *Client {
  17511. client := &Client{config: m.config}
  17512. client.init()
  17513. return client
  17514. }
  17515. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17516. // it returns an error otherwise.
  17517. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  17518. if _, ok := m.driver.(*txDriver); !ok {
  17519. return nil, errors.New("ent: mutation is not running in a transaction")
  17520. }
  17521. tx := &Tx{config: m.config}
  17522. tx.init()
  17523. return tx, nil
  17524. }
  17525. // SetID sets the value of the id field. Note that this
  17526. // operation is only accepted on creation of WorkExperience entities.
  17527. func (m *WorkExperienceMutation) SetID(id uint64) {
  17528. m.id = &id
  17529. }
  17530. // ID returns the ID value in the mutation. Note that the ID is only available
  17531. // if it was provided to the builder or after it was returned from the database.
  17532. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  17533. if m.id == nil {
  17534. return
  17535. }
  17536. return *m.id, true
  17537. }
  17538. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17539. // That means, if the mutation is applied within a transaction with an isolation level such
  17540. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17541. // or updated by the mutation.
  17542. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  17543. switch {
  17544. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17545. id, exists := m.ID()
  17546. if exists {
  17547. return []uint64{id}, nil
  17548. }
  17549. fallthrough
  17550. case m.op.Is(OpUpdate | OpDelete):
  17551. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  17552. default:
  17553. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17554. }
  17555. }
  17556. // SetCreatedAt sets the "created_at" field.
  17557. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  17558. m.created_at = &t
  17559. }
  17560. // CreatedAt returns the value of the "created_at" field in the mutation.
  17561. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  17562. v := m.created_at
  17563. if v == nil {
  17564. return
  17565. }
  17566. return *v, true
  17567. }
  17568. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  17569. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17571. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17572. if !m.op.Is(OpUpdateOne) {
  17573. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17574. }
  17575. if m.id == nil || m.oldValue == nil {
  17576. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17577. }
  17578. oldValue, err := m.oldValue(ctx)
  17579. if err != nil {
  17580. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17581. }
  17582. return oldValue.CreatedAt, nil
  17583. }
  17584. // ResetCreatedAt resets all changes to the "created_at" field.
  17585. func (m *WorkExperienceMutation) ResetCreatedAt() {
  17586. m.created_at = nil
  17587. }
  17588. // SetUpdatedAt sets the "updated_at" field.
  17589. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  17590. m.updated_at = &t
  17591. }
  17592. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17593. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  17594. v := m.updated_at
  17595. if v == nil {
  17596. return
  17597. }
  17598. return *v, true
  17599. }
  17600. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  17601. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17603. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17604. if !m.op.Is(OpUpdateOne) {
  17605. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17606. }
  17607. if m.id == nil || m.oldValue == nil {
  17608. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17609. }
  17610. oldValue, err := m.oldValue(ctx)
  17611. if err != nil {
  17612. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17613. }
  17614. return oldValue.UpdatedAt, nil
  17615. }
  17616. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17617. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  17618. m.updated_at = nil
  17619. }
  17620. // SetDeletedAt sets the "deleted_at" field.
  17621. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  17622. m.deleted_at = &t
  17623. }
  17624. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17625. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  17626. v := m.deleted_at
  17627. if v == nil {
  17628. return
  17629. }
  17630. return *v, true
  17631. }
  17632. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  17633. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17635. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17636. if !m.op.Is(OpUpdateOne) {
  17637. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17638. }
  17639. if m.id == nil || m.oldValue == nil {
  17640. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17641. }
  17642. oldValue, err := m.oldValue(ctx)
  17643. if err != nil {
  17644. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17645. }
  17646. return oldValue.DeletedAt, nil
  17647. }
  17648. // ClearDeletedAt clears the value of the "deleted_at" field.
  17649. func (m *WorkExperienceMutation) ClearDeletedAt() {
  17650. m.deleted_at = nil
  17651. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  17652. }
  17653. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17654. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  17655. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  17656. return ok
  17657. }
  17658. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17659. func (m *WorkExperienceMutation) ResetDeletedAt() {
  17660. m.deleted_at = nil
  17661. delete(m.clearedFields, workexperience.FieldDeletedAt)
  17662. }
  17663. // SetEmployeeID sets the "employee_id" field.
  17664. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  17665. m.employee = &u
  17666. }
  17667. // EmployeeID returns the value of the "employee_id" field in the mutation.
  17668. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  17669. v := m.employee
  17670. if v == nil {
  17671. return
  17672. }
  17673. return *v, true
  17674. }
  17675. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  17676. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17678. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  17679. if !m.op.Is(OpUpdateOne) {
  17680. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  17681. }
  17682. if m.id == nil || m.oldValue == nil {
  17683. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  17684. }
  17685. oldValue, err := m.oldValue(ctx)
  17686. if err != nil {
  17687. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  17688. }
  17689. return oldValue.EmployeeID, nil
  17690. }
  17691. // ResetEmployeeID resets all changes to the "employee_id" field.
  17692. func (m *WorkExperienceMutation) ResetEmployeeID() {
  17693. m.employee = nil
  17694. }
  17695. // SetStartDate sets the "start_date" field.
  17696. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  17697. m.start_date = &t
  17698. }
  17699. // StartDate returns the value of the "start_date" field in the mutation.
  17700. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  17701. v := m.start_date
  17702. if v == nil {
  17703. return
  17704. }
  17705. return *v, true
  17706. }
  17707. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  17708. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17710. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  17711. if !m.op.Is(OpUpdateOne) {
  17712. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  17713. }
  17714. if m.id == nil || m.oldValue == nil {
  17715. return v, errors.New("OldStartDate requires an ID field in the mutation")
  17716. }
  17717. oldValue, err := m.oldValue(ctx)
  17718. if err != nil {
  17719. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  17720. }
  17721. return oldValue.StartDate, nil
  17722. }
  17723. // ResetStartDate resets all changes to the "start_date" field.
  17724. func (m *WorkExperienceMutation) ResetStartDate() {
  17725. m.start_date = nil
  17726. }
  17727. // SetEndDate sets the "end_date" field.
  17728. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  17729. m.end_date = &t
  17730. }
  17731. // EndDate returns the value of the "end_date" field in the mutation.
  17732. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  17733. v := m.end_date
  17734. if v == nil {
  17735. return
  17736. }
  17737. return *v, true
  17738. }
  17739. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  17740. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17742. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  17743. if !m.op.Is(OpUpdateOne) {
  17744. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  17745. }
  17746. if m.id == nil || m.oldValue == nil {
  17747. return v, errors.New("OldEndDate requires an ID field in the mutation")
  17748. }
  17749. oldValue, err := m.oldValue(ctx)
  17750. if err != nil {
  17751. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  17752. }
  17753. return oldValue.EndDate, nil
  17754. }
  17755. // ResetEndDate resets all changes to the "end_date" field.
  17756. func (m *WorkExperienceMutation) ResetEndDate() {
  17757. m.end_date = nil
  17758. }
  17759. // SetCompany sets the "company" field.
  17760. func (m *WorkExperienceMutation) SetCompany(s string) {
  17761. m.company = &s
  17762. }
  17763. // Company returns the value of the "company" field in the mutation.
  17764. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  17765. v := m.company
  17766. if v == nil {
  17767. return
  17768. }
  17769. return *v, true
  17770. }
  17771. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  17772. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17774. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  17775. if !m.op.Is(OpUpdateOne) {
  17776. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  17777. }
  17778. if m.id == nil || m.oldValue == nil {
  17779. return v, errors.New("OldCompany requires an ID field in the mutation")
  17780. }
  17781. oldValue, err := m.oldValue(ctx)
  17782. if err != nil {
  17783. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  17784. }
  17785. return oldValue.Company, nil
  17786. }
  17787. // ResetCompany resets all changes to the "company" field.
  17788. func (m *WorkExperienceMutation) ResetCompany() {
  17789. m.company = nil
  17790. }
  17791. // SetExperience sets the "experience" field.
  17792. func (m *WorkExperienceMutation) SetExperience(s string) {
  17793. m.experience = &s
  17794. }
  17795. // Experience returns the value of the "experience" field in the mutation.
  17796. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  17797. v := m.experience
  17798. if v == nil {
  17799. return
  17800. }
  17801. return *v, true
  17802. }
  17803. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  17804. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17806. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  17807. if !m.op.Is(OpUpdateOne) {
  17808. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  17809. }
  17810. if m.id == nil || m.oldValue == nil {
  17811. return v, errors.New("OldExperience requires an ID field in the mutation")
  17812. }
  17813. oldValue, err := m.oldValue(ctx)
  17814. if err != nil {
  17815. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  17816. }
  17817. return oldValue.Experience, nil
  17818. }
  17819. // ResetExperience resets all changes to the "experience" field.
  17820. func (m *WorkExperienceMutation) ResetExperience() {
  17821. m.experience = nil
  17822. }
  17823. // SetOrganizationID sets the "organization_id" field.
  17824. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  17825. m.organization_id = &u
  17826. m.addorganization_id = nil
  17827. }
  17828. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17829. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  17830. v := m.organization_id
  17831. if v == nil {
  17832. return
  17833. }
  17834. return *v, true
  17835. }
  17836. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  17837. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17839. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17840. if !m.op.Is(OpUpdateOne) {
  17841. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17842. }
  17843. if m.id == nil || m.oldValue == nil {
  17844. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17845. }
  17846. oldValue, err := m.oldValue(ctx)
  17847. if err != nil {
  17848. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17849. }
  17850. return oldValue.OrganizationID, nil
  17851. }
  17852. // AddOrganizationID adds u to the "organization_id" field.
  17853. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  17854. if m.addorganization_id != nil {
  17855. *m.addorganization_id += u
  17856. } else {
  17857. m.addorganization_id = &u
  17858. }
  17859. }
  17860. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17861. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  17862. v := m.addorganization_id
  17863. if v == nil {
  17864. return
  17865. }
  17866. return *v, true
  17867. }
  17868. // ResetOrganizationID resets all changes to the "organization_id" field.
  17869. func (m *WorkExperienceMutation) ResetOrganizationID() {
  17870. m.organization_id = nil
  17871. m.addorganization_id = nil
  17872. }
  17873. // ClearEmployee clears the "employee" edge to the Employee entity.
  17874. func (m *WorkExperienceMutation) ClearEmployee() {
  17875. m.clearedemployee = true
  17876. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  17877. }
  17878. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  17879. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  17880. return m.clearedemployee
  17881. }
  17882. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  17883. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17884. // EmployeeID instead. It exists only for internal usage by the builders.
  17885. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  17886. if id := m.employee; id != nil {
  17887. ids = append(ids, *id)
  17888. }
  17889. return
  17890. }
  17891. // ResetEmployee resets all changes to the "employee" edge.
  17892. func (m *WorkExperienceMutation) ResetEmployee() {
  17893. m.employee = nil
  17894. m.clearedemployee = false
  17895. }
  17896. // Where appends a list predicates to the WorkExperienceMutation builder.
  17897. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  17898. m.predicates = append(m.predicates, ps...)
  17899. }
  17900. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  17901. // users can use type-assertion to append predicates that do not depend on any generated package.
  17902. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  17903. p := make([]predicate.WorkExperience, len(ps))
  17904. for i := range ps {
  17905. p[i] = ps[i]
  17906. }
  17907. m.Where(p...)
  17908. }
  17909. // Op returns the operation name.
  17910. func (m *WorkExperienceMutation) Op() Op {
  17911. return m.op
  17912. }
  17913. // SetOp allows setting the mutation operation.
  17914. func (m *WorkExperienceMutation) SetOp(op Op) {
  17915. m.op = op
  17916. }
  17917. // Type returns the node type of this mutation (WorkExperience).
  17918. func (m *WorkExperienceMutation) Type() string {
  17919. return m.typ
  17920. }
  17921. // Fields returns all fields that were changed during this mutation. Note that in
  17922. // order to get all numeric fields that were incremented/decremented, call
  17923. // AddedFields().
  17924. func (m *WorkExperienceMutation) Fields() []string {
  17925. fields := make([]string, 0, 9)
  17926. if m.created_at != nil {
  17927. fields = append(fields, workexperience.FieldCreatedAt)
  17928. }
  17929. if m.updated_at != nil {
  17930. fields = append(fields, workexperience.FieldUpdatedAt)
  17931. }
  17932. if m.deleted_at != nil {
  17933. fields = append(fields, workexperience.FieldDeletedAt)
  17934. }
  17935. if m.employee != nil {
  17936. fields = append(fields, workexperience.FieldEmployeeID)
  17937. }
  17938. if m.start_date != nil {
  17939. fields = append(fields, workexperience.FieldStartDate)
  17940. }
  17941. if m.end_date != nil {
  17942. fields = append(fields, workexperience.FieldEndDate)
  17943. }
  17944. if m.company != nil {
  17945. fields = append(fields, workexperience.FieldCompany)
  17946. }
  17947. if m.experience != nil {
  17948. fields = append(fields, workexperience.FieldExperience)
  17949. }
  17950. if m.organization_id != nil {
  17951. fields = append(fields, workexperience.FieldOrganizationID)
  17952. }
  17953. return fields
  17954. }
  17955. // Field returns the value of a field with the given name. The second boolean
  17956. // return value indicates that this field was not set, or was not defined in the
  17957. // schema.
  17958. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  17959. switch name {
  17960. case workexperience.FieldCreatedAt:
  17961. return m.CreatedAt()
  17962. case workexperience.FieldUpdatedAt:
  17963. return m.UpdatedAt()
  17964. case workexperience.FieldDeletedAt:
  17965. return m.DeletedAt()
  17966. case workexperience.FieldEmployeeID:
  17967. return m.EmployeeID()
  17968. case workexperience.FieldStartDate:
  17969. return m.StartDate()
  17970. case workexperience.FieldEndDate:
  17971. return m.EndDate()
  17972. case workexperience.FieldCompany:
  17973. return m.Company()
  17974. case workexperience.FieldExperience:
  17975. return m.Experience()
  17976. case workexperience.FieldOrganizationID:
  17977. return m.OrganizationID()
  17978. }
  17979. return nil, false
  17980. }
  17981. // OldField returns the old value of the field from the database. An error is
  17982. // returned if the mutation operation is not UpdateOne, or the query to the
  17983. // database failed.
  17984. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17985. switch name {
  17986. case workexperience.FieldCreatedAt:
  17987. return m.OldCreatedAt(ctx)
  17988. case workexperience.FieldUpdatedAt:
  17989. return m.OldUpdatedAt(ctx)
  17990. case workexperience.FieldDeletedAt:
  17991. return m.OldDeletedAt(ctx)
  17992. case workexperience.FieldEmployeeID:
  17993. return m.OldEmployeeID(ctx)
  17994. case workexperience.FieldStartDate:
  17995. return m.OldStartDate(ctx)
  17996. case workexperience.FieldEndDate:
  17997. return m.OldEndDate(ctx)
  17998. case workexperience.FieldCompany:
  17999. return m.OldCompany(ctx)
  18000. case workexperience.FieldExperience:
  18001. return m.OldExperience(ctx)
  18002. case workexperience.FieldOrganizationID:
  18003. return m.OldOrganizationID(ctx)
  18004. }
  18005. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  18006. }
  18007. // SetField sets the value of a field with the given name. It returns an error if
  18008. // the field is not defined in the schema, or if the type mismatched the field
  18009. // type.
  18010. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  18011. switch name {
  18012. case workexperience.FieldCreatedAt:
  18013. v, ok := value.(time.Time)
  18014. if !ok {
  18015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18016. }
  18017. m.SetCreatedAt(v)
  18018. return nil
  18019. case workexperience.FieldUpdatedAt:
  18020. v, ok := value.(time.Time)
  18021. if !ok {
  18022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18023. }
  18024. m.SetUpdatedAt(v)
  18025. return nil
  18026. case workexperience.FieldDeletedAt:
  18027. v, ok := value.(time.Time)
  18028. if !ok {
  18029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18030. }
  18031. m.SetDeletedAt(v)
  18032. return nil
  18033. case workexperience.FieldEmployeeID:
  18034. v, ok := value.(uint64)
  18035. if !ok {
  18036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18037. }
  18038. m.SetEmployeeID(v)
  18039. return nil
  18040. case workexperience.FieldStartDate:
  18041. v, ok := value.(time.Time)
  18042. if !ok {
  18043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18044. }
  18045. m.SetStartDate(v)
  18046. return nil
  18047. case workexperience.FieldEndDate:
  18048. v, ok := value.(time.Time)
  18049. if !ok {
  18050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18051. }
  18052. m.SetEndDate(v)
  18053. return nil
  18054. case workexperience.FieldCompany:
  18055. v, ok := value.(string)
  18056. if !ok {
  18057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18058. }
  18059. m.SetCompany(v)
  18060. return nil
  18061. case workexperience.FieldExperience:
  18062. v, ok := value.(string)
  18063. if !ok {
  18064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18065. }
  18066. m.SetExperience(v)
  18067. return nil
  18068. case workexperience.FieldOrganizationID:
  18069. v, ok := value.(uint64)
  18070. if !ok {
  18071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18072. }
  18073. m.SetOrganizationID(v)
  18074. return nil
  18075. }
  18076. return fmt.Errorf("unknown WorkExperience field %s", name)
  18077. }
  18078. // AddedFields returns all numeric fields that were incremented/decremented during
  18079. // this mutation.
  18080. func (m *WorkExperienceMutation) AddedFields() []string {
  18081. var fields []string
  18082. if m.addorganization_id != nil {
  18083. fields = append(fields, workexperience.FieldOrganizationID)
  18084. }
  18085. return fields
  18086. }
  18087. // AddedField returns the numeric value that was incremented/decremented on a field
  18088. // with the given name. The second boolean return value indicates that this field
  18089. // was not set, or was not defined in the schema.
  18090. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  18091. switch name {
  18092. case workexperience.FieldOrganizationID:
  18093. return m.AddedOrganizationID()
  18094. }
  18095. return nil, false
  18096. }
  18097. // AddField adds the value to the field with the given name. It returns an error if
  18098. // the field is not defined in the schema, or if the type mismatched the field
  18099. // type.
  18100. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  18101. switch name {
  18102. case workexperience.FieldOrganizationID:
  18103. v, ok := value.(int64)
  18104. if !ok {
  18105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18106. }
  18107. m.AddOrganizationID(v)
  18108. return nil
  18109. }
  18110. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  18111. }
  18112. // ClearedFields returns all nullable fields that were cleared during this
  18113. // mutation.
  18114. func (m *WorkExperienceMutation) ClearedFields() []string {
  18115. var fields []string
  18116. if m.FieldCleared(workexperience.FieldDeletedAt) {
  18117. fields = append(fields, workexperience.FieldDeletedAt)
  18118. }
  18119. return fields
  18120. }
  18121. // FieldCleared returns a boolean indicating if a field with the given name was
  18122. // cleared in this mutation.
  18123. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  18124. _, ok := m.clearedFields[name]
  18125. return ok
  18126. }
  18127. // ClearField clears the value of the field with the given name. It returns an
  18128. // error if the field is not defined in the schema.
  18129. func (m *WorkExperienceMutation) ClearField(name string) error {
  18130. switch name {
  18131. case workexperience.FieldDeletedAt:
  18132. m.ClearDeletedAt()
  18133. return nil
  18134. }
  18135. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  18136. }
  18137. // ResetField resets all changes in the mutation for the field with the given name.
  18138. // It returns an error if the field is not defined in the schema.
  18139. func (m *WorkExperienceMutation) ResetField(name string) error {
  18140. switch name {
  18141. case workexperience.FieldCreatedAt:
  18142. m.ResetCreatedAt()
  18143. return nil
  18144. case workexperience.FieldUpdatedAt:
  18145. m.ResetUpdatedAt()
  18146. return nil
  18147. case workexperience.FieldDeletedAt:
  18148. m.ResetDeletedAt()
  18149. return nil
  18150. case workexperience.FieldEmployeeID:
  18151. m.ResetEmployeeID()
  18152. return nil
  18153. case workexperience.FieldStartDate:
  18154. m.ResetStartDate()
  18155. return nil
  18156. case workexperience.FieldEndDate:
  18157. m.ResetEndDate()
  18158. return nil
  18159. case workexperience.FieldCompany:
  18160. m.ResetCompany()
  18161. return nil
  18162. case workexperience.FieldExperience:
  18163. m.ResetExperience()
  18164. return nil
  18165. case workexperience.FieldOrganizationID:
  18166. m.ResetOrganizationID()
  18167. return nil
  18168. }
  18169. return fmt.Errorf("unknown WorkExperience field %s", name)
  18170. }
  18171. // AddedEdges returns all edge names that were set/added in this mutation.
  18172. func (m *WorkExperienceMutation) AddedEdges() []string {
  18173. edges := make([]string, 0, 1)
  18174. if m.employee != nil {
  18175. edges = append(edges, workexperience.EdgeEmployee)
  18176. }
  18177. return edges
  18178. }
  18179. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18180. // name in this mutation.
  18181. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  18182. switch name {
  18183. case workexperience.EdgeEmployee:
  18184. if id := m.employee; id != nil {
  18185. return []ent.Value{*id}
  18186. }
  18187. }
  18188. return nil
  18189. }
  18190. // RemovedEdges returns all edge names that were removed in this mutation.
  18191. func (m *WorkExperienceMutation) RemovedEdges() []string {
  18192. edges := make([]string, 0, 1)
  18193. return edges
  18194. }
  18195. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18196. // the given name in this mutation.
  18197. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  18198. return nil
  18199. }
  18200. // ClearedEdges returns all edge names that were cleared in this mutation.
  18201. func (m *WorkExperienceMutation) ClearedEdges() []string {
  18202. edges := make([]string, 0, 1)
  18203. if m.clearedemployee {
  18204. edges = append(edges, workexperience.EdgeEmployee)
  18205. }
  18206. return edges
  18207. }
  18208. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18209. // was cleared in this mutation.
  18210. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  18211. switch name {
  18212. case workexperience.EdgeEmployee:
  18213. return m.clearedemployee
  18214. }
  18215. return false
  18216. }
  18217. // ClearEdge clears the value of the edge with the given name. It returns an error
  18218. // if that edge is not defined in the schema.
  18219. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  18220. switch name {
  18221. case workexperience.EdgeEmployee:
  18222. m.ClearEmployee()
  18223. return nil
  18224. }
  18225. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  18226. }
  18227. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18228. // It returns an error if the edge is not defined in the schema.
  18229. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  18230. switch name {
  18231. case workexperience.EdgeEmployee:
  18232. m.ResetEmployee()
  18233. return nil
  18234. }
  18235. return fmt.Errorf("unknown WorkExperience edge %s", name)
  18236. }
  18237. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  18238. type WxMutation struct {
  18239. config
  18240. op Op
  18241. typ string
  18242. id *uint64
  18243. created_at *time.Time
  18244. updated_at *time.Time
  18245. status *uint8
  18246. addstatus *int8
  18247. deleted_at *time.Time
  18248. port *string
  18249. process_id *string
  18250. callback *string
  18251. wxid *string
  18252. account *string
  18253. nickname *string
  18254. tel *string
  18255. head_big *string
  18256. organization_id *uint64
  18257. addorganization_id *int64
  18258. api_base *string
  18259. api_key *string
  18260. allow_list *[]string
  18261. appendallow_list []string
  18262. group_allow_list *[]string
  18263. appendgroup_allow_list []string
  18264. block_list *[]string
  18265. appendblock_list []string
  18266. group_block_list *[]string
  18267. appendgroup_block_list []string
  18268. clearedFields map[string]struct{}
  18269. server *uint64
  18270. clearedserver bool
  18271. agent *uint64
  18272. clearedagent bool
  18273. done bool
  18274. oldValue func(context.Context) (*Wx, error)
  18275. predicates []predicate.Wx
  18276. }
  18277. var _ ent.Mutation = (*WxMutation)(nil)
  18278. // wxOption allows management of the mutation configuration using functional options.
  18279. type wxOption func(*WxMutation)
  18280. // newWxMutation creates new mutation for the Wx entity.
  18281. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  18282. m := &WxMutation{
  18283. config: c,
  18284. op: op,
  18285. typ: TypeWx,
  18286. clearedFields: make(map[string]struct{}),
  18287. }
  18288. for _, opt := range opts {
  18289. opt(m)
  18290. }
  18291. return m
  18292. }
  18293. // withWxID sets the ID field of the mutation.
  18294. func withWxID(id uint64) wxOption {
  18295. return func(m *WxMutation) {
  18296. var (
  18297. err error
  18298. once sync.Once
  18299. value *Wx
  18300. )
  18301. m.oldValue = func(ctx context.Context) (*Wx, error) {
  18302. once.Do(func() {
  18303. if m.done {
  18304. err = errors.New("querying old values post mutation is not allowed")
  18305. } else {
  18306. value, err = m.Client().Wx.Get(ctx, id)
  18307. }
  18308. })
  18309. return value, err
  18310. }
  18311. m.id = &id
  18312. }
  18313. }
  18314. // withWx sets the old Wx of the mutation.
  18315. func withWx(node *Wx) wxOption {
  18316. return func(m *WxMutation) {
  18317. m.oldValue = func(context.Context) (*Wx, error) {
  18318. return node, nil
  18319. }
  18320. m.id = &node.ID
  18321. }
  18322. }
  18323. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18324. // executed in a transaction (ent.Tx), a transactional client is returned.
  18325. func (m WxMutation) Client() *Client {
  18326. client := &Client{config: m.config}
  18327. client.init()
  18328. return client
  18329. }
  18330. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18331. // it returns an error otherwise.
  18332. func (m WxMutation) Tx() (*Tx, error) {
  18333. if _, ok := m.driver.(*txDriver); !ok {
  18334. return nil, errors.New("ent: mutation is not running in a transaction")
  18335. }
  18336. tx := &Tx{config: m.config}
  18337. tx.init()
  18338. return tx, nil
  18339. }
  18340. // SetID sets the value of the id field. Note that this
  18341. // operation is only accepted on creation of Wx entities.
  18342. func (m *WxMutation) SetID(id uint64) {
  18343. m.id = &id
  18344. }
  18345. // ID returns the ID value in the mutation. Note that the ID is only available
  18346. // if it was provided to the builder or after it was returned from the database.
  18347. func (m *WxMutation) ID() (id uint64, exists bool) {
  18348. if m.id == nil {
  18349. return
  18350. }
  18351. return *m.id, true
  18352. }
  18353. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18354. // That means, if the mutation is applied within a transaction with an isolation level such
  18355. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18356. // or updated by the mutation.
  18357. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  18358. switch {
  18359. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18360. id, exists := m.ID()
  18361. if exists {
  18362. return []uint64{id}, nil
  18363. }
  18364. fallthrough
  18365. case m.op.Is(OpUpdate | OpDelete):
  18366. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  18367. default:
  18368. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18369. }
  18370. }
  18371. // SetCreatedAt sets the "created_at" field.
  18372. func (m *WxMutation) SetCreatedAt(t time.Time) {
  18373. m.created_at = &t
  18374. }
  18375. // CreatedAt returns the value of the "created_at" field in the mutation.
  18376. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  18377. v := m.created_at
  18378. if v == nil {
  18379. return
  18380. }
  18381. return *v, true
  18382. }
  18383. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  18384. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18386. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18387. if !m.op.Is(OpUpdateOne) {
  18388. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18389. }
  18390. if m.id == nil || m.oldValue == nil {
  18391. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18392. }
  18393. oldValue, err := m.oldValue(ctx)
  18394. if err != nil {
  18395. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18396. }
  18397. return oldValue.CreatedAt, nil
  18398. }
  18399. // ResetCreatedAt resets all changes to the "created_at" field.
  18400. func (m *WxMutation) ResetCreatedAt() {
  18401. m.created_at = nil
  18402. }
  18403. // SetUpdatedAt sets the "updated_at" field.
  18404. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  18405. m.updated_at = &t
  18406. }
  18407. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18408. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  18409. v := m.updated_at
  18410. if v == nil {
  18411. return
  18412. }
  18413. return *v, true
  18414. }
  18415. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  18416. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18418. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18419. if !m.op.Is(OpUpdateOne) {
  18420. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18421. }
  18422. if m.id == nil || m.oldValue == nil {
  18423. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18424. }
  18425. oldValue, err := m.oldValue(ctx)
  18426. if err != nil {
  18427. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18428. }
  18429. return oldValue.UpdatedAt, nil
  18430. }
  18431. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18432. func (m *WxMutation) ResetUpdatedAt() {
  18433. m.updated_at = nil
  18434. }
  18435. // SetStatus sets the "status" field.
  18436. func (m *WxMutation) SetStatus(u uint8) {
  18437. m.status = &u
  18438. m.addstatus = nil
  18439. }
  18440. // Status returns the value of the "status" field in the mutation.
  18441. func (m *WxMutation) Status() (r uint8, exists bool) {
  18442. v := m.status
  18443. if v == nil {
  18444. return
  18445. }
  18446. return *v, true
  18447. }
  18448. // OldStatus returns the old "status" field's value of the Wx entity.
  18449. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18451. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18452. if !m.op.Is(OpUpdateOne) {
  18453. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18454. }
  18455. if m.id == nil || m.oldValue == nil {
  18456. return v, errors.New("OldStatus requires an ID field in the mutation")
  18457. }
  18458. oldValue, err := m.oldValue(ctx)
  18459. if err != nil {
  18460. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18461. }
  18462. return oldValue.Status, nil
  18463. }
  18464. // AddStatus adds u to the "status" field.
  18465. func (m *WxMutation) AddStatus(u int8) {
  18466. if m.addstatus != nil {
  18467. *m.addstatus += u
  18468. } else {
  18469. m.addstatus = &u
  18470. }
  18471. }
  18472. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18473. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  18474. v := m.addstatus
  18475. if v == nil {
  18476. return
  18477. }
  18478. return *v, true
  18479. }
  18480. // ClearStatus clears the value of the "status" field.
  18481. func (m *WxMutation) ClearStatus() {
  18482. m.status = nil
  18483. m.addstatus = nil
  18484. m.clearedFields[wx.FieldStatus] = struct{}{}
  18485. }
  18486. // StatusCleared returns if the "status" field was cleared in this mutation.
  18487. func (m *WxMutation) StatusCleared() bool {
  18488. _, ok := m.clearedFields[wx.FieldStatus]
  18489. return ok
  18490. }
  18491. // ResetStatus resets all changes to the "status" field.
  18492. func (m *WxMutation) ResetStatus() {
  18493. m.status = nil
  18494. m.addstatus = nil
  18495. delete(m.clearedFields, wx.FieldStatus)
  18496. }
  18497. // SetDeletedAt sets the "deleted_at" field.
  18498. func (m *WxMutation) SetDeletedAt(t time.Time) {
  18499. m.deleted_at = &t
  18500. }
  18501. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18502. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  18503. v := m.deleted_at
  18504. if v == nil {
  18505. return
  18506. }
  18507. return *v, true
  18508. }
  18509. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  18510. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18512. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18513. if !m.op.Is(OpUpdateOne) {
  18514. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18515. }
  18516. if m.id == nil || m.oldValue == nil {
  18517. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18518. }
  18519. oldValue, err := m.oldValue(ctx)
  18520. if err != nil {
  18521. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18522. }
  18523. return oldValue.DeletedAt, nil
  18524. }
  18525. // ClearDeletedAt clears the value of the "deleted_at" field.
  18526. func (m *WxMutation) ClearDeletedAt() {
  18527. m.deleted_at = nil
  18528. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  18529. }
  18530. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18531. func (m *WxMutation) DeletedAtCleared() bool {
  18532. _, ok := m.clearedFields[wx.FieldDeletedAt]
  18533. return ok
  18534. }
  18535. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18536. func (m *WxMutation) ResetDeletedAt() {
  18537. m.deleted_at = nil
  18538. delete(m.clearedFields, wx.FieldDeletedAt)
  18539. }
  18540. // SetServerID sets the "server_id" field.
  18541. func (m *WxMutation) SetServerID(u uint64) {
  18542. m.server = &u
  18543. }
  18544. // ServerID returns the value of the "server_id" field in the mutation.
  18545. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  18546. v := m.server
  18547. if v == nil {
  18548. return
  18549. }
  18550. return *v, true
  18551. }
  18552. // OldServerID returns the old "server_id" field's value of the Wx entity.
  18553. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18555. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  18556. if !m.op.Is(OpUpdateOne) {
  18557. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  18558. }
  18559. if m.id == nil || m.oldValue == nil {
  18560. return v, errors.New("OldServerID requires an ID field in the mutation")
  18561. }
  18562. oldValue, err := m.oldValue(ctx)
  18563. if err != nil {
  18564. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  18565. }
  18566. return oldValue.ServerID, nil
  18567. }
  18568. // ClearServerID clears the value of the "server_id" field.
  18569. func (m *WxMutation) ClearServerID() {
  18570. m.server = nil
  18571. m.clearedFields[wx.FieldServerID] = struct{}{}
  18572. }
  18573. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  18574. func (m *WxMutation) ServerIDCleared() bool {
  18575. _, ok := m.clearedFields[wx.FieldServerID]
  18576. return ok
  18577. }
  18578. // ResetServerID resets all changes to the "server_id" field.
  18579. func (m *WxMutation) ResetServerID() {
  18580. m.server = nil
  18581. delete(m.clearedFields, wx.FieldServerID)
  18582. }
  18583. // SetPort sets the "port" field.
  18584. func (m *WxMutation) SetPort(s string) {
  18585. m.port = &s
  18586. }
  18587. // Port returns the value of the "port" field in the mutation.
  18588. func (m *WxMutation) Port() (r string, exists bool) {
  18589. v := m.port
  18590. if v == nil {
  18591. return
  18592. }
  18593. return *v, true
  18594. }
  18595. // OldPort returns the old "port" field's value of the Wx entity.
  18596. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18598. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  18599. if !m.op.Is(OpUpdateOne) {
  18600. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  18601. }
  18602. if m.id == nil || m.oldValue == nil {
  18603. return v, errors.New("OldPort requires an ID field in the mutation")
  18604. }
  18605. oldValue, err := m.oldValue(ctx)
  18606. if err != nil {
  18607. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  18608. }
  18609. return oldValue.Port, nil
  18610. }
  18611. // ResetPort resets all changes to the "port" field.
  18612. func (m *WxMutation) ResetPort() {
  18613. m.port = nil
  18614. }
  18615. // SetProcessID sets the "process_id" field.
  18616. func (m *WxMutation) SetProcessID(s string) {
  18617. m.process_id = &s
  18618. }
  18619. // ProcessID returns the value of the "process_id" field in the mutation.
  18620. func (m *WxMutation) ProcessID() (r string, exists bool) {
  18621. v := m.process_id
  18622. if v == nil {
  18623. return
  18624. }
  18625. return *v, true
  18626. }
  18627. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  18628. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18630. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  18631. if !m.op.Is(OpUpdateOne) {
  18632. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  18633. }
  18634. if m.id == nil || m.oldValue == nil {
  18635. return v, errors.New("OldProcessID requires an ID field in the mutation")
  18636. }
  18637. oldValue, err := m.oldValue(ctx)
  18638. if err != nil {
  18639. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  18640. }
  18641. return oldValue.ProcessID, nil
  18642. }
  18643. // ResetProcessID resets all changes to the "process_id" field.
  18644. func (m *WxMutation) ResetProcessID() {
  18645. m.process_id = nil
  18646. }
  18647. // SetCallback sets the "callback" field.
  18648. func (m *WxMutation) SetCallback(s string) {
  18649. m.callback = &s
  18650. }
  18651. // Callback returns the value of the "callback" field in the mutation.
  18652. func (m *WxMutation) Callback() (r string, exists bool) {
  18653. v := m.callback
  18654. if v == nil {
  18655. return
  18656. }
  18657. return *v, true
  18658. }
  18659. // OldCallback returns the old "callback" field's value of the Wx entity.
  18660. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18662. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  18663. if !m.op.Is(OpUpdateOne) {
  18664. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  18665. }
  18666. if m.id == nil || m.oldValue == nil {
  18667. return v, errors.New("OldCallback requires an ID field in the mutation")
  18668. }
  18669. oldValue, err := m.oldValue(ctx)
  18670. if err != nil {
  18671. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  18672. }
  18673. return oldValue.Callback, nil
  18674. }
  18675. // ResetCallback resets all changes to the "callback" field.
  18676. func (m *WxMutation) ResetCallback() {
  18677. m.callback = nil
  18678. }
  18679. // SetWxid sets the "wxid" field.
  18680. func (m *WxMutation) SetWxid(s string) {
  18681. m.wxid = &s
  18682. }
  18683. // Wxid returns the value of the "wxid" field in the mutation.
  18684. func (m *WxMutation) Wxid() (r string, exists bool) {
  18685. v := m.wxid
  18686. if v == nil {
  18687. return
  18688. }
  18689. return *v, true
  18690. }
  18691. // OldWxid returns the old "wxid" field's value of the Wx entity.
  18692. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18694. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  18695. if !m.op.Is(OpUpdateOne) {
  18696. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  18697. }
  18698. if m.id == nil || m.oldValue == nil {
  18699. return v, errors.New("OldWxid requires an ID field in the mutation")
  18700. }
  18701. oldValue, err := m.oldValue(ctx)
  18702. if err != nil {
  18703. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  18704. }
  18705. return oldValue.Wxid, nil
  18706. }
  18707. // ResetWxid resets all changes to the "wxid" field.
  18708. func (m *WxMutation) ResetWxid() {
  18709. m.wxid = nil
  18710. }
  18711. // SetAccount sets the "account" field.
  18712. func (m *WxMutation) SetAccount(s string) {
  18713. m.account = &s
  18714. }
  18715. // Account returns the value of the "account" field in the mutation.
  18716. func (m *WxMutation) Account() (r string, exists bool) {
  18717. v := m.account
  18718. if v == nil {
  18719. return
  18720. }
  18721. return *v, true
  18722. }
  18723. // OldAccount returns the old "account" field's value of the Wx entity.
  18724. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18725. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18726. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  18727. if !m.op.Is(OpUpdateOne) {
  18728. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  18729. }
  18730. if m.id == nil || m.oldValue == nil {
  18731. return v, errors.New("OldAccount requires an ID field in the mutation")
  18732. }
  18733. oldValue, err := m.oldValue(ctx)
  18734. if err != nil {
  18735. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  18736. }
  18737. return oldValue.Account, nil
  18738. }
  18739. // ResetAccount resets all changes to the "account" field.
  18740. func (m *WxMutation) ResetAccount() {
  18741. m.account = nil
  18742. }
  18743. // SetNickname sets the "nickname" field.
  18744. func (m *WxMutation) SetNickname(s string) {
  18745. m.nickname = &s
  18746. }
  18747. // Nickname returns the value of the "nickname" field in the mutation.
  18748. func (m *WxMutation) Nickname() (r string, exists bool) {
  18749. v := m.nickname
  18750. if v == nil {
  18751. return
  18752. }
  18753. return *v, true
  18754. }
  18755. // OldNickname returns the old "nickname" field's value of the Wx entity.
  18756. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18758. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  18759. if !m.op.Is(OpUpdateOne) {
  18760. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  18761. }
  18762. if m.id == nil || m.oldValue == nil {
  18763. return v, errors.New("OldNickname requires an ID field in the mutation")
  18764. }
  18765. oldValue, err := m.oldValue(ctx)
  18766. if err != nil {
  18767. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  18768. }
  18769. return oldValue.Nickname, nil
  18770. }
  18771. // ResetNickname resets all changes to the "nickname" field.
  18772. func (m *WxMutation) ResetNickname() {
  18773. m.nickname = nil
  18774. }
  18775. // SetTel sets the "tel" field.
  18776. func (m *WxMutation) SetTel(s string) {
  18777. m.tel = &s
  18778. }
  18779. // Tel returns the value of the "tel" field in the mutation.
  18780. func (m *WxMutation) Tel() (r string, exists bool) {
  18781. v := m.tel
  18782. if v == nil {
  18783. return
  18784. }
  18785. return *v, true
  18786. }
  18787. // OldTel returns the old "tel" field's value of the Wx entity.
  18788. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18789. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18790. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  18791. if !m.op.Is(OpUpdateOne) {
  18792. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  18793. }
  18794. if m.id == nil || m.oldValue == nil {
  18795. return v, errors.New("OldTel requires an ID field in the mutation")
  18796. }
  18797. oldValue, err := m.oldValue(ctx)
  18798. if err != nil {
  18799. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  18800. }
  18801. return oldValue.Tel, nil
  18802. }
  18803. // ResetTel resets all changes to the "tel" field.
  18804. func (m *WxMutation) ResetTel() {
  18805. m.tel = nil
  18806. }
  18807. // SetHeadBig sets the "head_big" field.
  18808. func (m *WxMutation) SetHeadBig(s string) {
  18809. m.head_big = &s
  18810. }
  18811. // HeadBig returns the value of the "head_big" field in the mutation.
  18812. func (m *WxMutation) HeadBig() (r string, exists bool) {
  18813. v := m.head_big
  18814. if v == nil {
  18815. return
  18816. }
  18817. return *v, true
  18818. }
  18819. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  18820. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18821. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18822. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  18823. if !m.op.Is(OpUpdateOne) {
  18824. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  18825. }
  18826. if m.id == nil || m.oldValue == nil {
  18827. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  18828. }
  18829. oldValue, err := m.oldValue(ctx)
  18830. if err != nil {
  18831. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  18832. }
  18833. return oldValue.HeadBig, nil
  18834. }
  18835. // ResetHeadBig resets all changes to the "head_big" field.
  18836. func (m *WxMutation) ResetHeadBig() {
  18837. m.head_big = nil
  18838. }
  18839. // SetOrganizationID sets the "organization_id" field.
  18840. func (m *WxMutation) SetOrganizationID(u uint64) {
  18841. m.organization_id = &u
  18842. m.addorganization_id = nil
  18843. }
  18844. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18845. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  18846. v := m.organization_id
  18847. if v == nil {
  18848. return
  18849. }
  18850. return *v, true
  18851. }
  18852. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  18853. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18855. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18856. if !m.op.Is(OpUpdateOne) {
  18857. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18858. }
  18859. if m.id == nil || m.oldValue == nil {
  18860. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18861. }
  18862. oldValue, err := m.oldValue(ctx)
  18863. if err != nil {
  18864. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18865. }
  18866. return oldValue.OrganizationID, nil
  18867. }
  18868. // AddOrganizationID adds u to the "organization_id" field.
  18869. func (m *WxMutation) AddOrganizationID(u int64) {
  18870. if m.addorganization_id != nil {
  18871. *m.addorganization_id += u
  18872. } else {
  18873. m.addorganization_id = &u
  18874. }
  18875. }
  18876. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18877. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  18878. v := m.addorganization_id
  18879. if v == nil {
  18880. return
  18881. }
  18882. return *v, true
  18883. }
  18884. // ClearOrganizationID clears the value of the "organization_id" field.
  18885. func (m *WxMutation) ClearOrganizationID() {
  18886. m.organization_id = nil
  18887. m.addorganization_id = nil
  18888. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  18889. }
  18890. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18891. func (m *WxMutation) OrganizationIDCleared() bool {
  18892. _, ok := m.clearedFields[wx.FieldOrganizationID]
  18893. return ok
  18894. }
  18895. // ResetOrganizationID resets all changes to the "organization_id" field.
  18896. func (m *WxMutation) ResetOrganizationID() {
  18897. m.organization_id = nil
  18898. m.addorganization_id = nil
  18899. delete(m.clearedFields, wx.FieldOrganizationID)
  18900. }
  18901. // SetAgentID sets the "agent_id" field.
  18902. func (m *WxMutation) SetAgentID(u uint64) {
  18903. m.agent = &u
  18904. }
  18905. // AgentID returns the value of the "agent_id" field in the mutation.
  18906. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  18907. v := m.agent
  18908. if v == nil {
  18909. return
  18910. }
  18911. return *v, true
  18912. }
  18913. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  18914. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18915. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18916. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  18917. if !m.op.Is(OpUpdateOne) {
  18918. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  18919. }
  18920. if m.id == nil || m.oldValue == nil {
  18921. return v, errors.New("OldAgentID requires an ID field in the mutation")
  18922. }
  18923. oldValue, err := m.oldValue(ctx)
  18924. if err != nil {
  18925. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  18926. }
  18927. return oldValue.AgentID, nil
  18928. }
  18929. // ResetAgentID resets all changes to the "agent_id" field.
  18930. func (m *WxMutation) ResetAgentID() {
  18931. m.agent = nil
  18932. }
  18933. // SetAPIBase sets the "api_base" field.
  18934. func (m *WxMutation) SetAPIBase(s string) {
  18935. m.api_base = &s
  18936. }
  18937. // APIBase returns the value of the "api_base" field in the mutation.
  18938. func (m *WxMutation) APIBase() (r string, exists bool) {
  18939. v := m.api_base
  18940. if v == nil {
  18941. return
  18942. }
  18943. return *v, true
  18944. }
  18945. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  18946. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18947. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18948. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  18949. if !m.op.Is(OpUpdateOne) {
  18950. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  18951. }
  18952. if m.id == nil || m.oldValue == nil {
  18953. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  18954. }
  18955. oldValue, err := m.oldValue(ctx)
  18956. if err != nil {
  18957. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  18958. }
  18959. return oldValue.APIBase, nil
  18960. }
  18961. // ClearAPIBase clears the value of the "api_base" field.
  18962. func (m *WxMutation) ClearAPIBase() {
  18963. m.api_base = nil
  18964. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  18965. }
  18966. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  18967. func (m *WxMutation) APIBaseCleared() bool {
  18968. _, ok := m.clearedFields[wx.FieldAPIBase]
  18969. return ok
  18970. }
  18971. // ResetAPIBase resets all changes to the "api_base" field.
  18972. func (m *WxMutation) ResetAPIBase() {
  18973. m.api_base = nil
  18974. delete(m.clearedFields, wx.FieldAPIBase)
  18975. }
  18976. // SetAPIKey sets the "api_key" field.
  18977. func (m *WxMutation) SetAPIKey(s string) {
  18978. m.api_key = &s
  18979. }
  18980. // APIKey returns the value of the "api_key" field in the mutation.
  18981. func (m *WxMutation) APIKey() (r string, exists bool) {
  18982. v := m.api_key
  18983. if v == nil {
  18984. return
  18985. }
  18986. return *v, true
  18987. }
  18988. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  18989. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18991. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  18992. if !m.op.Is(OpUpdateOne) {
  18993. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  18994. }
  18995. if m.id == nil || m.oldValue == nil {
  18996. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  18997. }
  18998. oldValue, err := m.oldValue(ctx)
  18999. if err != nil {
  19000. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  19001. }
  19002. return oldValue.APIKey, nil
  19003. }
  19004. // ClearAPIKey clears the value of the "api_key" field.
  19005. func (m *WxMutation) ClearAPIKey() {
  19006. m.api_key = nil
  19007. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  19008. }
  19009. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  19010. func (m *WxMutation) APIKeyCleared() bool {
  19011. _, ok := m.clearedFields[wx.FieldAPIKey]
  19012. return ok
  19013. }
  19014. // ResetAPIKey resets all changes to the "api_key" field.
  19015. func (m *WxMutation) ResetAPIKey() {
  19016. m.api_key = nil
  19017. delete(m.clearedFields, wx.FieldAPIKey)
  19018. }
  19019. // SetAllowList sets the "allow_list" field.
  19020. func (m *WxMutation) SetAllowList(s []string) {
  19021. m.allow_list = &s
  19022. m.appendallow_list = nil
  19023. }
  19024. // AllowList returns the value of the "allow_list" field in the mutation.
  19025. func (m *WxMutation) AllowList() (r []string, exists bool) {
  19026. v := m.allow_list
  19027. if v == nil {
  19028. return
  19029. }
  19030. return *v, true
  19031. }
  19032. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  19033. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19035. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  19036. if !m.op.Is(OpUpdateOne) {
  19037. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  19038. }
  19039. if m.id == nil || m.oldValue == nil {
  19040. return v, errors.New("OldAllowList requires an ID field in the mutation")
  19041. }
  19042. oldValue, err := m.oldValue(ctx)
  19043. if err != nil {
  19044. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  19045. }
  19046. return oldValue.AllowList, nil
  19047. }
  19048. // AppendAllowList adds s to the "allow_list" field.
  19049. func (m *WxMutation) AppendAllowList(s []string) {
  19050. m.appendallow_list = append(m.appendallow_list, s...)
  19051. }
  19052. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  19053. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  19054. if len(m.appendallow_list) == 0 {
  19055. return nil, false
  19056. }
  19057. return m.appendallow_list, true
  19058. }
  19059. // ResetAllowList resets all changes to the "allow_list" field.
  19060. func (m *WxMutation) ResetAllowList() {
  19061. m.allow_list = nil
  19062. m.appendallow_list = nil
  19063. }
  19064. // SetGroupAllowList sets the "group_allow_list" field.
  19065. func (m *WxMutation) SetGroupAllowList(s []string) {
  19066. m.group_allow_list = &s
  19067. m.appendgroup_allow_list = nil
  19068. }
  19069. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  19070. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  19071. v := m.group_allow_list
  19072. if v == nil {
  19073. return
  19074. }
  19075. return *v, true
  19076. }
  19077. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  19078. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19080. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  19081. if !m.op.Is(OpUpdateOne) {
  19082. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  19083. }
  19084. if m.id == nil || m.oldValue == nil {
  19085. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  19086. }
  19087. oldValue, err := m.oldValue(ctx)
  19088. if err != nil {
  19089. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  19090. }
  19091. return oldValue.GroupAllowList, nil
  19092. }
  19093. // AppendGroupAllowList adds s to the "group_allow_list" field.
  19094. func (m *WxMutation) AppendGroupAllowList(s []string) {
  19095. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  19096. }
  19097. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  19098. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  19099. if len(m.appendgroup_allow_list) == 0 {
  19100. return nil, false
  19101. }
  19102. return m.appendgroup_allow_list, true
  19103. }
  19104. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  19105. func (m *WxMutation) ResetGroupAllowList() {
  19106. m.group_allow_list = nil
  19107. m.appendgroup_allow_list = nil
  19108. }
  19109. // SetBlockList sets the "block_list" field.
  19110. func (m *WxMutation) SetBlockList(s []string) {
  19111. m.block_list = &s
  19112. m.appendblock_list = nil
  19113. }
  19114. // BlockList returns the value of the "block_list" field in the mutation.
  19115. func (m *WxMutation) BlockList() (r []string, exists bool) {
  19116. v := m.block_list
  19117. if v == nil {
  19118. return
  19119. }
  19120. return *v, true
  19121. }
  19122. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  19123. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19125. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  19126. if !m.op.Is(OpUpdateOne) {
  19127. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  19128. }
  19129. if m.id == nil || m.oldValue == nil {
  19130. return v, errors.New("OldBlockList requires an ID field in the mutation")
  19131. }
  19132. oldValue, err := m.oldValue(ctx)
  19133. if err != nil {
  19134. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  19135. }
  19136. return oldValue.BlockList, nil
  19137. }
  19138. // AppendBlockList adds s to the "block_list" field.
  19139. func (m *WxMutation) AppendBlockList(s []string) {
  19140. m.appendblock_list = append(m.appendblock_list, s...)
  19141. }
  19142. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  19143. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  19144. if len(m.appendblock_list) == 0 {
  19145. return nil, false
  19146. }
  19147. return m.appendblock_list, true
  19148. }
  19149. // ResetBlockList resets all changes to the "block_list" field.
  19150. func (m *WxMutation) ResetBlockList() {
  19151. m.block_list = nil
  19152. m.appendblock_list = nil
  19153. }
  19154. // SetGroupBlockList sets the "group_block_list" field.
  19155. func (m *WxMutation) SetGroupBlockList(s []string) {
  19156. m.group_block_list = &s
  19157. m.appendgroup_block_list = nil
  19158. }
  19159. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  19160. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  19161. v := m.group_block_list
  19162. if v == nil {
  19163. return
  19164. }
  19165. return *v, true
  19166. }
  19167. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  19168. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19170. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  19171. if !m.op.Is(OpUpdateOne) {
  19172. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  19173. }
  19174. if m.id == nil || m.oldValue == nil {
  19175. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  19176. }
  19177. oldValue, err := m.oldValue(ctx)
  19178. if err != nil {
  19179. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  19180. }
  19181. return oldValue.GroupBlockList, nil
  19182. }
  19183. // AppendGroupBlockList adds s to the "group_block_list" field.
  19184. func (m *WxMutation) AppendGroupBlockList(s []string) {
  19185. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  19186. }
  19187. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  19188. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  19189. if len(m.appendgroup_block_list) == 0 {
  19190. return nil, false
  19191. }
  19192. return m.appendgroup_block_list, true
  19193. }
  19194. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  19195. func (m *WxMutation) ResetGroupBlockList() {
  19196. m.group_block_list = nil
  19197. m.appendgroup_block_list = nil
  19198. }
  19199. // ClearServer clears the "server" edge to the Server entity.
  19200. func (m *WxMutation) ClearServer() {
  19201. m.clearedserver = true
  19202. m.clearedFields[wx.FieldServerID] = struct{}{}
  19203. }
  19204. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  19205. func (m *WxMutation) ServerCleared() bool {
  19206. return m.ServerIDCleared() || m.clearedserver
  19207. }
  19208. // ServerIDs returns the "server" edge IDs in the mutation.
  19209. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19210. // ServerID instead. It exists only for internal usage by the builders.
  19211. func (m *WxMutation) ServerIDs() (ids []uint64) {
  19212. if id := m.server; id != nil {
  19213. ids = append(ids, *id)
  19214. }
  19215. return
  19216. }
  19217. // ResetServer resets all changes to the "server" edge.
  19218. func (m *WxMutation) ResetServer() {
  19219. m.server = nil
  19220. m.clearedserver = false
  19221. }
  19222. // ClearAgent clears the "agent" edge to the Agent entity.
  19223. func (m *WxMutation) ClearAgent() {
  19224. m.clearedagent = true
  19225. m.clearedFields[wx.FieldAgentID] = struct{}{}
  19226. }
  19227. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  19228. func (m *WxMutation) AgentCleared() bool {
  19229. return m.clearedagent
  19230. }
  19231. // AgentIDs returns the "agent" edge IDs in the mutation.
  19232. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19233. // AgentID instead. It exists only for internal usage by the builders.
  19234. func (m *WxMutation) AgentIDs() (ids []uint64) {
  19235. if id := m.agent; id != nil {
  19236. ids = append(ids, *id)
  19237. }
  19238. return
  19239. }
  19240. // ResetAgent resets all changes to the "agent" edge.
  19241. func (m *WxMutation) ResetAgent() {
  19242. m.agent = nil
  19243. m.clearedagent = false
  19244. }
  19245. // Where appends a list predicates to the WxMutation builder.
  19246. func (m *WxMutation) Where(ps ...predicate.Wx) {
  19247. m.predicates = append(m.predicates, ps...)
  19248. }
  19249. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  19250. // users can use type-assertion to append predicates that do not depend on any generated package.
  19251. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  19252. p := make([]predicate.Wx, len(ps))
  19253. for i := range ps {
  19254. p[i] = ps[i]
  19255. }
  19256. m.Where(p...)
  19257. }
  19258. // Op returns the operation name.
  19259. func (m *WxMutation) Op() Op {
  19260. return m.op
  19261. }
  19262. // SetOp allows setting the mutation operation.
  19263. func (m *WxMutation) SetOp(op Op) {
  19264. m.op = op
  19265. }
  19266. // Type returns the node type of this mutation (Wx).
  19267. func (m *WxMutation) Type() string {
  19268. return m.typ
  19269. }
  19270. // Fields returns all fields that were changed during this mutation. Note that in
  19271. // order to get all numeric fields that were incremented/decremented, call
  19272. // AddedFields().
  19273. func (m *WxMutation) Fields() []string {
  19274. fields := make([]string, 0, 21)
  19275. if m.created_at != nil {
  19276. fields = append(fields, wx.FieldCreatedAt)
  19277. }
  19278. if m.updated_at != nil {
  19279. fields = append(fields, wx.FieldUpdatedAt)
  19280. }
  19281. if m.status != nil {
  19282. fields = append(fields, wx.FieldStatus)
  19283. }
  19284. if m.deleted_at != nil {
  19285. fields = append(fields, wx.FieldDeletedAt)
  19286. }
  19287. if m.server != nil {
  19288. fields = append(fields, wx.FieldServerID)
  19289. }
  19290. if m.port != nil {
  19291. fields = append(fields, wx.FieldPort)
  19292. }
  19293. if m.process_id != nil {
  19294. fields = append(fields, wx.FieldProcessID)
  19295. }
  19296. if m.callback != nil {
  19297. fields = append(fields, wx.FieldCallback)
  19298. }
  19299. if m.wxid != nil {
  19300. fields = append(fields, wx.FieldWxid)
  19301. }
  19302. if m.account != nil {
  19303. fields = append(fields, wx.FieldAccount)
  19304. }
  19305. if m.nickname != nil {
  19306. fields = append(fields, wx.FieldNickname)
  19307. }
  19308. if m.tel != nil {
  19309. fields = append(fields, wx.FieldTel)
  19310. }
  19311. if m.head_big != nil {
  19312. fields = append(fields, wx.FieldHeadBig)
  19313. }
  19314. if m.organization_id != nil {
  19315. fields = append(fields, wx.FieldOrganizationID)
  19316. }
  19317. if m.agent != nil {
  19318. fields = append(fields, wx.FieldAgentID)
  19319. }
  19320. if m.api_base != nil {
  19321. fields = append(fields, wx.FieldAPIBase)
  19322. }
  19323. if m.api_key != nil {
  19324. fields = append(fields, wx.FieldAPIKey)
  19325. }
  19326. if m.allow_list != nil {
  19327. fields = append(fields, wx.FieldAllowList)
  19328. }
  19329. if m.group_allow_list != nil {
  19330. fields = append(fields, wx.FieldGroupAllowList)
  19331. }
  19332. if m.block_list != nil {
  19333. fields = append(fields, wx.FieldBlockList)
  19334. }
  19335. if m.group_block_list != nil {
  19336. fields = append(fields, wx.FieldGroupBlockList)
  19337. }
  19338. return fields
  19339. }
  19340. // Field returns the value of a field with the given name. The second boolean
  19341. // return value indicates that this field was not set, or was not defined in the
  19342. // schema.
  19343. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  19344. switch name {
  19345. case wx.FieldCreatedAt:
  19346. return m.CreatedAt()
  19347. case wx.FieldUpdatedAt:
  19348. return m.UpdatedAt()
  19349. case wx.FieldStatus:
  19350. return m.Status()
  19351. case wx.FieldDeletedAt:
  19352. return m.DeletedAt()
  19353. case wx.FieldServerID:
  19354. return m.ServerID()
  19355. case wx.FieldPort:
  19356. return m.Port()
  19357. case wx.FieldProcessID:
  19358. return m.ProcessID()
  19359. case wx.FieldCallback:
  19360. return m.Callback()
  19361. case wx.FieldWxid:
  19362. return m.Wxid()
  19363. case wx.FieldAccount:
  19364. return m.Account()
  19365. case wx.FieldNickname:
  19366. return m.Nickname()
  19367. case wx.FieldTel:
  19368. return m.Tel()
  19369. case wx.FieldHeadBig:
  19370. return m.HeadBig()
  19371. case wx.FieldOrganizationID:
  19372. return m.OrganizationID()
  19373. case wx.FieldAgentID:
  19374. return m.AgentID()
  19375. case wx.FieldAPIBase:
  19376. return m.APIBase()
  19377. case wx.FieldAPIKey:
  19378. return m.APIKey()
  19379. case wx.FieldAllowList:
  19380. return m.AllowList()
  19381. case wx.FieldGroupAllowList:
  19382. return m.GroupAllowList()
  19383. case wx.FieldBlockList:
  19384. return m.BlockList()
  19385. case wx.FieldGroupBlockList:
  19386. return m.GroupBlockList()
  19387. }
  19388. return nil, false
  19389. }
  19390. // OldField returns the old value of the field from the database. An error is
  19391. // returned if the mutation operation is not UpdateOne, or the query to the
  19392. // database failed.
  19393. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19394. switch name {
  19395. case wx.FieldCreatedAt:
  19396. return m.OldCreatedAt(ctx)
  19397. case wx.FieldUpdatedAt:
  19398. return m.OldUpdatedAt(ctx)
  19399. case wx.FieldStatus:
  19400. return m.OldStatus(ctx)
  19401. case wx.FieldDeletedAt:
  19402. return m.OldDeletedAt(ctx)
  19403. case wx.FieldServerID:
  19404. return m.OldServerID(ctx)
  19405. case wx.FieldPort:
  19406. return m.OldPort(ctx)
  19407. case wx.FieldProcessID:
  19408. return m.OldProcessID(ctx)
  19409. case wx.FieldCallback:
  19410. return m.OldCallback(ctx)
  19411. case wx.FieldWxid:
  19412. return m.OldWxid(ctx)
  19413. case wx.FieldAccount:
  19414. return m.OldAccount(ctx)
  19415. case wx.FieldNickname:
  19416. return m.OldNickname(ctx)
  19417. case wx.FieldTel:
  19418. return m.OldTel(ctx)
  19419. case wx.FieldHeadBig:
  19420. return m.OldHeadBig(ctx)
  19421. case wx.FieldOrganizationID:
  19422. return m.OldOrganizationID(ctx)
  19423. case wx.FieldAgentID:
  19424. return m.OldAgentID(ctx)
  19425. case wx.FieldAPIBase:
  19426. return m.OldAPIBase(ctx)
  19427. case wx.FieldAPIKey:
  19428. return m.OldAPIKey(ctx)
  19429. case wx.FieldAllowList:
  19430. return m.OldAllowList(ctx)
  19431. case wx.FieldGroupAllowList:
  19432. return m.OldGroupAllowList(ctx)
  19433. case wx.FieldBlockList:
  19434. return m.OldBlockList(ctx)
  19435. case wx.FieldGroupBlockList:
  19436. return m.OldGroupBlockList(ctx)
  19437. }
  19438. return nil, fmt.Errorf("unknown Wx field %s", name)
  19439. }
  19440. // SetField sets the value of a field with the given name. It returns an error if
  19441. // the field is not defined in the schema, or if the type mismatched the field
  19442. // type.
  19443. func (m *WxMutation) SetField(name string, value ent.Value) error {
  19444. switch name {
  19445. case wx.FieldCreatedAt:
  19446. v, ok := value.(time.Time)
  19447. if !ok {
  19448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19449. }
  19450. m.SetCreatedAt(v)
  19451. return nil
  19452. case wx.FieldUpdatedAt:
  19453. v, ok := value.(time.Time)
  19454. if !ok {
  19455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19456. }
  19457. m.SetUpdatedAt(v)
  19458. return nil
  19459. case wx.FieldStatus:
  19460. v, ok := value.(uint8)
  19461. if !ok {
  19462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19463. }
  19464. m.SetStatus(v)
  19465. return nil
  19466. case wx.FieldDeletedAt:
  19467. v, ok := value.(time.Time)
  19468. if !ok {
  19469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19470. }
  19471. m.SetDeletedAt(v)
  19472. return nil
  19473. case wx.FieldServerID:
  19474. v, ok := value.(uint64)
  19475. if !ok {
  19476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19477. }
  19478. m.SetServerID(v)
  19479. return nil
  19480. case wx.FieldPort:
  19481. v, ok := value.(string)
  19482. if !ok {
  19483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19484. }
  19485. m.SetPort(v)
  19486. return nil
  19487. case wx.FieldProcessID:
  19488. v, ok := value.(string)
  19489. if !ok {
  19490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19491. }
  19492. m.SetProcessID(v)
  19493. return nil
  19494. case wx.FieldCallback:
  19495. v, ok := value.(string)
  19496. if !ok {
  19497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19498. }
  19499. m.SetCallback(v)
  19500. return nil
  19501. case wx.FieldWxid:
  19502. v, ok := value.(string)
  19503. if !ok {
  19504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19505. }
  19506. m.SetWxid(v)
  19507. return nil
  19508. case wx.FieldAccount:
  19509. v, ok := value.(string)
  19510. if !ok {
  19511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19512. }
  19513. m.SetAccount(v)
  19514. return nil
  19515. case wx.FieldNickname:
  19516. v, ok := value.(string)
  19517. if !ok {
  19518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19519. }
  19520. m.SetNickname(v)
  19521. return nil
  19522. case wx.FieldTel:
  19523. v, ok := value.(string)
  19524. if !ok {
  19525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19526. }
  19527. m.SetTel(v)
  19528. return nil
  19529. case wx.FieldHeadBig:
  19530. v, ok := value.(string)
  19531. if !ok {
  19532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19533. }
  19534. m.SetHeadBig(v)
  19535. return nil
  19536. case wx.FieldOrganizationID:
  19537. v, ok := value.(uint64)
  19538. if !ok {
  19539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19540. }
  19541. m.SetOrganizationID(v)
  19542. return nil
  19543. case wx.FieldAgentID:
  19544. v, ok := value.(uint64)
  19545. if !ok {
  19546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19547. }
  19548. m.SetAgentID(v)
  19549. return nil
  19550. case wx.FieldAPIBase:
  19551. v, ok := value.(string)
  19552. if !ok {
  19553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19554. }
  19555. m.SetAPIBase(v)
  19556. return nil
  19557. case wx.FieldAPIKey:
  19558. v, ok := value.(string)
  19559. if !ok {
  19560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19561. }
  19562. m.SetAPIKey(v)
  19563. return nil
  19564. case wx.FieldAllowList:
  19565. v, ok := value.([]string)
  19566. if !ok {
  19567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19568. }
  19569. m.SetAllowList(v)
  19570. return nil
  19571. case wx.FieldGroupAllowList:
  19572. v, ok := value.([]string)
  19573. if !ok {
  19574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19575. }
  19576. m.SetGroupAllowList(v)
  19577. return nil
  19578. case wx.FieldBlockList:
  19579. v, ok := value.([]string)
  19580. if !ok {
  19581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19582. }
  19583. m.SetBlockList(v)
  19584. return nil
  19585. case wx.FieldGroupBlockList:
  19586. v, ok := value.([]string)
  19587. if !ok {
  19588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19589. }
  19590. m.SetGroupBlockList(v)
  19591. return nil
  19592. }
  19593. return fmt.Errorf("unknown Wx field %s", name)
  19594. }
  19595. // AddedFields returns all numeric fields that were incremented/decremented during
  19596. // this mutation.
  19597. func (m *WxMutation) AddedFields() []string {
  19598. var fields []string
  19599. if m.addstatus != nil {
  19600. fields = append(fields, wx.FieldStatus)
  19601. }
  19602. if m.addorganization_id != nil {
  19603. fields = append(fields, wx.FieldOrganizationID)
  19604. }
  19605. return fields
  19606. }
  19607. // AddedField returns the numeric value that was incremented/decremented on a field
  19608. // with the given name. The second boolean return value indicates that this field
  19609. // was not set, or was not defined in the schema.
  19610. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  19611. switch name {
  19612. case wx.FieldStatus:
  19613. return m.AddedStatus()
  19614. case wx.FieldOrganizationID:
  19615. return m.AddedOrganizationID()
  19616. }
  19617. return nil, false
  19618. }
  19619. // AddField adds the value to the field with the given name. It returns an error if
  19620. // the field is not defined in the schema, or if the type mismatched the field
  19621. // type.
  19622. func (m *WxMutation) AddField(name string, value ent.Value) error {
  19623. switch name {
  19624. case wx.FieldStatus:
  19625. v, ok := value.(int8)
  19626. if !ok {
  19627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19628. }
  19629. m.AddStatus(v)
  19630. return nil
  19631. case wx.FieldOrganizationID:
  19632. v, ok := value.(int64)
  19633. if !ok {
  19634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19635. }
  19636. m.AddOrganizationID(v)
  19637. return nil
  19638. }
  19639. return fmt.Errorf("unknown Wx numeric field %s", name)
  19640. }
  19641. // ClearedFields returns all nullable fields that were cleared during this
  19642. // mutation.
  19643. func (m *WxMutation) ClearedFields() []string {
  19644. var fields []string
  19645. if m.FieldCleared(wx.FieldStatus) {
  19646. fields = append(fields, wx.FieldStatus)
  19647. }
  19648. if m.FieldCleared(wx.FieldDeletedAt) {
  19649. fields = append(fields, wx.FieldDeletedAt)
  19650. }
  19651. if m.FieldCleared(wx.FieldServerID) {
  19652. fields = append(fields, wx.FieldServerID)
  19653. }
  19654. if m.FieldCleared(wx.FieldOrganizationID) {
  19655. fields = append(fields, wx.FieldOrganizationID)
  19656. }
  19657. if m.FieldCleared(wx.FieldAPIBase) {
  19658. fields = append(fields, wx.FieldAPIBase)
  19659. }
  19660. if m.FieldCleared(wx.FieldAPIKey) {
  19661. fields = append(fields, wx.FieldAPIKey)
  19662. }
  19663. return fields
  19664. }
  19665. // FieldCleared returns a boolean indicating if a field with the given name was
  19666. // cleared in this mutation.
  19667. func (m *WxMutation) FieldCleared(name string) bool {
  19668. _, ok := m.clearedFields[name]
  19669. return ok
  19670. }
  19671. // ClearField clears the value of the field with the given name. It returns an
  19672. // error if the field is not defined in the schema.
  19673. func (m *WxMutation) ClearField(name string) error {
  19674. switch name {
  19675. case wx.FieldStatus:
  19676. m.ClearStatus()
  19677. return nil
  19678. case wx.FieldDeletedAt:
  19679. m.ClearDeletedAt()
  19680. return nil
  19681. case wx.FieldServerID:
  19682. m.ClearServerID()
  19683. return nil
  19684. case wx.FieldOrganizationID:
  19685. m.ClearOrganizationID()
  19686. return nil
  19687. case wx.FieldAPIBase:
  19688. m.ClearAPIBase()
  19689. return nil
  19690. case wx.FieldAPIKey:
  19691. m.ClearAPIKey()
  19692. return nil
  19693. }
  19694. return fmt.Errorf("unknown Wx nullable field %s", name)
  19695. }
  19696. // ResetField resets all changes in the mutation for the field with the given name.
  19697. // It returns an error if the field is not defined in the schema.
  19698. func (m *WxMutation) ResetField(name string) error {
  19699. switch name {
  19700. case wx.FieldCreatedAt:
  19701. m.ResetCreatedAt()
  19702. return nil
  19703. case wx.FieldUpdatedAt:
  19704. m.ResetUpdatedAt()
  19705. return nil
  19706. case wx.FieldStatus:
  19707. m.ResetStatus()
  19708. return nil
  19709. case wx.FieldDeletedAt:
  19710. m.ResetDeletedAt()
  19711. return nil
  19712. case wx.FieldServerID:
  19713. m.ResetServerID()
  19714. return nil
  19715. case wx.FieldPort:
  19716. m.ResetPort()
  19717. return nil
  19718. case wx.FieldProcessID:
  19719. m.ResetProcessID()
  19720. return nil
  19721. case wx.FieldCallback:
  19722. m.ResetCallback()
  19723. return nil
  19724. case wx.FieldWxid:
  19725. m.ResetWxid()
  19726. return nil
  19727. case wx.FieldAccount:
  19728. m.ResetAccount()
  19729. return nil
  19730. case wx.FieldNickname:
  19731. m.ResetNickname()
  19732. return nil
  19733. case wx.FieldTel:
  19734. m.ResetTel()
  19735. return nil
  19736. case wx.FieldHeadBig:
  19737. m.ResetHeadBig()
  19738. return nil
  19739. case wx.FieldOrganizationID:
  19740. m.ResetOrganizationID()
  19741. return nil
  19742. case wx.FieldAgentID:
  19743. m.ResetAgentID()
  19744. return nil
  19745. case wx.FieldAPIBase:
  19746. m.ResetAPIBase()
  19747. return nil
  19748. case wx.FieldAPIKey:
  19749. m.ResetAPIKey()
  19750. return nil
  19751. case wx.FieldAllowList:
  19752. m.ResetAllowList()
  19753. return nil
  19754. case wx.FieldGroupAllowList:
  19755. m.ResetGroupAllowList()
  19756. return nil
  19757. case wx.FieldBlockList:
  19758. m.ResetBlockList()
  19759. return nil
  19760. case wx.FieldGroupBlockList:
  19761. m.ResetGroupBlockList()
  19762. return nil
  19763. }
  19764. return fmt.Errorf("unknown Wx field %s", name)
  19765. }
  19766. // AddedEdges returns all edge names that were set/added in this mutation.
  19767. func (m *WxMutation) AddedEdges() []string {
  19768. edges := make([]string, 0, 2)
  19769. if m.server != nil {
  19770. edges = append(edges, wx.EdgeServer)
  19771. }
  19772. if m.agent != nil {
  19773. edges = append(edges, wx.EdgeAgent)
  19774. }
  19775. return edges
  19776. }
  19777. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19778. // name in this mutation.
  19779. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  19780. switch name {
  19781. case wx.EdgeServer:
  19782. if id := m.server; id != nil {
  19783. return []ent.Value{*id}
  19784. }
  19785. case wx.EdgeAgent:
  19786. if id := m.agent; id != nil {
  19787. return []ent.Value{*id}
  19788. }
  19789. }
  19790. return nil
  19791. }
  19792. // RemovedEdges returns all edge names that were removed in this mutation.
  19793. func (m *WxMutation) RemovedEdges() []string {
  19794. edges := make([]string, 0, 2)
  19795. return edges
  19796. }
  19797. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19798. // the given name in this mutation.
  19799. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  19800. return nil
  19801. }
  19802. // ClearedEdges returns all edge names that were cleared in this mutation.
  19803. func (m *WxMutation) ClearedEdges() []string {
  19804. edges := make([]string, 0, 2)
  19805. if m.clearedserver {
  19806. edges = append(edges, wx.EdgeServer)
  19807. }
  19808. if m.clearedagent {
  19809. edges = append(edges, wx.EdgeAgent)
  19810. }
  19811. return edges
  19812. }
  19813. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19814. // was cleared in this mutation.
  19815. func (m *WxMutation) EdgeCleared(name string) bool {
  19816. switch name {
  19817. case wx.EdgeServer:
  19818. return m.clearedserver
  19819. case wx.EdgeAgent:
  19820. return m.clearedagent
  19821. }
  19822. return false
  19823. }
  19824. // ClearEdge clears the value of the edge with the given name. It returns an error
  19825. // if that edge is not defined in the schema.
  19826. func (m *WxMutation) ClearEdge(name string) error {
  19827. switch name {
  19828. case wx.EdgeServer:
  19829. m.ClearServer()
  19830. return nil
  19831. case wx.EdgeAgent:
  19832. m.ClearAgent()
  19833. return nil
  19834. }
  19835. return fmt.Errorf("unknown Wx unique edge %s", name)
  19836. }
  19837. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19838. // It returns an error if the edge is not defined in the schema.
  19839. func (m *WxMutation) ResetEdge(name string) error {
  19840. switch name {
  19841. case wx.EdgeServer:
  19842. m.ResetServer()
  19843. return nil
  19844. case wx.EdgeAgent:
  19845. m.ResetAgent()
  19846. return nil
  19847. }
  19848. return fmt.Errorf("unknown Wx edge %s", name)
  19849. }