mutation.go 561 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/batchmsg"
  11. "wechat-api/ent/contact"
  12. "wechat-api/ent/custom_types"
  13. "wechat-api/ent/employee"
  14. "wechat-api/ent/label"
  15. "wechat-api/ent/labelrelationship"
  16. "wechat-api/ent/message"
  17. "wechat-api/ent/messagerecords"
  18. "wechat-api/ent/msg"
  19. "wechat-api/ent/predicate"
  20. "wechat-api/ent/server"
  21. "wechat-api/ent/sopnode"
  22. "wechat-api/ent/sopstage"
  23. "wechat-api/ent/soptask"
  24. "wechat-api/ent/tutorial"
  25. "wechat-api/ent/workexperience"
  26. "wechat-api/ent/wx"
  27. "entgo.io/ent"
  28. "entgo.io/ent/dialect/sql"
  29. )
  30. const (
  31. // Operation types.
  32. OpCreate = ent.OpCreate
  33. OpDelete = ent.OpDelete
  34. OpDeleteOne = ent.OpDeleteOne
  35. OpUpdate = ent.OpUpdate
  36. OpUpdateOne = ent.OpUpdateOne
  37. // Node types.
  38. TypeAgent = "Agent"
  39. TypeBatchMsg = "BatchMsg"
  40. TypeContact = "Contact"
  41. TypeEmployee = "Employee"
  42. TypeLabel = "Label"
  43. TypeLabelRelationship = "LabelRelationship"
  44. TypeMessage = "Message"
  45. TypeMessageRecords = "MessageRecords"
  46. TypeMsg = "Msg"
  47. TypeServer = "Server"
  48. TypeSopNode = "SopNode"
  49. TypeSopStage = "SopStage"
  50. TypeSopTask = "SopTask"
  51. TypeTutorial = "Tutorial"
  52. TypeWorkExperience = "WorkExperience"
  53. TypeWx = "Wx"
  54. )
  55. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  56. type AgentMutation struct {
  57. config
  58. op Op
  59. typ string
  60. id *uint64
  61. created_at *time.Time
  62. updated_at *time.Time
  63. deleted_at *time.Time
  64. name *string
  65. role *string
  66. status *int
  67. addstatus *int
  68. background *string
  69. examples *string
  70. organization_id *uint64
  71. addorganization_id *int64
  72. clearedFields map[string]struct{}
  73. wx_agent map[uint64]struct{}
  74. removedwx_agent map[uint64]struct{}
  75. clearedwx_agent bool
  76. done bool
  77. oldValue func(context.Context) (*Agent, error)
  78. predicates []predicate.Agent
  79. }
  80. var _ ent.Mutation = (*AgentMutation)(nil)
  81. // agentOption allows management of the mutation configuration using functional options.
  82. type agentOption func(*AgentMutation)
  83. // newAgentMutation creates new mutation for the Agent entity.
  84. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  85. m := &AgentMutation{
  86. config: c,
  87. op: op,
  88. typ: TypeAgent,
  89. clearedFields: make(map[string]struct{}),
  90. }
  91. for _, opt := range opts {
  92. opt(m)
  93. }
  94. return m
  95. }
  96. // withAgentID sets the ID field of the mutation.
  97. func withAgentID(id uint64) agentOption {
  98. return func(m *AgentMutation) {
  99. var (
  100. err error
  101. once sync.Once
  102. value *Agent
  103. )
  104. m.oldValue = func(ctx context.Context) (*Agent, error) {
  105. once.Do(func() {
  106. if m.done {
  107. err = errors.New("querying old values post mutation is not allowed")
  108. } else {
  109. value, err = m.Client().Agent.Get(ctx, id)
  110. }
  111. })
  112. return value, err
  113. }
  114. m.id = &id
  115. }
  116. }
  117. // withAgent sets the old Agent of the mutation.
  118. func withAgent(node *Agent) agentOption {
  119. return func(m *AgentMutation) {
  120. m.oldValue = func(context.Context) (*Agent, error) {
  121. return node, nil
  122. }
  123. m.id = &node.ID
  124. }
  125. }
  126. // Client returns a new `ent.Client` from the mutation. If the mutation was
  127. // executed in a transaction (ent.Tx), a transactional client is returned.
  128. func (m AgentMutation) Client() *Client {
  129. client := &Client{config: m.config}
  130. client.init()
  131. return client
  132. }
  133. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  134. // it returns an error otherwise.
  135. func (m AgentMutation) Tx() (*Tx, error) {
  136. if _, ok := m.driver.(*txDriver); !ok {
  137. return nil, errors.New("ent: mutation is not running in a transaction")
  138. }
  139. tx := &Tx{config: m.config}
  140. tx.init()
  141. return tx, nil
  142. }
  143. // SetID sets the value of the id field. Note that this
  144. // operation is only accepted on creation of Agent entities.
  145. func (m *AgentMutation) SetID(id uint64) {
  146. m.id = &id
  147. }
  148. // ID returns the ID value in the mutation. Note that the ID is only available
  149. // if it was provided to the builder or after it was returned from the database.
  150. func (m *AgentMutation) ID() (id uint64, exists bool) {
  151. if m.id == nil {
  152. return
  153. }
  154. return *m.id, true
  155. }
  156. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  157. // That means, if the mutation is applied within a transaction with an isolation level such
  158. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  159. // or updated by the mutation.
  160. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  161. switch {
  162. case m.op.Is(OpUpdateOne | OpDeleteOne):
  163. id, exists := m.ID()
  164. if exists {
  165. return []uint64{id}, nil
  166. }
  167. fallthrough
  168. case m.op.Is(OpUpdate | OpDelete):
  169. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  170. default:
  171. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  172. }
  173. }
  174. // SetCreatedAt sets the "created_at" field.
  175. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  176. m.created_at = &t
  177. }
  178. // CreatedAt returns the value of the "created_at" field in the mutation.
  179. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  180. v := m.created_at
  181. if v == nil {
  182. return
  183. }
  184. return *v, true
  185. }
  186. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  187. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  189. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  190. if !m.op.Is(OpUpdateOne) {
  191. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  192. }
  193. if m.id == nil || m.oldValue == nil {
  194. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  195. }
  196. oldValue, err := m.oldValue(ctx)
  197. if err != nil {
  198. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  199. }
  200. return oldValue.CreatedAt, nil
  201. }
  202. // ResetCreatedAt resets all changes to the "created_at" field.
  203. func (m *AgentMutation) ResetCreatedAt() {
  204. m.created_at = nil
  205. }
  206. // SetUpdatedAt sets the "updated_at" field.
  207. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  208. m.updated_at = &t
  209. }
  210. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  211. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  212. v := m.updated_at
  213. if v == nil {
  214. return
  215. }
  216. return *v, true
  217. }
  218. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  219. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  221. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  222. if !m.op.Is(OpUpdateOne) {
  223. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  224. }
  225. if m.id == nil || m.oldValue == nil {
  226. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  227. }
  228. oldValue, err := m.oldValue(ctx)
  229. if err != nil {
  230. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  231. }
  232. return oldValue.UpdatedAt, nil
  233. }
  234. // ResetUpdatedAt resets all changes to the "updated_at" field.
  235. func (m *AgentMutation) ResetUpdatedAt() {
  236. m.updated_at = nil
  237. }
  238. // SetDeletedAt sets the "deleted_at" field.
  239. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  240. m.deleted_at = &t
  241. }
  242. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  243. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  244. v := m.deleted_at
  245. if v == nil {
  246. return
  247. }
  248. return *v, true
  249. }
  250. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  251. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  253. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  254. if !m.op.Is(OpUpdateOne) {
  255. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  256. }
  257. if m.id == nil || m.oldValue == nil {
  258. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  259. }
  260. oldValue, err := m.oldValue(ctx)
  261. if err != nil {
  262. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  263. }
  264. return oldValue.DeletedAt, nil
  265. }
  266. // ClearDeletedAt clears the value of the "deleted_at" field.
  267. func (m *AgentMutation) ClearDeletedAt() {
  268. m.deleted_at = nil
  269. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  270. }
  271. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  272. func (m *AgentMutation) DeletedAtCleared() bool {
  273. _, ok := m.clearedFields[agent.FieldDeletedAt]
  274. return ok
  275. }
  276. // ResetDeletedAt resets all changes to the "deleted_at" field.
  277. func (m *AgentMutation) ResetDeletedAt() {
  278. m.deleted_at = nil
  279. delete(m.clearedFields, agent.FieldDeletedAt)
  280. }
  281. // SetName sets the "name" field.
  282. func (m *AgentMutation) SetName(s string) {
  283. m.name = &s
  284. }
  285. // Name returns the value of the "name" field in the mutation.
  286. func (m *AgentMutation) Name() (r string, exists bool) {
  287. v := m.name
  288. if v == nil {
  289. return
  290. }
  291. return *v, true
  292. }
  293. // OldName returns the old "name" field's value of the Agent entity.
  294. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  296. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  297. if !m.op.Is(OpUpdateOne) {
  298. return v, errors.New("OldName is only allowed on UpdateOne operations")
  299. }
  300. if m.id == nil || m.oldValue == nil {
  301. return v, errors.New("OldName requires an ID field in the mutation")
  302. }
  303. oldValue, err := m.oldValue(ctx)
  304. if err != nil {
  305. return v, fmt.Errorf("querying old value for OldName: %w", err)
  306. }
  307. return oldValue.Name, nil
  308. }
  309. // ResetName resets all changes to the "name" field.
  310. func (m *AgentMutation) ResetName() {
  311. m.name = nil
  312. }
  313. // SetRole sets the "role" field.
  314. func (m *AgentMutation) SetRole(s string) {
  315. m.role = &s
  316. }
  317. // Role returns the value of the "role" field in the mutation.
  318. func (m *AgentMutation) Role() (r string, exists bool) {
  319. v := m.role
  320. if v == nil {
  321. return
  322. }
  323. return *v, true
  324. }
  325. // OldRole returns the old "role" field's value of the Agent entity.
  326. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  328. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  329. if !m.op.Is(OpUpdateOne) {
  330. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  331. }
  332. if m.id == nil || m.oldValue == nil {
  333. return v, errors.New("OldRole requires an ID field in the mutation")
  334. }
  335. oldValue, err := m.oldValue(ctx)
  336. if err != nil {
  337. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  338. }
  339. return oldValue.Role, nil
  340. }
  341. // ResetRole resets all changes to the "role" field.
  342. func (m *AgentMutation) ResetRole() {
  343. m.role = nil
  344. }
  345. // SetStatus sets the "status" field.
  346. func (m *AgentMutation) SetStatus(i int) {
  347. m.status = &i
  348. m.addstatus = nil
  349. }
  350. // Status returns the value of the "status" field in the mutation.
  351. func (m *AgentMutation) Status() (r int, exists bool) {
  352. v := m.status
  353. if v == nil {
  354. return
  355. }
  356. return *v, true
  357. }
  358. // OldStatus returns the old "status" field's value of the Agent entity.
  359. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  361. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  362. if !m.op.Is(OpUpdateOne) {
  363. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  364. }
  365. if m.id == nil || m.oldValue == nil {
  366. return v, errors.New("OldStatus requires an ID field in the mutation")
  367. }
  368. oldValue, err := m.oldValue(ctx)
  369. if err != nil {
  370. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  371. }
  372. return oldValue.Status, nil
  373. }
  374. // AddStatus adds i to the "status" field.
  375. func (m *AgentMutation) AddStatus(i int) {
  376. if m.addstatus != nil {
  377. *m.addstatus += i
  378. } else {
  379. m.addstatus = &i
  380. }
  381. }
  382. // AddedStatus returns the value that was added to the "status" field in this mutation.
  383. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  384. v := m.addstatus
  385. if v == nil {
  386. return
  387. }
  388. return *v, true
  389. }
  390. // ClearStatus clears the value of the "status" field.
  391. func (m *AgentMutation) ClearStatus() {
  392. m.status = nil
  393. m.addstatus = nil
  394. m.clearedFields[agent.FieldStatus] = struct{}{}
  395. }
  396. // StatusCleared returns if the "status" field was cleared in this mutation.
  397. func (m *AgentMutation) StatusCleared() bool {
  398. _, ok := m.clearedFields[agent.FieldStatus]
  399. return ok
  400. }
  401. // ResetStatus resets all changes to the "status" field.
  402. func (m *AgentMutation) ResetStatus() {
  403. m.status = nil
  404. m.addstatus = nil
  405. delete(m.clearedFields, agent.FieldStatus)
  406. }
  407. // SetBackground sets the "background" field.
  408. func (m *AgentMutation) SetBackground(s string) {
  409. m.background = &s
  410. }
  411. // Background returns the value of the "background" field in the mutation.
  412. func (m *AgentMutation) Background() (r string, exists bool) {
  413. v := m.background
  414. if v == nil {
  415. return
  416. }
  417. return *v, true
  418. }
  419. // OldBackground returns the old "background" field's value of the Agent entity.
  420. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  422. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  423. if !m.op.Is(OpUpdateOne) {
  424. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  425. }
  426. if m.id == nil || m.oldValue == nil {
  427. return v, errors.New("OldBackground requires an ID field in the mutation")
  428. }
  429. oldValue, err := m.oldValue(ctx)
  430. if err != nil {
  431. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  432. }
  433. return oldValue.Background, nil
  434. }
  435. // ClearBackground clears the value of the "background" field.
  436. func (m *AgentMutation) ClearBackground() {
  437. m.background = nil
  438. m.clearedFields[agent.FieldBackground] = struct{}{}
  439. }
  440. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  441. func (m *AgentMutation) BackgroundCleared() bool {
  442. _, ok := m.clearedFields[agent.FieldBackground]
  443. return ok
  444. }
  445. // ResetBackground resets all changes to the "background" field.
  446. func (m *AgentMutation) ResetBackground() {
  447. m.background = nil
  448. delete(m.clearedFields, agent.FieldBackground)
  449. }
  450. // SetExamples sets the "examples" field.
  451. func (m *AgentMutation) SetExamples(s string) {
  452. m.examples = &s
  453. }
  454. // Examples returns the value of the "examples" field in the mutation.
  455. func (m *AgentMutation) Examples() (r string, exists bool) {
  456. v := m.examples
  457. if v == nil {
  458. return
  459. }
  460. return *v, true
  461. }
  462. // OldExamples returns the old "examples" field's value of the Agent entity.
  463. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  465. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  466. if !m.op.Is(OpUpdateOne) {
  467. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  468. }
  469. if m.id == nil || m.oldValue == nil {
  470. return v, errors.New("OldExamples requires an ID field in the mutation")
  471. }
  472. oldValue, err := m.oldValue(ctx)
  473. if err != nil {
  474. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  475. }
  476. return oldValue.Examples, nil
  477. }
  478. // ClearExamples clears the value of the "examples" field.
  479. func (m *AgentMutation) ClearExamples() {
  480. m.examples = nil
  481. m.clearedFields[agent.FieldExamples] = struct{}{}
  482. }
  483. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  484. func (m *AgentMutation) ExamplesCleared() bool {
  485. _, ok := m.clearedFields[agent.FieldExamples]
  486. return ok
  487. }
  488. // ResetExamples resets all changes to the "examples" field.
  489. func (m *AgentMutation) ResetExamples() {
  490. m.examples = nil
  491. delete(m.clearedFields, agent.FieldExamples)
  492. }
  493. // SetOrganizationID sets the "organization_id" field.
  494. func (m *AgentMutation) SetOrganizationID(u uint64) {
  495. m.organization_id = &u
  496. m.addorganization_id = nil
  497. }
  498. // OrganizationID returns the value of the "organization_id" field in the mutation.
  499. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  500. v := m.organization_id
  501. if v == nil {
  502. return
  503. }
  504. return *v, true
  505. }
  506. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  507. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  509. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  510. if !m.op.Is(OpUpdateOne) {
  511. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  512. }
  513. if m.id == nil || m.oldValue == nil {
  514. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  515. }
  516. oldValue, err := m.oldValue(ctx)
  517. if err != nil {
  518. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  519. }
  520. return oldValue.OrganizationID, nil
  521. }
  522. // AddOrganizationID adds u to the "organization_id" field.
  523. func (m *AgentMutation) AddOrganizationID(u int64) {
  524. if m.addorganization_id != nil {
  525. *m.addorganization_id += u
  526. } else {
  527. m.addorganization_id = &u
  528. }
  529. }
  530. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  531. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  532. v := m.addorganization_id
  533. if v == nil {
  534. return
  535. }
  536. return *v, true
  537. }
  538. // ResetOrganizationID resets all changes to the "organization_id" field.
  539. func (m *AgentMutation) ResetOrganizationID() {
  540. m.organization_id = nil
  541. m.addorganization_id = nil
  542. }
  543. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  544. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  545. if m.wx_agent == nil {
  546. m.wx_agent = make(map[uint64]struct{})
  547. }
  548. for i := range ids {
  549. m.wx_agent[ids[i]] = struct{}{}
  550. }
  551. }
  552. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  553. func (m *AgentMutation) ClearWxAgent() {
  554. m.clearedwx_agent = true
  555. }
  556. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  557. func (m *AgentMutation) WxAgentCleared() bool {
  558. return m.clearedwx_agent
  559. }
  560. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  561. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  562. if m.removedwx_agent == nil {
  563. m.removedwx_agent = make(map[uint64]struct{})
  564. }
  565. for i := range ids {
  566. delete(m.wx_agent, ids[i])
  567. m.removedwx_agent[ids[i]] = struct{}{}
  568. }
  569. }
  570. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  571. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  572. for id := range m.removedwx_agent {
  573. ids = append(ids, id)
  574. }
  575. return
  576. }
  577. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  578. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  579. for id := range m.wx_agent {
  580. ids = append(ids, id)
  581. }
  582. return
  583. }
  584. // ResetWxAgent resets all changes to the "wx_agent" edge.
  585. func (m *AgentMutation) ResetWxAgent() {
  586. m.wx_agent = nil
  587. m.clearedwx_agent = false
  588. m.removedwx_agent = nil
  589. }
  590. // Where appends a list predicates to the AgentMutation builder.
  591. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  592. m.predicates = append(m.predicates, ps...)
  593. }
  594. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  595. // users can use type-assertion to append predicates that do not depend on any generated package.
  596. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  597. p := make([]predicate.Agent, len(ps))
  598. for i := range ps {
  599. p[i] = ps[i]
  600. }
  601. m.Where(p...)
  602. }
  603. // Op returns the operation name.
  604. func (m *AgentMutation) Op() Op {
  605. return m.op
  606. }
  607. // SetOp allows setting the mutation operation.
  608. func (m *AgentMutation) SetOp(op Op) {
  609. m.op = op
  610. }
  611. // Type returns the node type of this mutation (Agent).
  612. func (m *AgentMutation) Type() string {
  613. return m.typ
  614. }
  615. // Fields returns all fields that were changed during this mutation. Note that in
  616. // order to get all numeric fields that were incremented/decremented, call
  617. // AddedFields().
  618. func (m *AgentMutation) Fields() []string {
  619. fields := make([]string, 0, 9)
  620. if m.created_at != nil {
  621. fields = append(fields, agent.FieldCreatedAt)
  622. }
  623. if m.updated_at != nil {
  624. fields = append(fields, agent.FieldUpdatedAt)
  625. }
  626. if m.deleted_at != nil {
  627. fields = append(fields, agent.FieldDeletedAt)
  628. }
  629. if m.name != nil {
  630. fields = append(fields, agent.FieldName)
  631. }
  632. if m.role != nil {
  633. fields = append(fields, agent.FieldRole)
  634. }
  635. if m.status != nil {
  636. fields = append(fields, agent.FieldStatus)
  637. }
  638. if m.background != nil {
  639. fields = append(fields, agent.FieldBackground)
  640. }
  641. if m.examples != nil {
  642. fields = append(fields, agent.FieldExamples)
  643. }
  644. if m.organization_id != nil {
  645. fields = append(fields, agent.FieldOrganizationID)
  646. }
  647. return fields
  648. }
  649. // Field returns the value of a field with the given name. The second boolean
  650. // return value indicates that this field was not set, or was not defined in the
  651. // schema.
  652. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  653. switch name {
  654. case agent.FieldCreatedAt:
  655. return m.CreatedAt()
  656. case agent.FieldUpdatedAt:
  657. return m.UpdatedAt()
  658. case agent.FieldDeletedAt:
  659. return m.DeletedAt()
  660. case agent.FieldName:
  661. return m.Name()
  662. case agent.FieldRole:
  663. return m.Role()
  664. case agent.FieldStatus:
  665. return m.Status()
  666. case agent.FieldBackground:
  667. return m.Background()
  668. case agent.FieldExamples:
  669. return m.Examples()
  670. case agent.FieldOrganizationID:
  671. return m.OrganizationID()
  672. }
  673. return nil, false
  674. }
  675. // OldField returns the old value of the field from the database. An error is
  676. // returned if the mutation operation is not UpdateOne, or the query to the
  677. // database failed.
  678. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  679. switch name {
  680. case agent.FieldCreatedAt:
  681. return m.OldCreatedAt(ctx)
  682. case agent.FieldUpdatedAt:
  683. return m.OldUpdatedAt(ctx)
  684. case agent.FieldDeletedAt:
  685. return m.OldDeletedAt(ctx)
  686. case agent.FieldName:
  687. return m.OldName(ctx)
  688. case agent.FieldRole:
  689. return m.OldRole(ctx)
  690. case agent.FieldStatus:
  691. return m.OldStatus(ctx)
  692. case agent.FieldBackground:
  693. return m.OldBackground(ctx)
  694. case agent.FieldExamples:
  695. return m.OldExamples(ctx)
  696. case agent.FieldOrganizationID:
  697. return m.OldOrganizationID(ctx)
  698. }
  699. return nil, fmt.Errorf("unknown Agent field %s", name)
  700. }
  701. // SetField sets the value of a field with the given name. It returns an error if
  702. // the field is not defined in the schema, or if the type mismatched the field
  703. // type.
  704. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  705. switch name {
  706. case agent.FieldCreatedAt:
  707. v, ok := value.(time.Time)
  708. if !ok {
  709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  710. }
  711. m.SetCreatedAt(v)
  712. return nil
  713. case agent.FieldUpdatedAt:
  714. v, ok := value.(time.Time)
  715. if !ok {
  716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  717. }
  718. m.SetUpdatedAt(v)
  719. return nil
  720. case agent.FieldDeletedAt:
  721. v, ok := value.(time.Time)
  722. if !ok {
  723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  724. }
  725. m.SetDeletedAt(v)
  726. return nil
  727. case agent.FieldName:
  728. v, ok := value.(string)
  729. if !ok {
  730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  731. }
  732. m.SetName(v)
  733. return nil
  734. case agent.FieldRole:
  735. v, ok := value.(string)
  736. if !ok {
  737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  738. }
  739. m.SetRole(v)
  740. return nil
  741. case agent.FieldStatus:
  742. v, ok := value.(int)
  743. if !ok {
  744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  745. }
  746. m.SetStatus(v)
  747. return nil
  748. case agent.FieldBackground:
  749. v, ok := value.(string)
  750. if !ok {
  751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  752. }
  753. m.SetBackground(v)
  754. return nil
  755. case agent.FieldExamples:
  756. v, ok := value.(string)
  757. if !ok {
  758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  759. }
  760. m.SetExamples(v)
  761. return nil
  762. case agent.FieldOrganizationID:
  763. v, ok := value.(uint64)
  764. if !ok {
  765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  766. }
  767. m.SetOrganizationID(v)
  768. return nil
  769. }
  770. return fmt.Errorf("unknown Agent field %s", name)
  771. }
  772. // AddedFields returns all numeric fields that were incremented/decremented during
  773. // this mutation.
  774. func (m *AgentMutation) AddedFields() []string {
  775. var fields []string
  776. if m.addstatus != nil {
  777. fields = append(fields, agent.FieldStatus)
  778. }
  779. if m.addorganization_id != nil {
  780. fields = append(fields, agent.FieldOrganizationID)
  781. }
  782. return fields
  783. }
  784. // AddedField returns the numeric value that was incremented/decremented on a field
  785. // with the given name. The second boolean return value indicates that this field
  786. // was not set, or was not defined in the schema.
  787. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  788. switch name {
  789. case agent.FieldStatus:
  790. return m.AddedStatus()
  791. case agent.FieldOrganizationID:
  792. return m.AddedOrganizationID()
  793. }
  794. return nil, false
  795. }
  796. // AddField adds the value to the field with the given name. It returns an error if
  797. // the field is not defined in the schema, or if the type mismatched the field
  798. // type.
  799. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  800. switch name {
  801. case agent.FieldStatus:
  802. v, ok := value.(int)
  803. if !ok {
  804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  805. }
  806. m.AddStatus(v)
  807. return nil
  808. case agent.FieldOrganizationID:
  809. v, ok := value.(int64)
  810. if !ok {
  811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  812. }
  813. m.AddOrganizationID(v)
  814. return nil
  815. }
  816. return fmt.Errorf("unknown Agent numeric field %s", name)
  817. }
  818. // ClearedFields returns all nullable fields that were cleared during this
  819. // mutation.
  820. func (m *AgentMutation) ClearedFields() []string {
  821. var fields []string
  822. if m.FieldCleared(agent.FieldDeletedAt) {
  823. fields = append(fields, agent.FieldDeletedAt)
  824. }
  825. if m.FieldCleared(agent.FieldStatus) {
  826. fields = append(fields, agent.FieldStatus)
  827. }
  828. if m.FieldCleared(agent.FieldBackground) {
  829. fields = append(fields, agent.FieldBackground)
  830. }
  831. if m.FieldCleared(agent.FieldExamples) {
  832. fields = append(fields, agent.FieldExamples)
  833. }
  834. return fields
  835. }
  836. // FieldCleared returns a boolean indicating if a field with the given name was
  837. // cleared in this mutation.
  838. func (m *AgentMutation) FieldCleared(name string) bool {
  839. _, ok := m.clearedFields[name]
  840. return ok
  841. }
  842. // ClearField clears the value of the field with the given name. It returns an
  843. // error if the field is not defined in the schema.
  844. func (m *AgentMutation) ClearField(name string) error {
  845. switch name {
  846. case agent.FieldDeletedAt:
  847. m.ClearDeletedAt()
  848. return nil
  849. case agent.FieldStatus:
  850. m.ClearStatus()
  851. return nil
  852. case agent.FieldBackground:
  853. m.ClearBackground()
  854. return nil
  855. case agent.FieldExamples:
  856. m.ClearExamples()
  857. return nil
  858. }
  859. return fmt.Errorf("unknown Agent nullable field %s", name)
  860. }
  861. // ResetField resets all changes in the mutation for the field with the given name.
  862. // It returns an error if the field is not defined in the schema.
  863. func (m *AgentMutation) ResetField(name string) error {
  864. switch name {
  865. case agent.FieldCreatedAt:
  866. m.ResetCreatedAt()
  867. return nil
  868. case agent.FieldUpdatedAt:
  869. m.ResetUpdatedAt()
  870. return nil
  871. case agent.FieldDeletedAt:
  872. m.ResetDeletedAt()
  873. return nil
  874. case agent.FieldName:
  875. m.ResetName()
  876. return nil
  877. case agent.FieldRole:
  878. m.ResetRole()
  879. return nil
  880. case agent.FieldStatus:
  881. m.ResetStatus()
  882. return nil
  883. case agent.FieldBackground:
  884. m.ResetBackground()
  885. return nil
  886. case agent.FieldExamples:
  887. m.ResetExamples()
  888. return nil
  889. case agent.FieldOrganizationID:
  890. m.ResetOrganizationID()
  891. return nil
  892. }
  893. return fmt.Errorf("unknown Agent field %s", name)
  894. }
  895. // AddedEdges returns all edge names that were set/added in this mutation.
  896. func (m *AgentMutation) AddedEdges() []string {
  897. edges := make([]string, 0, 1)
  898. if m.wx_agent != nil {
  899. edges = append(edges, agent.EdgeWxAgent)
  900. }
  901. return edges
  902. }
  903. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  904. // name in this mutation.
  905. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  906. switch name {
  907. case agent.EdgeWxAgent:
  908. ids := make([]ent.Value, 0, len(m.wx_agent))
  909. for id := range m.wx_agent {
  910. ids = append(ids, id)
  911. }
  912. return ids
  913. }
  914. return nil
  915. }
  916. // RemovedEdges returns all edge names that were removed in this mutation.
  917. func (m *AgentMutation) RemovedEdges() []string {
  918. edges := make([]string, 0, 1)
  919. if m.removedwx_agent != nil {
  920. edges = append(edges, agent.EdgeWxAgent)
  921. }
  922. return edges
  923. }
  924. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  925. // the given name in this mutation.
  926. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  927. switch name {
  928. case agent.EdgeWxAgent:
  929. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  930. for id := range m.removedwx_agent {
  931. ids = append(ids, id)
  932. }
  933. return ids
  934. }
  935. return nil
  936. }
  937. // ClearedEdges returns all edge names that were cleared in this mutation.
  938. func (m *AgentMutation) ClearedEdges() []string {
  939. edges := make([]string, 0, 1)
  940. if m.clearedwx_agent {
  941. edges = append(edges, agent.EdgeWxAgent)
  942. }
  943. return edges
  944. }
  945. // EdgeCleared returns a boolean which indicates if the edge with the given name
  946. // was cleared in this mutation.
  947. func (m *AgentMutation) EdgeCleared(name string) bool {
  948. switch name {
  949. case agent.EdgeWxAgent:
  950. return m.clearedwx_agent
  951. }
  952. return false
  953. }
  954. // ClearEdge clears the value of the edge with the given name. It returns an error
  955. // if that edge is not defined in the schema.
  956. func (m *AgentMutation) ClearEdge(name string) error {
  957. switch name {
  958. }
  959. return fmt.Errorf("unknown Agent unique edge %s", name)
  960. }
  961. // ResetEdge resets all changes to the edge with the given name in this mutation.
  962. // It returns an error if the edge is not defined in the schema.
  963. func (m *AgentMutation) ResetEdge(name string) error {
  964. switch name {
  965. case agent.EdgeWxAgent:
  966. m.ResetWxAgent()
  967. return nil
  968. }
  969. return fmt.Errorf("unknown Agent edge %s", name)
  970. }
  971. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  972. type BatchMsgMutation struct {
  973. config
  974. op Op
  975. typ string
  976. id *uint64
  977. created_at *time.Time
  978. updated_at *time.Time
  979. deleted_at *time.Time
  980. status *uint8
  981. addstatus *int8
  982. batch_no *string
  983. task_name *string
  984. fromwxid *string
  985. msg *string
  986. tag *string
  987. total *int32
  988. addtotal *int32
  989. success *int32
  990. addsuccess *int32
  991. fail *int32
  992. addfail *int32
  993. start_time *time.Time
  994. stop_time *time.Time
  995. send_time *time.Time
  996. _type *int32
  997. add_type *int32
  998. clearedFields map[string]struct{}
  999. done bool
  1000. oldValue func(context.Context) (*BatchMsg, error)
  1001. predicates []predicate.BatchMsg
  1002. }
  1003. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  1004. // batchmsgOption allows management of the mutation configuration using functional options.
  1005. type batchmsgOption func(*BatchMsgMutation)
  1006. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  1007. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  1008. m := &BatchMsgMutation{
  1009. config: c,
  1010. op: op,
  1011. typ: TypeBatchMsg,
  1012. clearedFields: make(map[string]struct{}),
  1013. }
  1014. for _, opt := range opts {
  1015. opt(m)
  1016. }
  1017. return m
  1018. }
  1019. // withBatchMsgID sets the ID field of the mutation.
  1020. func withBatchMsgID(id uint64) batchmsgOption {
  1021. return func(m *BatchMsgMutation) {
  1022. var (
  1023. err error
  1024. once sync.Once
  1025. value *BatchMsg
  1026. )
  1027. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  1028. once.Do(func() {
  1029. if m.done {
  1030. err = errors.New("querying old values post mutation is not allowed")
  1031. } else {
  1032. value, err = m.Client().BatchMsg.Get(ctx, id)
  1033. }
  1034. })
  1035. return value, err
  1036. }
  1037. m.id = &id
  1038. }
  1039. }
  1040. // withBatchMsg sets the old BatchMsg of the mutation.
  1041. func withBatchMsg(node *BatchMsg) batchmsgOption {
  1042. return func(m *BatchMsgMutation) {
  1043. m.oldValue = func(context.Context) (*BatchMsg, error) {
  1044. return node, nil
  1045. }
  1046. m.id = &node.ID
  1047. }
  1048. }
  1049. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1050. // executed in a transaction (ent.Tx), a transactional client is returned.
  1051. func (m BatchMsgMutation) Client() *Client {
  1052. client := &Client{config: m.config}
  1053. client.init()
  1054. return client
  1055. }
  1056. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1057. // it returns an error otherwise.
  1058. func (m BatchMsgMutation) Tx() (*Tx, error) {
  1059. if _, ok := m.driver.(*txDriver); !ok {
  1060. return nil, errors.New("ent: mutation is not running in a transaction")
  1061. }
  1062. tx := &Tx{config: m.config}
  1063. tx.init()
  1064. return tx, nil
  1065. }
  1066. // SetID sets the value of the id field. Note that this
  1067. // operation is only accepted on creation of BatchMsg entities.
  1068. func (m *BatchMsgMutation) SetID(id uint64) {
  1069. m.id = &id
  1070. }
  1071. // ID returns the ID value in the mutation. Note that the ID is only available
  1072. // if it was provided to the builder or after it was returned from the database.
  1073. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  1074. if m.id == nil {
  1075. return
  1076. }
  1077. return *m.id, true
  1078. }
  1079. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1080. // That means, if the mutation is applied within a transaction with an isolation level such
  1081. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1082. // or updated by the mutation.
  1083. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  1084. switch {
  1085. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1086. id, exists := m.ID()
  1087. if exists {
  1088. return []uint64{id}, nil
  1089. }
  1090. fallthrough
  1091. case m.op.Is(OpUpdate | OpDelete):
  1092. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  1093. default:
  1094. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1095. }
  1096. }
  1097. // SetCreatedAt sets the "created_at" field.
  1098. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  1099. m.created_at = &t
  1100. }
  1101. // CreatedAt returns the value of the "created_at" field in the mutation.
  1102. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  1103. v := m.created_at
  1104. if v == nil {
  1105. return
  1106. }
  1107. return *v, true
  1108. }
  1109. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  1110. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1112. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  1113. if !m.op.Is(OpUpdateOne) {
  1114. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  1115. }
  1116. if m.id == nil || m.oldValue == nil {
  1117. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  1118. }
  1119. oldValue, err := m.oldValue(ctx)
  1120. if err != nil {
  1121. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  1122. }
  1123. return oldValue.CreatedAt, nil
  1124. }
  1125. // ResetCreatedAt resets all changes to the "created_at" field.
  1126. func (m *BatchMsgMutation) ResetCreatedAt() {
  1127. m.created_at = nil
  1128. }
  1129. // SetUpdatedAt sets the "updated_at" field.
  1130. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  1131. m.updated_at = &t
  1132. }
  1133. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  1134. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  1135. v := m.updated_at
  1136. if v == nil {
  1137. return
  1138. }
  1139. return *v, true
  1140. }
  1141. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  1142. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1144. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  1145. if !m.op.Is(OpUpdateOne) {
  1146. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  1147. }
  1148. if m.id == nil || m.oldValue == nil {
  1149. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  1150. }
  1151. oldValue, err := m.oldValue(ctx)
  1152. if err != nil {
  1153. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  1154. }
  1155. return oldValue.UpdatedAt, nil
  1156. }
  1157. // ResetUpdatedAt resets all changes to the "updated_at" field.
  1158. func (m *BatchMsgMutation) ResetUpdatedAt() {
  1159. m.updated_at = nil
  1160. }
  1161. // SetDeletedAt sets the "deleted_at" field.
  1162. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  1163. m.deleted_at = &t
  1164. }
  1165. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  1166. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  1167. v := m.deleted_at
  1168. if v == nil {
  1169. return
  1170. }
  1171. return *v, true
  1172. }
  1173. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  1174. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1176. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  1177. if !m.op.Is(OpUpdateOne) {
  1178. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  1179. }
  1180. if m.id == nil || m.oldValue == nil {
  1181. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  1182. }
  1183. oldValue, err := m.oldValue(ctx)
  1184. if err != nil {
  1185. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  1186. }
  1187. return oldValue.DeletedAt, nil
  1188. }
  1189. // ClearDeletedAt clears the value of the "deleted_at" field.
  1190. func (m *BatchMsgMutation) ClearDeletedAt() {
  1191. m.deleted_at = nil
  1192. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  1193. }
  1194. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  1195. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  1196. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  1197. return ok
  1198. }
  1199. // ResetDeletedAt resets all changes to the "deleted_at" field.
  1200. func (m *BatchMsgMutation) ResetDeletedAt() {
  1201. m.deleted_at = nil
  1202. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  1203. }
  1204. // SetStatus sets the "status" field.
  1205. func (m *BatchMsgMutation) SetStatus(u uint8) {
  1206. m.status = &u
  1207. m.addstatus = nil
  1208. }
  1209. // Status returns the value of the "status" field in the mutation.
  1210. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  1211. v := m.status
  1212. if v == nil {
  1213. return
  1214. }
  1215. return *v, true
  1216. }
  1217. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  1218. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1220. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  1221. if !m.op.Is(OpUpdateOne) {
  1222. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  1223. }
  1224. if m.id == nil || m.oldValue == nil {
  1225. return v, errors.New("OldStatus requires an ID field in the mutation")
  1226. }
  1227. oldValue, err := m.oldValue(ctx)
  1228. if err != nil {
  1229. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  1230. }
  1231. return oldValue.Status, nil
  1232. }
  1233. // AddStatus adds u to the "status" field.
  1234. func (m *BatchMsgMutation) AddStatus(u int8) {
  1235. if m.addstatus != nil {
  1236. *m.addstatus += u
  1237. } else {
  1238. m.addstatus = &u
  1239. }
  1240. }
  1241. // AddedStatus returns the value that was added to the "status" field in this mutation.
  1242. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  1243. v := m.addstatus
  1244. if v == nil {
  1245. return
  1246. }
  1247. return *v, true
  1248. }
  1249. // ClearStatus clears the value of the "status" field.
  1250. func (m *BatchMsgMutation) ClearStatus() {
  1251. m.status = nil
  1252. m.addstatus = nil
  1253. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  1254. }
  1255. // StatusCleared returns if the "status" field was cleared in this mutation.
  1256. func (m *BatchMsgMutation) StatusCleared() bool {
  1257. _, ok := m.clearedFields[batchmsg.FieldStatus]
  1258. return ok
  1259. }
  1260. // ResetStatus resets all changes to the "status" field.
  1261. func (m *BatchMsgMutation) ResetStatus() {
  1262. m.status = nil
  1263. m.addstatus = nil
  1264. delete(m.clearedFields, batchmsg.FieldStatus)
  1265. }
  1266. // SetBatchNo sets the "batch_no" field.
  1267. func (m *BatchMsgMutation) SetBatchNo(s string) {
  1268. m.batch_no = &s
  1269. }
  1270. // BatchNo returns the value of the "batch_no" field in the mutation.
  1271. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  1272. v := m.batch_no
  1273. if v == nil {
  1274. return
  1275. }
  1276. return *v, true
  1277. }
  1278. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  1279. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1281. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  1282. if !m.op.Is(OpUpdateOne) {
  1283. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  1284. }
  1285. if m.id == nil || m.oldValue == nil {
  1286. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  1287. }
  1288. oldValue, err := m.oldValue(ctx)
  1289. if err != nil {
  1290. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  1291. }
  1292. return oldValue.BatchNo, nil
  1293. }
  1294. // ClearBatchNo clears the value of the "batch_no" field.
  1295. func (m *BatchMsgMutation) ClearBatchNo() {
  1296. m.batch_no = nil
  1297. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  1298. }
  1299. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  1300. func (m *BatchMsgMutation) BatchNoCleared() bool {
  1301. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  1302. return ok
  1303. }
  1304. // ResetBatchNo resets all changes to the "batch_no" field.
  1305. func (m *BatchMsgMutation) ResetBatchNo() {
  1306. m.batch_no = nil
  1307. delete(m.clearedFields, batchmsg.FieldBatchNo)
  1308. }
  1309. // SetTaskName sets the "task_name" field.
  1310. func (m *BatchMsgMutation) SetTaskName(s string) {
  1311. m.task_name = &s
  1312. }
  1313. // TaskName returns the value of the "task_name" field in the mutation.
  1314. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  1315. v := m.task_name
  1316. if v == nil {
  1317. return
  1318. }
  1319. return *v, true
  1320. }
  1321. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  1322. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1324. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  1325. if !m.op.Is(OpUpdateOne) {
  1326. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  1327. }
  1328. if m.id == nil || m.oldValue == nil {
  1329. return v, errors.New("OldTaskName requires an ID field in the mutation")
  1330. }
  1331. oldValue, err := m.oldValue(ctx)
  1332. if err != nil {
  1333. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  1334. }
  1335. return oldValue.TaskName, nil
  1336. }
  1337. // ClearTaskName clears the value of the "task_name" field.
  1338. func (m *BatchMsgMutation) ClearTaskName() {
  1339. m.task_name = nil
  1340. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  1341. }
  1342. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  1343. func (m *BatchMsgMutation) TaskNameCleared() bool {
  1344. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  1345. return ok
  1346. }
  1347. // ResetTaskName resets all changes to the "task_name" field.
  1348. func (m *BatchMsgMutation) ResetTaskName() {
  1349. m.task_name = nil
  1350. delete(m.clearedFields, batchmsg.FieldTaskName)
  1351. }
  1352. // SetFromwxid sets the "fromwxid" field.
  1353. func (m *BatchMsgMutation) SetFromwxid(s string) {
  1354. m.fromwxid = &s
  1355. }
  1356. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  1357. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  1358. v := m.fromwxid
  1359. if v == nil {
  1360. return
  1361. }
  1362. return *v, true
  1363. }
  1364. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  1365. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1367. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  1368. if !m.op.Is(OpUpdateOne) {
  1369. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  1370. }
  1371. if m.id == nil || m.oldValue == nil {
  1372. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  1373. }
  1374. oldValue, err := m.oldValue(ctx)
  1375. if err != nil {
  1376. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  1377. }
  1378. return oldValue.Fromwxid, nil
  1379. }
  1380. // ClearFromwxid clears the value of the "fromwxid" field.
  1381. func (m *BatchMsgMutation) ClearFromwxid() {
  1382. m.fromwxid = nil
  1383. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  1384. }
  1385. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  1386. func (m *BatchMsgMutation) FromwxidCleared() bool {
  1387. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  1388. return ok
  1389. }
  1390. // ResetFromwxid resets all changes to the "fromwxid" field.
  1391. func (m *BatchMsgMutation) ResetFromwxid() {
  1392. m.fromwxid = nil
  1393. delete(m.clearedFields, batchmsg.FieldFromwxid)
  1394. }
  1395. // SetMsg sets the "msg" field.
  1396. func (m *BatchMsgMutation) SetMsg(s string) {
  1397. m.msg = &s
  1398. }
  1399. // Msg returns the value of the "msg" field in the mutation.
  1400. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  1401. v := m.msg
  1402. if v == nil {
  1403. return
  1404. }
  1405. return *v, true
  1406. }
  1407. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  1408. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1410. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  1411. if !m.op.Is(OpUpdateOne) {
  1412. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  1413. }
  1414. if m.id == nil || m.oldValue == nil {
  1415. return v, errors.New("OldMsg requires an ID field in the mutation")
  1416. }
  1417. oldValue, err := m.oldValue(ctx)
  1418. if err != nil {
  1419. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  1420. }
  1421. return oldValue.Msg, nil
  1422. }
  1423. // ClearMsg clears the value of the "msg" field.
  1424. func (m *BatchMsgMutation) ClearMsg() {
  1425. m.msg = nil
  1426. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  1427. }
  1428. // MsgCleared returns if the "msg" field was cleared in this mutation.
  1429. func (m *BatchMsgMutation) MsgCleared() bool {
  1430. _, ok := m.clearedFields[batchmsg.FieldMsg]
  1431. return ok
  1432. }
  1433. // ResetMsg resets all changes to the "msg" field.
  1434. func (m *BatchMsgMutation) ResetMsg() {
  1435. m.msg = nil
  1436. delete(m.clearedFields, batchmsg.FieldMsg)
  1437. }
  1438. // SetTag sets the "tag" field.
  1439. func (m *BatchMsgMutation) SetTag(s string) {
  1440. m.tag = &s
  1441. }
  1442. // Tag returns the value of the "tag" field in the mutation.
  1443. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  1444. v := m.tag
  1445. if v == nil {
  1446. return
  1447. }
  1448. return *v, true
  1449. }
  1450. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  1451. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1453. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  1454. if !m.op.Is(OpUpdateOne) {
  1455. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  1456. }
  1457. if m.id == nil || m.oldValue == nil {
  1458. return v, errors.New("OldTag requires an ID field in the mutation")
  1459. }
  1460. oldValue, err := m.oldValue(ctx)
  1461. if err != nil {
  1462. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  1463. }
  1464. return oldValue.Tag, nil
  1465. }
  1466. // ClearTag clears the value of the "tag" field.
  1467. func (m *BatchMsgMutation) ClearTag() {
  1468. m.tag = nil
  1469. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  1470. }
  1471. // TagCleared returns if the "tag" field was cleared in this mutation.
  1472. func (m *BatchMsgMutation) TagCleared() bool {
  1473. _, ok := m.clearedFields[batchmsg.FieldTag]
  1474. return ok
  1475. }
  1476. // ResetTag resets all changes to the "tag" field.
  1477. func (m *BatchMsgMutation) ResetTag() {
  1478. m.tag = nil
  1479. delete(m.clearedFields, batchmsg.FieldTag)
  1480. }
  1481. // SetTotal sets the "total" field.
  1482. func (m *BatchMsgMutation) SetTotal(i int32) {
  1483. m.total = &i
  1484. m.addtotal = nil
  1485. }
  1486. // Total returns the value of the "total" field in the mutation.
  1487. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  1488. v := m.total
  1489. if v == nil {
  1490. return
  1491. }
  1492. return *v, true
  1493. }
  1494. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  1495. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1497. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  1498. if !m.op.Is(OpUpdateOne) {
  1499. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  1500. }
  1501. if m.id == nil || m.oldValue == nil {
  1502. return v, errors.New("OldTotal requires an ID field in the mutation")
  1503. }
  1504. oldValue, err := m.oldValue(ctx)
  1505. if err != nil {
  1506. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  1507. }
  1508. return oldValue.Total, nil
  1509. }
  1510. // AddTotal adds i to the "total" field.
  1511. func (m *BatchMsgMutation) AddTotal(i int32) {
  1512. if m.addtotal != nil {
  1513. *m.addtotal += i
  1514. } else {
  1515. m.addtotal = &i
  1516. }
  1517. }
  1518. // AddedTotal returns the value that was added to the "total" field in this mutation.
  1519. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  1520. v := m.addtotal
  1521. if v == nil {
  1522. return
  1523. }
  1524. return *v, true
  1525. }
  1526. // ClearTotal clears the value of the "total" field.
  1527. func (m *BatchMsgMutation) ClearTotal() {
  1528. m.total = nil
  1529. m.addtotal = nil
  1530. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  1531. }
  1532. // TotalCleared returns if the "total" field was cleared in this mutation.
  1533. func (m *BatchMsgMutation) TotalCleared() bool {
  1534. _, ok := m.clearedFields[batchmsg.FieldTotal]
  1535. return ok
  1536. }
  1537. // ResetTotal resets all changes to the "total" field.
  1538. func (m *BatchMsgMutation) ResetTotal() {
  1539. m.total = nil
  1540. m.addtotal = nil
  1541. delete(m.clearedFields, batchmsg.FieldTotal)
  1542. }
  1543. // SetSuccess sets the "success" field.
  1544. func (m *BatchMsgMutation) SetSuccess(i int32) {
  1545. m.success = &i
  1546. m.addsuccess = nil
  1547. }
  1548. // Success returns the value of the "success" field in the mutation.
  1549. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  1550. v := m.success
  1551. if v == nil {
  1552. return
  1553. }
  1554. return *v, true
  1555. }
  1556. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  1557. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1559. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  1560. if !m.op.Is(OpUpdateOne) {
  1561. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  1562. }
  1563. if m.id == nil || m.oldValue == nil {
  1564. return v, errors.New("OldSuccess requires an ID field in the mutation")
  1565. }
  1566. oldValue, err := m.oldValue(ctx)
  1567. if err != nil {
  1568. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  1569. }
  1570. return oldValue.Success, nil
  1571. }
  1572. // AddSuccess adds i to the "success" field.
  1573. func (m *BatchMsgMutation) AddSuccess(i int32) {
  1574. if m.addsuccess != nil {
  1575. *m.addsuccess += i
  1576. } else {
  1577. m.addsuccess = &i
  1578. }
  1579. }
  1580. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  1581. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  1582. v := m.addsuccess
  1583. if v == nil {
  1584. return
  1585. }
  1586. return *v, true
  1587. }
  1588. // ClearSuccess clears the value of the "success" field.
  1589. func (m *BatchMsgMutation) ClearSuccess() {
  1590. m.success = nil
  1591. m.addsuccess = nil
  1592. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  1593. }
  1594. // SuccessCleared returns if the "success" field was cleared in this mutation.
  1595. func (m *BatchMsgMutation) SuccessCleared() bool {
  1596. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  1597. return ok
  1598. }
  1599. // ResetSuccess resets all changes to the "success" field.
  1600. func (m *BatchMsgMutation) ResetSuccess() {
  1601. m.success = nil
  1602. m.addsuccess = nil
  1603. delete(m.clearedFields, batchmsg.FieldSuccess)
  1604. }
  1605. // SetFail sets the "fail" field.
  1606. func (m *BatchMsgMutation) SetFail(i int32) {
  1607. m.fail = &i
  1608. m.addfail = nil
  1609. }
  1610. // Fail returns the value of the "fail" field in the mutation.
  1611. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  1612. v := m.fail
  1613. if v == nil {
  1614. return
  1615. }
  1616. return *v, true
  1617. }
  1618. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  1619. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1621. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  1622. if !m.op.Is(OpUpdateOne) {
  1623. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  1624. }
  1625. if m.id == nil || m.oldValue == nil {
  1626. return v, errors.New("OldFail requires an ID field in the mutation")
  1627. }
  1628. oldValue, err := m.oldValue(ctx)
  1629. if err != nil {
  1630. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  1631. }
  1632. return oldValue.Fail, nil
  1633. }
  1634. // AddFail adds i to the "fail" field.
  1635. func (m *BatchMsgMutation) AddFail(i int32) {
  1636. if m.addfail != nil {
  1637. *m.addfail += i
  1638. } else {
  1639. m.addfail = &i
  1640. }
  1641. }
  1642. // AddedFail returns the value that was added to the "fail" field in this mutation.
  1643. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  1644. v := m.addfail
  1645. if v == nil {
  1646. return
  1647. }
  1648. return *v, true
  1649. }
  1650. // ClearFail clears the value of the "fail" field.
  1651. func (m *BatchMsgMutation) ClearFail() {
  1652. m.fail = nil
  1653. m.addfail = nil
  1654. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  1655. }
  1656. // FailCleared returns if the "fail" field was cleared in this mutation.
  1657. func (m *BatchMsgMutation) FailCleared() bool {
  1658. _, ok := m.clearedFields[batchmsg.FieldFail]
  1659. return ok
  1660. }
  1661. // ResetFail resets all changes to the "fail" field.
  1662. func (m *BatchMsgMutation) ResetFail() {
  1663. m.fail = nil
  1664. m.addfail = nil
  1665. delete(m.clearedFields, batchmsg.FieldFail)
  1666. }
  1667. // SetStartTime sets the "start_time" field.
  1668. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  1669. m.start_time = &t
  1670. }
  1671. // StartTime returns the value of the "start_time" field in the mutation.
  1672. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  1673. v := m.start_time
  1674. if v == nil {
  1675. return
  1676. }
  1677. return *v, true
  1678. }
  1679. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  1680. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1682. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  1683. if !m.op.Is(OpUpdateOne) {
  1684. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  1685. }
  1686. if m.id == nil || m.oldValue == nil {
  1687. return v, errors.New("OldStartTime requires an ID field in the mutation")
  1688. }
  1689. oldValue, err := m.oldValue(ctx)
  1690. if err != nil {
  1691. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  1692. }
  1693. return oldValue.StartTime, nil
  1694. }
  1695. // ClearStartTime clears the value of the "start_time" field.
  1696. func (m *BatchMsgMutation) ClearStartTime() {
  1697. m.start_time = nil
  1698. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  1699. }
  1700. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  1701. func (m *BatchMsgMutation) StartTimeCleared() bool {
  1702. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  1703. return ok
  1704. }
  1705. // ResetStartTime resets all changes to the "start_time" field.
  1706. func (m *BatchMsgMutation) ResetStartTime() {
  1707. m.start_time = nil
  1708. delete(m.clearedFields, batchmsg.FieldStartTime)
  1709. }
  1710. // SetStopTime sets the "stop_time" field.
  1711. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  1712. m.stop_time = &t
  1713. }
  1714. // StopTime returns the value of the "stop_time" field in the mutation.
  1715. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  1716. v := m.stop_time
  1717. if v == nil {
  1718. return
  1719. }
  1720. return *v, true
  1721. }
  1722. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  1723. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1724. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1725. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  1726. if !m.op.Is(OpUpdateOne) {
  1727. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  1728. }
  1729. if m.id == nil || m.oldValue == nil {
  1730. return v, errors.New("OldStopTime requires an ID field in the mutation")
  1731. }
  1732. oldValue, err := m.oldValue(ctx)
  1733. if err != nil {
  1734. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  1735. }
  1736. return oldValue.StopTime, nil
  1737. }
  1738. // ClearStopTime clears the value of the "stop_time" field.
  1739. func (m *BatchMsgMutation) ClearStopTime() {
  1740. m.stop_time = nil
  1741. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  1742. }
  1743. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  1744. func (m *BatchMsgMutation) StopTimeCleared() bool {
  1745. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  1746. return ok
  1747. }
  1748. // ResetStopTime resets all changes to the "stop_time" field.
  1749. func (m *BatchMsgMutation) ResetStopTime() {
  1750. m.stop_time = nil
  1751. delete(m.clearedFields, batchmsg.FieldStopTime)
  1752. }
  1753. // SetSendTime sets the "send_time" field.
  1754. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  1755. m.send_time = &t
  1756. }
  1757. // SendTime returns the value of the "send_time" field in the mutation.
  1758. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  1759. v := m.send_time
  1760. if v == nil {
  1761. return
  1762. }
  1763. return *v, true
  1764. }
  1765. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  1766. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1768. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  1769. if !m.op.Is(OpUpdateOne) {
  1770. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  1771. }
  1772. if m.id == nil || m.oldValue == nil {
  1773. return v, errors.New("OldSendTime requires an ID field in the mutation")
  1774. }
  1775. oldValue, err := m.oldValue(ctx)
  1776. if err != nil {
  1777. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  1778. }
  1779. return oldValue.SendTime, nil
  1780. }
  1781. // ClearSendTime clears the value of the "send_time" field.
  1782. func (m *BatchMsgMutation) ClearSendTime() {
  1783. m.send_time = nil
  1784. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  1785. }
  1786. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  1787. func (m *BatchMsgMutation) SendTimeCleared() bool {
  1788. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  1789. return ok
  1790. }
  1791. // ResetSendTime resets all changes to the "send_time" field.
  1792. func (m *BatchMsgMutation) ResetSendTime() {
  1793. m.send_time = nil
  1794. delete(m.clearedFields, batchmsg.FieldSendTime)
  1795. }
  1796. // SetType sets the "type" field.
  1797. func (m *BatchMsgMutation) SetType(i int32) {
  1798. m._type = &i
  1799. m.add_type = nil
  1800. }
  1801. // GetType returns the value of the "type" field in the mutation.
  1802. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  1803. v := m._type
  1804. if v == nil {
  1805. return
  1806. }
  1807. return *v, true
  1808. }
  1809. // OldType returns the old "type" field's value of the BatchMsg entity.
  1810. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1812. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  1813. if !m.op.Is(OpUpdateOne) {
  1814. return v, errors.New("OldType is only allowed on UpdateOne operations")
  1815. }
  1816. if m.id == nil || m.oldValue == nil {
  1817. return v, errors.New("OldType requires an ID field in the mutation")
  1818. }
  1819. oldValue, err := m.oldValue(ctx)
  1820. if err != nil {
  1821. return v, fmt.Errorf("querying old value for OldType: %w", err)
  1822. }
  1823. return oldValue.Type, nil
  1824. }
  1825. // AddType adds i to the "type" field.
  1826. func (m *BatchMsgMutation) AddType(i int32) {
  1827. if m.add_type != nil {
  1828. *m.add_type += i
  1829. } else {
  1830. m.add_type = &i
  1831. }
  1832. }
  1833. // AddedType returns the value that was added to the "type" field in this mutation.
  1834. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  1835. v := m.add_type
  1836. if v == nil {
  1837. return
  1838. }
  1839. return *v, true
  1840. }
  1841. // ClearType clears the value of the "type" field.
  1842. func (m *BatchMsgMutation) ClearType() {
  1843. m._type = nil
  1844. m.add_type = nil
  1845. m.clearedFields[batchmsg.FieldType] = struct{}{}
  1846. }
  1847. // TypeCleared returns if the "type" field was cleared in this mutation.
  1848. func (m *BatchMsgMutation) TypeCleared() bool {
  1849. _, ok := m.clearedFields[batchmsg.FieldType]
  1850. return ok
  1851. }
  1852. // ResetType resets all changes to the "type" field.
  1853. func (m *BatchMsgMutation) ResetType() {
  1854. m._type = nil
  1855. m.add_type = nil
  1856. delete(m.clearedFields, batchmsg.FieldType)
  1857. }
  1858. // Where appends a list predicates to the BatchMsgMutation builder.
  1859. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  1860. m.predicates = append(m.predicates, ps...)
  1861. }
  1862. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  1863. // users can use type-assertion to append predicates that do not depend on any generated package.
  1864. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  1865. p := make([]predicate.BatchMsg, len(ps))
  1866. for i := range ps {
  1867. p[i] = ps[i]
  1868. }
  1869. m.Where(p...)
  1870. }
  1871. // Op returns the operation name.
  1872. func (m *BatchMsgMutation) Op() Op {
  1873. return m.op
  1874. }
  1875. // SetOp allows setting the mutation operation.
  1876. func (m *BatchMsgMutation) SetOp(op Op) {
  1877. m.op = op
  1878. }
  1879. // Type returns the node type of this mutation (BatchMsg).
  1880. func (m *BatchMsgMutation) Type() string {
  1881. return m.typ
  1882. }
  1883. // Fields returns all fields that were changed during this mutation. Note that in
  1884. // order to get all numeric fields that were incremented/decremented, call
  1885. // AddedFields().
  1886. func (m *BatchMsgMutation) Fields() []string {
  1887. fields := make([]string, 0, 16)
  1888. if m.created_at != nil {
  1889. fields = append(fields, batchmsg.FieldCreatedAt)
  1890. }
  1891. if m.updated_at != nil {
  1892. fields = append(fields, batchmsg.FieldUpdatedAt)
  1893. }
  1894. if m.deleted_at != nil {
  1895. fields = append(fields, batchmsg.FieldDeletedAt)
  1896. }
  1897. if m.status != nil {
  1898. fields = append(fields, batchmsg.FieldStatus)
  1899. }
  1900. if m.batch_no != nil {
  1901. fields = append(fields, batchmsg.FieldBatchNo)
  1902. }
  1903. if m.task_name != nil {
  1904. fields = append(fields, batchmsg.FieldTaskName)
  1905. }
  1906. if m.fromwxid != nil {
  1907. fields = append(fields, batchmsg.FieldFromwxid)
  1908. }
  1909. if m.msg != nil {
  1910. fields = append(fields, batchmsg.FieldMsg)
  1911. }
  1912. if m.tag != nil {
  1913. fields = append(fields, batchmsg.FieldTag)
  1914. }
  1915. if m.total != nil {
  1916. fields = append(fields, batchmsg.FieldTotal)
  1917. }
  1918. if m.success != nil {
  1919. fields = append(fields, batchmsg.FieldSuccess)
  1920. }
  1921. if m.fail != nil {
  1922. fields = append(fields, batchmsg.FieldFail)
  1923. }
  1924. if m.start_time != nil {
  1925. fields = append(fields, batchmsg.FieldStartTime)
  1926. }
  1927. if m.stop_time != nil {
  1928. fields = append(fields, batchmsg.FieldStopTime)
  1929. }
  1930. if m.send_time != nil {
  1931. fields = append(fields, batchmsg.FieldSendTime)
  1932. }
  1933. if m._type != nil {
  1934. fields = append(fields, batchmsg.FieldType)
  1935. }
  1936. return fields
  1937. }
  1938. // Field returns the value of a field with the given name. The second boolean
  1939. // return value indicates that this field was not set, or was not defined in the
  1940. // schema.
  1941. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  1942. switch name {
  1943. case batchmsg.FieldCreatedAt:
  1944. return m.CreatedAt()
  1945. case batchmsg.FieldUpdatedAt:
  1946. return m.UpdatedAt()
  1947. case batchmsg.FieldDeletedAt:
  1948. return m.DeletedAt()
  1949. case batchmsg.FieldStatus:
  1950. return m.Status()
  1951. case batchmsg.FieldBatchNo:
  1952. return m.BatchNo()
  1953. case batchmsg.FieldTaskName:
  1954. return m.TaskName()
  1955. case batchmsg.FieldFromwxid:
  1956. return m.Fromwxid()
  1957. case batchmsg.FieldMsg:
  1958. return m.Msg()
  1959. case batchmsg.FieldTag:
  1960. return m.Tag()
  1961. case batchmsg.FieldTotal:
  1962. return m.Total()
  1963. case batchmsg.FieldSuccess:
  1964. return m.Success()
  1965. case batchmsg.FieldFail:
  1966. return m.Fail()
  1967. case batchmsg.FieldStartTime:
  1968. return m.StartTime()
  1969. case batchmsg.FieldStopTime:
  1970. return m.StopTime()
  1971. case batchmsg.FieldSendTime:
  1972. return m.SendTime()
  1973. case batchmsg.FieldType:
  1974. return m.GetType()
  1975. }
  1976. return nil, false
  1977. }
  1978. // OldField returns the old value of the field from the database. An error is
  1979. // returned if the mutation operation is not UpdateOne, or the query to the
  1980. // database failed.
  1981. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1982. switch name {
  1983. case batchmsg.FieldCreatedAt:
  1984. return m.OldCreatedAt(ctx)
  1985. case batchmsg.FieldUpdatedAt:
  1986. return m.OldUpdatedAt(ctx)
  1987. case batchmsg.FieldDeletedAt:
  1988. return m.OldDeletedAt(ctx)
  1989. case batchmsg.FieldStatus:
  1990. return m.OldStatus(ctx)
  1991. case batchmsg.FieldBatchNo:
  1992. return m.OldBatchNo(ctx)
  1993. case batchmsg.FieldTaskName:
  1994. return m.OldTaskName(ctx)
  1995. case batchmsg.FieldFromwxid:
  1996. return m.OldFromwxid(ctx)
  1997. case batchmsg.FieldMsg:
  1998. return m.OldMsg(ctx)
  1999. case batchmsg.FieldTag:
  2000. return m.OldTag(ctx)
  2001. case batchmsg.FieldTotal:
  2002. return m.OldTotal(ctx)
  2003. case batchmsg.FieldSuccess:
  2004. return m.OldSuccess(ctx)
  2005. case batchmsg.FieldFail:
  2006. return m.OldFail(ctx)
  2007. case batchmsg.FieldStartTime:
  2008. return m.OldStartTime(ctx)
  2009. case batchmsg.FieldStopTime:
  2010. return m.OldStopTime(ctx)
  2011. case batchmsg.FieldSendTime:
  2012. return m.OldSendTime(ctx)
  2013. case batchmsg.FieldType:
  2014. return m.OldType(ctx)
  2015. }
  2016. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  2017. }
  2018. // SetField sets the value of a field with the given name. It returns an error if
  2019. // the field is not defined in the schema, or if the type mismatched the field
  2020. // type.
  2021. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  2022. switch name {
  2023. case batchmsg.FieldCreatedAt:
  2024. v, ok := value.(time.Time)
  2025. if !ok {
  2026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2027. }
  2028. m.SetCreatedAt(v)
  2029. return nil
  2030. case batchmsg.FieldUpdatedAt:
  2031. v, ok := value.(time.Time)
  2032. if !ok {
  2033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2034. }
  2035. m.SetUpdatedAt(v)
  2036. return nil
  2037. case batchmsg.FieldDeletedAt:
  2038. v, ok := value.(time.Time)
  2039. if !ok {
  2040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2041. }
  2042. m.SetDeletedAt(v)
  2043. return nil
  2044. case batchmsg.FieldStatus:
  2045. v, ok := value.(uint8)
  2046. if !ok {
  2047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2048. }
  2049. m.SetStatus(v)
  2050. return nil
  2051. case batchmsg.FieldBatchNo:
  2052. v, ok := value.(string)
  2053. if !ok {
  2054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2055. }
  2056. m.SetBatchNo(v)
  2057. return nil
  2058. case batchmsg.FieldTaskName:
  2059. v, ok := value.(string)
  2060. if !ok {
  2061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2062. }
  2063. m.SetTaskName(v)
  2064. return nil
  2065. case batchmsg.FieldFromwxid:
  2066. v, ok := value.(string)
  2067. if !ok {
  2068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2069. }
  2070. m.SetFromwxid(v)
  2071. return nil
  2072. case batchmsg.FieldMsg:
  2073. v, ok := value.(string)
  2074. if !ok {
  2075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2076. }
  2077. m.SetMsg(v)
  2078. return nil
  2079. case batchmsg.FieldTag:
  2080. v, ok := value.(string)
  2081. if !ok {
  2082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2083. }
  2084. m.SetTag(v)
  2085. return nil
  2086. case batchmsg.FieldTotal:
  2087. v, ok := value.(int32)
  2088. if !ok {
  2089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2090. }
  2091. m.SetTotal(v)
  2092. return nil
  2093. case batchmsg.FieldSuccess:
  2094. v, ok := value.(int32)
  2095. if !ok {
  2096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2097. }
  2098. m.SetSuccess(v)
  2099. return nil
  2100. case batchmsg.FieldFail:
  2101. v, ok := value.(int32)
  2102. if !ok {
  2103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2104. }
  2105. m.SetFail(v)
  2106. return nil
  2107. case batchmsg.FieldStartTime:
  2108. v, ok := value.(time.Time)
  2109. if !ok {
  2110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2111. }
  2112. m.SetStartTime(v)
  2113. return nil
  2114. case batchmsg.FieldStopTime:
  2115. v, ok := value.(time.Time)
  2116. if !ok {
  2117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2118. }
  2119. m.SetStopTime(v)
  2120. return nil
  2121. case batchmsg.FieldSendTime:
  2122. v, ok := value.(time.Time)
  2123. if !ok {
  2124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2125. }
  2126. m.SetSendTime(v)
  2127. return nil
  2128. case batchmsg.FieldType:
  2129. v, ok := value.(int32)
  2130. if !ok {
  2131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2132. }
  2133. m.SetType(v)
  2134. return nil
  2135. }
  2136. return fmt.Errorf("unknown BatchMsg field %s", name)
  2137. }
  2138. // AddedFields returns all numeric fields that were incremented/decremented during
  2139. // this mutation.
  2140. func (m *BatchMsgMutation) AddedFields() []string {
  2141. var fields []string
  2142. if m.addstatus != nil {
  2143. fields = append(fields, batchmsg.FieldStatus)
  2144. }
  2145. if m.addtotal != nil {
  2146. fields = append(fields, batchmsg.FieldTotal)
  2147. }
  2148. if m.addsuccess != nil {
  2149. fields = append(fields, batchmsg.FieldSuccess)
  2150. }
  2151. if m.addfail != nil {
  2152. fields = append(fields, batchmsg.FieldFail)
  2153. }
  2154. if m.add_type != nil {
  2155. fields = append(fields, batchmsg.FieldType)
  2156. }
  2157. return fields
  2158. }
  2159. // AddedField returns the numeric value that was incremented/decremented on a field
  2160. // with the given name. The second boolean return value indicates that this field
  2161. // was not set, or was not defined in the schema.
  2162. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  2163. switch name {
  2164. case batchmsg.FieldStatus:
  2165. return m.AddedStatus()
  2166. case batchmsg.FieldTotal:
  2167. return m.AddedTotal()
  2168. case batchmsg.FieldSuccess:
  2169. return m.AddedSuccess()
  2170. case batchmsg.FieldFail:
  2171. return m.AddedFail()
  2172. case batchmsg.FieldType:
  2173. return m.AddedType()
  2174. }
  2175. return nil, false
  2176. }
  2177. // AddField adds the value to the field with the given name. It returns an error if
  2178. // the field is not defined in the schema, or if the type mismatched the field
  2179. // type.
  2180. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  2181. switch name {
  2182. case batchmsg.FieldStatus:
  2183. v, ok := value.(int8)
  2184. if !ok {
  2185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2186. }
  2187. m.AddStatus(v)
  2188. return nil
  2189. case batchmsg.FieldTotal:
  2190. v, ok := value.(int32)
  2191. if !ok {
  2192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2193. }
  2194. m.AddTotal(v)
  2195. return nil
  2196. case batchmsg.FieldSuccess:
  2197. v, ok := value.(int32)
  2198. if !ok {
  2199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2200. }
  2201. m.AddSuccess(v)
  2202. return nil
  2203. case batchmsg.FieldFail:
  2204. v, ok := value.(int32)
  2205. if !ok {
  2206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2207. }
  2208. m.AddFail(v)
  2209. return nil
  2210. case batchmsg.FieldType:
  2211. v, ok := value.(int32)
  2212. if !ok {
  2213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2214. }
  2215. m.AddType(v)
  2216. return nil
  2217. }
  2218. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  2219. }
  2220. // ClearedFields returns all nullable fields that were cleared during this
  2221. // mutation.
  2222. func (m *BatchMsgMutation) ClearedFields() []string {
  2223. var fields []string
  2224. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  2225. fields = append(fields, batchmsg.FieldDeletedAt)
  2226. }
  2227. if m.FieldCleared(batchmsg.FieldStatus) {
  2228. fields = append(fields, batchmsg.FieldStatus)
  2229. }
  2230. if m.FieldCleared(batchmsg.FieldBatchNo) {
  2231. fields = append(fields, batchmsg.FieldBatchNo)
  2232. }
  2233. if m.FieldCleared(batchmsg.FieldTaskName) {
  2234. fields = append(fields, batchmsg.FieldTaskName)
  2235. }
  2236. if m.FieldCleared(batchmsg.FieldFromwxid) {
  2237. fields = append(fields, batchmsg.FieldFromwxid)
  2238. }
  2239. if m.FieldCleared(batchmsg.FieldMsg) {
  2240. fields = append(fields, batchmsg.FieldMsg)
  2241. }
  2242. if m.FieldCleared(batchmsg.FieldTag) {
  2243. fields = append(fields, batchmsg.FieldTag)
  2244. }
  2245. if m.FieldCleared(batchmsg.FieldTotal) {
  2246. fields = append(fields, batchmsg.FieldTotal)
  2247. }
  2248. if m.FieldCleared(batchmsg.FieldSuccess) {
  2249. fields = append(fields, batchmsg.FieldSuccess)
  2250. }
  2251. if m.FieldCleared(batchmsg.FieldFail) {
  2252. fields = append(fields, batchmsg.FieldFail)
  2253. }
  2254. if m.FieldCleared(batchmsg.FieldStartTime) {
  2255. fields = append(fields, batchmsg.FieldStartTime)
  2256. }
  2257. if m.FieldCleared(batchmsg.FieldStopTime) {
  2258. fields = append(fields, batchmsg.FieldStopTime)
  2259. }
  2260. if m.FieldCleared(batchmsg.FieldSendTime) {
  2261. fields = append(fields, batchmsg.FieldSendTime)
  2262. }
  2263. if m.FieldCleared(batchmsg.FieldType) {
  2264. fields = append(fields, batchmsg.FieldType)
  2265. }
  2266. return fields
  2267. }
  2268. // FieldCleared returns a boolean indicating if a field with the given name was
  2269. // cleared in this mutation.
  2270. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  2271. _, ok := m.clearedFields[name]
  2272. return ok
  2273. }
  2274. // ClearField clears the value of the field with the given name. It returns an
  2275. // error if the field is not defined in the schema.
  2276. func (m *BatchMsgMutation) ClearField(name string) error {
  2277. switch name {
  2278. case batchmsg.FieldDeletedAt:
  2279. m.ClearDeletedAt()
  2280. return nil
  2281. case batchmsg.FieldStatus:
  2282. m.ClearStatus()
  2283. return nil
  2284. case batchmsg.FieldBatchNo:
  2285. m.ClearBatchNo()
  2286. return nil
  2287. case batchmsg.FieldTaskName:
  2288. m.ClearTaskName()
  2289. return nil
  2290. case batchmsg.FieldFromwxid:
  2291. m.ClearFromwxid()
  2292. return nil
  2293. case batchmsg.FieldMsg:
  2294. m.ClearMsg()
  2295. return nil
  2296. case batchmsg.FieldTag:
  2297. m.ClearTag()
  2298. return nil
  2299. case batchmsg.FieldTotal:
  2300. m.ClearTotal()
  2301. return nil
  2302. case batchmsg.FieldSuccess:
  2303. m.ClearSuccess()
  2304. return nil
  2305. case batchmsg.FieldFail:
  2306. m.ClearFail()
  2307. return nil
  2308. case batchmsg.FieldStartTime:
  2309. m.ClearStartTime()
  2310. return nil
  2311. case batchmsg.FieldStopTime:
  2312. m.ClearStopTime()
  2313. return nil
  2314. case batchmsg.FieldSendTime:
  2315. m.ClearSendTime()
  2316. return nil
  2317. case batchmsg.FieldType:
  2318. m.ClearType()
  2319. return nil
  2320. }
  2321. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  2322. }
  2323. // ResetField resets all changes in the mutation for the field with the given name.
  2324. // It returns an error if the field is not defined in the schema.
  2325. func (m *BatchMsgMutation) ResetField(name string) error {
  2326. switch name {
  2327. case batchmsg.FieldCreatedAt:
  2328. m.ResetCreatedAt()
  2329. return nil
  2330. case batchmsg.FieldUpdatedAt:
  2331. m.ResetUpdatedAt()
  2332. return nil
  2333. case batchmsg.FieldDeletedAt:
  2334. m.ResetDeletedAt()
  2335. return nil
  2336. case batchmsg.FieldStatus:
  2337. m.ResetStatus()
  2338. return nil
  2339. case batchmsg.FieldBatchNo:
  2340. m.ResetBatchNo()
  2341. return nil
  2342. case batchmsg.FieldTaskName:
  2343. m.ResetTaskName()
  2344. return nil
  2345. case batchmsg.FieldFromwxid:
  2346. m.ResetFromwxid()
  2347. return nil
  2348. case batchmsg.FieldMsg:
  2349. m.ResetMsg()
  2350. return nil
  2351. case batchmsg.FieldTag:
  2352. m.ResetTag()
  2353. return nil
  2354. case batchmsg.FieldTotal:
  2355. m.ResetTotal()
  2356. return nil
  2357. case batchmsg.FieldSuccess:
  2358. m.ResetSuccess()
  2359. return nil
  2360. case batchmsg.FieldFail:
  2361. m.ResetFail()
  2362. return nil
  2363. case batchmsg.FieldStartTime:
  2364. m.ResetStartTime()
  2365. return nil
  2366. case batchmsg.FieldStopTime:
  2367. m.ResetStopTime()
  2368. return nil
  2369. case batchmsg.FieldSendTime:
  2370. m.ResetSendTime()
  2371. return nil
  2372. case batchmsg.FieldType:
  2373. m.ResetType()
  2374. return nil
  2375. }
  2376. return fmt.Errorf("unknown BatchMsg field %s", name)
  2377. }
  2378. // AddedEdges returns all edge names that were set/added in this mutation.
  2379. func (m *BatchMsgMutation) AddedEdges() []string {
  2380. edges := make([]string, 0, 0)
  2381. return edges
  2382. }
  2383. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2384. // name in this mutation.
  2385. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  2386. return nil
  2387. }
  2388. // RemovedEdges returns all edge names that were removed in this mutation.
  2389. func (m *BatchMsgMutation) RemovedEdges() []string {
  2390. edges := make([]string, 0, 0)
  2391. return edges
  2392. }
  2393. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2394. // the given name in this mutation.
  2395. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  2396. return nil
  2397. }
  2398. // ClearedEdges returns all edge names that were cleared in this mutation.
  2399. func (m *BatchMsgMutation) ClearedEdges() []string {
  2400. edges := make([]string, 0, 0)
  2401. return edges
  2402. }
  2403. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2404. // was cleared in this mutation.
  2405. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  2406. return false
  2407. }
  2408. // ClearEdge clears the value of the edge with the given name. It returns an error
  2409. // if that edge is not defined in the schema.
  2410. func (m *BatchMsgMutation) ClearEdge(name string) error {
  2411. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  2412. }
  2413. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2414. // It returns an error if the edge is not defined in the schema.
  2415. func (m *BatchMsgMutation) ResetEdge(name string) error {
  2416. return fmt.Errorf("unknown BatchMsg edge %s", name)
  2417. }
  2418. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  2419. type ContactMutation struct {
  2420. config
  2421. op Op
  2422. typ string
  2423. id *uint64
  2424. created_at *time.Time
  2425. updated_at *time.Time
  2426. status *uint8
  2427. addstatus *int8
  2428. deleted_at *time.Time
  2429. wx_wxid *string
  2430. _type *int
  2431. add_type *int
  2432. wxid *string
  2433. account *string
  2434. nickname *string
  2435. markname *string
  2436. headimg *string
  2437. sex *int
  2438. addsex *int
  2439. starrole *string
  2440. dontseeit *int
  2441. adddontseeit *int
  2442. dontseeme *int
  2443. adddontseeme *int
  2444. lag *string
  2445. gid *string
  2446. gname *string
  2447. v3 *string
  2448. organization_id *uint64
  2449. addorganization_id *int64
  2450. clearedFields map[string]struct{}
  2451. contact_relationships map[uint64]struct{}
  2452. removedcontact_relationships map[uint64]struct{}
  2453. clearedcontact_relationships bool
  2454. contact_messages map[uint64]struct{}
  2455. removedcontact_messages map[uint64]struct{}
  2456. clearedcontact_messages bool
  2457. done bool
  2458. oldValue func(context.Context) (*Contact, error)
  2459. predicates []predicate.Contact
  2460. }
  2461. var _ ent.Mutation = (*ContactMutation)(nil)
  2462. // contactOption allows management of the mutation configuration using functional options.
  2463. type contactOption func(*ContactMutation)
  2464. // newContactMutation creates new mutation for the Contact entity.
  2465. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  2466. m := &ContactMutation{
  2467. config: c,
  2468. op: op,
  2469. typ: TypeContact,
  2470. clearedFields: make(map[string]struct{}),
  2471. }
  2472. for _, opt := range opts {
  2473. opt(m)
  2474. }
  2475. return m
  2476. }
  2477. // withContactID sets the ID field of the mutation.
  2478. func withContactID(id uint64) contactOption {
  2479. return func(m *ContactMutation) {
  2480. var (
  2481. err error
  2482. once sync.Once
  2483. value *Contact
  2484. )
  2485. m.oldValue = func(ctx context.Context) (*Contact, error) {
  2486. once.Do(func() {
  2487. if m.done {
  2488. err = errors.New("querying old values post mutation is not allowed")
  2489. } else {
  2490. value, err = m.Client().Contact.Get(ctx, id)
  2491. }
  2492. })
  2493. return value, err
  2494. }
  2495. m.id = &id
  2496. }
  2497. }
  2498. // withContact sets the old Contact of the mutation.
  2499. func withContact(node *Contact) contactOption {
  2500. return func(m *ContactMutation) {
  2501. m.oldValue = func(context.Context) (*Contact, error) {
  2502. return node, nil
  2503. }
  2504. m.id = &node.ID
  2505. }
  2506. }
  2507. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2508. // executed in a transaction (ent.Tx), a transactional client is returned.
  2509. func (m ContactMutation) Client() *Client {
  2510. client := &Client{config: m.config}
  2511. client.init()
  2512. return client
  2513. }
  2514. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2515. // it returns an error otherwise.
  2516. func (m ContactMutation) Tx() (*Tx, error) {
  2517. if _, ok := m.driver.(*txDriver); !ok {
  2518. return nil, errors.New("ent: mutation is not running in a transaction")
  2519. }
  2520. tx := &Tx{config: m.config}
  2521. tx.init()
  2522. return tx, nil
  2523. }
  2524. // SetID sets the value of the id field. Note that this
  2525. // operation is only accepted on creation of Contact entities.
  2526. func (m *ContactMutation) SetID(id uint64) {
  2527. m.id = &id
  2528. }
  2529. // ID returns the ID value in the mutation. Note that the ID is only available
  2530. // if it was provided to the builder or after it was returned from the database.
  2531. func (m *ContactMutation) ID() (id uint64, exists bool) {
  2532. if m.id == nil {
  2533. return
  2534. }
  2535. return *m.id, true
  2536. }
  2537. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2538. // That means, if the mutation is applied within a transaction with an isolation level such
  2539. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2540. // or updated by the mutation.
  2541. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  2542. switch {
  2543. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2544. id, exists := m.ID()
  2545. if exists {
  2546. return []uint64{id}, nil
  2547. }
  2548. fallthrough
  2549. case m.op.Is(OpUpdate | OpDelete):
  2550. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  2551. default:
  2552. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2553. }
  2554. }
  2555. // SetCreatedAt sets the "created_at" field.
  2556. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  2557. m.created_at = &t
  2558. }
  2559. // CreatedAt returns the value of the "created_at" field in the mutation.
  2560. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  2561. v := m.created_at
  2562. if v == nil {
  2563. return
  2564. }
  2565. return *v, true
  2566. }
  2567. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  2568. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2569. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2570. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2571. if !m.op.Is(OpUpdateOne) {
  2572. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2573. }
  2574. if m.id == nil || m.oldValue == nil {
  2575. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2576. }
  2577. oldValue, err := m.oldValue(ctx)
  2578. if err != nil {
  2579. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2580. }
  2581. return oldValue.CreatedAt, nil
  2582. }
  2583. // ResetCreatedAt resets all changes to the "created_at" field.
  2584. func (m *ContactMutation) ResetCreatedAt() {
  2585. m.created_at = nil
  2586. }
  2587. // SetUpdatedAt sets the "updated_at" field.
  2588. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  2589. m.updated_at = &t
  2590. }
  2591. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2592. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  2593. v := m.updated_at
  2594. if v == nil {
  2595. return
  2596. }
  2597. return *v, true
  2598. }
  2599. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  2600. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2602. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2603. if !m.op.Is(OpUpdateOne) {
  2604. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2605. }
  2606. if m.id == nil || m.oldValue == nil {
  2607. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2608. }
  2609. oldValue, err := m.oldValue(ctx)
  2610. if err != nil {
  2611. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2612. }
  2613. return oldValue.UpdatedAt, nil
  2614. }
  2615. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2616. func (m *ContactMutation) ResetUpdatedAt() {
  2617. m.updated_at = nil
  2618. }
  2619. // SetStatus sets the "status" field.
  2620. func (m *ContactMutation) SetStatus(u uint8) {
  2621. m.status = &u
  2622. m.addstatus = nil
  2623. }
  2624. // Status returns the value of the "status" field in the mutation.
  2625. func (m *ContactMutation) Status() (r uint8, exists bool) {
  2626. v := m.status
  2627. if v == nil {
  2628. return
  2629. }
  2630. return *v, true
  2631. }
  2632. // OldStatus returns the old "status" field's value of the Contact entity.
  2633. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2635. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  2636. if !m.op.Is(OpUpdateOne) {
  2637. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  2638. }
  2639. if m.id == nil || m.oldValue == nil {
  2640. return v, errors.New("OldStatus requires an ID field in the mutation")
  2641. }
  2642. oldValue, err := m.oldValue(ctx)
  2643. if err != nil {
  2644. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  2645. }
  2646. return oldValue.Status, nil
  2647. }
  2648. // AddStatus adds u to the "status" field.
  2649. func (m *ContactMutation) AddStatus(u int8) {
  2650. if m.addstatus != nil {
  2651. *m.addstatus += u
  2652. } else {
  2653. m.addstatus = &u
  2654. }
  2655. }
  2656. // AddedStatus returns the value that was added to the "status" field in this mutation.
  2657. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  2658. v := m.addstatus
  2659. if v == nil {
  2660. return
  2661. }
  2662. return *v, true
  2663. }
  2664. // ClearStatus clears the value of the "status" field.
  2665. func (m *ContactMutation) ClearStatus() {
  2666. m.status = nil
  2667. m.addstatus = nil
  2668. m.clearedFields[contact.FieldStatus] = struct{}{}
  2669. }
  2670. // StatusCleared returns if the "status" field was cleared in this mutation.
  2671. func (m *ContactMutation) StatusCleared() bool {
  2672. _, ok := m.clearedFields[contact.FieldStatus]
  2673. return ok
  2674. }
  2675. // ResetStatus resets all changes to the "status" field.
  2676. func (m *ContactMutation) ResetStatus() {
  2677. m.status = nil
  2678. m.addstatus = nil
  2679. delete(m.clearedFields, contact.FieldStatus)
  2680. }
  2681. // SetDeletedAt sets the "deleted_at" field.
  2682. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  2683. m.deleted_at = &t
  2684. }
  2685. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2686. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  2687. v := m.deleted_at
  2688. if v == nil {
  2689. return
  2690. }
  2691. return *v, true
  2692. }
  2693. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  2694. // If the Contact 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 *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2697. if !m.op.Is(OpUpdateOne) {
  2698. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2699. }
  2700. if m.id == nil || m.oldValue == nil {
  2701. return v, errors.New("OldDeletedAt 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 OldDeletedAt: %w", err)
  2706. }
  2707. return oldValue.DeletedAt, nil
  2708. }
  2709. // ClearDeletedAt clears the value of the "deleted_at" field.
  2710. func (m *ContactMutation) ClearDeletedAt() {
  2711. m.deleted_at = nil
  2712. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  2713. }
  2714. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2715. func (m *ContactMutation) DeletedAtCleared() bool {
  2716. _, ok := m.clearedFields[contact.FieldDeletedAt]
  2717. return ok
  2718. }
  2719. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2720. func (m *ContactMutation) ResetDeletedAt() {
  2721. m.deleted_at = nil
  2722. delete(m.clearedFields, contact.FieldDeletedAt)
  2723. }
  2724. // SetWxWxid sets the "wx_wxid" field.
  2725. func (m *ContactMutation) SetWxWxid(s string) {
  2726. m.wx_wxid = &s
  2727. }
  2728. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  2729. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  2730. v := m.wx_wxid
  2731. if v == nil {
  2732. return
  2733. }
  2734. return *v, true
  2735. }
  2736. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  2737. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2739. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  2740. if !m.op.Is(OpUpdateOne) {
  2741. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  2742. }
  2743. if m.id == nil || m.oldValue == nil {
  2744. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  2745. }
  2746. oldValue, err := m.oldValue(ctx)
  2747. if err != nil {
  2748. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  2749. }
  2750. return oldValue.WxWxid, nil
  2751. }
  2752. // ClearWxWxid clears the value of the "wx_wxid" field.
  2753. func (m *ContactMutation) ClearWxWxid() {
  2754. m.wx_wxid = nil
  2755. m.clearedFields[contact.FieldWxWxid] = struct{}{}
  2756. }
  2757. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  2758. func (m *ContactMutation) WxWxidCleared() bool {
  2759. _, ok := m.clearedFields[contact.FieldWxWxid]
  2760. return ok
  2761. }
  2762. // ResetWxWxid resets all changes to the "wx_wxid" field.
  2763. func (m *ContactMutation) ResetWxWxid() {
  2764. m.wx_wxid = nil
  2765. delete(m.clearedFields, contact.FieldWxWxid)
  2766. }
  2767. // SetType sets the "type" field.
  2768. func (m *ContactMutation) SetType(i int) {
  2769. m._type = &i
  2770. m.add_type = nil
  2771. }
  2772. // GetType returns the value of the "type" field in the mutation.
  2773. func (m *ContactMutation) GetType() (r int, exists bool) {
  2774. v := m._type
  2775. if v == nil {
  2776. return
  2777. }
  2778. return *v, true
  2779. }
  2780. // OldType returns the old "type" field's value of the Contact entity.
  2781. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2783. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  2784. if !m.op.Is(OpUpdateOne) {
  2785. return v, errors.New("OldType is only allowed on UpdateOne operations")
  2786. }
  2787. if m.id == nil || m.oldValue == nil {
  2788. return v, errors.New("OldType requires an ID field in the mutation")
  2789. }
  2790. oldValue, err := m.oldValue(ctx)
  2791. if err != nil {
  2792. return v, fmt.Errorf("querying old value for OldType: %w", err)
  2793. }
  2794. return oldValue.Type, nil
  2795. }
  2796. // AddType adds i to the "type" field.
  2797. func (m *ContactMutation) AddType(i int) {
  2798. if m.add_type != nil {
  2799. *m.add_type += i
  2800. } else {
  2801. m.add_type = &i
  2802. }
  2803. }
  2804. // AddedType returns the value that was added to the "type" field in this mutation.
  2805. func (m *ContactMutation) AddedType() (r int, exists bool) {
  2806. v := m.add_type
  2807. if v == nil {
  2808. return
  2809. }
  2810. return *v, true
  2811. }
  2812. // ClearType clears the value of the "type" field.
  2813. func (m *ContactMutation) ClearType() {
  2814. m._type = nil
  2815. m.add_type = nil
  2816. m.clearedFields[contact.FieldType] = struct{}{}
  2817. }
  2818. // TypeCleared returns if the "type" field was cleared in this mutation.
  2819. func (m *ContactMutation) TypeCleared() bool {
  2820. _, ok := m.clearedFields[contact.FieldType]
  2821. return ok
  2822. }
  2823. // ResetType resets all changes to the "type" field.
  2824. func (m *ContactMutation) ResetType() {
  2825. m._type = nil
  2826. m.add_type = nil
  2827. delete(m.clearedFields, contact.FieldType)
  2828. }
  2829. // SetWxid sets the "wxid" field.
  2830. func (m *ContactMutation) SetWxid(s string) {
  2831. m.wxid = &s
  2832. }
  2833. // Wxid returns the value of the "wxid" field in the mutation.
  2834. func (m *ContactMutation) Wxid() (r string, exists bool) {
  2835. v := m.wxid
  2836. if v == nil {
  2837. return
  2838. }
  2839. return *v, true
  2840. }
  2841. // OldWxid returns the old "wxid" field's value of the Contact entity.
  2842. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2844. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  2845. if !m.op.Is(OpUpdateOne) {
  2846. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  2847. }
  2848. if m.id == nil || m.oldValue == nil {
  2849. return v, errors.New("OldWxid requires an ID field in the mutation")
  2850. }
  2851. oldValue, err := m.oldValue(ctx)
  2852. if err != nil {
  2853. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  2854. }
  2855. return oldValue.Wxid, nil
  2856. }
  2857. // ResetWxid resets all changes to the "wxid" field.
  2858. func (m *ContactMutation) ResetWxid() {
  2859. m.wxid = nil
  2860. }
  2861. // SetAccount sets the "account" field.
  2862. func (m *ContactMutation) SetAccount(s string) {
  2863. m.account = &s
  2864. }
  2865. // Account returns the value of the "account" field in the mutation.
  2866. func (m *ContactMutation) Account() (r string, exists bool) {
  2867. v := m.account
  2868. if v == nil {
  2869. return
  2870. }
  2871. return *v, true
  2872. }
  2873. // OldAccount returns the old "account" field's value of the Contact entity.
  2874. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2876. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  2877. if !m.op.Is(OpUpdateOne) {
  2878. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  2879. }
  2880. if m.id == nil || m.oldValue == nil {
  2881. return v, errors.New("OldAccount requires an ID field in the mutation")
  2882. }
  2883. oldValue, err := m.oldValue(ctx)
  2884. if err != nil {
  2885. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  2886. }
  2887. return oldValue.Account, nil
  2888. }
  2889. // ResetAccount resets all changes to the "account" field.
  2890. func (m *ContactMutation) ResetAccount() {
  2891. m.account = nil
  2892. }
  2893. // SetNickname sets the "nickname" field.
  2894. func (m *ContactMutation) SetNickname(s string) {
  2895. m.nickname = &s
  2896. }
  2897. // Nickname returns the value of the "nickname" field in the mutation.
  2898. func (m *ContactMutation) Nickname() (r string, exists bool) {
  2899. v := m.nickname
  2900. if v == nil {
  2901. return
  2902. }
  2903. return *v, true
  2904. }
  2905. // OldNickname returns the old "nickname" field's value of the Contact entity.
  2906. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2908. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  2909. if !m.op.Is(OpUpdateOne) {
  2910. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  2911. }
  2912. if m.id == nil || m.oldValue == nil {
  2913. return v, errors.New("OldNickname requires an ID field in the mutation")
  2914. }
  2915. oldValue, err := m.oldValue(ctx)
  2916. if err != nil {
  2917. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  2918. }
  2919. return oldValue.Nickname, nil
  2920. }
  2921. // ResetNickname resets all changes to the "nickname" field.
  2922. func (m *ContactMutation) ResetNickname() {
  2923. m.nickname = nil
  2924. }
  2925. // SetMarkname sets the "markname" field.
  2926. func (m *ContactMutation) SetMarkname(s string) {
  2927. m.markname = &s
  2928. }
  2929. // Markname returns the value of the "markname" field in the mutation.
  2930. func (m *ContactMutation) Markname() (r string, exists bool) {
  2931. v := m.markname
  2932. if v == nil {
  2933. return
  2934. }
  2935. return *v, true
  2936. }
  2937. // OldMarkname returns the old "markname" field's value of the Contact entity.
  2938. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2940. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  2941. if !m.op.Is(OpUpdateOne) {
  2942. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  2943. }
  2944. if m.id == nil || m.oldValue == nil {
  2945. return v, errors.New("OldMarkname requires an ID field in the mutation")
  2946. }
  2947. oldValue, err := m.oldValue(ctx)
  2948. if err != nil {
  2949. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  2950. }
  2951. return oldValue.Markname, nil
  2952. }
  2953. // ResetMarkname resets all changes to the "markname" field.
  2954. func (m *ContactMutation) ResetMarkname() {
  2955. m.markname = nil
  2956. }
  2957. // SetHeadimg sets the "headimg" field.
  2958. func (m *ContactMutation) SetHeadimg(s string) {
  2959. m.headimg = &s
  2960. }
  2961. // Headimg returns the value of the "headimg" field in the mutation.
  2962. func (m *ContactMutation) Headimg() (r string, exists bool) {
  2963. v := m.headimg
  2964. if v == nil {
  2965. return
  2966. }
  2967. return *v, true
  2968. }
  2969. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  2970. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2972. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  2973. if !m.op.Is(OpUpdateOne) {
  2974. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  2975. }
  2976. if m.id == nil || m.oldValue == nil {
  2977. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  2978. }
  2979. oldValue, err := m.oldValue(ctx)
  2980. if err != nil {
  2981. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  2982. }
  2983. return oldValue.Headimg, nil
  2984. }
  2985. // ResetHeadimg resets all changes to the "headimg" field.
  2986. func (m *ContactMutation) ResetHeadimg() {
  2987. m.headimg = nil
  2988. }
  2989. // SetSex sets the "sex" field.
  2990. func (m *ContactMutation) SetSex(i int) {
  2991. m.sex = &i
  2992. m.addsex = nil
  2993. }
  2994. // Sex returns the value of the "sex" field in the mutation.
  2995. func (m *ContactMutation) Sex() (r int, exists bool) {
  2996. v := m.sex
  2997. if v == nil {
  2998. return
  2999. }
  3000. return *v, true
  3001. }
  3002. // OldSex returns the old "sex" field's value of the Contact entity.
  3003. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3004. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3005. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  3006. if !m.op.Is(OpUpdateOne) {
  3007. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  3008. }
  3009. if m.id == nil || m.oldValue == nil {
  3010. return v, errors.New("OldSex requires an ID field in the mutation")
  3011. }
  3012. oldValue, err := m.oldValue(ctx)
  3013. if err != nil {
  3014. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  3015. }
  3016. return oldValue.Sex, nil
  3017. }
  3018. // AddSex adds i to the "sex" field.
  3019. func (m *ContactMutation) AddSex(i int) {
  3020. if m.addsex != nil {
  3021. *m.addsex += i
  3022. } else {
  3023. m.addsex = &i
  3024. }
  3025. }
  3026. // AddedSex returns the value that was added to the "sex" field in this mutation.
  3027. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  3028. v := m.addsex
  3029. if v == nil {
  3030. return
  3031. }
  3032. return *v, true
  3033. }
  3034. // ResetSex resets all changes to the "sex" field.
  3035. func (m *ContactMutation) ResetSex() {
  3036. m.sex = nil
  3037. m.addsex = nil
  3038. }
  3039. // SetStarrole sets the "starrole" field.
  3040. func (m *ContactMutation) SetStarrole(s string) {
  3041. m.starrole = &s
  3042. }
  3043. // Starrole returns the value of the "starrole" field in the mutation.
  3044. func (m *ContactMutation) Starrole() (r string, exists bool) {
  3045. v := m.starrole
  3046. if v == nil {
  3047. return
  3048. }
  3049. return *v, true
  3050. }
  3051. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  3052. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3054. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  3055. if !m.op.Is(OpUpdateOne) {
  3056. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  3057. }
  3058. if m.id == nil || m.oldValue == nil {
  3059. return v, errors.New("OldStarrole requires an ID field in the mutation")
  3060. }
  3061. oldValue, err := m.oldValue(ctx)
  3062. if err != nil {
  3063. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  3064. }
  3065. return oldValue.Starrole, nil
  3066. }
  3067. // ResetStarrole resets all changes to the "starrole" field.
  3068. func (m *ContactMutation) ResetStarrole() {
  3069. m.starrole = nil
  3070. }
  3071. // SetDontseeit sets the "dontseeit" field.
  3072. func (m *ContactMutation) SetDontseeit(i int) {
  3073. m.dontseeit = &i
  3074. m.adddontseeit = nil
  3075. }
  3076. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  3077. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  3078. v := m.dontseeit
  3079. if v == nil {
  3080. return
  3081. }
  3082. return *v, true
  3083. }
  3084. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  3085. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3087. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  3088. if !m.op.Is(OpUpdateOne) {
  3089. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  3090. }
  3091. if m.id == nil || m.oldValue == nil {
  3092. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  3093. }
  3094. oldValue, err := m.oldValue(ctx)
  3095. if err != nil {
  3096. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  3097. }
  3098. return oldValue.Dontseeit, nil
  3099. }
  3100. // AddDontseeit adds i to the "dontseeit" field.
  3101. func (m *ContactMutation) AddDontseeit(i int) {
  3102. if m.adddontseeit != nil {
  3103. *m.adddontseeit += i
  3104. } else {
  3105. m.adddontseeit = &i
  3106. }
  3107. }
  3108. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  3109. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  3110. v := m.adddontseeit
  3111. if v == nil {
  3112. return
  3113. }
  3114. return *v, true
  3115. }
  3116. // ResetDontseeit resets all changes to the "dontseeit" field.
  3117. func (m *ContactMutation) ResetDontseeit() {
  3118. m.dontseeit = nil
  3119. m.adddontseeit = nil
  3120. }
  3121. // SetDontseeme sets the "dontseeme" field.
  3122. func (m *ContactMutation) SetDontseeme(i int) {
  3123. m.dontseeme = &i
  3124. m.adddontseeme = nil
  3125. }
  3126. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  3127. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  3128. v := m.dontseeme
  3129. if v == nil {
  3130. return
  3131. }
  3132. return *v, true
  3133. }
  3134. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  3135. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3137. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  3138. if !m.op.Is(OpUpdateOne) {
  3139. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  3140. }
  3141. if m.id == nil || m.oldValue == nil {
  3142. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  3143. }
  3144. oldValue, err := m.oldValue(ctx)
  3145. if err != nil {
  3146. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  3147. }
  3148. return oldValue.Dontseeme, nil
  3149. }
  3150. // AddDontseeme adds i to the "dontseeme" field.
  3151. func (m *ContactMutation) AddDontseeme(i int) {
  3152. if m.adddontseeme != nil {
  3153. *m.adddontseeme += i
  3154. } else {
  3155. m.adddontseeme = &i
  3156. }
  3157. }
  3158. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  3159. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  3160. v := m.adddontseeme
  3161. if v == nil {
  3162. return
  3163. }
  3164. return *v, true
  3165. }
  3166. // ResetDontseeme resets all changes to the "dontseeme" field.
  3167. func (m *ContactMutation) ResetDontseeme() {
  3168. m.dontseeme = nil
  3169. m.adddontseeme = nil
  3170. }
  3171. // SetLag sets the "lag" field.
  3172. func (m *ContactMutation) SetLag(s string) {
  3173. m.lag = &s
  3174. }
  3175. // Lag returns the value of the "lag" field in the mutation.
  3176. func (m *ContactMutation) Lag() (r string, exists bool) {
  3177. v := m.lag
  3178. if v == nil {
  3179. return
  3180. }
  3181. return *v, true
  3182. }
  3183. // OldLag returns the old "lag" field's value of the Contact entity.
  3184. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3186. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  3187. if !m.op.Is(OpUpdateOne) {
  3188. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  3189. }
  3190. if m.id == nil || m.oldValue == nil {
  3191. return v, errors.New("OldLag requires an ID field in the mutation")
  3192. }
  3193. oldValue, err := m.oldValue(ctx)
  3194. if err != nil {
  3195. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  3196. }
  3197. return oldValue.Lag, nil
  3198. }
  3199. // ResetLag resets all changes to the "lag" field.
  3200. func (m *ContactMutation) ResetLag() {
  3201. m.lag = nil
  3202. }
  3203. // SetGid sets the "gid" field.
  3204. func (m *ContactMutation) SetGid(s string) {
  3205. m.gid = &s
  3206. }
  3207. // Gid returns the value of the "gid" field in the mutation.
  3208. func (m *ContactMutation) Gid() (r string, exists bool) {
  3209. v := m.gid
  3210. if v == nil {
  3211. return
  3212. }
  3213. return *v, true
  3214. }
  3215. // OldGid returns the old "gid" field's value of the Contact entity.
  3216. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3218. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  3219. if !m.op.Is(OpUpdateOne) {
  3220. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  3221. }
  3222. if m.id == nil || m.oldValue == nil {
  3223. return v, errors.New("OldGid requires an ID field in the mutation")
  3224. }
  3225. oldValue, err := m.oldValue(ctx)
  3226. if err != nil {
  3227. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  3228. }
  3229. return oldValue.Gid, nil
  3230. }
  3231. // ResetGid resets all changes to the "gid" field.
  3232. func (m *ContactMutation) ResetGid() {
  3233. m.gid = nil
  3234. }
  3235. // SetGname sets the "gname" field.
  3236. func (m *ContactMutation) SetGname(s string) {
  3237. m.gname = &s
  3238. }
  3239. // Gname returns the value of the "gname" field in the mutation.
  3240. func (m *ContactMutation) Gname() (r string, exists bool) {
  3241. v := m.gname
  3242. if v == nil {
  3243. return
  3244. }
  3245. return *v, true
  3246. }
  3247. // OldGname returns the old "gname" field's value of the Contact entity.
  3248. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3250. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  3251. if !m.op.Is(OpUpdateOne) {
  3252. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  3253. }
  3254. if m.id == nil || m.oldValue == nil {
  3255. return v, errors.New("OldGname requires an ID field in the mutation")
  3256. }
  3257. oldValue, err := m.oldValue(ctx)
  3258. if err != nil {
  3259. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  3260. }
  3261. return oldValue.Gname, nil
  3262. }
  3263. // ResetGname resets all changes to the "gname" field.
  3264. func (m *ContactMutation) ResetGname() {
  3265. m.gname = nil
  3266. }
  3267. // SetV3 sets the "v3" field.
  3268. func (m *ContactMutation) SetV3(s string) {
  3269. m.v3 = &s
  3270. }
  3271. // V3 returns the value of the "v3" field in the mutation.
  3272. func (m *ContactMutation) V3() (r string, exists bool) {
  3273. v := m.v3
  3274. if v == nil {
  3275. return
  3276. }
  3277. return *v, true
  3278. }
  3279. // OldV3 returns the old "v3" field's value of the Contact entity.
  3280. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3282. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  3283. if !m.op.Is(OpUpdateOne) {
  3284. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  3285. }
  3286. if m.id == nil || m.oldValue == nil {
  3287. return v, errors.New("OldV3 requires an ID field in the mutation")
  3288. }
  3289. oldValue, err := m.oldValue(ctx)
  3290. if err != nil {
  3291. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  3292. }
  3293. return oldValue.V3, nil
  3294. }
  3295. // ResetV3 resets all changes to the "v3" field.
  3296. func (m *ContactMutation) ResetV3() {
  3297. m.v3 = nil
  3298. }
  3299. // SetOrganizationID sets the "organization_id" field.
  3300. func (m *ContactMutation) SetOrganizationID(u uint64) {
  3301. m.organization_id = &u
  3302. m.addorganization_id = nil
  3303. }
  3304. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3305. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  3306. v := m.organization_id
  3307. if v == nil {
  3308. return
  3309. }
  3310. return *v, true
  3311. }
  3312. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  3313. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3315. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3316. if !m.op.Is(OpUpdateOne) {
  3317. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3318. }
  3319. if m.id == nil || m.oldValue == nil {
  3320. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3321. }
  3322. oldValue, err := m.oldValue(ctx)
  3323. if err != nil {
  3324. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3325. }
  3326. return oldValue.OrganizationID, nil
  3327. }
  3328. // AddOrganizationID adds u to the "organization_id" field.
  3329. func (m *ContactMutation) AddOrganizationID(u int64) {
  3330. if m.addorganization_id != nil {
  3331. *m.addorganization_id += u
  3332. } else {
  3333. m.addorganization_id = &u
  3334. }
  3335. }
  3336. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3337. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  3338. v := m.addorganization_id
  3339. if v == nil {
  3340. return
  3341. }
  3342. return *v, true
  3343. }
  3344. // ClearOrganizationID clears the value of the "organization_id" field.
  3345. func (m *ContactMutation) ClearOrganizationID() {
  3346. m.organization_id = nil
  3347. m.addorganization_id = nil
  3348. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  3349. }
  3350. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3351. func (m *ContactMutation) OrganizationIDCleared() bool {
  3352. _, ok := m.clearedFields[contact.FieldOrganizationID]
  3353. return ok
  3354. }
  3355. // ResetOrganizationID resets all changes to the "organization_id" field.
  3356. func (m *ContactMutation) ResetOrganizationID() {
  3357. m.organization_id = nil
  3358. m.addorganization_id = nil
  3359. delete(m.clearedFields, contact.FieldOrganizationID)
  3360. }
  3361. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  3362. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  3363. if m.contact_relationships == nil {
  3364. m.contact_relationships = make(map[uint64]struct{})
  3365. }
  3366. for i := range ids {
  3367. m.contact_relationships[ids[i]] = struct{}{}
  3368. }
  3369. }
  3370. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  3371. func (m *ContactMutation) ClearContactRelationships() {
  3372. m.clearedcontact_relationships = true
  3373. }
  3374. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  3375. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  3376. return m.clearedcontact_relationships
  3377. }
  3378. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  3379. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  3380. if m.removedcontact_relationships == nil {
  3381. m.removedcontact_relationships = make(map[uint64]struct{})
  3382. }
  3383. for i := range ids {
  3384. delete(m.contact_relationships, ids[i])
  3385. m.removedcontact_relationships[ids[i]] = struct{}{}
  3386. }
  3387. }
  3388. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  3389. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  3390. for id := range m.removedcontact_relationships {
  3391. ids = append(ids, id)
  3392. }
  3393. return
  3394. }
  3395. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  3396. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  3397. for id := range m.contact_relationships {
  3398. ids = append(ids, id)
  3399. }
  3400. return
  3401. }
  3402. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  3403. func (m *ContactMutation) ResetContactRelationships() {
  3404. m.contact_relationships = nil
  3405. m.clearedcontact_relationships = false
  3406. m.removedcontact_relationships = nil
  3407. }
  3408. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  3409. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  3410. if m.contact_messages == nil {
  3411. m.contact_messages = make(map[uint64]struct{})
  3412. }
  3413. for i := range ids {
  3414. m.contact_messages[ids[i]] = struct{}{}
  3415. }
  3416. }
  3417. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  3418. func (m *ContactMutation) ClearContactMessages() {
  3419. m.clearedcontact_messages = true
  3420. }
  3421. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  3422. func (m *ContactMutation) ContactMessagesCleared() bool {
  3423. return m.clearedcontact_messages
  3424. }
  3425. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  3426. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  3427. if m.removedcontact_messages == nil {
  3428. m.removedcontact_messages = make(map[uint64]struct{})
  3429. }
  3430. for i := range ids {
  3431. delete(m.contact_messages, ids[i])
  3432. m.removedcontact_messages[ids[i]] = struct{}{}
  3433. }
  3434. }
  3435. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  3436. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  3437. for id := range m.removedcontact_messages {
  3438. ids = append(ids, id)
  3439. }
  3440. return
  3441. }
  3442. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  3443. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  3444. for id := range m.contact_messages {
  3445. ids = append(ids, id)
  3446. }
  3447. return
  3448. }
  3449. // ResetContactMessages resets all changes to the "contact_messages" edge.
  3450. func (m *ContactMutation) ResetContactMessages() {
  3451. m.contact_messages = nil
  3452. m.clearedcontact_messages = false
  3453. m.removedcontact_messages = nil
  3454. }
  3455. // Where appends a list predicates to the ContactMutation builder.
  3456. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  3457. m.predicates = append(m.predicates, ps...)
  3458. }
  3459. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  3460. // users can use type-assertion to append predicates that do not depend on any generated package.
  3461. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  3462. p := make([]predicate.Contact, len(ps))
  3463. for i := range ps {
  3464. p[i] = ps[i]
  3465. }
  3466. m.Where(p...)
  3467. }
  3468. // Op returns the operation name.
  3469. func (m *ContactMutation) Op() Op {
  3470. return m.op
  3471. }
  3472. // SetOp allows setting the mutation operation.
  3473. func (m *ContactMutation) SetOp(op Op) {
  3474. m.op = op
  3475. }
  3476. // Type returns the node type of this mutation (Contact).
  3477. func (m *ContactMutation) Type() string {
  3478. return m.typ
  3479. }
  3480. // Fields returns all fields that were changed during this mutation. Note that in
  3481. // order to get all numeric fields that were incremented/decremented, call
  3482. // AddedFields().
  3483. func (m *ContactMutation) Fields() []string {
  3484. fields := make([]string, 0, 20)
  3485. if m.created_at != nil {
  3486. fields = append(fields, contact.FieldCreatedAt)
  3487. }
  3488. if m.updated_at != nil {
  3489. fields = append(fields, contact.FieldUpdatedAt)
  3490. }
  3491. if m.status != nil {
  3492. fields = append(fields, contact.FieldStatus)
  3493. }
  3494. if m.deleted_at != nil {
  3495. fields = append(fields, contact.FieldDeletedAt)
  3496. }
  3497. if m.wx_wxid != nil {
  3498. fields = append(fields, contact.FieldWxWxid)
  3499. }
  3500. if m._type != nil {
  3501. fields = append(fields, contact.FieldType)
  3502. }
  3503. if m.wxid != nil {
  3504. fields = append(fields, contact.FieldWxid)
  3505. }
  3506. if m.account != nil {
  3507. fields = append(fields, contact.FieldAccount)
  3508. }
  3509. if m.nickname != nil {
  3510. fields = append(fields, contact.FieldNickname)
  3511. }
  3512. if m.markname != nil {
  3513. fields = append(fields, contact.FieldMarkname)
  3514. }
  3515. if m.headimg != nil {
  3516. fields = append(fields, contact.FieldHeadimg)
  3517. }
  3518. if m.sex != nil {
  3519. fields = append(fields, contact.FieldSex)
  3520. }
  3521. if m.starrole != nil {
  3522. fields = append(fields, contact.FieldStarrole)
  3523. }
  3524. if m.dontseeit != nil {
  3525. fields = append(fields, contact.FieldDontseeit)
  3526. }
  3527. if m.dontseeme != nil {
  3528. fields = append(fields, contact.FieldDontseeme)
  3529. }
  3530. if m.lag != nil {
  3531. fields = append(fields, contact.FieldLag)
  3532. }
  3533. if m.gid != nil {
  3534. fields = append(fields, contact.FieldGid)
  3535. }
  3536. if m.gname != nil {
  3537. fields = append(fields, contact.FieldGname)
  3538. }
  3539. if m.v3 != nil {
  3540. fields = append(fields, contact.FieldV3)
  3541. }
  3542. if m.organization_id != nil {
  3543. fields = append(fields, contact.FieldOrganizationID)
  3544. }
  3545. return fields
  3546. }
  3547. // Field returns the value of a field with the given name. The second boolean
  3548. // return value indicates that this field was not set, or was not defined in the
  3549. // schema.
  3550. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  3551. switch name {
  3552. case contact.FieldCreatedAt:
  3553. return m.CreatedAt()
  3554. case contact.FieldUpdatedAt:
  3555. return m.UpdatedAt()
  3556. case contact.FieldStatus:
  3557. return m.Status()
  3558. case contact.FieldDeletedAt:
  3559. return m.DeletedAt()
  3560. case contact.FieldWxWxid:
  3561. return m.WxWxid()
  3562. case contact.FieldType:
  3563. return m.GetType()
  3564. case contact.FieldWxid:
  3565. return m.Wxid()
  3566. case contact.FieldAccount:
  3567. return m.Account()
  3568. case contact.FieldNickname:
  3569. return m.Nickname()
  3570. case contact.FieldMarkname:
  3571. return m.Markname()
  3572. case contact.FieldHeadimg:
  3573. return m.Headimg()
  3574. case contact.FieldSex:
  3575. return m.Sex()
  3576. case contact.FieldStarrole:
  3577. return m.Starrole()
  3578. case contact.FieldDontseeit:
  3579. return m.Dontseeit()
  3580. case contact.FieldDontseeme:
  3581. return m.Dontseeme()
  3582. case contact.FieldLag:
  3583. return m.Lag()
  3584. case contact.FieldGid:
  3585. return m.Gid()
  3586. case contact.FieldGname:
  3587. return m.Gname()
  3588. case contact.FieldV3:
  3589. return m.V3()
  3590. case contact.FieldOrganizationID:
  3591. return m.OrganizationID()
  3592. }
  3593. return nil, false
  3594. }
  3595. // OldField returns the old value of the field from the database. An error is
  3596. // returned if the mutation operation is not UpdateOne, or the query to the
  3597. // database failed.
  3598. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3599. switch name {
  3600. case contact.FieldCreatedAt:
  3601. return m.OldCreatedAt(ctx)
  3602. case contact.FieldUpdatedAt:
  3603. return m.OldUpdatedAt(ctx)
  3604. case contact.FieldStatus:
  3605. return m.OldStatus(ctx)
  3606. case contact.FieldDeletedAt:
  3607. return m.OldDeletedAt(ctx)
  3608. case contact.FieldWxWxid:
  3609. return m.OldWxWxid(ctx)
  3610. case contact.FieldType:
  3611. return m.OldType(ctx)
  3612. case contact.FieldWxid:
  3613. return m.OldWxid(ctx)
  3614. case contact.FieldAccount:
  3615. return m.OldAccount(ctx)
  3616. case contact.FieldNickname:
  3617. return m.OldNickname(ctx)
  3618. case contact.FieldMarkname:
  3619. return m.OldMarkname(ctx)
  3620. case contact.FieldHeadimg:
  3621. return m.OldHeadimg(ctx)
  3622. case contact.FieldSex:
  3623. return m.OldSex(ctx)
  3624. case contact.FieldStarrole:
  3625. return m.OldStarrole(ctx)
  3626. case contact.FieldDontseeit:
  3627. return m.OldDontseeit(ctx)
  3628. case contact.FieldDontseeme:
  3629. return m.OldDontseeme(ctx)
  3630. case contact.FieldLag:
  3631. return m.OldLag(ctx)
  3632. case contact.FieldGid:
  3633. return m.OldGid(ctx)
  3634. case contact.FieldGname:
  3635. return m.OldGname(ctx)
  3636. case contact.FieldV3:
  3637. return m.OldV3(ctx)
  3638. case contact.FieldOrganizationID:
  3639. return m.OldOrganizationID(ctx)
  3640. }
  3641. return nil, fmt.Errorf("unknown Contact field %s", name)
  3642. }
  3643. // SetField sets the value of a field with the given name. It returns an error if
  3644. // the field is not defined in the schema, or if the type mismatched the field
  3645. // type.
  3646. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  3647. switch name {
  3648. case contact.FieldCreatedAt:
  3649. v, ok := value.(time.Time)
  3650. if !ok {
  3651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3652. }
  3653. m.SetCreatedAt(v)
  3654. return nil
  3655. case contact.FieldUpdatedAt:
  3656. v, ok := value.(time.Time)
  3657. if !ok {
  3658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3659. }
  3660. m.SetUpdatedAt(v)
  3661. return nil
  3662. case contact.FieldStatus:
  3663. v, ok := value.(uint8)
  3664. if !ok {
  3665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3666. }
  3667. m.SetStatus(v)
  3668. return nil
  3669. case contact.FieldDeletedAt:
  3670. v, ok := value.(time.Time)
  3671. if !ok {
  3672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3673. }
  3674. m.SetDeletedAt(v)
  3675. return nil
  3676. case contact.FieldWxWxid:
  3677. v, ok := value.(string)
  3678. if !ok {
  3679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3680. }
  3681. m.SetWxWxid(v)
  3682. return nil
  3683. case contact.FieldType:
  3684. v, ok := value.(int)
  3685. if !ok {
  3686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3687. }
  3688. m.SetType(v)
  3689. return nil
  3690. case contact.FieldWxid:
  3691. v, ok := value.(string)
  3692. if !ok {
  3693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3694. }
  3695. m.SetWxid(v)
  3696. return nil
  3697. case contact.FieldAccount:
  3698. v, ok := value.(string)
  3699. if !ok {
  3700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3701. }
  3702. m.SetAccount(v)
  3703. return nil
  3704. case contact.FieldNickname:
  3705. v, ok := value.(string)
  3706. if !ok {
  3707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3708. }
  3709. m.SetNickname(v)
  3710. return nil
  3711. case contact.FieldMarkname:
  3712. v, ok := value.(string)
  3713. if !ok {
  3714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3715. }
  3716. m.SetMarkname(v)
  3717. return nil
  3718. case contact.FieldHeadimg:
  3719. v, ok := value.(string)
  3720. if !ok {
  3721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3722. }
  3723. m.SetHeadimg(v)
  3724. return nil
  3725. case contact.FieldSex:
  3726. v, ok := value.(int)
  3727. if !ok {
  3728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3729. }
  3730. m.SetSex(v)
  3731. return nil
  3732. case contact.FieldStarrole:
  3733. v, ok := value.(string)
  3734. if !ok {
  3735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3736. }
  3737. m.SetStarrole(v)
  3738. return nil
  3739. case contact.FieldDontseeit:
  3740. v, ok := value.(int)
  3741. if !ok {
  3742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3743. }
  3744. m.SetDontseeit(v)
  3745. return nil
  3746. case contact.FieldDontseeme:
  3747. v, ok := value.(int)
  3748. if !ok {
  3749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3750. }
  3751. m.SetDontseeme(v)
  3752. return nil
  3753. case contact.FieldLag:
  3754. v, ok := value.(string)
  3755. if !ok {
  3756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3757. }
  3758. m.SetLag(v)
  3759. return nil
  3760. case contact.FieldGid:
  3761. v, ok := value.(string)
  3762. if !ok {
  3763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3764. }
  3765. m.SetGid(v)
  3766. return nil
  3767. case contact.FieldGname:
  3768. v, ok := value.(string)
  3769. if !ok {
  3770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3771. }
  3772. m.SetGname(v)
  3773. return nil
  3774. case contact.FieldV3:
  3775. v, ok := value.(string)
  3776. if !ok {
  3777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3778. }
  3779. m.SetV3(v)
  3780. return nil
  3781. case contact.FieldOrganizationID:
  3782. v, ok := value.(uint64)
  3783. if !ok {
  3784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3785. }
  3786. m.SetOrganizationID(v)
  3787. return nil
  3788. }
  3789. return fmt.Errorf("unknown Contact field %s", name)
  3790. }
  3791. // AddedFields returns all numeric fields that were incremented/decremented during
  3792. // this mutation.
  3793. func (m *ContactMutation) AddedFields() []string {
  3794. var fields []string
  3795. if m.addstatus != nil {
  3796. fields = append(fields, contact.FieldStatus)
  3797. }
  3798. if m.add_type != nil {
  3799. fields = append(fields, contact.FieldType)
  3800. }
  3801. if m.addsex != nil {
  3802. fields = append(fields, contact.FieldSex)
  3803. }
  3804. if m.adddontseeit != nil {
  3805. fields = append(fields, contact.FieldDontseeit)
  3806. }
  3807. if m.adddontseeme != nil {
  3808. fields = append(fields, contact.FieldDontseeme)
  3809. }
  3810. if m.addorganization_id != nil {
  3811. fields = append(fields, contact.FieldOrganizationID)
  3812. }
  3813. return fields
  3814. }
  3815. // AddedField returns the numeric value that was incremented/decremented on a field
  3816. // with the given name. The second boolean return value indicates that this field
  3817. // was not set, or was not defined in the schema.
  3818. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  3819. switch name {
  3820. case contact.FieldStatus:
  3821. return m.AddedStatus()
  3822. case contact.FieldType:
  3823. return m.AddedType()
  3824. case contact.FieldSex:
  3825. return m.AddedSex()
  3826. case contact.FieldDontseeit:
  3827. return m.AddedDontseeit()
  3828. case contact.FieldDontseeme:
  3829. return m.AddedDontseeme()
  3830. case contact.FieldOrganizationID:
  3831. return m.AddedOrganizationID()
  3832. }
  3833. return nil, false
  3834. }
  3835. // AddField adds the value to the field with the given name. It returns an error if
  3836. // the field is not defined in the schema, or if the type mismatched the field
  3837. // type.
  3838. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  3839. switch name {
  3840. case contact.FieldStatus:
  3841. v, ok := value.(int8)
  3842. if !ok {
  3843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3844. }
  3845. m.AddStatus(v)
  3846. return nil
  3847. case contact.FieldType:
  3848. v, ok := value.(int)
  3849. if !ok {
  3850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3851. }
  3852. m.AddType(v)
  3853. return nil
  3854. case contact.FieldSex:
  3855. v, ok := value.(int)
  3856. if !ok {
  3857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3858. }
  3859. m.AddSex(v)
  3860. return nil
  3861. case contact.FieldDontseeit:
  3862. v, ok := value.(int)
  3863. if !ok {
  3864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3865. }
  3866. m.AddDontseeit(v)
  3867. return nil
  3868. case contact.FieldDontseeme:
  3869. v, ok := value.(int)
  3870. if !ok {
  3871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3872. }
  3873. m.AddDontseeme(v)
  3874. return nil
  3875. case contact.FieldOrganizationID:
  3876. v, ok := value.(int64)
  3877. if !ok {
  3878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3879. }
  3880. m.AddOrganizationID(v)
  3881. return nil
  3882. }
  3883. return fmt.Errorf("unknown Contact numeric field %s", name)
  3884. }
  3885. // ClearedFields returns all nullable fields that were cleared during this
  3886. // mutation.
  3887. func (m *ContactMutation) ClearedFields() []string {
  3888. var fields []string
  3889. if m.FieldCleared(contact.FieldStatus) {
  3890. fields = append(fields, contact.FieldStatus)
  3891. }
  3892. if m.FieldCleared(contact.FieldDeletedAt) {
  3893. fields = append(fields, contact.FieldDeletedAt)
  3894. }
  3895. if m.FieldCleared(contact.FieldWxWxid) {
  3896. fields = append(fields, contact.FieldWxWxid)
  3897. }
  3898. if m.FieldCleared(contact.FieldType) {
  3899. fields = append(fields, contact.FieldType)
  3900. }
  3901. if m.FieldCleared(contact.FieldOrganizationID) {
  3902. fields = append(fields, contact.FieldOrganizationID)
  3903. }
  3904. return fields
  3905. }
  3906. // FieldCleared returns a boolean indicating if a field with the given name was
  3907. // cleared in this mutation.
  3908. func (m *ContactMutation) FieldCleared(name string) bool {
  3909. _, ok := m.clearedFields[name]
  3910. return ok
  3911. }
  3912. // ClearField clears the value of the field with the given name. It returns an
  3913. // error if the field is not defined in the schema.
  3914. func (m *ContactMutation) ClearField(name string) error {
  3915. switch name {
  3916. case contact.FieldStatus:
  3917. m.ClearStatus()
  3918. return nil
  3919. case contact.FieldDeletedAt:
  3920. m.ClearDeletedAt()
  3921. return nil
  3922. case contact.FieldWxWxid:
  3923. m.ClearWxWxid()
  3924. return nil
  3925. case contact.FieldType:
  3926. m.ClearType()
  3927. return nil
  3928. case contact.FieldOrganizationID:
  3929. m.ClearOrganizationID()
  3930. return nil
  3931. }
  3932. return fmt.Errorf("unknown Contact nullable field %s", name)
  3933. }
  3934. // ResetField resets all changes in the mutation for the field with the given name.
  3935. // It returns an error if the field is not defined in the schema.
  3936. func (m *ContactMutation) ResetField(name string) error {
  3937. switch name {
  3938. case contact.FieldCreatedAt:
  3939. m.ResetCreatedAt()
  3940. return nil
  3941. case contact.FieldUpdatedAt:
  3942. m.ResetUpdatedAt()
  3943. return nil
  3944. case contact.FieldStatus:
  3945. m.ResetStatus()
  3946. return nil
  3947. case contact.FieldDeletedAt:
  3948. m.ResetDeletedAt()
  3949. return nil
  3950. case contact.FieldWxWxid:
  3951. m.ResetWxWxid()
  3952. return nil
  3953. case contact.FieldType:
  3954. m.ResetType()
  3955. return nil
  3956. case contact.FieldWxid:
  3957. m.ResetWxid()
  3958. return nil
  3959. case contact.FieldAccount:
  3960. m.ResetAccount()
  3961. return nil
  3962. case contact.FieldNickname:
  3963. m.ResetNickname()
  3964. return nil
  3965. case contact.FieldMarkname:
  3966. m.ResetMarkname()
  3967. return nil
  3968. case contact.FieldHeadimg:
  3969. m.ResetHeadimg()
  3970. return nil
  3971. case contact.FieldSex:
  3972. m.ResetSex()
  3973. return nil
  3974. case contact.FieldStarrole:
  3975. m.ResetStarrole()
  3976. return nil
  3977. case contact.FieldDontseeit:
  3978. m.ResetDontseeit()
  3979. return nil
  3980. case contact.FieldDontseeme:
  3981. m.ResetDontseeme()
  3982. return nil
  3983. case contact.FieldLag:
  3984. m.ResetLag()
  3985. return nil
  3986. case contact.FieldGid:
  3987. m.ResetGid()
  3988. return nil
  3989. case contact.FieldGname:
  3990. m.ResetGname()
  3991. return nil
  3992. case contact.FieldV3:
  3993. m.ResetV3()
  3994. return nil
  3995. case contact.FieldOrganizationID:
  3996. m.ResetOrganizationID()
  3997. return nil
  3998. }
  3999. return fmt.Errorf("unknown Contact field %s", name)
  4000. }
  4001. // AddedEdges returns all edge names that were set/added in this mutation.
  4002. func (m *ContactMutation) AddedEdges() []string {
  4003. edges := make([]string, 0, 2)
  4004. if m.contact_relationships != nil {
  4005. edges = append(edges, contact.EdgeContactRelationships)
  4006. }
  4007. if m.contact_messages != nil {
  4008. edges = append(edges, contact.EdgeContactMessages)
  4009. }
  4010. return edges
  4011. }
  4012. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4013. // name in this mutation.
  4014. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  4015. switch name {
  4016. case contact.EdgeContactRelationships:
  4017. ids := make([]ent.Value, 0, len(m.contact_relationships))
  4018. for id := range m.contact_relationships {
  4019. ids = append(ids, id)
  4020. }
  4021. return ids
  4022. case contact.EdgeContactMessages:
  4023. ids := make([]ent.Value, 0, len(m.contact_messages))
  4024. for id := range m.contact_messages {
  4025. ids = append(ids, id)
  4026. }
  4027. return ids
  4028. }
  4029. return nil
  4030. }
  4031. // RemovedEdges returns all edge names that were removed in this mutation.
  4032. func (m *ContactMutation) RemovedEdges() []string {
  4033. edges := make([]string, 0, 2)
  4034. if m.removedcontact_relationships != nil {
  4035. edges = append(edges, contact.EdgeContactRelationships)
  4036. }
  4037. if m.removedcontact_messages != nil {
  4038. edges = append(edges, contact.EdgeContactMessages)
  4039. }
  4040. return edges
  4041. }
  4042. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4043. // the given name in this mutation.
  4044. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  4045. switch name {
  4046. case contact.EdgeContactRelationships:
  4047. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  4048. for id := range m.removedcontact_relationships {
  4049. ids = append(ids, id)
  4050. }
  4051. return ids
  4052. case contact.EdgeContactMessages:
  4053. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  4054. for id := range m.removedcontact_messages {
  4055. ids = append(ids, id)
  4056. }
  4057. return ids
  4058. }
  4059. return nil
  4060. }
  4061. // ClearedEdges returns all edge names that were cleared in this mutation.
  4062. func (m *ContactMutation) ClearedEdges() []string {
  4063. edges := make([]string, 0, 2)
  4064. if m.clearedcontact_relationships {
  4065. edges = append(edges, contact.EdgeContactRelationships)
  4066. }
  4067. if m.clearedcontact_messages {
  4068. edges = append(edges, contact.EdgeContactMessages)
  4069. }
  4070. return edges
  4071. }
  4072. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4073. // was cleared in this mutation.
  4074. func (m *ContactMutation) EdgeCleared(name string) bool {
  4075. switch name {
  4076. case contact.EdgeContactRelationships:
  4077. return m.clearedcontact_relationships
  4078. case contact.EdgeContactMessages:
  4079. return m.clearedcontact_messages
  4080. }
  4081. return false
  4082. }
  4083. // ClearEdge clears the value of the edge with the given name. It returns an error
  4084. // if that edge is not defined in the schema.
  4085. func (m *ContactMutation) ClearEdge(name string) error {
  4086. switch name {
  4087. }
  4088. return fmt.Errorf("unknown Contact unique edge %s", name)
  4089. }
  4090. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4091. // It returns an error if the edge is not defined in the schema.
  4092. func (m *ContactMutation) ResetEdge(name string) error {
  4093. switch name {
  4094. case contact.EdgeContactRelationships:
  4095. m.ResetContactRelationships()
  4096. return nil
  4097. case contact.EdgeContactMessages:
  4098. m.ResetContactMessages()
  4099. return nil
  4100. }
  4101. return fmt.Errorf("unknown Contact edge %s", name)
  4102. }
  4103. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  4104. type EmployeeMutation struct {
  4105. config
  4106. op Op
  4107. typ string
  4108. id *uint64
  4109. created_at *time.Time
  4110. updated_at *time.Time
  4111. deleted_at *time.Time
  4112. title *string
  4113. avatar *string
  4114. tags *string
  4115. hire_count *int
  4116. addhire_count *int
  4117. service_count *int
  4118. addservice_count *int
  4119. achievement_count *int
  4120. addachievement_count *int
  4121. intro *string
  4122. estimate *string
  4123. skill *string
  4124. ability_type *string
  4125. scene *string
  4126. switch_in *string
  4127. video_url *string
  4128. organization_id *uint64
  4129. addorganization_id *int64
  4130. clearedFields map[string]struct{}
  4131. em_work_experiences map[uint64]struct{}
  4132. removedem_work_experiences map[uint64]struct{}
  4133. clearedem_work_experiences bool
  4134. em_tutorial map[uint64]struct{}
  4135. removedem_tutorial map[uint64]struct{}
  4136. clearedem_tutorial bool
  4137. done bool
  4138. oldValue func(context.Context) (*Employee, error)
  4139. predicates []predicate.Employee
  4140. }
  4141. var _ ent.Mutation = (*EmployeeMutation)(nil)
  4142. // employeeOption allows management of the mutation configuration using functional options.
  4143. type employeeOption func(*EmployeeMutation)
  4144. // newEmployeeMutation creates new mutation for the Employee entity.
  4145. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  4146. m := &EmployeeMutation{
  4147. config: c,
  4148. op: op,
  4149. typ: TypeEmployee,
  4150. clearedFields: make(map[string]struct{}),
  4151. }
  4152. for _, opt := range opts {
  4153. opt(m)
  4154. }
  4155. return m
  4156. }
  4157. // withEmployeeID sets the ID field of the mutation.
  4158. func withEmployeeID(id uint64) employeeOption {
  4159. return func(m *EmployeeMutation) {
  4160. var (
  4161. err error
  4162. once sync.Once
  4163. value *Employee
  4164. )
  4165. m.oldValue = func(ctx context.Context) (*Employee, error) {
  4166. once.Do(func() {
  4167. if m.done {
  4168. err = errors.New("querying old values post mutation is not allowed")
  4169. } else {
  4170. value, err = m.Client().Employee.Get(ctx, id)
  4171. }
  4172. })
  4173. return value, err
  4174. }
  4175. m.id = &id
  4176. }
  4177. }
  4178. // withEmployee sets the old Employee of the mutation.
  4179. func withEmployee(node *Employee) employeeOption {
  4180. return func(m *EmployeeMutation) {
  4181. m.oldValue = func(context.Context) (*Employee, error) {
  4182. return node, nil
  4183. }
  4184. m.id = &node.ID
  4185. }
  4186. }
  4187. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4188. // executed in a transaction (ent.Tx), a transactional client is returned.
  4189. func (m EmployeeMutation) Client() *Client {
  4190. client := &Client{config: m.config}
  4191. client.init()
  4192. return client
  4193. }
  4194. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4195. // it returns an error otherwise.
  4196. func (m EmployeeMutation) Tx() (*Tx, error) {
  4197. if _, ok := m.driver.(*txDriver); !ok {
  4198. return nil, errors.New("ent: mutation is not running in a transaction")
  4199. }
  4200. tx := &Tx{config: m.config}
  4201. tx.init()
  4202. return tx, nil
  4203. }
  4204. // SetID sets the value of the id field. Note that this
  4205. // operation is only accepted on creation of Employee entities.
  4206. func (m *EmployeeMutation) SetID(id uint64) {
  4207. m.id = &id
  4208. }
  4209. // ID returns the ID value in the mutation. Note that the ID is only available
  4210. // if it was provided to the builder or after it was returned from the database.
  4211. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  4212. if m.id == nil {
  4213. return
  4214. }
  4215. return *m.id, true
  4216. }
  4217. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4218. // That means, if the mutation is applied within a transaction with an isolation level such
  4219. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4220. // or updated by the mutation.
  4221. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  4222. switch {
  4223. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4224. id, exists := m.ID()
  4225. if exists {
  4226. return []uint64{id}, nil
  4227. }
  4228. fallthrough
  4229. case m.op.Is(OpUpdate | OpDelete):
  4230. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  4231. default:
  4232. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4233. }
  4234. }
  4235. // SetCreatedAt sets the "created_at" field.
  4236. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  4237. m.created_at = &t
  4238. }
  4239. // CreatedAt returns the value of the "created_at" field in the mutation.
  4240. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  4241. v := m.created_at
  4242. if v == nil {
  4243. return
  4244. }
  4245. return *v, true
  4246. }
  4247. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  4248. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4250. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4251. if !m.op.Is(OpUpdateOne) {
  4252. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4253. }
  4254. if m.id == nil || m.oldValue == nil {
  4255. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4256. }
  4257. oldValue, err := m.oldValue(ctx)
  4258. if err != nil {
  4259. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4260. }
  4261. return oldValue.CreatedAt, nil
  4262. }
  4263. // ResetCreatedAt resets all changes to the "created_at" field.
  4264. func (m *EmployeeMutation) ResetCreatedAt() {
  4265. m.created_at = nil
  4266. }
  4267. // SetUpdatedAt sets the "updated_at" field.
  4268. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  4269. m.updated_at = &t
  4270. }
  4271. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4272. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  4273. v := m.updated_at
  4274. if v == nil {
  4275. return
  4276. }
  4277. return *v, true
  4278. }
  4279. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  4280. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4282. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4283. if !m.op.Is(OpUpdateOne) {
  4284. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4285. }
  4286. if m.id == nil || m.oldValue == nil {
  4287. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4288. }
  4289. oldValue, err := m.oldValue(ctx)
  4290. if err != nil {
  4291. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4292. }
  4293. return oldValue.UpdatedAt, nil
  4294. }
  4295. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4296. func (m *EmployeeMutation) ResetUpdatedAt() {
  4297. m.updated_at = nil
  4298. }
  4299. // SetDeletedAt sets the "deleted_at" field.
  4300. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  4301. m.deleted_at = &t
  4302. }
  4303. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4304. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  4305. v := m.deleted_at
  4306. if v == nil {
  4307. return
  4308. }
  4309. return *v, true
  4310. }
  4311. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  4312. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4314. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4315. if !m.op.Is(OpUpdateOne) {
  4316. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4317. }
  4318. if m.id == nil || m.oldValue == nil {
  4319. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4320. }
  4321. oldValue, err := m.oldValue(ctx)
  4322. if err != nil {
  4323. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4324. }
  4325. return oldValue.DeletedAt, nil
  4326. }
  4327. // ClearDeletedAt clears the value of the "deleted_at" field.
  4328. func (m *EmployeeMutation) ClearDeletedAt() {
  4329. m.deleted_at = nil
  4330. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  4331. }
  4332. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4333. func (m *EmployeeMutation) DeletedAtCleared() bool {
  4334. _, ok := m.clearedFields[employee.FieldDeletedAt]
  4335. return ok
  4336. }
  4337. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4338. func (m *EmployeeMutation) ResetDeletedAt() {
  4339. m.deleted_at = nil
  4340. delete(m.clearedFields, employee.FieldDeletedAt)
  4341. }
  4342. // SetTitle sets the "title" field.
  4343. func (m *EmployeeMutation) SetTitle(s string) {
  4344. m.title = &s
  4345. }
  4346. // Title returns the value of the "title" field in the mutation.
  4347. func (m *EmployeeMutation) Title() (r string, exists bool) {
  4348. v := m.title
  4349. if v == nil {
  4350. return
  4351. }
  4352. return *v, true
  4353. }
  4354. // OldTitle returns the old "title" field's value of the Employee entity.
  4355. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4357. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  4358. if !m.op.Is(OpUpdateOne) {
  4359. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4360. }
  4361. if m.id == nil || m.oldValue == nil {
  4362. return v, errors.New("OldTitle requires an ID field in the mutation")
  4363. }
  4364. oldValue, err := m.oldValue(ctx)
  4365. if err != nil {
  4366. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4367. }
  4368. return oldValue.Title, nil
  4369. }
  4370. // ResetTitle resets all changes to the "title" field.
  4371. func (m *EmployeeMutation) ResetTitle() {
  4372. m.title = nil
  4373. }
  4374. // SetAvatar sets the "avatar" field.
  4375. func (m *EmployeeMutation) SetAvatar(s string) {
  4376. m.avatar = &s
  4377. }
  4378. // Avatar returns the value of the "avatar" field in the mutation.
  4379. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  4380. v := m.avatar
  4381. if v == nil {
  4382. return
  4383. }
  4384. return *v, true
  4385. }
  4386. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  4387. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4389. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  4390. if !m.op.Is(OpUpdateOne) {
  4391. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  4392. }
  4393. if m.id == nil || m.oldValue == nil {
  4394. return v, errors.New("OldAvatar requires an ID field in the mutation")
  4395. }
  4396. oldValue, err := m.oldValue(ctx)
  4397. if err != nil {
  4398. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  4399. }
  4400. return oldValue.Avatar, nil
  4401. }
  4402. // ResetAvatar resets all changes to the "avatar" field.
  4403. func (m *EmployeeMutation) ResetAvatar() {
  4404. m.avatar = nil
  4405. }
  4406. // SetTags sets the "tags" field.
  4407. func (m *EmployeeMutation) SetTags(s string) {
  4408. m.tags = &s
  4409. }
  4410. // Tags returns the value of the "tags" field in the mutation.
  4411. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  4412. v := m.tags
  4413. if v == nil {
  4414. return
  4415. }
  4416. return *v, true
  4417. }
  4418. // OldTags returns the old "tags" field's value of the Employee entity.
  4419. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4421. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  4422. if !m.op.Is(OpUpdateOne) {
  4423. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  4424. }
  4425. if m.id == nil || m.oldValue == nil {
  4426. return v, errors.New("OldTags requires an ID field in the mutation")
  4427. }
  4428. oldValue, err := m.oldValue(ctx)
  4429. if err != nil {
  4430. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  4431. }
  4432. return oldValue.Tags, nil
  4433. }
  4434. // ResetTags resets all changes to the "tags" field.
  4435. func (m *EmployeeMutation) ResetTags() {
  4436. m.tags = nil
  4437. }
  4438. // SetHireCount sets the "hire_count" field.
  4439. func (m *EmployeeMutation) SetHireCount(i int) {
  4440. m.hire_count = &i
  4441. m.addhire_count = nil
  4442. }
  4443. // HireCount returns the value of the "hire_count" field in the mutation.
  4444. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  4445. v := m.hire_count
  4446. if v == nil {
  4447. return
  4448. }
  4449. return *v, true
  4450. }
  4451. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  4452. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4453. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4454. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  4455. if !m.op.Is(OpUpdateOne) {
  4456. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  4457. }
  4458. if m.id == nil || m.oldValue == nil {
  4459. return v, errors.New("OldHireCount requires an ID field in the mutation")
  4460. }
  4461. oldValue, err := m.oldValue(ctx)
  4462. if err != nil {
  4463. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  4464. }
  4465. return oldValue.HireCount, nil
  4466. }
  4467. // AddHireCount adds i to the "hire_count" field.
  4468. func (m *EmployeeMutation) AddHireCount(i int) {
  4469. if m.addhire_count != nil {
  4470. *m.addhire_count += i
  4471. } else {
  4472. m.addhire_count = &i
  4473. }
  4474. }
  4475. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  4476. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  4477. v := m.addhire_count
  4478. if v == nil {
  4479. return
  4480. }
  4481. return *v, true
  4482. }
  4483. // ResetHireCount resets all changes to the "hire_count" field.
  4484. func (m *EmployeeMutation) ResetHireCount() {
  4485. m.hire_count = nil
  4486. m.addhire_count = nil
  4487. }
  4488. // SetServiceCount sets the "service_count" field.
  4489. func (m *EmployeeMutation) SetServiceCount(i int) {
  4490. m.service_count = &i
  4491. m.addservice_count = nil
  4492. }
  4493. // ServiceCount returns the value of the "service_count" field in the mutation.
  4494. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  4495. v := m.service_count
  4496. if v == nil {
  4497. return
  4498. }
  4499. return *v, true
  4500. }
  4501. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  4502. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4504. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  4505. if !m.op.Is(OpUpdateOne) {
  4506. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  4507. }
  4508. if m.id == nil || m.oldValue == nil {
  4509. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  4510. }
  4511. oldValue, err := m.oldValue(ctx)
  4512. if err != nil {
  4513. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  4514. }
  4515. return oldValue.ServiceCount, nil
  4516. }
  4517. // AddServiceCount adds i to the "service_count" field.
  4518. func (m *EmployeeMutation) AddServiceCount(i int) {
  4519. if m.addservice_count != nil {
  4520. *m.addservice_count += i
  4521. } else {
  4522. m.addservice_count = &i
  4523. }
  4524. }
  4525. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  4526. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  4527. v := m.addservice_count
  4528. if v == nil {
  4529. return
  4530. }
  4531. return *v, true
  4532. }
  4533. // ResetServiceCount resets all changes to the "service_count" field.
  4534. func (m *EmployeeMutation) ResetServiceCount() {
  4535. m.service_count = nil
  4536. m.addservice_count = nil
  4537. }
  4538. // SetAchievementCount sets the "achievement_count" field.
  4539. func (m *EmployeeMutation) SetAchievementCount(i int) {
  4540. m.achievement_count = &i
  4541. m.addachievement_count = nil
  4542. }
  4543. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  4544. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  4545. v := m.achievement_count
  4546. if v == nil {
  4547. return
  4548. }
  4549. return *v, true
  4550. }
  4551. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  4552. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4554. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  4555. if !m.op.Is(OpUpdateOne) {
  4556. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  4557. }
  4558. if m.id == nil || m.oldValue == nil {
  4559. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  4560. }
  4561. oldValue, err := m.oldValue(ctx)
  4562. if err != nil {
  4563. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  4564. }
  4565. return oldValue.AchievementCount, nil
  4566. }
  4567. // AddAchievementCount adds i to the "achievement_count" field.
  4568. func (m *EmployeeMutation) AddAchievementCount(i int) {
  4569. if m.addachievement_count != nil {
  4570. *m.addachievement_count += i
  4571. } else {
  4572. m.addachievement_count = &i
  4573. }
  4574. }
  4575. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  4576. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  4577. v := m.addachievement_count
  4578. if v == nil {
  4579. return
  4580. }
  4581. return *v, true
  4582. }
  4583. // ResetAchievementCount resets all changes to the "achievement_count" field.
  4584. func (m *EmployeeMutation) ResetAchievementCount() {
  4585. m.achievement_count = nil
  4586. m.addachievement_count = nil
  4587. }
  4588. // SetIntro sets the "intro" field.
  4589. func (m *EmployeeMutation) SetIntro(s string) {
  4590. m.intro = &s
  4591. }
  4592. // Intro returns the value of the "intro" field in the mutation.
  4593. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  4594. v := m.intro
  4595. if v == nil {
  4596. return
  4597. }
  4598. return *v, true
  4599. }
  4600. // OldIntro returns the old "intro" field's value of the Employee entity.
  4601. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4603. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  4604. if !m.op.Is(OpUpdateOne) {
  4605. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  4606. }
  4607. if m.id == nil || m.oldValue == nil {
  4608. return v, errors.New("OldIntro requires an ID field in the mutation")
  4609. }
  4610. oldValue, err := m.oldValue(ctx)
  4611. if err != nil {
  4612. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  4613. }
  4614. return oldValue.Intro, nil
  4615. }
  4616. // ResetIntro resets all changes to the "intro" field.
  4617. func (m *EmployeeMutation) ResetIntro() {
  4618. m.intro = nil
  4619. }
  4620. // SetEstimate sets the "estimate" field.
  4621. func (m *EmployeeMutation) SetEstimate(s string) {
  4622. m.estimate = &s
  4623. }
  4624. // Estimate returns the value of the "estimate" field in the mutation.
  4625. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  4626. v := m.estimate
  4627. if v == nil {
  4628. return
  4629. }
  4630. return *v, true
  4631. }
  4632. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  4633. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4635. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  4636. if !m.op.Is(OpUpdateOne) {
  4637. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  4638. }
  4639. if m.id == nil || m.oldValue == nil {
  4640. return v, errors.New("OldEstimate requires an ID field in the mutation")
  4641. }
  4642. oldValue, err := m.oldValue(ctx)
  4643. if err != nil {
  4644. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  4645. }
  4646. return oldValue.Estimate, nil
  4647. }
  4648. // ResetEstimate resets all changes to the "estimate" field.
  4649. func (m *EmployeeMutation) ResetEstimate() {
  4650. m.estimate = nil
  4651. }
  4652. // SetSkill sets the "skill" field.
  4653. func (m *EmployeeMutation) SetSkill(s string) {
  4654. m.skill = &s
  4655. }
  4656. // Skill returns the value of the "skill" field in the mutation.
  4657. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  4658. v := m.skill
  4659. if v == nil {
  4660. return
  4661. }
  4662. return *v, true
  4663. }
  4664. // OldSkill returns the old "skill" field's value of the Employee entity.
  4665. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4667. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  4668. if !m.op.Is(OpUpdateOne) {
  4669. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  4670. }
  4671. if m.id == nil || m.oldValue == nil {
  4672. return v, errors.New("OldSkill requires an ID field in the mutation")
  4673. }
  4674. oldValue, err := m.oldValue(ctx)
  4675. if err != nil {
  4676. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  4677. }
  4678. return oldValue.Skill, nil
  4679. }
  4680. // ResetSkill resets all changes to the "skill" field.
  4681. func (m *EmployeeMutation) ResetSkill() {
  4682. m.skill = nil
  4683. }
  4684. // SetAbilityType sets the "ability_type" field.
  4685. func (m *EmployeeMutation) SetAbilityType(s string) {
  4686. m.ability_type = &s
  4687. }
  4688. // AbilityType returns the value of the "ability_type" field in the mutation.
  4689. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  4690. v := m.ability_type
  4691. if v == nil {
  4692. return
  4693. }
  4694. return *v, true
  4695. }
  4696. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  4697. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4699. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  4700. if !m.op.Is(OpUpdateOne) {
  4701. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  4702. }
  4703. if m.id == nil || m.oldValue == nil {
  4704. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  4705. }
  4706. oldValue, err := m.oldValue(ctx)
  4707. if err != nil {
  4708. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  4709. }
  4710. return oldValue.AbilityType, nil
  4711. }
  4712. // ResetAbilityType resets all changes to the "ability_type" field.
  4713. func (m *EmployeeMutation) ResetAbilityType() {
  4714. m.ability_type = nil
  4715. }
  4716. // SetScene sets the "scene" field.
  4717. func (m *EmployeeMutation) SetScene(s string) {
  4718. m.scene = &s
  4719. }
  4720. // Scene returns the value of the "scene" field in the mutation.
  4721. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  4722. v := m.scene
  4723. if v == nil {
  4724. return
  4725. }
  4726. return *v, true
  4727. }
  4728. // OldScene returns the old "scene" field's value of the Employee entity.
  4729. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4731. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  4732. if !m.op.Is(OpUpdateOne) {
  4733. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  4734. }
  4735. if m.id == nil || m.oldValue == nil {
  4736. return v, errors.New("OldScene requires an ID field in the mutation")
  4737. }
  4738. oldValue, err := m.oldValue(ctx)
  4739. if err != nil {
  4740. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  4741. }
  4742. return oldValue.Scene, nil
  4743. }
  4744. // ResetScene resets all changes to the "scene" field.
  4745. func (m *EmployeeMutation) ResetScene() {
  4746. m.scene = nil
  4747. }
  4748. // SetSwitchIn sets the "switch_in" field.
  4749. func (m *EmployeeMutation) SetSwitchIn(s string) {
  4750. m.switch_in = &s
  4751. }
  4752. // SwitchIn returns the value of the "switch_in" field in the mutation.
  4753. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  4754. v := m.switch_in
  4755. if v == nil {
  4756. return
  4757. }
  4758. return *v, true
  4759. }
  4760. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  4761. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4763. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  4764. if !m.op.Is(OpUpdateOne) {
  4765. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  4766. }
  4767. if m.id == nil || m.oldValue == nil {
  4768. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  4769. }
  4770. oldValue, err := m.oldValue(ctx)
  4771. if err != nil {
  4772. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  4773. }
  4774. return oldValue.SwitchIn, nil
  4775. }
  4776. // ResetSwitchIn resets all changes to the "switch_in" field.
  4777. func (m *EmployeeMutation) ResetSwitchIn() {
  4778. m.switch_in = nil
  4779. }
  4780. // SetVideoURL sets the "video_url" field.
  4781. func (m *EmployeeMutation) SetVideoURL(s string) {
  4782. m.video_url = &s
  4783. }
  4784. // VideoURL returns the value of the "video_url" field in the mutation.
  4785. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  4786. v := m.video_url
  4787. if v == nil {
  4788. return
  4789. }
  4790. return *v, true
  4791. }
  4792. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  4793. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4794. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4795. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  4796. if !m.op.Is(OpUpdateOne) {
  4797. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  4798. }
  4799. if m.id == nil || m.oldValue == nil {
  4800. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  4801. }
  4802. oldValue, err := m.oldValue(ctx)
  4803. if err != nil {
  4804. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  4805. }
  4806. return oldValue.VideoURL, nil
  4807. }
  4808. // ResetVideoURL resets all changes to the "video_url" field.
  4809. func (m *EmployeeMutation) ResetVideoURL() {
  4810. m.video_url = nil
  4811. }
  4812. // SetOrganizationID sets the "organization_id" field.
  4813. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  4814. m.organization_id = &u
  4815. m.addorganization_id = nil
  4816. }
  4817. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4818. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  4819. v := m.organization_id
  4820. if v == nil {
  4821. return
  4822. }
  4823. return *v, true
  4824. }
  4825. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  4826. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4828. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4829. if !m.op.Is(OpUpdateOne) {
  4830. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4831. }
  4832. if m.id == nil || m.oldValue == nil {
  4833. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4834. }
  4835. oldValue, err := m.oldValue(ctx)
  4836. if err != nil {
  4837. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4838. }
  4839. return oldValue.OrganizationID, nil
  4840. }
  4841. // AddOrganizationID adds u to the "organization_id" field.
  4842. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  4843. if m.addorganization_id != nil {
  4844. *m.addorganization_id += u
  4845. } else {
  4846. m.addorganization_id = &u
  4847. }
  4848. }
  4849. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4850. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  4851. v := m.addorganization_id
  4852. if v == nil {
  4853. return
  4854. }
  4855. return *v, true
  4856. }
  4857. // ResetOrganizationID resets all changes to the "organization_id" field.
  4858. func (m *EmployeeMutation) ResetOrganizationID() {
  4859. m.organization_id = nil
  4860. m.addorganization_id = nil
  4861. }
  4862. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  4863. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  4864. if m.em_work_experiences == nil {
  4865. m.em_work_experiences = make(map[uint64]struct{})
  4866. }
  4867. for i := range ids {
  4868. m.em_work_experiences[ids[i]] = struct{}{}
  4869. }
  4870. }
  4871. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  4872. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  4873. m.clearedem_work_experiences = true
  4874. }
  4875. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  4876. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  4877. return m.clearedem_work_experiences
  4878. }
  4879. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  4880. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  4881. if m.removedem_work_experiences == nil {
  4882. m.removedem_work_experiences = make(map[uint64]struct{})
  4883. }
  4884. for i := range ids {
  4885. delete(m.em_work_experiences, ids[i])
  4886. m.removedem_work_experiences[ids[i]] = struct{}{}
  4887. }
  4888. }
  4889. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  4890. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  4891. for id := range m.removedem_work_experiences {
  4892. ids = append(ids, id)
  4893. }
  4894. return
  4895. }
  4896. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  4897. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  4898. for id := range m.em_work_experiences {
  4899. ids = append(ids, id)
  4900. }
  4901. return
  4902. }
  4903. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  4904. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  4905. m.em_work_experiences = nil
  4906. m.clearedem_work_experiences = false
  4907. m.removedem_work_experiences = nil
  4908. }
  4909. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  4910. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  4911. if m.em_tutorial == nil {
  4912. m.em_tutorial = make(map[uint64]struct{})
  4913. }
  4914. for i := range ids {
  4915. m.em_tutorial[ids[i]] = struct{}{}
  4916. }
  4917. }
  4918. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  4919. func (m *EmployeeMutation) ClearEmTutorial() {
  4920. m.clearedem_tutorial = true
  4921. }
  4922. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  4923. func (m *EmployeeMutation) EmTutorialCleared() bool {
  4924. return m.clearedem_tutorial
  4925. }
  4926. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  4927. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  4928. if m.removedem_tutorial == nil {
  4929. m.removedem_tutorial = make(map[uint64]struct{})
  4930. }
  4931. for i := range ids {
  4932. delete(m.em_tutorial, ids[i])
  4933. m.removedem_tutorial[ids[i]] = struct{}{}
  4934. }
  4935. }
  4936. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  4937. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  4938. for id := range m.removedem_tutorial {
  4939. ids = append(ids, id)
  4940. }
  4941. return
  4942. }
  4943. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  4944. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  4945. for id := range m.em_tutorial {
  4946. ids = append(ids, id)
  4947. }
  4948. return
  4949. }
  4950. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  4951. func (m *EmployeeMutation) ResetEmTutorial() {
  4952. m.em_tutorial = nil
  4953. m.clearedem_tutorial = false
  4954. m.removedem_tutorial = nil
  4955. }
  4956. // Where appends a list predicates to the EmployeeMutation builder.
  4957. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  4958. m.predicates = append(m.predicates, ps...)
  4959. }
  4960. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  4961. // users can use type-assertion to append predicates that do not depend on any generated package.
  4962. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  4963. p := make([]predicate.Employee, len(ps))
  4964. for i := range ps {
  4965. p[i] = ps[i]
  4966. }
  4967. m.Where(p...)
  4968. }
  4969. // Op returns the operation name.
  4970. func (m *EmployeeMutation) Op() Op {
  4971. return m.op
  4972. }
  4973. // SetOp allows setting the mutation operation.
  4974. func (m *EmployeeMutation) SetOp(op Op) {
  4975. m.op = op
  4976. }
  4977. // Type returns the node type of this mutation (Employee).
  4978. func (m *EmployeeMutation) Type() string {
  4979. return m.typ
  4980. }
  4981. // Fields returns all fields that were changed during this mutation. Note that in
  4982. // order to get all numeric fields that were incremented/decremented, call
  4983. // AddedFields().
  4984. func (m *EmployeeMutation) Fields() []string {
  4985. fields := make([]string, 0, 17)
  4986. if m.created_at != nil {
  4987. fields = append(fields, employee.FieldCreatedAt)
  4988. }
  4989. if m.updated_at != nil {
  4990. fields = append(fields, employee.FieldUpdatedAt)
  4991. }
  4992. if m.deleted_at != nil {
  4993. fields = append(fields, employee.FieldDeletedAt)
  4994. }
  4995. if m.title != nil {
  4996. fields = append(fields, employee.FieldTitle)
  4997. }
  4998. if m.avatar != nil {
  4999. fields = append(fields, employee.FieldAvatar)
  5000. }
  5001. if m.tags != nil {
  5002. fields = append(fields, employee.FieldTags)
  5003. }
  5004. if m.hire_count != nil {
  5005. fields = append(fields, employee.FieldHireCount)
  5006. }
  5007. if m.service_count != nil {
  5008. fields = append(fields, employee.FieldServiceCount)
  5009. }
  5010. if m.achievement_count != nil {
  5011. fields = append(fields, employee.FieldAchievementCount)
  5012. }
  5013. if m.intro != nil {
  5014. fields = append(fields, employee.FieldIntro)
  5015. }
  5016. if m.estimate != nil {
  5017. fields = append(fields, employee.FieldEstimate)
  5018. }
  5019. if m.skill != nil {
  5020. fields = append(fields, employee.FieldSkill)
  5021. }
  5022. if m.ability_type != nil {
  5023. fields = append(fields, employee.FieldAbilityType)
  5024. }
  5025. if m.scene != nil {
  5026. fields = append(fields, employee.FieldScene)
  5027. }
  5028. if m.switch_in != nil {
  5029. fields = append(fields, employee.FieldSwitchIn)
  5030. }
  5031. if m.video_url != nil {
  5032. fields = append(fields, employee.FieldVideoURL)
  5033. }
  5034. if m.organization_id != nil {
  5035. fields = append(fields, employee.FieldOrganizationID)
  5036. }
  5037. return fields
  5038. }
  5039. // Field returns the value of a field with the given name. The second boolean
  5040. // return value indicates that this field was not set, or was not defined in the
  5041. // schema.
  5042. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  5043. switch name {
  5044. case employee.FieldCreatedAt:
  5045. return m.CreatedAt()
  5046. case employee.FieldUpdatedAt:
  5047. return m.UpdatedAt()
  5048. case employee.FieldDeletedAt:
  5049. return m.DeletedAt()
  5050. case employee.FieldTitle:
  5051. return m.Title()
  5052. case employee.FieldAvatar:
  5053. return m.Avatar()
  5054. case employee.FieldTags:
  5055. return m.Tags()
  5056. case employee.FieldHireCount:
  5057. return m.HireCount()
  5058. case employee.FieldServiceCount:
  5059. return m.ServiceCount()
  5060. case employee.FieldAchievementCount:
  5061. return m.AchievementCount()
  5062. case employee.FieldIntro:
  5063. return m.Intro()
  5064. case employee.FieldEstimate:
  5065. return m.Estimate()
  5066. case employee.FieldSkill:
  5067. return m.Skill()
  5068. case employee.FieldAbilityType:
  5069. return m.AbilityType()
  5070. case employee.FieldScene:
  5071. return m.Scene()
  5072. case employee.FieldSwitchIn:
  5073. return m.SwitchIn()
  5074. case employee.FieldVideoURL:
  5075. return m.VideoURL()
  5076. case employee.FieldOrganizationID:
  5077. return m.OrganizationID()
  5078. }
  5079. return nil, false
  5080. }
  5081. // OldField returns the old value of the field from the database. An error is
  5082. // returned if the mutation operation is not UpdateOne, or the query to the
  5083. // database failed.
  5084. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5085. switch name {
  5086. case employee.FieldCreatedAt:
  5087. return m.OldCreatedAt(ctx)
  5088. case employee.FieldUpdatedAt:
  5089. return m.OldUpdatedAt(ctx)
  5090. case employee.FieldDeletedAt:
  5091. return m.OldDeletedAt(ctx)
  5092. case employee.FieldTitle:
  5093. return m.OldTitle(ctx)
  5094. case employee.FieldAvatar:
  5095. return m.OldAvatar(ctx)
  5096. case employee.FieldTags:
  5097. return m.OldTags(ctx)
  5098. case employee.FieldHireCount:
  5099. return m.OldHireCount(ctx)
  5100. case employee.FieldServiceCount:
  5101. return m.OldServiceCount(ctx)
  5102. case employee.FieldAchievementCount:
  5103. return m.OldAchievementCount(ctx)
  5104. case employee.FieldIntro:
  5105. return m.OldIntro(ctx)
  5106. case employee.FieldEstimate:
  5107. return m.OldEstimate(ctx)
  5108. case employee.FieldSkill:
  5109. return m.OldSkill(ctx)
  5110. case employee.FieldAbilityType:
  5111. return m.OldAbilityType(ctx)
  5112. case employee.FieldScene:
  5113. return m.OldScene(ctx)
  5114. case employee.FieldSwitchIn:
  5115. return m.OldSwitchIn(ctx)
  5116. case employee.FieldVideoURL:
  5117. return m.OldVideoURL(ctx)
  5118. case employee.FieldOrganizationID:
  5119. return m.OldOrganizationID(ctx)
  5120. }
  5121. return nil, fmt.Errorf("unknown Employee field %s", name)
  5122. }
  5123. // SetField sets the value of a field with the given name. It returns an error if
  5124. // the field is not defined in the schema, or if the type mismatched the field
  5125. // type.
  5126. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  5127. switch name {
  5128. case employee.FieldCreatedAt:
  5129. v, ok := value.(time.Time)
  5130. if !ok {
  5131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5132. }
  5133. m.SetCreatedAt(v)
  5134. return nil
  5135. case employee.FieldUpdatedAt:
  5136. v, ok := value.(time.Time)
  5137. if !ok {
  5138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5139. }
  5140. m.SetUpdatedAt(v)
  5141. return nil
  5142. case employee.FieldDeletedAt:
  5143. v, ok := value.(time.Time)
  5144. if !ok {
  5145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5146. }
  5147. m.SetDeletedAt(v)
  5148. return nil
  5149. case employee.FieldTitle:
  5150. v, ok := value.(string)
  5151. if !ok {
  5152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5153. }
  5154. m.SetTitle(v)
  5155. return nil
  5156. case employee.FieldAvatar:
  5157. v, ok := value.(string)
  5158. if !ok {
  5159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5160. }
  5161. m.SetAvatar(v)
  5162. return nil
  5163. case employee.FieldTags:
  5164. v, ok := value.(string)
  5165. if !ok {
  5166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5167. }
  5168. m.SetTags(v)
  5169. return nil
  5170. case employee.FieldHireCount:
  5171. v, ok := value.(int)
  5172. if !ok {
  5173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5174. }
  5175. m.SetHireCount(v)
  5176. return nil
  5177. case employee.FieldServiceCount:
  5178. v, ok := value.(int)
  5179. if !ok {
  5180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5181. }
  5182. m.SetServiceCount(v)
  5183. return nil
  5184. case employee.FieldAchievementCount:
  5185. v, ok := value.(int)
  5186. if !ok {
  5187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5188. }
  5189. m.SetAchievementCount(v)
  5190. return nil
  5191. case employee.FieldIntro:
  5192. v, ok := value.(string)
  5193. if !ok {
  5194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5195. }
  5196. m.SetIntro(v)
  5197. return nil
  5198. case employee.FieldEstimate:
  5199. v, ok := value.(string)
  5200. if !ok {
  5201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5202. }
  5203. m.SetEstimate(v)
  5204. return nil
  5205. case employee.FieldSkill:
  5206. v, ok := value.(string)
  5207. if !ok {
  5208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5209. }
  5210. m.SetSkill(v)
  5211. return nil
  5212. case employee.FieldAbilityType:
  5213. v, ok := value.(string)
  5214. if !ok {
  5215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5216. }
  5217. m.SetAbilityType(v)
  5218. return nil
  5219. case employee.FieldScene:
  5220. v, ok := value.(string)
  5221. if !ok {
  5222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5223. }
  5224. m.SetScene(v)
  5225. return nil
  5226. case employee.FieldSwitchIn:
  5227. v, ok := value.(string)
  5228. if !ok {
  5229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5230. }
  5231. m.SetSwitchIn(v)
  5232. return nil
  5233. case employee.FieldVideoURL:
  5234. v, ok := value.(string)
  5235. if !ok {
  5236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5237. }
  5238. m.SetVideoURL(v)
  5239. return nil
  5240. case employee.FieldOrganizationID:
  5241. v, ok := value.(uint64)
  5242. if !ok {
  5243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5244. }
  5245. m.SetOrganizationID(v)
  5246. return nil
  5247. }
  5248. return fmt.Errorf("unknown Employee field %s", name)
  5249. }
  5250. // AddedFields returns all numeric fields that were incremented/decremented during
  5251. // this mutation.
  5252. func (m *EmployeeMutation) AddedFields() []string {
  5253. var fields []string
  5254. if m.addhire_count != nil {
  5255. fields = append(fields, employee.FieldHireCount)
  5256. }
  5257. if m.addservice_count != nil {
  5258. fields = append(fields, employee.FieldServiceCount)
  5259. }
  5260. if m.addachievement_count != nil {
  5261. fields = append(fields, employee.FieldAchievementCount)
  5262. }
  5263. if m.addorganization_id != nil {
  5264. fields = append(fields, employee.FieldOrganizationID)
  5265. }
  5266. return fields
  5267. }
  5268. // AddedField returns the numeric value that was incremented/decremented on a field
  5269. // with the given name. The second boolean return value indicates that this field
  5270. // was not set, or was not defined in the schema.
  5271. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  5272. switch name {
  5273. case employee.FieldHireCount:
  5274. return m.AddedHireCount()
  5275. case employee.FieldServiceCount:
  5276. return m.AddedServiceCount()
  5277. case employee.FieldAchievementCount:
  5278. return m.AddedAchievementCount()
  5279. case employee.FieldOrganizationID:
  5280. return m.AddedOrganizationID()
  5281. }
  5282. return nil, false
  5283. }
  5284. // AddField adds the value to the field with the given name. It returns an error if
  5285. // the field is not defined in the schema, or if the type mismatched the field
  5286. // type.
  5287. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  5288. switch name {
  5289. case employee.FieldHireCount:
  5290. v, ok := value.(int)
  5291. if !ok {
  5292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5293. }
  5294. m.AddHireCount(v)
  5295. return nil
  5296. case employee.FieldServiceCount:
  5297. v, ok := value.(int)
  5298. if !ok {
  5299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5300. }
  5301. m.AddServiceCount(v)
  5302. return nil
  5303. case employee.FieldAchievementCount:
  5304. v, ok := value.(int)
  5305. if !ok {
  5306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5307. }
  5308. m.AddAchievementCount(v)
  5309. return nil
  5310. case employee.FieldOrganizationID:
  5311. v, ok := value.(int64)
  5312. if !ok {
  5313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5314. }
  5315. m.AddOrganizationID(v)
  5316. return nil
  5317. }
  5318. return fmt.Errorf("unknown Employee numeric field %s", name)
  5319. }
  5320. // ClearedFields returns all nullable fields that were cleared during this
  5321. // mutation.
  5322. func (m *EmployeeMutation) ClearedFields() []string {
  5323. var fields []string
  5324. if m.FieldCleared(employee.FieldDeletedAt) {
  5325. fields = append(fields, employee.FieldDeletedAt)
  5326. }
  5327. return fields
  5328. }
  5329. // FieldCleared returns a boolean indicating if a field with the given name was
  5330. // cleared in this mutation.
  5331. func (m *EmployeeMutation) FieldCleared(name string) bool {
  5332. _, ok := m.clearedFields[name]
  5333. return ok
  5334. }
  5335. // ClearField clears the value of the field with the given name. It returns an
  5336. // error if the field is not defined in the schema.
  5337. func (m *EmployeeMutation) ClearField(name string) error {
  5338. switch name {
  5339. case employee.FieldDeletedAt:
  5340. m.ClearDeletedAt()
  5341. return nil
  5342. }
  5343. return fmt.Errorf("unknown Employee nullable field %s", name)
  5344. }
  5345. // ResetField resets all changes in the mutation for the field with the given name.
  5346. // It returns an error if the field is not defined in the schema.
  5347. func (m *EmployeeMutation) ResetField(name string) error {
  5348. switch name {
  5349. case employee.FieldCreatedAt:
  5350. m.ResetCreatedAt()
  5351. return nil
  5352. case employee.FieldUpdatedAt:
  5353. m.ResetUpdatedAt()
  5354. return nil
  5355. case employee.FieldDeletedAt:
  5356. m.ResetDeletedAt()
  5357. return nil
  5358. case employee.FieldTitle:
  5359. m.ResetTitle()
  5360. return nil
  5361. case employee.FieldAvatar:
  5362. m.ResetAvatar()
  5363. return nil
  5364. case employee.FieldTags:
  5365. m.ResetTags()
  5366. return nil
  5367. case employee.FieldHireCount:
  5368. m.ResetHireCount()
  5369. return nil
  5370. case employee.FieldServiceCount:
  5371. m.ResetServiceCount()
  5372. return nil
  5373. case employee.FieldAchievementCount:
  5374. m.ResetAchievementCount()
  5375. return nil
  5376. case employee.FieldIntro:
  5377. m.ResetIntro()
  5378. return nil
  5379. case employee.FieldEstimate:
  5380. m.ResetEstimate()
  5381. return nil
  5382. case employee.FieldSkill:
  5383. m.ResetSkill()
  5384. return nil
  5385. case employee.FieldAbilityType:
  5386. m.ResetAbilityType()
  5387. return nil
  5388. case employee.FieldScene:
  5389. m.ResetScene()
  5390. return nil
  5391. case employee.FieldSwitchIn:
  5392. m.ResetSwitchIn()
  5393. return nil
  5394. case employee.FieldVideoURL:
  5395. m.ResetVideoURL()
  5396. return nil
  5397. case employee.FieldOrganizationID:
  5398. m.ResetOrganizationID()
  5399. return nil
  5400. }
  5401. return fmt.Errorf("unknown Employee field %s", name)
  5402. }
  5403. // AddedEdges returns all edge names that were set/added in this mutation.
  5404. func (m *EmployeeMutation) AddedEdges() []string {
  5405. edges := make([]string, 0, 2)
  5406. if m.em_work_experiences != nil {
  5407. edges = append(edges, employee.EdgeEmWorkExperiences)
  5408. }
  5409. if m.em_tutorial != nil {
  5410. edges = append(edges, employee.EdgeEmTutorial)
  5411. }
  5412. return edges
  5413. }
  5414. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5415. // name in this mutation.
  5416. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  5417. switch name {
  5418. case employee.EdgeEmWorkExperiences:
  5419. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  5420. for id := range m.em_work_experiences {
  5421. ids = append(ids, id)
  5422. }
  5423. return ids
  5424. case employee.EdgeEmTutorial:
  5425. ids := make([]ent.Value, 0, len(m.em_tutorial))
  5426. for id := range m.em_tutorial {
  5427. ids = append(ids, id)
  5428. }
  5429. return ids
  5430. }
  5431. return nil
  5432. }
  5433. // RemovedEdges returns all edge names that were removed in this mutation.
  5434. func (m *EmployeeMutation) RemovedEdges() []string {
  5435. edges := make([]string, 0, 2)
  5436. if m.removedem_work_experiences != nil {
  5437. edges = append(edges, employee.EdgeEmWorkExperiences)
  5438. }
  5439. if m.removedem_tutorial != nil {
  5440. edges = append(edges, employee.EdgeEmTutorial)
  5441. }
  5442. return edges
  5443. }
  5444. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5445. // the given name in this mutation.
  5446. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  5447. switch name {
  5448. case employee.EdgeEmWorkExperiences:
  5449. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  5450. for id := range m.removedem_work_experiences {
  5451. ids = append(ids, id)
  5452. }
  5453. return ids
  5454. case employee.EdgeEmTutorial:
  5455. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  5456. for id := range m.removedem_tutorial {
  5457. ids = append(ids, id)
  5458. }
  5459. return ids
  5460. }
  5461. return nil
  5462. }
  5463. // ClearedEdges returns all edge names that were cleared in this mutation.
  5464. func (m *EmployeeMutation) ClearedEdges() []string {
  5465. edges := make([]string, 0, 2)
  5466. if m.clearedem_work_experiences {
  5467. edges = append(edges, employee.EdgeEmWorkExperiences)
  5468. }
  5469. if m.clearedem_tutorial {
  5470. edges = append(edges, employee.EdgeEmTutorial)
  5471. }
  5472. return edges
  5473. }
  5474. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5475. // was cleared in this mutation.
  5476. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  5477. switch name {
  5478. case employee.EdgeEmWorkExperiences:
  5479. return m.clearedem_work_experiences
  5480. case employee.EdgeEmTutorial:
  5481. return m.clearedem_tutorial
  5482. }
  5483. return false
  5484. }
  5485. // ClearEdge clears the value of the edge with the given name. It returns an error
  5486. // if that edge is not defined in the schema.
  5487. func (m *EmployeeMutation) ClearEdge(name string) error {
  5488. switch name {
  5489. }
  5490. return fmt.Errorf("unknown Employee unique edge %s", name)
  5491. }
  5492. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5493. // It returns an error if the edge is not defined in the schema.
  5494. func (m *EmployeeMutation) ResetEdge(name string) error {
  5495. switch name {
  5496. case employee.EdgeEmWorkExperiences:
  5497. m.ResetEmWorkExperiences()
  5498. return nil
  5499. case employee.EdgeEmTutorial:
  5500. m.ResetEmTutorial()
  5501. return nil
  5502. }
  5503. return fmt.Errorf("unknown Employee edge %s", name)
  5504. }
  5505. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  5506. type LabelMutation struct {
  5507. config
  5508. op Op
  5509. typ string
  5510. id *uint64
  5511. created_at *time.Time
  5512. updated_at *time.Time
  5513. status *uint8
  5514. addstatus *int8
  5515. _type *int
  5516. add_type *int
  5517. name *string
  5518. from *int
  5519. addfrom *int
  5520. mode *int
  5521. addmode *int
  5522. conditions *string
  5523. organization_id *uint64
  5524. addorganization_id *int64
  5525. clearedFields map[string]struct{}
  5526. label_relationships map[uint64]struct{}
  5527. removedlabel_relationships map[uint64]struct{}
  5528. clearedlabel_relationships bool
  5529. done bool
  5530. oldValue func(context.Context) (*Label, error)
  5531. predicates []predicate.Label
  5532. }
  5533. var _ ent.Mutation = (*LabelMutation)(nil)
  5534. // labelOption allows management of the mutation configuration using functional options.
  5535. type labelOption func(*LabelMutation)
  5536. // newLabelMutation creates new mutation for the Label entity.
  5537. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  5538. m := &LabelMutation{
  5539. config: c,
  5540. op: op,
  5541. typ: TypeLabel,
  5542. clearedFields: make(map[string]struct{}),
  5543. }
  5544. for _, opt := range opts {
  5545. opt(m)
  5546. }
  5547. return m
  5548. }
  5549. // withLabelID sets the ID field of the mutation.
  5550. func withLabelID(id uint64) labelOption {
  5551. return func(m *LabelMutation) {
  5552. var (
  5553. err error
  5554. once sync.Once
  5555. value *Label
  5556. )
  5557. m.oldValue = func(ctx context.Context) (*Label, error) {
  5558. once.Do(func() {
  5559. if m.done {
  5560. err = errors.New("querying old values post mutation is not allowed")
  5561. } else {
  5562. value, err = m.Client().Label.Get(ctx, id)
  5563. }
  5564. })
  5565. return value, err
  5566. }
  5567. m.id = &id
  5568. }
  5569. }
  5570. // withLabel sets the old Label of the mutation.
  5571. func withLabel(node *Label) labelOption {
  5572. return func(m *LabelMutation) {
  5573. m.oldValue = func(context.Context) (*Label, error) {
  5574. return node, nil
  5575. }
  5576. m.id = &node.ID
  5577. }
  5578. }
  5579. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5580. // executed in a transaction (ent.Tx), a transactional client is returned.
  5581. func (m LabelMutation) Client() *Client {
  5582. client := &Client{config: m.config}
  5583. client.init()
  5584. return client
  5585. }
  5586. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5587. // it returns an error otherwise.
  5588. func (m LabelMutation) Tx() (*Tx, error) {
  5589. if _, ok := m.driver.(*txDriver); !ok {
  5590. return nil, errors.New("ent: mutation is not running in a transaction")
  5591. }
  5592. tx := &Tx{config: m.config}
  5593. tx.init()
  5594. return tx, nil
  5595. }
  5596. // SetID sets the value of the id field. Note that this
  5597. // operation is only accepted on creation of Label entities.
  5598. func (m *LabelMutation) SetID(id uint64) {
  5599. m.id = &id
  5600. }
  5601. // ID returns the ID value in the mutation. Note that the ID is only available
  5602. // if it was provided to the builder or after it was returned from the database.
  5603. func (m *LabelMutation) ID() (id uint64, exists bool) {
  5604. if m.id == nil {
  5605. return
  5606. }
  5607. return *m.id, true
  5608. }
  5609. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5610. // That means, if the mutation is applied within a transaction with an isolation level such
  5611. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5612. // or updated by the mutation.
  5613. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  5614. switch {
  5615. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5616. id, exists := m.ID()
  5617. if exists {
  5618. return []uint64{id}, nil
  5619. }
  5620. fallthrough
  5621. case m.op.Is(OpUpdate | OpDelete):
  5622. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  5623. default:
  5624. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5625. }
  5626. }
  5627. // SetCreatedAt sets the "created_at" field.
  5628. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  5629. m.created_at = &t
  5630. }
  5631. // CreatedAt returns the value of the "created_at" field in the mutation.
  5632. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  5633. v := m.created_at
  5634. if v == nil {
  5635. return
  5636. }
  5637. return *v, true
  5638. }
  5639. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  5640. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  5641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5642. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5643. if !m.op.Is(OpUpdateOne) {
  5644. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5645. }
  5646. if m.id == nil || m.oldValue == nil {
  5647. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5648. }
  5649. oldValue, err := m.oldValue(ctx)
  5650. if err != nil {
  5651. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5652. }
  5653. return oldValue.CreatedAt, nil
  5654. }
  5655. // ResetCreatedAt resets all changes to the "created_at" field.
  5656. func (m *LabelMutation) ResetCreatedAt() {
  5657. m.created_at = nil
  5658. }
  5659. // SetUpdatedAt sets the "updated_at" field.
  5660. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  5661. m.updated_at = &t
  5662. }
  5663. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5664. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  5665. v := m.updated_at
  5666. if v == nil {
  5667. return
  5668. }
  5669. return *v, true
  5670. }
  5671. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  5672. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  5673. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5674. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5675. if !m.op.Is(OpUpdateOne) {
  5676. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5677. }
  5678. if m.id == nil || m.oldValue == nil {
  5679. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5680. }
  5681. oldValue, err := m.oldValue(ctx)
  5682. if err != nil {
  5683. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5684. }
  5685. return oldValue.UpdatedAt, nil
  5686. }
  5687. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5688. func (m *LabelMutation) ResetUpdatedAt() {
  5689. m.updated_at = nil
  5690. }
  5691. // SetStatus sets the "status" field.
  5692. func (m *LabelMutation) SetStatus(u uint8) {
  5693. m.status = &u
  5694. m.addstatus = nil
  5695. }
  5696. // Status returns the value of the "status" field in the mutation.
  5697. func (m *LabelMutation) Status() (r uint8, exists bool) {
  5698. v := m.status
  5699. if v == nil {
  5700. return
  5701. }
  5702. return *v, true
  5703. }
  5704. // OldStatus returns the old "status" field's value of the Label entity.
  5705. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  5706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5707. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5708. if !m.op.Is(OpUpdateOne) {
  5709. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5710. }
  5711. if m.id == nil || m.oldValue == nil {
  5712. return v, errors.New("OldStatus requires an ID field in the mutation")
  5713. }
  5714. oldValue, err := m.oldValue(ctx)
  5715. if err != nil {
  5716. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5717. }
  5718. return oldValue.Status, nil
  5719. }
  5720. // AddStatus adds u to the "status" field.
  5721. func (m *LabelMutation) AddStatus(u int8) {
  5722. if m.addstatus != nil {
  5723. *m.addstatus += u
  5724. } else {
  5725. m.addstatus = &u
  5726. }
  5727. }
  5728. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5729. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  5730. v := m.addstatus
  5731. if v == nil {
  5732. return
  5733. }
  5734. return *v, true
  5735. }
  5736. // ClearStatus clears the value of the "status" field.
  5737. func (m *LabelMutation) ClearStatus() {
  5738. m.status = nil
  5739. m.addstatus = nil
  5740. m.clearedFields[label.FieldStatus] = struct{}{}
  5741. }
  5742. // StatusCleared returns if the "status" field was cleared in this mutation.
  5743. func (m *LabelMutation) StatusCleared() bool {
  5744. _, ok := m.clearedFields[label.FieldStatus]
  5745. return ok
  5746. }
  5747. // ResetStatus resets all changes to the "status" field.
  5748. func (m *LabelMutation) ResetStatus() {
  5749. m.status = nil
  5750. m.addstatus = nil
  5751. delete(m.clearedFields, label.FieldStatus)
  5752. }
  5753. // SetType sets the "type" field.
  5754. func (m *LabelMutation) SetType(i int) {
  5755. m._type = &i
  5756. m.add_type = nil
  5757. }
  5758. // GetType returns the value of the "type" field in the mutation.
  5759. func (m *LabelMutation) GetType() (r int, exists bool) {
  5760. v := m._type
  5761. if v == nil {
  5762. return
  5763. }
  5764. return *v, true
  5765. }
  5766. // OldType returns the old "type" field's value of the Label entity.
  5767. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  5768. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5769. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  5770. if !m.op.Is(OpUpdateOne) {
  5771. return v, errors.New("OldType is only allowed on UpdateOne operations")
  5772. }
  5773. if m.id == nil || m.oldValue == nil {
  5774. return v, errors.New("OldType requires an ID field in the mutation")
  5775. }
  5776. oldValue, err := m.oldValue(ctx)
  5777. if err != nil {
  5778. return v, fmt.Errorf("querying old value for OldType: %w", err)
  5779. }
  5780. return oldValue.Type, nil
  5781. }
  5782. // AddType adds i to the "type" field.
  5783. func (m *LabelMutation) AddType(i int) {
  5784. if m.add_type != nil {
  5785. *m.add_type += i
  5786. } else {
  5787. m.add_type = &i
  5788. }
  5789. }
  5790. // AddedType returns the value that was added to the "type" field in this mutation.
  5791. func (m *LabelMutation) AddedType() (r int, exists bool) {
  5792. v := m.add_type
  5793. if v == nil {
  5794. return
  5795. }
  5796. return *v, true
  5797. }
  5798. // ResetType resets all changes to the "type" field.
  5799. func (m *LabelMutation) ResetType() {
  5800. m._type = nil
  5801. m.add_type = nil
  5802. }
  5803. // SetName sets the "name" field.
  5804. func (m *LabelMutation) SetName(s string) {
  5805. m.name = &s
  5806. }
  5807. // Name returns the value of the "name" field in the mutation.
  5808. func (m *LabelMutation) Name() (r string, exists bool) {
  5809. v := m.name
  5810. if v == nil {
  5811. return
  5812. }
  5813. return *v, true
  5814. }
  5815. // OldName returns the old "name" field's value of the Label entity.
  5816. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  5817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5818. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  5819. if !m.op.Is(OpUpdateOne) {
  5820. return v, errors.New("OldName is only allowed on UpdateOne operations")
  5821. }
  5822. if m.id == nil || m.oldValue == nil {
  5823. return v, errors.New("OldName requires an ID field in the mutation")
  5824. }
  5825. oldValue, err := m.oldValue(ctx)
  5826. if err != nil {
  5827. return v, fmt.Errorf("querying old value for OldName: %w", err)
  5828. }
  5829. return oldValue.Name, nil
  5830. }
  5831. // ResetName resets all changes to the "name" field.
  5832. func (m *LabelMutation) ResetName() {
  5833. m.name = nil
  5834. }
  5835. // SetFrom sets the "from" field.
  5836. func (m *LabelMutation) SetFrom(i int) {
  5837. m.from = &i
  5838. m.addfrom = nil
  5839. }
  5840. // From returns the value of the "from" field in the mutation.
  5841. func (m *LabelMutation) From() (r int, exists bool) {
  5842. v := m.from
  5843. if v == nil {
  5844. return
  5845. }
  5846. return *v, true
  5847. }
  5848. // OldFrom returns the old "from" field's value of the Label entity.
  5849. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  5850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5851. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  5852. if !m.op.Is(OpUpdateOne) {
  5853. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  5854. }
  5855. if m.id == nil || m.oldValue == nil {
  5856. return v, errors.New("OldFrom requires an ID field in the mutation")
  5857. }
  5858. oldValue, err := m.oldValue(ctx)
  5859. if err != nil {
  5860. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  5861. }
  5862. return oldValue.From, nil
  5863. }
  5864. // AddFrom adds i to the "from" field.
  5865. func (m *LabelMutation) AddFrom(i int) {
  5866. if m.addfrom != nil {
  5867. *m.addfrom += i
  5868. } else {
  5869. m.addfrom = &i
  5870. }
  5871. }
  5872. // AddedFrom returns the value that was added to the "from" field in this mutation.
  5873. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  5874. v := m.addfrom
  5875. if v == nil {
  5876. return
  5877. }
  5878. return *v, true
  5879. }
  5880. // ResetFrom resets all changes to the "from" field.
  5881. func (m *LabelMutation) ResetFrom() {
  5882. m.from = nil
  5883. m.addfrom = nil
  5884. }
  5885. // SetMode sets the "mode" field.
  5886. func (m *LabelMutation) SetMode(i int) {
  5887. m.mode = &i
  5888. m.addmode = nil
  5889. }
  5890. // Mode returns the value of the "mode" field in the mutation.
  5891. func (m *LabelMutation) Mode() (r int, exists bool) {
  5892. v := m.mode
  5893. if v == nil {
  5894. return
  5895. }
  5896. return *v, true
  5897. }
  5898. // OldMode returns the old "mode" field's value of the Label entity.
  5899. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  5900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5901. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  5902. if !m.op.Is(OpUpdateOne) {
  5903. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  5904. }
  5905. if m.id == nil || m.oldValue == nil {
  5906. return v, errors.New("OldMode requires an ID field in the mutation")
  5907. }
  5908. oldValue, err := m.oldValue(ctx)
  5909. if err != nil {
  5910. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  5911. }
  5912. return oldValue.Mode, nil
  5913. }
  5914. // AddMode adds i to the "mode" field.
  5915. func (m *LabelMutation) AddMode(i int) {
  5916. if m.addmode != nil {
  5917. *m.addmode += i
  5918. } else {
  5919. m.addmode = &i
  5920. }
  5921. }
  5922. // AddedMode returns the value that was added to the "mode" field in this mutation.
  5923. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  5924. v := m.addmode
  5925. if v == nil {
  5926. return
  5927. }
  5928. return *v, true
  5929. }
  5930. // ResetMode resets all changes to the "mode" field.
  5931. func (m *LabelMutation) ResetMode() {
  5932. m.mode = nil
  5933. m.addmode = nil
  5934. }
  5935. // SetConditions sets the "conditions" field.
  5936. func (m *LabelMutation) SetConditions(s string) {
  5937. m.conditions = &s
  5938. }
  5939. // Conditions returns the value of the "conditions" field in the mutation.
  5940. func (m *LabelMutation) Conditions() (r string, exists bool) {
  5941. v := m.conditions
  5942. if v == nil {
  5943. return
  5944. }
  5945. return *v, true
  5946. }
  5947. // OldConditions returns the old "conditions" field's value of the Label entity.
  5948. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  5949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5950. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  5951. if !m.op.Is(OpUpdateOne) {
  5952. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  5953. }
  5954. if m.id == nil || m.oldValue == nil {
  5955. return v, errors.New("OldConditions requires an ID field in the mutation")
  5956. }
  5957. oldValue, err := m.oldValue(ctx)
  5958. if err != nil {
  5959. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  5960. }
  5961. return oldValue.Conditions, nil
  5962. }
  5963. // ClearConditions clears the value of the "conditions" field.
  5964. func (m *LabelMutation) ClearConditions() {
  5965. m.conditions = nil
  5966. m.clearedFields[label.FieldConditions] = struct{}{}
  5967. }
  5968. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  5969. func (m *LabelMutation) ConditionsCleared() bool {
  5970. _, ok := m.clearedFields[label.FieldConditions]
  5971. return ok
  5972. }
  5973. // ResetConditions resets all changes to the "conditions" field.
  5974. func (m *LabelMutation) ResetConditions() {
  5975. m.conditions = nil
  5976. delete(m.clearedFields, label.FieldConditions)
  5977. }
  5978. // SetOrganizationID sets the "organization_id" field.
  5979. func (m *LabelMutation) SetOrganizationID(u uint64) {
  5980. m.organization_id = &u
  5981. m.addorganization_id = nil
  5982. }
  5983. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5984. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  5985. v := m.organization_id
  5986. if v == nil {
  5987. return
  5988. }
  5989. return *v, true
  5990. }
  5991. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  5992. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  5993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5994. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5995. if !m.op.Is(OpUpdateOne) {
  5996. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5997. }
  5998. if m.id == nil || m.oldValue == nil {
  5999. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6000. }
  6001. oldValue, err := m.oldValue(ctx)
  6002. if err != nil {
  6003. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6004. }
  6005. return oldValue.OrganizationID, nil
  6006. }
  6007. // AddOrganizationID adds u to the "organization_id" field.
  6008. func (m *LabelMutation) AddOrganizationID(u int64) {
  6009. if m.addorganization_id != nil {
  6010. *m.addorganization_id += u
  6011. } else {
  6012. m.addorganization_id = &u
  6013. }
  6014. }
  6015. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6016. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  6017. v := m.addorganization_id
  6018. if v == nil {
  6019. return
  6020. }
  6021. return *v, true
  6022. }
  6023. // ClearOrganizationID clears the value of the "organization_id" field.
  6024. func (m *LabelMutation) ClearOrganizationID() {
  6025. m.organization_id = nil
  6026. m.addorganization_id = nil
  6027. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  6028. }
  6029. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  6030. func (m *LabelMutation) OrganizationIDCleared() bool {
  6031. _, ok := m.clearedFields[label.FieldOrganizationID]
  6032. return ok
  6033. }
  6034. // ResetOrganizationID resets all changes to the "organization_id" field.
  6035. func (m *LabelMutation) ResetOrganizationID() {
  6036. m.organization_id = nil
  6037. m.addorganization_id = nil
  6038. delete(m.clearedFields, label.FieldOrganizationID)
  6039. }
  6040. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  6041. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  6042. if m.label_relationships == nil {
  6043. m.label_relationships = make(map[uint64]struct{})
  6044. }
  6045. for i := range ids {
  6046. m.label_relationships[ids[i]] = struct{}{}
  6047. }
  6048. }
  6049. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  6050. func (m *LabelMutation) ClearLabelRelationships() {
  6051. m.clearedlabel_relationships = true
  6052. }
  6053. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  6054. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  6055. return m.clearedlabel_relationships
  6056. }
  6057. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  6058. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  6059. if m.removedlabel_relationships == nil {
  6060. m.removedlabel_relationships = make(map[uint64]struct{})
  6061. }
  6062. for i := range ids {
  6063. delete(m.label_relationships, ids[i])
  6064. m.removedlabel_relationships[ids[i]] = struct{}{}
  6065. }
  6066. }
  6067. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  6068. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  6069. for id := range m.removedlabel_relationships {
  6070. ids = append(ids, id)
  6071. }
  6072. return
  6073. }
  6074. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  6075. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  6076. for id := range m.label_relationships {
  6077. ids = append(ids, id)
  6078. }
  6079. return
  6080. }
  6081. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  6082. func (m *LabelMutation) ResetLabelRelationships() {
  6083. m.label_relationships = nil
  6084. m.clearedlabel_relationships = false
  6085. m.removedlabel_relationships = nil
  6086. }
  6087. // Where appends a list predicates to the LabelMutation builder.
  6088. func (m *LabelMutation) Where(ps ...predicate.Label) {
  6089. m.predicates = append(m.predicates, ps...)
  6090. }
  6091. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  6092. // users can use type-assertion to append predicates that do not depend on any generated package.
  6093. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  6094. p := make([]predicate.Label, len(ps))
  6095. for i := range ps {
  6096. p[i] = ps[i]
  6097. }
  6098. m.Where(p...)
  6099. }
  6100. // Op returns the operation name.
  6101. func (m *LabelMutation) Op() Op {
  6102. return m.op
  6103. }
  6104. // SetOp allows setting the mutation operation.
  6105. func (m *LabelMutation) SetOp(op Op) {
  6106. m.op = op
  6107. }
  6108. // Type returns the node type of this mutation (Label).
  6109. func (m *LabelMutation) Type() string {
  6110. return m.typ
  6111. }
  6112. // Fields returns all fields that were changed during this mutation. Note that in
  6113. // order to get all numeric fields that were incremented/decremented, call
  6114. // AddedFields().
  6115. func (m *LabelMutation) Fields() []string {
  6116. fields := make([]string, 0, 9)
  6117. if m.created_at != nil {
  6118. fields = append(fields, label.FieldCreatedAt)
  6119. }
  6120. if m.updated_at != nil {
  6121. fields = append(fields, label.FieldUpdatedAt)
  6122. }
  6123. if m.status != nil {
  6124. fields = append(fields, label.FieldStatus)
  6125. }
  6126. if m._type != nil {
  6127. fields = append(fields, label.FieldType)
  6128. }
  6129. if m.name != nil {
  6130. fields = append(fields, label.FieldName)
  6131. }
  6132. if m.from != nil {
  6133. fields = append(fields, label.FieldFrom)
  6134. }
  6135. if m.mode != nil {
  6136. fields = append(fields, label.FieldMode)
  6137. }
  6138. if m.conditions != nil {
  6139. fields = append(fields, label.FieldConditions)
  6140. }
  6141. if m.organization_id != nil {
  6142. fields = append(fields, label.FieldOrganizationID)
  6143. }
  6144. return fields
  6145. }
  6146. // Field returns the value of a field with the given name. The second boolean
  6147. // return value indicates that this field was not set, or was not defined in the
  6148. // schema.
  6149. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  6150. switch name {
  6151. case label.FieldCreatedAt:
  6152. return m.CreatedAt()
  6153. case label.FieldUpdatedAt:
  6154. return m.UpdatedAt()
  6155. case label.FieldStatus:
  6156. return m.Status()
  6157. case label.FieldType:
  6158. return m.GetType()
  6159. case label.FieldName:
  6160. return m.Name()
  6161. case label.FieldFrom:
  6162. return m.From()
  6163. case label.FieldMode:
  6164. return m.Mode()
  6165. case label.FieldConditions:
  6166. return m.Conditions()
  6167. case label.FieldOrganizationID:
  6168. return m.OrganizationID()
  6169. }
  6170. return nil, false
  6171. }
  6172. // OldField returns the old value of the field from the database. An error is
  6173. // returned if the mutation operation is not UpdateOne, or the query to the
  6174. // database failed.
  6175. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6176. switch name {
  6177. case label.FieldCreatedAt:
  6178. return m.OldCreatedAt(ctx)
  6179. case label.FieldUpdatedAt:
  6180. return m.OldUpdatedAt(ctx)
  6181. case label.FieldStatus:
  6182. return m.OldStatus(ctx)
  6183. case label.FieldType:
  6184. return m.OldType(ctx)
  6185. case label.FieldName:
  6186. return m.OldName(ctx)
  6187. case label.FieldFrom:
  6188. return m.OldFrom(ctx)
  6189. case label.FieldMode:
  6190. return m.OldMode(ctx)
  6191. case label.FieldConditions:
  6192. return m.OldConditions(ctx)
  6193. case label.FieldOrganizationID:
  6194. return m.OldOrganizationID(ctx)
  6195. }
  6196. return nil, fmt.Errorf("unknown Label field %s", name)
  6197. }
  6198. // SetField sets the value of a field with the given name. It returns an error if
  6199. // the field is not defined in the schema, or if the type mismatched the field
  6200. // type.
  6201. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  6202. switch name {
  6203. case label.FieldCreatedAt:
  6204. v, ok := value.(time.Time)
  6205. if !ok {
  6206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6207. }
  6208. m.SetCreatedAt(v)
  6209. return nil
  6210. case label.FieldUpdatedAt:
  6211. v, ok := value.(time.Time)
  6212. if !ok {
  6213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6214. }
  6215. m.SetUpdatedAt(v)
  6216. return nil
  6217. case label.FieldStatus:
  6218. v, ok := value.(uint8)
  6219. if !ok {
  6220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6221. }
  6222. m.SetStatus(v)
  6223. return nil
  6224. case label.FieldType:
  6225. v, ok := value.(int)
  6226. if !ok {
  6227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6228. }
  6229. m.SetType(v)
  6230. return nil
  6231. case label.FieldName:
  6232. v, ok := value.(string)
  6233. if !ok {
  6234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6235. }
  6236. m.SetName(v)
  6237. return nil
  6238. case label.FieldFrom:
  6239. v, ok := value.(int)
  6240. if !ok {
  6241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6242. }
  6243. m.SetFrom(v)
  6244. return nil
  6245. case label.FieldMode:
  6246. v, ok := value.(int)
  6247. if !ok {
  6248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6249. }
  6250. m.SetMode(v)
  6251. return nil
  6252. case label.FieldConditions:
  6253. v, ok := value.(string)
  6254. if !ok {
  6255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6256. }
  6257. m.SetConditions(v)
  6258. return nil
  6259. case label.FieldOrganizationID:
  6260. v, ok := value.(uint64)
  6261. if !ok {
  6262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6263. }
  6264. m.SetOrganizationID(v)
  6265. return nil
  6266. }
  6267. return fmt.Errorf("unknown Label field %s", name)
  6268. }
  6269. // AddedFields returns all numeric fields that were incremented/decremented during
  6270. // this mutation.
  6271. func (m *LabelMutation) AddedFields() []string {
  6272. var fields []string
  6273. if m.addstatus != nil {
  6274. fields = append(fields, label.FieldStatus)
  6275. }
  6276. if m.add_type != nil {
  6277. fields = append(fields, label.FieldType)
  6278. }
  6279. if m.addfrom != nil {
  6280. fields = append(fields, label.FieldFrom)
  6281. }
  6282. if m.addmode != nil {
  6283. fields = append(fields, label.FieldMode)
  6284. }
  6285. if m.addorganization_id != nil {
  6286. fields = append(fields, label.FieldOrganizationID)
  6287. }
  6288. return fields
  6289. }
  6290. // AddedField returns the numeric value that was incremented/decremented on a field
  6291. // with the given name. The second boolean return value indicates that this field
  6292. // was not set, or was not defined in the schema.
  6293. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  6294. switch name {
  6295. case label.FieldStatus:
  6296. return m.AddedStatus()
  6297. case label.FieldType:
  6298. return m.AddedType()
  6299. case label.FieldFrom:
  6300. return m.AddedFrom()
  6301. case label.FieldMode:
  6302. return m.AddedMode()
  6303. case label.FieldOrganizationID:
  6304. return m.AddedOrganizationID()
  6305. }
  6306. return nil, false
  6307. }
  6308. // AddField adds the value to the field with the given name. It returns an error if
  6309. // the field is not defined in the schema, or if the type mismatched the field
  6310. // type.
  6311. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  6312. switch name {
  6313. case label.FieldStatus:
  6314. v, ok := value.(int8)
  6315. if !ok {
  6316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6317. }
  6318. m.AddStatus(v)
  6319. return nil
  6320. case label.FieldType:
  6321. v, ok := value.(int)
  6322. if !ok {
  6323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6324. }
  6325. m.AddType(v)
  6326. return nil
  6327. case label.FieldFrom:
  6328. v, ok := value.(int)
  6329. if !ok {
  6330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6331. }
  6332. m.AddFrom(v)
  6333. return nil
  6334. case label.FieldMode:
  6335. v, ok := value.(int)
  6336. if !ok {
  6337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6338. }
  6339. m.AddMode(v)
  6340. return nil
  6341. case label.FieldOrganizationID:
  6342. v, ok := value.(int64)
  6343. if !ok {
  6344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6345. }
  6346. m.AddOrganizationID(v)
  6347. return nil
  6348. }
  6349. return fmt.Errorf("unknown Label numeric field %s", name)
  6350. }
  6351. // ClearedFields returns all nullable fields that were cleared during this
  6352. // mutation.
  6353. func (m *LabelMutation) ClearedFields() []string {
  6354. var fields []string
  6355. if m.FieldCleared(label.FieldStatus) {
  6356. fields = append(fields, label.FieldStatus)
  6357. }
  6358. if m.FieldCleared(label.FieldConditions) {
  6359. fields = append(fields, label.FieldConditions)
  6360. }
  6361. if m.FieldCleared(label.FieldOrganizationID) {
  6362. fields = append(fields, label.FieldOrganizationID)
  6363. }
  6364. return fields
  6365. }
  6366. // FieldCleared returns a boolean indicating if a field with the given name was
  6367. // cleared in this mutation.
  6368. func (m *LabelMutation) FieldCleared(name string) bool {
  6369. _, ok := m.clearedFields[name]
  6370. return ok
  6371. }
  6372. // ClearField clears the value of the field with the given name. It returns an
  6373. // error if the field is not defined in the schema.
  6374. func (m *LabelMutation) ClearField(name string) error {
  6375. switch name {
  6376. case label.FieldStatus:
  6377. m.ClearStatus()
  6378. return nil
  6379. case label.FieldConditions:
  6380. m.ClearConditions()
  6381. return nil
  6382. case label.FieldOrganizationID:
  6383. m.ClearOrganizationID()
  6384. return nil
  6385. }
  6386. return fmt.Errorf("unknown Label nullable field %s", name)
  6387. }
  6388. // ResetField resets all changes in the mutation for the field with the given name.
  6389. // It returns an error if the field is not defined in the schema.
  6390. func (m *LabelMutation) ResetField(name string) error {
  6391. switch name {
  6392. case label.FieldCreatedAt:
  6393. m.ResetCreatedAt()
  6394. return nil
  6395. case label.FieldUpdatedAt:
  6396. m.ResetUpdatedAt()
  6397. return nil
  6398. case label.FieldStatus:
  6399. m.ResetStatus()
  6400. return nil
  6401. case label.FieldType:
  6402. m.ResetType()
  6403. return nil
  6404. case label.FieldName:
  6405. m.ResetName()
  6406. return nil
  6407. case label.FieldFrom:
  6408. m.ResetFrom()
  6409. return nil
  6410. case label.FieldMode:
  6411. m.ResetMode()
  6412. return nil
  6413. case label.FieldConditions:
  6414. m.ResetConditions()
  6415. return nil
  6416. case label.FieldOrganizationID:
  6417. m.ResetOrganizationID()
  6418. return nil
  6419. }
  6420. return fmt.Errorf("unknown Label field %s", name)
  6421. }
  6422. // AddedEdges returns all edge names that were set/added in this mutation.
  6423. func (m *LabelMutation) AddedEdges() []string {
  6424. edges := make([]string, 0, 1)
  6425. if m.label_relationships != nil {
  6426. edges = append(edges, label.EdgeLabelRelationships)
  6427. }
  6428. return edges
  6429. }
  6430. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6431. // name in this mutation.
  6432. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  6433. switch name {
  6434. case label.EdgeLabelRelationships:
  6435. ids := make([]ent.Value, 0, len(m.label_relationships))
  6436. for id := range m.label_relationships {
  6437. ids = append(ids, id)
  6438. }
  6439. return ids
  6440. }
  6441. return nil
  6442. }
  6443. // RemovedEdges returns all edge names that were removed in this mutation.
  6444. func (m *LabelMutation) RemovedEdges() []string {
  6445. edges := make([]string, 0, 1)
  6446. if m.removedlabel_relationships != nil {
  6447. edges = append(edges, label.EdgeLabelRelationships)
  6448. }
  6449. return edges
  6450. }
  6451. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6452. // the given name in this mutation.
  6453. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  6454. switch name {
  6455. case label.EdgeLabelRelationships:
  6456. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  6457. for id := range m.removedlabel_relationships {
  6458. ids = append(ids, id)
  6459. }
  6460. return ids
  6461. }
  6462. return nil
  6463. }
  6464. // ClearedEdges returns all edge names that were cleared in this mutation.
  6465. func (m *LabelMutation) ClearedEdges() []string {
  6466. edges := make([]string, 0, 1)
  6467. if m.clearedlabel_relationships {
  6468. edges = append(edges, label.EdgeLabelRelationships)
  6469. }
  6470. return edges
  6471. }
  6472. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6473. // was cleared in this mutation.
  6474. func (m *LabelMutation) EdgeCleared(name string) bool {
  6475. switch name {
  6476. case label.EdgeLabelRelationships:
  6477. return m.clearedlabel_relationships
  6478. }
  6479. return false
  6480. }
  6481. // ClearEdge clears the value of the edge with the given name. It returns an error
  6482. // if that edge is not defined in the schema.
  6483. func (m *LabelMutation) ClearEdge(name string) error {
  6484. switch name {
  6485. }
  6486. return fmt.Errorf("unknown Label unique edge %s", name)
  6487. }
  6488. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6489. // It returns an error if the edge is not defined in the schema.
  6490. func (m *LabelMutation) ResetEdge(name string) error {
  6491. switch name {
  6492. case label.EdgeLabelRelationships:
  6493. m.ResetLabelRelationships()
  6494. return nil
  6495. }
  6496. return fmt.Errorf("unknown Label edge %s", name)
  6497. }
  6498. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  6499. type LabelRelationshipMutation struct {
  6500. config
  6501. op Op
  6502. typ string
  6503. id *uint64
  6504. created_at *time.Time
  6505. updated_at *time.Time
  6506. status *uint8
  6507. addstatus *int8
  6508. deleted_at *time.Time
  6509. organization_id *uint64
  6510. addorganization_id *int64
  6511. clearedFields map[string]struct{}
  6512. contacts *uint64
  6513. clearedcontacts bool
  6514. labels *uint64
  6515. clearedlabels bool
  6516. done bool
  6517. oldValue func(context.Context) (*LabelRelationship, error)
  6518. predicates []predicate.LabelRelationship
  6519. }
  6520. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  6521. // labelrelationshipOption allows management of the mutation configuration using functional options.
  6522. type labelrelationshipOption func(*LabelRelationshipMutation)
  6523. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  6524. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  6525. m := &LabelRelationshipMutation{
  6526. config: c,
  6527. op: op,
  6528. typ: TypeLabelRelationship,
  6529. clearedFields: make(map[string]struct{}),
  6530. }
  6531. for _, opt := range opts {
  6532. opt(m)
  6533. }
  6534. return m
  6535. }
  6536. // withLabelRelationshipID sets the ID field of the mutation.
  6537. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  6538. return func(m *LabelRelationshipMutation) {
  6539. var (
  6540. err error
  6541. once sync.Once
  6542. value *LabelRelationship
  6543. )
  6544. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  6545. once.Do(func() {
  6546. if m.done {
  6547. err = errors.New("querying old values post mutation is not allowed")
  6548. } else {
  6549. value, err = m.Client().LabelRelationship.Get(ctx, id)
  6550. }
  6551. })
  6552. return value, err
  6553. }
  6554. m.id = &id
  6555. }
  6556. }
  6557. // withLabelRelationship sets the old LabelRelationship of the mutation.
  6558. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  6559. return func(m *LabelRelationshipMutation) {
  6560. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  6561. return node, nil
  6562. }
  6563. m.id = &node.ID
  6564. }
  6565. }
  6566. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6567. // executed in a transaction (ent.Tx), a transactional client is returned.
  6568. func (m LabelRelationshipMutation) Client() *Client {
  6569. client := &Client{config: m.config}
  6570. client.init()
  6571. return client
  6572. }
  6573. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6574. // it returns an error otherwise.
  6575. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  6576. if _, ok := m.driver.(*txDriver); !ok {
  6577. return nil, errors.New("ent: mutation is not running in a transaction")
  6578. }
  6579. tx := &Tx{config: m.config}
  6580. tx.init()
  6581. return tx, nil
  6582. }
  6583. // SetID sets the value of the id field. Note that this
  6584. // operation is only accepted on creation of LabelRelationship entities.
  6585. func (m *LabelRelationshipMutation) SetID(id uint64) {
  6586. m.id = &id
  6587. }
  6588. // ID returns the ID value in the mutation. Note that the ID is only available
  6589. // if it was provided to the builder or after it was returned from the database.
  6590. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  6591. if m.id == nil {
  6592. return
  6593. }
  6594. return *m.id, true
  6595. }
  6596. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6597. // That means, if the mutation is applied within a transaction with an isolation level such
  6598. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6599. // or updated by the mutation.
  6600. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  6601. switch {
  6602. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6603. id, exists := m.ID()
  6604. if exists {
  6605. return []uint64{id}, nil
  6606. }
  6607. fallthrough
  6608. case m.op.Is(OpUpdate | OpDelete):
  6609. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  6610. default:
  6611. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6612. }
  6613. }
  6614. // SetCreatedAt sets the "created_at" field.
  6615. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  6616. m.created_at = &t
  6617. }
  6618. // CreatedAt returns the value of the "created_at" field in the mutation.
  6619. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  6620. v := m.created_at
  6621. if v == nil {
  6622. return
  6623. }
  6624. return *v, true
  6625. }
  6626. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  6627. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  6628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6629. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6630. if !m.op.Is(OpUpdateOne) {
  6631. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6632. }
  6633. if m.id == nil || m.oldValue == nil {
  6634. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6635. }
  6636. oldValue, err := m.oldValue(ctx)
  6637. if err != nil {
  6638. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6639. }
  6640. return oldValue.CreatedAt, nil
  6641. }
  6642. // ResetCreatedAt resets all changes to the "created_at" field.
  6643. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  6644. m.created_at = nil
  6645. }
  6646. // SetUpdatedAt sets the "updated_at" field.
  6647. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  6648. m.updated_at = &t
  6649. }
  6650. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6651. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  6652. v := m.updated_at
  6653. if v == nil {
  6654. return
  6655. }
  6656. return *v, true
  6657. }
  6658. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  6659. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  6660. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6661. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6662. if !m.op.Is(OpUpdateOne) {
  6663. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6664. }
  6665. if m.id == nil || m.oldValue == nil {
  6666. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6667. }
  6668. oldValue, err := m.oldValue(ctx)
  6669. if err != nil {
  6670. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6671. }
  6672. return oldValue.UpdatedAt, nil
  6673. }
  6674. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6675. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  6676. m.updated_at = nil
  6677. }
  6678. // SetStatus sets the "status" field.
  6679. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  6680. m.status = &u
  6681. m.addstatus = nil
  6682. }
  6683. // Status returns the value of the "status" field in the mutation.
  6684. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  6685. v := m.status
  6686. if v == nil {
  6687. return
  6688. }
  6689. return *v, true
  6690. }
  6691. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  6692. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  6693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6694. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  6695. if !m.op.Is(OpUpdateOne) {
  6696. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  6697. }
  6698. if m.id == nil || m.oldValue == nil {
  6699. return v, errors.New("OldStatus requires an ID field in the mutation")
  6700. }
  6701. oldValue, err := m.oldValue(ctx)
  6702. if err != nil {
  6703. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  6704. }
  6705. return oldValue.Status, nil
  6706. }
  6707. // AddStatus adds u to the "status" field.
  6708. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  6709. if m.addstatus != nil {
  6710. *m.addstatus += u
  6711. } else {
  6712. m.addstatus = &u
  6713. }
  6714. }
  6715. // AddedStatus returns the value that was added to the "status" field in this mutation.
  6716. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  6717. v := m.addstatus
  6718. if v == nil {
  6719. return
  6720. }
  6721. return *v, true
  6722. }
  6723. // ClearStatus clears the value of the "status" field.
  6724. func (m *LabelRelationshipMutation) ClearStatus() {
  6725. m.status = nil
  6726. m.addstatus = nil
  6727. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  6728. }
  6729. // StatusCleared returns if the "status" field was cleared in this mutation.
  6730. func (m *LabelRelationshipMutation) StatusCleared() bool {
  6731. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  6732. return ok
  6733. }
  6734. // ResetStatus resets all changes to the "status" field.
  6735. func (m *LabelRelationshipMutation) ResetStatus() {
  6736. m.status = nil
  6737. m.addstatus = nil
  6738. delete(m.clearedFields, labelrelationship.FieldStatus)
  6739. }
  6740. // SetDeletedAt sets the "deleted_at" field.
  6741. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  6742. m.deleted_at = &t
  6743. }
  6744. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6745. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  6746. v := m.deleted_at
  6747. if v == nil {
  6748. return
  6749. }
  6750. return *v, true
  6751. }
  6752. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  6753. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  6754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6755. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6756. if !m.op.Is(OpUpdateOne) {
  6757. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6758. }
  6759. if m.id == nil || m.oldValue == nil {
  6760. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6761. }
  6762. oldValue, err := m.oldValue(ctx)
  6763. if err != nil {
  6764. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6765. }
  6766. return oldValue.DeletedAt, nil
  6767. }
  6768. // ClearDeletedAt clears the value of the "deleted_at" field.
  6769. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  6770. m.deleted_at = nil
  6771. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  6772. }
  6773. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6774. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  6775. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  6776. return ok
  6777. }
  6778. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6779. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  6780. m.deleted_at = nil
  6781. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  6782. }
  6783. // SetLabelID sets the "label_id" field.
  6784. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  6785. m.labels = &u
  6786. }
  6787. // LabelID returns the value of the "label_id" field in the mutation.
  6788. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  6789. v := m.labels
  6790. if v == nil {
  6791. return
  6792. }
  6793. return *v, true
  6794. }
  6795. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  6796. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  6797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6798. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  6799. if !m.op.Is(OpUpdateOne) {
  6800. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  6801. }
  6802. if m.id == nil || m.oldValue == nil {
  6803. return v, errors.New("OldLabelID requires an ID field in the mutation")
  6804. }
  6805. oldValue, err := m.oldValue(ctx)
  6806. if err != nil {
  6807. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  6808. }
  6809. return oldValue.LabelID, nil
  6810. }
  6811. // ResetLabelID resets all changes to the "label_id" field.
  6812. func (m *LabelRelationshipMutation) ResetLabelID() {
  6813. m.labels = nil
  6814. }
  6815. // SetContactID sets the "contact_id" field.
  6816. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  6817. m.contacts = &u
  6818. }
  6819. // ContactID returns the value of the "contact_id" field in the mutation.
  6820. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  6821. v := m.contacts
  6822. if v == nil {
  6823. return
  6824. }
  6825. return *v, true
  6826. }
  6827. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  6828. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  6829. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6830. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  6831. if !m.op.Is(OpUpdateOne) {
  6832. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  6833. }
  6834. if m.id == nil || m.oldValue == nil {
  6835. return v, errors.New("OldContactID requires an ID field in the mutation")
  6836. }
  6837. oldValue, err := m.oldValue(ctx)
  6838. if err != nil {
  6839. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  6840. }
  6841. return oldValue.ContactID, nil
  6842. }
  6843. // ResetContactID resets all changes to the "contact_id" field.
  6844. func (m *LabelRelationshipMutation) ResetContactID() {
  6845. m.contacts = nil
  6846. }
  6847. // SetOrganizationID sets the "organization_id" field.
  6848. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  6849. m.organization_id = &u
  6850. m.addorganization_id = nil
  6851. }
  6852. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6853. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  6854. v := m.organization_id
  6855. if v == nil {
  6856. return
  6857. }
  6858. return *v, true
  6859. }
  6860. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  6861. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  6862. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6863. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6864. if !m.op.Is(OpUpdateOne) {
  6865. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6866. }
  6867. if m.id == nil || m.oldValue == nil {
  6868. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6869. }
  6870. oldValue, err := m.oldValue(ctx)
  6871. if err != nil {
  6872. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6873. }
  6874. return oldValue.OrganizationID, nil
  6875. }
  6876. // AddOrganizationID adds u to the "organization_id" field.
  6877. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  6878. if m.addorganization_id != nil {
  6879. *m.addorganization_id += u
  6880. } else {
  6881. m.addorganization_id = &u
  6882. }
  6883. }
  6884. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6885. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  6886. v := m.addorganization_id
  6887. if v == nil {
  6888. return
  6889. }
  6890. return *v, true
  6891. }
  6892. // ClearOrganizationID clears the value of the "organization_id" field.
  6893. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  6894. m.organization_id = nil
  6895. m.addorganization_id = nil
  6896. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  6897. }
  6898. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  6899. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  6900. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  6901. return ok
  6902. }
  6903. // ResetOrganizationID resets all changes to the "organization_id" field.
  6904. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  6905. m.organization_id = nil
  6906. m.addorganization_id = nil
  6907. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  6908. }
  6909. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  6910. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  6911. m.contacts = &id
  6912. }
  6913. // ClearContacts clears the "contacts" edge to the Contact entity.
  6914. func (m *LabelRelationshipMutation) ClearContacts() {
  6915. m.clearedcontacts = true
  6916. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  6917. }
  6918. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  6919. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  6920. return m.clearedcontacts
  6921. }
  6922. // ContactsID returns the "contacts" edge ID in the mutation.
  6923. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  6924. if m.contacts != nil {
  6925. return *m.contacts, true
  6926. }
  6927. return
  6928. }
  6929. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  6930. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  6931. // ContactsID instead. It exists only for internal usage by the builders.
  6932. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  6933. if id := m.contacts; id != nil {
  6934. ids = append(ids, *id)
  6935. }
  6936. return
  6937. }
  6938. // ResetContacts resets all changes to the "contacts" edge.
  6939. func (m *LabelRelationshipMutation) ResetContacts() {
  6940. m.contacts = nil
  6941. m.clearedcontacts = false
  6942. }
  6943. // SetLabelsID sets the "labels" edge to the Label entity by id.
  6944. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  6945. m.labels = &id
  6946. }
  6947. // ClearLabels clears the "labels" edge to the Label entity.
  6948. func (m *LabelRelationshipMutation) ClearLabels() {
  6949. m.clearedlabels = true
  6950. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  6951. }
  6952. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  6953. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  6954. return m.clearedlabels
  6955. }
  6956. // LabelsID returns the "labels" edge ID in the mutation.
  6957. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  6958. if m.labels != nil {
  6959. return *m.labels, true
  6960. }
  6961. return
  6962. }
  6963. // LabelsIDs returns the "labels" edge IDs in the mutation.
  6964. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  6965. // LabelsID instead. It exists only for internal usage by the builders.
  6966. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  6967. if id := m.labels; id != nil {
  6968. ids = append(ids, *id)
  6969. }
  6970. return
  6971. }
  6972. // ResetLabels resets all changes to the "labels" edge.
  6973. func (m *LabelRelationshipMutation) ResetLabels() {
  6974. m.labels = nil
  6975. m.clearedlabels = false
  6976. }
  6977. // Where appends a list predicates to the LabelRelationshipMutation builder.
  6978. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  6979. m.predicates = append(m.predicates, ps...)
  6980. }
  6981. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  6982. // users can use type-assertion to append predicates that do not depend on any generated package.
  6983. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  6984. p := make([]predicate.LabelRelationship, len(ps))
  6985. for i := range ps {
  6986. p[i] = ps[i]
  6987. }
  6988. m.Where(p...)
  6989. }
  6990. // Op returns the operation name.
  6991. func (m *LabelRelationshipMutation) Op() Op {
  6992. return m.op
  6993. }
  6994. // SetOp allows setting the mutation operation.
  6995. func (m *LabelRelationshipMutation) SetOp(op Op) {
  6996. m.op = op
  6997. }
  6998. // Type returns the node type of this mutation (LabelRelationship).
  6999. func (m *LabelRelationshipMutation) Type() string {
  7000. return m.typ
  7001. }
  7002. // Fields returns all fields that were changed during this mutation. Note that in
  7003. // order to get all numeric fields that were incremented/decremented, call
  7004. // AddedFields().
  7005. func (m *LabelRelationshipMutation) Fields() []string {
  7006. fields := make([]string, 0, 7)
  7007. if m.created_at != nil {
  7008. fields = append(fields, labelrelationship.FieldCreatedAt)
  7009. }
  7010. if m.updated_at != nil {
  7011. fields = append(fields, labelrelationship.FieldUpdatedAt)
  7012. }
  7013. if m.status != nil {
  7014. fields = append(fields, labelrelationship.FieldStatus)
  7015. }
  7016. if m.deleted_at != nil {
  7017. fields = append(fields, labelrelationship.FieldDeletedAt)
  7018. }
  7019. if m.labels != nil {
  7020. fields = append(fields, labelrelationship.FieldLabelID)
  7021. }
  7022. if m.contacts != nil {
  7023. fields = append(fields, labelrelationship.FieldContactID)
  7024. }
  7025. if m.organization_id != nil {
  7026. fields = append(fields, labelrelationship.FieldOrganizationID)
  7027. }
  7028. return fields
  7029. }
  7030. // Field returns the value of a field with the given name. The second boolean
  7031. // return value indicates that this field was not set, or was not defined in the
  7032. // schema.
  7033. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  7034. switch name {
  7035. case labelrelationship.FieldCreatedAt:
  7036. return m.CreatedAt()
  7037. case labelrelationship.FieldUpdatedAt:
  7038. return m.UpdatedAt()
  7039. case labelrelationship.FieldStatus:
  7040. return m.Status()
  7041. case labelrelationship.FieldDeletedAt:
  7042. return m.DeletedAt()
  7043. case labelrelationship.FieldLabelID:
  7044. return m.LabelID()
  7045. case labelrelationship.FieldContactID:
  7046. return m.ContactID()
  7047. case labelrelationship.FieldOrganizationID:
  7048. return m.OrganizationID()
  7049. }
  7050. return nil, false
  7051. }
  7052. // OldField returns the old value of the field from the database. An error is
  7053. // returned if the mutation operation is not UpdateOne, or the query to the
  7054. // database failed.
  7055. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7056. switch name {
  7057. case labelrelationship.FieldCreatedAt:
  7058. return m.OldCreatedAt(ctx)
  7059. case labelrelationship.FieldUpdatedAt:
  7060. return m.OldUpdatedAt(ctx)
  7061. case labelrelationship.FieldStatus:
  7062. return m.OldStatus(ctx)
  7063. case labelrelationship.FieldDeletedAt:
  7064. return m.OldDeletedAt(ctx)
  7065. case labelrelationship.FieldLabelID:
  7066. return m.OldLabelID(ctx)
  7067. case labelrelationship.FieldContactID:
  7068. return m.OldContactID(ctx)
  7069. case labelrelationship.FieldOrganizationID:
  7070. return m.OldOrganizationID(ctx)
  7071. }
  7072. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  7073. }
  7074. // SetField sets the value of a field with the given name. It returns an error if
  7075. // the field is not defined in the schema, or if the type mismatched the field
  7076. // type.
  7077. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  7078. switch name {
  7079. case labelrelationship.FieldCreatedAt:
  7080. v, ok := value.(time.Time)
  7081. if !ok {
  7082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7083. }
  7084. m.SetCreatedAt(v)
  7085. return nil
  7086. case labelrelationship.FieldUpdatedAt:
  7087. v, ok := value.(time.Time)
  7088. if !ok {
  7089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7090. }
  7091. m.SetUpdatedAt(v)
  7092. return nil
  7093. case labelrelationship.FieldStatus:
  7094. v, ok := value.(uint8)
  7095. if !ok {
  7096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7097. }
  7098. m.SetStatus(v)
  7099. return nil
  7100. case labelrelationship.FieldDeletedAt:
  7101. v, ok := value.(time.Time)
  7102. if !ok {
  7103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7104. }
  7105. m.SetDeletedAt(v)
  7106. return nil
  7107. case labelrelationship.FieldLabelID:
  7108. v, ok := value.(uint64)
  7109. if !ok {
  7110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7111. }
  7112. m.SetLabelID(v)
  7113. return nil
  7114. case labelrelationship.FieldContactID:
  7115. v, ok := value.(uint64)
  7116. if !ok {
  7117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7118. }
  7119. m.SetContactID(v)
  7120. return nil
  7121. case labelrelationship.FieldOrganizationID:
  7122. v, ok := value.(uint64)
  7123. if !ok {
  7124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7125. }
  7126. m.SetOrganizationID(v)
  7127. return nil
  7128. }
  7129. return fmt.Errorf("unknown LabelRelationship field %s", name)
  7130. }
  7131. // AddedFields returns all numeric fields that were incremented/decremented during
  7132. // this mutation.
  7133. func (m *LabelRelationshipMutation) AddedFields() []string {
  7134. var fields []string
  7135. if m.addstatus != nil {
  7136. fields = append(fields, labelrelationship.FieldStatus)
  7137. }
  7138. if m.addorganization_id != nil {
  7139. fields = append(fields, labelrelationship.FieldOrganizationID)
  7140. }
  7141. return fields
  7142. }
  7143. // AddedField returns the numeric value that was incremented/decremented on a field
  7144. // with the given name. The second boolean return value indicates that this field
  7145. // was not set, or was not defined in the schema.
  7146. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  7147. switch name {
  7148. case labelrelationship.FieldStatus:
  7149. return m.AddedStatus()
  7150. case labelrelationship.FieldOrganizationID:
  7151. return m.AddedOrganizationID()
  7152. }
  7153. return nil, false
  7154. }
  7155. // AddField adds the value to the field with the given name. It returns an error if
  7156. // the field is not defined in the schema, or if the type mismatched the field
  7157. // type.
  7158. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  7159. switch name {
  7160. case labelrelationship.FieldStatus:
  7161. v, ok := value.(int8)
  7162. if !ok {
  7163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7164. }
  7165. m.AddStatus(v)
  7166. return nil
  7167. case labelrelationship.FieldOrganizationID:
  7168. v, ok := value.(int64)
  7169. if !ok {
  7170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7171. }
  7172. m.AddOrganizationID(v)
  7173. return nil
  7174. }
  7175. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  7176. }
  7177. // ClearedFields returns all nullable fields that were cleared during this
  7178. // mutation.
  7179. func (m *LabelRelationshipMutation) ClearedFields() []string {
  7180. var fields []string
  7181. if m.FieldCleared(labelrelationship.FieldStatus) {
  7182. fields = append(fields, labelrelationship.FieldStatus)
  7183. }
  7184. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  7185. fields = append(fields, labelrelationship.FieldDeletedAt)
  7186. }
  7187. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  7188. fields = append(fields, labelrelationship.FieldOrganizationID)
  7189. }
  7190. return fields
  7191. }
  7192. // FieldCleared returns a boolean indicating if a field with the given name was
  7193. // cleared in this mutation.
  7194. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  7195. _, ok := m.clearedFields[name]
  7196. return ok
  7197. }
  7198. // ClearField clears the value of the field with the given name. It returns an
  7199. // error if the field is not defined in the schema.
  7200. func (m *LabelRelationshipMutation) ClearField(name string) error {
  7201. switch name {
  7202. case labelrelationship.FieldStatus:
  7203. m.ClearStatus()
  7204. return nil
  7205. case labelrelationship.FieldDeletedAt:
  7206. m.ClearDeletedAt()
  7207. return nil
  7208. case labelrelationship.FieldOrganizationID:
  7209. m.ClearOrganizationID()
  7210. return nil
  7211. }
  7212. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  7213. }
  7214. // ResetField resets all changes in the mutation for the field with the given name.
  7215. // It returns an error if the field is not defined in the schema.
  7216. func (m *LabelRelationshipMutation) ResetField(name string) error {
  7217. switch name {
  7218. case labelrelationship.FieldCreatedAt:
  7219. m.ResetCreatedAt()
  7220. return nil
  7221. case labelrelationship.FieldUpdatedAt:
  7222. m.ResetUpdatedAt()
  7223. return nil
  7224. case labelrelationship.FieldStatus:
  7225. m.ResetStatus()
  7226. return nil
  7227. case labelrelationship.FieldDeletedAt:
  7228. m.ResetDeletedAt()
  7229. return nil
  7230. case labelrelationship.FieldLabelID:
  7231. m.ResetLabelID()
  7232. return nil
  7233. case labelrelationship.FieldContactID:
  7234. m.ResetContactID()
  7235. return nil
  7236. case labelrelationship.FieldOrganizationID:
  7237. m.ResetOrganizationID()
  7238. return nil
  7239. }
  7240. return fmt.Errorf("unknown LabelRelationship field %s", name)
  7241. }
  7242. // AddedEdges returns all edge names that were set/added in this mutation.
  7243. func (m *LabelRelationshipMutation) AddedEdges() []string {
  7244. edges := make([]string, 0, 2)
  7245. if m.contacts != nil {
  7246. edges = append(edges, labelrelationship.EdgeContacts)
  7247. }
  7248. if m.labels != nil {
  7249. edges = append(edges, labelrelationship.EdgeLabels)
  7250. }
  7251. return edges
  7252. }
  7253. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7254. // name in this mutation.
  7255. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  7256. switch name {
  7257. case labelrelationship.EdgeContacts:
  7258. if id := m.contacts; id != nil {
  7259. return []ent.Value{*id}
  7260. }
  7261. case labelrelationship.EdgeLabels:
  7262. if id := m.labels; id != nil {
  7263. return []ent.Value{*id}
  7264. }
  7265. }
  7266. return nil
  7267. }
  7268. // RemovedEdges returns all edge names that were removed in this mutation.
  7269. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  7270. edges := make([]string, 0, 2)
  7271. return edges
  7272. }
  7273. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7274. // the given name in this mutation.
  7275. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  7276. return nil
  7277. }
  7278. // ClearedEdges returns all edge names that were cleared in this mutation.
  7279. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  7280. edges := make([]string, 0, 2)
  7281. if m.clearedcontacts {
  7282. edges = append(edges, labelrelationship.EdgeContacts)
  7283. }
  7284. if m.clearedlabels {
  7285. edges = append(edges, labelrelationship.EdgeLabels)
  7286. }
  7287. return edges
  7288. }
  7289. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7290. // was cleared in this mutation.
  7291. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  7292. switch name {
  7293. case labelrelationship.EdgeContacts:
  7294. return m.clearedcontacts
  7295. case labelrelationship.EdgeLabels:
  7296. return m.clearedlabels
  7297. }
  7298. return false
  7299. }
  7300. // ClearEdge clears the value of the edge with the given name. It returns an error
  7301. // if that edge is not defined in the schema.
  7302. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  7303. switch name {
  7304. case labelrelationship.EdgeContacts:
  7305. m.ClearContacts()
  7306. return nil
  7307. case labelrelationship.EdgeLabels:
  7308. m.ClearLabels()
  7309. return nil
  7310. }
  7311. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  7312. }
  7313. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7314. // It returns an error if the edge is not defined in the schema.
  7315. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  7316. switch name {
  7317. case labelrelationship.EdgeContacts:
  7318. m.ResetContacts()
  7319. return nil
  7320. case labelrelationship.EdgeLabels:
  7321. m.ResetLabels()
  7322. return nil
  7323. }
  7324. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  7325. }
  7326. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  7327. type MessageMutation struct {
  7328. config
  7329. op Op
  7330. typ string
  7331. id *int
  7332. wx_wxid *string
  7333. wxid *string
  7334. content *string
  7335. clearedFields map[string]struct{}
  7336. done bool
  7337. oldValue func(context.Context) (*Message, error)
  7338. predicates []predicate.Message
  7339. }
  7340. var _ ent.Mutation = (*MessageMutation)(nil)
  7341. // messageOption allows management of the mutation configuration using functional options.
  7342. type messageOption func(*MessageMutation)
  7343. // newMessageMutation creates new mutation for the Message entity.
  7344. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  7345. m := &MessageMutation{
  7346. config: c,
  7347. op: op,
  7348. typ: TypeMessage,
  7349. clearedFields: make(map[string]struct{}),
  7350. }
  7351. for _, opt := range opts {
  7352. opt(m)
  7353. }
  7354. return m
  7355. }
  7356. // withMessageID sets the ID field of the mutation.
  7357. func withMessageID(id int) messageOption {
  7358. return func(m *MessageMutation) {
  7359. var (
  7360. err error
  7361. once sync.Once
  7362. value *Message
  7363. )
  7364. m.oldValue = func(ctx context.Context) (*Message, error) {
  7365. once.Do(func() {
  7366. if m.done {
  7367. err = errors.New("querying old values post mutation is not allowed")
  7368. } else {
  7369. value, err = m.Client().Message.Get(ctx, id)
  7370. }
  7371. })
  7372. return value, err
  7373. }
  7374. m.id = &id
  7375. }
  7376. }
  7377. // withMessage sets the old Message of the mutation.
  7378. func withMessage(node *Message) messageOption {
  7379. return func(m *MessageMutation) {
  7380. m.oldValue = func(context.Context) (*Message, error) {
  7381. return node, nil
  7382. }
  7383. m.id = &node.ID
  7384. }
  7385. }
  7386. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7387. // executed in a transaction (ent.Tx), a transactional client is returned.
  7388. func (m MessageMutation) Client() *Client {
  7389. client := &Client{config: m.config}
  7390. client.init()
  7391. return client
  7392. }
  7393. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7394. // it returns an error otherwise.
  7395. func (m MessageMutation) Tx() (*Tx, error) {
  7396. if _, ok := m.driver.(*txDriver); !ok {
  7397. return nil, errors.New("ent: mutation is not running in a transaction")
  7398. }
  7399. tx := &Tx{config: m.config}
  7400. tx.init()
  7401. return tx, nil
  7402. }
  7403. // ID returns the ID value in the mutation. Note that the ID is only available
  7404. // if it was provided to the builder or after it was returned from the database.
  7405. func (m *MessageMutation) ID() (id int, exists bool) {
  7406. if m.id == nil {
  7407. return
  7408. }
  7409. return *m.id, true
  7410. }
  7411. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7412. // That means, if the mutation is applied within a transaction with an isolation level such
  7413. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7414. // or updated by the mutation.
  7415. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  7416. switch {
  7417. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7418. id, exists := m.ID()
  7419. if exists {
  7420. return []int{id}, nil
  7421. }
  7422. fallthrough
  7423. case m.op.Is(OpUpdate | OpDelete):
  7424. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  7425. default:
  7426. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7427. }
  7428. }
  7429. // SetWxWxid sets the "wx_wxid" field.
  7430. func (m *MessageMutation) SetWxWxid(s string) {
  7431. m.wx_wxid = &s
  7432. }
  7433. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7434. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  7435. v := m.wx_wxid
  7436. if v == nil {
  7437. return
  7438. }
  7439. return *v, true
  7440. }
  7441. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  7442. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  7443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7444. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  7445. if !m.op.Is(OpUpdateOne) {
  7446. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  7447. }
  7448. if m.id == nil || m.oldValue == nil {
  7449. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  7450. }
  7451. oldValue, err := m.oldValue(ctx)
  7452. if err != nil {
  7453. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  7454. }
  7455. return oldValue.WxWxid, nil
  7456. }
  7457. // ClearWxWxid clears the value of the "wx_wxid" field.
  7458. func (m *MessageMutation) ClearWxWxid() {
  7459. m.wx_wxid = nil
  7460. m.clearedFields[message.FieldWxWxid] = struct{}{}
  7461. }
  7462. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  7463. func (m *MessageMutation) WxWxidCleared() bool {
  7464. _, ok := m.clearedFields[message.FieldWxWxid]
  7465. return ok
  7466. }
  7467. // ResetWxWxid resets all changes to the "wx_wxid" field.
  7468. func (m *MessageMutation) ResetWxWxid() {
  7469. m.wx_wxid = nil
  7470. delete(m.clearedFields, message.FieldWxWxid)
  7471. }
  7472. // SetWxid sets the "wxid" field.
  7473. func (m *MessageMutation) SetWxid(s string) {
  7474. m.wxid = &s
  7475. }
  7476. // Wxid returns the value of the "wxid" field in the mutation.
  7477. func (m *MessageMutation) Wxid() (r string, exists bool) {
  7478. v := m.wxid
  7479. if v == nil {
  7480. return
  7481. }
  7482. return *v, true
  7483. }
  7484. // OldWxid returns the old "wxid" field's value of the Message entity.
  7485. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  7486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7487. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  7488. if !m.op.Is(OpUpdateOne) {
  7489. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  7490. }
  7491. if m.id == nil || m.oldValue == nil {
  7492. return v, errors.New("OldWxid requires an ID field in the mutation")
  7493. }
  7494. oldValue, err := m.oldValue(ctx)
  7495. if err != nil {
  7496. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  7497. }
  7498. return oldValue.Wxid, nil
  7499. }
  7500. // ResetWxid resets all changes to the "wxid" field.
  7501. func (m *MessageMutation) ResetWxid() {
  7502. m.wxid = nil
  7503. }
  7504. // SetContent sets the "content" field.
  7505. func (m *MessageMutation) SetContent(s string) {
  7506. m.content = &s
  7507. }
  7508. // Content returns the value of the "content" field in the mutation.
  7509. func (m *MessageMutation) Content() (r string, exists bool) {
  7510. v := m.content
  7511. if v == nil {
  7512. return
  7513. }
  7514. return *v, true
  7515. }
  7516. // OldContent returns the old "content" field's value of the Message entity.
  7517. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  7518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7519. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  7520. if !m.op.Is(OpUpdateOne) {
  7521. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  7522. }
  7523. if m.id == nil || m.oldValue == nil {
  7524. return v, errors.New("OldContent requires an ID field in the mutation")
  7525. }
  7526. oldValue, err := m.oldValue(ctx)
  7527. if err != nil {
  7528. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  7529. }
  7530. return oldValue.Content, nil
  7531. }
  7532. // ResetContent resets all changes to the "content" field.
  7533. func (m *MessageMutation) ResetContent() {
  7534. m.content = nil
  7535. }
  7536. // Where appends a list predicates to the MessageMutation builder.
  7537. func (m *MessageMutation) Where(ps ...predicate.Message) {
  7538. m.predicates = append(m.predicates, ps...)
  7539. }
  7540. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  7541. // users can use type-assertion to append predicates that do not depend on any generated package.
  7542. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  7543. p := make([]predicate.Message, len(ps))
  7544. for i := range ps {
  7545. p[i] = ps[i]
  7546. }
  7547. m.Where(p...)
  7548. }
  7549. // Op returns the operation name.
  7550. func (m *MessageMutation) Op() Op {
  7551. return m.op
  7552. }
  7553. // SetOp allows setting the mutation operation.
  7554. func (m *MessageMutation) SetOp(op Op) {
  7555. m.op = op
  7556. }
  7557. // Type returns the node type of this mutation (Message).
  7558. func (m *MessageMutation) Type() string {
  7559. return m.typ
  7560. }
  7561. // Fields returns all fields that were changed during this mutation. Note that in
  7562. // order to get all numeric fields that were incremented/decremented, call
  7563. // AddedFields().
  7564. func (m *MessageMutation) Fields() []string {
  7565. fields := make([]string, 0, 3)
  7566. if m.wx_wxid != nil {
  7567. fields = append(fields, message.FieldWxWxid)
  7568. }
  7569. if m.wxid != nil {
  7570. fields = append(fields, message.FieldWxid)
  7571. }
  7572. if m.content != nil {
  7573. fields = append(fields, message.FieldContent)
  7574. }
  7575. return fields
  7576. }
  7577. // Field returns the value of a field with the given name. The second boolean
  7578. // return value indicates that this field was not set, or was not defined in the
  7579. // schema.
  7580. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  7581. switch name {
  7582. case message.FieldWxWxid:
  7583. return m.WxWxid()
  7584. case message.FieldWxid:
  7585. return m.Wxid()
  7586. case message.FieldContent:
  7587. return m.Content()
  7588. }
  7589. return nil, false
  7590. }
  7591. // OldField returns the old value of the field from the database. An error is
  7592. // returned if the mutation operation is not UpdateOne, or the query to the
  7593. // database failed.
  7594. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7595. switch name {
  7596. case message.FieldWxWxid:
  7597. return m.OldWxWxid(ctx)
  7598. case message.FieldWxid:
  7599. return m.OldWxid(ctx)
  7600. case message.FieldContent:
  7601. return m.OldContent(ctx)
  7602. }
  7603. return nil, fmt.Errorf("unknown Message field %s", name)
  7604. }
  7605. // SetField sets the value of a field with the given name. It returns an error if
  7606. // the field is not defined in the schema, or if the type mismatched the field
  7607. // type.
  7608. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  7609. switch name {
  7610. case message.FieldWxWxid:
  7611. v, ok := value.(string)
  7612. if !ok {
  7613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7614. }
  7615. m.SetWxWxid(v)
  7616. return nil
  7617. case message.FieldWxid:
  7618. v, ok := value.(string)
  7619. if !ok {
  7620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7621. }
  7622. m.SetWxid(v)
  7623. return nil
  7624. case message.FieldContent:
  7625. v, ok := value.(string)
  7626. if !ok {
  7627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7628. }
  7629. m.SetContent(v)
  7630. return nil
  7631. }
  7632. return fmt.Errorf("unknown Message field %s", name)
  7633. }
  7634. // AddedFields returns all numeric fields that were incremented/decremented during
  7635. // this mutation.
  7636. func (m *MessageMutation) AddedFields() []string {
  7637. return nil
  7638. }
  7639. // AddedField returns the numeric value that was incremented/decremented on a field
  7640. // with the given name. The second boolean return value indicates that this field
  7641. // was not set, or was not defined in the schema.
  7642. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  7643. return nil, false
  7644. }
  7645. // AddField adds the value to the field with the given name. It returns an error if
  7646. // the field is not defined in the schema, or if the type mismatched the field
  7647. // type.
  7648. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  7649. switch name {
  7650. }
  7651. return fmt.Errorf("unknown Message numeric field %s", name)
  7652. }
  7653. // ClearedFields returns all nullable fields that were cleared during this
  7654. // mutation.
  7655. func (m *MessageMutation) ClearedFields() []string {
  7656. var fields []string
  7657. if m.FieldCleared(message.FieldWxWxid) {
  7658. fields = append(fields, message.FieldWxWxid)
  7659. }
  7660. return fields
  7661. }
  7662. // FieldCleared returns a boolean indicating if a field with the given name was
  7663. // cleared in this mutation.
  7664. func (m *MessageMutation) FieldCleared(name string) bool {
  7665. _, ok := m.clearedFields[name]
  7666. return ok
  7667. }
  7668. // ClearField clears the value of the field with the given name. It returns an
  7669. // error if the field is not defined in the schema.
  7670. func (m *MessageMutation) ClearField(name string) error {
  7671. switch name {
  7672. case message.FieldWxWxid:
  7673. m.ClearWxWxid()
  7674. return nil
  7675. }
  7676. return fmt.Errorf("unknown Message nullable field %s", name)
  7677. }
  7678. // ResetField resets all changes in the mutation for the field with the given name.
  7679. // It returns an error if the field is not defined in the schema.
  7680. func (m *MessageMutation) ResetField(name string) error {
  7681. switch name {
  7682. case message.FieldWxWxid:
  7683. m.ResetWxWxid()
  7684. return nil
  7685. case message.FieldWxid:
  7686. m.ResetWxid()
  7687. return nil
  7688. case message.FieldContent:
  7689. m.ResetContent()
  7690. return nil
  7691. }
  7692. return fmt.Errorf("unknown Message field %s", name)
  7693. }
  7694. // AddedEdges returns all edge names that were set/added in this mutation.
  7695. func (m *MessageMutation) AddedEdges() []string {
  7696. edges := make([]string, 0, 0)
  7697. return edges
  7698. }
  7699. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7700. // name in this mutation.
  7701. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  7702. return nil
  7703. }
  7704. // RemovedEdges returns all edge names that were removed in this mutation.
  7705. func (m *MessageMutation) RemovedEdges() []string {
  7706. edges := make([]string, 0, 0)
  7707. return edges
  7708. }
  7709. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7710. // the given name in this mutation.
  7711. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  7712. return nil
  7713. }
  7714. // ClearedEdges returns all edge names that were cleared in this mutation.
  7715. func (m *MessageMutation) ClearedEdges() []string {
  7716. edges := make([]string, 0, 0)
  7717. return edges
  7718. }
  7719. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7720. // was cleared in this mutation.
  7721. func (m *MessageMutation) EdgeCleared(name string) bool {
  7722. return false
  7723. }
  7724. // ClearEdge clears the value of the edge with the given name. It returns an error
  7725. // if that edge is not defined in the schema.
  7726. func (m *MessageMutation) ClearEdge(name string) error {
  7727. return fmt.Errorf("unknown Message unique edge %s", name)
  7728. }
  7729. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7730. // It returns an error if the edge is not defined in the schema.
  7731. func (m *MessageMutation) ResetEdge(name string) error {
  7732. return fmt.Errorf("unknown Message edge %s", name)
  7733. }
  7734. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  7735. type MessageRecordsMutation struct {
  7736. config
  7737. op Op
  7738. typ string
  7739. id *uint64
  7740. created_at *time.Time
  7741. updated_at *time.Time
  7742. status *uint8
  7743. addstatus *int8
  7744. deleted_at *time.Time
  7745. bot_wxid *string
  7746. contact_type *int
  7747. addcontact_type *int
  7748. contact_wxid *string
  7749. content_type *int
  7750. addcontent_type *int
  7751. content *string
  7752. meta *custom_types.Meta
  7753. error_detail *string
  7754. send_time *time.Time
  7755. source_type *int
  7756. addsource_type *int
  7757. organization_id *uint64
  7758. addorganization_id *int64
  7759. clearedFields map[string]struct{}
  7760. sop_stage *uint64
  7761. clearedsop_stage bool
  7762. sop_node *uint64
  7763. clearedsop_node bool
  7764. message_contact *uint64
  7765. clearedmessage_contact bool
  7766. done bool
  7767. oldValue func(context.Context) (*MessageRecords, error)
  7768. predicates []predicate.MessageRecords
  7769. }
  7770. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  7771. // messagerecordsOption allows management of the mutation configuration using functional options.
  7772. type messagerecordsOption func(*MessageRecordsMutation)
  7773. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  7774. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  7775. m := &MessageRecordsMutation{
  7776. config: c,
  7777. op: op,
  7778. typ: TypeMessageRecords,
  7779. clearedFields: make(map[string]struct{}),
  7780. }
  7781. for _, opt := range opts {
  7782. opt(m)
  7783. }
  7784. return m
  7785. }
  7786. // withMessageRecordsID sets the ID field of the mutation.
  7787. func withMessageRecordsID(id uint64) messagerecordsOption {
  7788. return func(m *MessageRecordsMutation) {
  7789. var (
  7790. err error
  7791. once sync.Once
  7792. value *MessageRecords
  7793. )
  7794. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  7795. once.Do(func() {
  7796. if m.done {
  7797. err = errors.New("querying old values post mutation is not allowed")
  7798. } else {
  7799. value, err = m.Client().MessageRecords.Get(ctx, id)
  7800. }
  7801. })
  7802. return value, err
  7803. }
  7804. m.id = &id
  7805. }
  7806. }
  7807. // withMessageRecords sets the old MessageRecords of the mutation.
  7808. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  7809. return func(m *MessageRecordsMutation) {
  7810. m.oldValue = func(context.Context) (*MessageRecords, error) {
  7811. return node, nil
  7812. }
  7813. m.id = &node.ID
  7814. }
  7815. }
  7816. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7817. // executed in a transaction (ent.Tx), a transactional client is returned.
  7818. func (m MessageRecordsMutation) Client() *Client {
  7819. client := &Client{config: m.config}
  7820. client.init()
  7821. return client
  7822. }
  7823. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7824. // it returns an error otherwise.
  7825. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  7826. if _, ok := m.driver.(*txDriver); !ok {
  7827. return nil, errors.New("ent: mutation is not running in a transaction")
  7828. }
  7829. tx := &Tx{config: m.config}
  7830. tx.init()
  7831. return tx, nil
  7832. }
  7833. // SetID sets the value of the id field. Note that this
  7834. // operation is only accepted on creation of MessageRecords entities.
  7835. func (m *MessageRecordsMutation) SetID(id uint64) {
  7836. m.id = &id
  7837. }
  7838. // ID returns the ID value in the mutation. Note that the ID is only available
  7839. // if it was provided to the builder or after it was returned from the database.
  7840. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  7841. if m.id == nil {
  7842. return
  7843. }
  7844. return *m.id, true
  7845. }
  7846. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7847. // That means, if the mutation is applied within a transaction with an isolation level such
  7848. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7849. // or updated by the mutation.
  7850. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  7851. switch {
  7852. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7853. id, exists := m.ID()
  7854. if exists {
  7855. return []uint64{id}, nil
  7856. }
  7857. fallthrough
  7858. case m.op.Is(OpUpdate | OpDelete):
  7859. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  7860. default:
  7861. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7862. }
  7863. }
  7864. // SetCreatedAt sets the "created_at" field.
  7865. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  7866. m.created_at = &t
  7867. }
  7868. // CreatedAt returns the value of the "created_at" field in the mutation.
  7869. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  7870. v := m.created_at
  7871. if v == nil {
  7872. return
  7873. }
  7874. return *v, true
  7875. }
  7876. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  7877. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  7878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7879. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7880. if !m.op.Is(OpUpdateOne) {
  7881. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7882. }
  7883. if m.id == nil || m.oldValue == nil {
  7884. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7885. }
  7886. oldValue, err := m.oldValue(ctx)
  7887. if err != nil {
  7888. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7889. }
  7890. return oldValue.CreatedAt, nil
  7891. }
  7892. // ResetCreatedAt resets all changes to the "created_at" field.
  7893. func (m *MessageRecordsMutation) ResetCreatedAt() {
  7894. m.created_at = nil
  7895. }
  7896. // SetUpdatedAt sets the "updated_at" field.
  7897. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  7898. m.updated_at = &t
  7899. }
  7900. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7901. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  7902. v := m.updated_at
  7903. if v == nil {
  7904. return
  7905. }
  7906. return *v, true
  7907. }
  7908. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  7909. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  7910. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7911. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7912. if !m.op.Is(OpUpdateOne) {
  7913. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7914. }
  7915. if m.id == nil || m.oldValue == nil {
  7916. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7917. }
  7918. oldValue, err := m.oldValue(ctx)
  7919. if err != nil {
  7920. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7921. }
  7922. return oldValue.UpdatedAt, nil
  7923. }
  7924. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7925. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  7926. m.updated_at = nil
  7927. }
  7928. // SetStatus sets the "status" field.
  7929. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  7930. m.status = &u
  7931. m.addstatus = nil
  7932. }
  7933. // Status returns the value of the "status" field in the mutation.
  7934. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  7935. v := m.status
  7936. if v == nil {
  7937. return
  7938. }
  7939. return *v, true
  7940. }
  7941. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  7942. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  7943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7944. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7945. if !m.op.Is(OpUpdateOne) {
  7946. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7947. }
  7948. if m.id == nil || m.oldValue == nil {
  7949. return v, errors.New("OldStatus requires an ID field in the mutation")
  7950. }
  7951. oldValue, err := m.oldValue(ctx)
  7952. if err != nil {
  7953. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7954. }
  7955. return oldValue.Status, nil
  7956. }
  7957. // AddStatus adds u to the "status" field.
  7958. func (m *MessageRecordsMutation) AddStatus(u int8) {
  7959. if m.addstatus != nil {
  7960. *m.addstatus += u
  7961. } else {
  7962. m.addstatus = &u
  7963. }
  7964. }
  7965. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7966. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  7967. v := m.addstatus
  7968. if v == nil {
  7969. return
  7970. }
  7971. return *v, true
  7972. }
  7973. // ClearStatus clears the value of the "status" field.
  7974. func (m *MessageRecordsMutation) ClearStatus() {
  7975. m.status = nil
  7976. m.addstatus = nil
  7977. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  7978. }
  7979. // StatusCleared returns if the "status" field was cleared in this mutation.
  7980. func (m *MessageRecordsMutation) StatusCleared() bool {
  7981. _, ok := m.clearedFields[messagerecords.FieldStatus]
  7982. return ok
  7983. }
  7984. // ResetStatus resets all changes to the "status" field.
  7985. func (m *MessageRecordsMutation) ResetStatus() {
  7986. m.status = nil
  7987. m.addstatus = nil
  7988. delete(m.clearedFields, messagerecords.FieldStatus)
  7989. }
  7990. // SetDeletedAt sets the "deleted_at" field.
  7991. func (m *MessageRecordsMutation) SetDeletedAt(t time.Time) {
  7992. m.deleted_at = &t
  7993. }
  7994. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7995. func (m *MessageRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  7996. v := m.deleted_at
  7997. if v == nil {
  7998. return
  7999. }
  8000. return *v, true
  8001. }
  8002. // OldDeletedAt returns the old "deleted_at" field's value of the MessageRecords entity.
  8003. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8004. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8005. func (m *MessageRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8006. if !m.op.Is(OpUpdateOne) {
  8007. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8008. }
  8009. if m.id == nil || m.oldValue == nil {
  8010. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8011. }
  8012. oldValue, err := m.oldValue(ctx)
  8013. if err != nil {
  8014. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8015. }
  8016. return oldValue.DeletedAt, nil
  8017. }
  8018. // ClearDeletedAt clears the value of the "deleted_at" field.
  8019. func (m *MessageRecordsMutation) ClearDeletedAt() {
  8020. m.deleted_at = nil
  8021. m.clearedFields[messagerecords.FieldDeletedAt] = struct{}{}
  8022. }
  8023. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8024. func (m *MessageRecordsMutation) DeletedAtCleared() bool {
  8025. _, ok := m.clearedFields[messagerecords.FieldDeletedAt]
  8026. return ok
  8027. }
  8028. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8029. func (m *MessageRecordsMutation) ResetDeletedAt() {
  8030. m.deleted_at = nil
  8031. delete(m.clearedFields, messagerecords.FieldDeletedAt)
  8032. }
  8033. // SetBotWxid sets the "bot_wxid" field.
  8034. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  8035. m.bot_wxid = &s
  8036. }
  8037. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  8038. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  8039. v := m.bot_wxid
  8040. if v == nil {
  8041. return
  8042. }
  8043. return *v, true
  8044. }
  8045. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  8046. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8048. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  8049. if !m.op.Is(OpUpdateOne) {
  8050. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  8051. }
  8052. if m.id == nil || m.oldValue == nil {
  8053. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  8054. }
  8055. oldValue, err := m.oldValue(ctx)
  8056. if err != nil {
  8057. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  8058. }
  8059. return oldValue.BotWxid, nil
  8060. }
  8061. // ResetBotWxid resets all changes to the "bot_wxid" field.
  8062. func (m *MessageRecordsMutation) ResetBotWxid() {
  8063. m.bot_wxid = nil
  8064. }
  8065. // SetContactID sets the "contact_id" field.
  8066. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  8067. m.message_contact = &u
  8068. }
  8069. // ContactID returns the value of the "contact_id" field in the mutation.
  8070. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  8071. v := m.message_contact
  8072. if v == nil {
  8073. return
  8074. }
  8075. return *v, true
  8076. }
  8077. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  8078. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8080. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  8081. if !m.op.Is(OpUpdateOne) {
  8082. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  8083. }
  8084. if m.id == nil || m.oldValue == nil {
  8085. return v, errors.New("OldContactID requires an ID field in the mutation")
  8086. }
  8087. oldValue, err := m.oldValue(ctx)
  8088. if err != nil {
  8089. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  8090. }
  8091. return oldValue.ContactID, nil
  8092. }
  8093. // ClearContactID clears the value of the "contact_id" field.
  8094. func (m *MessageRecordsMutation) ClearContactID() {
  8095. m.message_contact = nil
  8096. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  8097. }
  8098. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  8099. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  8100. _, ok := m.clearedFields[messagerecords.FieldContactID]
  8101. return ok
  8102. }
  8103. // ResetContactID resets all changes to the "contact_id" field.
  8104. func (m *MessageRecordsMutation) ResetContactID() {
  8105. m.message_contact = nil
  8106. delete(m.clearedFields, messagerecords.FieldContactID)
  8107. }
  8108. // SetContactType sets the "contact_type" field.
  8109. func (m *MessageRecordsMutation) SetContactType(i int) {
  8110. m.contact_type = &i
  8111. m.addcontact_type = nil
  8112. }
  8113. // ContactType returns the value of the "contact_type" field in the mutation.
  8114. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  8115. v := m.contact_type
  8116. if v == nil {
  8117. return
  8118. }
  8119. return *v, true
  8120. }
  8121. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  8122. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8124. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  8125. if !m.op.Is(OpUpdateOne) {
  8126. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  8127. }
  8128. if m.id == nil || m.oldValue == nil {
  8129. return v, errors.New("OldContactType requires an ID field in the mutation")
  8130. }
  8131. oldValue, err := m.oldValue(ctx)
  8132. if err != nil {
  8133. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  8134. }
  8135. return oldValue.ContactType, nil
  8136. }
  8137. // AddContactType adds i to the "contact_type" field.
  8138. func (m *MessageRecordsMutation) AddContactType(i int) {
  8139. if m.addcontact_type != nil {
  8140. *m.addcontact_type += i
  8141. } else {
  8142. m.addcontact_type = &i
  8143. }
  8144. }
  8145. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  8146. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  8147. v := m.addcontact_type
  8148. if v == nil {
  8149. return
  8150. }
  8151. return *v, true
  8152. }
  8153. // ResetContactType resets all changes to the "contact_type" field.
  8154. func (m *MessageRecordsMutation) ResetContactType() {
  8155. m.contact_type = nil
  8156. m.addcontact_type = nil
  8157. }
  8158. // SetContactWxid sets the "contact_wxid" field.
  8159. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  8160. m.contact_wxid = &s
  8161. }
  8162. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  8163. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  8164. v := m.contact_wxid
  8165. if v == nil {
  8166. return
  8167. }
  8168. return *v, true
  8169. }
  8170. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  8171. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8173. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  8174. if !m.op.Is(OpUpdateOne) {
  8175. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  8176. }
  8177. if m.id == nil || m.oldValue == nil {
  8178. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  8179. }
  8180. oldValue, err := m.oldValue(ctx)
  8181. if err != nil {
  8182. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  8183. }
  8184. return oldValue.ContactWxid, nil
  8185. }
  8186. // ResetContactWxid resets all changes to the "contact_wxid" field.
  8187. func (m *MessageRecordsMutation) ResetContactWxid() {
  8188. m.contact_wxid = nil
  8189. }
  8190. // SetContentType sets the "content_type" field.
  8191. func (m *MessageRecordsMutation) SetContentType(i int) {
  8192. m.content_type = &i
  8193. m.addcontent_type = nil
  8194. }
  8195. // ContentType returns the value of the "content_type" field in the mutation.
  8196. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  8197. v := m.content_type
  8198. if v == nil {
  8199. return
  8200. }
  8201. return *v, true
  8202. }
  8203. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  8204. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8206. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  8207. if !m.op.Is(OpUpdateOne) {
  8208. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  8209. }
  8210. if m.id == nil || m.oldValue == nil {
  8211. return v, errors.New("OldContentType requires an ID field in the mutation")
  8212. }
  8213. oldValue, err := m.oldValue(ctx)
  8214. if err != nil {
  8215. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  8216. }
  8217. return oldValue.ContentType, nil
  8218. }
  8219. // AddContentType adds i to the "content_type" field.
  8220. func (m *MessageRecordsMutation) AddContentType(i int) {
  8221. if m.addcontent_type != nil {
  8222. *m.addcontent_type += i
  8223. } else {
  8224. m.addcontent_type = &i
  8225. }
  8226. }
  8227. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  8228. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  8229. v := m.addcontent_type
  8230. if v == nil {
  8231. return
  8232. }
  8233. return *v, true
  8234. }
  8235. // ResetContentType resets all changes to the "content_type" field.
  8236. func (m *MessageRecordsMutation) ResetContentType() {
  8237. m.content_type = nil
  8238. m.addcontent_type = nil
  8239. }
  8240. // SetContent sets the "content" field.
  8241. func (m *MessageRecordsMutation) SetContent(s string) {
  8242. m.content = &s
  8243. }
  8244. // Content returns the value of the "content" field in the mutation.
  8245. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  8246. v := m.content
  8247. if v == nil {
  8248. return
  8249. }
  8250. return *v, true
  8251. }
  8252. // OldContent returns the old "content" field's value of the MessageRecords entity.
  8253. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8255. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  8256. if !m.op.Is(OpUpdateOne) {
  8257. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  8258. }
  8259. if m.id == nil || m.oldValue == nil {
  8260. return v, errors.New("OldContent requires an ID field in the mutation")
  8261. }
  8262. oldValue, err := m.oldValue(ctx)
  8263. if err != nil {
  8264. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  8265. }
  8266. return oldValue.Content, nil
  8267. }
  8268. // ResetContent resets all changes to the "content" field.
  8269. func (m *MessageRecordsMutation) ResetContent() {
  8270. m.content = nil
  8271. }
  8272. // SetMeta sets the "meta" field.
  8273. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  8274. m.meta = &ct
  8275. }
  8276. // Meta returns the value of the "meta" field in the mutation.
  8277. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  8278. v := m.meta
  8279. if v == nil {
  8280. return
  8281. }
  8282. return *v, true
  8283. }
  8284. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  8285. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8287. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  8288. if !m.op.Is(OpUpdateOne) {
  8289. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  8290. }
  8291. if m.id == nil || m.oldValue == nil {
  8292. return v, errors.New("OldMeta requires an ID field in the mutation")
  8293. }
  8294. oldValue, err := m.oldValue(ctx)
  8295. if err != nil {
  8296. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  8297. }
  8298. return oldValue.Meta, nil
  8299. }
  8300. // ClearMeta clears the value of the "meta" field.
  8301. func (m *MessageRecordsMutation) ClearMeta() {
  8302. m.meta = nil
  8303. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  8304. }
  8305. // MetaCleared returns if the "meta" field was cleared in this mutation.
  8306. func (m *MessageRecordsMutation) MetaCleared() bool {
  8307. _, ok := m.clearedFields[messagerecords.FieldMeta]
  8308. return ok
  8309. }
  8310. // ResetMeta resets all changes to the "meta" field.
  8311. func (m *MessageRecordsMutation) ResetMeta() {
  8312. m.meta = nil
  8313. delete(m.clearedFields, messagerecords.FieldMeta)
  8314. }
  8315. // SetErrorDetail sets the "error_detail" field.
  8316. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  8317. m.error_detail = &s
  8318. }
  8319. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  8320. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  8321. v := m.error_detail
  8322. if v == nil {
  8323. return
  8324. }
  8325. return *v, true
  8326. }
  8327. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  8328. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8330. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  8331. if !m.op.Is(OpUpdateOne) {
  8332. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  8333. }
  8334. if m.id == nil || m.oldValue == nil {
  8335. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  8336. }
  8337. oldValue, err := m.oldValue(ctx)
  8338. if err != nil {
  8339. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  8340. }
  8341. return oldValue.ErrorDetail, nil
  8342. }
  8343. // ResetErrorDetail resets all changes to the "error_detail" field.
  8344. func (m *MessageRecordsMutation) ResetErrorDetail() {
  8345. m.error_detail = nil
  8346. }
  8347. // SetSendTime sets the "send_time" field.
  8348. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  8349. m.send_time = &t
  8350. }
  8351. // SendTime returns the value of the "send_time" field in the mutation.
  8352. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  8353. v := m.send_time
  8354. if v == nil {
  8355. return
  8356. }
  8357. return *v, true
  8358. }
  8359. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  8360. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8362. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  8363. if !m.op.Is(OpUpdateOne) {
  8364. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  8365. }
  8366. if m.id == nil || m.oldValue == nil {
  8367. return v, errors.New("OldSendTime requires an ID field in the mutation")
  8368. }
  8369. oldValue, err := m.oldValue(ctx)
  8370. if err != nil {
  8371. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  8372. }
  8373. return oldValue.SendTime, nil
  8374. }
  8375. // ClearSendTime clears the value of the "send_time" field.
  8376. func (m *MessageRecordsMutation) ClearSendTime() {
  8377. m.send_time = nil
  8378. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  8379. }
  8380. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  8381. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  8382. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  8383. return ok
  8384. }
  8385. // ResetSendTime resets all changes to the "send_time" field.
  8386. func (m *MessageRecordsMutation) ResetSendTime() {
  8387. m.send_time = nil
  8388. delete(m.clearedFields, messagerecords.FieldSendTime)
  8389. }
  8390. // SetSourceType sets the "source_type" field.
  8391. func (m *MessageRecordsMutation) SetSourceType(i int) {
  8392. m.source_type = &i
  8393. m.addsource_type = nil
  8394. }
  8395. // SourceType returns the value of the "source_type" field in the mutation.
  8396. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  8397. v := m.source_type
  8398. if v == nil {
  8399. return
  8400. }
  8401. return *v, true
  8402. }
  8403. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  8404. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8406. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  8407. if !m.op.Is(OpUpdateOne) {
  8408. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  8409. }
  8410. if m.id == nil || m.oldValue == nil {
  8411. return v, errors.New("OldSourceType requires an ID field in the mutation")
  8412. }
  8413. oldValue, err := m.oldValue(ctx)
  8414. if err != nil {
  8415. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  8416. }
  8417. return oldValue.SourceType, nil
  8418. }
  8419. // AddSourceType adds i to the "source_type" field.
  8420. func (m *MessageRecordsMutation) AddSourceType(i int) {
  8421. if m.addsource_type != nil {
  8422. *m.addsource_type += i
  8423. } else {
  8424. m.addsource_type = &i
  8425. }
  8426. }
  8427. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  8428. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  8429. v := m.addsource_type
  8430. if v == nil {
  8431. return
  8432. }
  8433. return *v, true
  8434. }
  8435. // ResetSourceType resets all changes to the "source_type" field.
  8436. func (m *MessageRecordsMutation) ResetSourceType() {
  8437. m.source_type = nil
  8438. m.addsource_type = nil
  8439. }
  8440. // SetSourceID sets the "source_id" field.
  8441. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  8442. m.sop_stage = &u
  8443. }
  8444. // SourceID returns the value of the "source_id" field in the mutation.
  8445. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  8446. v := m.sop_stage
  8447. if v == nil {
  8448. return
  8449. }
  8450. return *v, true
  8451. }
  8452. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  8453. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8455. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  8456. if !m.op.Is(OpUpdateOne) {
  8457. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  8458. }
  8459. if m.id == nil || m.oldValue == nil {
  8460. return v, errors.New("OldSourceID requires an ID field in the mutation")
  8461. }
  8462. oldValue, err := m.oldValue(ctx)
  8463. if err != nil {
  8464. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  8465. }
  8466. return oldValue.SourceID, nil
  8467. }
  8468. // ClearSourceID clears the value of the "source_id" field.
  8469. func (m *MessageRecordsMutation) ClearSourceID() {
  8470. m.sop_stage = nil
  8471. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  8472. }
  8473. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  8474. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  8475. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  8476. return ok
  8477. }
  8478. // ResetSourceID resets all changes to the "source_id" field.
  8479. func (m *MessageRecordsMutation) ResetSourceID() {
  8480. m.sop_stage = nil
  8481. delete(m.clearedFields, messagerecords.FieldSourceID)
  8482. }
  8483. // SetSubSourceID sets the "sub_source_id" field.
  8484. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  8485. m.sop_node = &u
  8486. }
  8487. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  8488. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  8489. v := m.sop_node
  8490. if v == nil {
  8491. return
  8492. }
  8493. return *v, true
  8494. }
  8495. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  8496. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8497. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8498. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  8499. if !m.op.Is(OpUpdateOne) {
  8500. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  8501. }
  8502. if m.id == nil || m.oldValue == nil {
  8503. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  8504. }
  8505. oldValue, err := m.oldValue(ctx)
  8506. if err != nil {
  8507. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  8508. }
  8509. return oldValue.SubSourceID, nil
  8510. }
  8511. // ClearSubSourceID clears the value of the "sub_source_id" field.
  8512. func (m *MessageRecordsMutation) ClearSubSourceID() {
  8513. m.sop_node = nil
  8514. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  8515. }
  8516. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  8517. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  8518. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  8519. return ok
  8520. }
  8521. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  8522. func (m *MessageRecordsMutation) ResetSubSourceID() {
  8523. m.sop_node = nil
  8524. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  8525. }
  8526. // SetOrganizationID sets the "organization_id" field.
  8527. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  8528. m.organization_id = &u
  8529. m.addorganization_id = nil
  8530. }
  8531. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8532. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  8533. v := m.organization_id
  8534. if v == nil {
  8535. return
  8536. }
  8537. return *v, true
  8538. }
  8539. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  8540. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8542. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8543. if !m.op.Is(OpUpdateOne) {
  8544. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8545. }
  8546. if m.id == nil || m.oldValue == nil {
  8547. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8548. }
  8549. oldValue, err := m.oldValue(ctx)
  8550. if err != nil {
  8551. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8552. }
  8553. return oldValue.OrganizationID, nil
  8554. }
  8555. // AddOrganizationID adds u to the "organization_id" field.
  8556. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  8557. if m.addorganization_id != nil {
  8558. *m.addorganization_id += u
  8559. } else {
  8560. m.addorganization_id = &u
  8561. }
  8562. }
  8563. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8564. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  8565. v := m.addorganization_id
  8566. if v == nil {
  8567. return
  8568. }
  8569. return *v, true
  8570. }
  8571. // ClearOrganizationID clears the value of the "organization_id" field.
  8572. func (m *MessageRecordsMutation) ClearOrganizationID() {
  8573. m.organization_id = nil
  8574. m.addorganization_id = nil
  8575. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  8576. }
  8577. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  8578. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  8579. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  8580. return ok
  8581. }
  8582. // ResetOrganizationID resets all changes to the "organization_id" field.
  8583. func (m *MessageRecordsMutation) ResetOrganizationID() {
  8584. m.organization_id = nil
  8585. m.addorganization_id = nil
  8586. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  8587. }
  8588. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  8589. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  8590. m.sop_stage = &id
  8591. }
  8592. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  8593. func (m *MessageRecordsMutation) ClearSopStage() {
  8594. m.clearedsop_stage = true
  8595. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  8596. }
  8597. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  8598. func (m *MessageRecordsMutation) SopStageCleared() bool {
  8599. return m.SourceIDCleared() || m.clearedsop_stage
  8600. }
  8601. // SopStageID returns the "sop_stage" edge ID in the mutation.
  8602. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  8603. if m.sop_stage != nil {
  8604. return *m.sop_stage, true
  8605. }
  8606. return
  8607. }
  8608. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  8609. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  8610. // SopStageID instead. It exists only for internal usage by the builders.
  8611. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  8612. if id := m.sop_stage; id != nil {
  8613. ids = append(ids, *id)
  8614. }
  8615. return
  8616. }
  8617. // ResetSopStage resets all changes to the "sop_stage" edge.
  8618. func (m *MessageRecordsMutation) ResetSopStage() {
  8619. m.sop_stage = nil
  8620. m.clearedsop_stage = false
  8621. }
  8622. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  8623. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  8624. m.sop_node = &id
  8625. }
  8626. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  8627. func (m *MessageRecordsMutation) ClearSopNode() {
  8628. m.clearedsop_node = true
  8629. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  8630. }
  8631. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  8632. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  8633. return m.SubSourceIDCleared() || m.clearedsop_node
  8634. }
  8635. // SopNodeID returns the "sop_node" edge ID in the mutation.
  8636. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  8637. if m.sop_node != nil {
  8638. return *m.sop_node, true
  8639. }
  8640. return
  8641. }
  8642. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  8643. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  8644. // SopNodeID instead. It exists only for internal usage by the builders.
  8645. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  8646. if id := m.sop_node; id != nil {
  8647. ids = append(ids, *id)
  8648. }
  8649. return
  8650. }
  8651. // ResetSopNode resets all changes to the "sop_node" edge.
  8652. func (m *MessageRecordsMutation) ResetSopNode() {
  8653. m.sop_node = nil
  8654. m.clearedsop_node = false
  8655. }
  8656. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  8657. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  8658. m.message_contact = &id
  8659. }
  8660. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  8661. func (m *MessageRecordsMutation) ClearMessageContact() {
  8662. m.clearedmessage_contact = true
  8663. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  8664. }
  8665. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  8666. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  8667. return m.ContactIDCleared() || m.clearedmessage_contact
  8668. }
  8669. // MessageContactID returns the "message_contact" edge ID in the mutation.
  8670. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  8671. if m.message_contact != nil {
  8672. return *m.message_contact, true
  8673. }
  8674. return
  8675. }
  8676. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  8677. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  8678. // MessageContactID instead. It exists only for internal usage by the builders.
  8679. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  8680. if id := m.message_contact; id != nil {
  8681. ids = append(ids, *id)
  8682. }
  8683. return
  8684. }
  8685. // ResetMessageContact resets all changes to the "message_contact" edge.
  8686. func (m *MessageRecordsMutation) ResetMessageContact() {
  8687. m.message_contact = nil
  8688. m.clearedmessage_contact = false
  8689. }
  8690. // Where appends a list predicates to the MessageRecordsMutation builder.
  8691. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  8692. m.predicates = append(m.predicates, ps...)
  8693. }
  8694. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  8695. // users can use type-assertion to append predicates that do not depend on any generated package.
  8696. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  8697. p := make([]predicate.MessageRecords, len(ps))
  8698. for i := range ps {
  8699. p[i] = ps[i]
  8700. }
  8701. m.Where(p...)
  8702. }
  8703. // Op returns the operation name.
  8704. func (m *MessageRecordsMutation) Op() Op {
  8705. return m.op
  8706. }
  8707. // SetOp allows setting the mutation operation.
  8708. func (m *MessageRecordsMutation) SetOp(op Op) {
  8709. m.op = op
  8710. }
  8711. // Type returns the node type of this mutation (MessageRecords).
  8712. func (m *MessageRecordsMutation) Type() string {
  8713. return m.typ
  8714. }
  8715. // Fields returns all fields that were changed during this mutation. Note that in
  8716. // order to get all numeric fields that were incremented/decremented, call
  8717. // AddedFields().
  8718. func (m *MessageRecordsMutation) Fields() []string {
  8719. fields := make([]string, 0, 17)
  8720. if m.created_at != nil {
  8721. fields = append(fields, messagerecords.FieldCreatedAt)
  8722. }
  8723. if m.updated_at != nil {
  8724. fields = append(fields, messagerecords.FieldUpdatedAt)
  8725. }
  8726. if m.status != nil {
  8727. fields = append(fields, messagerecords.FieldStatus)
  8728. }
  8729. if m.deleted_at != nil {
  8730. fields = append(fields, messagerecords.FieldDeletedAt)
  8731. }
  8732. if m.bot_wxid != nil {
  8733. fields = append(fields, messagerecords.FieldBotWxid)
  8734. }
  8735. if m.message_contact != nil {
  8736. fields = append(fields, messagerecords.FieldContactID)
  8737. }
  8738. if m.contact_type != nil {
  8739. fields = append(fields, messagerecords.FieldContactType)
  8740. }
  8741. if m.contact_wxid != nil {
  8742. fields = append(fields, messagerecords.FieldContactWxid)
  8743. }
  8744. if m.content_type != nil {
  8745. fields = append(fields, messagerecords.FieldContentType)
  8746. }
  8747. if m.content != nil {
  8748. fields = append(fields, messagerecords.FieldContent)
  8749. }
  8750. if m.meta != nil {
  8751. fields = append(fields, messagerecords.FieldMeta)
  8752. }
  8753. if m.error_detail != nil {
  8754. fields = append(fields, messagerecords.FieldErrorDetail)
  8755. }
  8756. if m.send_time != nil {
  8757. fields = append(fields, messagerecords.FieldSendTime)
  8758. }
  8759. if m.source_type != nil {
  8760. fields = append(fields, messagerecords.FieldSourceType)
  8761. }
  8762. if m.sop_stage != nil {
  8763. fields = append(fields, messagerecords.FieldSourceID)
  8764. }
  8765. if m.sop_node != nil {
  8766. fields = append(fields, messagerecords.FieldSubSourceID)
  8767. }
  8768. if m.organization_id != nil {
  8769. fields = append(fields, messagerecords.FieldOrganizationID)
  8770. }
  8771. return fields
  8772. }
  8773. // Field returns the value of a field with the given name. The second boolean
  8774. // return value indicates that this field was not set, or was not defined in the
  8775. // schema.
  8776. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  8777. switch name {
  8778. case messagerecords.FieldCreatedAt:
  8779. return m.CreatedAt()
  8780. case messagerecords.FieldUpdatedAt:
  8781. return m.UpdatedAt()
  8782. case messagerecords.FieldStatus:
  8783. return m.Status()
  8784. case messagerecords.FieldDeletedAt:
  8785. return m.DeletedAt()
  8786. case messagerecords.FieldBotWxid:
  8787. return m.BotWxid()
  8788. case messagerecords.FieldContactID:
  8789. return m.ContactID()
  8790. case messagerecords.FieldContactType:
  8791. return m.ContactType()
  8792. case messagerecords.FieldContactWxid:
  8793. return m.ContactWxid()
  8794. case messagerecords.FieldContentType:
  8795. return m.ContentType()
  8796. case messagerecords.FieldContent:
  8797. return m.Content()
  8798. case messagerecords.FieldMeta:
  8799. return m.Meta()
  8800. case messagerecords.FieldErrorDetail:
  8801. return m.ErrorDetail()
  8802. case messagerecords.FieldSendTime:
  8803. return m.SendTime()
  8804. case messagerecords.FieldSourceType:
  8805. return m.SourceType()
  8806. case messagerecords.FieldSourceID:
  8807. return m.SourceID()
  8808. case messagerecords.FieldSubSourceID:
  8809. return m.SubSourceID()
  8810. case messagerecords.FieldOrganizationID:
  8811. return m.OrganizationID()
  8812. }
  8813. return nil, false
  8814. }
  8815. // OldField returns the old value of the field from the database. An error is
  8816. // returned if the mutation operation is not UpdateOne, or the query to the
  8817. // database failed.
  8818. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8819. switch name {
  8820. case messagerecords.FieldCreatedAt:
  8821. return m.OldCreatedAt(ctx)
  8822. case messagerecords.FieldUpdatedAt:
  8823. return m.OldUpdatedAt(ctx)
  8824. case messagerecords.FieldStatus:
  8825. return m.OldStatus(ctx)
  8826. case messagerecords.FieldDeletedAt:
  8827. return m.OldDeletedAt(ctx)
  8828. case messagerecords.FieldBotWxid:
  8829. return m.OldBotWxid(ctx)
  8830. case messagerecords.FieldContactID:
  8831. return m.OldContactID(ctx)
  8832. case messagerecords.FieldContactType:
  8833. return m.OldContactType(ctx)
  8834. case messagerecords.FieldContactWxid:
  8835. return m.OldContactWxid(ctx)
  8836. case messagerecords.FieldContentType:
  8837. return m.OldContentType(ctx)
  8838. case messagerecords.FieldContent:
  8839. return m.OldContent(ctx)
  8840. case messagerecords.FieldMeta:
  8841. return m.OldMeta(ctx)
  8842. case messagerecords.FieldErrorDetail:
  8843. return m.OldErrorDetail(ctx)
  8844. case messagerecords.FieldSendTime:
  8845. return m.OldSendTime(ctx)
  8846. case messagerecords.FieldSourceType:
  8847. return m.OldSourceType(ctx)
  8848. case messagerecords.FieldSourceID:
  8849. return m.OldSourceID(ctx)
  8850. case messagerecords.FieldSubSourceID:
  8851. return m.OldSubSourceID(ctx)
  8852. case messagerecords.FieldOrganizationID:
  8853. return m.OldOrganizationID(ctx)
  8854. }
  8855. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  8856. }
  8857. // SetField sets the value of a field with the given name. It returns an error if
  8858. // the field is not defined in the schema, or if the type mismatched the field
  8859. // type.
  8860. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  8861. switch name {
  8862. case messagerecords.FieldCreatedAt:
  8863. v, ok := value.(time.Time)
  8864. if !ok {
  8865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8866. }
  8867. m.SetCreatedAt(v)
  8868. return nil
  8869. case messagerecords.FieldUpdatedAt:
  8870. v, ok := value.(time.Time)
  8871. if !ok {
  8872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8873. }
  8874. m.SetUpdatedAt(v)
  8875. return nil
  8876. case messagerecords.FieldStatus:
  8877. v, ok := value.(uint8)
  8878. if !ok {
  8879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8880. }
  8881. m.SetStatus(v)
  8882. return nil
  8883. case messagerecords.FieldDeletedAt:
  8884. v, ok := value.(time.Time)
  8885. if !ok {
  8886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8887. }
  8888. m.SetDeletedAt(v)
  8889. return nil
  8890. case messagerecords.FieldBotWxid:
  8891. v, ok := value.(string)
  8892. if !ok {
  8893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8894. }
  8895. m.SetBotWxid(v)
  8896. return nil
  8897. case messagerecords.FieldContactID:
  8898. v, ok := value.(uint64)
  8899. if !ok {
  8900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8901. }
  8902. m.SetContactID(v)
  8903. return nil
  8904. case messagerecords.FieldContactType:
  8905. v, ok := value.(int)
  8906. if !ok {
  8907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8908. }
  8909. m.SetContactType(v)
  8910. return nil
  8911. case messagerecords.FieldContactWxid:
  8912. v, ok := value.(string)
  8913. if !ok {
  8914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8915. }
  8916. m.SetContactWxid(v)
  8917. return nil
  8918. case messagerecords.FieldContentType:
  8919. v, ok := value.(int)
  8920. if !ok {
  8921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8922. }
  8923. m.SetContentType(v)
  8924. return nil
  8925. case messagerecords.FieldContent:
  8926. v, ok := value.(string)
  8927. if !ok {
  8928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8929. }
  8930. m.SetContent(v)
  8931. return nil
  8932. case messagerecords.FieldMeta:
  8933. v, ok := value.(custom_types.Meta)
  8934. if !ok {
  8935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8936. }
  8937. m.SetMeta(v)
  8938. return nil
  8939. case messagerecords.FieldErrorDetail:
  8940. v, ok := value.(string)
  8941. if !ok {
  8942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8943. }
  8944. m.SetErrorDetail(v)
  8945. return nil
  8946. case messagerecords.FieldSendTime:
  8947. v, ok := value.(time.Time)
  8948. if !ok {
  8949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8950. }
  8951. m.SetSendTime(v)
  8952. return nil
  8953. case messagerecords.FieldSourceType:
  8954. v, ok := value.(int)
  8955. if !ok {
  8956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8957. }
  8958. m.SetSourceType(v)
  8959. return nil
  8960. case messagerecords.FieldSourceID:
  8961. v, ok := value.(uint64)
  8962. if !ok {
  8963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8964. }
  8965. m.SetSourceID(v)
  8966. return nil
  8967. case messagerecords.FieldSubSourceID:
  8968. v, ok := value.(uint64)
  8969. if !ok {
  8970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8971. }
  8972. m.SetSubSourceID(v)
  8973. return nil
  8974. case messagerecords.FieldOrganizationID:
  8975. v, ok := value.(uint64)
  8976. if !ok {
  8977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8978. }
  8979. m.SetOrganizationID(v)
  8980. return nil
  8981. }
  8982. return fmt.Errorf("unknown MessageRecords field %s", name)
  8983. }
  8984. // AddedFields returns all numeric fields that were incremented/decremented during
  8985. // this mutation.
  8986. func (m *MessageRecordsMutation) AddedFields() []string {
  8987. var fields []string
  8988. if m.addstatus != nil {
  8989. fields = append(fields, messagerecords.FieldStatus)
  8990. }
  8991. if m.addcontact_type != nil {
  8992. fields = append(fields, messagerecords.FieldContactType)
  8993. }
  8994. if m.addcontent_type != nil {
  8995. fields = append(fields, messagerecords.FieldContentType)
  8996. }
  8997. if m.addsource_type != nil {
  8998. fields = append(fields, messagerecords.FieldSourceType)
  8999. }
  9000. if m.addorganization_id != nil {
  9001. fields = append(fields, messagerecords.FieldOrganizationID)
  9002. }
  9003. return fields
  9004. }
  9005. // AddedField returns the numeric value that was incremented/decremented on a field
  9006. // with the given name. The second boolean return value indicates that this field
  9007. // was not set, or was not defined in the schema.
  9008. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  9009. switch name {
  9010. case messagerecords.FieldStatus:
  9011. return m.AddedStatus()
  9012. case messagerecords.FieldContactType:
  9013. return m.AddedContactType()
  9014. case messagerecords.FieldContentType:
  9015. return m.AddedContentType()
  9016. case messagerecords.FieldSourceType:
  9017. return m.AddedSourceType()
  9018. case messagerecords.FieldOrganizationID:
  9019. return m.AddedOrganizationID()
  9020. }
  9021. return nil, false
  9022. }
  9023. // AddField adds the value to the field with the given name. It returns an error if
  9024. // the field is not defined in the schema, or if the type mismatched the field
  9025. // type.
  9026. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  9027. switch name {
  9028. case messagerecords.FieldStatus:
  9029. v, ok := value.(int8)
  9030. if !ok {
  9031. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9032. }
  9033. m.AddStatus(v)
  9034. return nil
  9035. case messagerecords.FieldContactType:
  9036. v, ok := value.(int)
  9037. if !ok {
  9038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9039. }
  9040. m.AddContactType(v)
  9041. return nil
  9042. case messagerecords.FieldContentType:
  9043. v, ok := value.(int)
  9044. if !ok {
  9045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9046. }
  9047. m.AddContentType(v)
  9048. return nil
  9049. case messagerecords.FieldSourceType:
  9050. v, ok := value.(int)
  9051. if !ok {
  9052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9053. }
  9054. m.AddSourceType(v)
  9055. return nil
  9056. case messagerecords.FieldOrganizationID:
  9057. v, ok := value.(int64)
  9058. if !ok {
  9059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9060. }
  9061. m.AddOrganizationID(v)
  9062. return nil
  9063. }
  9064. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  9065. }
  9066. // ClearedFields returns all nullable fields that were cleared during this
  9067. // mutation.
  9068. func (m *MessageRecordsMutation) ClearedFields() []string {
  9069. var fields []string
  9070. if m.FieldCleared(messagerecords.FieldStatus) {
  9071. fields = append(fields, messagerecords.FieldStatus)
  9072. }
  9073. if m.FieldCleared(messagerecords.FieldDeletedAt) {
  9074. fields = append(fields, messagerecords.FieldDeletedAt)
  9075. }
  9076. if m.FieldCleared(messagerecords.FieldContactID) {
  9077. fields = append(fields, messagerecords.FieldContactID)
  9078. }
  9079. if m.FieldCleared(messagerecords.FieldMeta) {
  9080. fields = append(fields, messagerecords.FieldMeta)
  9081. }
  9082. if m.FieldCleared(messagerecords.FieldSendTime) {
  9083. fields = append(fields, messagerecords.FieldSendTime)
  9084. }
  9085. if m.FieldCleared(messagerecords.FieldSourceID) {
  9086. fields = append(fields, messagerecords.FieldSourceID)
  9087. }
  9088. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  9089. fields = append(fields, messagerecords.FieldSubSourceID)
  9090. }
  9091. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  9092. fields = append(fields, messagerecords.FieldOrganizationID)
  9093. }
  9094. return fields
  9095. }
  9096. // FieldCleared returns a boolean indicating if a field with the given name was
  9097. // cleared in this mutation.
  9098. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  9099. _, ok := m.clearedFields[name]
  9100. return ok
  9101. }
  9102. // ClearField clears the value of the field with the given name. It returns an
  9103. // error if the field is not defined in the schema.
  9104. func (m *MessageRecordsMutation) ClearField(name string) error {
  9105. switch name {
  9106. case messagerecords.FieldStatus:
  9107. m.ClearStatus()
  9108. return nil
  9109. case messagerecords.FieldDeletedAt:
  9110. m.ClearDeletedAt()
  9111. return nil
  9112. case messagerecords.FieldContactID:
  9113. m.ClearContactID()
  9114. return nil
  9115. case messagerecords.FieldMeta:
  9116. m.ClearMeta()
  9117. return nil
  9118. case messagerecords.FieldSendTime:
  9119. m.ClearSendTime()
  9120. return nil
  9121. case messagerecords.FieldSourceID:
  9122. m.ClearSourceID()
  9123. return nil
  9124. case messagerecords.FieldSubSourceID:
  9125. m.ClearSubSourceID()
  9126. return nil
  9127. case messagerecords.FieldOrganizationID:
  9128. m.ClearOrganizationID()
  9129. return nil
  9130. }
  9131. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  9132. }
  9133. // ResetField resets all changes in the mutation for the field with the given name.
  9134. // It returns an error if the field is not defined in the schema.
  9135. func (m *MessageRecordsMutation) ResetField(name string) error {
  9136. switch name {
  9137. case messagerecords.FieldCreatedAt:
  9138. m.ResetCreatedAt()
  9139. return nil
  9140. case messagerecords.FieldUpdatedAt:
  9141. m.ResetUpdatedAt()
  9142. return nil
  9143. case messagerecords.FieldStatus:
  9144. m.ResetStatus()
  9145. return nil
  9146. case messagerecords.FieldDeletedAt:
  9147. m.ResetDeletedAt()
  9148. return nil
  9149. case messagerecords.FieldBotWxid:
  9150. m.ResetBotWxid()
  9151. return nil
  9152. case messagerecords.FieldContactID:
  9153. m.ResetContactID()
  9154. return nil
  9155. case messagerecords.FieldContactType:
  9156. m.ResetContactType()
  9157. return nil
  9158. case messagerecords.FieldContactWxid:
  9159. m.ResetContactWxid()
  9160. return nil
  9161. case messagerecords.FieldContentType:
  9162. m.ResetContentType()
  9163. return nil
  9164. case messagerecords.FieldContent:
  9165. m.ResetContent()
  9166. return nil
  9167. case messagerecords.FieldMeta:
  9168. m.ResetMeta()
  9169. return nil
  9170. case messagerecords.FieldErrorDetail:
  9171. m.ResetErrorDetail()
  9172. return nil
  9173. case messagerecords.FieldSendTime:
  9174. m.ResetSendTime()
  9175. return nil
  9176. case messagerecords.FieldSourceType:
  9177. m.ResetSourceType()
  9178. return nil
  9179. case messagerecords.FieldSourceID:
  9180. m.ResetSourceID()
  9181. return nil
  9182. case messagerecords.FieldSubSourceID:
  9183. m.ResetSubSourceID()
  9184. return nil
  9185. case messagerecords.FieldOrganizationID:
  9186. m.ResetOrganizationID()
  9187. return nil
  9188. }
  9189. return fmt.Errorf("unknown MessageRecords field %s", name)
  9190. }
  9191. // AddedEdges returns all edge names that were set/added in this mutation.
  9192. func (m *MessageRecordsMutation) AddedEdges() []string {
  9193. edges := make([]string, 0, 3)
  9194. if m.sop_stage != nil {
  9195. edges = append(edges, messagerecords.EdgeSopStage)
  9196. }
  9197. if m.sop_node != nil {
  9198. edges = append(edges, messagerecords.EdgeSopNode)
  9199. }
  9200. if m.message_contact != nil {
  9201. edges = append(edges, messagerecords.EdgeMessageContact)
  9202. }
  9203. return edges
  9204. }
  9205. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9206. // name in this mutation.
  9207. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  9208. switch name {
  9209. case messagerecords.EdgeSopStage:
  9210. if id := m.sop_stage; id != nil {
  9211. return []ent.Value{*id}
  9212. }
  9213. case messagerecords.EdgeSopNode:
  9214. if id := m.sop_node; id != nil {
  9215. return []ent.Value{*id}
  9216. }
  9217. case messagerecords.EdgeMessageContact:
  9218. if id := m.message_contact; id != nil {
  9219. return []ent.Value{*id}
  9220. }
  9221. }
  9222. return nil
  9223. }
  9224. // RemovedEdges returns all edge names that were removed in this mutation.
  9225. func (m *MessageRecordsMutation) RemovedEdges() []string {
  9226. edges := make([]string, 0, 3)
  9227. return edges
  9228. }
  9229. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9230. // the given name in this mutation.
  9231. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  9232. return nil
  9233. }
  9234. // ClearedEdges returns all edge names that were cleared in this mutation.
  9235. func (m *MessageRecordsMutation) ClearedEdges() []string {
  9236. edges := make([]string, 0, 3)
  9237. if m.clearedsop_stage {
  9238. edges = append(edges, messagerecords.EdgeSopStage)
  9239. }
  9240. if m.clearedsop_node {
  9241. edges = append(edges, messagerecords.EdgeSopNode)
  9242. }
  9243. if m.clearedmessage_contact {
  9244. edges = append(edges, messagerecords.EdgeMessageContact)
  9245. }
  9246. return edges
  9247. }
  9248. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9249. // was cleared in this mutation.
  9250. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  9251. switch name {
  9252. case messagerecords.EdgeSopStage:
  9253. return m.clearedsop_stage
  9254. case messagerecords.EdgeSopNode:
  9255. return m.clearedsop_node
  9256. case messagerecords.EdgeMessageContact:
  9257. return m.clearedmessage_contact
  9258. }
  9259. return false
  9260. }
  9261. // ClearEdge clears the value of the edge with the given name. It returns an error
  9262. // if that edge is not defined in the schema.
  9263. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  9264. switch name {
  9265. case messagerecords.EdgeSopStage:
  9266. m.ClearSopStage()
  9267. return nil
  9268. case messagerecords.EdgeSopNode:
  9269. m.ClearSopNode()
  9270. return nil
  9271. case messagerecords.EdgeMessageContact:
  9272. m.ClearMessageContact()
  9273. return nil
  9274. }
  9275. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  9276. }
  9277. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9278. // It returns an error if the edge is not defined in the schema.
  9279. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  9280. switch name {
  9281. case messagerecords.EdgeSopStage:
  9282. m.ResetSopStage()
  9283. return nil
  9284. case messagerecords.EdgeSopNode:
  9285. m.ResetSopNode()
  9286. return nil
  9287. case messagerecords.EdgeMessageContact:
  9288. m.ResetMessageContact()
  9289. return nil
  9290. }
  9291. return fmt.Errorf("unknown MessageRecords edge %s", name)
  9292. }
  9293. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  9294. type MsgMutation struct {
  9295. config
  9296. op Op
  9297. typ string
  9298. id *uint64
  9299. created_at *time.Time
  9300. updated_at *time.Time
  9301. deleted_at *time.Time
  9302. status *uint8
  9303. addstatus *int8
  9304. fromwxid *string
  9305. toid *string
  9306. msgtype *int32
  9307. addmsgtype *int32
  9308. msg *string
  9309. batch_no *string
  9310. clearedFields map[string]struct{}
  9311. done bool
  9312. oldValue func(context.Context) (*Msg, error)
  9313. predicates []predicate.Msg
  9314. }
  9315. var _ ent.Mutation = (*MsgMutation)(nil)
  9316. // msgOption allows management of the mutation configuration using functional options.
  9317. type msgOption func(*MsgMutation)
  9318. // newMsgMutation creates new mutation for the Msg entity.
  9319. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  9320. m := &MsgMutation{
  9321. config: c,
  9322. op: op,
  9323. typ: TypeMsg,
  9324. clearedFields: make(map[string]struct{}),
  9325. }
  9326. for _, opt := range opts {
  9327. opt(m)
  9328. }
  9329. return m
  9330. }
  9331. // withMsgID sets the ID field of the mutation.
  9332. func withMsgID(id uint64) msgOption {
  9333. return func(m *MsgMutation) {
  9334. var (
  9335. err error
  9336. once sync.Once
  9337. value *Msg
  9338. )
  9339. m.oldValue = func(ctx context.Context) (*Msg, error) {
  9340. once.Do(func() {
  9341. if m.done {
  9342. err = errors.New("querying old values post mutation is not allowed")
  9343. } else {
  9344. value, err = m.Client().Msg.Get(ctx, id)
  9345. }
  9346. })
  9347. return value, err
  9348. }
  9349. m.id = &id
  9350. }
  9351. }
  9352. // withMsg sets the old Msg of the mutation.
  9353. func withMsg(node *Msg) msgOption {
  9354. return func(m *MsgMutation) {
  9355. m.oldValue = func(context.Context) (*Msg, error) {
  9356. return node, nil
  9357. }
  9358. m.id = &node.ID
  9359. }
  9360. }
  9361. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9362. // executed in a transaction (ent.Tx), a transactional client is returned.
  9363. func (m MsgMutation) Client() *Client {
  9364. client := &Client{config: m.config}
  9365. client.init()
  9366. return client
  9367. }
  9368. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9369. // it returns an error otherwise.
  9370. func (m MsgMutation) Tx() (*Tx, error) {
  9371. if _, ok := m.driver.(*txDriver); !ok {
  9372. return nil, errors.New("ent: mutation is not running in a transaction")
  9373. }
  9374. tx := &Tx{config: m.config}
  9375. tx.init()
  9376. return tx, nil
  9377. }
  9378. // SetID sets the value of the id field. Note that this
  9379. // operation is only accepted on creation of Msg entities.
  9380. func (m *MsgMutation) SetID(id uint64) {
  9381. m.id = &id
  9382. }
  9383. // ID returns the ID value in the mutation. Note that the ID is only available
  9384. // if it was provided to the builder or after it was returned from the database.
  9385. func (m *MsgMutation) ID() (id uint64, exists bool) {
  9386. if m.id == nil {
  9387. return
  9388. }
  9389. return *m.id, true
  9390. }
  9391. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9392. // That means, if the mutation is applied within a transaction with an isolation level such
  9393. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9394. // or updated by the mutation.
  9395. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  9396. switch {
  9397. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9398. id, exists := m.ID()
  9399. if exists {
  9400. return []uint64{id}, nil
  9401. }
  9402. fallthrough
  9403. case m.op.Is(OpUpdate | OpDelete):
  9404. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  9405. default:
  9406. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9407. }
  9408. }
  9409. // SetCreatedAt sets the "created_at" field.
  9410. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  9411. m.created_at = &t
  9412. }
  9413. // CreatedAt returns the value of the "created_at" field in the mutation.
  9414. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  9415. v := m.created_at
  9416. if v == nil {
  9417. return
  9418. }
  9419. return *v, true
  9420. }
  9421. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  9422. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  9423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9424. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9425. if !m.op.Is(OpUpdateOne) {
  9426. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9427. }
  9428. if m.id == nil || m.oldValue == nil {
  9429. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9430. }
  9431. oldValue, err := m.oldValue(ctx)
  9432. if err != nil {
  9433. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9434. }
  9435. return oldValue.CreatedAt, nil
  9436. }
  9437. // ResetCreatedAt resets all changes to the "created_at" field.
  9438. func (m *MsgMutation) ResetCreatedAt() {
  9439. m.created_at = nil
  9440. }
  9441. // SetUpdatedAt sets the "updated_at" field.
  9442. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  9443. m.updated_at = &t
  9444. }
  9445. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9446. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  9447. v := m.updated_at
  9448. if v == nil {
  9449. return
  9450. }
  9451. return *v, true
  9452. }
  9453. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  9454. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  9455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9456. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9457. if !m.op.Is(OpUpdateOne) {
  9458. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9459. }
  9460. if m.id == nil || m.oldValue == nil {
  9461. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9462. }
  9463. oldValue, err := m.oldValue(ctx)
  9464. if err != nil {
  9465. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9466. }
  9467. return oldValue.UpdatedAt, nil
  9468. }
  9469. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9470. func (m *MsgMutation) ResetUpdatedAt() {
  9471. m.updated_at = nil
  9472. }
  9473. // SetDeletedAt sets the "deleted_at" field.
  9474. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  9475. m.deleted_at = &t
  9476. }
  9477. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9478. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  9479. v := m.deleted_at
  9480. if v == nil {
  9481. return
  9482. }
  9483. return *v, true
  9484. }
  9485. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  9486. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  9487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9488. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9489. if !m.op.Is(OpUpdateOne) {
  9490. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9491. }
  9492. if m.id == nil || m.oldValue == nil {
  9493. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9494. }
  9495. oldValue, err := m.oldValue(ctx)
  9496. if err != nil {
  9497. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9498. }
  9499. return oldValue.DeletedAt, nil
  9500. }
  9501. // ClearDeletedAt clears the value of the "deleted_at" field.
  9502. func (m *MsgMutation) ClearDeletedAt() {
  9503. m.deleted_at = nil
  9504. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  9505. }
  9506. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9507. func (m *MsgMutation) DeletedAtCleared() bool {
  9508. _, ok := m.clearedFields[msg.FieldDeletedAt]
  9509. return ok
  9510. }
  9511. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9512. func (m *MsgMutation) ResetDeletedAt() {
  9513. m.deleted_at = nil
  9514. delete(m.clearedFields, msg.FieldDeletedAt)
  9515. }
  9516. // SetStatus sets the "status" field.
  9517. func (m *MsgMutation) SetStatus(u uint8) {
  9518. m.status = &u
  9519. m.addstatus = nil
  9520. }
  9521. // Status returns the value of the "status" field in the mutation.
  9522. func (m *MsgMutation) Status() (r uint8, exists bool) {
  9523. v := m.status
  9524. if v == nil {
  9525. return
  9526. }
  9527. return *v, true
  9528. }
  9529. // OldStatus returns the old "status" field's value of the Msg entity.
  9530. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  9531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9532. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9533. if !m.op.Is(OpUpdateOne) {
  9534. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9535. }
  9536. if m.id == nil || m.oldValue == nil {
  9537. return v, errors.New("OldStatus requires an ID field in the mutation")
  9538. }
  9539. oldValue, err := m.oldValue(ctx)
  9540. if err != nil {
  9541. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9542. }
  9543. return oldValue.Status, nil
  9544. }
  9545. // AddStatus adds u to the "status" field.
  9546. func (m *MsgMutation) AddStatus(u int8) {
  9547. if m.addstatus != nil {
  9548. *m.addstatus += u
  9549. } else {
  9550. m.addstatus = &u
  9551. }
  9552. }
  9553. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9554. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  9555. v := m.addstatus
  9556. if v == nil {
  9557. return
  9558. }
  9559. return *v, true
  9560. }
  9561. // ClearStatus clears the value of the "status" field.
  9562. func (m *MsgMutation) ClearStatus() {
  9563. m.status = nil
  9564. m.addstatus = nil
  9565. m.clearedFields[msg.FieldStatus] = struct{}{}
  9566. }
  9567. // StatusCleared returns if the "status" field was cleared in this mutation.
  9568. func (m *MsgMutation) StatusCleared() bool {
  9569. _, ok := m.clearedFields[msg.FieldStatus]
  9570. return ok
  9571. }
  9572. // ResetStatus resets all changes to the "status" field.
  9573. func (m *MsgMutation) ResetStatus() {
  9574. m.status = nil
  9575. m.addstatus = nil
  9576. delete(m.clearedFields, msg.FieldStatus)
  9577. }
  9578. // SetFromwxid sets the "fromwxid" field.
  9579. func (m *MsgMutation) SetFromwxid(s string) {
  9580. m.fromwxid = &s
  9581. }
  9582. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  9583. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  9584. v := m.fromwxid
  9585. if v == nil {
  9586. return
  9587. }
  9588. return *v, true
  9589. }
  9590. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  9591. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  9592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9593. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  9594. if !m.op.Is(OpUpdateOne) {
  9595. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  9596. }
  9597. if m.id == nil || m.oldValue == nil {
  9598. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  9599. }
  9600. oldValue, err := m.oldValue(ctx)
  9601. if err != nil {
  9602. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  9603. }
  9604. return oldValue.Fromwxid, nil
  9605. }
  9606. // ClearFromwxid clears the value of the "fromwxid" field.
  9607. func (m *MsgMutation) ClearFromwxid() {
  9608. m.fromwxid = nil
  9609. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  9610. }
  9611. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  9612. func (m *MsgMutation) FromwxidCleared() bool {
  9613. _, ok := m.clearedFields[msg.FieldFromwxid]
  9614. return ok
  9615. }
  9616. // ResetFromwxid resets all changes to the "fromwxid" field.
  9617. func (m *MsgMutation) ResetFromwxid() {
  9618. m.fromwxid = nil
  9619. delete(m.clearedFields, msg.FieldFromwxid)
  9620. }
  9621. // SetToid sets the "toid" field.
  9622. func (m *MsgMutation) SetToid(s string) {
  9623. m.toid = &s
  9624. }
  9625. // Toid returns the value of the "toid" field in the mutation.
  9626. func (m *MsgMutation) Toid() (r string, exists bool) {
  9627. v := m.toid
  9628. if v == nil {
  9629. return
  9630. }
  9631. return *v, true
  9632. }
  9633. // OldToid returns the old "toid" field's value of the Msg entity.
  9634. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  9635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9636. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  9637. if !m.op.Is(OpUpdateOne) {
  9638. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  9639. }
  9640. if m.id == nil || m.oldValue == nil {
  9641. return v, errors.New("OldToid requires an ID field in the mutation")
  9642. }
  9643. oldValue, err := m.oldValue(ctx)
  9644. if err != nil {
  9645. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  9646. }
  9647. return oldValue.Toid, nil
  9648. }
  9649. // ClearToid clears the value of the "toid" field.
  9650. func (m *MsgMutation) ClearToid() {
  9651. m.toid = nil
  9652. m.clearedFields[msg.FieldToid] = struct{}{}
  9653. }
  9654. // ToidCleared returns if the "toid" field was cleared in this mutation.
  9655. func (m *MsgMutation) ToidCleared() bool {
  9656. _, ok := m.clearedFields[msg.FieldToid]
  9657. return ok
  9658. }
  9659. // ResetToid resets all changes to the "toid" field.
  9660. func (m *MsgMutation) ResetToid() {
  9661. m.toid = nil
  9662. delete(m.clearedFields, msg.FieldToid)
  9663. }
  9664. // SetMsgtype sets the "msgtype" field.
  9665. func (m *MsgMutation) SetMsgtype(i int32) {
  9666. m.msgtype = &i
  9667. m.addmsgtype = nil
  9668. }
  9669. // Msgtype returns the value of the "msgtype" field in the mutation.
  9670. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  9671. v := m.msgtype
  9672. if v == nil {
  9673. return
  9674. }
  9675. return *v, true
  9676. }
  9677. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  9678. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  9679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9680. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  9681. if !m.op.Is(OpUpdateOne) {
  9682. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  9683. }
  9684. if m.id == nil || m.oldValue == nil {
  9685. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  9686. }
  9687. oldValue, err := m.oldValue(ctx)
  9688. if err != nil {
  9689. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  9690. }
  9691. return oldValue.Msgtype, nil
  9692. }
  9693. // AddMsgtype adds i to the "msgtype" field.
  9694. func (m *MsgMutation) AddMsgtype(i int32) {
  9695. if m.addmsgtype != nil {
  9696. *m.addmsgtype += i
  9697. } else {
  9698. m.addmsgtype = &i
  9699. }
  9700. }
  9701. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  9702. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  9703. v := m.addmsgtype
  9704. if v == nil {
  9705. return
  9706. }
  9707. return *v, true
  9708. }
  9709. // ClearMsgtype clears the value of the "msgtype" field.
  9710. func (m *MsgMutation) ClearMsgtype() {
  9711. m.msgtype = nil
  9712. m.addmsgtype = nil
  9713. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  9714. }
  9715. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  9716. func (m *MsgMutation) MsgtypeCleared() bool {
  9717. _, ok := m.clearedFields[msg.FieldMsgtype]
  9718. return ok
  9719. }
  9720. // ResetMsgtype resets all changes to the "msgtype" field.
  9721. func (m *MsgMutation) ResetMsgtype() {
  9722. m.msgtype = nil
  9723. m.addmsgtype = nil
  9724. delete(m.clearedFields, msg.FieldMsgtype)
  9725. }
  9726. // SetMsg sets the "msg" field.
  9727. func (m *MsgMutation) SetMsg(s string) {
  9728. m.msg = &s
  9729. }
  9730. // Msg returns the value of the "msg" field in the mutation.
  9731. func (m *MsgMutation) Msg() (r string, exists bool) {
  9732. v := m.msg
  9733. if v == nil {
  9734. return
  9735. }
  9736. return *v, true
  9737. }
  9738. // OldMsg returns the old "msg" field's value of the Msg entity.
  9739. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  9740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9741. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  9742. if !m.op.Is(OpUpdateOne) {
  9743. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  9744. }
  9745. if m.id == nil || m.oldValue == nil {
  9746. return v, errors.New("OldMsg requires an ID field in the mutation")
  9747. }
  9748. oldValue, err := m.oldValue(ctx)
  9749. if err != nil {
  9750. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  9751. }
  9752. return oldValue.Msg, nil
  9753. }
  9754. // ClearMsg clears the value of the "msg" field.
  9755. func (m *MsgMutation) ClearMsg() {
  9756. m.msg = nil
  9757. m.clearedFields[msg.FieldMsg] = struct{}{}
  9758. }
  9759. // MsgCleared returns if the "msg" field was cleared in this mutation.
  9760. func (m *MsgMutation) MsgCleared() bool {
  9761. _, ok := m.clearedFields[msg.FieldMsg]
  9762. return ok
  9763. }
  9764. // ResetMsg resets all changes to the "msg" field.
  9765. func (m *MsgMutation) ResetMsg() {
  9766. m.msg = nil
  9767. delete(m.clearedFields, msg.FieldMsg)
  9768. }
  9769. // SetBatchNo sets the "batch_no" field.
  9770. func (m *MsgMutation) SetBatchNo(s string) {
  9771. m.batch_no = &s
  9772. }
  9773. // BatchNo returns the value of the "batch_no" field in the mutation.
  9774. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  9775. v := m.batch_no
  9776. if v == nil {
  9777. return
  9778. }
  9779. return *v, true
  9780. }
  9781. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  9782. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  9783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9784. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  9785. if !m.op.Is(OpUpdateOne) {
  9786. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  9787. }
  9788. if m.id == nil || m.oldValue == nil {
  9789. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  9790. }
  9791. oldValue, err := m.oldValue(ctx)
  9792. if err != nil {
  9793. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  9794. }
  9795. return oldValue.BatchNo, nil
  9796. }
  9797. // ClearBatchNo clears the value of the "batch_no" field.
  9798. func (m *MsgMutation) ClearBatchNo() {
  9799. m.batch_no = nil
  9800. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  9801. }
  9802. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  9803. func (m *MsgMutation) BatchNoCleared() bool {
  9804. _, ok := m.clearedFields[msg.FieldBatchNo]
  9805. return ok
  9806. }
  9807. // ResetBatchNo resets all changes to the "batch_no" field.
  9808. func (m *MsgMutation) ResetBatchNo() {
  9809. m.batch_no = nil
  9810. delete(m.clearedFields, msg.FieldBatchNo)
  9811. }
  9812. // Where appends a list predicates to the MsgMutation builder.
  9813. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  9814. m.predicates = append(m.predicates, ps...)
  9815. }
  9816. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  9817. // users can use type-assertion to append predicates that do not depend on any generated package.
  9818. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  9819. p := make([]predicate.Msg, len(ps))
  9820. for i := range ps {
  9821. p[i] = ps[i]
  9822. }
  9823. m.Where(p...)
  9824. }
  9825. // Op returns the operation name.
  9826. func (m *MsgMutation) Op() Op {
  9827. return m.op
  9828. }
  9829. // SetOp allows setting the mutation operation.
  9830. func (m *MsgMutation) SetOp(op Op) {
  9831. m.op = op
  9832. }
  9833. // Type returns the node type of this mutation (Msg).
  9834. func (m *MsgMutation) Type() string {
  9835. return m.typ
  9836. }
  9837. // Fields returns all fields that were changed during this mutation. Note that in
  9838. // order to get all numeric fields that were incremented/decremented, call
  9839. // AddedFields().
  9840. func (m *MsgMutation) Fields() []string {
  9841. fields := make([]string, 0, 9)
  9842. if m.created_at != nil {
  9843. fields = append(fields, msg.FieldCreatedAt)
  9844. }
  9845. if m.updated_at != nil {
  9846. fields = append(fields, msg.FieldUpdatedAt)
  9847. }
  9848. if m.deleted_at != nil {
  9849. fields = append(fields, msg.FieldDeletedAt)
  9850. }
  9851. if m.status != nil {
  9852. fields = append(fields, msg.FieldStatus)
  9853. }
  9854. if m.fromwxid != nil {
  9855. fields = append(fields, msg.FieldFromwxid)
  9856. }
  9857. if m.toid != nil {
  9858. fields = append(fields, msg.FieldToid)
  9859. }
  9860. if m.msgtype != nil {
  9861. fields = append(fields, msg.FieldMsgtype)
  9862. }
  9863. if m.msg != nil {
  9864. fields = append(fields, msg.FieldMsg)
  9865. }
  9866. if m.batch_no != nil {
  9867. fields = append(fields, msg.FieldBatchNo)
  9868. }
  9869. return fields
  9870. }
  9871. // Field returns the value of a field with the given name. The second boolean
  9872. // return value indicates that this field was not set, or was not defined in the
  9873. // schema.
  9874. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  9875. switch name {
  9876. case msg.FieldCreatedAt:
  9877. return m.CreatedAt()
  9878. case msg.FieldUpdatedAt:
  9879. return m.UpdatedAt()
  9880. case msg.FieldDeletedAt:
  9881. return m.DeletedAt()
  9882. case msg.FieldStatus:
  9883. return m.Status()
  9884. case msg.FieldFromwxid:
  9885. return m.Fromwxid()
  9886. case msg.FieldToid:
  9887. return m.Toid()
  9888. case msg.FieldMsgtype:
  9889. return m.Msgtype()
  9890. case msg.FieldMsg:
  9891. return m.Msg()
  9892. case msg.FieldBatchNo:
  9893. return m.BatchNo()
  9894. }
  9895. return nil, false
  9896. }
  9897. // OldField returns the old value of the field from the database. An error is
  9898. // returned if the mutation operation is not UpdateOne, or the query to the
  9899. // database failed.
  9900. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9901. switch name {
  9902. case msg.FieldCreatedAt:
  9903. return m.OldCreatedAt(ctx)
  9904. case msg.FieldUpdatedAt:
  9905. return m.OldUpdatedAt(ctx)
  9906. case msg.FieldDeletedAt:
  9907. return m.OldDeletedAt(ctx)
  9908. case msg.FieldStatus:
  9909. return m.OldStatus(ctx)
  9910. case msg.FieldFromwxid:
  9911. return m.OldFromwxid(ctx)
  9912. case msg.FieldToid:
  9913. return m.OldToid(ctx)
  9914. case msg.FieldMsgtype:
  9915. return m.OldMsgtype(ctx)
  9916. case msg.FieldMsg:
  9917. return m.OldMsg(ctx)
  9918. case msg.FieldBatchNo:
  9919. return m.OldBatchNo(ctx)
  9920. }
  9921. return nil, fmt.Errorf("unknown Msg field %s", name)
  9922. }
  9923. // SetField sets the value of a field with the given name. It returns an error if
  9924. // the field is not defined in the schema, or if the type mismatched the field
  9925. // type.
  9926. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  9927. switch name {
  9928. case msg.FieldCreatedAt:
  9929. v, ok := value.(time.Time)
  9930. if !ok {
  9931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9932. }
  9933. m.SetCreatedAt(v)
  9934. return nil
  9935. case msg.FieldUpdatedAt:
  9936. v, ok := value.(time.Time)
  9937. if !ok {
  9938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9939. }
  9940. m.SetUpdatedAt(v)
  9941. return nil
  9942. case msg.FieldDeletedAt:
  9943. v, ok := value.(time.Time)
  9944. if !ok {
  9945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9946. }
  9947. m.SetDeletedAt(v)
  9948. return nil
  9949. case msg.FieldStatus:
  9950. v, ok := value.(uint8)
  9951. if !ok {
  9952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9953. }
  9954. m.SetStatus(v)
  9955. return nil
  9956. case msg.FieldFromwxid:
  9957. v, ok := value.(string)
  9958. if !ok {
  9959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9960. }
  9961. m.SetFromwxid(v)
  9962. return nil
  9963. case msg.FieldToid:
  9964. v, ok := value.(string)
  9965. if !ok {
  9966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9967. }
  9968. m.SetToid(v)
  9969. return nil
  9970. case msg.FieldMsgtype:
  9971. v, ok := value.(int32)
  9972. if !ok {
  9973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9974. }
  9975. m.SetMsgtype(v)
  9976. return nil
  9977. case msg.FieldMsg:
  9978. v, ok := value.(string)
  9979. if !ok {
  9980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9981. }
  9982. m.SetMsg(v)
  9983. return nil
  9984. case msg.FieldBatchNo:
  9985. v, ok := value.(string)
  9986. if !ok {
  9987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9988. }
  9989. m.SetBatchNo(v)
  9990. return nil
  9991. }
  9992. return fmt.Errorf("unknown Msg field %s", name)
  9993. }
  9994. // AddedFields returns all numeric fields that were incremented/decremented during
  9995. // this mutation.
  9996. func (m *MsgMutation) AddedFields() []string {
  9997. var fields []string
  9998. if m.addstatus != nil {
  9999. fields = append(fields, msg.FieldStatus)
  10000. }
  10001. if m.addmsgtype != nil {
  10002. fields = append(fields, msg.FieldMsgtype)
  10003. }
  10004. return fields
  10005. }
  10006. // AddedField returns the numeric value that was incremented/decremented on a field
  10007. // with the given name. The second boolean return value indicates that this field
  10008. // was not set, or was not defined in the schema.
  10009. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  10010. switch name {
  10011. case msg.FieldStatus:
  10012. return m.AddedStatus()
  10013. case msg.FieldMsgtype:
  10014. return m.AddedMsgtype()
  10015. }
  10016. return nil, false
  10017. }
  10018. // AddField adds the value to the field with the given name. It returns an error if
  10019. // the field is not defined in the schema, or if the type mismatched the field
  10020. // type.
  10021. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  10022. switch name {
  10023. case msg.FieldStatus:
  10024. v, ok := value.(int8)
  10025. if !ok {
  10026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10027. }
  10028. m.AddStatus(v)
  10029. return nil
  10030. case msg.FieldMsgtype:
  10031. v, ok := value.(int32)
  10032. if !ok {
  10033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10034. }
  10035. m.AddMsgtype(v)
  10036. return nil
  10037. }
  10038. return fmt.Errorf("unknown Msg numeric field %s", name)
  10039. }
  10040. // ClearedFields returns all nullable fields that were cleared during this
  10041. // mutation.
  10042. func (m *MsgMutation) ClearedFields() []string {
  10043. var fields []string
  10044. if m.FieldCleared(msg.FieldDeletedAt) {
  10045. fields = append(fields, msg.FieldDeletedAt)
  10046. }
  10047. if m.FieldCleared(msg.FieldStatus) {
  10048. fields = append(fields, msg.FieldStatus)
  10049. }
  10050. if m.FieldCleared(msg.FieldFromwxid) {
  10051. fields = append(fields, msg.FieldFromwxid)
  10052. }
  10053. if m.FieldCleared(msg.FieldToid) {
  10054. fields = append(fields, msg.FieldToid)
  10055. }
  10056. if m.FieldCleared(msg.FieldMsgtype) {
  10057. fields = append(fields, msg.FieldMsgtype)
  10058. }
  10059. if m.FieldCleared(msg.FieldMsg) {
  10060. fields = append(fields, msg.FieldMsg)
  10061. }
  10062. if m.FieldCleared(msg.FieldBatchNo) {
  10063. fields = append(fields, msg.FieldBatchNo)
  10064. }
  10065. return fields
  10066. }
  10067. // FieldCleared returns a boolean indicating if a field with the given name was
  10068. // cleared in this mutation.
  10069. func (m *MsgMutation) FieldCleared(name string) bool {
  10070. _, ok := m.clearedFields[name]
  10071. return ok
  10072. }
  10073. // ClearField clears the value of the field with the given name. It returns an
  10074. // error if the field is not defined in the schema.
  10075. func (m *MsgMutation) ClearField(name string) error {
  10076. switch name {
  10077. case msg.FieldDeletedAt:
  10078. m.ClearDeletedAt()
  10079. return nil
  10080. case msg.FieldStatus:
  10081. m.ClearStatus()
  10082. return nil
  10083. case msg.FieldFromwxid:
  10084. m.ClearFromwxid()
  10085. return nil
  10086. case msg.FieldToid:
  10087. m.ClearToid()
  10088. return nil
  10089. case msg.FieldMsgtype:
  10090. m.ClearMsgtype()
  10091. return nil
  10092. case msg.FieldMsg:
  10093. m.ClearMsg()
  10094. return nil
  10095. case msg.FieldBatchNo:
  10096. m.ClearBatchNo()
  10097. return nil
  10098. }
  10099. return fmt.Errorf("unknown Msg nullable field %s", name)
  10100. }
  10101. // ResetField resets all changes in the mutation for the field with the given name.
  10102. // It returns an error if the field is not defined in the schema.
  10103. func (m *MsgMutation) ResetField(name string) error {
  10104. switch name {
  10105. case msg.FieldCreatedAt:
  10106. m.ResetCreatedAt()
  10107. return nil
  10108. case msg.FieldUpdatedAt:
  10109. m.ResetUpdatedAt()
  10110. return nil
  10111. case msg.FieldDeletedAt:
  10112. m.ResetDeletedAt()
  10113. return nil
  10114. case msg.FieldStatus:
  10115. m.ResetStatus()
  10116. return nil
  10117. case msg.FieldFromwxid:
  10118. m.ResetFromwxid()
  10119. return nil
  10120. case msg.FieldToid:
  10121. m.ResetToid()
  10122. return nil
  10123. case msg.FieldMsgtype:
  10124. m.ResetMsgtype()
  10125. return nil
  10126. case msg.FieldMsg:
  10127. m.ResetMsg()
  10128. return nil
  10129. case msg.FieldBatchNo:
  10130. m.ResetBatchNo()
  10131. return nil
  10132. }
  10133. return fmt.Errorf("unknown Msg field %s", name)
  10134. }
  10135. // AddedEdges returns all edge names that were set/added in this mutation.
  10136. func (m *MsgMutation) AddedEdges() []string {
  10137. edges := make([]string, 0, 0)
  10138. return edges
  10139. }
  10140. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10141. // name in this mutation.
  10142. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  10143. return nil
  10144. }
  10145. // RemovedEdges returns all edge names that were removed in this mutation.
  10146. func (m *MsgMutation) RemovedEdges() []string {
  10147. edges := make([]string, 0, 0)
  10148. return edges
  10149. }
  10150. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10151. // the given name in this mutation.
  10152. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  10153. return nil
  10154. }
  10155. // ClearedEdges returns all edge names that were cleared in this mutation.
  10156. func (m *MsgMutation) ClearedEdges() []string {
  10157. edges := make([]string, 0, 0)
  10158. return edges
  10159. }
  10160. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10161. // was cleared in this mutation.
  10162. func (m *MsgMutation) EdgeCleared(name string) bool {
  10163. return false
  10164. }
  10165. // ClearEdge clears the value of the edge with the given name. It returns an error
  10166. // if that edge is not defined in the schema.
  10167. func (m *MsgMutation) ClearEdge(name string) error {
  10168. return fmt.Errorf("unknown Msg unique edge %s", name)
  10169. }
  10170. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10171. // It returns an error if the edge is not defined in the schema.
  10172. func (m *MsgMutation) ResetEdge(name string) error {
  10173. return fmt.Errorf("unknown Msg edge %s", name)
  10174. }
  10175. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  10176. type ServerMutation struct {
  10177. config
  10178. op Op
  10179. typ string
  10180. id *uint64
  10181. created_at *time.Time
  10182. updated_at *time.Time
  10183. status *uint8
  10184. addstatus *int8
  10185. deleted_at *time.Time
  10186. name *string
  10187. public_ip *string
  10188. private_ip *string
  10189. admin_port *string
  10190. clearedFields map[string]struct{}
  10191. wxs map[uint64]struct{}
  10192. removedwxs map[uint64]struct{}
  10193. clearedwxs bool
  10194. done bool
  10195. oldValue func(context.Context) (*Server, error)
  10196. predicates []predicate.Server
  10197. }
  10198. var _ ent.Mutation = (*ServerMutation)(nil)
  10199. // serverOption allows management of the mutation configuration using functional options.
  10200. type serverOption func(*ServerMutation)
  10201. // newServerMutation creates new mutation for the Server entity.
  10202. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  10203. m := &ServerMutation{
  10204. config: c,
  10205. op: op,
  10206. typ: TypeServer,
  10207. clearedFields: make(map[string]struct{}),
  10208. }
  10209. for _, opt := range opts {
  10210. opt(m)
  10211. }
  10212. return m
  10213. }
  10214. // withServerID sets the ID field of the mutation.
  10215. func withServerID(id uint64) serverOption {
  10216. return func(m *ServerMutation) {
  10217. var (
  10218. err error
  10219. once sync.Once
  10220. value *Server
  10221. )
  10222. m.oldValue = func(ctx context.Context) (*Server, error) {
  10223. once.Do(func() {
  10224. if m.done {
  10225. err = errors.New("querying old values post mutation is not allowed")
  10226. } else {
  10227. value, err = m.Client().Server.Get(ctx, id)
  10228. }
  10229. })
  10230. return value, err
  10231. }
  10232. m.id = &id
  10233. }
  10234. }
  10235. // withServer sets the old Server of the mutation.
  10236. func withServer(node *Server) serverOption {
  10237. return func(m *ServerMutation) {
  10238. m.oldValue = func(context.Context) (*Server, error) {
  10239. return node, nil
  10240. }
  10241. m.id = &node.ID
  10242. }
  10243. }
  10244. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10245. // executed in a transaction (ent.Tx), a transactional client is returned.
  10246. func (m ServerMutation) Client() *Client {
  10247. client := &Client{config: m.config}
  10248. client.init()
  10249. return client
  10250. }
  10251. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10252. // it returns an error otherwise.
  10253. func (m ServerMutation) Tx() (*Tx, error) {
  10254. if _, ok := m.driver.(*txDriver); !ok {
  10255. return nil, errors.New("ent: mutation is not running in a transaction")
  10256. }
  10257. tx := &Tx{config: m.config}
  10258. tx.init()
  10259. return tx, nil
  10260. }
  10261. // SetID sets the value of the id field. Note that this
  10262. // operation is only accepted on creation of Server entities.
  10263. func (m *ServerMutation) SetID(id uint64) {
  10264. m.id = &id
  10265. }
  10266. // ID returns the ID value in the mutation. Note that the ID is only available
  10267. // if it was provided to the builder or after it was returned from the database.
  10268. func (m *ServerMutation) ID() (id uint64, exists bool) {
  10269. if m.id == nil {
  10270. return
  10271. }
  10272. return *m.id, true
  10273. }
  10274. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10275. // That means, if the mutation is applied within a transaction with an isolation level such
  10276. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10277. // or updated by the mutation.
  10278. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  10279. switch {
  10280. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10281. id, exists := m.ID()
  10282. if exists {
  10283. return []uint64{id}, nil
  10284. }
  10285. fallthrough
  10286. case m.op.Is(OpUpdate | OpDelete):
  10287. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  10288. default:
  10289. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10290. }
  10291. }
  10292. // SetCreatedAt sets the "created_at" field.
  10293. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  10294. m.created_at = &t
  10295. }
  10296. // CreatedAt returns the value of the "created_at" field in the mutation.
  10297. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  10298. v := m.created_at
  10299. if v == nil {
  10300. return
  10301. }
  10302. return *v, true
  10303. }
  10304. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  10305. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  10306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10307. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10308. if !m.op.Is(OpUpdateOne) {
  10309. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10310. }
  10311. if m.id == nil || m.oldValue == nil {
  10312. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10313. }
  10314. oldValue, err := m.oldValue(ctx)
  10315. if err != nil {
  10316. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10317. }
  10318. return oldValue.CreatedAt, nil
  10319. }
  10320. // ResetCreatedAt resets all changes to the "created_at" field.
  10321. func (m *ServerMutation) ResetCreatedAt() {
  10322. m.created_at = nil
  10323. }
  10324. // SetUpdatedAt sets the "updated_at" field.
  10325. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  10326. m.updated_at = &t
  10327. }
  10328. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10329. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  10330. v := m.updated_at
  10331. if v == nil {
  10332. return
  10333. }
  10334. return *v, true
  10335. }
  10336. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  10337. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  10338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10339. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10340. if !m.op.Is(OpUpdateOne) {
  10341. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10342. }
  10343. if m.id == nil || m.oldValue == nil {
  10344. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10345. }
  10346. oldValue, err := m.oldValue(ctx)
  10347. if err != nil {
  10348. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10349. }
  10350. return oldValue.UpdatedAt, nil
  10351. }
  10352. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10353. func (m *ServerMutation) ResetUpdatedAt() {
  10354. m.updated_at = nil
  10355. }
  10356. // SetStatus sets the "status" field.
  10357. func (m *ServerMutation) SetStatus(u uint8) {
  10358. m.status = &u
  10359. m.addstatus = nil
  10360. }
  10361. // Status returns the value of the "status" field in the mutation.
  10362. func (m *ServerMutation) Status() (r uint8, exists bool) {
  10363. v := m.status
  10364. if v == nil {
  10365. return
  10366. }
  10367. return *v, true
  10368. }
  10369. // OldStatus returns the old "status" field's value of the Server entity.
  10370. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  10371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10372. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  10373. if !m.op.Is(OpUpdateOne) {
  10374. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10375. }
  10376. if m.id == nil || m.oldValue == nil {
  10377. return v, errors.New("OldStatus requires an ID field in the mutation")
  10378. }
  10379. oldValue, err := m.oldValue(ctx)
  10380. if err != nil {
  10381. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10382. }
  10383. return oldValue.Status, nil
  10384. }
  10385. // AddStatus adds u to the "status" field.
  10386. func (m *ServerMutation) AddStatus(u int8) {
  10387. if m.addstatus != nil {
  10388. *m.addstatus += u
  10389. } else {
  10390. m.addstatus = &u
  10391. }
  10392. }
  10393. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10394. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  10395. v := m.addstatus
  10396. if v == nil {
  10397. return
  10398. }
  10399. return *v, true
  10400. }
  10401. // ClearStatus clears the value of the "status" field.
  10402. func (m *ServerMutation) ClearStatus() {
  10403. m.status = nil
  10404. m.addstatus = nil
  10405. m.clearedFields[server.FieldStatus] = struct{}{}
  10406. }
  10407. // StatusCleared returns if the "status" field was cleared in this mutation.
  10408. func (m *ServerMutation) StatusCleared() bool {
  10409. _, ok := m.clearedFields[server.FieldStatus]
  10410. return ok
  10411. }
  10412. // ResetStatus resets all changes to the "status" field.
  10413. func (m *ServerMutation) ResetStatus() {
  10414. m.status = nil
  10415. m.addstatus = nil
  10416. delete(m.clearedFields, server.FieldStatus)
  10417. }
  10418. // SetDeletedAt sets the "deleted_at" field.
  10419. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  10420. m.deleted_at = &t
  10421. }
  10422. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10423. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  10424. v := m.deleted_at
  10425. if v == nil {
  10426. return
  10427. }
  10428. return *v, true
  10429. }
  10430. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  10431. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  10432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10433. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10434. if !m.op.Is(OpUpdateOne) {
  10435. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10436. }
  10437. if m.id == nil || m.oldValue == nil {
  10438. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10439. }
  10440. oldValue, err := m.oldValue(ctx)
  10441. if err != nil {
  10442. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10443. }
  10444. return oldValue.DeletedAt, nil
  10445. }
  10446. // ClearDeletedAt clears the value of the "deleted_at" field.
  10447. func (m *ServerMutation) ClearDeletedAt() {
  10448. m.deleted_at = nil
  10449. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  10450. }
  10451. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10452. func (m *ServerMutation) DeletedAtCleared() bool {
  10453. _, ok := m.clearedFields[server.FieldDeletedAt]
  10454. return ok
  10455. }
  10456. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10457. func (m *ServerMutation) ResetDeletedAt() {
  10458. m.deleted_at = nil
  10459. delete(m.clearedFields, server.FieldDeletedAt)
  10460. }
  10461. // SetName sets the "name" field.
  10462. func (m *ServerMutation) SetName(s string) {
  10463. m.name = &s
  10464. }
  10465. // Name returns the value of the "name" field in the mutation.
  10466. func (m *ServerMutation) Name() (r string, exists bool) {
  10467. v := m.name
  10468. if v == nil {
  10469. return
  10470. }
  10471. return *v, true
  10472. }
  10473. // OldName returns the old "name" field's value of the Server entity.
  10474. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  10475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10476. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  10477. if !m.op.Is(OpUpdateOne) {
  10478. return v, errors.New("OldName is only allowed on UpdateOne operations")
  10479. }
  10480. if m.id == nil || m.oldValue == nil {
  10481. return v, errors.New("OldName requires an ID field in the mutation")
  10482. }
  10483. oldValue, err := m.oldValue(ctx)
  10484. if err != nil {
  10485. return v, fmt.Errorf("querying old value for OldName: %w", err)
  10486. }
  10487. return oldValue.Name, nil
  10488. }
  10489. // ResetName resets all changes to the "name" field.
  10490. func (m *ServerMutation) ResetName() {
  10491. m.name = nil
  10492. }
  10493. // SetPublicIP sets the "public_ip" field.
  10494. func (m *ServerMutation) SetPublicIP(s string) {
  10495. m.public_ip = &s
  10496. }
  10497. // PublicIP returns the value of the "public_ip" field in the mutation.
  10498. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  10499. v := m.public_ip
  10500. if v == nil {
  10501. return
  10502. }
  10503. return *v, true
  10504. }
  10505. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  10506. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  10507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10508. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  10509. if !m.op.Is(OpUpdateOne) {
  10510. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  10511. }
  10512. if m.id == nil || m.oldValue == nil {
  10513. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  10514. }
  10515. oldValue, err := m.oldValue(ctx)
  10516. if err != nil {
  10517. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  10518. }
  10519. return oldValue.PublicIP, nil
  10520. }
  10521. // ResetPublicIP resets all changes to the "public_ip" field.
  10522. func (m *ServerMutation) ResetPublicIP() {
  10523. m.public_ip = nil
  10524. }
  10525. // SetPrivateIP sets the "private_ip" field.
  10526. func (m *ServerMutation) SetPrivateIP(s string) {
  10527. m.private_ip = &s
  10528. }
  10529. // PrivateIP returns the value of the "private_ip" field in the mutation.
  10530. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  10531. v := m.private_ip
  10532. if v == nil {
  10533. return
  10534. }
  10535. return *v, true
  10536. }
  10537. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  10538. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  10539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10540. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  10541. if !m.op.Is(OpUpdateOne) {
  10542. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  10543. }
  10544. if m.id == nil || m.oldValue == nil {
  10545. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  10546. }
  10547. oldValue, err := m.oldValue(ctx)
  10548. if err != nil {
  10549. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  10550. }
  10551. return oldValue.PrivateIP, nil
  10552. }
  10553. // ResetPrivateIP resets all changes to the "private_ip" field.
  10554. func (m *ServerMutation) ResetPrivateIP() {
  10555. m.private_ip = nil
  10556. }
  10557. // SetAdminPort sets the "admin_port" field.
  10558. func (m *ServerMutation) SetAdminPort(s string) {
  10559. m.admin_port = &s
  10560. }
  10561. // AdminPort returns the value of the "admin_port" field in the mutation.
  10562. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  10563. v := m.admin_port
  10564. if v == nil {
  10565. return
  10566. }
  10567. return *v, true
  10568. }
  10569. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  10570. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  10571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10572. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  10573. if !m.op.Is(OpUpdateOne) {
  10574. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  10575. }
  10576. if m.id == nil || m.oldValue == nil {
  10577. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  10578. }
  10579. oldValue, err := m.oldValue(ctx)
  10580. if err != nil {
  10581. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  10582. }
  10583. return oldValue.AdminPort, nil
  10584. }
  10585. // ResetAdminPort resets all changes to the "admin_port" field.
  10586. func (m *ServerMutation) ResetAdminPort() {
  10587. m.admin_port = nil
  10588. }
  10589. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  10590. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  10591. if m.wxs == nil {
  10592. m.wxs = make(map[uint64]struct{})
  10593. }
  10594. for i := range ids {
  10595. m.wxs[ids[i]] = struct{}{}
  10596. }
  10597. }
  10598. // ClearWxs clears the "wxs" edge to the Wx entity.
  10599. func (m *ServerMutation) ClearWxs() {
  10600. m.clearedwxs = true
  10601. }
  10602. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  10603. func (m *ServerMutation) WxsCleared() bool {
  10604. return m.clearedwxs
  10605. }
  10606. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  10607. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  10608. if m.removedwxs == nil {
  10609. m.removedwxs = make(map[uint64]struct{})
  10610. }
  10611. for i := range ids {
  10612. delete(m.wxs, ids[i])
  10613. m.removedwxs[ids[i]] = struct{}{}
  10614. }
  10615. }
  10616. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  10617. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  10618. for id := range m.removedwxs {
  10619. ids = append(ids, id)
  10620. }
  10621. return
  10622. }
  10623. // WxsIDs returns the "wxs" edge IDs in the mutation.
  10624. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  10625. for id := range m.wxs {
  10626. ids = append(ids, id)
  10627. }
  10628. return
  10629. }
  10630. // ResetWxs resets all changes to the "wxs" edge.
  10631. func (m *ServerMutation) ResetWxs() {
  10632. m.wxs = nil
  10633. m.clearedwxs = false
  10634. m.removedwxs = nil
  10635. }
  10636. // Where appends a list predicates to the ServerMutation builder.
  10637. func (m *ServerMutation) Where(ps ...predicate.Server) {
  10638. m.predicates = append(m.predicates, ps...)
  10639. }
  10640. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  10641. // users can use type-assertion to append predicates that do not depend on any generated package.
  10642. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  10643. p := make([]predicate.Server, len(ps))
  10644. for i := range ps {
  10645. p[i] = ps[i]
  10646. }
  10647. m.Where(p...)
  10648. }
  10649. // Op returns the operation name.
  10650. func (m *ServerMutation) Op() Op {
  10651. return m.op
  10652. }
  10653. // SetOp allows setting the mutation operation.
  10654. func (m *ServerMutation) SetOp(op Op) {
  10655. m.op = op
  10656. }
  10657. // Type returns the node type of this mutation (Server).
  10658. func (m *ServerMutation) Type() string {
  10659. return m.typ
  10660. }
  10661. // Fields returns all fields that were changed during this mutation. Note that in
  10662. // order to get all numeric fields that were incremented/decremented, call
  10663. // AddedFields().
  10664. func (m *ServerMutation) Fields() []string {
  10665. fields := make([]string, 0, 8)
  10666. if m.created_at != nil {
  10667. fields = append(fields, server.FieldCreatedAt)
  10668. }
  10669. if m.updated_at != nil {
  10670. fields = append(fields, server.FieldUpdatedAt)
  10671. }
  10672. if m.status != nil {
  10673. fields = append(fields, server.FieldStatus)
  10674. }
  10675. if m.deleted_at != nil {
  10676. fields = append(fields, server.FieldDeletedAt)
  10677. }
  10678. if m.name != nil {
  10679. fields = append(fields, server.FieldName)
  10680. }
  10681. if m.public_ip != nil {
  10682. fields = append(fields, server.FieldPublicIP)
  10683. }
  10684. if m.private_ip != nil {
  10685. fields = append(fields, server.FieldPrivateIP)
  10686. }
  10687. if m.admin_port != nil {
  10688. fields = append(fields, server.FieldAdminPort)
  10689. }
  10690. return fields
  10691. }
  10692. // Field returns the value of a field with the given name. The second boolean
  10693. // return value indicates that this field was not set, or was not defined in the
  10694. // schema.
  10695. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  10696. switch name {
  10697. case server.FieldCreatedAt:
  10698. return m.CreatedAt()
  10699. case server.FieldUpdatedAt:
  10700. return m.UpdatedAt()
  10701. case server.FieldStatus:
  10702. return m.Status()
  10703. case server.FieldDeletedAt:
  10704. return m.DeletedAt()
  10705. case server.FieldName:
  10706. return m.Name()
  10707. case server.FieldPublicIP:
  10708. return m.PublicIP()
  10709. case server.FieldPrivateIP:
  10710. return m.PrivateIP()
  10711. case server.FieldAdminPort:
  10712. return m.AdminPort()
  10713. }
  10714. return nil, false
  10715. }
  10716. // OldField returns the old value of the field from the database. An error is
  10717. // returned if the mutation operation is not UpdateOne, or the query to the
  10718. // database failed.
  10719. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10720. switch name {
  10721. case server.FieldCreatedAt:
  10722. return m.OldCreatedAt(ctx)
  10723. case server.FieldUpdatedAt:
  10724. return m.OldUpdatedAt(ctx)
  10725. case server.FieldStatus:
  10726. return m.OldStatus(ctx)
  10727. case server.FieldDeletedAt:
  10728. return m.OldDeletedAt(ctx)
  10729. case server.FieldName:
  10730. return m.OldName(ctx)
  10731. case server.FieldPublicIP:
  10732. return m.OldPublicIP(ctx)
  10733. case server.FieldPrivateIP:
  10734. return m.OldPrivateIP(ctx)
  10735. case server.FieldAdminPort:
  10736. return m.OldAdminPort(ctx)
  10737. }
  10738. return nil, fmt.Errorf("unknown Server field %s", name)
  10739. }
  10740. // SetField sets the value of a field with the given name. It returns an error if
  10741. // the field is not defined in the schema, or if the type mismatched the field
  10742. // type.
  10743. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  10744. switch name {
  10745. case server.FieldCreatedAt:
  10746. v, ok := value.(time.Time)
  10747. if !ok {
  10748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10749. }
  10750. m.SetCreatedAt(v)
  10751. return nil
  10752. case server.FieldUpdatedAt:
  10753. v, ok := value.(time.Time)
  10754. if !ok {
  10755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10756. }
  10757. m.SetUpdatedAt(v)
  10758. return nil
  10759. case server.FieldStatus:
  10760. v, ok := value.(uint8)
  10761. if !ok {
  10762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10763. }
  10764. m.SetStatus(v)
  10765. return nil
  10766. case server.FieldDeletedAt:
  10767. v, ok := value.(time.Time)
  10768. if !ok {
  10769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10770. }
  10771. m.SetDeletedAt(v)
  10772. return nil
  10773. case server.FieldName:
  10774. v, ok := value.(string)
  10775. if !ok {
  10776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10777. }
  10778. m.SetName(v)
  10779. return nil
  10780. case server.FieldPublicIP:
  10781. v, ok := value.(string)
  10782. if !ok {
  10783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10784. }
  10785. m.SetPublicIP(v)
  10786. return nil
  10787. case server.FieldPrivateIP:
  10788. v, ok := value.(string)
  10789. if !ok {
  10790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10791. }
  10792. m.SetPrivateIP(v)
  10793. return nil
  10794. case server.FieldAdminPort:
  10795. v, ok := value.(string)
  10796. if !ok {
  10797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10798. }
  10799. m.SetAdminPort(v)
  10800. return nil
  10801. }
  10802. return fmt.Errorf("unknown Server field %s", name)
  10803. }
  10804. // AddedFields returns all numeric fields that were incremented/decremented during
  10805. // this mutation.
  10806. func (m *ServerMutation) AddedFields() []string {
  10807. var fields []string
  10808. if m.addstatus != nil {
  10809. fields = append(fields, server.FieldStatus)
  10810. }
  10811. return fields
  10812. }
  10813. // AddedField returns the numeric value that was incremented/decremented on a field
  10814. // with the given name. The second boolean return value indicates that this field
  10815. // was not set, or was not defined in the schema.
  10816. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  10817. switch name {
  10818. case server.FieldStatus:
  10819. return m.AddedStatus()
  10820. }
  10821. return nil, false
  10822. }
  10823. // AddField adds the value to the field with the given name. It returns an error if
  10824. // the field is not defined in the schema, or if the type mismatched the field
  10825. // type.
  10826. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  10827. switch name {
  10828. case server.FieldStatus:
  10829. v, ok := value.(int8)
  10830. if !ok {
  10831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10832. }
  10833. m.AddStatus(v)
  10834. return nil
  10835. }
  10836. return fmt.Errorf("unknown Server numeric field %s", name)
  10837. }
  10838. // ClearedFields returns all nullable fields that were cleared during this
  10839. // mutation.
  10840. func (m *ServerMutation) ClearedFields() []string {
  10841. var fields []string
  10842. if m.FieldCleared(server.FieldStatus) {
  10843. fields = append(fields, server.FieldStatus)
  10844. }
  10845. if m.FieldCleared(server.FieldDeletedAt) {
  10846. fields = append(fields, server.FieldDeletedAt)
  10847. }
  10848. return fields
  10849. }
  10850. // FieldCleared returns a boolean indicating if a field with the given name was
  10851. // cleared in this mutation.
  10852. func (m *ServerMutation) FieldCleared(name string) bool {
  10853. _, ok := m.clearedFields[name]
  10854. return ok
  10855. }
  10856. // ClearField clears the value of the field with the given name. It returns an
  10857. // error if the field is not defined in the schema.
  10858. func (m *ServerMutation) ClearField(name string) error {
  10859. switch name {
  10860. case server.FieldStatus:
  10861. m.ClearStatus()
  10862. return nil
  10863. case server.FieldDeletedAt:
  10864. m.ClearDeletedAt()
  10865. return nil
  10866. }
  10867. return fmt.Errorf("unknown Server nullable field %s", name)
  10868. }
  10869. // ResetField resets all changes in the mutation for the field with the given name.
  10870. // It returns an error if the field is not defined in the schema.
  10871. func (m *ServerMutation) ResetField(name string) error {
  10872. switch name {
  10873. case server.FieldCreatedAt:
  10874. m.ResetCreatedAt()
  10875. return nil
  10876. case server.FieldUpdatedAt:
  10877. m.ResetUpdatedAt()
  10878. return nil
  10879. case server.FieldStatus:
  10880. m.ResetStatus()
  10881. return nil
  10882. case server.FieldDeletedAt:
  10883. m.ResetDeletedAt()
  10884. return nil
  10885. case server.FieldName:
  10886. m.ResetName()
  10887. return nil
  10888. case server.FieldPublicIP:
  10889. m.ResetPublicIP()
  10890. return nil
  10891. case server.FieldPrivateIP:
  10892. m.ResetPrivateIP()
  10893. return nil
  10894. case server.FieldAdminPort:
  10895. m.ResetAdminPort()
  10896. return nil
  10897. }
  10898. return fmt.Errorf("unknown Server field %s", name)
  10899. }
  10900. // AddedEdges returns all edge names that were set/added in this mutation.
  10901. func (m *ServerMutation) AddedEdges() []string {
  10902. edges := make([]string, 0, 1)
  10903. if m.wxs != nil {
  10904. edges = append(edges, server.EdgeWxs)
  10905. }
  10906. return edges
  10907. }
  10908. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10909. // name in this mutation.
  10910. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  10911. switch name {
  10912. case server.EdgeWxs:
  10913. ids := make([]ent.Value, 0, len(m.wxs))
  10914. for id := range m.wxs {
  10915. ids = append(ids, id)
  10916. }
  10917. return ids
  10918. }
  10919. return nil
  10920. }
  10921. // RemovedEdges returns all edge names that were removed in this mutation.
  10922. func (m *ServerMutation) RemovedEdges() []string {
  10923. edges := make([]string, 0, 1)
  10924. if m.removedwxs != nil {
  10925. edges = append(edges, server.EdgeWxs)
  10926. }
  10927. return edges
  10928. }
  10929. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10930. // the given name in this mutation.
  10931. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  10932. switch name {
  10933. case server.EdgeWxs:
  10934. ids := make([]ent.Value, 0, len(m.removedwxs))
  10935. for id := range m.removedwxs {
  10936. ids = append(ids, id)
  10937. }
  10938. return ids
  10939. }
  10940. return nil
  10941. }
  10942. // ClearedEdges returns all edge names that were cleared in this mutation.
  10943. func (m *ServerMutation) ClearedEdges() []string {
  10944. edges := make([]string, 0, 1)
  10945. if m.clearedwxs {
  10946. edges = append(edges, server.EdgeWxs)
  10947. }
  10948. return edges
  10949. }
  10950. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10951. // was cleared in this mutation.
  10952. func (m *ServerMutation) EdgeCleared(name string) bool {
  10953. switch name {
  10954. case server.EdgeWxs:
  10955. return m.clearedwxs
  10956. }
  10957. return false
  10958. }
  10959. // ClearEdge clears the value of the edge with the given name. It returns an error
  10960. // if that edge is not defined in the schema.
  10961. func (m *ServerMutation) ClearEdge(name string) error {
  10962. switch name {
  10963. }
  10964. return fmt.Errorf("unknown Server unique edge %s", name)
  10965. }
  10966. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10967. // It returns an error if the edge is not defined in the schema.
  10968. func (m *ServerMutation) ResetEdge(name string) error {
  10969. switch name {
  10970. case server.EdgeWxs:
  10971. m.ResetWxs()
  10972. return nil
  10973. }
  10974. return fmt.Errorf("unknown Server edge %s", name)
  10975. }
  10976. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  10977. type SopNodeMutation struct {
  10978. config
  10979. op Op
  10980. typ string
  10981. id *uint64
  10982. created_at *time.Time
  10983. updated_at *time.Time
  10984. status *uint8
  10985. addstatus *int8
  10986. deleted_at *time.Time
  10987. parent_id *uint64
  10988. addparent_id *int64
  10989. name *string
  10990. condition_type *int
  10991. addcondition_type *int
  10992. condition_list *[]string
  10993. appendcondition_list []string
  10994. no_reply_condition *uint64
  10995. addno_reply_condition *int64
  10996. action_message *[]custom_types.Action
  10997. appendaction_message []custom_types.Action
  10998. action_label *[]uint64
  10999. appendaction_label []uint64
  11000. clearedFields map[string]struct{}
  11001. sop_stage *uint64
  11002. clearedsop_stage bool
  11003. node_messages map[uint64]struct{}
  11004. removednode_messages map[uint64]struct{}
  11005. clearednode_messages bool
  11006. done bool
  11007. oldValue func(context.Context) (*SopNode, error)
  11008. predicates []predicate.SopNode
  11009. }
  11010. var _ ent.Mutation = (*SopNodeMutation)(nil)
  11011. // sopnodeOption allows management of the mutation configuration using functional options.
  11012. type sopnodeOption func(*SopNodeMutation)
  11013. // newSopNodeMutation creates new mutation for the SopNode entity.
  11014. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  11015. m := &SopNodeMutation{
  11016. config: c,
  11017. op: op,
  11018. typ: TypeSopNode,
  11019. clearedFields: make(map[string]struct{}),
  11020. }
  11021. for _, opt := range opts {
  11022. opt(m)
  11023. }
  11024. return m
  11025. }
  11026. // withSopNodeID sets the ID field of the mutation.
  11027. func withSopNodeID(id uint64) sopnodeOption {
  11028. return func(m *SopNodeMutation) {
  11029. var (
  11030. err error
  11031. once sync.Once
  11032. value *SopNode
  11033. )
  11034. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  11035. once.Do(func() {
  11036. if m.done {
  11037. err = errors.New("querying old values post mutation is not allowed")
  11038. } else {
  11039. value, err = m.Client().SopNode.Get(ctx, id)
  11040. }
  11041. })
  11042. return value, err
  11043. }
  11044. m.id = &id
  11045. }
  11046. }
  11047. // withSopNode sets the old SopNode of the mutation.
  11048. func withSopNode(node *SopNode) sopnodeOption {
  11049. return func(m *SopNodeMutation) {
  11050. m.oldValue = func(context.Context) (*SopNode, error) {
  11051. return node, nil
  11052. }
  11053. m.id = &node.ID
  11054. }
  11055. }
  11056. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11057. // executed in a transaction (ent.Tx), a transactional client is returned.
  11058. func (m SopNodeMutation) Client() *Client {
  11059. client := &Client{config: m.config}
  11060. client.init()
  11061. return client
  11062. }
  11063. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11064. // it returns an error otherwise.
  11065. func (m SopNodeMutation) Tx() (*Tx, error) {
  11066. if _, ok := m.driver.(*txDriver); !ok {
  11067. return nil, errors.New("ent: mutation is not running in a transaction")
  11068. }
  11069. tx := &Tx{config: m.config}
  11070. tx.init()
  11071. return tx, nil
  11072. }
  11073. // SetID sets the value of the id field. Note that this
  11074. // operation is only accepted on creation of SopNode entities.
  11075. func (m *SopNodeMutation) SetID(id uint64) {
  11076. m.id = &id
  11077. }
  11078. // ID returns the ID value in the mutation. Note that the ID is only available
  11079. // if it was provided to the builder or after it was returned from the database.
  11080. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  11081. if m.id == nil {
  11082. return
  11083. }
  11084. return *m.id, true
  11085. }
  11086. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11087. // That means, if the mutation is applied within a transaction with an isolation level such
  11088. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11089. // or updated by the mutation.
  11090. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  11091. switch {
  11092. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11093. id, exists := m.ID()
  11094. if exists {
  11095. return []uint64{id}, nil
  11096. }
  11097. fallthrough
  11098. case m.op.Is(OpUpdate | OpDelete):
  11099. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  11100. default:
  11101. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11102. }
  11103. }
  11104. // SetCreatedAt sets the "created_at" field.
  11105. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  11106. m.created_at = &t
  11107. }
  11108. // CreatedAt returns the value of the "created_at" field in the mutation.
  11109. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  11110. v := m.created_at
  11111. if v == nil {
  11112. return
  11113. }
  11114. return *v, true
  11115. }
  11116. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  11117. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11119. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11120. if !m.op.Is(OpUpdateOne) {
  11121. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11122. }
  11123. if m.id == nil || m.oldValue == nil {
  11124. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11125. }
  11126. oldValue, err := m.oldValue(ctx)
  11127. if err != nil {
  11128. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11129. }
  11130. return oldValue.CreatedAt, nil
  11131. }
  11132. // ResetCreatedAt resets all changes to the "created_at" field.
  11133. func (m *SopNodeMutation) ResetCreatedAt() {
  11134. m.created_at = nil
  11135. }
  11136. // SetUpdatedAt sets the "updated_at" field.
  11137. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  11138. m.updated_at = &t
  11139. }
  11140. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11141. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  11142. v := m.updated_at
  11143. if v == nil {
  11144. return
  11145. }
  11146. return *v, true
  11147. }
  11148. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  11149. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11151. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11152. if !m.op.Is(OpUpdateOne) {
  11153. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11154. }
  11155. if m.id == nil || m.oldValue == nil {
  11156. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11157. }
  11158. oldValue, err := m.oldValue(ctx)
  11159. if err != nil {
  11160. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11161. }
  11162. return oldValue.UpdatedAt, nil
  11163. }
  11164. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11165. func (m *SopNodeMutation) ResetUpdatedAt() {
  11166. m.updated_at = nil
  11167. }
  11168. // SetStatus sets the "status" field.
  11169. func (m *SopNodeMutation) SetStatus(u uint8) {
  11170. m.status = &u
  11171. m.addstatus = nil
  11172. }
  11173. // Status returns the value of the "status" field in the mutation.
  11174. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  11175. v := m.status
  11176. if v == nil {
  11177. return
  11178. }
  11179. return *v, true
  11180. }
  11181. // OldStatus returns the old "status" field's value of the SopNode entity.
  11182. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11184. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11185. if !m.op.Is(OpUpdateOne) {
  11186. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11187. }
  11188. if m.id == nil || m.oldValue == nil {
  11189. return v, errors.New("OldStatus requires an ID field in the mutation")
  11190. }
  11191. oldValue, err := m.oldValue(ctx)
  11192. if err != nil {
  11193. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11194. }
  11195. return oldValue.Status, nil
  11196. }
  11197. // AddStatus adds u to the "status" field.
  11198. func (m *SopNodeMutation) AddStatus(u int8) {
  11199. if m.addstatus != nil {
  11200. *m.addstatus += u
  11201. } else {
  11202. m.addstatus = &u
  11203. }
  11204. }
  11205. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11206. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  11207. v := m.addstatus
  11208. if v == nil {
  11209. return
  11210. }
  11211. return *v, true
  11212. }
  11213. // ClearStatus clears the value of the "status" field.
  11214. func (m *SopNodeMutation) ClearStatus() {
  11215. m.status = nil
  11216. m.addstatus = nil
  11217. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  11218. }
  11219. // StatusCleared returns if the "status" field was cleared in this mutation.
  11220. func (m *SopNodeMutation) StatusCleared() bool {
  11221. _, ok := m.clearedFields[sopnode.FieldStatus]
  11222. return ok
  11223. }
  11224. // ResetStatus resets all changes to the "status" field.
  11225. func (m *SopNodeMutation) ResetStatus() {
  11226. m.status = nil
  11227. m.addstatus = nil
  11228. delete(m.clearedFields, sopnode.FieldStatus)
  11229. }
  11230. // SetDeletedAt sets the "deleted_at" field.
  11231. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  11232. m.deleted_at = &t
  11233. }
  11234. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11235. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  11236. v := m.deleted_at
  11237. if v == nil {
  11238. return
  11239. }
  11240. return *v, true
  11241. }
  11242. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  11243. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11245. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11246. if !m.op.Is(OpUpdateOne) {
  11247. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11248. }
  11249. if m.id == nil || m.oldValue == nil {
  11250. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11251. }
  11252. oldValue, err := m.oldValue(ctx)
  11253. if err != nil {
  11254. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11255. }
  11256. return oldValue.DeletedAt, nil
  11257. }
  11258. // ClearDeletedAt clears the value of the "deleted_at" field.
  11259. func (m *SopNodeMutation) ClearDeletedAt() {
  11260. m.deleted_at = nil
  11261. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  11262. }
  11263. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11264. func (m *SopNodeMutation) DeletedAtCleared() bool {
  11265. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  11266. return ok
  11267. }
  11268. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11269. func (m *SopNodeMutation) ResetDeletedAt() {
  11270. m.deleted_at = nil
  11271. delete(m.clearedFields, sopnode.FieldDeletedAt)
  11272. }
  11273. // SetStageID sets the "stage_id" field.
  11274. func (m *SopNodeMutation) SetStageID(u uint64) {
  11275. m.sop_stage = &u
  11276. }
  11277. // StageID returns the value of the "stage_id" field in the mutation.
  11278. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  11279. v := m.sop_stage
  11280. if v == nil {
  11281. return
  11282. }
  11283. return *v, true
  11284. }
  11285. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  11286. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11288. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  11289. if !m.op.Is(OpUpdateOne) {
  11290. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  11291. }
  11292. if m.id == nil || m.oldValue == nil {
  11293. return v, errors.New("OldStageID requires an ID field in the mutation")
  11294. }
  11295. oldValue, err := m.oldValue(ctx)
  11296. if err != nil {
  11297. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  11298. }
  11299. return oldValue.StageID, nil
  11300. }
  11301. // ResetStageID resets all changes to the "stage_id" field.
  11302. func (m *SopNodeMutation) ResetStageID() {
  11303. m.sop_stage = nil
  11304. }
  11305. // SetParentID sets the "parent_id" field.
  11306. func (m *SopNodeMutation) SetParentID(u uint64) {
  11307. m.parent_id = &u
  11308. m.addparent_id = nil
  11309. }
  11310. // ParentID returns the value of the "parent_id" field in the mutation.
  11311. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  11312. v := m.parent_id
  11313. if v == nil {
  11314. return
  11315. }
  11316. return *v, true
  11317. }
  11318. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  11319. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11321. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  11322. if !m.op.Is(OpUpdateOne) {
  11323. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  11324. }
  11325. if m.id == nil || m.oldValue == nil {
  11326. return v, errors.New("OldParentID requires an ID field in the mutation")
  11327. }
  11328. oldValue, err := m.oldValue(ctx)
  11329. if err != nil {
  11330. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  11331. }
  11332. return oldValue.ParentID, nil
  11333. }
  11334. // AddParentID adds u to the "parent_id" field.
  11335. func (m *SopNodeMutation) AddParentID(u int64) {
  11336. if m.addparent_id != nil {
  11337. *m.addparent_id += u
  11338. } else {
  11339. m.addparent_id = &u
  11340. }
  11341. }
  11342. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  11343. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  11344. v := m.addparent_id
  11345. if v == nil {
  11346. return
  11347. }
  11348. return *v, true
  11349. }
  11350. // ResetParentID resets all changes to the "parent_id" field.
  11351. func (m *SopNodeMutation) ResetParentID() {
  11352. m.parent_id = nil
  11353. m.addparent_id = nil
  11354. }
  11355. // SetName sets the "name" field.
  11356. func (m *SopNodeMutation) SetName(s string) {
  11357. m.name = &s
  11358. }
  11359. // Name returns the value of the "name" field in the mutation.
  11360. func (m *SopNodeMutation) Name() (r string, exists bool) {
  11361. v := m.name
  11362. if v == nil {
  11363. return
  11364. }
  11365. return *v, true
  11366. }
  11367. // OldName returns the old "name" field's value of the SopNode entity.
  11368. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11370. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  11371. if !m.op.Is(OpUpdateOne) {
  11372. return v, errors.New("OldName is only allowed on UpdateOne operations")
  11373. }
  11374. if m.id == nil || m.oldValue == nil {
  11375. return v, errors.New("OldName requires an ID field in the mutation")
  11376. }
  11377. oldValue, err := m.oldValue(ctx)
  11378. if err != nil {
  11379. return v, fmt.Errorf("querying old value for OldName: %w", err)
  11380. }
  11381. return oldValue.Name, nil
  11382. }
  11383. // ResetName resets all changes to the "name" field.
  11384. func (m *SopNodeMutation) ResetName() {
  11385. m.name = nil
  11386. }
  11387. // SetConditionType sets the "condition_type" field.
  11388. func (m *SopNodeMutation) SetConditionType(i int) {
  11389. m.condition_type = &i
  11390. m.addcondition_type = nil
  11391. }
  11392. // ConditionType returns the value of the "condition_type" field in the mutation.
  11393. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  11394. v := m.condition_type
  11395. if v == nil {
  11396. return
  11397. }
  11398. return *v, true
  11399. }
  11400. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  11401. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11403. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  11404. if !m.op.Is(OpUpdateOne) {
  11405. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  11406. }
  11407. if m.id == nil || m.oldValue == nil {
  11408. return v, errors.New("OldConditionType requires an ID field in the mutation")
  11409. }
  11410. oldValue, err := m.oldValue(ctx)
  11411. if err != nil {
  11412. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  11413. }
  11414. return oldValue.ConditionType, nil
  11415. }
  11416. // AddConditionType adds i to the "condition_type" field.
  11417. func (m *SopNodeMutation) AddConditionType(i int) {
  11418. if m.addcondition_type != nil {
  11419. *m.addcondition_type += i
  11420. } else {
  11421. m.addcondition_type = &i
  11422. }
  11423. }
  11424. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  11425. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  11426. v := m.addcondition_type
  11427. if v == nil {
  11428. return
  11429. }
  11430. return *v, true
  11431. }
  11432. // ResetConditionType resets all changes to the "condition_type" field.
  11433. func (m *SopNodeMutation) ResetConditionType() {
  11434. m.condition_type = nil
  11435. m.addcondition_type = nil
  11436. }
  11437. // SetConditionList sets the "condition_list" field.
  11438. func (m *SopNodeMutation) SetConditionList(s []string) {
  11439. m.condition_list = &s
  11440. m.appendcondition_list = nil
  11441. }
  11442. // ConditionList returns the value of the "condition_list" field in the mutation.
  11443. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  11444. v := m.condition_list
  11445. if v == nil {
  11446. return
  11447. }
  11448. return *v, true
  11449. }
  11450. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  11451. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11453. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  11454. if !m.op.Is(OpUpdateOne) {
  11455. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  11456. }
  11457. if m.id == nil || m.oldValue == nil {
  11458. return v, errors.New("OldConditionList requires an ID field in the mutation")
  11459. }
  11460. oldValue, err := m.oldValue(ctx)
  11461. if err != nil {
  11462. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  11463. }
  11464. return oldValue.ConditionList, nil
  11465. }
  11466. // AppendConditionList adds s to the "condition_list" field.
  11467. func (m *SopNodeMutation) AppendConditionList(s []string) {
  11468. m.appendcondition_list = append(m.appendcondition_list, s...)
  11469. }
  11470. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  11471. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  11472. if len(m.appendcondition_list) == 0 {
  11473. return nil, false
  11474. }
  11475. return m.appendcondition_list, true
  11476. }
  11477. // ClearConditionList clears the value of the "condition_list" field.
  11478. func (m *SopNodeMutation) ClearConditionList() {
  11479. m.condition_list = nil
  11480. m.appendcondition_list = nil
  11481. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  11482. }
  11483. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  11484. func (m *SopNodeMutation) ConditionListCleared() bool {
  11485. _, ok := m.clearedFields[sopnode.FieldConditionList]
  11486. return ok
  11487. }
  11488. // ResetConditionList resets all changes to the "condition_list" field.
  11489. func (m *SopNodeMutation) ResetConditionList() {
  11490. m.condition_list = nil
  11491. m.appendcondition_list = nil
  11492. delete(m.clearedFields, sopnode.FieldConditionList)
  11493. }
  11494. // SetNoReplyCondition sets the "no_reply_condition" field.
  11495. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  11496. m.no_reply_condition = &u
  11497. m.addno_reply_condition = nil
  11498. }
  11499. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  11500. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  11501. v := m.no_reply_condition
  11502. if v == nil {
  11503. return
  11504. }
  11505. return *v, true
  11506. }
  11507. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  11508. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11510. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  11511. if !m.op.Is(OpUpdateOne) {
  11512. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  11513. }
  11514. if m.id == nil || m.oldValue == nil {
  11515. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  11516. }
  11517. oldValue, err := m.oldValue(ctx)
  11518. if err != nil {
  11519. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  11520. }
  11521. return oldValue.NoReplyCondition, nil
  11522. }
  11523. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  11524. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  11525. if m.addno_reply_condition != nil {
  11526. *m.addno_reply_condition += u
  11527. } else {
  11528. m.addno_reply_condition = &u
  11529. }
  11530. }
  11531. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  11532. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  11533. v := m.addno_reply_condition
  11534. if v == nil {
  11535. return
  11536. }
  11537. return *v, true
  11538. }
  11539. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  11540. func (m *SopNodeMutation) ResetNoReplyCondition() {
  11541. m.no_reply_condition = nil
  11542. m.addno_reply_condition = nil
  11543. }
  11544. // SetActionMessage sets the "action_message" field.
  11545. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  11546. m.action_message = &ct
  11547. m.appendaction_message = nil
  11548. }
  11549. // ActionMessage returns the value of the "action_message" field in the mutation.
  11550. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  11551. v := m.action_message
  11552. if v == nil {
  11553. return
  11554. }
  11555. return *v, true
  11556. }
  11557. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  11558. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11560. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  11561. if !m.op.Is(OpUpdateOne) {
  11562. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  11563. }
  11564. if m.id == nil || m.oldValue == nil {
  11565. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  11566. }
  11567. oldValue, err := m.oldValue(ctx)
  11568. if err != nil {
  11569. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  11570. }
  11571. return oldValue.ActionMessage, nil
  11572. }
  11573. // AppendActionMessage adds ct to the "action_message" field.
  11574. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  11575. m.appendaction_message = append(m.appendaction_message, ct...)
  11576. }
  11577. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  11578. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  11579. if len(m.appendaction_message) == 0 {
  11580. return nil, false
  11581. }
  11582. return m.appendaction_message, true
  11583. }
  11584. // ClearActionMessage clears the value of the "action_message" field.
  11585. func (m *SopNodeMutation) ClearActionMessage() {
  11586. m.action_message = nil
  11587. m.appendaction_message = nil
  11588. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  11589. }
  11590. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  11591. func (m *SopNodeMutation) ActionMessageCleared() bool {
  11592. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  11593. return ok
  11594. }
  11595. // ResetActionMessage resets all changes to the "action_message" field.
  11596. func (m *SopNodeMutation) ResetActionMessage() {
  11597. m.action_message = nil
  11598. m.appendaction_message = nil
  11599. delete(m.clearedFields, sopnode.FieldActionMessage)
  11600. }
  11601. // SetActionLabel sets the "action_label" field.
  11602. func (m *SopNodeMutation) SetActionLabel(u []uint64) {
  11603. m.action_label = &u
  11604. m.appendaction_label = nil
  11605. }
  11606. // ActionLabel returns the value of the "action_label" field in the mutation.
  11607. func (m *SopNodeMutation) ActionLabel() (r []uint64, exists bool) {
  11608. v := m.action_label
  11609. if v == nil {
  11610. return
  11611. }
  11612. return *v, true
  11613. }
  11614. // OldActionLabel returns the old "action_label" field's value of the SopNode entity.
  11615. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11617. func (m *SopNodeMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  11618. if !m.op.Is(OpUpdateOne) {
  11619. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  11620. }
  11621. if m.id == nil || m.oldValue == nil {
  11622. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  11623. }
  11624. oldValue, err := m.oldValue(ctx)
  11625. if err != nil {
  11626. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  11627. }
  11628. return oldValue.ActionLabel, nil
  11629. }
  11630. // AppendActionLabel adds u to the "action_label" field.
  11631. func (m *SopNodeMutation) AppendActionLabel(u []uint64) {
  11632. m.appendaction_label = append(m.appendaction_label, u...)
  11633. }
  11634. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  11635. func (m *SopNodeMutation) AppendedActionLabel() ([]uint64, bool) {
  11636. if len(m.appendaction_label) == 0 {
  11637. return nil, false
  11638. }
  11639. return m.appendaction_label, true
  11640. }
  11641. // ClearActionLabel clears the value of the "action_label" field.
  11642. func (m *SopNodeMutation) ClearActionLabel() {
  11643. m.action_label = nil
  11644. m.appendaction_label = nil
  11645. m.clearedFields[sopnode.FieldActionLabel] = struct{}{}
  11646. }
  11647. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  11648. func (m *SopNodeMutation) ActionLabelCleared() bool {
  11649. _, ok := m.clearedFields[sopnode.FieldActionLabel]
  11650. return ok
  11651. }
  11652. // ResetActionLabel resets all changes to the "action_label" field.
  11653. func (m *SopNodeMutation) ResetActionLabel() {
  11654. m.action_label = nil
  11655. m.appendaction_label = nil
  11656. delete(m.clearedFields, sopnode.FieldActionLabel)
  11657. }
  11658. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  11659. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  11660. m.sop_stage = &id
  11661. }
  11662. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  11663. func (m *SopNodeMutation) ClearSopStage() {
  11664. m.clearedsop_stage = true
  11665. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  11666. }
  11667. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  11668. func (m *SopNodeMutation) SopStageCleared() bool {
  11669. return m.clearedsop_stage
  11670. }
  11671. // SopStageID returns the "sop_stage" edge ID in the mutation.
  11672. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  11673. if m.sop_stage != nil {
  11674. return *m.sop_stage, true
  11675. }
  11676. return
  11677. }
  11678. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  11679. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  11680. // SopStageID instead. It exists only for internal usage by the builders.
  11681. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  11682. if id := m.sop_stage; id != nil {
  11683. ids = append(ids, *id)
  11684. }
  11685. return
  11686. }
  11687. // ResetSopStage resets all changes to the "sop_stage" edge.
  11688. func (m *SopNodeMutation) ResetSopStage() {
  11689. m.sop_stage = nil
  11690. m.clearedsop_stage = false
  11691. }
  11692. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  11693. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  11694. if m.node_messages == nil {
  11695. m.node_messages = make(map[uint64]struct{})
  11696. }
  11697. for i := range ids {
  11698. m.node_messages[ids[i]] = struct{}{}
  11699. }
  11700. }
  11701. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  11702. func (m *SopNodeMutation) ClearNodeMessages() {
  11703. m.clearednode_messages = true
  11704. }
  11705. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  11706. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  11707. return m.clearednode_messages
  11708. }
  11709. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  11710. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  11711. if m.removednode_messages == nil {
  11712. m.removednode_messages = make(map[uint64]struct{})
  11713. }
  11714. for i := range ids {
  11715. delete(m.node_messages, ids[i])
  11716. m.removednode_messages[ids[i]] = struct{}{}
  11717. }
  11718. }
  11719. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  11720. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  11721. for id := range m.removednode_messages {
  11722. ids = append(ids, id)
  11723. }
  11724. return
  11725. }
  11726. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  11727. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  11728. for id := range m.node_messages {
  11729. ids = append(ids, id)
  11730. }
  11731. return
  11732. }
  11733. // ResetNodeMessages resets all changes to the "node_messages" edge.
  11734. func (m *SopNodeMutation) ResetNodeMessages() {
  11735. m.node_messages = nil
  11736. m.clearednode_messages = false
  11737. m.removednode_messages = nil
  11738. }
  11739. // Where appends a list predicates to the SopNodeMutation builder.
  11740. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  11741. m.predicates = append(m.predicates, ps...)
  11742. }
  11743. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  11744. // users can use type-assertion to append predicates that do not depend on any generated package.
  11745. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  11746. p := make([]predicate.SopNode, len(ps))
  11747. for i := range ps {
  11748. p[i] = ps[i]
  11749. }
  11750. m.Where(p...)
  11751. }
  11752. // Op returns the operation name.
  11753. func (m *SopNodeMutation) Op() Op {
  11754. return m.op
  11755. }
  11756. // SetOp allows setting the mutation operation.
  11757. func (m *SopNodeMutation) SetOp(op Op) {
  11758. m.op = op
  11759. }
  11760. // Type returns the node type of this mutation (SopNode).
  11761. func (m *SopNodeMutation) Type() string {
  11762. return m.typ
  11763. }
  11764. // Fields returns all fields that were changed during this mutation. Note that in
  11765. // order to get all numeric fields that were incremented/decremented, call
  11766. // AddedFields().
  11767. func (m *SopNodeMutation) Fields() []string {
  11768. fields := make([]string, 0, 12)
  11769. if m.created_at != nil {
  11770. fields = append(fields, sopnode.FieldCreatedAt)
  11771. }
  11772. if m.updated_at != nil {
  11773. fields = append(fields, sopnode.FieldUpdatedAt)
  11774. }
  11775. if m.status != nil {
  11776. fields = append(fields, sopnode.FieldStatus)
  11777. }
  11778. if m.deleted_at != nil {
  11779. fields = append(fields, sopnode.FieldDeletedAt)
  11780. }
  11781. if m.sop_stage != nil {
  11782. fields = append(fields, sopnode.FieldStageID)
  11783. }
  11784. if m.parent_id != nil {
  11785. fields = append(fields, sopnode.FieldParentID)
  11786. }
  11787. if m.name != nil {
  11788. fields = append(fields, sopnode.FieldName)
  11789. }
  11790. if m.condition_type != nil {
  11791. fields = append(fields, sopnode.FieldConditionType)
  11792. }
  11793. if m.condition_list != nil {
  11794. fields = append(fields, sopnode.FieldConditionList)
  11795. }
  11796. if m.no_reply_condition != nil {
  11797. fields = append(fields, sopnode.FieldNoReplyCondition)
  11798. }
  11799. if m.action_message != nil {
  11800. fields = append(fields, sopnode.FieldActionMessage)
  11801. }
  11802. if m.action_label != nil {
  11803. fields = append(fields, sopnode.FieldActionLabel)
  11804. }
  11805. return fields
  11806. }
  11807. // Field returns the value of a field with the given name. The second boolean
  11808. // return value indicates that this field was not set, or was not defined in the
  11809. // schema.
  11810. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  11811. switch name {
  11812. case sopnode.FieldCreatedAt:
  11813. return m.CreatedAt()
  11814. case sopnode.FieldUpdatedAt:
  11815. return m.UpdatedAt()
  11816. case sopnode.FieldStatus:
  11817. return m.Status()
  11818. case sopnode.FieldDeletedAt:
  11819. return m.DeletedAt()
  11820. case sopnode.FieldStageID:
  11821. return m.StageID()
  11822. case sopnode.FieldParentID:
  11823. return m.ParentID()
  11824. case sopnode.FieldName:
  11825. return m.Name()
  11826. case sopnode.FieldConditionType:
  11827. return m.ConditionType()
  11828. case sopnode.FieldConditionList:
  11829. return m.ConditionList()
  11830. case sopnode.FieldNoReplyCondition:
  11831. return m.NoReplyCondition()
  11832. case sopnode.FieldActionMessage:
  11833. return m.ActionMessage()
  11834. case sopnode.FieldActionLabel:
  11835. return m.ActionLabel()
  11836. }
  11837. return nil, false
  11838. }
  11839. // OldField returns the old value of the field from the database. An error is
  11840. // returned if the mutation operation is not UpdateOne, or the query to the
  11841. // database failed.
  11842. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11843. switch name {
  11844. case sopnode.FieldCreatedAt:
  11845. return m.OldCreatedAt(ctx)
  11846. case sopnode.FieldUpdatedAt:
  11847. return m.OldUpdatedAt(ctx)
  11848. case sopnode.FieldStatus:
  11849. return m.OldStatus(ctx)
  11850. case sopnode.FieldDeletedAt:
  11851. return m.OldDeletedAt(ctx)
  11852. case sopnode.FieldStageID:
  11853. return m.OldStageID(ctx)
  11854. case sopnode.FieldParentID:
  11855. return m.OldParentID(ctx)
  11856. case sopnode.FieldName:
  11857. return m.OldName(ctx)
  11858. case sopnode.FieldConditionType:
  11859. return m.OldConditionType(ctx)
  11860. case sopnode.FieldConditionList:
  11861. return m.OldConditionList(ctx)
  11862. case sopnode.FieldNoReplyCondition:
  11863. return m.OldNoReplyCondition(ctx)
  11864. case sopnode.FieldActionMessage:
  11865. return m.OldActionMessage(ctx)
  11866. case sopnode.FieldActionLabel:
  11867. return m.OldActionLabel(ctx)
  11868. }
  11869. return nil, fmt.Errorf("unknown SopNode field %s", name)
  11870. }
  11871. // SetField sets the value of a field with the given name. It returns an error if
  11872. // the field is not defined in the schema, or if the type mismatched the field
  11873. // type.
  11874. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  11875. switch name {
  11876. case sopnode.FieldCreatedAt:
  11877. v, ok := value.(time.Time)
  11878. if !ok {
  11879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11880. }
  11881. m.SetCreatedAt(v)
  11882. return nil
  11883. case sopnode.FieldUpdatedAt:
  11884. v, ok := value.(time.Time)
  11885. if !ok {
  11886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11887. }
  11888. m.SetUpdatedAt(v)
  11889. return nil
  11890. case sopnode.FieldStatus:
  11891. v, ok := value.(uint8)
  11892. if !ok {
  11893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11894. }
  11895. m.SetStatus(v)
  11896. return nil
  11897. case sopnode.FieldDeletedAt:
  11898. v, ok := value.(time.Time)
  11899. if !ok {
  11900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11901. }
  11902. m.SetDeletedAt(v)
  11903. return nil
  11904. case sopnode.FieldStageID:
  11905. v, ok := value.(uint64)
  11906. if !ok {
  11907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11908. }
  11909. m.SetStageID(v)
  11910. return nil
  11911. case sopnode.FieldParentID:
  11912. v, ok := value.(uint64)
  11913. if !ok {
  11914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11915. }
  11916. m.SetParentID(v)
  11917. return nil
  11918. case sopnode.FieldName:
  11919. v, ok := value.(string)
  11920. if !ok {
  11921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11922. }
  11923. m.SetName(v)
  11924. return nil
  11925. case sopnode.FieldConditionType:
  11926. v, ok := value.(int)
  11927. if !ok {
  11928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11929. }
  11930. m.SetConditionType(v)
  11931. return nil
  11932. case sopnode.FieldConditionList:
  11933. v, ok := value.([]string)
  11934. if !ok {
  11935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11936. }
  11937. m.SetConditionList(v)
  11938. return nil
  11939. case sopnode.FieldNoReplyCondition:
  11940. v, ok := value.(uint64)
  11941. if !ok {
  11942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11943. }
  11944. m.SetNoReplyCondition(v)
  11945. return nil
  11946. case sopnode.FieldActionMessage:
  11947. v, ok := value.([]custom_types.Action)
  11948. if !ok {
  11949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11950. }
  11951. m.SetActionMessage(v)
  11952. return nil
  11953. case sopnode.FieldActionLabel:
  11954. v, ok := value.([]uint64)
  11955. if !ok {
  11956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11957. }
  11958. m.SetActionLabel(v)
  11959. return nil
  11960. }
  11961. return fmt.Errorf("unknown SopNode field %s", name)
  11962. }
  11963. // AddedFields returns all numeric fields that were incremented/decremented during
  11964. // this mutation.
  11965. func (m *SopNodeMutation) AddedFields() []string {
  11966. var fields []string
  11967. if m.addstatus != nil {
  11968. fields = append(fields, sopnode.FieldStatus)
  11969. }
  11970. if m.addparent_id != nil {
  11971. fields = append(fields, sopnode.FieldParentID)
  11972. }
  11973. if m.addcondition_type != nil {
  11974. fields = append(fields, sopnode.FieldConditionType)
  11975. }
  11976. if m.addno_reply_condition != nil {
  11977. fields = append(fields, sopnode.FieldNoReplyCondition)
  11978. }
  11979. return fields
  11980. }
  11981. // AddedField returns the numeric value that was incremented/decremented on a field
  11982. // with the given name. The second boolean return value indicates that this field
  11983. // was not set, or was not defined in the schema.
  11984. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  11985. switch name {
  11986. case sopnode.FieldStatus:
  11987. return m.AddedStatus()
  11988. case sopnode.FieldParentID:
  11989. return m.AddedParentID()
  11990. case sopnode.FieldConditionType:
  11991. return m.AddedConditionType()
  11992. case sopnode.FieldNoReplyCondition:
  11993. return m.AddedNoReplyCondition()
  11994. }
  11995. return nil, false
  11996. }
  11997. // AddField adds the value to the field with the given name. It returns an error if
  11998. // the field is not defined in the schema, or if the type mismatched the field
  11999. // type.
  12000. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  12001. switch name {
  12002. case sopnode.FieldStatus:
  12003. v, ok := value.(int8)
  12004. if !ok {
  12005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12006. }
  12007. m.AddStatus(v)
  12008. return nil
  12009. case sopnode.FieldParentID:
  12010. v, ok := value.(int64)
  12011. if !ok {
  12012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12013. }
  12014. m.AddParentID(v)
  12015. return nil
  12016. case sopnode.FieldConditionType:
  12017. v, ok := value.(int)
  12018. if !ok {
  12019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12020. }
  12021. m.AddConditionType(v)
  12022. return nil
  12023. case sopnode.FieldNoReplyCondition:
  12024. v, ok := value.(int64)
  12025. if !ok {
  12026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12027. }
  12028. m.AddNoReplyCondition(v)
  12029. return nil
  12030. }
  12031. return fmt.Errorf("unknown SopNode numeric field %s", name)
  12032. }
  12033. // ClearedFields returns all nullable fields that were cleared during this
  12034. // mutation.
  12035. func (m *SopNodeMutation) ClearedFields() []string {
  12036. var fields []string
  12037. if m.FieldCleared(sopnode.FieldStatus) {
  12038. fields = append(fields, sopnode.FieldStatus)
  12039. }
  12040. if m.FieldCleared(sopnode.FieldDeletedAt) {
  12041. fields = append(fields, sopnode.FieldDeletedAt)
  12042. }
  12043. if m.FieldCleared(sopnode.FieldConditionList) {
  12044. fields = append(fields, sopnode.FieldConditionList)
  12045. }
  12046. if m.FieldCleared(sopnode.FieldActionMessage) {
  12047. fields = append(fields, sopnode.FieldActionMessage)
  12048. }
  12049. if m.FieldCleared(sopnode.FieldActionLabel) {
  12050. fields = append(fields, sopnode.FieldActionLabel)
  12051. }
  12052. return fields
  12053. }
  12054. // FieldCleared returns a boolean indicating if a field with the given name was
  12055. // cleared in this mutation.
  12056. func (m *SopNodeMutation) FieldCleared(name string) bool {
  12057. _, ok := m.clearedFields[name]
  12058. return ok
  12059. }
  12060. // ClearField clears the value of the field with the given name. It returns an
  12061. // error if the field is not defined in the schema.
  12062. func (m *SopNodeMutation) ClearField(name string) error {
  12063. switch name {
  12064. case sopnode.FieldStatus:
  12065. m.ClearStatus()
  12066. return nil
  12067. case sopnode.FieldDeletedAt:
  12068. m.ClearDeletedAt()
  12069. return nil
  12070. case sopnode.FieldConditionList:
  12071. m.ClearConditionList()
  12072. return nil
  12073. case sopnode.FieldActionMessage:
  12074. m.ClearActionMessage()
  12075. return nil
  12076. case sopnode.FieldActionLabel:
  12077. m.ClearActionLabel()
  12078. return nil
  12079. }
  12080. return fmt.Errorf("unknown SopNode nullable field %s", name)
  12081. }
  12082. // ResetField resets all changes in the mutation for the field with the given name.
  12083. // It returns an error if the field is not defined in the schema.
  12084. func (m *SopNodeMutation) ResetField(name string) error {
  12085. switch name {
  12086. case sopnode.FieldCreatedAt:
  12087. m.ResetCreatedAt()
  12088. return nil
  12089. case sopnode.FieldUpdatedAt:
  12090. m.ResetUpdatedAt()
  12091. return nil
  12092. case sopnode.FieldStatus:
  12093. m.ResetStatus()
  12094. return nil
  12095. case sopnode.FieldDeletedAt:
  12096. m.ResetDeletedAt()
  12097. return nil
  12098. case sopnode.FieldStageID:
  12099. m.ResetStageID()
  12100. return nil
  12101. case sopnode.FieldParentID:
  12102. m.ResetParentID()
  12103. return nil
  12104. case sopnode.FieldName:
  12105. m.ResetName()
  12106. return nil
  12107. case sopnode.FieldConditionType:
  12108. m.ResetConditionType()
  12109. return nil
  12110. case sopnode.FieldConditionList:
  12111. m.ResetConditionList()
  12112. return nil
  12113. case sopnode.FieldNoReplyCondition:
  12114. m.ResetNoReplyCondition()
  12115. return nil
  12116. case sopnode.FieldActionMessage:
  12117. m.ResetActionMessage()
  12118. return nil
  12119. case sopnode.FieldActionLabel:
  12120. m.ResetActionLabel()
  12121. return nil
  12122. }
  12123. return fmt.Errorf("unknown SopNode field %s", name)
  12124. }
  12125. // AddedEdges returns all edge names that were set/added in this mutation.
  12126. func (m *SopNodeMutation) AddedEdges() []string {
  12127. edges := make([]string, 0, 2)
  12128. if m.sop_stage != nil {
  12129. edges = append(edges, sopnode.EdgeSopStage)
  12130. }
  12131. if m.node_messages != nil {
  12132. edges = append(edges, sopnode.EdgeNodeMessages)
  12133. }
  12134. return edges
  12135. }
  12136. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12137. // name in this mutation.
  12138. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  12139. switch name {
  12140. case sopnode.EdgeSopStage:
  12141. if id := m.sop_stage; id != nil {
  12142. return []ent.Value{*id}
  12143. }
  12144. case sopnode.EdgeNodeMessages:
  12145. ids := make([]ent.Value, 0, len(m.node_messages))
  12146. for id := range m.node_messages {
  12147. ids = append(ids, id)
  12148. }
  12149. return ids
  12150. }
  12151. return nil
  12152. }
  12153. // RemovedEdges returns all edge names that were removed in this mutation.
  12154. func (m *SopNodeMutation) RemovedEdges() []string {
  12155. edges := make([]string, 0, 2)
  12156. if m.removednode_messages != nil {
  12157. edges = append(edges, sopnode.EdgeNodeMessages)
  12158. }
  12159. return edges
  12160. }
  12161. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12162. // the given name in this mutation.
  12163. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  12164. switch name {
  12165. case sopnode.EdgeNodeMessages:
  12166. ids := make([]ent.Value, 0, len(m.removednode_messages))
  12167. for id := range m.removednode_messages {
  12168. ids = append(ids, id)
  12169. }
  12170. return ids
  12171. }
  12172. return nil
  12173. }
  12174. // ClearedEdges returns all edge names that were cleared in this mutation.
  12175. func (m *SopNodeMutation) ClearedEdges() []string {
  12176. edges := make([]string, 0, 2)
  12177. if m.clearedsop_stage {
  12178. edges = append(edges, sopnode.EdgeSopStage)
  12179. }
  12180. if m.clearednode_messages {
  12181. edges = append(edges, sopnode.EdgeNodeMessages)
  12182. }
  12183. return edges
  12184. }
  12185. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12186. // was cleared in this mutation.
  12187. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  12188. switch name {
  12189. case sopnode.EdgeSopStage:
  12190. return m.clearedsop_stage
  12191. case sopnode.EdgeNodeMessages:
  12192. return m.clearednode_messages
  12193. }
  12194. return false
  12195. }
  12196. // ClearEdge clears the value of the edge with the given name. It returns an error
  12197. // if that edge is not defined in the schema.
  12198. func (m *SopNodeMutation) ClearEdge(name string) error {
  12199. switch name {
  12200. case sopnode.EdgeSopStage:
  12201. m.ClearSopStage()
  12202. return nil
  12203. }
  12204. return fmt.Errorf("unknown SopNode unique edge %s", name)
  12205. }
  12206. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12207. // It returns an error if the edge is not defined in the schema.
  12208. func (m *SopNodeMutation) ResetEdge(name string) error {
  12209. switch name {
  12210. case sopnode.EdgeSopStage:
  12211. m.ResetSopStage()
  12212. return nil
  12213. case sopnode.EdgeNodeMessages:
  12214. m.ResetNodeMessages()
  12215. return nil
  12216. }
  12217. return fmt.Errorf("unknown SopNode edge %s", name)
  12218. }
  12219. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  12220. type SopStageMutation struct {
  12221. config
  12222. op Op
  12223. typ string
  12224. id *uint64
  12225. created_at *time.Time
  12226. updated_at *time.Time
  12227. status *uint8
  12228. addstatus *int8
  12229. deleted_at *time.Time
  12230. name *string
  12231. condition_type *int
  12232. addcondition_type *int
  12233. condition_operator *int
  12234. addcondition_operator *int
  12235. condition_list *[]custom_types.Condition
  12236. appendcondition_list []custom_types.Condition
  12237. action_message *[]custom_types.Action
  12238. appendaction_message []custom_types.Action
  12239. action_label *[]uint64
  12240. appendaction_label []uint64
  12241. index_sort *int
  12242. addindex_sort *int
  12243. clearedFields map[string]struct{}
  12244. sop_task *uint64
  12245. clearedsop_task bool
  12246. stage_nodes map[uint64]struct{}
  12247. removedstage_nodes map[uint64]struct{}
  12248. clearedstage_nodes bool
  12249. stage_messages map[uint64]struct{}
  12250. removedstage_messages map[uint64]struct{}
  12251. clearedstage_messages bool
  12252. done bool
  12253. oldValue func(context.Context) (*SopStage, error)
  12254. predicates []predicate.SopStage
  12255. }
  12256. var _ ent.Mutation = (*SopStageMutation)(nil)
  12257. // sopstageOption allows management of the mutation configuration using functional options.
  12258. type sopstageOption func(*SopStageMutation)
  12259. // newSopStageMutation creates new mutation for the SopStage entity.
  12260. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  12261. m := &SopStageMutation{
  12262. config: c,
  12263. op: op,
  12264. typ: TypeSopStage,
  12265. clearedFields: make(map[string]struct{}),
  12266. }
  12267. for _, opt := range opts {
  12268. opt(m)
  12269. }
  12270. return m
  12271. }
  12272. // withSopStageID sets the ID field of the mutation.
  12273. func withSopStageID(id uint64) sopstageOption {
  12274. return func(m *SopStageMutation) {
  12275. var (
  12276. err error
  12277. once sync.Once
  12278. value *SopStage
  12279. )
  12280. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  12281. once.Do(func() {
  12282. if m.done {
  12283. err = errors.New("querying old values post mutation is not allowed")
  12284. } else {
  12285. value, err = m.Client().SopStage.Get(ctx, id)
  12286. }
  12287. })
  12288. return value, err
  12289. }
  12290. m.id = &id
  12291. }
  12292. }
  12293. // withSopStage sets the old SopStage of the mutation.
  12294. func withSopStage(node *SopStage) sopstageOption {
  12295. return func(m *SopStageMutation) {
  12296. m.oldValue = func(context.Context) (*SopStage, error) {
  12297. return node, nil
  12298. }
  12299. m.id = &node.ID
  12300. }
  12301. }
  12302. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12303. // executed in a transaction (ent.Tx), a transactional client is returned.
  12304. func (m SopStageMutation) Client() *Client {
  12305. client := &Client{config: m.config}
  12306. client.init()
  12307. return client
  12308. }
  12309. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12310. // it returns an error otherwise.
  12311. func (m SopStageMutation) Tx() (*Tx, error) {
  12312. if _, ok := m.driver.(*txDriver); !ok {
  12313. return nil, errors.New("ent: mutation is not running in a transaction")
  12314. }
  12315. tx := &Tx{config: m.config}
  12316. tx.init()
  12317. return tx, nil
  12318. }
  12319. // SetID sets the value of the id field. Note that this
  12320. // operation is only accepted on creation of SopStage entities.
  12321. func (m *SopStageMutation) SetID(id uint64) {
  12322. m.id = &id
  12323. }
  12324. // ID returns the ID value in the mutation. Note that the ID is only available
  12325. // if it was provided to the builder or after it was returned from the database.
  12326. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  12327. if m.id == nil {
  12328. return
  12329. }
  12330. return *m.id, true
  12331. }
  12332. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12333. // That means, if the mutation is applied within a transaction with an isolation level such
  12334. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12335. // or updated by the mutation.
  12336. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  12337. switch {
  12338. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12339. id, exists := m.ID()
  12340. if exists {
  12341. return []uint64{id}, nil
  12342. }
  12343. fallthrough
  12344. case m.op.Is(OpUpdate | OpDelete):
  12345. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  12346. default:
  12347. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12348. }
  12349. }
  12350. // SetCreatedAt sets the "created_at" field.
  12351. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  12352. m.created_at = &t
  12353. }
  12354. // CreatedAt returns the value of the "created_at" field in the mutation.
  12355. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  12356. v := m.created_at
  12357. if v == nil {
  12358. return
  12359. }
  12360. return *v, true
  12361. }
  12362. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  12363. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12365. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12366. if !m.op.Is(OpUpdateOne) {
  12367. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12368. }
  12369. if m.id == nil || m.oldValue == nil {
  12370. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12371. }
  12372. oldValue, err := m.oldValue(ctx)
  12373. if err != nil {
  12374. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12375. }
  12376. return oldValue.CreatedAt, nil
  12377. }
  12378. // ResetCreatedAt resets all changes to the "created_at" field.
  12379. func (m *SopStageMutation) ResetCreatedAt() {
  12380. m.created_at = nil
  12381. }
  12382. // SetUpdatedAt sets the "updated_at" field.
  12383. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  12384. m.updated_at = &t
  12385. }
  12386. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12387. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  12388. v := m.updated_at
  12389. if v == nil {
  12390. return
  12391. }
  12392. return *v, true
  12393. }
  12394. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  12395. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12397. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12398. if !m.op.Is(OpUpdateOne) {
  12399. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12400. }
  12401. if m.id == nil || m.oldValue == nil {
  12402. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12403. }
  12404. oldValue, err := m.oldValue(ctx)
  12405. if err != nil {
  12406. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12407. }
  12408. return oldValue.UpdatedAt, nil
  12409. }
  12410. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12411. func (m *SopStageMutation) ResetUpdatedAt() {
  12412. m.updated_at = nil
  12413. }
  12414. // SetStatus sets the "status" field.
  12415. func (m *SopStageMutation) SetStatus(u uint8) {
  12416. m.status = &u
  12417. m.addstatus = nil
  12418. }
  12419. // Status returns the value of the "status" field in the mutation.
  12420. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  12421. v := m.status
  12422. if v == nil {
  12423. return
  12424. }
  12425. return *v, true
  12426. }
  12427. // OldStatus returns the old "status" field's value of the SopStage entity.
  12428. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12430. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12431. if !m.op.Is(OpUpdateOne) {
  12432. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12433. }
  12434. if m.id == nil || m.oldValue == nil {
  12435. return v, errors.New("OldStatus requires an ID field in the mutation")
  12436. }
  12437. oldValue, err := m.oldValue(ctx)
  12438. if err != nil {
  12439. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12440. }
  12441. return oldValue.Status, nil
  12442. }
  12443. // AddStatus adds u to the "status" field.
  12444. func (m *SopStageMutation) AddStatus(u int8) {
  12445. if m.addstatus != nil {
  12446. *m.addstatus += u
  12447. } else {
  12448. m.addstatus = &u
  12449. }
  12450. }
  12451. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12452. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  12453. v := m.addstatus
  12454. if v == nil {
  12455. return
  12456. }
  12457. return *v, true
  12458. }
  12459. // ClearStatus clears the value of the "status" field.
  12460. func (m *SopStageMutation) ClearStatus() {
  12461. m.status = nil
  12462. m.addstatus = nil
  12463. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  12464. }
  12465. // StatusCleared returns if the "status" field was cleared in this mutation.
  12466. func (m *SopStageMutation) StatusCleared() bool {
  12467. _, ok := m.clearedFields[sopstage.FieldStatus]
  12468. return ok
  12469. }
  12470. // ResetStatus resets all changes to the "status" field.
  12471. func (m *SopStageMutation) ResetStatus() {
  12472. m.status = nil
  12473. m.addstatus = nil
  12474. delete(m.clearedFields, sopstage.FieldStatus)
  12475. }
  12476. // SetDeletedAt sets the "deleted_at" field.
  12477. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  12478. m.deleted_at = &t
  12479. }
  12480. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12481. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  12482. v := m.deleted_at
  12483. if v == nil {
  12484. return
  12485. }
  12486. return *v, true
  12487. }
  12488. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  12489. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12491. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12492. if !m.op.Is(OpUpdateOne) {
  12493. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12494. }
  12495. if m.id == nil || m.oldValue == nil {
  12496. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12497. }
  12498. oldValue, err := m.oldValue(ctx)
  12499. if err != nil {
  12500. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12501. }
  12502. return oldValue.DeletedAt, nil
  12503. }
  12504. // ClearDeletedAt clears the value of the "deleted_at" field.
  12505. func (m *SopStageMutation) ClearDeletedAt() {
  12506. m.deleted_at = nil
  12507. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  12508. }
  12509. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12510. func (m *SopStageMutation) DeletedAtCleared() bool {
  12511. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  12512. return ok
  12513. }
  12514. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12515. func (m *SopStageMutation) ResetDeletedAt() {
  12516. m.deleted_at = nil
  12517. delete(m.clearedFields, sopstage.FieldDeletedAt)
  12518. }
  12519. // SetTaskID sets the "task_id" field.
  12520. func (m *SopStageMutation) SetTaskID(u uint64) {
  12521. m.sop_task = &u
  12522. }
  12523. // TaskID returns the value of the "task_id" field in the mutation.
  12524. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  12525. v := m.sop_task
  12526. if v == nil {
  12527. return
  12528. }
  12529. return *v, true
  12530. }
  12531. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  12532. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12534. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  12535. if !m.op.Is(OpUpdateOne) {
  12536. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  12537. }
  12538. if m.id == nil || m.oldValue == nil {
  12539. return v, errors.New("OldTaskID requires an ID field in the mutation")
  12540. }
  12541. oldValue, err := m.oldValue(ctx)
  12542. if err != nil {
  12543. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  12544. }
  12545. return oldValue.TaskID, nil
  12546. }
  12547. // ResetTaskID resets all changes to the "task_id" field.
  12548. func (m *SopStageMutation) ResetTaskID() {
  12549. m.sop_task = nil
  12550. }
  12551. // SetName sets the "name" field.
  12552. func (m *SopStageMutation) SetName(s string) {
  12553. m.name = &s
  12554. }
  12555. // Name returns the value of the "name" field in the mutation.
  12556. func (m *SopStageMutation) Name() (r string, exists bool) {
  12557. v := m.name
  12558. if v == nil {
  12559. return
  12560. }
  12561. return *v, true
  12562. }
  12563. // OldName returns the old "name" field's value of the SopStage entity.
  12564. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12566. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  12567. if !m.op.Is(OpUpdateOne) {
  12568. return v, errors.New("OldName is only allowed on UpdateOne operations")
  12569. }
  12570. if m.id == nil || m.oldValue == nil {
  12571. return v, errors.New("OldName requires an ID field in the mutation")
  12572. }
  12573. oldValue, err := m.oldValue(ctx)
  12574. if err != nil {
  12575. return v, fmt.Errorf("querying old value for OldName: %w", err)
  12576. }
  12577. return oldValue.Name, nil
  12578. }
  12579. // ResetName resets all changes to the "name" field.
  12580. func (m *SopStageMutation) ResetName() {
  12581. m.name = nil
  12582. }
  12583. // SetConditionType sets the "condition_type" field.
  12584. func (m *SopStageMutation) SetConditionType(i int) {
  12585. m.condition_type = &i
  12586. m.addcondition_type = nil
  12587. }
  12588. // ConditionType returns the value of the "condition_type" field in the mutation.
  12589. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  12590. v := m.condition_type
  12591. if v == nil {
  12592. return
  12593. }
  12594. return *v, true
  12595. }
  12596. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  12597. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12599. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  12600. if !m.op.Is(OpUpdateOne) {
  12601. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  12602. }
  12603. if m.id == nil || m.oldValue == nil {
  12604. return v, errors.New("OldConditionType requires an ID field in the mutation")
  12605. }
  12606. oldValue, err := m.oldValue(ctx)
  12607. if err != nil {
  12608. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  12609. }
  12610. return oldValue.ConditionType, nil
  12611. }
  12612. // AddConditionType adds i to the "condition_type" field.
  12613. func (m *SopStageMutation) AddConditionType(i int) {
  12614. if m.addcondition_type != nil {
  12615. *m.addcondition_type += i
  12616. } else {
  12617. m.addcondition_type = &i
  12618. }
  12619. }
  12620. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  12621. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  12622. v := m.addcondition_type
  12623. if v == nil {
  12624. return
  12625. }
  12626. return *v, true
  12627. }
  12628. // ResetConditionType resets all changes to the "condition_type" field.
  12629. func (m *SopStageMutation) ResetConditionType() {
  12630. m.condition_type = nil
  12631. m.addcondition_type = nil
  12632. }
  12633. // SetConditionOperator sets the "condition_operator" field.
  12634. func (m *SopStageMutation) SetConditionOperator(i int) {
  12635. m.condition_operator = &i
  12636. m.addcondition_operator = nil
  12637. }
  12638. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  12639. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  12640. v := m.condition_operator
  12641. if v == nil {
  12642. return
  12643. }
  12644. return *v, true
  12645. }
  12646. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  12647. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12649. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  12650. if !m.op.Is(OpUpdateOne) {
  12651. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  12652. }
  12653. if m.id == nil || m.oldValue == nil {
  12654. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  12655. }
  12656. oldValue, err := m.oldValue(ctx)
  12657. if err != nil {
  12658. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  12659. }
  12660. return oldValue.ConditionOperator, nil
  12661. }
  12662. // AddConditionOperator adds i to the "condition_operator" field.
  12663. func (m *SopStageMutation) AddConditionOperator(i int) {
  12664. if m.addcondition_operator != nil {
  12665. *m.addcondition_operator += i
  12666. } else {
  12667. m.addcondition_operator = &i
  12668. }
  12669. }
  12670. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  12671. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  12672. v := m.addcondition_operator
  12673. if v == nil {
  12674. return
  12675. }
  12676. return *v, true
  12677. }
  12678. // ResetConditionOperator resets all changes to the "condition_operator" field.
  12679. func (m *SopStageMutation) ResetConditionOperator() {
  12680. m.condition_operator = nil
  12681. m.addcondition_operator = nil
  12682. }
  12683. // SetConditionList sets the "condition_list" field.
  12684. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  12685. m.condition_list = &ct
  12686. m.appendcondition_list = nil
  12687. }
  12688. // ConditionList returns the value of the "condition_list" field in the mutation.
  12689. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  12690. v := m.condition_list
  12691. if v == nil {
  12692. return
  12693. }
  12694. return *v, true
  12695. }
  12696. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  12697. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12699. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  12700. if !m.op.Is(OpUpdateOne) {
  12701. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  12702. }
  12703. if m.id == nil || m.oldValue == nil {
  12704. return v, errors.New("OldConditionList requires an ID field in the mutation")
  12705. }
  12706. oldValue, err := m.oldValue(ctx)
  12707. if err != nil {
  12708. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  12709. }
  12710. return oldValue.ConditionList, nil
  12711. }
  12712. // AppendConditionList adds ct to the "condition_list" field.
  12713. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  12714. m.appendcondition_list = append(m.appendcondition_list, ct...)
  12715. }
  12716. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  12717. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  12718. if len(m.appendcondition_list) == 0 {
  12719. return nil, false
  12720. }
  12721. return m.appendcondition_list, true
  12722. }
  12723. // ResetConditionList resets all changes to the "condition_list" field.
  12724. func (m *SopStageMutation) ResetConditionList() {
  12725. m.condition_list = nil
  12726. m.appendcondition_list = nil
  12727. }
  12728. // SetActionMessage sets the "action_message" field.
  12729. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  12730. m.action_message = &ct
  12731. m.appendaction_message = nil
  12732. }
  12733. // ActionMessage returns the value of the "action_message" field in the mutation.
  12734. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  12735. v := m.action_message
  12736. if v == nil {
  12737. return
  12738. }
  12739. return *v, true
  12740. }
  12741. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  12742. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12744. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  12745. if !m.op.Is(OpUpdateOne) {
  12746. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  12747. }
  12748. if m.id == nil || m.oldValue == nil {
  12749. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  12750. }
  12751. oldValue, err := m.oldValue(ctx)
  12752. if err != nil {
  12753. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  12754. }
  12755. return oldValue.ActionMessage, nil
  12756. }
  12757. // AppendActionMessage adds ct to the "action_message" field.
  12758. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  12759. m.appendaction_message = append(m.appendaction_message, ct...)
  12760. }
  12761. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  12762. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  12763. if len(m.appendaction_message) == 0 {
  12764. return nil, false
  12765. }
  12766. return m.appendaction_message, true
  12767. }
  12768. // ClearActionMessage clears the value of the "action_message" field.
  12769. func (m *SopStageMutation) ClearActionMessage() {
  12770. m.action_message = nil
  12771. m.appendaction_message = nil
  12772. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  12773. }
  12774. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  12775. func (m *SopStageMutation) ActionMessageCleared() bool {
  12776. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  12777. return ok
  12778. }
  12779. // ResetActionMessage resets all changes to the "action_message" field.
  12780. func (m *SopStageMutation) ResetActionMessage() {
  12781. m.action_message = nil
  12782. m.appendaction_message = nil
  12783. delete(m.clearedFields, sopstage.FieldActionMessage)
  12784. }
  12785. // SetActionLabel sets the "action_label" field.
  12786. func (m *SopStageMutation) SetActionLabel(u []uint64) {
  12787. m.action_label = &u
  12788. m.appendaction_label = nil
  12789. }
  12790. // ActionLabel returns the value of the "action_label" field in the mutation.
  12791. func (m *SopStageMutation) ActionLabel() (r []uint64, exists bool) {
  12792. v := m.action_label
  12793. if v == nil {
  12794. return
  12795. }
  12796. return *v, true
  12797. }
  12798. // OldActionLabel returns the old "action_label" field's value of the SopStage entity.
  12799. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12801. func (m *SopStageMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  12802. if !m.op.Is(OpUpdateOne) {
  12803. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  12804. }
  12805. if m.id == nil || m.oldValue == nil {
  12806. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  12807. }
  12808. oldValue, err := m.oldValue(ctx)
  12809. if err != nil {
  12810. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  12811. }
  12812. return oldValue.ActionLabel, nil
  12813. }
  12814. // AppendActionLabel adds u to the "action_label" field.
  12815. func (m *SopStageMutation) AppendActionLabel(u []uint64) {
  12816. m.appendaction_label = append(m.appendaction_label, u...)
  12817. }
  12818. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  12819. func (m *SopStageMutation) AppendedActionLabel() ([]uint64, bool) {
  12820. if len(m.appendaction_label) == 0 {
  12821. return nil, false
  12822. }
  12823. return m.appendaction_label, true
  12824. }
  12825. // ClearActionLabel clears the value of the "action_label" field.
  12826. func (m *SopStageMutation) ClearActionLabel() {
  12827. m.action_label = nil
  12828. m.appendaction_label = nil
  12829. m.clearedFields[sopstage.FieldActionLabel] = struct{}{}
  12830. }
  12831. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  12832. func (m *SopStageMutation) ActionLabelCleared() bool {
  12833. _, ok := m.clearedFields[sopstage.FieldActionLabel]
  12834. return ok
  12835. }
  12836. // ResetActionLabel resets all changes to the "action_label" field.
  12837. func (m *SopStageMutation) ResetActionLabel() {
  12838. m.action_label = nil
  12839. m.appendaction_label = nil
  12840. delete(m.clearedFields, sopstage.FieldActionLabel)
  12841. }
  12842. // SetIndexSort sets the "index_sort" field.
  12843. func (m *SopStageMutation) SetIndexSort(i int) {
  12844. m.index_sort = &i
  12845. m.addindex_sort = nil
  12846. }
  12847. // IndexSort returns the value of the "index_sort" field in the mutation.
  12848. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  12849. v := m.index_sort
  12850. if v == nil {
  12851. return
  12852. }
  12853. return *v, true
  12854. }
  12855. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  12856. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12858. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  12859. if !m.op.Is(OpUpdateOne) {
  12860. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  12861. }
  12862. if m.id == nil || m.oldValue == nil {
  12863. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  12864. }
  12865. oldValue, err := m.oldValue(ctx)
  12866. if err != nil {
  12867. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  12868. }
  12869. return oldValue.IndexSort, nil
  12870. }
  12871. // AddIndexSort adds i to the "index_sort" field.
  12872. func (m *SopStageMutation) AddIndexSort(i int) {
  12873. if m.addindex_sort != nil {
  12874. *m.addindex_sort += i
  12875. } else {
  12876. m.addindex_sort = &i
  12877. }
  12878. }
  12879. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  12880. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  12881. v := m.addindex_sort
  12882. if v == nil {
  12883. return
  12884. }
  12885. return *v, true
  12886. }
  12887. // ClearIndexSort clears the value of the "index_sort" field.
  12888. func (m *SopStageMutation) ClearIndexSort() {
  12889. m.index_sort = nil
  12890. m.addindex_sort = nil
  12891. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  12892. }
  12893. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  12894. func (m *SopStageMutation) IndexSortCleared() bool {
  12895. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  12896. return ok
  12897. }
  12898. // ResetIndexSort resets all changes to the "index_sort" field.
  12899. func (m *SopStageMutation) ResetIndexSort() {
  12900. m.index_sort = nil
  12901. m.addindex_sort = nil
  12902. delete(m.clearedFields, sopstage.FieldIndexSort)
  12903. }
  12904. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  12905. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  12906. m.sop_task = &id
  12907. }
  12908. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  12909. func (m *SopStageMutation) ClearSopTask() {
  12910. m.clearedsop_task = true
  12911. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  12912. }
  12913. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  12914. func (m *SopStageMutation) SopTaskCleared() bool {
  12915. return m.clearedsop_task
  12916. }
  12917. // SopTaskID returns the "sop_task" edge ID in the mutation.
  12918. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  12919. if m.sop_task != nil {
  12920. return *m.sop_task, true
  12921. }
  12922. return
  12923. }
  12924. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  12925. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12926. // SopTaskID instead. It exists only for internal usage by the builders.
  12927. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  12928. if id := m.sop_task; id != nil {
  12929. ids = append(ids, *id)
  12930. }
  12931. return
  12932. }
  12933. // ResetSopTask resets all changes to the "sop_task" edge.
  12934. func (m *SopStageMutation) ResetSopTask() {
  12935. m.sop_task = nil
  12936. m.clearedsop_task = false
  12937. }
  12938. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  12939. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  12940. if m.stage_nodes == nil {
  12941. m.stage_nodes = make(map[uint64]struct{})
  12942. }
  12943. for i := range ids {
  12944. m.stage_nodes[ids[i]] = struct{}{}
  12945. }
  12946. }
  12947. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  12948. func (m *SopStageMutation) ClearStageNodes() {
  12949. m.clearedstage_nodes = true
  12950. }
  12951. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  12952. func (m *SopStageMutation) StageNodesCleared() bool {
  12953. return m.clearedstage_nodes
  12954. }
  12955. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  12956. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  12957. if m.removedstage_nodes == nil {
  12958. m.removedstage_nodes = make(map[uint64]struct{})
  12959. }
  12960. for i := range ids {
  12961. delete(m.stage_nodes, ids[i])
  12962. m.removedstage_nodes[ids[i]] = struct{}{}
  12963. }
  12964. }
  12965. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  12966. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  12967. for id := range m.removedstage_nodes {
  12968. ids = append(ids, id)
  12969. }
  12970. return
  12971. }
  12972. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  12973. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  12974. for id := range m.stage_nodes {
  12975. ids = append(ids, id)
  12976. }
  12977. return
  12978. }
  12979. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  12980. func (m *SopStageMutation) ResetStageNodes() {
  12981. m.stage_nodes = nil
  12982. m.clearedstage_nodes = false
  12983. m.removedstage_nodes = nil
  12984. }
  12985. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  12986. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  12987. if m.stage_messages == nil {
  12988. m.stage_messages = make(map[uint64]struct{})
  12989. }
  12990. for i := range ids {
  12991. m.stage_messages[ids[i]] = struct{}{}
  12992. }
  12993. }
  12994. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  12995. func (m *SopStageMutation) ClearStageMessages() {
  12996. m.clearedstage_messages = true
  12997. }
  12998. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  12999. func (m *SopStageMutation) StageMessagesCleared() bool {
  13000. return m.clearedstage_messages
  13001. }
  13002. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  13003. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  13004. if m.removedstage_messages == nil {
  13005. m.removedstage_messages = make(map[uint64]struct{})
  13006. }
  13007. for i := range ids {
  13008. delete(m.stage_messages, ids[i])
  13009. m.removedstage_messages[ids[i]] = struct{}{}
  13010. }
  13011. }
  13012. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  13013. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  13014. for id := range m.removedstage_messages {
  13015. ids = append(ids, id)
  13016. }
  13017. return
  13018. }
  13019. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  13020. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  13021. for id := range m.stage_messages {
  13022. ids = append(ids, id)
  13023. }
  13024. return
  13025. }
  13026. // ResetStageMessages resets all changes to the "stage_messages" edge.
  13027. func (m *SopStageMutation) ResetStageMessages() {
  13028. m.stage_messages = nil
  13029. m.clearedstage_messages = false
  13030. m.removedstage_messages = nil
  13031. }
  13032. // Where appends a list predicates to the SopStageMutation builder.
  13033. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  13034. m.predicates = append(m.predicates, ps...)
  13035. }
  13036. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  13037. // users can use type-assertion to append predicates that do not depend on any generated package.
  13038. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  13039. p := make([]predicate.SopStage, len(ps))
  13040. for i := range ps {
  13041. p[i] = ps[i]
  13042. }
  13043. m.Where(p...)
  13044. }
  13045. // Op returns the operation name.
  13046. func (m *SopStageMutation) Op() Op {
  13047. return m.op
  13048. }
  13049. // SetOp allows setting the mutation operation.
  13050. func (m *SopStageMutation) SetOp(op Op) {
  13051. m.op = op
  13052. }
  13053. // Type returns the node type of this mutation (SopStage).
  13054. func (m *SopStageMutation) Type() string {
  13055. return m.typ
  13056. }
  13057. // Fields returns all fields that were changed during this mutation. Note that in
  13058. // order to get all numeric fields that were incremented/decremented, call
  13059. // AddedFields().
  13060. func (m *SopStageMutation) Fields() []string {
  13061. fields := make([]string, 0, 12)
  13062. if m.created_at != nil {
  13063. fields = append(fields, sopstage.FieldCreatedAt)
  13064. }
  13065. if m.updated_at != nil {
  13066. fields = append(fields, sopstage.FieldUpdatedAt)
  13067. }
  13068. if m.status != nil {
  13069. fields = append(fields, sopstage.FieldStatus)
  13070. }
  13071. if m.deleted_at != nil {
  13072. fields = append(fields, sopstage.FieldDeletedAt)
  13073. }
  13074. if m.sop_task != nil {
  13075. fields = append(fields, sopstage.FieldTaskID)
  13076. }
  13077. if m.name != nil {
  13078. fields = append(fields, sopstage.FieldName)
  13079. }
  13080. if m.condition_type != nil {
  13081. fields = append(fields, sopstage.FieldConditionType)
  13082. }
  13083. if m.condition_operator != nil {
  13084. fields = append(fields, sopstage.FieldConditionOperator)
  13085. }
  13086. if m.condition_list != nil {
  13087. fields = append(fields, sopstage.FieldConditionList)
  13088. }
  13089. if m.action_message != nil {
  13090. fields = append(fields, sopstage.FieldActionMessage)
  13091. }
  13092. if m.action_label != nil {
  13093. fields = append(fields, sopstage.FieldActionLabel)
  13094. }
  13095. if m.index_sort != nil {
  13096. fields = append(fields, sopstage.FieldIndexSort)
  13097. }
  13098. return fields
  13099. }
  13100. // Field returns the value of a field with the given name. The second boolean
  13101. // return value indicates that this field was not set, or was not defined in the
  13102. // schema.
  13103. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  13104. switch name {
  13105. case sopstage.FieldCreatedAt:
  13106. return m.CreatedAt()
  13107. case sopstage.FieldUpdatedAt:
  13108. return m.UpdatedAt()
  13109. case sopstage.FieldStatus:
  13110. return m.Status()
  13111. case sopstage.FieldDeletedAt:
  13112. return m.DeletedAt()
  13113. case sopstage.FieldTaskID:
  13114. return m.TaskID()
  13115. case sopstage.FieldName:
  13116. return m.Name()
  13117. case sopstage.FieldConditionType:
  13118. return m.ConditionType()
  13119. case sopstage.FieldConditionOperator:
  13120. return m.ConditionOperator()
  13121. case sopstage.FieldConditionList:
  13122. return m.ConditionList()
  13123. case sopstage.FieldActionMessage:
  13124. return m.ActionMessage()
  13125. case sopstage.FieldActionLabel:
  13126. return m.ActionLabel()
  13127. case sopstage.FieldIndexSort:
  13128. return m.IndexSort()
  13129. }
  13130. return nil, false
  13131. }
  13132. // OldField returns the old value of the field from the database. An error is
  13133. // returned if the mutation operation is not UpdateOne, or the query to the
  13134. // database failed.
  13135. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13136. switch name {
  13137. case sopstage.FieldCreatedAt:
  13138. return m.OldCreatedAt(ctx)
  13139. case sopstage.FieldUpdatedAt:
  13140. return m.OldUpdatedAt(ctx)
  13141. case sopstage.FieldStatus:
  13142. return m.OldStatus(ctx)
  13143. case sopstage.FieldDeletedAt:
  13144. return m.OldDeletedAt(ctx)
  13145. case sopstage.FieldTaskID:
  13146. return m.OldTaskID(ctx)
  13147. case sopstage.FieldName:
  13148. return m.OldName(ctx)
  13149. case sopstage.FieldConditionType:
  13150. return m.OldConditionType(ctx)
  13151. case sopstage.FieldConditionOperator:
  13152. return m.OldConditionOperator(ctx)
  13153. case sopstage.FieldConditionList:
  13154. return m.OldConditionList(ctx)
  13155. case sopstage.FieldActionMessage:
  13156. return m.OldActionMessage(ctx)
  13157. case sopstage.FieldActionLabel:
  13158. return m.OldActionLabel(ctx)
  13159. case sopstage.FieldIndexSort:
  13160. return m.OldIndexSort(ctx)
  13161. }
  13162. return nil, fmt.Errorf("unknown SopStage field %s", name)
  13163. }
  13164. // SetField sets the value of a field with the given name. It returns an error if
  13165. // the field is not defined in the schema, or if the type mismatched the field
  13166. // type.
  13167. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  13168. switch name {
  13169. case sopstage.FieldCreatedAt:
  13170. v, ok := value.(time.Time)
  13171. if !ok {
  13172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13173. }
  13174. m.SetCreatedAt(v)
  13175. return nil
  13176. case sopstage.FieldUpdatedAt:
  13177. v, ok := value.(time.Time)
  13178. if !ok {
  13179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13180. }
  13181. m.SetUpdatedAt(v)
  13182. return nil
  13183. case sopstage.FieldStatus:
  13184. v, ok := value.(uint8)
  13185. if !ok {
  13186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13187. }
  13188. m.SetStatus(v)
  13189. return nil
  13190. case sopstage.FieldDeletedAt:
  13191. v, ok := value.(time.Time)
  13192. if !ok {
  13193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13194. }
  13195. m.SetDeletedAt(v)
  13196. return nil
  13197. case sopstage.FieldTaskID:
  13198. v, ok := value.(uint64)
  13199. if !ok {
  13200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13201. }
  13202. m.SetTaskID(v)
  13203. return nil
  13204. case sopstage.FieldName:
  13205. v, ok := value.(string)
  13206. if !ok {
  13207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13208. }
  13209. m.SetName(v)
  13210. return nil
  13211. case sopstage.FieldConditionType:
  13212. v, ok := value.(int)
  13213. if !ok {
  13214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13215. }
  13216. m.SetConditionType(v)
  13217. return nil
  13218. case sopstage.FieldConditionOperator:
  13219. v, ok := value.(int)
  13220. if !ok {
  13221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13222. }
  13223. m.SetConditionOperator(v)
  13224. return nil
  13225. case sopstage.FieldConditionList:
  13226. v, ok := value.([]custom_types.Condition)
  13227. if !ok {
  13228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13229. }
  13230. m.SetConditionList(v)
  13231. return nil
  13232. case sopstage.FieldActionMessage:
  13233. v, ok := value.([]custom_types.Action)
  13234. if !ok {
  13235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13236. }
  13237. m.SetActionMessage(v)
  13238. return nil
  13239. case sopstage.FieldActionLabel:
  13240. v, ok := value.([]uint64)
  13241. if !ok {
  13242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13243. }
  13244. m.SetActionLabel(v)
  13245. return nil
  13246. case sopstage.FieldIndexSort:
  13247. v, ok := value.(int)
  13248. if !ok {
  13249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13250. }
  13251. m.SetIndexSort(v)
  13252. return nil
  13253. }
  13254. return fmt.Errorf("unknown SopStage field %s", name)
  13255. }
  13256. // AddedFields returns all numeric fields that were incremented/decremented during
  13257. // this mutation.
  13258. func (m *SopStageMutation) AddedFields() []string {
  13259. var fields []string
  13260. if m.addstatus != nil {
  13261. fields = append(fields, sopstage.FieldStatus)
  13262. }
  13263. if m.addcondition_type != nil {
  13264. fields = append(fields, sopstage.FieldConditionType)
  13265. }
  13266. if m.addcondition_operator != nil {
  13267. fields = append(fields, sopstage.FieldConditionOperator)
  13268. }
  13269. if m.addindex_sort != nil {
  13270. fields = append(fields, sopstage.FieldIndexSort)
  13271. }
  13272. return fields
  13273. }
  13274. // AddedField returns the numeric value that was incremented/decremented on a field
  13275. // with the given name. The second boolean return value indicates that this field
  13276. // was not set, or was not defined in the schema.
  13277. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  13278. switch name {
  13279. case sopstage.FieldStatus:
  13280. return m.AddedStatus()
  13281. case sopstage.FieldConditionType:
  13282. return m.AddedConditionType()
  13283. case sopstage.FieldConditionOperator:
  13284. return m.AddedConditionOperator()
  13285. case sopstage.FieldIndexSort:
  13286. return m.AddedIndexSort()
  13287. }
  13288. return nil, false
  13289. }
  13290. // AddField adds the value to the field with the given name. It returns an error if
  13291. // the field is not defined in the schema, or if the type mismatched the field
  13292. // type.
  13293. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  13294. switch name {
  13295. case sopstage.FieldStatus:
  13296. v, ok := value.(int8)
  13297. if !ok {
  13298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13299. }
  13300. m.AddStatus(v)
  13301. return nil
  13302. case sopstage.FieldConditionType:
  13303. v, ok := value.(int)
  13304. if !ok {
  13305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13306. }
  13307. m.AddConditionType(v)
  13308. return nil
  13309. case sopstage.FieldConditionOperator:
  13310. v, ok := value.(int)
  13311. if !ok {
  13312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13313. }
  13314. m.AddConditionOperator(v)
  13315. return nil
  13316. case sopstage.FieldIndexSort:
  13317. v, ok := value.(int)
  13318. if !ok {
  13319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13320. }
  13321. m.AddIndexSort(v)
  13322. return nil
  13323. }
  13324. return fmt.Errorf("unknown SopStage numeric field %s", name)
  13325. }
  13326. // ClearedFields returns all nullable fields that were cleared during this
  13327. // mutation.
  13328. func (m *SopStageMutation) ClearedFields() []string {
  13329. var fields []string
  13330. if m.FieldCleared(sopstage.FieldStatus) {
  13331. fields = append(fields, sopstage.FieldStatus)
  13332. }
  13333. if m.FieldCleared(sopstage.FieldDeletedAt) {
  13334. fields = append(fields, sopstage.FieldDeletedAt)
  13335. }
  13336. if m.FieldCleared(sopstage.FieldActionMessage) {
  13337. fields = append(fields, sopstage.FieldActionMessage)
  13338. }
  13339. if m.FieldCleared(sopstage.FieldActionLabel) {
  13340. fields = append(fields, sopstage.FieldActionLabel)
  13341. }
  13342. if m.FieldCleared(sopstage.FieldIndexSort) {
  13343. fields = append(fields, sopstage.FieldIndexSort)
  13344. }
  13345. return fields
  13346. }
  13347. // FieldCleared returns a boolean indicating if a field with the given name was
  13348. // cleared in this mutation.
  13349. func (m *SopStageMutation) FieldCleared(name string) bool {
  13350. _, ok := m.clearedFields[name]
  13351. return ok
  13352. }
  13353. // ClearField clears the value of the field with the given name. It returns an
  13354. // error if the field is not defined in the schema.
  13355. func (m *SopStageMutation) ClearField(name string) error {
  13356. switch name {
  13357. case sopstage.FieldStatus:
  13358. m.ClearStatus()
  13359. return nil
  13360. case sopstage.FieldDeletedAt:
  13361. m.ClearDeletedAt()
  13362. return nil
  13363. case sopstage.FieldActionMessage:
  13364. m.ClearActionMessage()
  13365. return nil
  13366. case sopstage.FieldActionLabel:
  13367. m.ClearActionLabel()
  13368. return nil
  13369. case sopstage.FieldIndexSort:
  13370. m.ClearIndexSort()
  13371. return nil
  13372. }
  13373. return fmt.Errorf("unknown SopStage nullable field %s", name)
  13374. }
  13375. // ResetField resets all changes in the mutation for the field with the given name.
  13376. // It returns an error if the field is not defined in the schema.
  13377. func (m *SopStageMutation) ResetField(name string) error {
  13378. switch name {
  13379. case sopstage.FieldCreatedAt:
  13380. m.ResetCreatedAt()
  13381. return nil
  13382. case sopstage.FieldUpdatedAt:
  13383. m.ResetUpdatedAt()
  13384. return nil
  13385. case sopstage.FieldStatus:
  13386. m.ResetStatus()
  13387. return nil
  13388. case sopstage.FieldDeletedAt:
  13389. m.ResetDeletedAt()
  13390. return nil
  13391. case sopstage.FieldTaskID:
  13392. m.ResetTaskID()
  13393. return nil
  13394. case sopstage.FieldName:
  13395. m.ResetName()
  13396. return nil
  13397. case sopstage.FieldConditionType:
  13398. m.ResetConditionType()
  13399. return nil
  13400. case sopstage.FieldConditionOperator:
  13401. m.ResetConditionOperator()
  13402. return nil
  13403. case sopstage.FieldConditionList:
  13404. m.ResetConditionList()
  13405. return nil
  13406. case sopstage.FieldActionMessage:
  13407. m.ResetActionMessage()
  13408. return nil
  13409. case sopstage.FieldActionLabel:
  13410. m.ResetActionLabel()
  13411. return nil
  13412. case sopstage.FieldIndexSort:
  13413. m.ResetIndexSort()
  13414. return nil
  13415. }
  13416. return fmt.Errorf("unknown SopStage field %s", name)
  13417. }
  13418. // AddedEdges returns all edge names that were set/added in this mutation.
  13419. func (m *SopStageMutation) AddedEdges() []string {
  13420. edges := make([]string, 0, 3)
  13421. if m.sop_task != nil {
  13422. edges = append(edges, sopstage.EdgeSopTask)
  13423. }
  13424. if m.stage_nodes != nil {
  13425. edges = append(edges, sopstage.EdgeStageNodes)
  13426. }
  13427. if m.stage_messages != nil {
  13428. edges = append(edges, sopstage.EdgeStageMessages)
  13429. }
  13430. return edges
  13431. }
  13432. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13433. // name in this mutation.
  13434. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  13435. switch name {
  13436. case sopstage.EdgeSopTask:
  13437. if id := m.sop_task; id != nil {
  13438. return []ent.Value{*id}
  13439. }
  13440. case sopstage.EdgeStageNodes:
  13441. ids := make([]ent.Value, 0, len(m.stage_nodes))
  13442. for id := range m.stage_nodes {
  13443. ids = append(ids, id)
  13444. }
  13445. return ids
  13446. case sopstage.EdgeStageMessages:
  13447. ids := make([]ent.Value, 0, len(m.stage_messages))
  13448. for id := range m.stage_messages {
  13449. ids = append(ids, id)
  13450. }
  13451. return ids
  13452. }
  13453. return nil
  13454. }
  13455. // RemovedEdges returns all edge names that were removed in this mutation.
  13456. func (m *SopStageMutation) RemovedEdges() []string {
  13457. edges := make([]string, 0, 3)
  13458. if m.removedstage_nodes != nil {
  13459. edges = append(edges, sopstage.EdgeStageNodes)
  13460. }
  13461. if m.removedstage_messages != nil {
  13462. edges = append(edges, sopstage.EdgeStageMessages)
  13463. }
  13464. return edges
  13465. }
  13466. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13467. // the given name in this mutation.
  13468. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  13469. switch name {
  13470. case sopstage.EdgeStageNodes:
  13471. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  13472. for id := range m.removedstage_nodes {
  13473. ids = append(ids, id)
  13474. }
  13475. return ids
  13476. case sopstage.EdgeStageMessages:
  13477. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  13478. for id := range m.removedstage_messages {
  13479. ids = append(ids, id)
  13480. }
  13481. return ids
  13482. }
  13483. return nil
  13484. }
  13485. // ClearedEdges returns all edge names that were cleared in this mutation.
  13486. func (m *SopStageMutation) ClearedEdges() []string {
  13487. edges := make([]string, 0, 3)
  13488. if m.clearedsop_task {
  13489. edges = append(edges, sopstage.EdgeSopTask)
  13490. }
  13491. if m.clearedstage_nodes {
  13492. edges = append(edges, sopstage.EdgeStageNodes)
  13493. }
  13494. if m.clearedstage_messages {
  13495. edges = append(edges, sopstage.EdgeStageMessages)
  13496. }
  13497. return edges
  13498. }
  13499. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13500. // was cleared in this mutation.
  13501. func (m *SopStageMutation) EdgeCleared(name string) bool {
  13502. switch name {
  13503. case sopstage.EdgeSopTask:
  13504. return m.clearedsop_task
  13505. case sopstage.EdgeStageNodes:
  13506. return m.clearedstage_nodes
  13507. case sopstage.EdgeStageMessages:
  13508. return m.clearedstage_messages
  13509. }
  13510. return false
  13511. }
  13512. // ClearEdge clears the value of the edge with the given name. It returns an error
  13513. // if that edge is not defined in the schema.
  13514. func (m *SopStageMutation) ClearEdge(name string) error {
  13515. switch name {
  13516. case sopstage.EdgeSopTask:
  13517. m.ClearSopTask()
  13518. return nil
  13519. }
  13520. return fmt.Errorf("unknown SopStage unique edge %s", name)
  13521. }
  13522. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13523. // It returns an error if the edge is not defined in the schema.
  13524. func (m *SopStageMutation) ResetEdge(name string) error {
  13525. switch name {
  13526. case sopstage.EdgeSopTask:
  13527. m.ResetSopTask()
  13528. return nil
  13529. case sopstage.EdgeStageNodes:
  13530. m.ResetStageNodes()
  13531. return nil
  13532. case sopstage.EdgeStageMessages:
  13533. m.ResetStageMessages()
  13534. return nil
  13535. }
  13536. return fmt.Errorf("unknown SopStage edge %s", name)
  13537. }
  13538. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  13539. type SopTaskMutation struct {
  13540. config
  13541. op Op
  13542. typ string
  13543. id *uint64
  13544. created_at *time.Time
  13545. updated_at *time.Time
  13546. status *uint8
  13547. addstatus *int8
  13548. deleted_at *time.Time
  13549. name *string
  13550. bot_wxid_list *[]string
  13551. appendbot_wxid_list []string
  13552. _type *int
  13553. add_type *int
  13554. plan_start_time *time.Time
  13555. plan_end_time *time.Time
  13556. creator_id *string
  13557. organization_id *uint64
  13558. addorganization_id *int64
  13559. clearedFields map[string]struct{}
  13560. task_stages map[uint64]struct{}
  13561. removedtask_stages map[uint64]struct{}
  13562. clearedtask_stages bool
  13563. done bool
  13564. oldValue func(context.Context) (*SopTask, error)
  13565. predicates []predicate.SopTask
  13566. }
  13567. var _ ent.Mutation = (*SopTaskMutation)(nil)
  13568. // soptaskOption allows management of the mutation configuration using functional options.
  13569. type soptaskOption func(*SopTaskMutation)
  13570. // newSopTaskMutation creates new mutation for the SopTask entity.
  13571. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  13572. m := &SopTaskMutation{
  13573. config: c,
  13574. op: op,
  13575. typ: TypeSopTask,
  13576. clearedFields: make(map[string]struct{}),
  13577. }
  13578. for _, opt := range opts {
  13579. opt(m)
  13580. }
  13581. return m
  13582. }
  13583. // withSopTaskID sets the ID field of the mutation.
  13584. func withSopTaskID(id uint64) soptaskOption {
  13585. return func(m *SopTaskMutation) {
  13586. var (
  13587. err error
  13588. once sync.Once
  13589. value *SopTask
  13590. )
  13591. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  13592. once.Do(func() {
  13593. if m.done {
  13594. err = errors.New("querying old values post mutation is not allowed")
  13595. } else {
  13596. value, err = m.Client().SopTask.Get(ctx, id)
  13597. }
  13598. })
  13599. return value, err
  13600. }
  13601. m.id = &id
  13602. }
  13603. }
  13604. // withSopTask sets the old SopTask of the mutation.
  13605. func withSopTask(node *SopTask) soptaskOption {
  13606. return func(m *SopTaskMutation) {
  13607. m.oldValue = func(context.Context) (*SopTask, error) {
  13608. return node, nil
  13609. }
  13610. m.id = &node.ID
  13611. }
  13612. }
  13613. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13614. // executed in a transaction (ent.Tx), a transactional client is returned.
  13615. func (m SopTaskMutation) Client() *Client {
  13616. client := &Client{config: m.config}
  13617. client.init()
  13618. return client
  13619. }
  13620. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13621. // it returns an error otherwise.
  13622. func (m SopTaskMutation) Tx() (*Tx, error) {
  13623. if _, ok := m.driver.(*txDriver); !ok {
  13624. return nil, errors.New("ent: mutation is not running in a transaction")
  13625. }
  13626. tx := &Tx{config: m.config}
  13627. tx.init()
  13628. return tx, nil
  13629. }
  13630. // SetID sets the value of the id field. Note that this
  13631. // operation is only accepted on creation of SopTask entities.
  13632. func (m *SopTaskMutation) SetID(id uint64) {
  13633. m.id = &id
  13634. }
  13635. // ID returns the ID value in the mutation. Note that the ID is only available
  13636. // if it was provided to the builder or after it was returned from the database.
  13637. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  13638. if m.id == nil {
  13639. return
  13640. }
  13641. return *m.id, true
  13642. }
  13643. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13644. // That means, if the mutation is applied within a transaction with an isolation level such
  13645. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13646. // or updated by the mutation.
  13647. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  13648. switch {
  13649. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13650. id, exists := m.ID()
  13651. if exists {
  13652. return []uint64{id}, nil
  13653. }
  13654. fallthrough
  13655. case m.op.Is(OpUpdate | OpDelete):
  13656. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  13657. default:
  13658. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13659. }
  13660. }
  13661. // SetCreatedAt sets the "created_at" field.
  13662. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  13663. m.created_at = &t
  13664. }
  13665. // CreatedAt returns the value of the "created_at" field in the mutation.
  13666. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  13667. v := m.created_at
  13668. if v == nil {
  13669. return
  13670. }
  13671. return *v, true
  13672. }
  13673. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  13674. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  13675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13676. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13677. if !m.op.Is(OpUpdateOne) {
  13678. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13679. }
  13680. if m.id == nil || m.oldValue == nil {
  13681. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13682. }
  13683. oldValue, err := m.oldValue(ctx)
  13684. if err != nil {
  13685. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13686. }
  13687. return oldValue.CreatedAt, nil
  13688. }
  13689. // ResetCreatedAt resets all changes to the "created_at" field.
  13690. func (m *SopTaskMutation) ResetCreatedAt() {
  13691. m.created_at = nil
  13692. }
  13693. // SetUpdatedAt sets the "updated_at" field.
  13694. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  13695. m.updated_at = &t
  13696. }
  13697. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13698. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  13699. v := m.updated_at
  13700. if v == nil {
  13701. return
  13702. }
  13703. return *v, true
  13704. }
  13705. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  13706. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  13707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13708. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13709. if !m.op.Is(OpUpdateOne) {
  13710. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13711. }
  13712. if m.id == nil || m.oldValue == nil {
  13713. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13714. }
  13715. oldValue, err := m.oldValue(ctx)
  13716. if err != nil {
  13717. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13718. }
  13719. return oldValue.UpdatedAt, nil
  13720. }
  13721. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13722. func (m *SopTaskMutation) ResetUpdatedAt() {
  13723. m.updated_at = nil
  13724. }
  13725. // SetStatus sets the "status" field.
  13726. func (m *SopTaskMutation) SetStatus(u uint8) {
  13727. m.status = &u
  13728. m.addstatus = nil
  13729. }
  13730. // Status returns the value of the "status" field in the mutation.
  13731. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  13732. v := m.status
  13733. if v == nil {
  13734. return
  13735. }
  13736. return *v, true
  13737. }
  13738. // OldStatus returns the old "status" field's value of the SopTask entity.
  13739. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  13740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13741. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13742. if !m.op.Is(OpUpdateOne) {
  13743. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13744. }
  13745. if m.id == nil || m.oldValue == nil {
  13746. return v, errors.New("OldStatus requires an ID field in the mutation")
  13747. }
  13748. oldValue, err := m.oldValue(ctx)
  13749. if err != nil {
  13750. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13751. }
  13752. return oldValue.Status, nil
  13753. }
  13754. // AddStatus adds u to the "status" field.
  13755. func (m *SopTaskMutation) AddStatus(u int8) {
  13756. if m.addstatus != nil {
  13757. *m.addstatus += u
  13758. } else {
  13759. m.addstatus = &u
  13760. }
  13761. }
  13762. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13763. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  13764. v := m.addstatus
  13765. if v == nil {
  13766. return
  13767. }
  13768. return *v, true
  13769. }
  13770. // ClearStatus clears the value of the "status" field.
  13771. func (m *SopTaskMutation) ClearStatus() {
  13772. m.status = nil
  13773. m.addstatus = nil
  13774. m.clearedFields[soptask.FieldStatus] = struct{}{}
  13775. }
  13776. // StatusCleared returns if the "status" field was cleared in this mutation.
  13777. func (m *SopTaskMutation) StatusCleared() bool {
  13778. _, ok := m.clearedFields[soptask.FieldStatus]
  13779. return ok
  13780. }
  13781. // ResetStatus resets all changes to the "status" field.
  13782. func (m *SopTaskMutation) ResetStatus() {
  13783. m.status = nil
  13784. m.addstatus = nil
  13785. delete(m.clearedFields, soptask.FieldStatus)
  13786. }
  13787. // SetDeletedAt sets the "deleted_at" field.
  13788. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  13789. m.deleted_at = &t
  13790. }
  13791. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13792. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  13793. v := m.deleted_at
  13794. if v == nil {
  13795. return
  13796. }
  13797. return *v, true
  13798. }
  13799. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  13800. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  13801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13802. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13803. if !m.op.Is(OpUpdateOne) {
  13804. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13805. }
  13806. if m.id == nil || m.oldValue == nil {
  13807. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13808. }
  13809. oldValue, err := m.oldValue(ctx)
  13810. if err != nil {
  13811. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13812. }
  13813. return oldValue.DeletedAt, nil
  13814. }
  13815. // ClearDeletedAt clears the value of the "deleted_at" field.
  13816. func (m *SopTaskMutation) ClearDeletedAt() {
  13817. m.deleted_at = nil
  13818. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  13819. }
  13820. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13821. func (m *SopTaskMutation) DeletedAtCleared() bool {
  13822. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  13823. return ok
  13824. }
  13825. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13826. func (m *SopTaskMutation) ResetDeletedAt() {
  13827. m.deleted_at = nil
  13828. delete(m.clearedFields, soptask.FieldDeletedAt)
  13829. }
  13830. // SetName sets the "name" field.
  13831. func (m *SopTaskMutation) SetName(s string) {
  13832. m.name = &s
  13833. }
  13834. // Name returns the value of the "name" field in the mutation.
  13835. func (m *SopTaskMutation) Name() (r string, exists bool) {
  13836. v := m.name
  13837. if v == nil {
  13838. return
  13839. }
  13840. return *v, true
  13841. }
  13842. // OldName returns the old "name" field's value of the SopTask entity.
  13843. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  13844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13845. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  13846. if !m.op.Is(OpUpdateOne) {
  13847. return v, errors.New("OldName is only allowed on UpdateOne operations")
  13848. }
  13849. if m.id == nil || m.oldValue == nil {
  13850. return v, errors.New("OldName requires an ID field in the mutation")
  13851. }
  13852. oldValue, err := m.oldValue(ctx)
  13853. if err != nil {
  13854. return v, fmt.Errorf("querying old value for OldName: %w", err)
  13855. }
  13856. return oldValue.Name, nil
  13857. }
  13858. // ResetName resets all changes to the "name" field.
  13859. func (m *SopTaskMutation) ResetName() {
  13860. m.name = nil
  13861. }
  13862. // SetBotWxidList sets the "bot_wxid_list" field.
  13863. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  13864. m.bot_wxid_list = &s
  13865. m.appendbot_wxid_list = nil
  13866. }
  13867. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  13868. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  13869. v := m.bot_wxid_list
  13870. if v == nil {
  13871. return
  13872. }
  13873. return *v, true
  13874. }
  13875. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  13876. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  13877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13878. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  13879. if !m.op.Is(OpUpdateOne) {
  13880. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  13881. }
  13882. if m.id == nil || m.oldValue == nil {
  13883. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  13884. }
  13885. oldValue, err := m.oldValue(ctx)
  13886. if err != nil {
  13887. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  13888. }
  13889. return oldValue.BotWxidList, nil
  13890. }
  13891. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  13892. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  13893. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  13894. }
  13895. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  13896. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  13897. if len(m.appendbot_wxid_list) == 0 {
  13898. return nil, false
  13899. }
  13900. return m.appendbot_wxid_list, true
  13901. }
  13902. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  13903. func (m *SopTaskMutation) ClearBotWxidList() {
  13904. m.bot_wxid_list = nil
  13905. m.appendbot_wxid_list = nil
  13906. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  13907. }
  13908. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  13909. func (m *SopTaskMutation) BotWxidListCleared() bool {
  13910. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  13911. return ok
  13912. }
  13913. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  13914. func (m *SopTaskMutation) ResetBotWxidList() {
  13915. m.bot_wxid_list = nil
  13916. m.appendbot_wxid_list = nil
  13917. delete(m.clearedFields, soptask.FieldBotWxidList)
  13918. }
  13919. // SetType sets the "type" field.
  13920. func (m *SopTaskMutation) SetType(i int) {
  13921. m._type = &i
  13922. m.add_type = nil
  13923. }
  13924. // GetType returns the value of the "type" field in the mutation.
  13925. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  13926. v := m._type
  13927. if v == nil {
  13928. return
  13929. }
  13930. return *v, true
  13931. }
  13932. // OldType returns the old "type" field's value of the SopTask entity.
  13933. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  13934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13935. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  13936. if !m.op.Is(OpUpdateOne) {
  13937. return v, errors.New("OldType is only allowed on UpdateOne operations")
  13938. }
  13939. if m.id == nil || m.oldValue == nil {
  13940. return v, errors.New("OldType requires an ID field in the mutation")
  13941. }
  13942. oldValue, err := m.oldValue(ctx)
  13943. if err != nil {
  13944. return v, fmt.Errorf("querying old value for OldType: %w", err)
  13945. }
  13946. return oldValue.Type, nil
  13947. }
  13948. // AddType adds i to the "type" field.
  13949. func (m *SopTaskMutation) AddType(i int) {
  13950. if m.add_type != nil {
  13951. *m.add_type += i
  13952. } else {
  13953. m.add_type = &i
  13954. }
  13955. }
  13956. // AddedType returns the value that was added to the "type" field in this mutation.
  13957. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  13958. v := m.add_type
  13959. if v == nil {
  13960. return
  13961. }
  13962. return *v, true
  13963. }
  13964. // ResetType resets all changes to the "type" field.
  13965. func (m *SopTaskMutation) ResetType() {
  13966. m._type = nil
  13967. m.add_type = nil
  13968. }
  13969. // SetPlanStartTime sets the "plan_start_time" field.
  13970. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  13971. m.plan_start_time = &t
  13972. }
  13973. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  13974. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  13975. v := m.plan_start_time
  13976. if v == nil {
  13977. return
  13978. }
  13979. return *v, true
  13980. }
  13981. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  13982. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  13983. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13984. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  13985. if !m.op.Is(OpUpdateOne) {
  13986. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  13987. }
  13988. if m.id == nil || m.oldValue == nil {
  13989. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  13990. }
  13991. oldValue, err := m.oldValue(ctx)
  13992. if err != nil {
  13993. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  13994. }
  13995. return oldValue.PlanStartTime, nil
  13996. }
  13997. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  13998. func (m *SopTaskMutation) ClearPlanStartTime() {
  13999. m.plan_start_time = nil
  14000. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  14001. }
  14002. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  14003. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  14004. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  14005. return ok
  14006. }
  14007. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  14008. func (m *SopTaskMutation) ResetPlanStartTime() {
  14009. m.plan_start_time = nil
  14010. delete(m.clearedFields, soptask.FieldPlanStartTime)
  14011. }
  14012. // SetPlanEndTime sets the "plan_end_time" field.
  14013. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  14014. m.plan_end_time = &t
  14015. }
  14016. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  14017. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  14018. v := m.plan_end_time
  14019. if v == nil {
  14020. return
  14021. }
  14022. return *v, true
  14023. }
  14024. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  14025. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14027. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  14028. if !m.op.Is(OpUpdateOne) {
  14029. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  14030. }
  14031. if m.id == nil || m.oldValue == nil {
  14032. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  14033. }
  14034. oldValue, err := m.oldValue(ctx)
  14035. if err != nil {
  14036. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  14037. }
  14038. return oldValue.PlanEndTime, nil
  14039. }
  14040. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  14041. func (m *SopTaskMutation) ClearPlanEndTime() {
  14042. m.plan_end_time = nil
  14043. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  14044. }
  14045. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  14046. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  14047. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  14048. return ok
  14049. }
  14050. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  14051. func (m *SopTaskMutation) ResetPlanEndTime() {
  14052. m.plan_end_time = nil
  14053. delete(m.clearedFields, soptask.FieldPlanEndTime)
  14054. }
  14055. // SetCreatorID sets the "creator_id" field.
  14056. func (m *SopTaskMutation) SetCreatorID(s string) {
  14057. m.creator_id = &s
  14058. }
  14059. // CreatorID returns the value of the "creator_id" field in the mutation.
  14060. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  14061. v := m.creator_id
  14062. if v == nil {
  14063. return
  14064. }
  14065. return *v, true
  14066. }
  14067. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  14068. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14069. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14070. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  14071. if !m.op.Is(OpUpdateOne) {
  14072. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  14073. }
  14074. if m.id == nil || m.oldValue == nil {
  14075. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  14076. }
  14077. oldValue, err := m.oldValue(ctx)
  14078. if err != nil {
  14079. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  14080. }
  14081. return oldValue.CreatorID, nil
  14082. }
  14083. // ClearCreatorID clears the value of the "creator_id" field.
  14084. func (m *SopTaskMutation) ClearCreatorID() {
  14085. m.creator_id = nil
  14086. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  14087. }
  14088. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  14089. func (m *SopTaskMutation) CreatorIDCleared() bool {
  14090. _, ok := m.clearedFields[soptask.FieldCreatorID]
  14091. return ok
  14092. }
  14093. // ResetCreatorID resets all changes to the "creator_id" field.
  14094. func (m *SopTaskMutation) ResetCreatorID() {
  14095. m.creator_id = nil
  14096. delete(m.clearedFields, soptask.FieldCreatorID)
  14097. }
  14098. // SetOrganizationID sets the "organization_id" field.
  14099. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  14100. m.organization_id = &u
  14101. m.addorganization_id = nil
  14102. }
  14103. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14104. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  14105. v := m.organization_id
  14106. if v == nil {
  14107. return
  14108. }
  14109. return *v, true
  14110. }
  14111. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  14112. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14114. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14115. if !m.op.Is(OpUpdateOne) {
  14116. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14117. }
  14118. if m.id == nil || m.oldValue == nil {
  14119. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14120. }
  14121. oldValue, err := m.oldValue(ctx)
  14122. if err != nil {
  14123. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14124. }
  14125. return oldValue.OrganizationID, nil
  14126. }
  14127. // AddOrganizationID adds u to the "organization_id" field.
  14128. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  14129. if m.addorganization_id != nil {
  14130. *m.addorganization_id += u
  14131. } else {
  14132. m.addorganization_id = &u
  14133. }
  14134. }
  14135. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14136. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  14137. v := m.addorganization_id
  14138. if v == nil {
  14139. return
  14140. }
  14141. return *v, true
  14142. }
  14143. // ClearOrganizationID clears the value of the "organization_id" field.
  14144. func (m *SopTaskMutation) ClearOrganizationID() {
  14145. m.organization_id = nil
  14146. m.addorganization_id = nil
  14147. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  14148. }
  14149. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14150. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  14151. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  14152. return ok
  14153. }
  14154. // ResetOrganizationID resets all changes to the "organization_id" field.
  14155. func (m *SopTaskMutation) ResetOrganizationID() {
  14156. m.organization_id = nil
  14157. m.addorganization_id = nil
  14158. delete(m.clearedFields, soptask.FieldOrganizationID)
  14159. }
  14160. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  14161. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  14162. if m.task_stages == nil {
  14163. m.task_stages = make(map[uint64]struct{})
  14164. }
  14165. for i := range ids {
  14166. m.task_stages[ids[i]] = struct{}{}
  14167. }
  14168. }
  14169. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  14170. func (m *SopTaskMutation) ClearTaskStages() {
  14171. m.clearedtask_stages = true
  14172. }
  14173. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  14174. func (m *SopTaskMutation) TaskStagesCleared() bool {
  14175. return m.clearedtask_stages
  14176. }
  14177. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  14178. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  14179. if m.removedtask_stages == nil {
  14180. m.removedtask_stages = make(map[uint64]struct{})
  14181. }
  14182. for i := range ids {
  14183. delete(m.task_stages, ids[i])
  14184. m.removedtask_stages[ids[i]] = struct{}{}
  14185. }
  14186. }
  14187. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  14188. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  14189. for id := range m.removedtask_stages {
  14190. ids = append(ids, id)
  14191. }
  14192. return
  14193. }
  14194. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  14195. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  14196. for id := range m.task_stages {
  14197. ids = append(ids, id)
  14198. }
  14199. return
  14200. }
  14201. // ResetTaskStages resets all changes to the "task_stages" edge.
  14202. func (m *SopTaskMutation) ResetTaskStages() {
  14203. m.task_stages = nil
  14204. m.clearedtask_stages = false
  14205. m.removedtask_stages = nil
  14206. }
  14207. // Where appends a list predicates to the SopTaskMutation builder.
  14208. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  14209. m.predicates = append(m.predicates, ps...)
  14210. }
  14211. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  14212. // users can use type-assertion to append predicates that do not depend on any generated package.
  14213. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  14214. p := make([]predicate.SopTask, len(ps))
  14215. for i := range ps {
  14216. p[i] = ps[i]
  14217. }
  14218. m.Where(p...)
  14219. }
  14220. // Op returns the operation name.
  14221. func (m *SopTaskMutation) Op() Op {
  14222. return m.op
  14223. }
  14224. // SetOp allows setting the mutation operation.
  14225. func (m *SopTaskMutation) SetOp(op Op) {
  14226. m.op = op
  14227. }
  14228. // Type returns the node type of this mutation (SopTask).
  14229. func (m *SopTaskMutation) Type() string {
  14230. return m.typ
  14231. }
  14232. // Fields returns all fields that were changed during this mutation. Note that in
  14233. // order to get all numeric fields that were incremented/decremented, call
  14234. // AddedFields().
  14235. func (m *SopTaskMutation) Fields() []string {
  14236. fields := make([]string, 0, 11)
  14237. if m.created_at != nil {
  14238. fields = append(fields, soptask.FieldCreatedAt)
  14239. }
  14240. if m.updated_at != nil {
  14241. fields = append(fields, soptask.FieldUpdatedAt)
  14242. }
  14243. if m.status != nil {
  14244. fields = append(fields, soptask.FieldStatus)
  14245. }
  14246. if m.deleted_at != nil {
  14247. fields = append(fields, soptask.FieldDeletedAt)
  14248. }
  14249. if m.name != nil {
  14250. fields = append(fields, soptask.FieldName)
  14251. }
  14252. if m.bot_wxid_list != nil {
  14253. fields = append(fields, soptask.FieldBotWxidList)
  14254. }
  14255. if m._type != nil {
  14256. fields = append(fields, soptask.FieldType)
  14257. }
  14258. if m.plan_start_time != nil {
  14259. fields = append(fields, soptask.FieldPlanStartTime)
  14260. }
  14261. if m.plan_end_time != nil {
  14262. fields = append(fields, soptask.FieldPlanEndTime)
  14263. }
  14264. if m.creator_id != nil {
  14265. fields = append(fields, soptask.FieldCreatorID)
  14266. }
  14267. if m.organization_id != nil {
  14268. fields = append(fields, soptask.FieldOrganizationID)
  14269. }
  14270. return fields
  14271. }
  14272. // Field returns the value of a field with the given name. The second boolean
  14273. // return value indicates that this field was not set, or was not defined in the
  14274. // schema.
  14275. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  14276. switch name {
  14277. case soptask.FieldCreatedAt:
  14278. return m.CreatedAt()
  14279. case soptask.FieldUpdatedAt:
  14280. return m.UpdatedAt()
  14281. case soptask.FieldStatus:
  14282. return m.Status()
  14283. case soptask.FieldDeletedAt:
  14284. return m.DeletedAt()
  14285. case soptask.FieldName:
  14286. return m.Name()
  14287. case soptask.FieldBotWxidList:
  14288. return m.BotWxidList()
  14289. case soptask.FieldType:
  14290. return m.GetType()
  14291. case soptask.FieldPlanStartTime:
  14292. return m.PlanStartTime()
  14293. case soptask.FieldPlanEndTime:
  14294. return m.PlanEndTime()
  14295. case soptask.FieldCreatorID:
  14296. return m.CreatorID()
  14297. case soptask.FieldOrganizationID:
  14298. return m.OrganizationID()
  14299. }
  14300. return nil, false
  14301. }
  14302. // OldField returns the old value of the field from the database. An error is
  14303. // returned if the mutation operation is not UpdateOne, or the query to the
  14304. // database failed.
  14305. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14306. switch name {
  14307. case soptask.FieldCreatedAt:
  14308. return m.OldCreatedAt(ctx)
  14309. case soptask.FieldUpdatedAt:
  14310. return m.OldUpdatedAt(ctx)
  14311. case soptask.FieldStatus:
  14312. return m.OldStatus(ctx)
  14313. case soptask.FieldDeletedAt:
  14314. return m.OldDeletedAt(ctx)
  14315. case soptask.FieldName:
  14316. return m.OldName(ctx)
  14317. case soptask.FieldBotWxidList:
  14318. return m.OldBotWxidList(ctx)
  14319. case soptask.FieldType:
  14320. return m.OldType(ctx)
  14321. case soptask.FieldPlanStartTime:
  14322. return m.OldPlanStartTime(ctx)
  14323. case soptask.FieldPlanEndTime:
  14324. return m.OldPlanEndTime(ctx)
  14325. case soptask.FieldCreatorID:
  14326. return m.OldCreatorID(ctx)
  14327. case soptask.FieldOrganizationID:
  14328. return m.OldOrganizationID(ctx)
  14329. }
  14330. return nil, fmt.Errorf("unknown SopTask field %s", name)
  14331. }
  14332. // SetField sets the value of a field with the given name. It returns an error if
  14333. // the field is not defined in the schema, or if the type mismatched the field
  14334. // type.
  14335. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  14336. switch name {
  14337. case soptask.FieldCreatedAt:
  14338. v, ok := value.(time.Time)
  14339. if !ok {
  14340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14341. }
  14342. m.SetCreatedAt(v)
  14343. return nil
  14344. case soptask.FieldUpdatedAt:
  14345. v, ok := value.(time.Time)
  14346. if !ok {
  14347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14348. }
  14349. m.SetUpdatedAt(v)
  14350. return nil
  14351. case soptask.FieldStatus:
  14352. v, ok := value.(uint8)
  14353. if !ok {
  14354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14355. }
  14356. m.SetStatus(v)
  14357. return nil
  14358. case soptask.FieldDeletedAt:
  14359. v, ok := value.(time.Time)
  14360. if !ok {
  14361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14362. }
  14363. m.SetDeletedAt(v)
  14364. return nil
  14365. case soptask.FieldName:
  14366. v, ok := value.(string)
  14367. if !ok {
  14368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14369. }
  14370. m.SetName(v)
  14371. return nil
  14372. case soptask.FieldBotWxidList:
  14373. v, ok := value.([]string)
  14374. if !ok {
  14375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14376. }
  14377. m.SetBotWxidList(v)
  14378. return nil
  14379. case soptask.FieldType:
  14380. v, ok := value.(int)
  14381. if !ok {
  14382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14383. }
  14384. m.SetType(v)
  14385. return nil
  14386. case soptask.FieldPlanStartTime:
  14387. v, ok := value.(time.Time)
  14388. if !ok {
  14389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14390. }
  14391. m.SetPlanStartTime(v)
  14392. return nil
  14393. case soptask.FieldPlanEndTime:
  14394. v, ok := value.(time.Time)
  14395. if !ok {
  14396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14397. }
  14398. m.SetPlanEndTime(v)
  14399. return nil
  14400. case soptask.FieldCreatorID:
  14401. v, ok := value.(string)
  14402. if !ok {
  14403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14404. }
  14405. m.SetCreatorID(v)
  14406. return nil
  14407. case soptask.FieldOrganizationID:
  14408. v, ok := value.(uint64)
  14409. if !ok {
  14410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14411. }
  14412. m.SetOrganizationID(v)
  14413. return nil
  14414. }
  14415. return fmt.Errorf("unknown SopTask field %s", name)
  14416. }
  14417. // AddedFields returns all numeric fields that were incremented/decremented during
  14418. // this mutation.
  14419. func (m *SopTaskMutation) AddedFields() []string {
  14420. var fields []string
  14421. if m.addstatus != nil {
  14422. fields = append(fields, soptask.FieldStatus)
  14423. }
  14424. if m.add_type != nil {
  14425. fields = append(fields, soptask.FieldType)
  14426. }
  14427. if m.addorganization_id != nil {
  14428. fields = append(fields, soptask.FieldOrganizationID)
  14429. }
  14430. return fields
  14431. }
  14432. // AddedField returns the numeric value that was incremented/decremented on a field
  14433. // with the given name. The second boolean return value indicates that this field
  14434. // was not set, or was not defined in the schema.
  14435. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  14436. switch name {
  14437. case soptask.FieldStatus:
  14438. return m.AddedStatus()
  14439. case soptask.FieldType:
  14440. return m.AddedType()
  14441. case soptask.FieldOrganizationID:
  14442. return m.AddedOrganizationID()
  14443. }
  14444. return nil, false
  14445. }
  14446. // AddField adds the value to the field with the given name. It returns an error if
  14447. // the field is not defined in the schema, or if the type mismatched the field
  14448. // type.
  14449. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  14450. switch name {
  14451. case soptask.FieldStatus:
  14452. v, ok := value.(int8)
  14453. if !ok {
  14454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14455. }
  14456. m.AddStatus(v)
  14457. return nil
  14458. case soptask.FieldType:
  14459. v, ok := value.(int)
  14460. if !ok {
  14461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14462. }
  14463. m.AddType(v)
  14464. return nil
  14465. case soptask.FieldOrganizationID:
  14466. v, ok := value.(int64)
  14467. if !ok {
  14468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14469. }
  14470. m.AddOrganizationID(v)
  14471. return nil
  14472. }
  14473. return fmt.Errorf("unknown SopTask numeric field %s", name)
  14474. }
  14475. // ClearedFields returns all nullable fields that were cleared during this
  14476. // mutation.
  14477. func (m *SopTaskMutation) ClearedFields() []string {
  14478. var fields []string
  14479. if m.FieldCleared(soptask.FieldStatus) {
  14480. fields = append(fields, soptask.FieldStatus)
  14481. }
  14482. if m.FieldCleared(soptask.FieldDeletedAt) {
  14483. fields = append(fields, soptask.FieldDeletedAt)
  14484. }
  14485. if m.FieldCleared(soptask.FieldBotWxidList) {
  14486. fields = append(fields, soptask.FieldBotWxidList)
  14487. }
  14488. if m.FieldCleared(soptask.FieldPlanStartTime) {
  14489. fields = append(fields, soptask.FieldPlanStartTime)
  14490. }
  14491. if m.FieldCleared(soptask.FieldPlanEndTime) {
  14492. fields = append(fields, soptask.FieldPlanEndTime)
  14493. }
  14494. if m.FieldCleared(soptask.FieldCreatorID) {
  14495. fields = append(fields, soptask.FieldCreatorID)
  14496. }
  14497. if m.FieldCleared(soptask.FieldOrganizationID) {
  14498. fields = append(fields, soptask.FieldOrganizationID)
  14499. }
  14500. return fields
  14501. }
  14502. // FieldCleared returns a boolean indicating if a field with the given name was
  14503. // cleared in this mutation.
  14504. func (m *SopTaskMutation) FieldCleared(name string) bool {
  14505. _, ok := m.clearedFields[name]
  14506. return ok
  14507. }
  14508. // ClearField clears the value of the field with the given name. It returns an
  14509. // error if the field is not defined in the schema.
  14510. func (m *SopTaskMutation) ClearField(name string) error {
  14511. switch name {
  14512. case soptask.FieldStatus:
  14513. m.ClearStatus()
  14514. return nil
  14515. case soptask.FieldDeletedAt:
  14516. m.ClearDeletedAt()
  14517. return nil
  14518. case soptask.FieldBotWxidList:
  14519. m.ClearBotWxidList()
  14520. return nil
  14521. case soptask.FieldPlanStartTime:
  14522. m.ClearPlanStartTime()
  14523. return nil
  14524. case soptask.FieldPlanEndTime:
  14525. m.ClearPlanEndTime()
  14526. return nil
  14527. case soptask.FieldCreatorID:
  14528. m.ClearCreatorID()
  14529. return nil
  14530. case soptask.FieldOrganizationID:
  14531. m.ClearOrganizationID()
  14532. return nil
  14533. }
  14534. return fmt.Errorf("unknown SopTask nullable field %s", name)
  14535. }
  14536. // ResetField resets all changes in the mutation for the field with the given name.
  14537. // It returns an error if the field is not defined in the schema.
  14538. func (m *SopTaskMutation) ResetField(name string) error {
  14539. switch name {
  14540. case soptask.FieldCreatedAt:
  14541. m.ResetCreatedAt()
  14542. return nil
  14543. case soptask.FieldUpdatedAt:
  14544. m.ResetUpdatedAt()
  14545. return nil
  14546. case soptask.FieldStatus:
  14547. m.ResetStatus()
  14548. return nil
  14549. case soptask.FieldDeletedAt:
  14550. m.ResetDeletedAt()
  14551. return nil
  14552. case soptask.FieldName:
  14553. m.ResetName()
  14554. return nil
  14555. case soptask.FieldBotWxidList:
  14556. m.ResetBotWxidList()
  14557. return nil
  14558. case soptask.FieldType:
  14559. m.ResetType()
  14560. return nil
  14561. case soptask.FieldPlanStartTime:
  14562. m.ResetPlanStartTime()
  14563. return nil
  14564. case soptask.FieldPlanEndTime:
  14565. m.ResetPlanEndTime()
  14566. return nil
  14567. case soptask.FieldCreatorID:
  14568. m.ResetCreatorID()
  14569. return nil
  14570. case soptask.FieldOrganizationID:
  14571. m.ResetOrganizationID()
  14572. return nil
  14573. }
  14574. return fmt.Errorf("unknown SopTask field %s", name)
  14575. }
  14576. // AddedEdges returns all edge names that were set/added in this mutation.
  14577. func (m *SopTaskMutation) AddedEdges() []string {
  14578. edges := make([]string, 0, 1)
  14579. if m.task_stages != nil {
  14580. edges = append(edges, soptask.EdgeTaskStages)
  14581. }
  14582. return edges
  14583. }
  14584. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14585. // name in this mutation.
  14586. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  14587. switch name {
  14588. case soptask.EdgeTaskStages:
  14589. ids := make([]ent.Value, 0, len(m.task_stages))
  14590. for id := range m.task_stages {
  14591. ids = append(ids, id)
  14592. }
  14593. return ids
  14594. }
  14595. return nil
  14596. }
  14597. // RemovedEdges returns all edge names that were removed in this mutation.
  14598. func (m *SopTaskMutation) RemovedEdges() []string {
  14599. edges := make([]string, 0, 1)
  14600. if m.removedtask_stages != nil {
  14601. edges = append(edges, soptask.EdgeTaskStages)
  14602. }
  14603. return edges
  14604. }
  14605. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14606. // the given name in this mutation.
  14607. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  14608. switch name {
  14609. case soptask.EdgeTaskStages:
  14610. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  14611. for id := range m.removedtask_stages {
  14612. ids = append(ids, id)
  14613. }
  14614. return ids
  14615. }
  14616. return nil
  14617. }
  14618. // ClearedEdges returns all edge names that were cleared in this mutation.
  14619. func (m *SopTaskMutation) ClearedEdges() []string {
  14620. edges := make([]string, 0, 1)
  14621. if m.clearedtask_stages {
  14622. edges = append(edges, soptask.EdgeTaskStages)
  14623. }
  14624. return edges
  14625. }
  14626. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14627. // was cleared in this mutation.
  14628. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  14629. switch name {
  14630. case soptask.EdgeTaskStages:
  14631. return m.clearedtask_stages
  14632. }
  14633. return false
  14634. }
  14635. // ClearEdge clears the value of the edge with the given name. It returns an error
  14636. // if that edge is not defined in the schema.
  14637. func (m *SopTaskMutation) ClearEdge(name string) error {
  14638. switch name {
  14639. }
  14640. return fmt.Errorf("unknown SopTask unique edge %s", name)
  14641. }
  14642. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14643. // It returns an error if the edge is not defined in the schema.
  14644. func (m *SopTaskMutation) ResetEdge(name string) error {
  14645. switch name {
  14646. case soptask.EdgeTaskStages:
  14647. m.ResetTaskStages()
  14648. return nil
  14649. }
  14650. return fmt.Errorf("unknown SopTask edge %s", name)
  14651. }
  14652. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  14653. type TutorialMutation struct {
  14654. config
  14655. op Op
  14656. typ string
  14657. id *uint64
  14658. created_at *time.Time
  14659. updated_at *time.Time
  14660. deleted_at *time.Time
  14661. index *int
  14662. addindex *int
  14663. title *string
  14664. content *string
  14665. organization_id *uint64
  14666. addorganization_id *int64
  14667. clearedFields map[string]struct{}
  14668. employee *uint64
  14669. clearedemployee bool
  14670. done bool
  14671. oldValue func(context.Context) (*Tutorial, error)
  14672. predicates []predicate.Tutorial
  14673. }
  14674. var _ ent.Mutation = (*TutorialMutation)(nil)
  14675. // tutorialOption allows management of the mutation configuration using functional options.
  14676. type tutorialOption func(*TutorialMutation)
  14677. // newTutorialMutation creates new mutation for the Tutorial entity.
  14678. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  14679. m := &TutorialMutation{
  14680. config: c,
  14681. op: op,
  14682. typ: TypeTutorial,
  14683. clearedFields: make(map[string]struct{}),
  14684. }
  14685. for _, opt := range opts {
  14686. opt(m)
  14687. }
  14688. return m
  14689. }
  14690. // withTutorialID sets the ID field of the mutation.
  14691. func withTutorialID(id uint64) tutorialOption {
  14692. return func(m *TutorialMutation) {
  14693. var (
  14694. err error
  14695. once sync.Once
  14696. value *Tutorial
  14697. )
  14698. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  14699. once.Do(func() {
  14700. if m.done {
  14701. err = errors.New("querying old values post mutation is not allowed")
  14702. } else {
  14703. value, err = m.Client().Tutorial.Get(ctx, id)
  14704. }
  14705. })
  14706. return value, err
  14707. }
  14708. m.id = &id
  14709. }
  14710. }
  14711. // withTutorial sets the old Tutorial of the mutation.
  14712. func withTutorial(node *Tutorial) tutorialOption {
  14713. return func(m *TutorialMutation) {
  14714. m.oldValue = func(context.Context) (*Tutorial, error) {
  14715. return node, nil
  14716. }
  14717. m.id = &node.ID
  14718. }
  14719. }
  14720. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14721. // executed in a transaction (ent.Tx), a transactional client is returned.
  14722. func (m TutorialMutation) Client() *Client {
  14723. client := &Client{config: m.config}
  14724. client.init()
  14725. return client
  14726. }
  14727. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14728. // it returns an error otherwise.
  14729. func (m TutorialMutation) Tx() (*Tx, error) {
  14730. if _, ok := m.driver.(*txDriver); !ok {
  14731. return nil, errors.New("ent: mutation is not running in a transaction")
  14732. }
  14733. tx := &Tx{config: m.config}
  14734. tx.init()
  14735. return tx, nil
  14736. }
  14737. // SetID sets the value of the id field. Note that this
  14738. // operation is only accepted on creation of Tutorial entities.
  14739. func (m *TutorialMutation) SetID(id uint64) {
  14740. m.id = &id
  14741. }
  14742. // ID returns the ID value in the mutation. Note that the ID is only available
  14743. // if it was provided to the builder or after it was returned from the database.
  14744. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  14745. if m.id == nil {
  14746. return
  14747. }
  14748. return *m.id, true
  14749. }
  14750. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14751. // That means, if the mutation is applied within a transaction with an isolation level such
  14752. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14753. // or updated by the mutation.
  14754. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  14755. switch {
  14756. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14757. id, exists := m.ID()
  14758. if exists {
  14759. return []uint64{id}, nil
  14760. }
  14761. fallthrough
  14762. case m.op.Is(OpUpdate | OpDelete):
  14763. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  14764. default:
  14765. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14766. }
  14767. }
  14768. // SetCreatedAt sets the "created_at" field.
  14769. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  14770. m.created_at = &t
  14771. }
  14772. // CreatedAt returns the value of the "created_at" field in the mutation.
  14773. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  14774. v := m.created_at
  14775. if v == nil {
  14776. return
  14777. }
  14778. return *v, true
  14779. }
  14780. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  14781. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  14782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14783. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14784. if !m.op.Is(OpUpdateOne) {
  14785. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14786. }
  14787. if m.id == nil || m.oldValue == nil {
  14788. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14789. }
  14790. oldValue, err := m.oldValue(ctx)
  14791. if err != nil {
  14792. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14793. }
  14794. return oldValue.CreatedAt, nil
  14795. }
  14796. // ResetCreatedAt resets all changes to the "created_at" field.
  14797. func (m *TutorialMutation) ResetCreatedAt() {
  14798. m.created_at = nil
  14799. }
  14800. // SetUpdatedAt sets the "updated_at" field.
  14801. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  14802. m.updated_at = &t
  14803. }
  14804. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14805. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  14806. v := m.updated_at
  14807. if v == nil {
  14808. return
  14809. }
  14810. return *v, true
  14811. }
  14812. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  14813. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  14814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14815. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14816. if !m.op.Is(OpUpdateOne) {
  14817. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14818. }
  14819. if m.id == nil || m.oldValue == nil {
  14820. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14821. }
  14822. oldValue, err := m.oldValue(ctx)
  14823. if err != nil {
  14824. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14825. }
  14826. return oldValue.UpdatedAt, nil
  14827. }
  14828. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14829. func (m *TutorialMutation) ResetUpdatedAt() {
  14830. m.updated_at = nil
  14831. }
  14832. // SetDeletedAt sets the "deleted_at" field.
  14833. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  14834. m.deleted_at = &t
  14835. }
  14836. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14837. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  14838. v := m.deleted_at
  14839. if v == nil {
  14840. return
  14841. }
  14842. return *v, true
  14843. }
  14844. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  14845. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  14846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14847. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14848. if !m.op.Is(OpUpdateOne) {
  14849. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14850. }
  14851. if m.id == nil || m.oldValue == nil {
  14852. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14853. }
  14854. oldValue, err := m.oldValue(ctx)
  14855. if err != nil {
  14856. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14857. }
  14858. return oldValue.DeletedAt, nil
  14859. }
  14860. // ClearDeletedAt clears the value of the "deleted_at" field.
  14861. func (m *TutorialMutation) ClearDeletedAt() {
  14862. m.deleted_at = nil
  14863. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  14864. }
  14865. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14866. func (m *TutorialMutation) DeletedAtCleared() bool {
  14867. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  14868. return ok
  14869. }
  14870. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14871. func (m *TutorialMutation) ResetDeletedAt() {
  14872. m.deleted_at = nil
  14873. delete(m.clearedFields, tutorial.FieldDeletedAt)
  14874. }
  14875. // SetEmployeeID sets the "employee_id" field.
  14876. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  14877. m.employee = &u
  14878. }
  14879. // EmployeeID returns the value of the "employee_id" field in the mutation.
  14880. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  14881. v := m.employee
  14882. if v == nil {
  14883. return
  14884. }
  14885. return *v, true
  14886. }
  14887. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  14888. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  14889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14890. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  14891. if !m.op.Is(OpUpdateOne) {
  14892. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  14893. }
  14894. if m.id == nil || m.oldValue == nil {
  14895. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  14896. }
  14897. oldValue, err := m.oldValue(ctx)
  14898. if err != nil {
  14899. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  14900. }
  14901. return oldValue.EmployeeID, nil
  14902. }
  14903. // ResetEmployeeID resets all changes to the "employee_id" field.
  14904. func (m *TutorialMutation) ResetEmployeeID() {
  14905. m.employee = nil
  14906. }
  14907. // SetIndex sets the "index" field.
  14908. func (m *TutorialMutation) SetIndex(i int) {
  14909. m.index = &i
  14910. m.addindex = nil
  14911. }
  14912. // Index returns the value of the "index" field in the mutation.
  14913. func (m *TutorialMutation) Index() (r int, exists bool) {
  14914. v := m.index
  14915. if v == nil {
  14916. return
  14917. }
  14918. return *v, true
  14919. }
  14920. // OldIndex returns the old "index" field's value of the Tutorial entity.
  14921. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  14922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14923. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  14924. if !m.op.Is(OpUpdateOne) {
  14925. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  14926. }
  14927. if m.id == nil || m.oldValue == nil {
  14928. return v, errors.New("OldIndex requires an ID field in the mutation")
  14929. }
  14930. oldValue, err := m.oldValue(ctx)
  14931. if err != nil {
  14932. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  14933. }
  14934. return oldValue.Index, nil
  14935. }
  14936. // AddIndex adds i to the "index" field.
  14937. func (m *TutorialMutation) AddIndex(i int) {
  14938. if m.addindex != nil {
  14939. *m.addindex += i
  14940. } else {
  14941. m.addindex = &i
  14942. }
  14943. }
  14944. // AddedIndex returns the value that was added to the "index" field in this mutation.
  14945. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  14946. v := m.addindex
  14947. if v == nil {
  14948. return
  14949. }
  14950. return *v, true
  14951. }
  14952. // ResetIndex resets all changes to the "index" field.
  14953. func (m *TutorialMutation) ResetIndex() {
  14954. m.index = nil
  14955. m.addindex = nil
  14956. }
  14957. // SetTitle sets the "title" field.
  14958. func (m *TutorialMutation) SetTitle(s string) {
  14959. m.title = &s
  14960. }
  14961. // Title returns the value of the "title" field in the mutation.
  14962. func (m *TutorialMutation) Title() (r string, exists bool) {
  14963. v := m.title
  14964. if v == nil {
  14965. return
  14966. }
  14967. return *v, true
  14968. }
  14969. // OldTitle returns the old "title" field's value of the Tutorial entity.
  14970. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  14971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14972. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  14973. if !m.op.Is(OpUpdateOne) {
  14974. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  14975. }
  14976. if m.id == nil || m.oldValue == nil {
  14977. return v, errors.New("OldTitle requires an ID field in the mutation")
  14978. }
  14979. oldValue, err := m.oldValue(ctx)
  14980. if err != nil {
  14981. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  14982. }
  14983. return oldValue.Title, nil
  14984. }
  14985. // ResetTitle resets all changes to the "title" field.
  14986. func (m *TutorialMutation) ResetTitle() {
  14987. m.title = nil
  14988. }
  14989. // SetContent sets the "content" field.
  14990. func (m *TutorialMutation) SetContent(s string) {
  14991. m.content = &s
  14992. }
  14993. // Content returns the value of the "content" field in the mutation.
  14994. func (m *TutorialMutation) Content() (r string, exists bool) {
  14995. v := m.content
  14996. if v == nil {
  14997. return
  14998. }
  14999. return *v, true
  15000. }
  15001. // OldContent returns the old "content" field's value of the Tutorial entity.
  15002. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  15003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15004. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  15005. if !m.op.Is(OpUpdateOne) {
  15006. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  15007. }
  15008. if m.id == nil || m.oldValue == nil {
  15009. return v, errors.New("OldContent requires an ID field in the mutation")
  15010. }
  15011. oldValue, err := m.oldValue(ctx)
  15012. if err != nil {
  15013. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  15014. }
  15015. return oldValue.Content, nil
  15016. }
  15017. // ResetContent resets all changes to the "content" field.
  15018. func (m *TutorialMutation) ResetContent() {
  15019. m.content = nil
  15020. }
  15021. // SetOrganizationID sets the "organization_id" field.
  15022. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  15023. m.organization_id = &u
  15024. m.addorganization_id = nil
  15025. }
  15026. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15027. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  15028. v := m.organization_id
  15029. if v == nil {
  15030. return
  15031. }
  15032. return *v, true
  15033. }
  15034. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  15035. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  15036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15037. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15038. if !m.op.Is(OpUpdateOne) {
  15039. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15040. }
  15041. if m.id == nil || m.oldValue == nil {
  15042. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15043. }
  15044. oldValue, err := m.oldValue(ctx)
  15045. if err != nil {
  15046. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15047. }
  15048. return oldValue.OrganizationID, nil
  15049. }
  15050. // AddOrganizationID adds u to the "organization_id" field.
  15051. func (m *TutorialMutation) AddOrganizationID(u int64) {
  15052. if m.addorganization_id != nil {
  15053. *m.addorganization_id += u
  15054. } else {
  15055. m.addorganization_id = &u
  15056. }
  15057. }
  15058. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15059. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  15060. v := m.addorganization_id
  15061. if v == nil {
  15062. return
  15063. }
  15064. return *v, true
  15065. }
  15066. // ResetOrganizationID resets all changes to the "organization_id" field.
  15067. func (m *TutorialMutation) ResetOrganizationID() {
  15068. m.organization_id = nil
  15069. m.addorganization_id = nil
  15070. }
  15071. // ClearEmployee clears the "employee" edge to the Employee entity.
  15072. func (m *TutorialMutation) ClearEmployee() {
  15073. m.clearedemployee = true
  15074. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  15075. }
  15076. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  15077. func (m *TutorialMutation) EmployeeCleared() bool {
  15078. return m.clearedemployee
  15079. }
  15080. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  15081. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15082. // EmployeeID instead. It exists only for internal usage by the builders.
  15083. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  15084. if id := m.employee; id != nil {
  15085. ids = append(ids, *id)
  15086. }
  15087. return
  15088. }
  15089. // ResetEmployee resets all changes to the "employee" edge.
  15090. func (m *TutorialMutation) ResetEmployee() {
  15091. m.employee = nil
  15092. m.clearedemployee = false
  15093. }
  15094. // Where appends a list predicates to the TutorialMutation builder.
  15095. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  15096. m.predicates = append(m.predicates, ps...)
  15097. }
  15098. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  15099. // users can use type-assertion to append predicates that do not depend on any generated package.
  15100. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  15101. p := make([]predicate.Tutorial, len(ps))
  15102. for i := range ps {
  15103. p[i] = ps[i]
  15104. }
  15105. m.Where(p...)
  15106. }
  15107. // Op returns the operation name.
  15108. func (m *TutorialMutation) Op() Op {
  15109. return m.op
  15110. }
  15111. // SetOp allows setting the mutation operation.
  15112. func (m *TutorialMutation) SetOp(op Op) {
  15113. m.op = op
  15114. }
  15115. // Type returns the node type of this mutation (Tutorial).
  15116. func (m *TutorialMutation) Type() string {
  15117. return m.typ
  15118. }
  15119. // Fields returns all fields that were changed during this mutation. Note that in
  15120. // order to get all numeric fields that were incremented/decremented, call
  15121. // AddedFields().
  15122. func (m *TutorialMutation) Fields() []string {
  15123. fields := make([]string, 0, 8)
  15124. if m.created_at != nil {
  15125. fields = append(fields, tutorial.FieldCreatedAt)
  15126. }
  15127. if m.updated_at != nil {
  15128. fields = append(fields, tutorial.FieldUpdatedAt)
  15129. }
  15130. if m.deleted_at != nil {
  15131. fields = append(fields, tutorial.FieldDeletedAt)
  15132. }
  15133. if m.employee != nil {
  15134. fields = append(fields, tutorial.FieldEmployeeID)
  15135. }
  15136. if m.index != nil {
  15137. fields = append(fields, tutorial.FieldIndex)
  15138. }
  15139. if m.title != nil {
  15140. fields = append(fields, tutorial.FieldTitle)
  15141. }
  15142. if m.content != nil {
  15143. fields = append(fields, tutorial.FieldContent)
  15144. }
  15145. if m.organization_id != nil {
  15146. fields = append(fields, tutorial.FieldOrganizationID)
  15147. }
  15148. return fields
  15149. }
  15150. // Field returns the value of a field with the given name. The second boolean
  15151. // return value indicates that this field was not set, or was not defined in the
  15152. // schema.
  15153. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  15154. switch name {
  15155. case tutorial.FieldCreatedAt:
  15156. return m.CreatedAt()
  15157. case tutorial.FieldUpdatedAt:
  15158. return m.UpdatedAt()
  15159. case tutorial.FieldDeletedAt:
  15160. return m.DeletedAt()
  15161. case tutorial.FieldEmployeeID:
  15162. return m.EmployeeID()
  15163. case tutorial.FieldIndex:
  15164. return m.Index()
  15165. case tutorial.FieldTitle:
  15166. return m.Title()
  15167. case tutorial.FieldContent:
  15168. return m.Content()
  15169. case tutorial.FieldOrganizationID:
  15170. return m.OrganizationID()
  15171. }
  15172. return nil, false
  15173. }
  15174. // OldField returns the old value of the field from the database. An error is
  15175. // returned if the mutation operation is not UpdateOne, or the query to the
  15176. // database failed.
  15177. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15178. switch name {
  15179. case tutorial.FieldCreatedAt:
  15180. return m.OldCreatedAt(ctx)
  15181. case tutorial.FieldUpdatedAt:
  15182. return m.OldUpdatedAt(ctx)
  15183. case tutorial.FieldDeletedAt:
  15184. return m.OldDeletedAt(ctx)
  15185. case tutorial.FieldEmployeeID:
  15186. return m.OldEmployeeID(ctx)
  15187. case tutorial.FieldIndex:
  15188. return m.OldIndex(ctx)
  15189. case tutorial.FieldTitle:
  15190. return m.OldTitle(ctx)
  15191. case tutorial.FieldContent:
  15192. return m.OldContent(ctx)
  15193. case tutorial.FieldOrganizationID:
  15194. return m.OldOrganizationID(ctx)
  15195. }
  15196. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  15197. }
  15198. // SetField sets the value of a field with the given name. It returns an error if
  15199. // the field is not defined in the schema, or if the type mismatched the field
  15200. // type.
  15201. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  15202. switch name {
  15203. case tutorial.FieldCreatedAt:
  15204. v, ok := value.(time.Time)
  15205. if !ok {
  15206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15207. }
  15208. m.SetCreatedAt(v)
  15209. return nil
  15210. case tutorial.FieldUpdatedAt:
  15211. v, ok := value.(time.Time)
  15212. if !ok {
  15213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15214. }
  15215. m.SetUpdatedAt(v)
  15216. return nil
  15217. case tutorial.FieldDeletedAt:
  15218. v, ok := value.(time.Time)
  15219. if !ok {
  15220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15221. }
  15222. m.SetDeletedAt(v)
  15223. return nil
  15224. case tutorial.FieldEmployeeID:
  15225. v, ok := value.(uint64)
  15226. if !ok {
  15227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15228. }
  15229. m.SetEmployeeID(v)
  15230. return nil
  15231. case tutorial.FieldIndex:
  15232. v, ok := value.(int)
  15233. if !ok {
  15234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15235. }
  15236. m.SetIndex(v)
  15237. return nil
  15238. case tutorial.FieldTitle:
  15239. v, ok := value.(string)
  15240. if !ok {
  15241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15242. }
  15243. m.SetTitle(v)
  15244. return nil
  15245. case tutorial.FieldContent:
  15246. v, ok := value.(string)
  15247. if !ok {
  15248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15249. }
  15250. m.SetContent(v)
  15251. return nil
  15252. case tutorial.FieldOrganizationID:
  15253. v, ok := value.(uint64)
  15254. if !ok {
  15255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15256. }
  15257. m.SetOrganizationID(v)
  15258. return nil
  15259. }
  15260. return fmt.Errorf("unknown Tutorial field %s", name)
  15261. }
  15262. // AddedFields returns all numeric fields that were incremented/decremented during
  15263. // this mutation.
  15264. func (m *TutorialMutation) AddedFields() []string {
  15265. var fields []string
  15266. if m.addindex != nil {
  15267. fields = append(fields, tutorial.FieldIndex)
  15268. }
  15269. if m.addorganization_id != nil {
  15270. fields = append(fields, tutorial.FieldOrganizationID)
  15271. }
  15272. return fields
  15273. }
  15274. // AddedField returns the numeric value that was incremented/decremented on a field
  15275. // with the given name. The second boolean return value indicates that this field
  15276. // was not set, or was not defined in the schema.
  15277. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  15278. switch name {
  15279. case tutorial.FieldIndex:
  15280. return m.AddedIndex()
  15281. case tutorial.FieldOrganizationID:
  15282. return m.AddedOrganizationID()
  15283. }
  15284. return nil, false
  15285. }
  15286. // AddField adds the value to the field with the given name. It returns an error if
  15287. // the field is not defined in the schema, or if the type mismatched the field
  15288. // type.
  15289. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  15290. switch name {
  15291. case tutorial.FieldIndex:
  15292. v, ok := value.(int)
  15293. if !ok {
  15294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15295. }
  15296. m.AddIndex(v)
  15297. return nil
  15298. case tutorial.FieldOrganizationID:
  15299. v, ok := value.(int64)
  15300. if !ok {
  15301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15302. }
  15303. m.AddOrganizationID(v)
  15304. return nil
  15305. }
  15306. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  15307. }
  15308. // ClearedFields returns all nullable fields that were cleared during this
  15309. // mutation.
  15310. func (m *TutorialMutation) ClearedFields() []string {
  15311. var fields []string
  15312. if m.FieldCleared(tutorial.FieldDeletedAt) {
  15313. fields = append(fields, tutorial.FieldDeletedAt)
  15314. }
  15315. return fields
  15316. }
  15317. // FieldCleared returns a boolean indicating if a field with the given name was
  15318. // cleared in this mutation.
  15319. func (m *TutorialMutation) FieldCleared(name string) bool {
  15320. _, ok := m.clearedFields[name]
  15321. return ok
  15322. }
  15323. // ClearField clears the value of the field with the given name. It returns an
  15324. // error if the field is not defined in the schema.
  15325. func (m *TutorialMutation) ClearField(name string) error {
  15326. switch name {
  15327. case tutorial.FieldDeletedAt:
  15328. m.ClearDeletedAt()
  15329. return nil
  15330. }
  15331. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  15332. }
  15333. // ResetField resets all changes in the mutation for the field with the given name.
  15334. // It returns an error if the field is not defined in the schema.
  15335. func (m *TutorialMutation) ResetField(name string) error {
  15336. switch name {
  15337. case tutorial.FieldCreatedAt:
  15338. m.ResetCreatedAt()
  15339. return nil
  15340. case tutorial.FieldUpdatedAt:
  15341. m.ResetUpdatedAt()
  15342. return nil
  15343. case tutorial.FieldDeletedAt:
  15344. m.ResetDeletedAt()
  15345. return nil
  15346. case tutorial.FieldEmployeeID:
  15347. m.ResetEmployeeID()
  15348. return nil
  15349. case tutorial.FieldIndex:
  15350. m.ResetIndex()
  15351. return nil
  15352. case tutorial.FieldTitle:
  15353. m.ResetTitle()
  15354. return nil
  15355. case tutorial.FieldContent:
  15356. m.ResetContent()
  15357. return nil
  15358. case tutorial.FieldOrganizationID:
  15359. m.ResetOrganizationID()
  15360. return nil
  15361. }
  15362. return fmt.Errorf("unknown Tutorial field %s", name)
  15363. }
  15364. // AddedEdges returns all edge names that were set/added in this mutation.
  15365. func (m *TutorialMutation) AddedEdges() []string {
  15366. edges := make([]string, 0, 1)
  15367. if m.employee != nil {
  15368. edges = append(edges, tutorial.EdgeEmployee)
  15369. }
  15370. return edges
  15371. }
  15372. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15373. // name in this mutation.
  15374. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  15375. switch name {
  15376. case tutorial.EdgeEmployee:
  15377. if id := m.employee; id != nil {
  15378. return []ent.Value{*id}
  15379. }
  15380. }
  15381. return nil
  15382. }
  15383. // RemovedEdges returns all edge names that were removed in this mutation.
  15384. func (m *TutorialMutation) RemovedEdges() []string {
  15385. edges := make([]string, 0, 1)
  15386. return edges
  15387. }
  15388. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15389. // the given name in this mutation.
  15390. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  15391. return nil
  15392. }
  15393. // ClearedEdges returns all edge names that were cleared in this mutation.
  15394. func (m *TutorialMutation) ClearedEdges() []string {
  15395. edges := make([]string, 0, 1)
  15396. if m.clearedemployee {
  15397. edges = append(edges, tutorial.EdgeEmployee)
  15398. }
  15399. return edges
  15400. }
  15401. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15402. // was cleared in this mutation.
  15403. func (m *TutorialMutation) EdgeCleared(name string) bool {
  15404. switch name {
  15405. case tutorial.EdgeEmployee:
  15406. return m.clearedemployee
  15407. }
  15408. return false
  15409. }
  15410. // ClearEdge clears the value of the edge with the given name. It returns an error
  15411. // if that edge is not defined in the schema.
  15412. func (m *TutorialMutation) ClearEdge(name string) error {
  15413. switch name {
  15414. case tutorial.EdgeEmployee:
  15415. m.ClearEmployee()
  15416. return nil
  15417. }
  15418. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  15419. }
  15420. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15421. // It returns an error if the edge is not defined in the schema.
  15422. func (m *TutorialMutation) ResetEdge(name string) error {
  15423. switch name {
  15424. case tutorial.EdgeEmployee:
  15425. m.ResetEmployee()
  15426. return nil
  15427. }
  15428. return fmt.Errorf("unknown Tutorial edge %s", name)
  15429. }
  15430. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  15431. type WorkExperienceMutation struct {
  15432. config
  15433. op Op
  15434. typ string
  15435. id *uint64
  15436. created_at *time.Time
  15437. updated_at *time.Time
  15438. deleted_at *time.Time
  15439. start_date *time.Time
  15440. end_date *time.Time
  15441. company *string
  15442. experience *string
  15443. organization_id *uint64
  15444. addorganization_id *int64
  15445. clearedFields map[string]struct{}
  15446. employee *uint64
  15447. clearedemployee bool
  15448. done bool
  15449. oldValue func(context.Context) (*WorkExperience, error)
  15450. predicates []predicate.WorkExperience
  15451. }
  15452. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  15453. // workexperienceOption allows management of the mutation configuration using functional options.
  15454. type workexperienceOption func(*WorkExperienceMutation)
  15455. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  15456. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  15457. m := &WorkExperienceMutation{
  15458. config: c,
  15459. op: op,
  15460. typ: TypeWorkExperience,
  15461. clearedFields: make(map[string]struct{}),
  15462. }
  15463. for _, opt := range opts {
  15464. opt(m)
  15465. }
  15466. return m
  15467. }
  15468. // withWorkExperienceID sets the ID field of the mutation.
  15469. func withWorkExperienceID(id uint64) workexperienceOption {
  15470. return func(m *WorkExperienceMutation) {
  15471. var (
  15472. err error
  15473. once sync.Once
  15474. value *WorkExperience
  15475. )
  15476. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  15477. once.Do(func() {
  15478. if m.done {
  15479. err = errors.New("querying old values post mutation is not allowed")
  15480. } else {
  15481. value, err = m.Client().WorkExperience.Get(ctx, id)
  15482. }
  15483. })
  15484. return value, err
  15485. }
  15486. m.id = &id
  15487. }
  15488. }
  15489. // withWorkExperience sets the old WorkExperience of the mutation.
  15490. func withWorkExperience(node *WorkExperience) workexperienceOption {
  15491. return func(m *WorkExperienceMutation) {
  15492. m.oldValue = func(context.Context) (*WorkExperience, error) {
  15493. return node, nil
  15494. }
  15495. m.id = &node.ID
  15496. }
  15497. }
  15498. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15499. // executed in a transaction (ent.Tx), a transactional client is returned.
  15500. func (m WorkExperienceMutation) Client() *Client {
  15501. client := &Client{config: m.config}
  15502. client.init()
  15503. return client
  15504. }
  15505. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15506. // it returns an error otherwise.
  15507. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  15508. if _, ok := m.driver.(*txDriver); !ok {
  15509. return nil, errors.New("ent: mutation is not running in a transaction")
  15510. }
  15511. tx := &Tx{config: m.config}
  15512. tx.init()
  15513. return tx, nil
  15514. }
  15515. // SetID sets the value of the id field. Note that this
  15516. // operation is only accepted on creation of WorkExperience entities.
  15517. func (m *WorkExperienceMutation) SetID(id uint64) {
  15518. m.id = &id
  15519. }
  15520. // ID returns the ID value in the mutation. Note that the ID is only available
  15521. // if it was provided to the builder or after it was returned from the database.
  15522. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  15523. if m.id == nil {
  15524. return
  15525. }
  15526. return *m.id, true
  15527. }
  15528. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15529. // That means, if the mutation is applied within a transaction with an isolation level such
  15530. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15531. // or updated by the mutation.
  15532. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  15533. switch {
  15534. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15535. id, exists := m.ID()
  15536. if exists {
  15537. return []uint64{id}, nil
  15538. }
  15539. fallthrough
  15540. case m.op.Is(OpUpdate | OpDelete):
  15541. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  15542. default:
  15543. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15544. }
  15545. }
  15546. // SetCreatedAt sets the "created_at" field.
  15547. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  15548. m.created_at = &t
  15549. }
  15550. // CreatedAt returns the value of the "created_at" field in the mutation.
  15551. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  15552. v := m.created_at
  15553. if v == nil {
  15554. return
  15555. }
  15556. return *v, true
  15557. }
  15558. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  15559. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  15560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15561. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15562. if !m.op.Is(OpUpdateOne) {
  15563. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15564. }
  15565. if m.id == nil || m.oldValue == nil {
  15566. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15567. }
  15568. oldValue, err := m.oldValue(ctx)
  15569. if err != nil {
  15570. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15571. }
  15572. return oldValue.CreatedAt, nil
  15573. }
  15574. // ResetCreatedAt resets all changes to the "created_at" field.
  15575. func (m *WorkExperienceMutation) ResetCreatedAt() {
  15576. m.created_at = nil
  15577. }
  15578. // SetUpdatedAt sets the "updated_at" field.
  15579. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  15580. m.updated_at = &t
  15581. }
  15582. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15583. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  15584. v := m.updated_at
  15585. if v == nil {
  15586. return
  15587. }
  15588. return *v, true
  15589. }
  15590. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  15591. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  15592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15593. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15594. if !m.op.Is(OpUpdateOne) {
  15595. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15596. }
  15597. if m.id == nil || m.oldValue == nil {
  15598. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15599. }
  15600. oldValue, err := m.oldValue(ctx)
  15601. if err != nil {
  15602. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15603. }
  15604. return oldValue.UpdatedAt, nil
  15605. }
  15606. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15607. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  15608. m.updated_at = nil
  15609. }
  15610. // SetDeletedAt sets the "deleted_at" field.
  15611. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  15612. m.deleted_at = &t
  15613. }
  15614. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15615. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  15616. v := m.deleted_at
  15617. if v == nil {
  15618. return
  15619. }
  15620. return *v, true
  15621. }
  15622. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  15623. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  15624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15625. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15626. if !m.op.Is(OpUpdateOne) {
  15627. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15628. }
  15629. if m.id == nil || m.oldValue == nil {
  15630. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15631. }
  15632. oldValue, err := m.oldValue(ctx)
  15633. if err != nil {
  15634. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15635. }
  15636. return oldValue.DeletedAt, nil
  15637. }
  15638. // ClearDeletedAt clears the value of the "deleted_at" field.
  15639. func (m *WorkExperienceMutation) ClearDeletedAt() {
  15640. m.deleted_at = nil
  15641. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  15642. }
  15643. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15644. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  15645. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  15646. return ok
  15647. }
  15648. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15649. func (m *WorkExperienceMutation) ResetDeletedAt() {
  15650. m.deleted_at = nil
  15651. delete(m.clearedFields, workexperience.FieldDeletedAt)
  15652. }
  15653. // SetEmployeeID sets the "employee_id" field.
  15654. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  15655. m.employee = &u
  15656. }
  15657. // EmployeeID returns the value of the "employee_id" field in the mutation.
  15658. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  15659. v := m.employee
  15660. if v == nil {
  15661. return
  15662. }
  15663. return *v, true
  15664. }
  15665. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  15666. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  15667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15668. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  15669. if !m.op.Is(OpUpdateOne) {
  15670. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  15671. }
  15672. if m.id == nil || m.oldValue == nil {
  15673. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  15674. }
  15675. oldValue, err := m.oldValue(ctx)
  15676. if err != nil {
  15677. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  15678. }
  15679. return oldValue.EmployeeID, nil
  15680. }
  15681. // ResetEmployeeID resets all changes to the "employee_id" field.
  15682. func (m *WorkExperienceMutation) ResetEmployeeID() {
  15683. m.employee = nil
  15684. }
  15685. // SetStartDate sets the "start_date" field.
  15686. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  15687. m.start_date = &t
  15688. }
  15689. // StartDate returns the value of the "start_date" field in the mutation.
  15690. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  15691. v := m.start_date
  15692. if v == nil {
  15693. return
  15694. }
  15695. return *v, true
  15696. }
  15697. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  15698. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  15699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15700. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  15701. if !m.op.Is(OpUpdateOne) {
  15702. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  15703. }
  15704. if m.id == nil || m.oldValue == nil {
  15705. return v, errors.New("OldStartDate requires an ID field in the mutation")
  15706. }
  15707. oldValue, err := m.oldValue(ctx)
  15708. if err != nil {
  15709. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  15710. }
  15711. return oldValue.StartDate, nil
  15712. }
  15713. // ResetStartDate resets all changes to the "start_date" field.
  15714. func (m *WorkExperienceMutation) ResetStartDate() {
  15715. m.start_date = nil
  15716. }
  15717. // SetEndDate sets the "end_date" field.
  15718. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  15719. m.end_date = &t
  15720. }
  15721. // EndDate returns the value of the "end_date" field in the mutation.
  15722. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  15723. v := m.end_date
  15724. if v == nil {
  15725. return
  15726. }
  15727. return *v, true
  15728. }
  15729. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  15730. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  15731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15732. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  15733. if !m.op.Is(OpUpdateOne) {
  15734. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  15735. }
  15736. if m.id == nil || m.oldValue == nil {
  15737. return v, errors.New("OldEndDate requires an ID field in the mutation")
  15738. }
  15739. oldValue, err := m.oldValue(ctx)
  15740. if err != nil {
  15741. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  15742. }
  15743. return oldValue.EndDate, nil
  15744. }
  15745. // ResetEndDate resets all changes to the "end_date" field.
  15746. func (m *WorkExperienceMutation) ResetEndDate() {
  15747. m.end_date = nil
  15748. }
  15749. // SetCompany sets the "company" field.
  15750. func (m *WorkExperienceMutation) SetCompany(s string) {
  15751. m.company = &s
  15752. }
  15753. // Company returns the value of the "company" field in the mutation.
  15754. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  15755. v := m.company
  15756. if v == nil {
  15757. return
  15758. }
  15759. return *v, true
  15760. }
  15761. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  15762. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  15763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15764. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  15765. if !m.op.Is(OpUpdateOne) {
  15766. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  15767. }
  15768. if m.id == nil || m.oldValue == nil {
  15769. return v, errors.New("OldCompany requires an ID field in the mutation")
  15770. }
  15771. oldValue, err := m.oldValue(ctx)
  15772. if err != nil {
  15773. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  15774. }
  15775. return oldValue.Company, nil
  15776. }
  15777. // ResetCompany resets all changes to the "company" field.
  15778. func (m *WorkExperienceMutation) ResetCompany() {
  15779. m.company = nil
  15780. }
  15781. // SetExperience sets the "experience" field.
  15782. func (m *WorkExperienceMutation) SetExperience(s string) {
  15783. m.experience = &s
  15784. }
  15785. // Experience returns the value of the "experience" field in the mutation.
  15786. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  15787. v := m.experience
  15788. if v == nil {
  15789. return
  15790. }
  15791. return *v, true
  15792. }
  15793. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  15794. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  15795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15796. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  15797. if !m.op.Is(OpUpdateOne) {
  15798. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  15799. }
  15800. if m.id == nil || m.oldValue == nil {
  15801. return v, errors.New("OldExperience requires an ID field in the mutation")
  15802. }
  15803. oldValue, err := m.oldValue(ctx)
  15804. if err != nil {
  15805. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  15806. }
  15807. return oldValue.Experience, nil
  15808. }
  15809. // ResetExperience resets all changes to the "experience" field.
  15810. func (m *WorkExperienceMutation) ResetExperience() {
  15811. m.experience = nil
  15812. }
  15813. // SetOrganizationID sets the "organization_id" field.
  15814. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  15815. m.organization_id = &u
  15816. m.addorganization_id = nil
  15817. }
  15818. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15819. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  15820. v := m.organization_id
  15821. if v == nil {
  15822. return
  15823. }
  15824. return *v, true
  15825. }
  15826. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  15827. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  15828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15829. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15830. if !m.op.Is(OpUpdateOne) {
  15831. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15832. }
  15833. if m.id == nil || m.oldValue == nil {
  15834. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15835. }
  15836. oldValue, err := m.oldValue(ctx)
  15837. if err != nil {
  15838. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15839. }
  15840. return oldValue.OrganizationID, nil
  15841. }
  15842. // AddOrganizationID adds u to the "organization_id" field.
  15843. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  15844. if m.addorganization_id != nil {
  15845. *m.addorganization_id += u
  15846. } else {
  15847. m.addorganization_id = &u
  15848. }
  15849. }
  15850. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15851. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  15852. v := m.addorganization_id
  15853. if v == nil {
  15854. return
  15855. }
  15856. return *v, true
  15857. }
  15858. // ResetOrganizationID resets all changes to the "organization_id" field.
  15859. func (m *WorkExperienceMutation) ResetOrganizationID() {
  15860. m.organization_id = nil
  15861. m.addorganization_id = nil
  15862. }
  15863. // ClearEmployee clears the "employee" edge to the Employee entity.
  15864. func (m *WorkExperienceMutation) ClearEmployee() {
  15865. m.clearedemployee = true
  15866. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  15867. }
  15868. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  15869. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  15870. return m.clearedemployee
  15871. }
  15872. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  15873. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15874. // EmployeeID instead. It exists only for internal usage by the builders.
  15875. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  15876. if id := m.employee; id != nil {
  15877. ids = append(ids, *id)
  15878. }
  15879. return
  15880. }
  15881. // ResetEmployee resets all changes to the "employee" edge.
  15882. func (m *WorkExperienceMutation) ResetEmployee() {
  15883. m.employee = nil
  15884. m.clearedemployee = false
  15885. }
  15886. // Where appends a list predicates to the WorkExperienceMutation builder.
  15887. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  15888. m.predicates = append(m.predicates, ps...)
  15889. }
  15890. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  15891. // users can use type-assertion to append predicates that do not depend on any generated package.
  15892. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  15893. p := make([]predicate.WorkExperience, len(ps))
  15894. for i := range ps {
  15895. p[i] = ps[i]
  15896. }
  15897. m.Where(p...)
  15898. }
  15899. // Op returns the operation name.
  15900. func (m *WorkExperienceMutation) Op() Op {
  15901. return m.op
  15902. }
  15903. // SetOp allows setting the mutation operation.
  15904. func (m *WorkExperienceMutation) SetOp(op Op) {
  15905. m.op = op
  15906. }
  15907. // Type returns the node type of this mutation (WorkExperience).
  15908. func (m *WorkExperienceMutation) Type() string {
  15909. return m.typ
  15910. }
  15911. // Fields returns all fields that were changed during this mutation. Note that in
  15912. // order to get all numeric fields that were incremented/decremented, call
  15913. // AddedFields().
  15914. func (m *WorkExperienceMutation) Fields() []string {
  15915. fields := make([]string, 0, 9)
  15916. if m.created_at != nil {
  15917. fields = append(fields, workexperience.FieldCreatedAt)
  15918. }
  15919. if m.updated_at != nil {
  15920. fields = append(fields, workexperience.FieldUpdatedAt)
  15921. }
  15922. if m.deleted_at != nil {
  15923. fields = append(fields, workexperience.FieldDeletedAt)
  15924. }
  15925. if m.employee != nil {
  15926. fields = append(fields, workexperience.FieldEmployeeID)
  15927. }
  15928. if m.start_date != nil {
  15929. fields = append(fields, workexperience.FieldStartDate)
  15930. }
  15931. if m.end_date != nil {
  15932. fields = append(fields, workexperience.FieldEndDate)
  15933. }
  15934. if m.company != nil {
  15935. fields = append(fields, workexperience.FieldCompany)
  15936. }
  15937. if m.experience != nil {
  15938. fields = append(fields, workexperience.FieldExperience)
  15939. }
  15940. if m.organization_id != nil {
  15941. fields = append(fields, workexperience.FieldOrganizationID)
  15942. }
  15943. return fields
  15944. }
  15945. // Field returns the value of a field with the given name. The second boolean
  15946. // return value indicates that this field was not set, or was not defined in the
  15947. // schema.
  15948. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  15949. switch name {
  15950. case workexperience.FieldCreatedAt:
  15951. return m.CreatedAt()
  15952. case workexperience.FieldUpdatedAt:
  15953. return m.UpdatedAt()
  15954. case workexperience.FieldDeletedAt:
  15955. return m.DeletedAt()
  15956. case workexperience.FieldEmployeeID:
  15957. return m.EmployeeID()
  15958. case workexperience.FieldStartDate:
  15959. return m.StartDate()
  15960. case workexperience.FieldEndDate:
  15961. return m.EndDate()
  15962. case workexperience.FieldCompany:
  15963. return m.Company()
  15964. case workexperience.FieldExperience:
  15965. return m.Experience()
  15966. case workexperience.FieldOrganizationID:
  15967. return m.OrganizationID()
  15968. }
  15969. return nil, false
  15970. }
  15971. // OldField returns the old value of the field from the database. An error is
  15972. // returned if the mutation operation is not UpdateOne, or the query to the
  15973. // database failed.
  15974. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15975. switch name {
  15976. case workexperience.FieldCreatedAt:
  15977. return m.OldCreatedAt(ctx)
  15978. case workexperience.FieldUpdatedAt:
  15979. return m.OldUpdatedAt(ctx)
  15980. case workexperience.FieldDeletedAt:
  15981. return m.OldDeletedAt(ctx)
  15982. case workexperience.FieldEmployeeID:
  15983. return m.OldEmployeeID(ctx)
  15984. case workexperience.FieldStartDate:
  15985. return m.OldStartDate(ctx)
  15986. case workexperience.FieldEndDate:
  15987. return m.OldEndDate(ctx)
  15988. case workexperience.FieldCompany:
  15989. return m.OldCompany(ctx)
  15990. case workexperience.FieldExperience:
  15991. return m.OldExperience(ctx)
  15992. case workexperience.FieldOrganizationID:
  15993. return m.OldOrganizationID(ctx)
  15994. }
  15995. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  15996. }
  15997. // SetField sets the value of a field with the given name. It returns an error if
  15998. // the field is not defined in the schema, or if the type mismatched the field
  15999. // type.
  16000. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  16001. switch name {
  16002. case workexperience.FieldCreatedAt:
  16003. v, ok := value.(time.Time)
  16004. if !ok {
  16005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16006. }
  16007. m.SetCreatedAt(v)
  16008. return nil
  16009. case workexperience.FieldUpdatedAt:
  16010. v, ok := value.(time.Time)
  16011. if !ok {
  16012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16013. }
  16014. m.SetUpdatedAt(v)
  16015. return nil
  16016. case workexperience.FieldDeletedAt:
  16017. v, ok := value.(time.Time)
  16018. if !ok {
  16019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16020. }
  16021. m.SetDeletedAt(v)
  16022. return nil
  16023. case workexperience.FieldEmployeeID:
  16024. v, ok := value.(uint64)
  16025. if !ok {
  16026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16027. }
  16028. m.SetEmployeeID(v)
  16029. return nil
  16030. case workexperience.FieldStartDate:
  16031. v, ok := value.(time.Time)
  16032. if !ok {
  16033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16034. }
  16035. m.SetStartDate(v)
  16036. return nil
  16037. case workexperience.FieldEndDate:
  16038. v, ok := value.(time.Time)
  16039. if !ok {
  16040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16041. }
  16042. m.SetEndDate(v)
  16043. return nil
  16044. case workexperience.FieldCompany:
  16045. v, ok := value.(string)
  16046. if !ok {
  16047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16048. }
  16049. m.SetCompany(v)
  16050. return nil
  16051. case workexperience.FieldExperience:
  16052. v, ok := value.(string)
  16053. if !ok {
  16054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16055. }
  16056. m.SetExperience(v)
  16057. return nil
  16058. case workexperience.FieldOrganizationID:
  16059. v, ok := value.(uint64)
  16060. if !ok {
  16061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16062. }
  16063. m.SetOrganizationID(v)
  16064. return nil
  16065. }
  16066. return fmt.Errorf("unknown WorkExperience field %s", name)
  16067. }
  16068. // AddedFields returns all numeric fields that were incremented/decremented during
  16069. // this mutation.
  16070. func (m *WorkExperienceMutation) AddedFields() []string {
  16071. var fields []string
  16072. if m.addorganization_id != nil {
  16073. fields = append(fields, workexperience.FieldOrganizationID)
  16074. }
  16075. return fields
  16076. }
  16077. // AddedField returns the numeric value that was incremented/decremented on a field
  16078. // with the given name. The second boolean return value indicates that this field
  16079. // was not set, or was not defined in the schema.
  16080. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  16081. switch name {
  16082. case workexperience.FieldOrganizationID:
  16083. return m.AddedOrganizationID()
  16084. }
  16085. return nil, false
  16086. }
  16087. // AddField adds the value to the field with the given name. It returns an error if
  16088. // the field is not defined in the schema, or if the type mismatched the field
  16089. // type.
  16090. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  16091. switch name {
  16092. case workexperience.FieldOrganizationID:
  16093. v, ok := value.(int64)
  16094. if !ok {
  16095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16096. }
  16097. m.AddOrganizationID(v)
  16098. return nil
  16099. }
  16100. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  16101. }
  16102. // ClearedFields returns all nullable fields that were cleared during this
  16103. // mutation.
  16104. func (m *WorkExperienceMutation) ClearedFields() []string {
  16105. var fields []string
  16106. if m.FieldCleared(workexperience.FieldDeletedAt) {
  16107. fields = append(fields, workexperience.FieldDeletedAt)
  16108. }
  16109. return fields
  16110. }
  16111. // FieldCleared returns a boolean indicating if a field with the given name was
  16112. // cleared in this mutation.
  16113. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  16114. _, ok := m.clearedFields[name]
  16115. return ok
  16116. }
  16117. // ClearField clears the value of the field with the given name. It returns an
  16118. // error if the field is not defined in the schema.
  16119. func (m *WorkExperienceMutation) ClearField(name string) error {
  16120. switch name {
  16121. case workexperience.FieldDeletedAt:
  16122. m.ClearDeletedAt()
  16123. return nil
  16124. }
  16125. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  16126. }
  16127. // ResetField resets all changes in the mutation for the field with the given name.
  16128. // It returns an error if the field is not defined in the schema.
  16129. func (m *WorkExperienceMutation) ResetField(name string) error {
  16130. switch name {
  16131. case workexperience.FieldCreatedAt:
  16132. m.ResetCreatedAt()
  16133. return nil
  16134. case workexperience.FieldUpdatedAt:
  16135. m.ResetUpdatedAt()
  16136. return nil
  16137. case workexperience.FieldDeletedAt:
  16138. m.ResetDeletedAt()
  16139. return nil
  16140. case workexperience.FieldEmployeeID:
  16141. m.ResetEmployeeID()
  16142. return nil
  16143. case workexperience.FieldStartDate:
  16144. m.ResetStartDate()
  16145. return nil
  16146. case workexperience.FieldEndDate:
  16147. m.ResetEndDate()
  16148. return nil
  16149. case workexperience.FieldCompany:
  16150. m.ResetCompany()
  16151. return nil
  16152. case workexperience.FieldExperience:
  16153. m.ResetExperience()
  16154. return nil
  16155. case workexperience.FieldOrganizationID:
  16156. m.ResetOrganizationID()
  16157. return nil
  16158. }
  16159. return fmt.Errorf("unknown WorkExperience field %s", name)
  16160. }
  16161. // AddedEdges returns all edge names that were set/added in this mutation.
  16162. func (m *WorkExperienceMutation) AddedEdges() []string {
  16163. edges := make([]string, 0, 1)
  16164. if m.employee != nil {
  16165. edges = append(edges, workexperience.EdgeEmployee)
  16166. }
  16167. return edges
  16168. }
  16169. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16170. // name in this mutation.
  16171. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  16172. switch name {
  16173. case workexperience.EdgeEmployee:
  16174. if id := m.employee; id != nil {
  16175. return []ent.Value{*id}
  16176. }
  16177. }
  16178. return nil
  16179. }
  16180. // RemovedEdges returns all edge names that were removed in this mutation.
  16181. func (m *WorkExperienceMutation) RemovedEdges() []string {
  16182. edges := make([]string, 0, 1)
  16183. return edges
  16184. }
  16185. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16186. // the given name in this mutation.
  16187. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  16188. return nil
  16189. }
  16190. // ClearedEdges returns all edge names that were cleared in this mutation.
  16191. func (m *WorkExperienceMutation) ClearedEdges() []string {
  16192. edges := make([]string, 0, 1)
  16193. if m.clearedemployee {
  16194. edges = append(edges, workexperience.EdgeEmployee)
  16195. }
  16196. return edges
  16197. }
  16198. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16199. // was cleared in this mutation.
  16200. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  16201. switch name {
  16202. case workexperience.EdgeEmployee:
  16203. return m.clearedemployee
  16204. }
  16205. return false
  16206. }
  16207. // ClearEdge clears the value of the edge with the given name. It returns an error
  16208. // if that edge is not defined in the schema.
  16209. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  16210. switch name {
  16211. case workexperience.EdgeEmployee:
  16212. m.ClearEmployee()
  16213. return nil
  16214. }
  16215. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  16216. }
  16217. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16218. // It returns an error if the edge is not defined in the schema.
  16219. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  16220. switch name {
  16221. case workexperience.EdgeEmployee:
  16222. m.ResetEmployee()
  16223. return nil
  16224. }
  16225. return fmt.Errorf("unknown WorkExperience edge %s", name)
  16226. }
  16227. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  16228. type WxMutation struct {
  16229. config
  16230. op Op
  16231. typ string
  16232. id *uint64
  16233. created_at *time.Time
  16234. updated_at *time.Time
  16235. status *uint8
  16236. addstatus *int8
  16237. deleted_at *time.Time
  16238. port *string
  16239. process_id *string
  16240. callback *string
  16241. wxid *string
  16242. account *string
  16243. nickname *string
  16244. tel *string
  16245. head_big *string
  16246. organization_id *uint64
  16247. addorganization_id *int64
  16248. clearedFields map[string]struct{}
  16249. server *uint64
  16250. clearedserver bool
  16251. agent *uint64
  16252. clearedagent bool
  16253. done bool
  16254. oldValue func(context.Context) (*Wx, error)
  16255. predicates []predicate.Wx
  16256. }
  16257. var _ ent.Mutation = (*WxMutation)(nil)
  16258. // wxOption allows management of the mutation configuration using functional options.
  16259. type wxOption func(*WxMutation)
  16260. // newWxMutation creates new mutation for the Wx entity.
  16261. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  16262. m := &WxMutation{
  16263. config: c,
  16264. op: op,
  16265. typ: TypeWx,
  16266. clearedFields: make(map[string]struct{}),
  16267. }
  16268. for _, opt := range opts {
  16269. opt(m)
  16270. }
  16271. return m
  16272. }
  16273. // withWxID sets the ID field of the mutation.
  16274. func withWxID(id uint64) wxOption {
  16275. return func(m *WxMutation) {
  16276. var (
  16277. err error
  16278. once sync.Once
  16279. value *Wx
  16280. )
  16281. m.oldValue = func(ctx context.Context) (*Wx, error) {
  16282. once.Do(func() {
  16283. if m.done {
  16284. err = errors.New("querying old values post mutation is not allowed")
  16285. } else {
  16286. value, err = m.Client().Wx.Get(ctx, id)
  16287. }
  16288. })
  16289. return value, err
  16290. }
  16291. m.id = &id
  16292. }
  16293. }
  16294. // withWx sets the old Wx of the mutation.
  16295. func withWx(node *Wx) wxOption {
  16296. return func(m *WxMutation) {
  16297. m.oldValue = func(context.Context) (*Wx, error) {
  16298. return node, nil
  16299. }
  16300. m.id = &node.ID
  16301. }
  16302. }
  16303. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16304. // executed in a transaction (ent.Tx), a transactional client is returned.
  16305. func (m WxMutation) Client() *Client {
  16306. client := &Client{config: m.config}
  16307. client.init()
  16308. return client
  16309. }
  16310. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16311. // it returns an error otherwise.
  16312. func (m WxMutation) Tx() (*Tx, error) {
  16313. if _, ok := m.driver.(*txDriver); !ok {
  16314. return nil, errors.New("ent: mutation is not running in a transaction")
  16315. }
  16316. tx := &Tx{config: m.config}
  16317. tx.init()
  16318. return tx, nil
  16319. }
  16320. // SetID sets the value of the id field. Note that this
  16321. // operation is only accepted on creation of Wx entities.
  16322. func (m *WxMutation) SetID(id uint64) {
  16323. m.id = &id
  16324. }
  16325. // ID returns the ID value in the mutation. Note that the ID is only available
  16326. // if it was provided to the builder or after it was returned from the database.
  16327. func (m *WxMutation) ID() (id uint64, exists bool) {
  16328. if m.id == nil {
  16329. return
  16330. }
  16331. return *m.id, true
  16332. }
  16333. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16334. // That means, if the mutation is applied within a transaction with an isolation level such
  16335. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16336. // or updated by the mutation.
  16337. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  16338. switch {
  16339. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16340. id, exists := m.ID()
  16341. if exists {
  16342. return []uint64{id}, nil
  16343. }
  16344. fallthrough
  16345. case m.op.Is(OpUpdate | OpDelete):
  16346. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  16347. default:
  16348. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16349. }
  16350. }
  16351. // SetCreatedAt sets the "created_at" field.
  16352. func (m *WxMutation) SetCreatedAt(t time.Time) {
  16353. m.created_at = &t
  16354. }
  16355. // CreatedAt returns the value of the "created_at" field in the mutation.
  16356. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  16357. v := m.created_at
  16358. if v == nil {
  16359. return
  16360. }
  16361. return *v, true
  16362. }
  16363. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  16364. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  16365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16366. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16367. if !m.op.Is(OpUpdateOne) {
  16368. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16369. }
  16370. if m.id == nil || m.oldValue == nil {
  16371. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16372. }
  16373. oldValue, err := m.oldValue(ctx)
  16374. if err != nil {
  16375. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16376. }
  16377. return oldValue.CreatedAt, nil
  16378. }
  16379. // ResetCreatedAt resets all changes to the "created_at" field.
  16380. func (m *WxMutation) ResetCreatedAt() {
  16381. m.created_at = nil
  16382. }
  16383. // SetUpdatedAt sets the "updated_at" field.
  16384. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  16385. m.updated_at = &t
  16386. }
  16387. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16388. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  16389. v := m.updated_at
  16390. if v == nil {
  16391. return
  16392. }
  16393. return *v, true
  16394. }
  16395. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  16396. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  16397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16398. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16399. if !m.op.Is(OpUpdateOne) {
  16400. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16401. }
  16402. if m.id == nil || m.oldValue == nil {
  16403. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16404. }
  16405. oldValue, err := m.oldValue(ctx)
  16406. if err != nil {
  16407. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16408. }
  16409. return oldValue.UpdatedAt, nil
  16410. }
  16411. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16412. func (m *WxMutation) ResetUpdatedAt() {
  16413. m.updated_at = nil
  16414. }
  16415. // SetStatus sets the "status" field.
  16416. func (m *WxMutation) SetStatus(u uint8) {
  16417. m.status = &u
  16418. m.addstatus = nil
  16419. }
  16420. // Status returns the value of the "status" field in the mutation.
  16421. func (m *WxMutation) Status() (r uint8, exists bool) {
  16422. v := m.status
  16423. if v == nil {
  16424. return
  16425. }
  16426. return *v, true
  16427. }
  16428. // OldStatus returns the old "status" field's value of the Wx entity.
  16429. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  16430. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16431. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16432. if !m.op.Is(OpUpdateOne) {
  16433. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16434. }
  16435. if m.id == nil || m.oldValue == nil {
  16436. return v, errors.New("OldStatus requires an ID field in the mutation")
  16437. }
  16438. oldValue, err := m.oldValue(ctx)
  16439. if err != nil {
  16440. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16441. }
  16442. return oldValue.Status, nil
  16443. }
  16444. // AddStatus adds u to the "status" field.
  16445. func (m *WxMutation) AddStatus(u int8) {
  16446. if m.addstatus != nil {
  16447. *m.addstatus += u
  16448. } else {
  16449. m.addstatus = &u
  16450. }
  16451. }
  16452. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16453. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  16454. v := m.addstatus
  16455. if v == nil {
  16456. return
  16457. }
  16458. return *v, true
  16459. }
  16460. // ClearStatus clears the value of the "status" field.
  16461. func (m *WxMutation) ClearStatus() {
  16462. m.status = nil
  16463. m.addstatus = nil
  16464. m.clearedFields[wx.FieldStatus] = struct{}{}
  16465. }
  16466. // StatusCleared returns if the "status" field was cleared in this mutation.
  16467. func (m *WxMutation) StatusCleared() bool {
  16468. _, ok := m.clearedFields[wx.FieldStatus]
  16469. return ok
  16470. }
  16471. // ResetStatus resets all changes to the "status" field.
  16472. func (m *WxMutation) ResetStatus() {
  16473. m.status = nil
  16474. m.addstatus = nil
  16475. delete(m.clearedFields, wx.FieldStatus)
  16476. }
  16477. // SetDeletedAt sets the "deleted_at" field.
  16478. func (m *WxMutation) SetDeletedAt(t time.Time) {
  16479. m.deleted_at = &t
  16480. }
  16481. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16482. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  16483. v := m.deleted_at
  16484. if v == nil {
  16485. return
  16486. }
  16487. return *v, true
  16488. }
  16489. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  16490. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  16491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16492. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16493. if !m.op.Is(OpUpdateOne) {
  16494. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16495. }
  16496. if m.id == nil || m.oldValue == nil {
  16497. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16498. }
  16499. oldValue, err := m.oldValue(ctx)
  16500. if err != nil {
  16501. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16502. }
  16503. return oldValue.DeletedAt, nil
  16504. }
  16505. // ClearDeletedAt clears the value of the "deleted_at" field.
  16506. func (m *WxMutation) ClearDeletedAt() {
  16507. m.deleted_at = nil
  16508. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  16509. }
  16510. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16511. func (m *WxMutation) DeletedAtCleared() bool {
  16512. _, ok := m.clearedFields[wx.FieldDeletedAt]
  16513. return ok
  16514. }
  16515. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16516. func (m *WxMutation) ResetDeletedAt() {
  16517. m.deleted_at = nil
  16518. delete(m.clearedFields, wx.FieldDeletedAt)
  16519. }
  16520. // SetServerID sets the "server_id" field.
  16521. func (m *WxMutation) SetServerID(u uint64) {
  16522. m.server = &u
  16523. }
  16524. // ServerID returns the value of the "server_id" field in the mutation.
  16525. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  16526. v := m.server
  16527. if v == nil {
  16528. return
  16529. }
  16530. return *v, true
  16531. }
  16532. // OldServerID returns the old "server_id" field's value of the Wx entity.
  16533. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  16534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16535. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  16536. if !m.op.Is(OpUpdateOne) {
  16537. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  16538. }
  16539. if m.id == nil || m.oldValue == nil {
  16540. return v, errors.New("OldServerID requires an ID field in the mutation")
  16541. }
  16542. oldValue, err := m.oldValue(ctx)
  16543. if err != nil {
  16544. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  16545. }
  16546. return oldValue.ServerID, nil
  16547. }
  16548. // ClearServerID clears the value of the "server_id" field.
  16549. func (m *WxMutation) ClearServerID() {
  16550. m.server = nil
  16551. m.clearedFields[wx.FieldServerID] = struct{}{}
  16552. }
  16553. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  16554. func (m *WxMutation) ServerIDCleared() bool {
  16555. _, ok := m.clearedFields[wx.FieldServerID]
  16556. return ok
  16557. }
  16558. // ResetServerID resets all changes to the "server_id" field.
  16559. func (m *WxMutation) ResetServerID() {
  16560. m.server = nil
  16561. delete(m.clearedFields, wx.FieldServerID)
  16562. }
  16563. // SetPort sets the "port" field.
  16564. func (m *WxMutation) SetPort(s string) {
  16565. m.port = &s
  16566. }
  16567. // Port returns the value of the "port" field in the mutation.
  16568. func (m *WxMutation) Port() (r string, exists bool) {
  16569. v := m.port
  16570. if v == nil {
  16571. return
  16572. }
  16573. return *v, true
  16574. }
  16575. // OldPort returns the old "port" field's value of the Wx entity.
  16576. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  16577. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16578. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  16579. if !m.op.Is(OpUpdateOne) {
  16580. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  16581. }
  16582. if m.id == nil || m.oldValue == nil {
  16583. return v, errors.New("OldPort requires an ID field in the mutation")
  16584. }
  16585. oldValue, err := m.oldValue(ctx)
  16586. if err != nil {
  16587. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  16588. }
  16589. return oldValue.Port, nil
  16590. }
  16591. // ResetPort resets all changes to the "port" field.
  16592. func (m *WxMutation) ResetPort() {
  16593. m.port = nil
  16594. }
  16595. // SetProcessID sets the "process_id" field.
  16596. func (m *WxMutation) SetProcessID(s string) {
  16597. m.process_id = &s
  16598. }
  16599. // ProcessID returns the value of the "process_id" field in the mutation.
  16600. func (m *WxMutation) ProcessID() (r string, exists bool) {
  16601. v := m.process_id
  16602. if v == nil {
  16603. return
  16604. }
  16605. return *v, true
  16606. }
  16607. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  16608. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  16609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16610. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  16611. if !m.op.Is(OpUpdateOne) {
  16612. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  16613. }
  16614. if m.id == nil || m.oldValue == nil {
  16615. return v, errors.New("OldProcessID requires an ID field in the mutation")
  16616. }
  16617. oldValue, err := m.oldValue(ctx)
  16618. if err != nil {
  16619. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  16620. }
  16621. return oldValue.ProcessID, nil
  16622. }
  16623. // ResetProcessID resets all changes to the "process_id" field.
  16624. func (m *WxMutation) ResetProcessID() {
  16625. m.process_id = nil
  16626. }
  16627. // SetCallback sets the "callback" field.
  16628. func (m *WxMutation) SetCallback(s string) {
  16629. m.callback = &s
  16630. }
  16631. // Callback returns the value of the "callback" field in the mutation.
  16632. func (m *WxMutation) Callback() (r string, exists bool) {
  16633. v := m.callback
  16634. if v == nil {
  16635. return
  16636. }
  16637. return *v, true
  16638. }
  16639. // OldCallback returns the old "callback" field's value of the Wx entity.
  16640. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  16641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16642. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  16643. if !m.op.Is(OpUpdateOne) {
  16644. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  16645. }
  16646. if m.id == nil || m.oldValue == nil {
  16647. return v, errors.New("OldCallback requires an ID field in the mutation")
  16648. }
  16649. oldValue, err := m.oldValue(ctx)
  16650. if err != nil {
  16651. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  16652. }
  16653. return oldValue.Callback, nil
  16654. }
  16655. // ResetCallback resets all changes to the "callback" field.
  16656. func (m *WxMutation) ResetCallback() {
  16657. m.callback = nil
  16658. }
  16659. // SetWxid sets the "wxid" field.
  16660. func (m *WxMutation) SetWxid(s string) {
  16661. m.wxid = &s
  16662. }
  16663. // Wxid returns the value of the "wxid" field in the mutation.
  16664. func (m *WxMutation) Wxid() (r string, exists bool) {
  16665. v := m.wxid
  16666. if v == nil {
  16667. return
  16668. }
  16669. return *v, true
  16670. }
  16671. // OldWxid returns the old "wxid" field's value of the Wx entity.
  16672. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  16673. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16674. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  16675. if !m.op.Is(OpUpdateOne) {
  16676. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  16677. }
  16678. if m.id == nil || m.oldValue == nil {
  16679. return v, errors.New("OldWxid requires an ID field in the mutation")
  16680. }
  16681. oldValue, err := m.oldValue(ctx)
  16682. if err != nil {
  16683. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  16684. }
  16685. return oldValue.Wxid, nil
  16686. }
  16687. // ResetWxid resets all changes to the "wxid" field.
  16688. func (m *WxMutation) ResetWxid() {
  16689. m.wxid = nil
  16690. }
  16691. // SetAccount sets the "account" field.
  16692. func (m *WxMutation) SetAccount(s string) {
  16693. m.account = &s
  16694. }
  16695. // Account returns the value of the "account" field in the mutation.
  16696. func (m *WxMutation) Account() (r string, exists bool) {
  16697. v := m.account
  16698. if v == nil {
  16699. return
  16700. }
  16701. return *v, true
  16702. }
  16703. // OldAccount returns the old "account" field's value of the Wx entity.
  16704. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  16705. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16706. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  16707. if !m.op.Is(OpUpdateOne) {
  16708. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  16709. }
  16710. if m.id == nil || m.oldValue == nil {
  16711. return v, errors.New("OldAccount requires an ID field in the mutation")
  16712. }
  16713. oldValue, err := m.oldValue(ctx)
  16714. if err != nil {
  16715. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  16716. }
  16717. return oldValue.Account, nil
  16718. }
  16719. // ResetAccount resets all changes to the "account" field.
  16720. func (m *WxMutation) ResetAccount() {
  16721. m.account = nil
  16722. }
  16723. // SetNickname sets the "nickname" field.
  16724. func (m *WxMutation) SetNickname(s string) {
  16725. m.nickname = &s
  16726. }
  16727. // Nickname returns the value of the "nickname" field in the mutation.
  16728. func (m *WxMutation) Nickname() (r string, exists bool) {
  16729. v := m.nickname
  16730. if v == nil {
  16731. return
  16732. }
  16733. return *v, true
  16734. }
  16735. // OldNickname returns the old "nickname" field's value of the Wx entity.
  16736. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  16737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16738. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  16739. if !m.op.Is(OpUpdateOne) {
  16740. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  16741. }
  16742. if m.id == nil || m.oldValue == nil {
  16743. return v, errors.New("OldNickname requires an ID field in the mutation")
  16744. }
  16745. oldValue, err := m.oldValue(ctx)
  16746. if err != nil {
  16747. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  16748. }
  16749. return oldValue.Nickname, nil
  16750. }
  16751. // ResetNickname resets all changes to the "nickname" field.
  16752. func (m *WxMutation) ResetNickname() {
  16753. m.nickname = nil
  16754. }
  16755. // SetTel sets the "tel" field.
  16756. func (m *WxMutation) SetTel(s string) {
  16757. m.tel = &s
  16758. }
  16759. // Tel returns the value of the "tel" field in the mutation.
  16760. func (m *WxMutation) Tel() (r string, exists bool) {
  16761. v := m.tel
  16762. if v == nil {
  16763. return
  16764. }
  16765. return *v, true
  16766. }
  16767. // OldTel returns the old "tel" field's value of the Wx entity.
  16768. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  16769. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16770. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  16771. if !m.op.Is(OpUpdateOne) {
  16772. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  16773. }
  16774. if m.id == nil || m.oldValue == nil {
  16775. return v, errors.New("OldTel requires an ID field in the mutation")
  16776. }
  16777. oldValue, err := m.oldValue(ctx)
  16778. if err != nil {
  16779. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  16780. }
  16781. return oldValue.Tel, nil
  16782. }
  16783. // ResetTel resets all changes to the "tel" field.
  16784. func (m *WxMutation) ResetTel() {
  16785. m.tel = nil
  16786. }
  16787. // SetHeadBig sets the "head_big" field.
  16788. func (m *WxMutation) SetHeadBig(s string) {
  16789. m.head_big = &s
  16790. }
  16791. // HeadBig returns the value of the "head_big" field in the mutation.
  16792. func (m *WxMutation) HeadBig() (r string, exists bool) {
  16793. v := m.head_big
  16794. if v == nil {
  16795. return
  16796. }
  16797. return *v, true
  16798. }
  16799. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  16800. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  16801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16802. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  16803. if !m.op.Is(OpUpdateOne) {
  16804. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  16805. }
  16806. if m.id == nil || m.oldValue == nil {
  16807. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  16808. }
  16809. oldValue, err := m.oldValue(ctx)
  16810. if err != nil {
  16811. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  16812. }
  16813. return oldValue.HeadBig, nil
  16814. }
  16815. // ResetHeadBig resets all changes to the "head_big" field.
  16816. func (m *WxMutation) ResetHeadBig() {
  16817. m.head_big = nil
  16818. }
  16819. // SetOrganizationID sets the "organization_id" field.
  16820. func (m *WxMutation) SetOrganizationID(u uint64) {
  16821. m.organization_id = &u
  16822. m.addorganization_id = nil
  16823. }
  16824. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16825. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  16826. v := m.organization_id
  16827. if v == nil {
  16828. return
  16829. }
  16830. return *v, true
  16831. }
  16832. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  16833. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  16834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16835. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16836. if !m.op.Is(OpUpdateOne) {
  16837. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16838. }
  16839. if m.id == nil || m.oldValue == nil {
  16840. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16841. }
  16842. oldValue, err := m.oldValue(ctx)
  16843. if err != nil {
  16844. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16845. }
  16846. return oldValue.OrganizationID, nil
  16847. }
  16848. // AddOrganizationID adds u to the "organization_id" field.
  16849. func (m *WxMutation) AddOrganizationID(u int64) {
  16850. if m.addorganization_id != nil {
  16851. *m.addorganization_id += u
  16852. } else {
  16853. m.addorganization_id = &u
  16854. }
  16855. }
  16856. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16857. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  16858. v := m.addorganization_id
  16859. if v == nil {
  16860. return
  16861. }
  16862. return *v, true
  16863. }
  16864. // ClearOrganizationID clears the value of the "organization_id" field.
  16865. func (m *WxMutation) ClearOrganizationID() {
  16866. m.organization_id = nil
  16867. m.addorganization_id = nil
  16868. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  16869. }
  16870. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  16871. func (m *WxMutation) OrganizationIDCleared() bool {
  16872. _, ok := m.clearedFields[wx.FieldOrganizationID]
  16873. return ok
  16874. }
  16875. // ResetOrganizationID resets all changes to the "organization_id" field.
  16876. func (m *WxMutation) ResetOrganizationID() {
  16877. m.organization_id = nil
  16878. m.addorganization_id = nil
  16879. delete(m.clearedFields, wx.FieldOrganizationID)
  16880. }
  16881. // SetAgentID sets the "agent_id" field.
  16882. func (m *WxMutation) SetAgentID(u uint64) {
  16883. m.agent = &u
  16884. }
  16885. // AgentID returns the value of the "agent_id" field in the mutation.
  16886. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  16887. v := m.agent
  16888. if v == nil {
  16889. return
  16890. }
  16891. return *v, true
  16892. }
  16893. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  16894. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  16895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16896. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  16897. if !m.op.Is(OpUpdateOne) {
  16898. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  16899. }
  16900. if m.id == nil || m.oldValue == nil {
  16901. return v, errors.New("OldAgentID requires an ID field in the mutation")
  16902. }
  16903. oldValue, err := m.oldValue(ctx)
  16904. if err != nil {
  16905. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  16906. }
  16907. return oldValue.AgentID, nil
  16908. }
  16909. // ResetAgentID resets all changes to the "agent_id" field.
  16910. func (m *WxMutation) ResetAgentID() {
  16911. m.agent = nil
  16912. }
  16913. // ClearServer clears the "server" edge to the Server entity.
  16914. func (m *WxMutation) ClearServer() {
  16915. m.clearedserver = true
  16916. m.clearedFields[wx.FieldServerID] = struct{}{}
  16917. }
  16918. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  16919. func (m *WxMutation) ServerCleared() bool {
  16920. return m.ServerIDCleared() || m.clearedserver
  16921. }
  16922. // ServerIDs returns the "server" edge IDs in the mutation.
  16923. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  16924. // ServerID instead. It exists only for internal usage by the builders.
  16925. func (m *WxMutation) ServerIDs() (ids []uint64) {
  16926. if id := m.server; id != nil {
  16927. ids = append(ids, *id)
  16928. }
  16929. return
  16930. }
  16931. // ResetServer resets all changes to the "server" edge.
  16932. func (m *WxMutation) ResetServer() {
  16933. m.server = nil
  16934. m.clearedserver = false
  16935. }
  16936. // ClearAgent clears the "agent" edge to the Agent entity.
  16937. func (m *WxMutation) ClearAgent() {
  16938. m.clearedagent = true
  16939. m.clearedFields[wx.FieldAgentID] = struct{}{}
  16940. }
  16941. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  16942. func (m *WxMutation) AgentCleared() bool {
  16943. return m.clearedagent
  16944. }
  16945. // AgentIDs returns the "agent" edge IDs in the mutation.
  16946. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  16947. // AgentID instead. It exists only for internal usage by the builders.
  16948. func (m *WxMutation) AgentIDs() (ids []uint64) {
  16949. if id := m.agent; id != nil {
  16950. ids = append(ids, *id)
  16951. }
  16952. return
  16953. }
  16954. // ResetAgent resets all changes to the "agent" edge.
  16955. func (m *WxMutation) ResetAgent() {
  16956. m.agent = nil
  16957. m.clearedagent = false
  16958. }
  16959. // Where appends a list predicates to the WxMutation builder.
  16960. func (m *WxMutation) Where(ps ...predicate.Wx) {
  16961. m.predicates = append(m.predicates, ps...)
  16962. }
  16963. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  16964. // users can use type-assertion to append predicates that do not depend on any generated package.
  16965. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  16966. p := make([]predicate.Wx, len(ps))
  16967. for i := range ps {
  16968. p[i] = ps[i]
  16969. }
  16970. m.Where(p...)
  16971. }
  16972. // Op returns the operation name.
  16973. func (m *WxMutation) Op() Op {
  16974. return m.op
  16975. }
  16976. // SetOp allows setting the mutation operation.
  16977. func (m *WxMutation) SetOp(op Op) {
  16978. m.op = op
  16979. }
  16980. // Type returns the node type of this mutation (Wx).
  16981. func (m *WxMutation) Type() string {
  16982. return m.typ
  16983. }
  16984. // Fields returns all fields that were changed during this mutation. Note that in
  16985. // order to get all numeric fields that were incremented/decremented, call
  16986. // AddedFields().
  16987. func (m *WxMutation) Fields() []string {
  16988. fields := make([]string, 0, 15)
  16989. if m.created_at != nil {
  16990. fields = append(fields, wx.FieldCreatedAt)
  16991. }
  16992. if m.updated_at != nil {
  16993. fields = append(fields, wx.FieldUpdatedAt)
  16994. }
  16995. if m.status != nil {
  16996. fields = append(fields, wx.FieldStatus)
  16997. }
  16998. if m.deleted_at != nil {
  16999. fields = append(fields, wx.FieldDeletedAt)
  17000. }
  17001. if m.server != nil {
  17002. fields = append(fields, wx.FieldServerID)
  17003. }
  17004. if m.port != nil {
  17005. fields = append(fields, wx.FieldPort)
  17006. }
  17007. if m.process_id != nil {
  17008. fields = append(fields, wx.FieldProcessID)
  17009. }
  17010. if m.callback != nil {
  17011. fields = append(fields, wx.FieldCallback)
  17012. }
  17013. if m.wxid != nil {
  17014. fields = append(fields, wx.FieldWxid)
  17015. }
  17016. if m.account != nil {
  17017. fields = append(fields, wx.FieldAccount)
  17018. }
  17019. if m.nickname != nil {
  17020. fields = append(fields, wx.FieldNickname)
  17021. }
  17022. if m.tel != nil {
  17023. fields = append(fields, wx.FieldTel)
  17024. }
  17025. if m.head_big != nil {
  17026. fields = append(fields, wx.FieldHeadBig)
  17027. }
  17028. if m.organization_id != nil {
  17029. fields = append(fields, wx.FieldOrganizationID)
  17030. }
  17031. if m.agent != nil {
  17032. fields = append(fields, wx.FieldAgentID)
  17033. }
  17034. return fields
  17035. }
  17036. // Field returns the value of a field with the given name. The second boolean
  17037. // return value indicates that this field was not set, or was not defined in the
  17038. // schema.
  17039. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  17040. switch name {
  17041. case wx.FieldCreatedAt:
  17042. return m.CreatedAt()
  17043. case wx.FieldUpdatedAt:
  17044. return m.UpdatedAt()
  17045. case wx.FieldStatus:
  17046. return m.Status()
  17047. case wx.FieldDeletedAt:
  17048. return m.DeletedAt()
  17049. case wx.FieldServerID:
  17050. return m.ServerID()
  17051. case wx.FieldPort:
  17052. return m.Port()
  17053. case wx.FieldProcessID:
  17054. return m.ProcessID()
  17055. case wx.FieldCallback:
  17056. return m.Callback()
  17057. case wx.FieldWxid:
  17058. return m.Wxid()
  17059. case wx.FieldAccount:
  17060. return m.Account()
  17061. case wx.FieldNickname:
  17062. return m.Nickname()
  17063. case wx.FieldTel:
  17064. return m.Tel()
  17065. case wx.FieldHeadBig:
  17066. return m.HeadBig()
  17067. case wx.FieldOrganizationID:
  17068. return m.OrganizationID()
  17069. case wx.FieldAgentID:
  17070. return m.AgentID()
  17071. }
  17072. return nil, false
  17073. }
  17074. // OldField returns the old value of the field from the database. An error is
  17075. // returned if the mutation operation is not UpdateOne, or the query to the
  17076. // database failed.
  17077. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17078. switch name {
  17079. case wx.FieldCreatedAt:
  17080. return m.OldCreatedAt(ctx)
  17081. case wx.FieldUpdatedAt:
  17082. return m.OldUpdatedAt(ctx)
  17083. case wx.FieldStatus:
  17084. return m.OldStatus(ctx)
  17085. case wx.FieldDeletedAt:
  17086. return m.OldDeletedAt(ctx)
  17087. case wx.FieldServerID:
  17088. return m.OldServerID(ctx)
  17089. case wx.FieldPort:
  17090. return m.OldPort(ctx)
  17091. case wx.FieldProcessID:
  17092. return m.OldProcessID(ctx)
  17093. case wx.FieldCallback:
  17094. return m.OldCallback(ctx)
  17095. case wx.FieldWxid:
  17096. return m.OldWxid(ctx)
  17097. case wx.FieldAccount:
  17098. return m.OldAccount(ctx)
  17099. case wx.FieldNickname:
  17100. return m.OldNickname(ctx)
  17101. case wx.FieldTel:
  17102. return m.OldTel(ctx)
  17103. case wx.FieldHeadBig:
  17104. return m.OldHeadBig(ctx)
  17105. case wx.FieldOrganizationID:
  17106. return m.OldOrganizationID(ctx)
  17107. case wx.FieldAgentID:
  17108. return m.OldAgentID(ctx)
  17109. }
  17110. return nil, fmt.Errorf("unknown Wx field %s", name)
  17111. }
  17112. // SetField sets the value of a field with the given name. It returns an error if
  17113. // the field is not defined in the schema, or if the type mismatched the field
  17114. // type.
  17115. func (m *WxMutation) SetField(name string, value ent.Value) error {
  17116. switch name {
  17117. case wx.FieldCreatedAt:
  17118. v, ok := value.(time.Time)
  17119. if !ok {
  17120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17121. }
  17122. m.SetCreatedAt(v)
  17123. return nil
  17124. case wx.FieldUpdatedAt:
  17125. v, ok := value.(time.Time)
  17126. if !ok {
  17127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17128. }
  17129. m.SetUpdatedAt(v)
  17130. return nil
  17131. case wx.FieldStatus:
  17132. v, ok := value.(uint8)
  17133. if !ok {
  17134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17135. }
  17136. m.SetStatus(v)
  17137. return nil
  17138. case wx.FieldDeletedAt:
  17139. v, ok := value.(time.Time)
  17140. if !ok {
  17141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17142. }
  17143. m.SetDeletedAt(v)
  17144. return nil
  17145. case wx.FieldServerID:
  17146. v, ok := value.(uint64)
  17147. if !ok {
  17148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17149. }
  17150. m.SetServerID(v)
  17151. return nil
  17152. case wx.FieldPort:
  17153. v, ok := value.(string)
  17154. if !ok {
  17155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17156. }
  17157. m.SetPort(v)
  17158. return nil
  17159. case wx.FieldProcessID:
  17160. v, ok := value.(string)
  17161. if !ok {
  17162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17163. }
  17164. m.SetProcessID(v)
  17165. return nil
  17166. case wx.FieldCallback:
  17167. v, ok := value.(string)
  17168. if !ok {
  17169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17170. }
  17171. m.SetCallback(v)
  17172. return nil
  17173. case wx.FieldWxid:
  17174. v, ok := value.(string)
  17175. if !ok {
  17176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17177. }
  17178. m.SetWxid(v)
  17179. return nil
  17180. case wx.FieldAccount:
  17181. v, ok := value.(string)
  17182. if !ok {
  17183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17184. }
  17185. m.SetAccount(v)
  17186. return nil
  17187. case wx.FieldNickname:
  17188. v, ok := value.(string)
  17189. if !ok {
  17190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17191. }
  17192. m.SetNickname(v)
  17193. return nil
  17194. case wx.FieldTel:
  17195. v, ok := value.(string)
  17196. if !ok {
  17197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17198. }
  17199. m.SetTel(v)
  17200. return nil
  17201. case wx.FieldHeadBig:
  17202. v, ok := value.(string)
  17203. if !ok {
  17204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17205. }
  17206. m.SetHeadBig(v)
  17207. return nil
  17208. case wx.FieldOrganizationID:
  17209. v, ok := value.(uint64)
  17210. if !ok {
  17211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17212. }
  17213. m.SetOrganizationID(v)
  17214. return nil
  17215. case wx.FieldAgentID:
  17216. v, ok := value.(uint64)
  17217. if !ok {
  17218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17219. }
  17220. m.SetAgentID(v)
  17221. return nil
  17222. }
  17223. return fmt.Errorf("unknown Wx field %s", name)
  17224. }
  17225. // AddedFields returns all numeric fields that were incremented/decremented during
  17226. // this mutation.
  17227. func (m *WxMutation) AddedFields() []string {
  17228. var fields []string
  17229. if m.addstatus != nil {
  17230. fields = append(fields, wx.FieldStatus)
  17231. }
  17232. if m.addorganization_id != nil {
  17233. fields = append(fields, wx.FieldOrganizationID)
  17234. }
  17235. return fields
  17236. }
  17237. // AddedField returns the numeric value that was incremented/decremented on a field
  17238. // with the given name. The second boolean return value indicates that this field
  17239. // was not set, or was not defined in the schema.
  17240. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  17241. switch name {
  17242. case wx.FieldStatus:
  17243. return m.AddedStatus()
  17244. case wx.FieldOrganizationID:
  17245. return m.AddedOrganizationID()
  17246. }
  17247. return nil, false
  17248. }
  17249. // AddField adds the value to the field with the given name. It returns an error if
  17250. // the field is not defined in the schema, or if the type mismatched the field
  17251. // type.
  17252. func (m *WxMutation) AddField(name string, value ent.Value) error {
  17253. switch name {
  17254. case wx.FieldStatus:
  17255. v, ok := value.(int8)
  17256. if !ok {
  17257. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17258. }
  17259. m.AddStatus(v)
  17260. return nil
  17261. case wx.FieldOrganizationID:
  17262. v, ok := value.(int64)
  17263. if !ok {
  17264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17265. }
  17266. m.AddOrganizationID(v)
  17267. return nil
  17268. }
  17269. return fmt.Errorf("unknown Wx numeric field %s", name)
  17270. }
  17271. // ClearedFields returns all nullable fields that were cleared during this
  17272. // mutation.
  17273. func (m *WxMutation) ClearedFields() []string {
  17274. var fields []string
  17275. if m.FieldCleared(wx.FieldStatus) {
  17276. fields = append(fields, wx.FieldStatus)
  17277. }
  17278. if m.FieldCleared(wx.FieldDeletedAt) {
  17279. fields = append(fields, wx.FieldDeletedAt)
  17280. }
  17281. if m.FieldCleared(wx.FieldServerID) {
  17282. fields = append(fields, wx.FieldServerID)
  17283. }
  17284. if m.FieldCleared(wx.FieldOrganizationID) {
  17285. fields = append(fields, wx.FieldOrganizationID)
  17286. }
  17287. return fields
  17288. }
  17289. // FieldCleared returns a boolean indicating if a field with the given name was
  17290. // cleared in this mutation.
  17291. func (m *WxMutation) FieldCleared(name string) bool {
  17292. _, ok := m.clearedFields[name]
  17293. return ok
  17294. }
  17295. // ClearField clears the value of the field with the given name. It returns an
  17296. // error if the field is not defined in the schema.
  17297. func (m *WxMutation) ClearField(name string) error {
  17298. switch name {
  17299. case wx.FieldStatus:
  17300. m.ClearStatus()
  17301. return nil
  17302. case wx.FieldDeletedAt:
  17303. m.ClearDeletedAt()
  17304. return nil
  17305. case wx.FieldServerID:
  17306. m.ClearServerID()
  17307. return nil
  17308. case wx.FieldOrganizationID:
  17309. m.ClearOrganizationID()
  17310. return nil
  17311. }
  17312. return fmt.Errorf("unknown Wx nullable field %s", name)
  17313. }
  17314. // ResetField resets all changes in the mutation for the field with the given name.
  17315. // It returns an error if the field is not defined in the schema.
  17316. func (m *WxMutation) ResetField(name string) error {
  17317. switch name {
  17318. case wx.FieldCreatedAt:
  17319. m.ResetCreatedAt()
  17320. return nil
  17321. case wx.FieldUpdatedAt:
  17322. m.ResetUpdatedAt()
  17323. return nil
  17324. case wx.FieldStatus:
  17325. m.ResetStatus()
  17326. return nil
  17327. case wx.FieldDeletedAt:
  17328. m.ResetDeletedAt()
  17329. return nil
  17330. case wx.FieldServerID:
  17331. m.ResetServerID()
  17332. return nil
  17333. case wx.FieldPort:
  17334. m.ResetPort()
  17335. return nil
  17336. case wx.FieldProcessID:
  17337. m.ResetProcessID()
  17338. return nil
  17339. case wx.FieldCallback:
  17340. m.ResetCallback()
  17341. return nil
  17342. case wx.FieldWxid:
  17343. m.ResetWxid()
  17344. return nil
  17345. case wx.FieldAccount:
  17346. m.ResetAccount()
  17347. return nil
  17348. case wx.FieldNickname:
  17349. m.ResetNickname()
  17350. return nil
  17351. case wx.FieldTel:
  17352. m.ResetTel()
  17353. return nil
  17354. case wx.FieldHeadBig:
  17355. m.ResetHeadBig()
  17356. return nil
  17357. case wx.FieldOrganizationID:
  17358. m.ResetOrganizationID()
  17359. return nil
  17360. case wx.FieldAgentID:
  17361. m.ResetAgentID()
  17362. return nil
  17363. }
  17364. return fmt.Errorf("unknown Wx field %s", name)
  17365. }
  17366. // AddedEdges returns all edge names that were set/added in this mutation.
  17367. func (m *WxMutation) AddedEdges() []string {
  17368. edges := make([]string, 0, 2)
  17369. if m.server != nil {
  17370. edges = append(edges, wx.EdgeServer)
  17371. }
  17372. if m.agent != nil {
  17373. edges = append(edges, wx.EdgeAgent)
  17374. }
  17375. return edges
  17376. }
  17377. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17378. // name in this mutation.
  17379. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  17380. switch name {
  17381. case wx.EdgeServer:
  17382. if id := m.server; id != nil {
  17383. return []ent.Value{*id}
  17384. }
  17385. case wx.EdgeAgent:
  17386. if id := m.agent; id != nil {
  17387. return []ent.Value{*id}
  17388. }
  17389. }
  17390. return nil
  17391. }
  17392. // RemovedEdges returns all edge names that were removed in this mutation.
  17393. func (m *WxMutation) RemovedEdges() []string {
  17394. edges := make([]string, 0, 2)
  17395. return edges
  17396. }
  17397. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17398. // the given name in this mutation.
  17399. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  17400. return nil
  17401. }
  17402. // ClearedEdges returns all edge names that were cleared in this mutation.
  17403. func (m *WxMutation) ClearedEdges() []string {
  17404. edges := make([]string, 0, 2)
  17405. if m.clearedserver {
  17406. edges = append(edges, wx.EdgeServer)
  17407. }
  17408. if m.clearedagent {
  17409. edges = append(edges, wx.EdgeAgent)
  17410. }
  17411. return edges
  17412. }
  17413. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17414. // was cleared in this mutation.
  17415. func (m *WxMutation) EdgeCleared(name string) bool {
  17416. switch name {
  17417. case wx.EdgeServer:
  17418. return m.clearedserver
  17419. case wx.EdgeAgent:
  17420. return m.clearedagent
  17421. }
  17422. return false
  17423. }
  17424. // ClearEdge clears the value of the edge with the given name. It returns an error
  17425. // if that edge is not defined in the schema.
  17426. func (m *WxMutation) ClearEdge(name string) error {
  17427. switch name {
  17428. case wx.EdgeServer:
  17429. m.ClearServer()
  17430. return nil
  17431. case wx.EdgeAgent:
  17432. m.ClearAgent()
  17433. return nil
  17434. }
  17435. return fmt.Errorf("unknown Wx unique edge %s", name)
  17436. }
  17437. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17438. // It returns an error if the edge is not defined in the schema.
  17439. func (m *WxMutation) ResetEdge(name string) error {
  17440. switch name {
  17441. case wx.EdgeServer:
  17442. m.ResetServer()
  17443. return nil
  17444. case wx.EdgeAgent:
  17445. m.ResetAgent()
  17446. return nil
  17447. }
  17448. return fmt.Errorf("unknown Wx edge %s", name)
  17449. }