mutation.go 581 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806
  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/token"
  25. "wechat-api/ent/tutorial"
  26. "wechat-api/ent/workexperience"
  27. "wechat-api/ent/wx"
  28. "entgo.io/ent"
  29. "entgo.io/ent/dialect/sql"
  30. )
  31. const (
  32. // Operation types.
  33. OpCreate = ent.OpCreate
  34. OpDelete = ent.OpDelete
  35. OpDeleteOne = ent.OpDeleteOne
  36. OpUpdate = ent.OpUpdate
  37. OpUpdateOne = ent.OpUpdateOne
  38. // Node types.
  39. TypeAgent = "Agent"
  40. TypeBatchMsg = "BatchMsg"
  41. TypeContact = "Contact"
  42. TypeEmployee = "Employee"
  43. TypeLabel = "Label"
  44. TypeLabelRelationship = "LabelRelationship"
  45. TypeMessage = "Message"
  46. TypeMessageRecords = "MessageRecords"
  47. TypeMsg = "Msg"
  48. TypeServer = "Server"
  49. TypeSopNode = "SopNode"
  50. TypeSopStage = "SopStage"
  51. TypeSopTask = "SopTask"
  52. TypeToken = "Token"
  53. TypeTutorial = "Tutorial"
  54. TypeWorkExperience = "WorkExperience"
  55. TypeWx = "Wx"
  56. )
  57. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  58. type AgentMutation struct {
  59. config
  60. op Op
  61. typ string
  62. id *uint64
  63. created_at *time.Time
  64. updated_at *time.Time
  65. deleted_at *time.Time
  66. name *string
  67. role *string
  68. status *int
  69. addstatus *int
  70. background *string
  71. examples *string
  72. organization_id *uint64
  73. addorganization_id *int64
  74. clearedFields map[string]struct{}
  75. wx_agent map[uint64]struct{}
  76. removedwx_agent map[uint64]struct{}
  77. clearedwx_agent bool
  78. done bool
  79. oldValue func(context.Context) (*Agent, error)
  80. predicates []predicate.Agent
  81. }
  82. var _ ent.Mutation = (*AgentMutation)(nil)
  83. // agentOption allows management of the mutation configuration using functional options.
  84. type agentOption func(*AgentMutation)
  85. // newAgentMutation creates new mutation for the Agent entity.
  86. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  87. m := &AgentMutation{
  88. config: c,
  89. op: op,
  90. typ: TypeAgent,
  91. clearedFields: make(map[string]struct{}),
  92. }
  93. for _, opt := range opts {
  94. opt(m)
  95. }
  96. return m
  97. }
  98. // withAgentID sets the ID field of the mutation.
  99. func withAgentID(id uint64) agentOption {
  100. return func(m *AgentMutation) {
  101. var (
  102. err error
  103. once sync.Once
  104. value *Agent
  105. )
  106. m.oldValue = func(ctx context.Context) (*Agent, error) {
  107. once.Do(func() {
  108. if m.done {
  109. err = errors.New("querying old values post mutation is not allowed")
  110. } else {
  111. value, err = m.Client().Agent.Get(ctx, id)
  112. }
  113. })
  114. return value, err
  115. }
  116. m.id = &id
  117. }
  118. }
  119. // withAgent sets the old Agent of the mutation.
  120. func withAgent(node *Agent) agentOption {
  121. return func(m *AgentMutation) {
  122. m.oldValue = func(context.Context) (*Agent, error) {
  123. return node, nil
  124. }
  125. m.id = &node.ID
  126. }
  127. }
  128. // Client returns a new `ent.Client` from the mutation. If the mutation was
  129. // executed in a transaction (ent.Tx), a transactional client is returned.
  130. func (m AgentMutation) Client() *Client {
  131. client := &Client{config: m.config}
  132. client.init()
  133. return client
  134. }
  135. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  136. // it returns an error otherwise.
  137. func (m AgentMutation) Tx() (*Tx, error) {
  138. if _, ok := m.driver.(*txDriver); !ok {
  139. return nil, errors.New("ent: mutation is not running in a transaction")
  140. }
  141. tx := &Tx{config: m.config}
  142. tx.init()
  143. return tx, nil
  144. }
  145. // SetID sets the value of the id field. Note that this
  146. // operation is only accepted on creation of Agent entities.
  147. func (m *AgentMutation) SetID(id uint64) {
  148. m.id = &id
  149. }
  150. // ID returns the ID value in the mutation. Note that the ID is only available
  151. // if it was provided to the builder or after it was returned from the database.
  152. func (m *AgentMutation) ID() (id uint64, exists bool) {
  153. if m.id == nil {
  154. return
  155. }
  156. return *m.id, true
  157. }
  158. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  159. // That means, if the mutation is applied within a transaction with an isolation level such
  160. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  161. // or updated by the mutation.
  162. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  163. switch {
  164. case m.op.Is(OpUpdateOne | OpDeleteOne):
  165. id, exists := m.ID()
  166. if exists {
  167. return []uint64{id}, nil
  168. }
  169. fallthrough
  170. case m.op.Is(OpUpdate | OpDelete):
  171. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  172. default:
  173. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  174. }
  175. }
  176. // SetCreatedAt sets the "created_at" field.
  177. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  178. m.created_at = &t
  179. }
  180. // CreatedAt returns the value of the "created_at" field in the mutation.
  181. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  182. v := m.created_at
  183. if v == nil {
  184. return
  185. }
  186. return *v, true
  187. }
  188. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  189. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  191. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  192. if !m.op.Is(OpUpdateOne) {
  193. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  194. }
  195. if m.id == nil || m.oldValue == nil {
  196. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  197. }
  198. oldValue, err := m.oldValue(ctx)
  199. if err != nil {
  200. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  201. }
  202. return oldValue.CreatedAt, nil
  203. }
  204. // ResetCreatedAt resets all changes to the "created_at" field.
  205. func (m *AgentMutation) ResetCreatedAt() {
  206. m.created_at = nil
  207. }
  208. // SetUpdatedAt sets the "updated_at" field.
  209. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  210. m.updated_at = &t
  211. }
  212. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  213. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  214. v := m.updated_at
  215. if v == nil {
  216. return
  217. }
  218. return *v, true
  219. }
  220. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  221. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  223. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  224. if !m.op.Is(OpUpdateOne) {
  225. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  226. }
  227. if m.id == nil || m.oldValue == nil {
  228. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  229. }
  230. oldValue, err := m.oldValue(ctx)
  231. if err != nil {
  232. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  233. }
  234. return oldValue.UpdatedAt, nil
  235. }
  236. // ResetUpdatedAt resets all changes to the "updated_at" field.
  237. func (m *AgentMutation) ResetUpdatedAt() {
  238. m.updated_at = nil
  239. }
  240. // SetDeletedAt sets the "deleted_at" field.
  241. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  242. m.deleted_at = &t
  243. }
  244. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  245. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  246. v := m.deleted_at
  247. if v == nil {
  248. return
  249. }
  250. return *v, true
  251. }
  252. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  253. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  255. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  256. if !m.op.Is(OpUpdateOne) {
  257. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  258. }
  259. if m.id == nil || m.oldValue == nil {
  260. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  261. }
  262. oldValue, err := m.oldValue(ctx)
  263. if err != nil {
  264. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  265. }
  266. return oldValue.DeletedAt, nil
  267. }
  268. // ClearDeletedAt clears the value of the "deleted_at" field.
  269. func (m *AgentMutation) ClearDeletedAt() {
  270. m.deleted_at = nil
  271. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  272. }
  273. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  274. func (m *AgentMutation) DeletedAtCleared() bool {
  275. _, ok := m.clearedFields[agent.FieldDeletedAt]
  276. return ok
  277. }
  278. // ResetDeletedAt resets all changes to the "deleted_at" field.
  279. func (m *AgentMutation) ResetDeletedAt() {
  280. m.deleted_at = nil
  281. delete(m.clearedFields, agent.FieldDeletedAt)
  282. }
  283. // SetName sets the "name" field.
  284. func (m *AgentMutation) SetName(s string) {
  285. m.name = &s
  286. }
  287. // Name returns the value of the "name" field in the mutation.
  288. func (m *AgentMutation) Name() (r string, exists bool) {
  289. v := m.name
  290. if v == nil {
  291. return
  292. }
  293. return *v, true
  294. }
  295. // OldName returns the old "name" field's value of the Agent entity.
  296. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  298. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  299. if !m.op.Is(OpUpdateOne) {
  300. return v, errors.New("OldName is only allowed on UpdateOne operations")
  301. }
  302. if m.id == nil || m.oldValue == nil {
  303. return v, errors.New("OldName requires an ID field in the mutation")
  304. }
  305. oldValue, err := m.oldValue(ctx)
  306. if err != nil {
  307. return v, fmt.Errorf("querying old value for OldName: %w", err)
  308. }
  309. return oldValue.Name, nil
  310. }
  311. // ResetName resets all changes to the "name" field.
  312. func (m *AgentMutation) ResetName() {
  313. m.name = nil
  314. }
  315. // SetRole sets the "role" field.
  316. func (m *AgentMutation) SetRole(s string) {
  317. m.role = &s
  318. }
  319. // Role returns the value of the "role" field in the mutation.
  320. func (m *AgentMutation) Role() (r string, exists bool) {
  321. v := m.role
  322. if v == nil {
  323. return
  324. }
  325. return *v, true
  326. }
  327. // OldRole returns the old "role" field's value of the Agent entity.
  328. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  330. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  331. if !m.op.Is(OpUpdateOne) {
  332. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  333. }
  334. if m.id == nil || m.oldValue == nil {
  335. return v, errors.New("OldRole requires an ID field in the mutation")
  336. }
  337. oldValue, err := m.oldValue(ctx)
  338. if err != nil {
  339. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  340. }
  341. return oldValue.Role, nil
  342. }
  343. // ResetRole resets all changes to the "role" field.
  344. func (m *AgentMutation) ResetRole() {
  345. m.role = nil
  346. }
  347. // SetStatus sets the "status" field.
  348. func (m *AgentMutation) SetStatus(i int) {
  349. m.status = &i
  350. m.addstatus = nil
  351. }
  352. // Status returns the value of the "status" field in the mutation.
  353. func (m *AgentMutation) Status() (r int, exists bool) {
  354. v := m.status
  355. if v == nil {
  356. return
  357. }
  358. return *v, true
  359. }
  360. // OldStatus returns the old "status" field's value of the Agent entity.
  361. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  363. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  364. if !m.op.Is(OpUpdateOne) {
  365. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  366. }
  367. if m.id == nil || m.oldValue == nil {
  368. return v, errors.New("OldStatus requires an ID field in the mutation")
  369. }
  370. oldValue, err := m.oldValue(ctx)
  371. if err != nil {
  372. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  373. }
  374. return oldValue.Status, nil
  375. }
  376. // AddStatus adds i to the "status" field.
  377. func (m *AgentMutation) AddStatus(i int) {
  378. if m.addstatus != nil {
  379. *m.addstatus += i
  380. } else {
  381. m.addstatus = &i
  382. }
  383. }
  384. // AddedStatus returns the value that was added to the "status" field in this mutation.
  385. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  386. v := m.addstatus
  387. if v == nil {
  388. return
  389. }
  390. return *v, true
  391. }
  392. // ClearStatus clears the value of the "status" field.
  393. func (m *AgentMutation) ClearStatus() {
  394. m.status = nil
  395. m.addstatus = nil
  396. m.clearedFields[agent.FieldStatus] = struct{}{}
  397. }
  398. // StatusCleared returns if the "status" field was cleared in this mutation.
  399. func (m *AgentMutation) StatusCleared() bool {
  400. _, ok := m.clearedFields[agent.FieldStatus]
  401. return ok
  402. }
  403. // ResetStatus resets all changes to the "status" field.
  404. func (m *AgentMutation) ResetStatus() {
  405. m.status = nil
  406. m.addstatus = nil
  407. delete(m.clearedFields, agent.FieldStatus)
  408. }
  409. // SetBackground sets the "background" field.
  410. func (m *AgentMutation) SetBackground(s string) {
  411. m.background = &s
  412. }
  413. // Background returns the value of the "background" field in the mutation.
  414. func (m *AgentMutation) Background() (r string, exists bool) {
  415. v := m.background
  416. if v == nil {
  417. return
  418. }
  419. return *v, true
  420. }
  421. // OldBackground returns the old "background" field's value of the Agent entity.
  422. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  424. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  425. if !m.op.Is(OpUpdateOne) {
  426. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  427. }
  428. if m.id == nil || m.oldValue == nil {
  429. return v, errors.New("OldBackground requires an ID field in the mutation")
  430. }
  431. oldValue, err := m.oldValue(ctx)
  432. if err != nil {
  433. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  434. }
  435. return oldValue.Background, nil
  436. }
  437. // ClearBackground clears the value of the "background" field.
  438. func (m *AgentMutation) ClearBackground() {
  439. m.background = nil
  440. m.clearedFields[agent.FieldBackground] = struct{}{}
  441. }
  442. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  443. func (m *AgentMutation) BackgroundCleared() bool {
  444. _, ok := m.clearedFields[agent.FieldBackground]
  445. return ok
  446. }
  447. // ResetBackground resets all changes to the "background" field.
  448. func (m *AgentMutation) ResetBackground() {
  449. m.background = nil
  450. delete(m.clearedFields, agent.FieldBackground)
  451. }
  452. // SetExamples sets the "examples" field.
  453. func (m *AgentMutation) SetExamples(s string) {
  454. m.examples = &s
  455. }
  456. // Examples returns the value of the "examples" field in the mutation.
  457. func (m *AgentMutation) Examples() (r string, exists bool) {
  458. v := m.examples
  459. if v == nil {
  460. return
  461. }
  462. return *v, true
  463. }
  464. // OldExamples returns the old "examples" field's value of the Agent entity.
  465. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  466. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  467. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  468. if !m.op.Is(OpUpdateOne) {
  469. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  470. }
  471. if m.id == nil || m.oldValue == nil {
  472. return v, errors.New("OldExamples requires an ID field in the mutation")
  473. }
  474. oldValue, err := m.oldValue(ctx)
  475. if err != nil {
  476. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  477. }
  478. return oldValue.Examples, nil
  479. }
  480. // ClearExamples clears the value of the "examples" field.
  481. func (m *AgentMutation) ClearExamples() {
  482. m.examples = nil
  483. m.clearedFields[agent.FieldExamples] = struct{}{}
  484. }
  485. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  486. func (m *AgentMutation) ExamplesCleared() bool {
  487. _, ok := m.clearedFields[agent.FieldExamples]
  488. return ok
  489. }
  490. // ResetExamples resets all changes to the "examples" field.
  491. func (m *AgentMutation) ResetExamples() {
  492. m.examples = nil
  493. delete(m.clearedFields, agent.FieldExamples)
  494. }
  495. // SetOrganizationID sets the "organization_id" field.
  496. func (m *AgentMutation) SetOrganizationID(u uint64) {
  497. m.organization_id = &u
  498. m.addorganization_id = nil
  499. }
  500. // OrganizationID returns the value of the "organization_id" field in the mutation.
  501. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  502. v := m.organization_id
  503. if v == nil {
  504. return
  505. }
  506. return *v, true
  507. }
  508. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  509. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  511. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  512. if !m.op.Is(OpUpdateOne) {
  513. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  514. }
  515. if m.id == nil || m.oldValue == nil {
  516. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  517. }
  518. oldValue, err := m.oldValue(ctx)
  519. if err != nil {
  520. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  521. }
  522. return oldValue.OrganizationID, nil
  523. }
  524. // AddOrganizationID adds u to the "organization_id" field.
  525. func (m *AgentMutation) AddOrganizationID(u int64) {
  526. if m.addorganization_id != nil {
  527. *m.addorganization_id += u
  528. } else {
  529. m.addorganization_id = &u
  530. }
  531. }
  532. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  533. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  534. v := m.addorganization_id
  535. if v == nil {
  536. return
  537. }
  538. return *v, true
  539. }
  540. // ResetOrganizationID resets all changes to the "organization_id" field.
  541. func (m *AgentMutation) ResetOrganizationID() {
  542. m.organization_id = nil
  543. m.addorganization_id = nil
  544. }
  545. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  546. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  547. if m.wx_agent == nil {
  548. m.wx_agent = make(map[uint64]struct{})
  549. }
  550. for i := range ids {
  551. m.wx_agent[ids[i]] = struct{}{}
  552. }
  553. }
  554. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  555. func (m *AgentMutation) ClearWxAgent() {
  556. m.clearedwx_agent = true
  557. }
  558. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  559. func (m *AgentMutation) WxAgentCleared() bool {
  560. return m.clearedwx_agent
  561. }
  562. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  563. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  564. if m.removedwx_agent == nil {
  565. m.removedwx_agent = make(map[uint64]struct{})
  566. }
  567. for i := range ids {
  568. delete(m.wx_agent, ids[i])
  569. m.removedwx_agent[ids[i]] = struct{}{}
  570. }
  571. }
  572. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  573. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  574. for id := range m.removedwx_agent {
  575. ids = append(ids, id)
  576. }
  577. return
  578. }
  579. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  580. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  581. for id := range m.wx_agent {
  582. ids = append(ids, id)
  583. }
  584. return
  585. }
  586. // ResetWxAgent resets all changes to the "wx_agent" edge.
  587. func (m *AgentMutation) ResetWxAgent() {
  588. m.wx_agent = nil
  589. m.clearedwx_agent = false
  590. m.removedwx_agent = nil
  591. }
  592. // Where appends a list predicates to the AgentMutation builder.
  593. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  594. m.predicates = append(m.predicates, ps...)
  595. }
  596. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  597. // users can use type-assertion to append predicates that do not depend on any generated package.
  598. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  599. p := make([]predicate.Agent, len(ps))
  600. for i := range ps {
  601. p[i] = ps[i]
  602. }
  603. m.Where(p...)
  604. }
  605. // Op returns the operation name.
  606. func (m *AgentMutation) Op() Op {
  607. return m.op
  608. }
  609. // SetOp allows setting the mutation operation.
  610. func (m *AgentMutation) SetOp(op Op) {
  611. m.op = op
  612. }
  613. // Type returns the node type of this mutation (Agent).
  614. func (m *AgentMutation) Type() string {
  615. return m.typ
  616. }
  617. // Fields returns all fields that were changed during this mutation. Note that in
  618. // order to get all numeric fields that were incremented/decremented, call
  619. // AddedFields().
  620. func (m *AgentMutation) Fields() []string {
  621. fields := make([]string, 0, 9)
  622. if m.created_at != nil {
  623. fields = append(fields, agent.FieldCreatedAt)
  624. }
  625. if m.updated_at != nil {
  626. fields = append(fields, agent.FieldUpdatedAt)
  627. }
  628. if m.deleted_at != nil {
  629. fields = append(fields, agent.FieldDeletedAt)
  630. }
  631. if m.name != nil {
  632. fields = append(fields, agent.FieldName)
  633. }
  634. if m.role != nil {
  635. fields = append(fields, agent.FieldRole)
  636. }
  637. if m.status != nil {
  638. fields = append(fields, agent.FieldStatus)
  639. }
  640. if m.background != nil {
  641. fields = append(fields, agent.FieldBackground)
  642. }
  643. if m.examples != nil {
  644. fields = append(fields, agent.FieldExamples)
  645. }
  646. if m.organization_id != nil {
  647. fields = append(fields, agent.FieldOrganizationID)
  648. }
  649. return fields
  650. }
  651. // Field returns the value of a field with the given name. The second boolean
  652. // return value indicates that this field was not set, or was not defined in the
  653. // schema.
  654. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  655. switch name {
  656. case agent.FieldCreatedAt:
  657. return m.CreatedAt()
  658. case agent.FieldUpdatedAt:
  659. return m.UpdatedAt()
  660. case agent.FieldDeletedAt:
  661. return m.DeletedAt()
  662. case agent.FieldName:
  663. return m.Name()
  664. case agent.FieldRole:
  665. return m.Role()
  666. case agent.FieldStatus:
  667. return m.Status()
  668. case agent.FieldBackground:
  669. return m.Background()
  670. case agent.FieldExamples:
  671. return m.Examples()
  672. case agent.FieldOrganizationID:
  673. return m.OrganizationID()
  674. }
  675. return nil, false
  676. }
  677. // OldField returns the old value of the field from the database. An error is
  678. // returned if the mutation operation is not UpdateOne, or the query to the
  679. // database failed.
  680. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  681. switch name {
  682. case agent.FieldCreatedAt:
  683. return m.OldCreatedAt(ctx)
  684. case agent.FieldUpdatedAt:
  685. return m.OldUpdatedAt(ctx)
  686. case agent.FieldDeletedAt:
  687. return m.OldDeletedAt(ctx)
  688. case agent.FieldName:
  689. return m.OldName(ctx)
  690. case agent.FieldRole:
  691. return m.OldRole(ctx)
  692. case agent.FieldStatus:
  693. return m.OldStatus(ctx)
  694. case agent.FieldBackground:
  695. return m.OldBackground(ctx)
  696. case agent.FieldExamples:
  697. return m.OldExamples(ctx)
  698. case agent.FieldOrganizationID:
  699. return m.OldOrganizationID(ctx)
  700. }
  701. return nil, fmt.Errorf("unknown Agent field %s", name)
  702. }
  703. // SetField sets the value of a field with the given name. It returns an error if
  704. // the field is not defined in the schema, or if the type mismatched the field
  705. // type.
  706. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  707. switch name {
  708. case agent.FieldCreatedAt:
  709. v, ok := value.(time.Time)
  710. if !ok {
  711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  712. }
  713. m.SetCreatedAt(v)
  714. return nil
  715. case agent.FieldUpdatedAt:
  716. v, ok := value.(time.Time)
  717. if !ok {
  718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  719. }
  720. m.SetUpdatedAt(v)
  721. return nil
  722. case agent.FieldDeletedAt:
  723. v, ok := value.(time.Time)
  724. if !ok {
  725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  726. }
  727. m.SetDeletedAt(v)
  728. return nil
  729. case agent.FieldName:
  730. v, ok := value.(string)
  731. if !ok {
  732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  733. }
  734. m.SetName(v)
  735. return nil
  736. case agent.FieldRole:
  737. v, ok := value.(string)
  738. if !ok {
  739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  740. }
  741. m.SetRole(v)
  742. return nil
  743. case agent.FieldStatus:
  744. v, ok := value.(int)
  745. if !ok {
  746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  747. }
  748. m.SetStatus(v)
  749. return nil
  750. case agent.FieldBackground:
  751. v, ok := value.(string)
  752. if !ok {
  753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  754. }
  755. m.SetBackground(v)
  756. return nil
  757. case agent.FieldExamples:
  758. v, ok := value.(string)
  759. if !ok {
  760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  761. }
  762. m.SetExamples(v)
  763. return nil
  764. case agent.FieldOrganizationID:
  765. v, ok := value.(uint64)
  766. if !ok {
  767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  768. }
  769. m.SetOrganizationID(v)
  770. return nil
  771. }
  772. return fmt.Errorf("unknown Agent field %s", name)
  773. }
  774. // AddedFields returns all numeric fields that were incremented/decremented during
  775. // this mutation.
  776. func (m *AgentMutation) AddedFields() []string {
  777. var fields []string
  778. if m.addstatus != nil {
  779. fields = append(fields, agent.FieldStatus)
  780. }
  781. if m.addorganization_id != nil {
  782. fields = append(fields, agent.FieldOrganizationID)
  783. }
  784. return fields
  785. }
  786. // AddedField returns the numeric value that was incremented/decremented on a field
  787. // with the given name. The second boolean return value indicates that this field
  788. // was not set, or was not defined in the schema.
  789. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  790. switch name {
  791. case agent.FieldStatus:
  792. return m.AddedStatus()
  793. case agent.FieldOrganizationID:
  794. return m.AddedOrganizationID()
  795. }
  796. return nil, false
  797. }
  798. // AddField adds the value to the field with the given name. It returns an error if
  799. // the field is not defined in the schema, or if the type mismatched the field
  800. // type.
  801. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  802. switch name {
  803. case agent.FieldStatus:
  804. v, ok := value.(int)
  805. if !ok {
  806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  807. }
  808. m.AddStatus(v)
  809. return nil
  810. case agent.FieldOrganizationID:
  811. v, ok := value.(int64)
  812. if !ok {
  813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  814. }
  815. m.AddOrganizationID(v)
  816. return nil
  817. }
  818. return fmt.Errorf("unknown Agent numeric field %s", name)
  819. }
  820. // ClearedFields returns all nullable fields that were cleared during this
  821. // mutation.
  822. func (m *AgentMutation) ClearedFields() []string {
  823. var fields []string
  824. if m.FieldCleared(agent.FieldDeletedAt) {
  825. fields = append(fields, agent.FieldDeletedAt)
  826. }
  827. if m.FieldCleared(agent.FieldStatus) {
  828. fields = append(fields, agent.FieldStatus)
  829. }
  830. if m.FieldCleared(agent.FieldBackground) {
  831. fields = append(fields, agent.FieldBackground)
  832. }
  833. if m.FieldCleared(agent.FieldExamples) {
  834. fields = append(fields, agent.FieldExamples)
  835. }
  836. return fields
  837. }
  838. // FieldCleared returns a boolean indicating if a field with the given name was
  839. // cleared in this mutation.
  840. func (m *AgentMutation) FieldCleared(name string) bool {
  841. _, ok := m.clearedFields[name]
  842. return ok
  843. }
  844. // ClearField clears the value of the field with the given name. It returns an
  845. // error if the field is not defined in the schema.
  846. func (m *AgentMutation) ClearField(name string) error {
  847. switch name {
  848. case agent.FieldDeletedAt:
  849. m.ClearDeletedAt()
  850. return nil
  851. case agent.FieldStatus:
  852. m.ClearStatus()
  853. return nil
  854. case agent.FieldBackground:
  855. m.ClearBackground()
  856. return nil
  857. case agent.FieldExamples:
  858. m.ClearExamples()
  859. return nil
  860. }
  861. return fmt.Errorf("unknown Agent nullable field %s", name)
  862. }
  863. // ResetField resets all changes in the mutation for the field with the given name.
  864. // It returns an error if the field is not defined in the schema.
  865. func (m *AgentMutation) ResetField(name string) error {
  866. switch name {
  867. case agent.FieldCreatedAt:
  868. m.ResetCreatedAt()
  869. return nil
  870. case agent.FieldUpdatedAt:
  871. m.ResetUpdatedAt()
  872. return nil
  873. case agent.FieldDeletedAt:
  874. m.ResetDeletedAt()
  875. return nil
  876. case agent.FieldName:
  877. m.ResetName()
  878. return nil
  879. case agent.FieldRole:
  880. m.ResetRole()
  881. return nil
  882. case agent.FieldStatus:
  883. m.ResetStatus()
  884. return nil
  885. case agent.FieldBackground:
  886. m.ResetBackground()
  887. return nil
  888. case agent.FieldExamples:
  889. m.ResetExamples()
  890. return nil
  891. case agent.FieldOrganizationID:
  892. m.ResetOrganizationID()
  893. return nil
  894. }
  895. return fmt.Errorf("unknown Agent field %s", name)
  896. }
  897. // AddedEdges returns all edge names that were set/added in this mutation.
  898. func (m *AgentMutation) AddedEdges() []string {
  899. edges := make([]string, 0, 1)
  900. if m.wx_agent != nil {
  901. edges = append(edges, agent.EdgeWxAgent)
  902. }
  903. return edges
  904. }
  905. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  906. // name in this mutation.
  907. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  908. switch name {
  909. case agent.EdgeWxAgent:
  910. ids := make([]ent.Value, 0, len(m.wx_agent))
  911. for id := range m.wx_agent {
  912. ids = append(ids, id)
  913. }
  914. return ids
  915. }
  916. return nil
  917. }
  918. // RemovedEdges returns all edge names that were removed in this mutation.
  919. func (m *AgentMutation) RemovedEdges() []string {
  920. edges := make([]string, 0, 1)
  921. if m.removedwx_agent != nil {
  922. edges = append(edges, agent.EdgeWxAgent)
  923. }
  924. return edges
  925. }
  926. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  927. // the given name in this mutation.
  928. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  929. switch name {
  930. case agent.EdgeWxAgent:
  931. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  932. for id := range m.removedwx_agent {
  933. ids = append(ids, id)
  934. }
  935. return ids
  936. }
  937. return nil
  938. }
  939. // ClearedEdges returns all edge names that were cleared in this mutation.
  940. func (m *AgentMutation) ClearedEdges() []string {
  941. edges := make([]string, 0, 1)
  942. if m.clearedwx_agent {
  943. edges = append(edges, agent.EdgeWxAgent)
  944. }
  945. return edges
  946. }
  947. // EdgeCleared returns a boolean which indicates if the edge with the given name
  948. // was cleared in this mutation.
  949. func (m *AgentMutation) EdgeCleared(name string) bool {
  950. switch name {
  951. case agent.EdgeWxAgent:
  952. return m.clearedwx_agent
  953. }
  954. return false
  955. }
  956. // ClearEdge clears the value of the edge with the given name. It returns an error
  957. // if that edge is not defined in the schema.
  958. func (m *AgentMutation) ClearEdge(name string) error {
  959. switch name {
  960. }
  961. return fmt.Errorf("unknown Agent unique edge %s", name)
  962. }
  963. // ResetEdge resets all changes to the edge with the given name in this mutation.
  964. // It returns an error if the edge is not defined in the schema.
  965. func (m *AgentMutation) ResetEdge(name string) error {
  966. switch name {
  967. case agent.EdgeWxAgent:
  968. m.ResetWxAgent()
  969. return nil
  970. }
  971. return fmt.Errorf("unknown Agent edge %s", name)
  972. }
  973. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  974. type BatchMsgMutation struct {
  975. config
  976. op Op
  977. typ string
  978. id *uint64
  979. created_at *time.Time
  980. updated_at *time.Time
  981. deleted_at *time.Time
  982. status *uint8
  983. addstatus *int8
  984. batch_no *string
  985. task_name *string
  986. fromwxid *string
  987. msg *string
  988. tag *string
  989. total *int32
  990. addtotal *int32
  991. success *int32
  992. addsuccess *int32
  993. fail *int32
  994. addfail *int32
  995. start_time *time.Time
  996. stop_time *time.Time
  997. _type *int32
  998. add_type *int32
  999. organization_id *uint64
  1000. addorganization_id *int64
  1001. clearedFields map[string]struct{}
  1002. done bool
  1003. oldValue func(context.Context) (*BatchMsg, error)
  1004. predicates []predicate.BatchMsg
  1005. }
  1006. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  1007. // batchmsgOption allows management of the mutation configuration using functional options.
  1008. type batchmsgOption func(*BatchMsgMutation)
  1009. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  1010. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  1011. m := &BatchMsgMutation{
  1012. config: c,
  1013. op: op,
  1014. typ: TypeBatchMsg,
  1015. clearedFields: make(map[string]struct{}),
  1016. }
  1017. for _, opt := range opts {
  1018. opt(m)
  1019. }
  1020. return m
  1021. }
  1022. // withBatchMsgID sets the ID field of the mutation.
  1023. func withBatchMsgID(id uint64) batchmsgOption {
  1024. return func(m *BatchMsgMutation) {
  1025. var (
  1026. err error
  1027. once sync.Once
  1028. value *BatchMsg
  1029. )
  1030. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  1031. once.Do(func() {
  1032. if m.done {
  1033. err = errors.New("querying old values post mutation is not allowed")
  1034. } else {
  1035. value, err = m.Client().BatchMsg.Get(ctx, id)
  1036. }
  1037. })
  1038. return value, err
  1039. }
  1040. m.id = &id
  1041. }
  1042. }
  1043. // withBatchMsg sets the old BatchMsg of the mutation.
  1044. func withBatchMsg(node *BatchMsg) batchmsgOption {
  1045. return func(m *BatchMsgMutation) {
  1046. m.oldValue = func(context.Context) (*BatchMsg, error) {
  1047. return node, nil
  1048. }
  1049. m.id = &node.ID
  1050. }
  1051. }
  1052. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1053. // executed in a transaction (ent.Tx), a transactional client is returned.
  1054. func (m BatchMsgMutation) Client() *Client {
  1055. client := &Client{config: m.config}
  1056. client.init()
  1057. return client
  1058. }
  1059. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1060. // it returns an error otherwise.
  1061. func (m BatchMsgMutation) Tx() (*Tx, error) {
  1062. if _, ok := m.driver.(*txDriver); !ok {
  1063. return nil, errors.New("ent: mutation is not running in a transaction")
  1064. }
  1065. tx := &Tx{config: m.config}
  1066. tx.init()
  1067. return tx, nil
  1068. }
  1069. // SetID sets the value of the id field. Note that this
  1070. // operation is only accepted on creation of BatchMsg entities.
  1071. func (m *BatchMsgMutation) SetID(id uint64) {
  1072. m.id = &id
  1073. }
  1074. // ID returns the ID value in the mutation. Note that the ID is only available
  1075. // if it was provided to the builder or after it was returned from the database.
  1076. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  1077. if m.id == nil {
  1078. return
  1079. }
  1080. return *m.id, true
  1081. }
  1082. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1083. // That means, if the mutation is applied within a transaction with an isolation level such
  1084. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1085. // or updated by the mutation.
  1086. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  1087. switch {
  1088. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1089. id, exists := m.ID()
  1090. if exists {
  1091. return []uint64{id}, nil
  1092. }
  1093. fallthrough
  1094. case m.op.Is(OpUpdate | OpDelete):
  1095. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  1096. default:
  1097. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1098. }
  1099. }
  1100. // SetCreatedAt sets the "created_at" field.
  1101. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  1102. m.created_at = &t
  1103. }
  1104. // CreatedAt returns the value of the "created_at" field in the mutation.
  1105. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  1106. v := m.created_at
  1107. if v == nil {
  1108. return
  1109. }
  1110. return *v, true
  1111. }
  1112. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  1113. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1114. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1115. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  1116. if !m.op.Is(OpUpdateOne) {
  1117. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  1118. }
  1119. if m.id == nil || m.oldValue == nil {
  1120. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  1121. }
  1122. oldValue, err := m.oldValue(ctx)
  1123. if err != nil {
  1124. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  1125. }
  1126. return oldValue.CreatedAt, nil
  1127. }
  1128. // ResetCreatedAt resets all changes to the "created_at" field.
  1129. func (m *BatchMsgMutation) ResetCreatedAt() {
  1130. m.created_at = nil
  1131. }
  1132. // SetUpdatedAt sets the "updated_at" field.
  1133. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  1134. m.updated_at = &t
  1135. }
  1136. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  1137. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  1138. v := m.updated_at
  1139. if v == nil {
  1140. return
  1141. }
  1142. return *v, true
  1143. }
  1144. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  1145. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1147. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  1148. if !m.op.Is(OpUpdateOne) {
  1149. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  1150. }
  1151. if m.id == nil || m.oldValue == nil {
  1152. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  1153. }
  1154. oldValue, err := m.oldValue(ctx)
  1155. if err != nil {
  1156. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  1157. }
  1158. return oldValue.UpdatedAt, nil
  1159. }
  1160. // ResetUpdatedAt resets all changes to the "updated_at" field.
  1161. func (m *BatchMsgMutation) ResetUpdatedAt() {
  1162. m.updated_at = nil
  1163. }
  1164. // SetDeletedAt sets the "deleted_at" field.
  1165. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  1166. m.deleted_at = &t
  1167. }
  1168. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  1169. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  1170. v := m.deleted_at
  1171. if v == nil {
  1172. return
  1173. }
  1174. return *v, true
  1175. }
  1176. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  1177. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1178. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1179. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  1180. if !m.op.Is(OpUpdateOne) {
  1181. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  1182. }
  1183. if m.id == nil || m.oldValue == nil {
  1184. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  1185. }
  1186. oldValue, err := m.oldValue(ctx)
  1187. if err != nil {
  1188. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  1189. }
  1190. return oldValue.DeletedAt, nil
  1191. }
  1192. // ClearDeletedAt clears the value of the "deleted_at" field.
  1193. func (m *BatchMsgMutation) ClearDeletedAt() {
  1194. m.deleted_at = nil
  1195. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  1196. }
  1197. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  1198. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  1199. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  1200. return ok
  1201. }
  1202. // ResetDeletedAt resets all changes to the "deleted_at" field.
  1203. func (m *BatchMsgMutation) ResetDeletedAt() {
  1204. m.deleted_at = nil
  1205. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  1206. }
  1207. // SetStatus sets the "status" field.
  1208. func (m *BatchMsgMutation) SetStatus(u uint8) {
  1209. m.status = &u
  1210. m.addstatus = nil
  1211. }
  1212. // Status returns the value of the "status" field in the mutation.
  1213. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  1214. v := m.status
  1215. if v == nil {
  1216. return
  1217. }
  1218. return *v, true
  1219. }
  1220. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  1221. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1223. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  1224. if !m.op.Is(OpUpdateOne) {
  1225. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  1226. }
  1227. if m.id == nil || m.oldValue == nil {
  1228. return v, errors.New("OldStatus requires an ID field in the mutation")
  1229. }
  1230. oldValue, err := m.oldValue(ctx)
  1231. if err != nil {
  1232. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  1233. }
  1234. return oldValue.Status, nil
  1235. }
  1236. // AddStatus adds u to the "status" field.
  1237. func (m *BatchMsgMutation) AddStatus(u int8) {
  1238. if m.addstatus != nil {
  1239. *m.addstatus += u
  1240. } else {
  1241. m.addstatus = &u
  1242. }
  1243. }
  1244. // AddedStatus returns the value that was added to the "status" field in this mutation.
  1245. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  1246. v := m.addstatus
  1247. if v == nil {
  1248. return
  1249. }
  1250. return *v, true
  1251. }
  1252. // ClearStatus clears the value of the "status" field.
  1253. func (m *BatchMsgMutation) ClearStatus() {
  1254. m.status = nil
  1255. m.addstatus = nil
  1256. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  1257. }
  1258. // StatusCleared returns if the "status" field was cleared in this mutation.
  1259. func (m *BatchMsgMutation) StatusCleared() bool {
  1260. _, ok := m.clearedFields[batchmsg.FieldStatus]
  1261. return ok
  1262. }
  1263. // ResetStatus resets all changes to the "status" field.
  1264. func (m *BatchMsgMutation) ResetStatus() {
  1265. m.status = nil
  1266. m.addstatus = nil
  1267. delete(m.clearedFields, batchmsg.FieldStatus)
  1268. }
  1269. // SetBatchNo sets the "batch_no" field.
  1270. func (m *BatchMsgMutation) SetBatchNo(s string) {
  1271. m.batch_no = &s
  1272. }
  1273. // BatchNo returns the value of the "batch_no" field in the mutation.
  1274. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  1275. v := m.batch_no
  1276. if v == nil {
  1277. return
  1278. }
  1279. return *v, true
  1280. }
  1281. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  1282. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1284. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  1285. if !m.op.Is(OpUpdateOne) {
  1286. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  1287. }
  1288. if m.id == nil || m.oldValue == nil {
  1289. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  1290. }
  1291. oldValue, err := m.oldValue(ctx)
  1292. if err != nil {
  1293. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  1294. }
  1295. return oldValue.BatchNo, nil
  1296. }
  1297. // ClearBatchNo clears the value of the "batch_no" field.
  1298. func (m *BatchMsgMutation) ClearBatchNo() {
  1299. m.batch_no = nil
  1300. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  1301. }
  1302. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  1303. func (m *BatchMsgMutation) BatchNoCleared() bool {
  1304. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  1305. return ok
  1306. }
  1307. // ResetBatchNo resets all changes to the "batch_no" field.
  1308. func (m *BatchMsgMutation) ResetBatchNo() {
  1309. m.batch_no = nil
  1310. delete(m.clearedFields, batchmsg.FieldBatchNo)
  1311. }
  1312. // SetTaskName sets the "task_name" field.
  1313. func (m *BatchMsgMutation) SetTaskName(s string) {
  1314. m.task_name = &s
  1315. }
  1316. // TaskName returns the value of the "task_name" field in the mutation.
  1317. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  1318. v := m.task_name
  1319. if v == nil {
  1320. return
  1321. }
  1322. return *v, true
  1323. }
  1324. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  1325. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1327. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  1328. if !m.op.Is(OpUpdateOne) {
  1329. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  1330. }
  1331. if m.id == nil || m.oldValue == nil {
  1332. return v, errors.New("OldTaskName requires an ID field in the mutation")
  1333. }
  1334. oldValue, err := m.oldValue(ctx)
  1335. if err != nil {
  1336. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  1337. }
  1338. return oldValue.TaskName, nil
  1339. }
  1340. // ClearTaskName clears the value of the "task_name" field.
  1341. func (m *BatchMsgMutation) ClearTaskName() {
  1342. m.task_name = nil
  1343. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  1344. }
  1345. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  1346. func (m *BatchMsgMutation) TaskNameCleared() bool {
  1347. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  1348. return ok
  1349. }
  1350. // ResetTaskName resets all changes to the "task_name" field.
  1351. func (m *BatchMsgMutation) ResetTaskName() {
  1352. m.task_name = nil
  1353. delete(m.clearedFields, batchmsg.FieldTaskName)
  1354. }
  1355. // SetFromwxid sets the "fromwxid" field.
  1356. func (m *BatchMsgMutation) SetFromwxid(s string) {
  1357. m.fromwxid = &s
  1358. }
  1359. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  1360. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  1361. v := m.fromwxid
  1362. if v == nil {
  1363. return
  1364. }
  1365. return *v, true
  1366. }
  1367. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  1368. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1370. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  1371. if !m.op.Is(OpUpdateOne) {
  1372. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  1373. }
  1374. if m.id == nil || m.oldValue == nil {
  1375. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  1376. }
  1377. oldValue, err := m.oldValue(ctx)
  1378. if err != nil {
  1379. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  1380. }
  1381. return oldValue.Fromwxid, nil
  1382. }
  1383. // ClearFromwxid clears the value of the "fromwxid" field.
  1384. func (m *BatchMsgMutation) ClearFromwxid() {
  1385. m.fromwxid = nil
  1386. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  1387. }
  1388. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  1389. func (m *BatchMsgMutation) FromwxidCleared() bool {
  1390. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  1391. return ok
  1392. }
  1393. // ResetFromwxid resets all changes to the "fromwxid" field.
  1394. func (m *BatchMsgMutation) ResetFromwxid() {
  1395. m.fromwxid = nil
  1396. delete(m.clearedFields, batchmsg.FieldFromwxid)
  1397. }
  1398. // SetMsg sets the "msg" field.
  1399. func (m *BatchMsgMutation) SetMsg(s string) {
  1400. m.msg = &s
  1401. }
  1402. // Msg returns the value of the "msg" field in the mutation.
  1403. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  1404. v := m.msg
  1405. if v == nil {
  1406. return
  1407. }
  1408. return *v, true
  1409. }
  1410. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  1411. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1413. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  1414. if !m.op.Is(OpUpdateOne) {
  1415. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  1416. }
  1417. if m.id == nil || m.oldValue == nil {
  1418. return v, errors.New("OldMsg requires an ID field in the mutation")
  1419. }
  1420. oldValue, err := m.oldValue(ctx)
  1421. if err != nil {
  1422. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  1423. }
  1424. return oldValue.Msg, nil
  1425. }
  1426. // ClearMsg clears the value of the "msg" field.
  1427. func (m *BatchMsgMutation) ClearMsg() {
  1428. m.msg = nil
  1429. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  1430. }
  1431. // MsgCleared returns if the "msg" field was cleared in this mutation.
  1432. func (m *BatchMsgMutation) MsgCleared() bool {
  1433. _, ok := m.clearedFields[batchmsg.FieldMsg]
  1434. return ok
  1435. }
  1436. // ResetMsg resets all changes to the "msg" field.
  1437. func (m *BatchMsgMutation) ResetMsg() {
  1438. m.msg = nil
  1439. delete(m.clearedFields, batchmsg.FieldMsg)
  1440. }
  1441. // SetTag sets the "tag" field.
  1442. func (m *BatchMsgMutation) SetTag(s string) {
  1443. m.tag = &s
  1444. }
  1445. // Tag returns the value of the "tag" field in the mutation.
  1446. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  1447. v := m.tag
  1448. if v == nil {
  1449. return
  1450. }
  1451. return *v, true
  1452. }
  1453. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  1454. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1456. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  1457. if !m.op.Is(OpUpdateOne) {
  1458. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  1459. }
  1460. if m.id == nil || m.oldValue == nil {
  1461. return v, errors.New("OldTag requires an ID field in the mutation")
  1462. }
  1463. oldValue, err := m.oldValue(ctx)
  1464. if err != nil {
  1465. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  1466. }
  1467. return oldValue.Tag, nil
  1468. }
  1469. // ClearTag clears the value of the "tag" field.
  1470. func (m *BatchMsgMutation) ClearTag() {
  1471. m.tag = nil
  1472. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  1473. }
  1474. // TagCleared returns if the "tag" field was cleared in this mutation.
  1475. func (m *BatchMsgMutation) TagCleared() bool {
  1476. _, ok := m.clearedFields[batchmsg.FieldTag]
  1477. return ok
  1478. }
  1479. // ResetTag resets all changes to the "tag" field.
  1480. func (m *BatchMsgMutation) ResetTag() {
  1481. m.tag = nil
  1482. delete(m.clearedFields, batchmsg.FieldTag)
  1483. }
  1484. // SetTotal sets the "total" field.
  1485. func (m *BatchMsgMutation) SetTotal(i int32) {
  1486. m.total = &i
  1487. m.addtotal = nil
  1488. }
  1489. // Total returns the value of the "total" field in the mutation.
  1490. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  1491. v := m.total
  1492. if v == nil {
  1493. return
  1494. }
  1495. return *v, true
  1496. }
  1497. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  1498. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1499. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1500. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  1501. if !m.op.Is(OpUpdateOne) {
  1502. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  1503. }
  1504. if m.id == nil || m.oldValue == nil {
  1505. return v, errors.New("OldTotal requires an ID field in the mutation")
  1506. }
  1507. oldValue, err := m.oldValue(ctx)
  1508. if err != nil {
  1509. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  1510. }
  1511. return oldValue.Total, nil
  1512. }
  1513. // AddTotal adds i to the "total" field.
  1514. func (m *BatchMsgMutation) AddTotal(i int32) {
  1515. if m.addtotal != nil {
  1516. *m.addtotal += i
  1517. } else {
  1518. m.addtotal = &i
  1519. }
  1520. }
  1521. // AddedTotal returns the value that was added to the "total" field in this mutation.
  1522. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  1523. v := m.addtotal
  1524. if v == nil {
  1525. return
  1526. }
  1527. return *v, true
  1528. }
  1529. // ClearTotal clears the value of the "total" field.
  1530. func (m *BatchMsgMutation) ClearTotal() {
  1531. m.total = nil
  1532. m.addtotal = nil
  1533. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  1534. }
  1535. // TotalCleared returns if the "total" field was cleared in this mutation.
  1536. func (m *BatchMsgMutation) TotalCleared() bool {
  1537. _, ok := m.clearedFields[batchmsg.FieldTotal]
  1538. return ok
  1539. }
  1540. // ResetTotal resets all changes to the "total" field.
  1541. func (m *BatchMsgMutation) ResetTotal() {
  1542. m.total = nil
  1543. m.addtotal = nil
  1544. delete(m.clearedFields, batchmsg.FieldTotal)
  1545. }
  1546. // SetSuccess sets the "success" field.
  1547. func (m *BatchMsgMutation) SetSuccess(i int32) {
  1548. m.success = &i
  1549. m.addsuccess = nil
  1550. }
  1551. // Success returns the value of the "success" field in the mutation.
  1552. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  1553. v := m.success
  1554. if v == nil {
  1555. return
  1556. }
  1557. return *v, true
  1558. }
  1559. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  1560. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1562. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  1563. if !m.op.Is(OpUpdateOne) {
  1564. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  1565. }
  1566. if m.id == nil || m.oldValue == nil {
  1567. return v, errors.New("OldSuccess requires an ID field in the mutation")
  1568. }
  1569. oldValue, err := m.oldValue(ctx)
  1570. if err != nil {
  1571. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  1572. }
  1573. return oldValue.Success, nil
  1574. }
  1575. // AddSuccess adds i to the "success" field.
  1576. func (m *BatchMsgMutation) AddSuccess(i int32) {
  1577. if m.addsuccess != nil {
  1578. *m.addsuccess += i
  1579. } else {
  1580. m.addsuccess = &i
  1581. }
  1582. }
  1583. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  1584. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  1585. v := m.addsuccess
  1586. if v == nil {
  1587. return
  1588. }
  1589. return *v, true
  1590. }
  1591. // ClearSuccess clears the value of the "success" field.
  1592. func (m *BatchMsgMutation) ClearSuccess() {
  1593. m.success = nil
  1594. m.addsuccess = nil
  1595. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  1596. }
  1597. // SuccessCleared returns if the "success" field was cleared in this mutation.
  1598. func (m *BatchMsgMutation) SuccessCleared() bool {
  1599. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  1600. return ok
  1601. }
  1602. // ResetSuccess resets all changes to the "success" field.
  1603. func (m *BatchMsgMutation) ResetSuccess() {
  1604. m.success = nil
  1605. m.addsuccess = nil
  1606. delete(m.clearedFields, batchmsg.FieldSuccess)
  1607. }
  1608. // SetFail sets the "fail" field.
  1609. func (m *BatchMsgMutation) SetFail(i int32) {
  1610. m.fail = &i
  1611. m.addfail = nil
  1612. }
  1613. // Fail returns the value of the "fail" field in the mutation.
  1614. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  1615. v := m.fail
  1616. if v == nil {
  1617. return
  1618. }
  1619. return *v, true
  1620. }
  1621. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  1622. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1624. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  1625. if !m.op.Is(OpUpdateOne) {
  1626. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  1627. }
  1628. if m.id == nil || m.oldValue == nil {
  1629. return v, errors.New("OldFail requires an ID field in the mutation")
  1630. }
  1631. oldValue, err := m.oldValue(ctx)
  1632. if err != nil {
  1633. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  1634. }
  1635. return oldValue.Fail, nil
  1636. }
  1637. // AddFail adds i to the "fail" field.
  1638. func (m *BatchMsgMutation) AddFail(i int32) {
  1639. if m.addfail != nil {
  1640. *m.addfail += i
  1641. } else {
  1642. m.addfail = &i
  1643. }
  1644. }
  1645. // AddedFail returns the value that was added to the "fail" field in this mutation.
  1646. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  1647. v := m.addfail
  1648. if v == nil {
  1649. return
  1650. }
  1651. return *v, true
  1652. }
  1653. // ClearFail clears the value of the "fail" field.
  1654. func (m *BatchMsgMutation) ClearFail() {
  1655. m.fail = nil
  1656. m.addfail = nil
  1657. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  1658. }
  1659. // FailCleared returns if the "fail" field was cleared in this mutation.
  1660. func (m *BatchMsgMutation) FailCleared() bool {
  1661. _, ok := m.clearedFields[batchmsg.FieldFail]
  1662. return ok
  1663. }
  1664. // ResetFail resets all changes to the "fail" field.
  1665. func (m *BatchMsgMutation) ResetFail() {
  1666. m.fail = nil
  1667. m.addfail = nil
  1668. delete(m.clearedFields, batchmsg.FieldFail)
  1669. }
  1670. // SetStartTime sets the "start_time" field.
  1671. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  1672. m.start_time = &t
  1673. }
  1674. // StartTime returns the value of the "start_time" field in the mutation.
  1675. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  1676. v := m.start_time
  1677. if v == nil {
  1678. return
  1679. }
  1680. return *v, true
  1681. }
  1682. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  1683. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1685. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  1686. if !m.op.Is(OpUpdateOne) {
  1687. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  1688. }
  1689. if m.id == nil || m.oldValue == nil {
  1690. return v, errors.New("OldStartTime requires an ID field in the mutation")
  1691. }
  1692. oldValue, err := m.oldValue(ctx)
  1693. if err != nil {
  1694. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  1695. }
  1696. return oldValue.StartTime, nil
  1697. }
  1698. // ClearStartTime clears the value of the "start_time" field.
  1699. func (m *BatchMsgMutation) ClearStartTime() {
  1700. m.start_time = nil
  1701. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  1702. }
  1703. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  1704. func (m *BatchMsgMutation) StartTimeCleared() bool {
  1705. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  1706. return ok
  1707. }
  1708. // ResetStartTime resets all changes to the "start_time" field.
  1709. func (m *BatchMsgMutation) ResetStartTime() {
  1710. m.start_time = nil
  1711. delete(m.clearedFields, batchmsg.FieldStartTime)
  1712. }
  1713. // SetStopTime sets the "stop_time" field.
  1714. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  1715. m.stop_time = &t
  1716. }
  1717. // StopTime returns the value of the "stop_time" field in the mutation.
  1718. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  1719. v := m.stop_time
  1720. if v == nil {
  1721. return
  1722. }
  1723. return *v, true
  1724. }
  1725. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  1726. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1728. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  1729. if !m.op.Is(OpUpdateOne) {
  1730. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  1731. }
  1732. if m.id == nil || m.oldValue == nil {
  1733. return v, errors.New("OldStopTime requires an ID field in the mutation")
  1734. }
  1735. oldValue, err := m.oldValue(ctx)
  1736. if err != nil {
  1737. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  1738. }
  1739. return oldValue.StopTime, nil
  1740. }
  1741. // ClearStopTime clears the value of the "stop_time" field.
  1742. func (m *BatchMsgMutation) ClearStopTime() {
  1743. m.stop_time = nil
  1744. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  1745. }
  1746. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  1747. func (m *BatchMsgMutation) StopTimeCleared() bool {
  1748. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  1749. return ok
  1750. }
  1751. // ResetStopTime resets all changes to the "stop_time" field.
  1752. func (m *BatchMsgMutation) ResetStopTime() {
  1753. m.stop_time = nil
  1754. delete(m.clearedFields, batchmsg.FieldStopTime)
  1755. }
  1756. // SetType sets the "type" field.
  1757. func (m *BatchMsgMutation) SetType(i int32) {
  1758. m._type = &i
  1759. m.add_type = nil
  1760. }
  1761. // GetType returns the value of the "type" field in the mutation.
  1762. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  1763. v := m._type
  1764. if v == nil {
  1765. return
  1766. }
  1767. return *v, true
  1768. }
  1769. // OldType returns the old "type" field's value of the BatchMsg entity.
  1770. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1771. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1772. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  1773. if !m.op.Is(OpUpdateOne) {
  1774. return v, errors.New("OldType is only allowed on UpdateOne operations")
  1775. }
  1776. if m.id == nil || m.oldValue == nil {
  1777. return v, errors.New("OldType requires an ID field in the mutation")
  1778. }
  1779. oldValue, err := m.oldValue(ctx)
  1780. if err != nil {
  1781. return v, fmt.Errorf("querying old value for OldType: %w", err)
  1782. }
  1783. return oldValue.Type, nil
  1784. }
  1785. // AddType adds i to the "type" field.
  1786. func (m *BatchMsgMutation) AddType(i int32) {
  1787. if m.add_type != nil {
  1788. *m.add_type += i
  1789. } else {
  1790. m.add_type = &i
  1791. }
  1792. }
  1793. // AddedType returns the value that was added to the "type" field in this mutation.
  1794. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  1795. v := m.add_type
  1796. if v == nil {
  1797. return
  1798. }
  1799. return *v, true
  1800. }
  1801. // ClearType clears the value of the "type" field.
  1802. func (m *BatchMsgMutation) ClearType() {
  1803. m._type = nil
  1804. m.add_type = nil
  1805. m.clearedFields[batchmsg.FieldType] = struct{}{}
  1806. }
  1807. // TypeCleared returns if the "type" field was cleared in this mutation.
  1808. func (m *BatchMsgMutation) TypeCleared() bool {
  1809. _, ok := m.clearedFields[batchmsg.FieldType]
  1810. return ok
  1811. }
  1812. // ResetType resets all changes to the "type" field.
  1813. func (m *BatchMsgMutation) ResetType() {
  1814. m._type = nil
  1815. m.add_type = nil
  1816. delete(m.clearedFields, batchmsg.FieldType)
  1817. }
  1818. // SetOrganizationID sets the "organization_id" field.
  1819. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  1820. m.organization_id = &u
  1821. m.addorganization_id = nil
  1822. }
  1823. // OrganizationID returns the value of the "organization_id" field in the mutation.
  1824. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  1825. v := m.organization_id
  1826. if v == nil {
  1827. return
  1828. }
  1829. return *v, true
  1830. }
  1831. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  1832. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1834. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  1835. if !m.op.Is(OpUpdateOne) {
  1836. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  1837. }
  1838. if m.id == nil || m.oldValue == nil {
  1839. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  1840. }
  1841. oldValue, err := m.oldValue(ctx)
  1842. if err != nil {
  1843. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  1844. }
  1845. return oldValue.OrganizationID, nil
  1846. }
  1847. // AddOrganizationID adds u to the "organization_id" field.
  1848. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  1849. if m.addorganization_id != nil {
  1850. *m.addorganization_id += u
  1851. } else {
  1852. m.addorganization_id = &u
  1853. }
  1854. }
  1855. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  1856. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  1857. v := m.addorganization_id
  1858. if v == nil {
  1859. return
  1860. }
  1861. return *v, true
  1862. }
  1863. // ResetOrganizationID resets all changes to the "organization_id" field.
  1864. func (m *BatchMsgMutation) ResetOrganizationID() {
  1865. m.organization_id = nil
  1866. m.addorganization_id = nil
  1867. }
  1868. // Where appends a list predicates to the BatchMsgMutation builder.
  1869. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  1870. m.predicates = append(m.predicates, ps...)
  1871. }
  1872. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  1873. // users can use type-assertion to append predicates that do not depend on any generated package.
  1874. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  1875. p := make([]predicate.BatchMsg, len(ps))
  1876. for i := range ps {
  1877. p[i] = ps[i]
  1878. }
  1879. m.Where(p...)
  1880. }
  1881. // Op returns the operation name.
  1882. func (m *BatchMsgMutation) Op() Op {
  1883. return m.op
  1884. }
  1885. // SetOp allows setting the mutation operation.
  1886. func (m *BatchMsgMutation) SetOp(op Op) {
  1887. m.op = op
  1888. }
  1889. // Type returns the node type of this mutation (BatchMsg).
  1890. func (m *BatchMsgMutation) Type() string {
  1891. return m.typ
  1892. }
  1893. // Fields returns all fields that were changed during this mutation. Note that in
  1894. // order to get all numeric fields that were incremented/decremented, call
  1895. // AddedFields().
  1896. func (m *BatchMsgMutation) Fields() []string {
  1897. fields := make([]string, 0, 16)
  1898. if m.created_at != nil {
  1899. fields = append(fields, batchmsg.FieldCreatedAt)
  1900. }
  1901. if m.updated_at != nil {
  1902. fields = append(fields, batchmsg.FieldUpdatedAt)
  1903. }
  1904. if m.deleted_at != nil {
  1905. fields = append(fields, batchmsg.FieldDeletedAt)
  1906. }
  1907. if m.status != nil {
  1908. fields = append(fields, batchmsg.FieldStatus)
  1909. }
  1910. if m.batch_no != nil {
  1911. fields = append(fields, batchmsg.FieldBatchNo)
  1912. }
  1913. if m.task_name != nil {
  1914. fields = append(fields, batchmsg.FieldTaskName)
  1915. }
  1916. if m.fromwxid != nil {
  1917. fields = append(fields, batchmsg.FieldFromwxid)
  1918. }
  1919. if m.msg != nil {
  1920. fields = append(fields, batchmsg.FieldMsg)
  1921. }
  1922. if m.tag != nil {
  1923. fields = append(fields, batchmsg.FieldTag)
  1924. }
  1925. if m.total != nil {
  1926. fields = append(fields, batchmsg.FieldTotal)
  1927. }
  1928. if m.success != nil {
  1929. fields = append(fields, batchmsg.FieldSuccess)
  1930. }
  1931. if m.fail != nil {
  1932. fields = append(fields, batchmsg.FieldFail)
  1933. }
  1934. if m.start_time != nil {
  1935. fields = append(fields, batchmsg.FieldStartTime)
  1936. }
  1937. if m.stop_time != nil {
  1938. fields = append(fields, batchmsg.FieldStopTime)
  1939. }
  1940. if m._type != nil {
  1941. fields = append(fields, batchmsg.FieldType)
  1942. }
  1943. if m.organization_id != nil {
  1944. fields = append(fields, batchmsg.FieldOrganizationID)
  1945. }
  1946. return fields
  1947. }
  1948. // Field returns the value of a field with the given name. The second boolean
  1949. // return value indicates that this field was not set, or was not defined in the
  1950. // schema.
  1951. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  1952. switch name {
  1953. case batchmsg.FieldCreatedAt:
  1954. return m.CreatedAt()
  1955. case batchmsg.FieldUpdatedAt:
  1956. return m.UpdatedAt()
  1957. case batchmsg.FieldDeletedAt:
  1958. return m.DeletedAt()
  1959. case batchmsg.FieldStatus:
  1960. return m.Status()
  1961. case batchmsg.FieldBatchNo:
  1962. return m.BatchNo()
  1963. case batchmsg.FieldTaskName:
  1964. return m.TaskName()
  1965. case batchmsg.FieldFromwxid:
  1966. return m.Fromwxid()
  1967. case batchmsg.FieldMsg:
  1968. return m.Msg()
  1969. case batchmsg.FieldTag:
  1970. return m.Tag()
  1971. case batchmsg.FieldTotal:
  1972. return m.Total()
  1973. case batchmsg.FieldSuccess:
  1974. return m.Success()
  1975. case batchmsg.FieldFail:
  1976. return m.Fail()
  1977. case batchmsg.FieldStartTime:
  1978. return m.StartTime()
  1979. case batchmsg.FieldStopTime:
  1980. return m.StopTime()
  1981. case batchmsg.FieldType:
  1982. return m.GetType()
  1983. case batchmsg.FieldOrganizationID:
  1984. return m.OrganizationID()
  1985. }
  1986. return nil, false
  1987. }
  1988. // OldField returns the old value of the field from the database. An error is
  1989. // returned if the mutation operation is not UpdateOne, or the query to the
  1990. // database failed.
  1991. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1992. switch name {
  1993. case batchmsg.FieldCreatedAt:
  1994. return m.OldCreatedAt(ctx)
  1995. case batchmsg.FieldUpdatedAt:
  1996. return m.OldUpdatedAt(ctx)
  1997. case batchmsg.FieldDeletedAt:
  1998. return m.OldDeletedAt(ctx)
  1999. case batchmsg.FieldStatus:
  2000. return m.OldStatus(ctx)
  2001. case batchmsg.FieldBatchNo:
  2002. return m.OldBatchNo(ctx)
  2003. case batchmsg.FieldTaskName:
  2004. return m.OldTaskName(ctx)
  2005. case batchmsg.FieldFromwxid:
  2006. return m.OldFromwxid(ctx)
  2007. case batchmsg.FieldMsg:
  2008. return m.OldMsg(ctx)
  2009. case batchmsg.FieldTag:
  2010. return m.OldTag(ctx)
  2011. case batchmsg.FieldTotal:
  2012. return m.OldTotal(ctx)
  2013. case batchmsg.FieldSuccess:
  2014. return m.OldSuccess(ctx)
  2015. case batchmsg.FieldFail:
  2016. return m.OldFail(ctx)
  2017. case batchmsg.FieldStartTime:
  2018. return m.OldStartTime(ctx)
  2019. case batchmsg.FieldStopTime:
  2020. return m.OldStopTime(ctx)
  2021. case batchmsg.FieldType:
  2022. return m.OldType(ctx)
  2023. case batchmsg.FieldOrganizationID:
  2024. return m.OldOrganizationID(ctx)
  2025. }
  2026. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  2027. }
  2028. // SetField sets the value of a field with the given name. It returns an error if
  2029. // the field is not defined in the schema, or if the type mismatched the field
  2030. // type.
  2031. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  2032. switch name {
  2033. case batchmsg.FieldCreatedAt:
  2034. v, ok := value.(time.Time)
  2035. if !ok {
  2036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2037. }
  2038. m.SetCreatedAt(v)
  2039. return nil
  2040. case batchmsg.FieldUpdatedAt:
  2041. v, ok := value.(time.Time)
  2042. if !ok {
  2043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2044. }
  2045. m.SetUpdatedAt(v)
  2046. return nil
  2047. case batchmsg.FieldDeletedAt:
  2048. v, ok := value.(time.Time)
  2049. if !ok {
  2050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2051. }
  2052. m.SetDeletedAt(v)
  2053. return nil
  2054. case batchmsg.FieldStatus:
  2055. v, ok := value.(uint8)
  2056. if !ok {
  2057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2058. }
  2059. m.SetStatus(v)
  2060. return nil
  2061. case batchmsg.FieldBatchNo:
  2062. v, ok := value.(string)
  2063. if !ok {
  2064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2065. }
  2066. m.SetBatchNo(v)
  2067. return nil
  2068. case batchmsg.FieldTaskName:
  2069. v, ok := value.(string)
  2070. if !ok {
  2071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2072. }
  2073. m.SetTaskName(v)
  2074. return nil
  2075. case batchmsg.FieldFromwxid:
  2076. v, ok := value.(string)
  2077. if !ok {
  2078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2079. }
  2080. m.SetFromwxid(v)
  2081. return nil
  2082. case batchmsg.FieldMsg:
  2083. v, ok := value.(string)
  2084. if !ok {
  2085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2086. }
  2087. m.SetMsg(v)
  2088. return nil
  2089. case batchmsg.FieldTag:
  2090. v, ok := value.(string)
  2091. if !ok {
  2092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2093. }
  2094. m.SetTag(v)
  2095. return nil
  2096. case batchmsg.FieldTotal:
  2097. v, ok := value.(int32)
  2098. if !ok {
  2099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2100. }
  2101. m.SetTotal(v)
  2102. return nil
  2103. case batchmsg.FieldSuccess:
  2104. v, ok := value.(int32)
  2105. if !ok {
  2106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2107. }
  2108. m.SetSuccess(v)
  2109. return nil
  2110. case batchmsg.FieldFail:
  2111. v, ok := value.(int32)
  2112. if !ok {
  2113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2114. }
  2115. m.SetFail(v)
  2116. return nil
  2117. case batchmsg.FieldStartTime:
  2118. v, ok := value.(time.Time)
  2119. if !ok {
  2120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2121. }
  2122. m.SetStartTime(v)
  2123. return nil
  2124. case batchmsg.FieldStopTime:
  2125. v, ok := value.(time.Time)
  2126. if !ok {
  2127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2128. }
  2129. m.SetStopTime(v)
  2130. return nil
  2131. case batchmsg.FieldType:
  2132. v, ok := value.(int32)
  2133. if !ok {
  2134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2135. }
  2136. m.SetType(v)
  2137. return nil
  2138. case batchmsg.FieldOrganizationID:
  2139. v, ok := value.(uint64)
  2140. if !ok {
  2141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2142. }
  2143. m.SetOrganizationID(v)
  2144. return nil
  2145. }
  2146. return fmt.Errorf("unknown BatchMsg field %s", name)
  2147. }
  2148. // AddedFields returns all numeric fields that were incremented/decremented during
  2149. // this mutation.
  2150. func (m *BatchMsgMutation) AddedFields() []string {
  2151. var fields []string
  2152. if m.addstatus != nil {
  2153. fields = append(fields, batchmsg.FieldStatus)
  2154. }
  2155. if m.addtotal != nil {
  2156. fields = append(fields, batchmsg.FieldTotal)
  2157. }
  2158. if m.addsuccess != nil {
  2159. fields = append(fields, batchmsg.FieldSuccess)
  2160. }
  2161. if m.addfail != nil {
  2162. fields = append(fields, batchmsg.FieldFail)
  2163. }
  2164. if m.add_type != nil {
  2165. fields = append(fields, batchmsg.FieldType)
  2166. }
  2167. if m.addorganization_id != nil {
  2168. fields = append(fields, batchmsg.FieldOrganizationID)
  2169. }
  2170. return fields
  2171. }
  2172. // AddedField returns the numeric value that was incremented/decremented on a field
  2173. // with the given name. The second boolean return value indicates that this field
  2174. // was not set, or was not defined in the schema.
  2175. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  2176. switch name {
  2177. case batchmsg.FieldStatus:
  2178. return m.AddedStatus()
  2179. case batchmsg.FieldTotal:
  2180. return m.AddedTotal()
  2181. case batchmsg.FieldSuccess:
  2182. return m.AddedSuccess()
  2183. case batchmsg.FieldFail:
  2184. return m.AddedFail()
  2185. case batchmsg.FieldType:
  2186. return m.AddedType()
  2187. case batchmsg.FieldOrganizationID:
  2188. return m.AddedOrganizationID()
  2189. }
  2190. return nil, false
  2191. }
  2192. // AddField adds the value to the field with the given name. It returns an error if
  2193. // the field is not defined in the schema, or if the type mismatched the field
  2194. // type.
  2195. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  2196. switch name {
  2197. case batchmsg.FieldStatus:
  2198. v, ok := value.(int8)
  2199. if !ok {
  2200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2201. }
  2202. m.AddStatus(v)
  2203. return nil
  2204. case batchmsg.FieldTotal:
  2205. v, ok := value.(int32)
  2206. if !ok {
  2207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2208. }
  2209. m.AddTotal(v)
  2210. return nil
  2211. case batchmsg.FieldSuccess:
  2212. v, ok := value.(int32)
  2213. if !ok {
  2214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2215. }
  2216. m.AddSuccess(v)
  2217. return nil
  2218. case batchmsg.FieldFail:
  2219. v, ok := value.(int32)
  2220. if !ok {
  2221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2222. }
  2223. m.AddFail(v)
  2224. return nil
  2225. case batchmsg.FieldType:
  2226. v, ok := value.(int32)
  2227. if !ok {
  2228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2229. }
  2230. m.AddType(v)
  2231. return nil
  2232. case batchmsg.FieldOrganizationID:
  2233. v, ok := value.(int64)
  2234. if !ok {
  2235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2236. }
  2237. m.AddOrganizationID(v)
  2238. return nil
  2239. }
  2240. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  2241. }
  2242. // ClearedFields returns all nullable fields that were cleared during this
  2243. // mutation.
  2244. func (m *BatchMsgMutation) ClearedFields() []string {
  2245. var fields []string
  2246. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  2247. fields = append(fields, batchmsg.FieldDeletedAt)
  2248. }
  2249. if m.FieldCleared(batchmsg.FieldStatus) {
  2250. fields = append(fields, batchmsg.FieldStatus)
  2251. }
  2252. if m.FieldCleared(batchmsg.FieldBatchNo) {
  2253. fields = append(fields, batchmsg.FieldBatchNo)
  2254. }
  2255. if m.FieldCleared(batchmsg.FieldTaskName) {
  2256. fields = append(fields, batchmsg.FieldTaskName)
  2257. }
  2258. if m.FieldCleared(batchmsg.FieldFromwxid) {
  2259. fields = append(fields, batchmsg.FieldFromwxid)
  2260. }
  2261. if m.FieldCleared(batchmsg.FieldMsg) {
  2262. fields = append(fields, batchmsg.FieldMsg)
  2263. }
  2264. if m.FieldCleared(batchmsg.FieldTag) {
  2265. fields = append(fields, batchmsg.FieldTag)
  2266. }
  2267. if m.FieldCleared(batchmsg.FieldTotal) {
  2268. fields = append(fields, batchmsg.FieldTotal)
  2269. }
  2270. if m.FieldCleared(batchmsg.FieldSuccess) {
  2271. fields = append(fields, batchmsg.FieldSuccess)
  2272. }
  2273. if m.FieldCleared(batchmsg.FieldFail) {
  2274. fields = append(fields, batchmsg.FieldFail)
  2275. }
  2276. if m.FieldCleared(batchmsg.FieldStartTime) {
  2277. fields = append(fields, batchmsg.FieldStartTime)
  2278. }
  2279. if m.FieldCleared(batchmsg.FieldStopTime) {
  2280. fields = append(fields, batchmsg.FieldStopTime)
  2281. }
  2282. if m.FieldCleared(batchmsg.FieldType) {
  2283. fields = append(fields, batchmsg.FieldType)
  2284. }
  2285. return fields
  2286. }
  2287. // FieldCleared returns a boolean indicating if a field with the given name was
  2288. // cleared in this mutation.
  2289. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  2290. _, ok := m.clearedFields[name]
  2291. return ok
  2292. }
  2293. // ClearField clears the value of the field with the given name. It returns an
  2294. // error if the field is not defined in the schema.
  2295. func (m *BatchMsgMutation) ClearField(name string) error {
  2296. switch name {
  2297. case batchmsg.FieldDeletedAt:
  2298. m.ClearDeletedAt()
  2299. return nil
  2300. case batchmsg.FieldStatus:
  2301. m.ClearStatus()
  2302. return nil
  2303. case batchmsg.FieldBatchNo:
  2304. m.ClearBatchNo()
  2305. return nil
  2306. case batchmsg.FieldTaskName:
  2307. m.ClearTaskName()
  2308. return nil
  2309. case batchmsg.FieldFromwxid:
  2310. m.ClearFromwxid()
  2311. return nil
  2312. case batchmsg.FieldMsg:
  2313. m.ClearMsg()
  2314. return nil
  2315. case batchmsg.FieldTag:
  2316. m.ClearTag()
  2317. return nil
  2318. case batchmsg.FieldTotal:
  2319. m.ClearTotal()
  2320. return nil
  2321. case batchmsg.FieldSuccess:
  2322. m.ClearSuccess()
  2323. return nil
  2324. case batchmsg.FieldFail:
  2325. m.ClearFail()
  2326. return nil
  2327. case batchmsg.FieldStartTime:
  2328. m.ClearStartTime()
  2329. return nil
  2330. case batchmsg.FieldStopTime:
  2331. m.ClearStopTime()
  2332. return nil
  2333. case batchmsg.FieldType:
  2334. m.ClearType()
  2335. return nil
  2336. }
  2337. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  2338. }
  2339. // ResetField resets all changes in the mutation for the field with the given name.
  2340. // It returns an error if the field is not defined in the schema.
  2341. func (m *BatchMsgMutation) ResetField(name string) error {
  2342. switch name {
  2343. case batchmsg.FieldCreatedAt:
  2344. m.ResetCreatedAt()
  2345. return nil
  2346. case batchmsg.FieldUpdatedAt:
  2347. m.ResetUpdatedAt()
  2348. return nil
  2349. case batchmsg.FieldDeletedAt:
  2350. m.ResetDeletedAt()
  2351. return nil
  2352. case batchmsg.FieldStatus:
  2353. m.ResetStatus()
  2354. return nil
  2355. case batchmsg.FieldBatchNo:
  2356. m.ResetBatchNo()
  2357. return nil
  2358. case batchmsg.FieldTaskName:
  2359. m.ResetTaskName()
  2360. return nil
  2361. case batchmsg.FieldFromwxid:
  2362. m.ResetFromwxid()
  2363. return nil
  2364. case batchmsg.FieldMsg:
  2365. m.ResetMsg()
  2366. return nil
  2367. case batchmsg.FieldTag:
  2368. m.ResetTag()
  2369. return nil
  2370. case batchmsg.FieldTotal:
  2371. m.ResetTotal()
  2372. return nil
  2373. case batchmsg.FieldSuccess:
  2374. m.ResetSuccess()
  2375. return nil
  2376. case batchmsg.FieldFail:
  2377. m.ResetFail()
  2378. return nil
  2379. case batchmsg.FieldStartTime:
  2380. m.ResetStartTime()
  2381. return nil
  2382. case batchmsg.FieldStopTime:
  2383. m.ResetStopTime()
  2384. return nil
  2385. case batchmsg.FieldType:
  2386. m.ResetType()
  2387. return nil
  2388. case batchmsg.FieldOrganizationID:
  2389. m.ResetOrganizationID()
  2390. return nil
  2391. }
  2392. return fmt.Errorf("unknown BatchMsg field %s", name)
  2393. }
  2394. // AddedEdges returns all edge names that were set/added in this mutation.
  2395. func (m *BatchMsgMutation) AddedEdges() []string {
  2396. edges := make([]string, 0, 0)
  2397. return edges
  2398. }
  2399. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2400. // name in this mutation.
  2401. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  2402. return nil
  2403. }
  2404. // RemovedEdges returns all edge names that were removed in this mutation.
  2405. func (m *BatchMsgMutation) RemovedEdges() []string {
  2406. edges := make([]string, 0, 0)
  2407. return edges
  2408. }
  2409. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2410. // the given name in this mutation.
  2411. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  2412. return nil
  2413. }
  2414. // ClearedEdges returns all edge names that were cleared in this mutation.
  2415. func (m *BatchMsgMutation) ClearedEdges() []string {
  2416. edges := make([]string, 0, 0)
  2417. return edges
  2418. }
  2419. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2420. // was cleared in this mutation.
  2421. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  2422. return false
  2423. }
  2424. // ClearEdge clears the value of the edge with the given name. It returns an error
  2425. // if that edge is not defined in the schema.
  2426. func (m *BatchMsgMutation) ClearEdge(name string) error {
  2427. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  2428. }
  2429. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2430. // It returns an error if the edge is not defined in the schema.
  2431. func (m *BatchMsgMutation) ResetEdge(name string) error {
  2432. return fmt.Errorf("unknown BatchMsg edge %s", name)
  2433. }
  2434. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  2435. type ContactMutation struct {
  2436. config
  2437. op Op
  2438. typ string
  2439. id *uint64
  2440. created_at *time.Time
  2441. updated_at *time.Time
  2442. status *uint8
  2443. addstatus *int8
  2444. deleted_at *time.Time
  2445. wx_wxid *string
  2446. _type *int
  2447. add_type *int
  2448. wxid *string
  2449. account *string
  2450. nickname *string
  2451. markname *string
  2452. headimg *string
  2453. sex *int
  2454. addsex *int
  2455. starrole *string
  2456. dontseeit *int
  2457. adddontseeit *int
  2458. dontseeme *int
  2459. adddontseeme *int
  2460. lag *string
  2461. gid *string
  2462. gname *string
  2463. v3 *string
  2464. organization_id *uint64
  2465. addorganization_id *int64
  2466. clearedFields map[string]struct{}
  2467. contact_relationships map[uint64]struct{}
  2468. removedcontact_relationships map[uint64]struct{}
  2469. clearedcontact_relationships bool
  2470. contact_messages map[uint64]struct{}
  2471. removedcontact_messages map[uint64]struct{}
  2472. clearedcontact_messages bool
  2473. done bool
  2474. oldValue func(context.Context) (*Contact, error)
  2475. predicates []predicate.Contact
  2476. }
  2477. var _ ent.Mutation = (*ContactMutation)(nil)
  2478. // contactOption allows management of the mutation configuration using functional options.
  2479. type contactOption func(*ContactMutation)
  2480. // newContactMutation creates new mutation for the Contact entity.
  2481. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  2482. m := &ContactMutation{
  2483. config: c,
  2484. op: op,
  2485. typ: TypeContact,
  2486. clearedFields: make(map[string]struct{}),
  2487. }
  2488. for _, opt := range opts {
  2489. opt(m)
  2490. }
  2491. return m
  2492. }
  2493. // withContactID sets the ID field of the mutation.
  2494. func withContactID(id uint64) contactOption {
  2495. return func(m *ContactMutation) {
  2496. var (
  2497. err error
  2498. once sync.Once
  2499. value *Contact
  2500. )
  2501. m.oldValue = func(ctx context.Context) (*Contact, error) {
  2502. once.Do(func() {
  2503. if m.done {
  2504. err = errors.New("querying old values post mutation is not allowed")
  2505. } else {
  2506. value, err = m.Client().Contact.Get(ctx, id)
  2507. }
  2508. })
  2509. return value, err
  2510. }
  2511. m.id = &id
  2512. }
  2513. }
  2514. // withContact sets the old Contact of the mutation.
  2515. func withContact(node *Contact) contactOption {
  2516. return func(m *ContactMutation) {
  2517. m.oldValue = func(context.Context) (*Contact, error) {
  2518. return node, nil
  2519. }
  2520. m.id = &node.ID
  2521. }
  2522. }
  2523. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2524. // executed in a transaction (ent.Tx), a transactional client is returned.
  2525. func (m ContactMutation) Client() *Client {
  2526. client := &Client{config: m.config}
  2527. client.init()
  2528. return client
  2529. }
  2530. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2531. // it returns an error otherwise.
  2532. func (m ContactMutation) Tx() (*Tx, error) {
  2533. if _, ok := m.driver.(*txDriver); !ok {
  2534. return nil, errors.New("ent: mutation is not running in a transaction")
  2535. }
  2536. tx := &Tx{config: m.config}
  2537. tx.init()
  2538. return tx, nil
  2539. }
  2540. // SetID sets the value of the id field. Note that this
  2541. // operation is only accepted on creation of Contact entities.
  2542. func (m *ContactMutation) SetID(id uint64) {
  2543. m.id = &id
  2544. }
  2545. // ID returns the ID value in the mutation. Note that the ID is only available
  2546. // if it was provided to the builder or after it was returned from the database.
  2547. func (m *ContactMutation) ID() (id uint64, exists bool) {
  2548. if m.id == nil {
  2549. return
  2550. }
  2551. return *m.id, true
  2552. }
  2553. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2554. // That means, if the mutation is applied within a transaction with an isolation level such
  2555. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2556. // or updated by the mutation.
  2557. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  2558. switch {
  2559. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2560. id, exists := m.ID()
  2561. if exists {
  2562. return []uint64{id}, nil
  2563. }
  2564. fallthrough
  2565. case m.op.Is(OpUpdate | OpDelete):
  2566. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  2567. default:
  2568. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2569. }
  2570. }
  2571. // SetCreatedAt sets the "created_at" field.
  2572. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  2573. m.created_at = &t
  2574. }
  2575. // CreatedAt returns the value of the "created_at" field in the mutation.
  2576. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  2577. v := m.created_at
  2578. if v == nil {
  2579. return
  2580. }
  2581. return *v, true
  2582. }
  2583. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  2584. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2586. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2587. if !m.op.Is(OpUpdateOne) {
  2588. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2589. }
  2590. if m.id == nil || m.oldValue == nil {
  2591. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2592. }
  2593. oldValue, err := m.oldValue(ctx)
  2594. if err != nil {
  2595. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2596. }
  2597. return oldValue.CreatedAt, nil
  2598. }
  2599. // ResetCreatedAt resets all changes to the "created_at" field.
  2600. func (m *ContactMutation) ResetCreatedAt() {
  2601. m.created_at = nil
  2602. }
  2603. // SetUpdatedAt sets the "updated_at" field.
  2604. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  2605. m.updated_at = &t
  2606. }
  2607. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2608. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  2609. v := m.updated_at
  2610. if v == nil {
  2611. return
  2612. }
  2613. return *v, true
  2614. }
  2615. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  2616. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2617. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2618. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2619. if !m.op.Is(OpUpdateOne) {
  2620. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2621. }
  2622. if m.id == nil || m.oldValue == nil {
  2623. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2624. }
  2625. oldValue, err := m.oldValue(ctx)
  2626. if err != nil {
  2627. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2628. }
  2629. return oldValue.UpdatedAt, nil
  2630. }
  2631. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2632. func (m *ContactMutation) ResetUpdatedAt() {
  2633. m.updated_at = nil
  2634. }
  2635. // SetStatus sets the "status" field.
  2636. func (m *ContactMutation) SetStatus(u uint8) {
  2637. m.status = &u
  2638. m.addstatus = nil
  2639. }
  2640. // Status returns the value of the "status" field in the mutation.
  2641. func (m *ContactMutation) Status() (r uint8, exists bool) {
  2642. v := m.status
  2643. if v == nil {
  2644. return
  2645. }
  2646. return *v, true
  2647. }
  2648. // OldStatus returns the old "status" field's value of the Contact entity.
  2649. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2651. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  2652. if !m.op.Is(OpUpdateOne) {
  2653. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  2654. }
  2655. if m.id == nil || m.oldValue == nil {
  2656. return v, errors.New("OldStatus requires an ID field in the mutation")
  2657. }
  2658. oldValue, err := m.oldValue(ctx)
  2659. if err != nil {
  2660. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  2661. }
  2662. return oldValue.Status, nil
  2663. }
  2664. // AddStatus adds u to the "status" field.
  2665. func (m *ContactMutation) AddStatus(u int8) {
  2666. if m.addstatus != nil {
  2667. *m.addstatus += u
  2668. } else {
  2669. m.addstatus = &u
  2670. }
  2671. }
  2672. // AddedStatus returns the value that was added to the "status" field in this mutation.
  2673. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  2674. v := m.addstatus
  2675. if v == nil {
  2676. return
  2677. }
  2678. return *v, true
  2679. }
  2680. // ClearStatus clears the value of the "status" field.
  2681. func (m *ContactMutation) ClearStatus() {
  2682. m.status = nil
  2683. m.addstatus = nil
  2684. m.clearedFields[contact.FieldStatus] = struct{}{}
  2685. }
  2686. // StatusCleared returns if the "status" field was cleared in this mutation.
  2687. func (m *ContactMutation) StatusCleared() bool {
  2688. _, ok := m.clearedFields[contact.FieldStatus]
  2689. return ok
  2690. }
  2691. // ResetStatus resets all changes to the "status" field.
  2692. func (m *ContactMutation) ResetStatus() {
  2693. m.status = nil
  2694. m.addstatus = nil
  2695. delete(m.clearedFields, contact.FieldStatus)
  2696. }
  2697. // SetDeletedAt sets the "deleted_at" field.
  2698. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  2699. m.deleted_at = &t
  2700. }
  2701. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2702. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  2703. v := m.deleted_at
  2704. if v == nil {
  2705. return
  2706. }
  2707. return *v, true
  2708. }
  2709. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  2710. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2712. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2713. if !m.op.Is(OpUpdateOne) {
  2714. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2715. }
  2716. if m.id == nil || m.oldValue == nil {
  2717. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2718. }
  2719. oldValue, err := m.oldValue(ctx)
  2720. if err != nil {
  2721. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2722. }
  2723. return oldValue.DeletedAt, nil
  2724. }
  2725. // ClearDeletedAt clears the value of the "deleted_at" field.
  2726. func (m *ContactMutation) ClearDeletedAt() {
  2727. m.deleted_at = nil
  2728. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  2729. }
  2730. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2731. func (m *ContactMutation) DeletedAtCleared() bool {
  2732. _, ok := m.clearedFields[contact.FieldDeletedAt]
  2733. return ok
  2734. }
  2735. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2736. func (m *ContactMutation) ResetDeletedAt() {
  2737. m.deleted_at = nil
  2738. delete(m.clearedFields, contact.FieldDeletedAt)
  2739. }
  2740. // SetWxWxid sets the "wx_wxid" field.
  2741. func (m *ContactMutation) SetWxWxid(s string) {
  2742. m.wx_wxid = &s
  2743. }
  2744. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  2745. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  2746. v := m.wx_wxid
  2747. if v == nil {
  2748. return
  2749. }
  2750. return *v, true
  2751. }
  2752. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  2753. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2755. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  2756. if !m.op.Is(OpUpdateOne) {
  2757. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  2758. }
  2759. if m.id == nil || m.oldValue == nil {
  2760. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  2761. }
  2762. oldValue, err := m.oldValue(ctx)
  2763. if err != nil {
  2764. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  2765. }
  2766. return oldValue.WxWxid, nil
  2767. }
  2768. // ClearWxWxid clears the value of the "wx_wxid" field.
  2769. func (m *ContactMutation) ClearWxWxid() {
  2770. m.wx_wxid = nil
  2771. m.clearedFields[contact.FieldWxWxid] = struct{}{}
  2772. }
  2773. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  2774. func (m *ContactMutation) WxWxidCleared() bool {
  2775. _, ok := m.clearedFields[contact.FieldWxWxid]
  2776. return ok
  2777. }
  2778. // ResetWxWxid resets all changes to the "wx_wxid" field.
  2779. func (m *ContactMutation) ResetWxWxid() {
  2780. m.wx_wxid = nil
  2781. delete(m.clearedFields, contact.FieldWxWxid)
  2782. }
  2783. // SetType sets the "type" field.
  2784. func (m *ContactMutation) SetType(i int) {
  2785. m._type = &i
  2786. m.add_type = nil
  2787. }
  2788. // GetType returns the value of the "type" field in the mutation.
  2789. func (m *ContactMutation) GetType() (r int, exists bool) {
  2790. v := m._type
  2791. if v == nil {
  2792. return
  2793. }
  2794. return *v, true
  2795. }
  2796. // OldType returns the old "type" field's value of the Contact entity.
  2797. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2799. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  2800. if !m.op.Is(OpUpdateOne) {
  2801. return v, errors.New("OldType is only allowed on UpdateOne operations")
  2802. }
  2803. if m.id == nil || m.oldValue == nil {
  2804. return v, errors.New("OldType requires an ID field in the mutation")
  2805. }
  2806. oldValue, err := m.oldValue(ctx)
  2807. if err != nil {
  2808. return v, fmt.Errorf("querying old value for OldType: %w", err)
  2809. }
  2810. return oldValue.Type, nil
  2811. }
  2812. // AddType adds i to the "type" field.
  2813. func (m *ContactMutation) AddType(i int) {
  2814. if m.add_type != nil {
  2815. *m.add_type += i
  2816. } else {
  2817. m.add_type = &i
  2818. }
  2819. }
  2820. // AddedType returns the value that was added to the "type" field in this mutation.
  2821. func (m *ContactMutation) AddedType() (r int, exists bool) {
  2822. v := m.add_type
  2823. if v == nil {
  2824. return
  2825. }
  2826. return *v, true
  2827. }
  2828. // ClearType clears the value of the "type" field.
  2829. func (m *ContactMutation) ClearType() {
  2830. m._type = nil
  2831. m.add_type = nil
  2832. m.clearedFields[contact.FieldType] = struct{}{}
  2833. }
  2834. // TypeCleared returns if the "type" field was cleared in this mutation.
  2835. func (m *ContactMutation) TypeCleared() bool {
  2836. _, ok := m.clearedFields[contact.FieldType]
  2837. return ok
  2838. }
  2839. // ResetType resets all changes to the "type" field.
  2840. func (m *ContactMutation) ResetType() {
  2841. m._type = nil
  2842. m.add_type = nil
  2843. delete(m.clearedFields, contact.FieldType)
  2844. }
  2845. // SetWxid sets the "wxid" field.
  2846. func (m *ContactMutation) SetWxid(s string) {
  2847. m.wxid = &s
  2848. }
  2849. // Wxid returns the value of the "wxid" field in the mutation.
  2850. func (m *ContactMutation) Wxid() (r string, exists bool) {
  2851. v := m.wxid
  2852. if v == nil {
  2853. return
  2854. }
  2855. return *v, true
  2856. }
  2857. // OldWxid returns the old "wxid" field's value of the Contact entity.
  2858. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2860. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  2861. if !m.op.Is(OpUpdateOne) {
  2862. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  2863. }
  2864. if m.id == nil || m.oldValue == nil {
  2865. return v, errors.New("OldWxid requires an ID field in the mutation")
  2866. }
  2867. oldValue, err := m.oldValue(ctx)
  2868. if err != nil {
  2869. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  2870. }
  2871. return oldValue.Wxid, nil
  2872. }
  2873. // ResetWxid resets all changes to the "wxid" field.
  2874. func (m *ContactMutation) ResetWxid() {
  2875. m.wxid = nil
  2876. }
  2877. // SetAccount sets the "account" field.
  2878. func (m *ContactMutation) SetAccount(s string) {
  2879. m.account = &s
  2880. }
  2881. // Account returns the value of the "account" field in the mutation.
  2882. func (m *ContactMutation) Account() (r string, exists bool) {
  2883. v := m.account
  2884. if v == nil {
  2885. return
  2886. }
  2887. return *v, true
  2888. }
  2889. // OldAccount returns the old "account" field's value of the Contact entity.
  2890. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2892. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  2893. if !m.op.Is(OpUpdateOne) {
  2894. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  2895. }
  2896. if m.id == nil || m.oldValue == nil {
  2897. return v, errors.New("OldAccount requires an ID field in the mutation")
  2898. }
  2899. oldValue, err := m.oldValue(ctx)
  2900. if err != nil {
  2901. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  2902. }
  2903. return oldValue.Account, nil
  2904. }
  2905. // ResetAccount resets all changes to the "account" field.
  2906. func (m *ContactMutation) ResetAccount() {
  2907. m.account = nil
  2908. }
  2909. // SetNickname sets the "nickname" field.
  2910. func (m *ContactMutation) SetNickname(s string) {
  2911. m.nickname = &s
  2912. }
  2913. // Nickname returns the value of the "nickname" field in the mutation.
  2914. func (m *ContactMutation) Nickname() (r string, exists bool) {
  2915. v := m.nickname
  2916. if v == nil {
  2917. return
  2918. }
  2919. return *v, true
  2920. }
  2921. // OldNickname returns the old "nickname" field's value of the Contact entity.
  2922. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2924. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  2925. if !m.op.Is(OpUpdateOne) {
  2926. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  2927. }
  2928. if m.id == nil || m.oldValue == nil {
  2929. return v, errors.New("OldNickname requires an ID field in the mutation")
  2930. }
  2931. oldValue, err := m.oldValue(ctx)
  2932. if err != nil {
  2933. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  2934. }
  2935. return oldValue.Nickname, nil
  2936. }
  2937. // ResetNickname resets all changes to the "nickname" field.
  2938. func (m *ContactMutation) ResetNickname() {
  2939. m.nickname = nil
  2940. }
  2941. // SetMarkname sets the "markname" field.
  2942. func (m *ContactMutation) SetMarkname(s string) {
  2943. m.markname = &s
  2944. }
  2945. // Markname returns the value of the "markname" field in the mutation.
  2946. func (m *ContactMutation) Markname() (r string, exists bool) {
  2947. v := m.markname
  2948. if v == nil {
  2949. return
  2950. }
  2951. return *v, true
  2952. }
  2953. // OldMarkname returns the old "markname" field's value of the Contact entity.
  2954. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2956. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  2957. if !m.op.Is(OpUpdateOne) {
  2958. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  2959. }
  2960. if m.id == nil || m.oldValue == nil {
  2961. return v, errors.New("OldMarkname requires an ID field in the mutation")
  2962. }
  2963. oldValue, err := m.oldValue(ctx)
  2964. if err != nil {
  2965. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  2966. }
  2967. return oldValue.Markname, nil
  2968. }
  2969. // ResetMarkname resets all changes to the "markname" field.
  2970. func (m *ContactMutation) ResetMarkname() {
  2971. m.markname = nil
  2972. }
  2973. // SetHeadimg sets the "headimg" field.
  2974. func (m *ContactMutation) SetHeadimg(s string) {
  2975. m.headimg = &s
  2976. }
  2977. // Headimg returns the value of the "headimg" field in the mutation.
  2978. func (m *ContactMutation) Headimg() (r string, exists bool) {
  2979. v := m.headimg
  2980. if v == nil {
  2981. return
  2982. }
  2983. return *v, true
  2984. }
  2985. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  2986. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2988. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  2989. if !m.op.Is(OpUpdateOne) {
  2990. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  2991. }
  2992. if m.id == nil || m.oldValue == nil {
  2993. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  2994. }
  2995. oldValue, err := m.oldValue(ctx)
  2996. if err != nil {
  2997. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  2998. }
  2999. return oldValue.Headimg, nil
  3000. }
  3001. // ResetHeadimg resets all changes to the "headimg" field.
  3002. func (m *ContactMutation) ResetHeadimg() {
  3003. m.headimg = nil
  3004. }
  3005. // SetSex sets the "sex" field.
  3006. func (m *ContactMutation) SetSex(i int) {
  3007. m.sex = &i
  3008. m.addsex = nil
  3009. }
  3010. // Sex returns the value of the "sex" field in the mutation.
  3011. func (m *ContactMutation) Sex() (r int, exists bool) {
  3012. v := m.sex
  3013. if v == nil {
  3014. return
  3015. }
  3016. return *v, true
  3017. }
  3018. // OldSex returns the old "sex" field's value of the Contact entity.
  3019. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3021. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  3022. if !m.op.Is(OpUpdateOne) {
  3023. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  3024. }
  3025. if m.id == nil || m.oldValue == nil {
  3026. return v, errors.New("OldSex requires an ID field in the mutation")
  3027. }
  3028. oldValue, err := m.oldValue(ctx)
  3029. if err != nil {
  3030. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  3031. }
  3032. return oldValue.Sex, nil
  3033. }
  3034. // AddSex adds i to the "sex" field.
  3035. func (m *ContactMutation) AddSex(i int) {
  3036. if m.addsex != nil {
  3037. *m.addsex += i
  3038. } else {
  3039. m.addsex = &i
  3040. }
  3041. }
  3042. // AddedSex returns the value that was added to the "sex" field in this mutation.
  3043. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  3044. v := m.addsex
  3045. if v == nil {
  3046. return
  3047. }
  3048. return *v, true
  3049. }
  3050. // ResetSex resets all changes to the "sex" field.
  3051. func (m *ContactMutation) ResetSex() {
  3052. m.sex = nil
  3053. m.addsex = nil
  3054. }
  3055. // SetStarrole sets the "starrole" field.
  3056. func (m *ContactMutation) SetStarrole(s string) {
  3057. m.starrole = &s
  3058. }
  3059. // Starrole returns the value of the "starrole" field in the mutation.
  3060. func (m *ContactMutation) Starrole() (r string, exists bool) {
  3061. v := m.starrole
  3062. if v == nil {
  3063. return
  3064. }
  3065. return *v, true
  3066. }
  3067. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  3068. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3069. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3070. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  3071. if !m.op.Is(OpUpdateOne) {
  3072. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  3073. }
  3074. if m.id == nil || m.oldValue == nil {
  3075. return v, errors.New("OldStarrole requires an ID field in the mutation")
  3076. }
  3077. oldValue, err := m.oldValue(ctx)
  3078. if err != nil {
  3079. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  3080. }
  3081. return oldValue.Starrole, nil
  3082. }
  3083. // ResetStarrole resets all changes to the "starrole" field.
  3084. func (m *ContactMutation) ResetStarrole() {
  3085. m.starrole = nil
  3086. }
  3087. // SetDontseeit sets the "dontseeit" field.
  3088. func (m *ContactMutation) SetDontseeit(i int) {
  3089. m.dontseeit = &i
  3090. m.adddontseeit = nil
  3091. }
  3092. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  3093. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  3094. v := m.dontseeit
  3095. if v == nil {
  3096. return
  3097. }
  3098. return *v, true
  3099. }
  3100. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  3101. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3103. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  3104. if !m.op.Is(OpUpdateOne) {
  3105. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  3106. }
  3107. if m.id == nil || m.oldValue == nil {
  3108. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  3109. }
  3110. oldValue, err := m.oldValue(ctx)
  3111. if err != nil {
  3112. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  3113. }
  3114. return oldValue.Dontseeit, nil
  3115. }
  3116. // AddDontseeit adds i to the "dontseeit" field.
  3117. func (m *ContactMutation) AddDontseeit(i int) {
  3118. if m.adddontseeit != nil {
  3119. *m.adddontseeit += i
  3120. } else {
  3121. m.adddontseeit = &i
  3122. }
  3123. }
  3124. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  3125. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  3126. v := m.adddontseeit
  3127. if v == nil {
  3128. return
  3129. }
  3130. return *v, true
  3131. }
  3132. // ResetDontseeit resets all changes to the "dontseeit" field.
  3133. func (m *ContactMutation) ResetDontseeit() {
  3134. m.dontseeit = nil
  3135. m.adddontseeit = nil
  3136. }
  3137. // SetDontseeme sets the "dontseeme" field.
  3138. func (m *ContactMutation) SetDontseeme(i int) {
  3139. m.dontseeme = &i
  3140. m.adddontseeme = nil
  3141. }
  3142. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  3143. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  3144. v := m.dontseeme
  3145. if v == nil {
  3146. return
  3147. }
  3148. return *v, true
  3149. }
  3150. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  3151. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3153. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  3154. if !m.op.Is(OpUpdateOne) {
  3155. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  3156. }
  3157. if m.id == nil || m.oldValue == nil {
  3158. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  3159. }
  3160. oldValue, err := m.oldValue(ctx)
  3161. if err != nil {
  3162. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  3163. }
  3164. return oldValue.Dontseeme, nil
  3165. }
  3166. // AddDontseeme adds i to the "dontseeme" field.
  3167. func (m *ContactMutation) AddDontseeme(i int) {
  3168. if m.adddontseeme != nil {
  3169. *m.adddontseeme += i
  3170. } else {
  3171. m.adddontseeme = &i
  3172. }
  3173. }
  3174. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  3175. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  3176. v := m.adddontseeme
  3177. if v == nil {
  3178. return
  3179. }
  3180. return *v, true
  3181. }
  3182. // ResetDontseeme resets all changes to the "dontseeme" field.
  3183. func (m *ContactMutation) ResetDontseeme() {
  3184. m.dontseeme = nil
  3185. m.adddontseeme = nil
  3186. }
  3187. // SetLag sets the "lag" field.
  3188. func (m *ContactMutation) SetLag(s string) {
  3189. m.lag = &s
  3190. }
  3191. // Lag returns the value of the "lag" field in the mutation.
  3192. func (m *ContactMutation) Lag() (r string, exists bool) {
  3193. v := m.lag
  3194. if v == nil {
  3195. return
  3196. }
  3197. return *v, true
  3198. }
  3199. // OldLag returns the old "lag" field's value of the Contact entity.
  3200. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3202. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  3203. if !m.op.Is(OpUpdateOne) {
  3204. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  3205. }
  3206. if m.id == nil || m.oldValue == nil {
  3207. return v, errors.New("OldLag requires an ID field in the mutation")
  3208. }
  3209. oldValue, err := m.oldValue(ctx)
  3210. if err != nil {
  3211. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  3212. }
  3213. return oldValue.Lag, nil
  3214. }
  3215. // ResetLag resets all changes to the "lag" field.
  3216. func (m *ContactMutation) ResetLag() {
  3217. m.lag = nil
  3218. }
  3219. // SetGid sets the "gid" field.
  3220. func (m *ContactMutation) SetGid(s string) {
  3221. m.gid = &s
  3222. }
  3223. // Gid returns the value of the "gid" field in the mutation.
  3224. func (m *ContactMutation) Gid() (r string, exists bool) {
  3225. v := m.gid
  3226. if v == nil {
  3227. return
  3228. }
  3229. return *v, true
  3230. }
  3231. // OldGid returns the old "gid" field's value of the Contact entity.
  3232. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3234. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  3235. if !m.op.Is(OpUpdateOne) {
  3236. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  3237. }
  3238. if m.id == nil || m.oldValue == nil {
  3239. return v, errors.New("OldGid requires an ID field in the mutation")
  3240. }
  3241. oldValue, err := m.oldValue(ctx)
  3242. if err != nil {
  3243. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  3244. }
  3245. return oldValue.Gid, nil
  3246. }
  3247. // ResetGid resets all changes to the "gid" field.
  3248. func (m *ContactMutation) ResetGid() {
  3249. m.gid = nil
  3250. }
  3251. // SetGname sets the "gname" field.
  3252. func (m *ContactMutation) SetGname(s string) {
  3253. m.gname = &s
  3254. }
  3255. // Gname returns the value of the "gname" field in the mutation.
  3256. func (m *ContactMutation) Gname() (r string, exists bool) {
  3257. v := m.gname
  3258. if v == nil {
  3259. return
  3260. }
  3261. return *v, true
  3262. }
  3263. // OldGname returns the old "gname" field's value of the Contact entity.
  3264. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3266. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  3267. if !m.op.Is(OpUpdateOne) {
  3268. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  3269. }
  3270. if m.id == nil || m.oldValue == nil {
  3271. return v, errors.New("OldGname requires an ID field in the mutation")
  3272. }
  3273. oldValue, err := m.oldValue(ctx)
  3274. if err != nil {
  3275. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  3276. }
  3277. return oldValue.Gname, nil
  3278. }
  3279. // ResetGname resets all changes to the "gname" field.
  3280. func (m *ContactMutation) ResetGname() {
  3281. m.gname = nil
  3282. }
  3283. // SetV3 sets the "v3" field.
  3284. func (m *ContactMutation) SetV3(s string) {
  3285. m.v3 = &s
  3286. }
  3287. // V3 returns the value of the "v3" field in the mutation.
  3288. func (m *ContactMutation) V3() (r string, exists bool) {
  3289. v := m.v3
  3290. if v == nil {
  3291. return
  3292. }
  3293. return *v, true
  3294. }
  3295. // OldV3 returns the old "v3" field's value of the Contact entity.
  3296. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3298. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  3299. if !m.op.Is(OpUpdateOne) {
  3300. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  3301. }
  3302. if m.id == nil || m.oldValue == nil {
  3303. return v, errors.New("OldV3 requires an ID field in the mutation")
  3304. }
  3305. oldValue, err := m.oldValue(ctx)
  3306. if err != nil {
  3307. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  3308. }
  3309. return oldValue.V3, nil
  3310. }
  3311. // ResetV3 resets all changes to the "v3" field.
  3312. func (m *ContactMutation) ResetV3() {
  3313. m.v3 = nil
  3314. }
  3315. // SetOrganizationID sets the "organization_id" field.
  3316. func (m *ContactMutation) SetOrganizationID(u uint64) {
  3317. m.organization_id = &u
  3318. m.addorganization_id = nil
  3319. }
  3320. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3321. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  3322. v := m.organization_id
  3323. if v == nil {
  3324. return
  3325. }
  3326. return *v, true
  3327. }
  3328. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  3329. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3331. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3332. if !m.op.Is(OpUpdateOne) {
  3333. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3334. }
  3335. if m.id == nil || m.oldValue == nil {
  3336. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3337. }
  3338. oldValue, err := m.oldValue(ctx)
  3339. if err != nil {
  3340. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3341. }
  3342. return oldValue.OrganizationID, nil
  3343. }
  3344. // AddOrganizationID adds u to the "organization_id" field.
  3345. func (m *ContactMutation) AddOrganizationID(u int64) {
  3346. if m.addorganization_id != nil {
  3347. *m.addorganization_id += u
  3348. } else {
  3349. m.addorganization_id = &u
  3350. }
  3351. }
  3352. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3353. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  3354. v := m.addorganization_id
  3355. if v == nil {
  3356. return
  3357. }
  3358. return *v, true
  3359. }
  3360. // ClearOrganizationID clears the value of the "organization_id" field.
  3361. func (m *ContactMutation) ClearOrganizationID() {
  3362. m.organization_id = nil
  3363. m.addorganization_id = nil
  3364. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  3365. }
  3366. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3367. func (m *ContactMutation) OrganizationIDCleared() bool {
  3368. _, ok := m.clearedFields[contact.FieldOrganizationID]
  3369. return ok
  3370. }
  3371. // ResetOrganizationID resets all changes to the "organization_id" field.
  3372. func (m *ContactMutation) ResetOrganizationID() {
  3373. m.organization_id = nil
  3374. m.addorganization_id = nil
  3375. delete(m.clearedFields, contact.FieldOrganizationID)
  3376. }
  3377. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  3378. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  3379. if m.contact_relationships == nil {
  3380. m.contact_relationships = make(map[uint64]struct{})
  3381. }
  3382. for i := range ids {
  3383. m.contact_relationships[ids[i]] = struct{}{}
  3384. }
  3385. }
  3386. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  3387. func (m *ContactMutation) ClearContactRelationships() {
  3388. m.clearedcontact_relationships = true
  3389. }
  3390. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  3391. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  3392. return m.clearedcontact_relationships
  3393. }
  3394. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  3395. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  3396. if m.removedcontact_relationships == nil {
  3397. m.removedcontact_relationships = make(map[uint64]struct{})
  3398. }
  3399. for i := range ids {
  3400. delete(m.contact_relationships, ids[i])
  3401. m.removedcontact_relationships[ids[i]] = struct{}{}
  3402. }
  3403. }
  3404. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  3405. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  3406. for id := range m.removedcontact_relationships {
  3407. ids = append(ids, id)
  3408. }
  3409. return
  3410. }
  3411. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  3412. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  3413. for id := range m.contact_relationships {
  3414. ids = append(ids, id)
  3415. }
  3416. return
  3417. }
  3418. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  3419. func (m *ContactMutation) ResetContactRelationships() {
  3420. m.contact_relationships = nil
  3421. m.clearedcontact_relationships = false
  3422. m.removedcontact_relationships = nil
  3423. }
  3424. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  3425. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  3426. if m.contact_messages == nil {
  3427. m.contact_messages = make(map[uint64]struct{})
  3428. }
  3429. for i := range ids {
  3430. m.contact_messages[ids[i]] = struct{}{}
  3431. }
  3432. }
  3433. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  3434. func (m *ContactMutation) ClearContactMessages() {
  3435. m.clearedcontact_messages = true
  3436. }
  3437. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  3438. func (m *ContactMutation) ContactMessagesCleared() bool {
  3439. return m.clearedcontact_messages
  3440. }
  3441. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  3442. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  3443. if m.removedcontact_messages == nil {
  3444. m.removedcontact_messages = make(map[uint64]struct{})
  3445. }
  3446. for i := range ids {
  3447. delete(m.contact_messages, ids[i])
  3448. m.removedcontact_messages[ids[i]] = struct{}{}
  3449. }
  3450. }
  3451. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  3452. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  3453. for id := range m.removedcontact_messages {
  3454. ids = append(ids, id)
  3455. }
  3456. return
  3457. }
  3458. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  3459. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  3460. for id := range m.contact_messages {
  3461. ids = append(ids, id)
  3462. }
  3463. return
  3464. }
  3465. // ResetContactMessages resets all changes to the "contact_messages" edge.
  3466. func (m *ContactMutation) ResetContactMessages() {
  3467. m.contact_messages = nil
  3468. m.clearedcontact_messages = false
  3469. m.removedcontact_messages = nil
  3470. }
  3471. // Where appends a list predicates to the ContactMutation builder.
  3472. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  3473. m.predicates = append(m.predicates, ps...)
  3474. }
  3475. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  3476. // users can use type-assertion to append predicates that do not depend on any generated package.
  3477. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  3478. p := make([]predicate.Contact, len(ps))
  3479. for i := range ps {
  3480. p[i] = ps[i]
  3481. }
  3482. m.Where(p...)
  3483. }
  3484. // Op returns the operation name.
  3485. func (m *ContactMutation) Op() Op {
  3486. return m.op
  3487. }
  3488. // SetOp allows setting the mutation operation.
  3489. func (m *ContactMutation) SetOp(op Op) {
  3490. m.op = op
  3491. }
  3492. // Type returns the node type of this mutation (Contact).
  3493. func (m *ContactMutation) Type() string {
  3494. return m.typ
  3495. }
  3496. // Fields returns all fields that were changed during this mutation. Note that in
  3497. // order to get all numeric fields that were incremented/decremented, call
  3498. // AddedFields().
  3499. func (m *ContactMutation) Fields() []string {
  3500. fields := make([]string, 0, 20)
  3501. if m.created_at != nil {
  3502. fields = append(fields, contact.FieldCreatedAt)
  3503. }
  3504. if m.updated_at != nil {
  3505. fields = append(fields, contact.FieldUpdatedAt)
  3506. }
  3507. if m.status != nil {
  3508. fields = append(fields, contact.FieldStatus)
  3509. }
  3510. if m.deleted_at != nil {
  3511. fields = append(fields, contact.FieldDeletedAt)
  3512. }
  3513. if m.wx_wxid != nil {
  3514. fields = append(fields, contact.FieldWxWxid)
  3515. }
  3516. if m._type != nil {
  3517. fields = append(fields, contact.FieldType)
  3518. }
  3519. if m.wxid != nil {
  3520. fields = append(fields, contact.FieldWxid)
  3521. }
  3522. if m.account != nil {
  3523. fields = append(fields, contact.FieldAccount)
  3524. }
  3525. if m.nickname != nil {
  3526. fields = append(fields, contact.FieldNickname)
  3527. }
  3528. if m.markname != nil {
  3529. fields = append(fields, contact.FieldMarkname)
  3530. }
  3531. if m.headimg != nil {
  3532. fields = append(fields, contact.FieldHeadimg)
  3533. }
  3534. if m.sex != nil {
  3535. fields = append(fields, contact.FieldSex)
  3536. }
  3537. if m.starrole != nil {
  3538. fields = append(fields, contact.FieldStarrole)
  3539. }
  3540. if m.dontseeit != nil {
  3541. fields = append(fields, contact.FieldDontseeit)
  3542. }
  3543. if m.dontseeme != nil {
  3544. fields = append(fields, contact.FieldDontseeme)
  3545. }
  3546. if m.lag != nil {
  3547. fields = append(fields, contact.FieldLag)
  3548. }
  3549. if m.gid != nil {
  3550. fields = append(fields, contact.FieldGid)
  3551. }
  3552. if m.gname != nil {
  3553. fields = append(fields, contact.FieldGname)
  3554. }
  3555. if m.v3 != nil {
  3556. fields = append(fields, contact.FieldV3)
  3557. }
  3558. if m.organization_id != nil {
  3559. fields = append(fields, contact.FieldOrganizationID)
  3560. }
  3561. return fields
  3562. }
  3563. // Field returns the value of a field with the given name. The second boolean
  3564. // return value indicates that this field was not set, or was not defined in the
  3565. // schema.
  3566. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  3567. switch name {
  3568. case contact.FieldCreatedAt:
  3569. return m.CreatedAt()
  3570. case contact.FieldUpdatedAt:
  3571. return m.UpdatedAt()
  3572. case contact.FieldStatus:
  3573. return m.Status()
  3574. case contact.FieldDeletedAt:
  3575. return m.DeletedAt()
  3576. case contact.FieldWxWxid:
  3577. return m.WxWxid()
  3578. case contact.FieldType:
  3579. return m.GetType()
  3580. case contact.FieldWxid:
  3581. return m.Wxid()
  3582. case contact.FieldAccount:
  3583. return m.Account()
  3584. case contact.FieldNickname:
  3585. return m.Nickname()
  3586. case contact.FieldMarkname:
  3587. return m.Markname()
  3588. case contact.FieldHeadimg:
  3589. return m.Headimg()
  3590. case contact.FieldSex:
  3591. return m.Sex()
  3592. case contact.FieldStarrole:
  3593. return m.Starrole()
  3594. case contact.FieldDontseeit:
  3595. return m.Dontseeit()
  3596. case contact.FieldDontseeme:
  3597. return m.Dontseeme()
  3598. case contact.FieldLag:
  3599. return m.Lag()
  3600. case contact.FieldGid:
  3601. return m.Gid()
  3602. case contact.FieldGname:
  3603. return m.Gname()
  3604. case contact.FieldV3:
  3605. return m.V3()
  3606. case contact.FieldOrganizationID:
  3607. return m.OrganizationID()
  3608. }
  3609. return nil, false
  3610. }
  3611. // OldField returns the old value of the field from the database. An error is
  3612. // returned if the mutation operation is not UpdateOne, or the query to the
  3613. // database failed.
  3614. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3615. switch name {
  3616. case contact.FieldCreatedAt:
  3617. return m.OldCreatedAt(ctx)
  3618. case contact.FieldUpdatedAt:
  3619. return m.OldUpdatedAt(ctx)
  3620. case contact.FieldStatus:
  3621. return m.OldStatus(ctx)
  3622. case contact.FieldDeletedAt:
  3623. return m.OldDeletedAt(ctx)
  3624. case contact.FieldWxWxid:
  3625. return m.OldWxWxid(ctx)
  3626. case contact.FieldType:
  3627. return m.OldType(ctx)
  3628. case contact.FieldWxid:
  3629. return m.OldWxid(ctx)
  3630. case contact.FieldAccount:
  3631. return m.OldAccount(ctx)
  3632. case contact.FieldNickname:
  3633. return m.OldNickname(ctx)
  3634. case contact.FieldMarkname:
  3635. return m.OldMarkname(ctx)
  3636. case contact.FieldHeadimg:
  3637. return m.OldHeadimg(ctx)
  3638. case contact.FieldSex:
  3639. return m.OldSex(ctx)
  3640. case contact.FieldStarrole:
  3641. return m.OldStarrole(ctx)
  3642. case contact.FieldDontseeit:
  3643. return m.OldDontseeit(ctx)
  3644. case contact.FieldDontseeme:
  3645. return m.OldDontseeme(ctx)
  3646. case contact.FieldLag:
  3647. return m.OldLag(ctx)
  3648. case contact.FieldGid:
  3649. return m.OldGid(ctx)
  3650. case contact.FieldGname:
  3651. return m.OldGname(ctx)
  3652. case contact.FieldV3:
  3653. return m.OldV3(ctx)
  3654. case contact.FieldOrganizationID:
  3655. return m.OldOrganizationID(ctx)
  3656. }
  3657. return nil, fmt.Errorf("unknown Contact field %s", name)
  3658. }
  3659. // SetField sets the value of a field with the given name. It returns an error if
  3660. // the field is not defined in the schema, or if the type mismatched the field
  3661. // type.
  3662. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  3663. switch name {
  3664. case contact.FieldCreatedAt:
  3665. v, ok := value.(time.Time)
  3666. if !ok {
  3667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3668. }
  3669. m.SetCreatedAt(v)
  3670. return nil
  3671. case contact.FieldUpdatedAt:
  3672. v, ok := value.(time.Time)
  3673. if !ok {
  3674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3675. }
  3676. m.SetUpdatedAt(v)
  3677. return nil
  3678. case contact.FieldStatus:
  3679. v, ok := value.(uint8)
  3680. if !ok {
  3681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3682. }
  3683. m.SetStatus(v)
  3684. return nil
  3685. case contact.FieldDeletedAt:
  3686. v, ok := value.(time.Time)
  3687. if !ok {
  3688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3689. }
  3690. m.SetDeletedAt(v)
  3691. return nil
  3692. case contact.FieldWxWxid:
  3693. v, ok := value.(string)
  3694. if !ok {
  3695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3696. }
  3697. m.SetWxWxid(v)
  3698. return nil
  3699. case contact.FieldType:
  3700. v, ok := value.(int)
  3701. if !ok {
  3702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3703. }
  3704. m.SetType(v)
  3705. return nil
  3706. case contact.FieldWxid:
  3707. v, ok := value.(string)
  3708. if !ok {
  3709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3710. }
  3711. m.SetWxid(v)
  3712. return nil
  3713. case contact.FieldAccount:
  3714. v, ok := value.(string)
  3715. if !ok {
  3716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3717. }
  3718. m.SetAccount(v)
  3719. return nil
  3720. case contact.FieldNickname:
  3721. v, ok := value.(string)
  3722. if !ok {
  3723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3724. }
  3725. m.SetNickname(v)
  3726. return nil
  3727. case contact.FieldMarkname:
  3728. v, ok := value.(string)
  3729. if !ok {
  3730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3731. }
  3732. m.SetMarkname(v)
  3733. return nil
  3734. case contact.FieldHeadimg:
  3735. v, ok := value.(string)
  3736. if !ok {
  3737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3738. }
  3739. m.SetHeadimg(v)
  3740. return nil
  3741. case contact.FieldSex:
  3742. v, ok := value.(int)
  3743. if !ok {
  3744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3745. }
  3746. m.SetSex(v)
  3747. return nil
  3748. case contact.FieldStarrole:
  3749. v, ok := value.(string)
  3750. if !ok {
  3751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3752. }
  3753. m.SetStarrole(v)
  3754. return nil
  3755. case contact.FieldDontseeit:
  3756. v, ok := value.(int)
  3757. if !ok {
  3758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3759. }
  3760. m.SetDontseeit(v)
  3761. return nil
  3762. case contact.FieldDontseeme:
  3763. v, ok := value.(int)
  3764. if !ok {
  3765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3766. }
  3767. m.SetDontseeme(v)
  3768. return nil
  3769. case contact.FieldLag:
  3770. v, ok := value.(string)
  3771. if !ok {
  3772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3773. }
  3774. m.SetLag(v)
  3775. return nil
  3776. case contact.FieldGid:
  3777. v, ok := value.(string)
  3778. if !ok {
  3779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3780. }
  3781. m.SetGid(v)
  3782. return nil
  3783. case contact.FieldGname:
  3784. v, ok := value.(string)
  3785. if !ok {
  3786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3787. }
  3788. m.SetGname(v)
  3789. return nil
  3790. case contact.FieldV3:
  3791. v, ok := value.(string)
  3792. if !ok {
  3793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3794. }
  3795. m.SetV3(v)
  3796. return nil
  3797. case contact.FieldOrganizationID:
  3798. v, ok := value.(uint64)
  3799. if !ok {
  3800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3801. }
  3802. m.SetOrganizationID(v)
  3803. return nil
  3804. }
  3805. return fmt.Errorf("unknown Contact field %s", name)
  3806. }
  3807. // AddedFields returns all numeric fields that were incremented/decremented during
  3808. // this mutation.
  3809. func (m *ContactMutation) AddedFields() []string {
  3810. var fields []string
  3811. if m.addstatus != nil {
  3812. fields = append(fields, contact.FieldStatus)
  3813. }
  3814. if m.add_type != nil {
  3815. fields = append(fields, contact.FieldType)
  3816. }
  3817. if m.addsex != nil {
  3818. fields = append(fields, contact.FieldSex)
  3819. }
  3820. if m.adddontseeit != nil {
  3821. fields = append(fields, contact.FieldDontseeit)
  3822. }
  3823. if m.adddontseeme != nil {
  3824. fields = append(fields, contact.FieldDontseeme)
  3825. }
  3826. if m.addorganization_id != nil {
  3827. fields = append(fields, contact.FieldOrganizationID)
  3828. }
  3829. return fields
  3830. }
  3831. // AddedField returns the numeric value that was incremented/decremented on a field
  3832. // with the given name. The second boolean return value indicates that this field
  3833. // was not set, or was not defined in the schema.
  3834. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  3835. switch name {
  3836. case contact.FieldStatus:
  3837. return m.AddedStatus()
  3838. case contact.FieldType:
  3839. return m.AddedType()
  3840. case contact.FieldSex:
  3841. return m.AddedSex()
  3842. case contact.FieldDontseeit:
  3843. return m.AddedDontseeit()
  3844. case contact.FieldDontseeme:
  3845. return m.AddedDontseeme()
  3846. case contact.FieldOrganizationID:
  3847. return m.AddedOrganizationID()
  3848. }
  3849. return nil, false
  3850. }
  3851. // AddField adds the value to the field with the given name. It returns an error if
  3852. // the field is not defined in the schema, or if the type mismatched the field
  3853. // type.
  3854. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  3855. switch name {
  3856. case contact.FieldStatus:
  3857. v, ok := value.(int8)
  3858. if !ok {
  3859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3860. }
  3861. m.AddStatus(v)
  3862. return nil
  3863. case contact.FieldType:
  3864. v, ok := value.(int)
  3865. if !ok {
  3866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3867. }
  3868. m.AddType(v)
  3869. return nil
  3870. case contact.FieldSex:
  3871. v, ok := value.(int)
  3872. if !ok {
  3873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3874. }
  3875. m.AddSex(v)
  3876. return nil
  3877. case contact.FieldDontseeit:
  3878. v, ok := value.(int)
  3879. if !ok {
  3880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3881. }
  3882. m.AddDontseeit(v)
  3883. return nil
  3884. case contact.FieldDontseeme:
  3885. v, ok := value.(int)
  3886. if !ok {
  3887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3888. }
  3889. m.AddDontseeme(v)
  3890. return nil
  3891. case contact.FieldOrganizationID:
  3892. v, ok := value.(int64)
  3893. if !ok {
  3894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3895. }
  3896. m.AddOrganizationID(v)
  3897. return nil
  3898. }
  3899. return fmt.Errorf("unknown Contact numeric field %s", name)
  3900. }
  3901. // ClearedFields returns all nullable fields that were cleared during this
  3902. // mutation.
  3903. func (m *ContactMutation) ClearedFields() []string {
  3904. var fields []string
  3905. if m.FieldCleared(contact.FieldStatus) {
  3906. fields = append(fields, contact.FieldStatus)
  3907. }
  3908. if m.FieldCleared(contact.FieldDeletedAt) {
  3909. fields = append(fields, contact.FieldDeletedAt)
  3910. }
  3911. if m.FieldCleared(contact.FieldWxWxid) {
  3912. fields = append(fields, contact.FieldWxWxid)
  3913. }
  3914. if m.FieldCleared(contact.FieldType) {
  3915. fields = append(fields, contact.FieldType)
  3916. }
  3917. if m.FieldCleared(contact.FieldOrganizationID) {
  3918. fields = append(fields, contact.FieldOrganizationID)
  3919. }
  3920. return fields
  3921. }
  3922. // FieldCleared returns a boolean indicating if a field with the given name was
  3923. // cleared in this mutation.
  3924. func (m *ContactMutation) FieldCleared(name string) bool {
  3925. _, ok := m.clearedFields[name]
  3926. return ok
  3927. }
  3928. // ClearField clears the value of the field with the given name. It returns an
  3929. // error if the field is not defined in the schema.
  3930. func (m *ContactMutation) ClearField(name string) error {
  3931. switch name {
  3932. case contact.FieldStatus:
  3933. m.ClearStatus()
  3934. return nil
  3935. case contact.FieldDeletedAt:
  3936. m.ClearDeletedAt()
  3937. return nil
  3938. case contact.FieldWxWxid:
  3939. m.ClearWxWxid()
  3940. return nil
  3941. case contact.FieldType:
  3942. m.ClearType()
  3943. return nil
  3944. case contact.FieldOrganizationID:
  3945. m.ClearOrganizationID()
  3946. return nil
  3947. }
  3948. return fmt.Errorf("unknown Contact nullable field %s", name)
  3949. }
  3950. // ResetField resets all changes in the mutation for the field with the given name.
  3951. // It returns an error if the field is not defined in the schema.
  3952. func (m *ContactMutation) ResetField(name string) error {
  3953. switch name {
  3954. case contact.FieldCreatedAt:
  3955. m.ResetCreatedAt()
  3956. return nil
  3957. case contact.FieldUpdatedAt:
  3958. m.ResetUpdatedAt()
  3959. return nil
  3960. case contact.FieldStatus:
  3961. m.ResetStatus()
  3962. return nil
  3963. case contact.FieldDeletedAt:
  3964. m.ResetDeletedAt()
  3965. return nil
  3966. case contact.FieldWxWxid:
  3967. m.ResetWxWxid()
  3968. return nil
  3969. case contact.FieldType:
  3970. m.ResetType()
  3971. return nil
  3972. case contact.FieldWxid:
  3973. m.ResetWxid()
  3974. return nil
  3975. case contact.FieldAccount:
  3976. m.ResetAccount()
  3977. return nil
  3978. case contact.FieldNickname:
  3979. m.ResetNickname()
  3980. return nil
  3981. case contact.FieldMarkname:
  3982. m.ResetMarkname()
  3983. return nil
  3984. case contact.FieldHeadimg:
  3985. m.ResetHeadimg()
  3986. return nil
  3987. case contact.FieldSex:
  3988. m.ResetSex()
  3989. return nil
  3990. case contact.FieldStarrole:
  3991. m.ResetStarrole()
  3992. return nil
  3993. case contact.FieldDontseeit:
  3994. m.ResetDontseeit()
  3995. return nil
  3996. case contact.FieldDontseeme:
  3997. m.ResetDontseeme()
  3998. return nil
  3999. case contact.FieldLag:
  4000. m.ResetLag()
  4001. return nil
  4002. case contact.FieldGid:
  4003. m.ResetGid()
  4004. return nil
  4005. case contact.FieldGname:
  4006. m.ResetGname()
  4007. return nil
  4008. case contact.FieldV3:
  4009. m.ResetV3()
  4010. return nil
  4011. case contact.FieldOrganizationID:
  4012. m.ResetOrganizationID()
  4013. return nil
  4014. }
  4015. return fmt.Errorf("unknown Contact field %s", name)
  4016. }
  4017. // AddedEdges returns all edge names that were set/added in this mutation.
  4018. func (m *ContactMutation) AddedEdges() []string {
  4019. edges := make([]string, 0, 2)
  4020. if m.contact_relationships != nil {
  4021. edges = append(edges, contact.EdgeContactRelationships)
  4022. }
  4023. if m.contact_messages != nil {
  4024. edges = append(edges, contact.EdgeContactMessages)
  4025. }
  4026. return edges
  4027. }
  4028. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4029. // name in this mutation.
  4030. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  4031. switch name {
  4032. case contact.EdgeContactRelationships:
  4033. ids := make([]ent.Value, 0, len(m.contact_relationships))
  4034. for id := range m.contact_relationships {
  4035. ids = append(ids, id)
  4036. }
  4037. return ids
  4038. case contact.EdgeContactMessages:
  4039. ids := make([]ent.Value, 0, len(m.contact_messages))
  4040. for id := range m.contact_messages {
  4041. ids = append(ids, id)
  4042. }
  4043. return ids
  4044. }
  4045. return nil
  4046. }
  4047. // RemovedEdges returns all edge names that were removed in this mutation.
  4048. func (m *ContactMutation) RemovedEdges() []string {
  4049. edges := make([]string, 0, 2)
  4050. if m.removedcontact_relationships != nil {
  4051. edges = append(edges, contact.EdgeContactRelationships)
  4052. }
  4053. if m.removedcontact_messages != nil {
  4054. edges = append(edges, contact.EdgeContactMessages)
  4055. }
  4056. return edges
  4057. }
  4058. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4059. // the given name in this mutation.
  4060. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  4061. switch name {
  4062. case contact.EdgeContactRelationships:
  4063. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  4064. for id := range m.removedcontact_relationships {
  4065. ids = append(ids, id)
  4066. }
  4067. return ids
  4068. case contact.EdgeContactMessages:
  4069. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  4070. for id := range m.removedcontact_messages {
  4071. ids = append(ids, id)
  4072. }
  4073. return ids
  4074. }
  4075. return nil
  4076. }
  4077. // ClearedEdges returns all edge names that were cleared in this mutation.
  4078. func (m *ContactMutation) ClearedEdges() []string {
  4079. edges := make([]string, 0, 2)
  4080. if m.clearedcontact_relationships {
  4081. edges = append(edges, contact.EdgeContactRelationships)
  4082. }
  4083. if m.clearedcontact_messages {
  4084. edges = append(edges, contact.EdgeContactMessages)
  4085. }
  4086. return edges
  4087. }
  4088. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4089. // was cleared in this mutation.
  4090. func (m *ContactMutation) EdgeCleared(name string) bool {
  4091. switch name {
  4092. case contact.EdgeContactRelationships:
  4093. return m.clearedcontact_relationships
  4094. case contact.EdgeContactMessages:
  4095. return m.clearedcontact_messages
  4096. }
  4097. return false
  4098. }
  4099. // ClearEdge clears the value of the edge with the given name. It returns an error
  4100. // if that edge is not defined in the schema.
  4101. func (m *ContactMutation) ClearEdge(name string) error {
  4102. switch name {
  4103. }
  4104. return fmt.Errorf("unknown Contact unique edge %s", name)
  4105. }
  4106. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4107. // It returns an error if the edge is not defined in the schema.
  4108. func (m *ContactMutation) ResetEdge(name string) error {
  4109. switch name {
  4110. case contact.EdgeContactRelationships:
  4111. m.ResetContactRelationships()
  4112. return nil
  4113. case contact.EdgeContactMessages:
  4114. m.ResetContactMessages()
  4115. return nil
  4116. }
  4117. return fmt.Errorf("unknown Contact edge %s", name)
  4118. }
  4119. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  4120. type EmployeeMutation struct {
  4121. config
  4122. op Op
  4123. typ string
  4124. id *uint64
  4125. created_at *time.Time
  4126. updated_at *time.Time
  4127. deleted_at *time.Time
  4128. title *string
  4129. avatar *string
  4130. tags *string
  4131. hire_count *int
  4132. addhire_count *int
  4133. service_count *int
  4134. addservice_count *int
  4135. achievement_count *int
  4136. addachievement_count *int
  4137. intro *string
  4138. estimate *string
  4139. skill *string
  4140. ability_type *string
  4141. scene *string
  4142. switch_in *string
  4143. video_url *string
  4144. organization_id *uint64
  4145. addorganization_id *int64
  4146. clearedFields map[string]struct{}
  4147. em_work_experiences map[uint64]struct{}
  4148. removedem_work_experiences map[uint64]struct{}
  4149. clearedem_work_experiences bool
  4150. em_tutorial map[uint64]struct{}
  4151. removedem_tutorial map[uint64]struct{}
  4152. clearedem_tutorial bool
  4153. done bool
  4154. oldValue func(context.Context) (*Employee, error)
  4155. predicates []predicate.Employee
  4156. }
  4157. var _ ent.Mutation = (*EmployeeMutation)(nil)
  4158. // employeeOption allows management of the mutation configuration using functional options.
  4159. type employeeOption func(*EmployeeMutation)
  4160. // newEmployeeMutation creates new mutation for the Employee entity.
  4161. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  4162. m := &EmployeeMutation{
  4163. config: c,
  4164. op: op,
  4165. typ: TypeEmployee,
  4166. clearedFields: make(map[string]struct{}),
  4167. }
  4168. for _, opt := range opts {
  4169. opt(m)
  4170. }
  4171. return m
  4172. }
  4173. // withEmployeeID sets the ID field of the mutation.
  4174. func withEmployeeID(id uint64) employeeOption {
  4175. return func(m *EmployeeMutation) {
  4176. var (
  4177. err error
  4178. once sync.Once
  4179. value *Employee
  4180. )
  4181. m.oldValue = func(ctx context.Context) (*Employee, error) {
  4182. once.Do(func() {
  4183. if m.done {
  4184. err = errors.New("querying old values post mutation is not allowed")
  4185. } else {
  4186. value, err = m.Client().Employee.Get(ctx, id)
  4187. }
  4188. })
  4189. return value, err
  4190. }
  4191. m.id = &id
  4192. }
  4193. }
  4194. // withEmployee sets the old Employee of the mutation.
  4195. func withEmployee(node *Employee) employeeOption {
  4196. return func(m *EmployeeMutation) {
  4197. m.oldValue = func(context.Context) (*Employee, error) {
  4198. return node, nil
  4199. }
  4200. m.id = &node.ID
  4201. }
  4202. }
  4203. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4204. // executed in a transaction (ent.Tx), a transactional client is returned.
  4205. func (m EmployeeMutation) Client() *Client {
  4206. client := &Client{config: m.config}
  4207. client.init()
  4208. return client
  4209. }
  4210. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4211. // it returns an error otherwise.
  4212. func (m EmployeeMutation) Tx() (*Tx, error) {
  4213. if _, ok := m.driver.(*txDriver); !ok {
  4214. return nil, errors.New("ent: mutation is not running in a transaction")
  4215. }
  4216. tx := &Tx{config: m.config}
  4217. tx.init()
  4218. return tx, nil
  4219. }
  4220. // SetID sets the value of the id field. Note that this
  4221. // operation is only accepted on creation of Employee entities.
  4222. func (m *EmployeeMutation) SetID(id uint64) {
  4223. m.id = &id
  4224. }
  4225. // ID returns the ID value in the mutation. Note that the ID is only available
  4226. // if it was provided to the builder or after it was returned from the database.
  4227. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  4228. if m.id == nil {
  4229. return
  4230. }
  4231. return *m.id, true
  4232. }
  4233. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4234. // That means, if the mutation is applied within a transaction with an isolation level such
  4235. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4236. // or updated by the mutation.
  4237. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  4238. switch {
  4239. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4240. id, exists := m.ID()
  4241. if exists {
  4242. return []uint64{id}, nil
  4243. }
  4244. fallthrough
  4245. case m.op.Is(OpUpdate | OpDelete):
  4246. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  4247. default:
  4248. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4249. }
  4250. }
  4251. // SetCreatedAt sets the "created_at" field.
  4252. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  4253. m.created_at = &t
  4254. }
  4255. // CreatedAt returns the value of the "created_at" field in the mutation.
  4256. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  4257. v := m.created_at
  4258. if v == nil {
  4259. return
  4260. }
  4261. return *v, true
  4262. }
  4263. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  4264. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4266. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4267. if !m.op.Is(OpUpdateOne) {
  4268. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4269. }
  4270. if m.id == nil || m.oldValue == nil {
  4271. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4272. }
  4273. oldValue, err := m.oldValue(ctx)
  4274. if err != nil {
  4275. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4276. }
  4277. return oldValue.CreatedAt, nil
  4278. }
  4279. // ResetCreatedAt resets all changes to the "created_at" field.
  4280. func (m *EmployeeMutation) ResetCreatedAt() {
  4281. m.created_at = nil
  4282. }
  4283. // SetUpdatedAt sets the "updated_at" field.
  4284. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  4285. m.updated_at = &t
  4286. }
  4287. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4288. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  4289. v := m.updated_at
  4290. if v == nil {
  4291. return
  4292. }
  4293. return *v, true
  4294. }
  4295. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  4296. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4298. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4299. if !m.op.Is(OpUpdateOne) {
  4300. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4301. }
  4302. if m.id == nil || m.oldValue == nil {
  4303. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4304. }
  4305. oldValue, err := m.oldValue(ctx)
  4306. if err != nil {
  4307. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4308. }
  4309. return oldValue.UpdatedAt, nil
  4310. }
  4311. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4312. func (m *EmployeeMutation) ResetUpdatedAt() {
  4313. m.updated_at = nil
  4314. }
  4315. // SetDeletedAt sets the "deleted_at" field.
  4316. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  4317. m.deleted_at = &t
  4318. }
  4319. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4320. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  4321. v := m.deleted_at
  4322. if v == nil {
  4323. return
  4324. }
  4325. return *v, true
  4326. }
  4327. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  4328. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4330. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4331. if !m.op.Is(OpUpdateOne) {
  4332. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4333. }
  4334. if m.id == nil || m.oldValue == nil {
  4335. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4336. }
  4337. oldValue, err := m.oldValue(ctx)
  4338. if err != nil {
  4339. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4340. }
  4341. return oldValue.DeletedAt, nil
  4342. }
  4343. // ClearDeletedAt clears the value of the "deleted_at" field.
  4344. func (m *EmployeeMutation) ClearDeletedAt() {
  4345. m.deleted_at = nil
  4346. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  4347. }
  4348. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4349. func (m *EmployeeMutation) DeletedAtCleared() bool {
  4350. _, ok := m.clearedFields[employee.FieldDeletedAt]
  4351. return ok
  4352. }
  4353. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4354. func (m *EmployeeMutation) ResetDeletedAt() {
  4355. m.deleted_at = nil
  4356. delete(m.clearedFields, employee.FieldDeletedAt)
  4357. }
  4358. // SetTitle sets the "title" field.
  4359. func (m *EmployeeMutation) SetTitle(s string) {
  4360. m.title = &s
  4361. }
  4362. // Title returns the value of the "title" field in the mutation.
  4363. func (m *EmployeeMutation) Title() (r string, exists bool) {
  4364. v := m.title
  4365. if v == nil {
  4366. return
  4367. }
  4368. return *v, true
  4369. }
  4370. // OldTitle returns the old "title" field's value of the Employee entity.
  4371. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4372. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4373. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  4374. if !m.op.Is(OpUpdateOne) {
  4375. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4376. }
  4377. if m.id == nil || m.oldValue == nil {
  4378. return v, errors.New("OldTitle requires an ID field in the mutation")
  4379. }
  4380. oldValue, err := m.oldValue(ctx)
  4381. if err != nil {
  4382. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4383. }
  4384. return oldValue.Title, nil
  4385. }
  4386. // ResetTitle resets all changes to the "title" field.
  4387. func (m *EmployeeMutation) ResetTitle() {
  4388. m.title = nil
  4389. }
  4390. // SetAvatar sets the "avatar" field.
  4391. func (m *EmployeeMutation) SetAvatar(s string) {
  4392. m.avatar = &s
  4393. }
  4394. // Avatar returns the value of the "avatar" field in the mutation.
  4395. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  4396. v := m.avatar
  4397. if v == nil {
  4398. return
  4399. }
  4400. return *v, true
  4401. }
  4402. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  4403. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4405. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  4406. if !m.op.Is(OpUpdateOne) {
  4407. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  4408. }
  4409. if m.id == nil || m.oldValue == nil {
  4410. return v, errors.New("OldAvatar requires an ID field in the mutation")
  4411. }
  4412. oldValue, err := m.oldValue(ctx)
  4413. if err != nil {
  4414. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  4415. }
  4416. return oldValue.Avatar, nil
  4417. }
  4418. // ResetAvatar resets all changes to the "avatar" field.
  4419. func (m *EmployeeMutation) ResetAvatar() {
  4420. m.avatar = nil
  4421. }
  4422. // SetTags sets the "tags" field.
  4423. func (m *EmployeeMutation) SetTags(s string) {
  4424. m.tags = &s
  4425. }
  4426. // Tags returns the value of the "tags" field in the mutation.
  4427. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  4428. v := m.tags
  4429. if v == nil {
  4430. return
  4431. }
  4432. return *v, true
  4433. }
  4434. // OldTags returns the old "tags" field's value of the Employee entity.
  4435. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4437. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  4438. if !m.op.Is(OpUpdateOne) {
  4439. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  4440. }
  4441. if m.id == nil || m.oldValue == nil {
  4442. return v, errors.New("OldTags requires an ID field in the mutation")
  4443. }
  4444. oldValue, err := m.oldValue(ctx)
  4445. if err != nil {
  4446. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  4447. }
  4448. return oldValue.Tags, nil
  4449. }
  4450. // ResetTags resets all changes to the "tags" field.
  4451. func (m *EmployeeMutation) ResetTags() {
  4452. m.tags = nil
  4453. }
  4454. // SetHireCount sets the "hire_count" field.
  4455. func (m *EmployeeMutation) SetHireCount(i int) {
  4456. m.hire_count = &i
  4457. m.addhire_count = nil
  4458. }
  4459. // HireCount returns the value of the "hire_count" field in the mutation.
  4460. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  4461. v := m.hire_count
  4462. if v == nil {
  4463. return
  4464. }
  4465. return *v, true
  4466. }
  4467. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  4468. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4470. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  4471. if !m.op.Is(OpUpdateOne) {
  4472. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  4473. }
  4474. if m.id == nil || m.oldValue == nil {
  4475. return v, errors.New("OldHireCount requires an ID field in the mutation")
  4476. }
  4477. oldValue, err := m.oldValue(ctx)
  4478. if err != nil {
  4479. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  4480. }
  4481. return oldValue.HireCount, nil
  4482. }
  4483. // AddHireCount adds i to the "hire_count" field.
  4484. func (m *EmployeeMutation) AddHireCount(i int) {
  4485. if m.addhire_count != nil {
  4486. *m.addhire_count += i
  4487. } else {
  4488. m.addhire_count = &i
  4489. }
  4490. }
  4491. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  4492. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  4493. v := m.addhire_count
  4494. if v == nil {
  4495. return
  4496. }
  4497. return *v, true
  4498. }
  4499. // ResetHireCount resets all changes to the "hire_count" field.
  4500. func (m *EmployeeMutation) ResetHireCount() {
  4501. m.hire_count = nil
  4502. m.addhire_count = nil
  4503. }
  4504. // SetServiceCount sets the "service_count" field.
  4505. func (m *EmployeeMutation) SetServiceCount(i int) {
  4506. m.service_count = &i
  4507. m.addservice_count = nil
  4508. }
  4509. // ServiceCount returns the value of the "service_count" field in the mutation.
  4510. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  4511. v := m.service_count
  4512. if v == nil {
  4513. return
  4514. }
  4515. return *v, true
  4516. }
  4517. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  4518. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4520. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  4521. if !m.op.Is(OpUpdateOne) {
  4522. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  4523. }
  4524. if m.id == nil || m.oldValue == nil {
  4525. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  4526. }
  4527. oldValue, err := m.oldValue(ctx)
  4528. if err != nil {
  4529. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  4530. }
  4531. return oldValue.ServiceCount, nil
  4532. }
  4533. // AddServiceCount adds i to the "service_count" field.
  4534. func (m *EmployeeMutation) AddServiceCount(i int) {
  4535. if m.addservice_count != nil {
  4536. *m.addservice_count += i
  4537. } else {
  4538. m.addservice_count = &i
  4539. }
  4540. }
  4541. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  4542. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  4543. v := m.addservice_count
  4544. if v == nil {
  4545. return
  4546. }
  4547. return *v, true
  4548. }
  4549. // ResetServiceCount resets all changes to the "service_count" field.
  4550. func (m *EmployeeMutation) ResetServiceCount() {
  4551. m.service_count = nil
  4552. m.addservice_count = nil
  4553. }
  4554. // SetAchievementCount sets the "achievement_count" field.
  4555. func (m *EmployeeMutation) SetAchievementCount(i int) {
  4556. m.achievement_count = &i
  4557. m.addachievement_count = nil
  4558. }
  4559. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  4560. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  4561. v := m.achievement_count
  4562. if v == nil {
  4563. return
  4564. }
  4565. return *v, true
  4566. }
  4567. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  4568. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4569. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4570. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  4571. if !m.op.Is(OpUpdateOne) {
  4572. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  4573. }
  4574. if m.id == nil || m.oldValue == nil {
  4575. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  4576. }
  4577. oldValue, err := m.oldValue(ctx)
  4578. if err != nil {
  4579. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  4580. }
  4581. return oldValue.AchievementCount, nil
  4582. }
  4583. // AddAchievementCount adds i to the "achievement_count" field.
  4584. func (m *EmployeeMutation) AddAchievementCount(i int) {
  4585. if m.addachievement_count != nil {
  4586. *m.addachievement_count += i
  4587. } else {
  4588. m.addachievement_count = &i
  4589. }
  4590. }
  4591. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  4592. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  4593. v := m.addachievement_count
  4594. if v == nil {
  4595. return
  4596. }
  4597. return *v, true
  4598. }
  4599. // ResetAchievementCount resets all changes to the "achievement_count" field.
  4600. func (m *EmployeeMutation) ResetAchievementCount() {
  4601. m.achievement_count = nil
  4602. m.addachievement_count = nil
  4603. }
  4604. // SetIntro sets the "intro" field.
  4605. func (m *EmployeeMutation) SetIntro(s string) {
  4606. m.intro = &s
  4607. }
  4608. // Intro returns the value of the "intro" field in the mutation.
  4609. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  4610. v := m.intro
  4611. if v == nil {
  4612. return
  4613. }
  4614. return *v, true
  4615. }
  4616. // OldIntro returns the old "intro" field's value of the Employee entity.
  4617. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4619. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  4620. if !m.op.Is(OpUpdateOne) {
  4621. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  4622. }
  4623. if m.id == nil || m.oldValue == nil {
  4624. return v, errors.New("OldIntro requires an ID field in the mutation")
  4625. }
  4626. oldValue, err := m.oldValue(ctx)
  4627. if err != nil {
  4628. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  4629. }
  4630. return oldValue.Intro, nil
  4631. }
  4632. // ResetIntro resets all changes to the "intro" field.
  4633. func (m *EmployeeMutation) ResetIntro() {
  4634. m.intro = nil
  4635. }
  4636. // SetEstimate sets the "estimate" field.
  4637. func (m *EmployeeMutation) SetEstimate(s string) {
  4638. m.estimate = &s
  4639. }
  4640. // Estimate returns the value of the "estimate" field in the mutation.
  4641. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  4642. v := m.estimate
  4643. if v == nil {
  4644. return
  4645. }
  4646. return *v, true
  4647. }
  4648. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  4649. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4651. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  4652. if !m.op.Is(OpUpdateOne) {
  4653. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  4654. }
  4655. if m.id == nil || m.oldValue == nil {
  4656. return v, errors.New("OldEstimate requires an ID field in the mutation")
  4657. }
  4658. oldValue, err := m.oldValue(ctx)
  4659. if err != nil {
  4660. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  4661. }
  4662. return oldValue.Estimate, nil
  4663. }
  4664. // ResetEstimate resets all changes to the "estimate" field.
  4665. func (m *EmployeeMutation) ResetEstimate() {
  4666. m.estimate = nil
  4667. }
  4668. // SetSkill sets the "skill" field.
  4669. func (m *EmployeeMutation) SetSkill(s string) {
  4670. m.skill = &s
  4671. }
  4672. // Skill returns the value of the "skill" field in the mutation.
  4673. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  4674. v := m.skill
  4675. if v == nil {
  4676. return
  4677. }
  4678. return *v, true
  4679. }
  4680. // OldSkill returns the old "skill" field's value of the Employee entity.
  4681. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4683. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  4684. if !m.op.Is(OpUpdateOne) {
  4685. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  4686. }
  4687. if m.id == nil || m.oldValue == nil {
  4688. return v, errors.New("OldSkill requires an ID field in the mutation")
  4689. }
  4690. oldValue, err := m.oldValue(ctx)
  4691. if err != nil {
  4692. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  4693. }
  4694. return oldValue.Skill, nil
  4695. }
  4696. // ResetSkill resets all changes to the "skill" field.
  4697. func (m *EmployeeMutation) ResetSkill() {
  4698. m.skill = nil
  4699. }
  4700. // SetAbilityType sets the "ability_type" field.
  4701. func (m *EmployeeMutation) SetAbilityType(s string) {
  4702. m.ability_type = &s
  4703. }
  4704. // AbilityType returns the value of the "ability_type" field in the mutation.
  4705. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  4706. v := m.ability_type
  4707. if v == nil {
  4708. return
  4709. }
  4710. return *v, true
  4711. }
  4712. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  4713. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4715. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  4716. if !m.op.Is(OpUpdateOne) {
  4717. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  4718. }
  4719. if m.id == nil || m.oldValue == nil {
  4720. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  4721. }
  4722. oldValue, err := m.oldValue(ctx)
  4723. if err != nil {
  4724. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  4725. }
  4726. return oldValue.AbilityType, nil
  4727. }
  4728. // ResetAbilityType resets all changes to the "ability_type" field.
  4729. func (m *EmployeeMutation) ResetAbilityType() {
  4730. m.ability_type = nil
  4731. }
  4732. // SetScene sets the "scene" field.
  4733. func (m *EmployeeMutation) SetScene(s string) {
  4734. m.scene = &s
  4735. }
  4736. // Scene returns the value of the "scene" field in the mutation.
  4737. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  4738. v := m.scene
  4739. if v == nil {
  4740. return
  4741. }
  4742. return *v, true
  4743. }
  4744. // OldScene returns the old "scene" field's value of the Employee entity.
  4745. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4747. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  4748. if !m.op.Is(OpUpdateOne) {
  4749. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  4750. }
  4751. if m.id == nil || m.oldValue == nil {
  4752. return v, errors.New("OldScene requires an ID field in the mutation")
  4753. }
  4754. oldValue, err := m.oldValue(ctx)
  4755. if err != nil {
  4756. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  4757. }
  4758. return oldValue.Scene, nil
  4759. }
  4760. // ResetScene resets all changes to the "scene" field.
  4761. func (m *EmployeeMutation) ResetScene() {
  4762. m.scene = nil
  4763. }
  4764. // SetSwitchIn sets the "switch_in" field.
  4765. func (m *EmployeeMutation) SetSwitchIn(s string) {
  4766. m.switch_in = &s
  4767. }
  4768. // SwitchIn returns the value of the "switch_in" field in the mutation.
  4769. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  4770. v := m.switch_in
  4771. if v == nil {
  4772. return
  4773. }
  4774. return *v, true
  4775. }
  4776. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  4777. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4779. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  4780. if !m.op.Is(OpUpdateOne) {
  4781. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  4782. }
  4783. if m.id == nil || m.oldValue == nil {
  4784. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  4785. }
  4786. oldValue, err := m.oldValue(ctx)
  4787. if err != nil {
  4788. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  4789. }
  4790. return oldValue.SwitchIn, nil
  4791. }
  4792. // ResetSwitchIn resets all changes to the "switch_in" field.
  4793. func (m *EmployeeMutation) ResetSwitchIn() {
  4794. m.switch_in = nil
  4795. }
  4796. // SetVideoURL sets the "video_url" field.
  4797. func (m *EmployeeMutation) SetVideoURL(s string) {
  4798. m.video_url = &s
  4799. }
  4800. // VideoURL returns the value of the "video_url" field in the mutation.
  4801. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  4802. v := m.video_url
  4803. if v == nil {
  4804. return
  4805. }
  4806. return *v, true
  4807. }
  4808. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  4809. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4811. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  4812. if !m.op.Is(OpUpdateOne) {
  4813. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  4814. }
  4815. if m.id == nil || m.oldValue == nil {
  4816. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  4817. }
  4818. oldValue, err := m.oldValue(ctx)
  4819. if err != nil {
  4820. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  4821. }
  4822. return oldValue.VideoURL, nil
  4823. }
  4824. // ResetVideoURL resets all changes to the "video_url" field.
  4825. func (m *EmployeeMutation) ResetVideoURL() {
  4826. m.video_url = nil
  4827. }
  4828. // SetOrganizationID sets the "organization_id" field.
  4829. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  4830. m.organization_id = &u
  4831. m.addorganization_id = nil
  4832. }
  4833. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4834. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  4835. v := m.organization_id
  4836. if v == nil {
  4837. return
  4838. }
  4839. return *v, true
  4840. }
  4841. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  4842. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4844. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4845. if !m.op.Is(OpUpdateOne) {
  4846. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4847. }
  4848. if m.id == nil || m.oldValue == nil {
  4849. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4850. }
  4851. oldValue, err := m.oldValue(ctx)
  4852. if err != nil {
  4853. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4854. }
  4855. return oldValue.OrganizationID, nil
  4856. }
  4857. // AddOrganizationID adds u to the "organization_id" field.
  4858. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  4859. if m.addorganization_id != nil {
  4860. *m.addorganization_id += u
  4861. } else {
  4862. m.addorganization_id = &u
  4863. }
  4864. }
  4865. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4866. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  4867. v := m.addorganization_id
  4868. if v == nil {
  4869. return
  4870. }
  4871. return *v, true
  4872. }
  4873. // ResetOrganizationID resets all changes to the "organization_id" field.
  4874. func (m *EmployeeMutation) ResetOrganizationID() {
  4875. m.organization_id = nil
  4876. m.addorganization_id = nil
  4877. }
  4878. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  4879. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  4880. if m.em_work_experiences == nil {
  4881. m.em_work_experiences = make(map[uint64]struct{})
  4882. }
  4883. for i := range ids {
  4884. m.em_work_experiences[ids[i]] = struct{}{}
  4885. }
  4886. }
  4887. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  4888. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  4889. m.clearedem_work_experiences = true
  4890. }
  4891. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  4892. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  4893. return m.clearedem_work_experiences
  4894. }
  4895. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  4896. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  4897. if m.removedem_work_experiences == nil {
  4898. m.removedem_work_experiences = make(map[uint64]struct{})
  4899. }
  4900. for i := range ids {
  4901. delete(m.em_work_experiences, ids[i])
  4902. m.removedem_work_experiences[ids[i]] = struct{}{}
  4903. }
  4904. }
  4905. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  4906. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  4907. for id := range m.removedem_work_experiences {
  4908. ids = append(ids, id)
  4909. }
  4910. return
  4911. }
  4912. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  4913. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  4914. for id := range m.em_work_experiences {
  4915. ids = append(ids, id)
  4916. }
  4917. return
  4918. }
  4919. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  4920. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  4921. m.em_work_experiences = nil
  4922. m.clearedem_work_experiences = false
  4923. m.removedem_work_experiences = nil
  4924. }
  4925. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  4926. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  4927. if m.em_tutorial == nil {
  4928. m.em_tutorial = make(map[uint64]struct{})
  4929. }
  4930. for i := range ids {
  4931. m.em_tutorial[ids[i]] = struct{}{}
  4932. }
  4933. }
  4934. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  4935. func (m *EmployeeMutation) ClearEmTutorial() {
  4936. m.clearedem_tutorial = true
  4937. }
  4938. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  4939. func (m *EmployeeMutation) EmTutorialCleared() bool {
  4940. return m.clearedem_tutorial
  4941. }
  4942. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  4943. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  4944. if m.removedem_tutorial == nil {
  4945. m.removedem_tutorial = make(map[uint64]struct{})
  4946. }
  4947. for i := range ids {
  4948. delete(m.em_tutorial, ids[i])
  4949. m.removedem_tutorial[ids[i]] = struct{}{}
  4950. }
  4951. }
  4952. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  4953. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  4954. for id := range m.removedem_tutorial {
  4955. ids = append(ids, id)
  4956. }
  4957. return
  4958. }
  4959. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  4960. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  4961. for id := range m.em_tutorial {
  4962. ids = append(ids, id)
  4963. }
  4964. return
  4965. }
  4966. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  4967. func (m *EmployeeMutation) ResetEmTutorial() {
  4968. m.em_tutorial = nil
  4969. m.clearedem_tutorial = false
  4970. m.removedem_tutorial = nil
  4971. }
  4972. // Where appends a list predicates to the EmployeeMutation builder.
  4973. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  4974. m.predicates = append(m.predicates, ps...)
  4975. }
  4976. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  4977. // users can use type-assertion to append predicates that do not depend on any generated package.
  4978. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  4979. p := make([]predicate.Employee, len(ps))
  4980. for i := range ps {
  4981. p[i] = ps[i]
  4982. }
  4983. m.Where(p...)
  4984. }
  4985. // Op returns the operation name.
  4986. func (m *EmployeeMutation) Op() Op {
  4987. return m.op
  4988. }
  4989. // SetOp allows setting the mutation operation.
  4990. func (m *EmployeeMutation) SetOp(op Op) {
  4991. m.op = op
  4992. }
  4993. // Type returns the node type of this mutation (Employee).
  4994. func (m *EmployeeMutation) Type() string {
  4995. return m.typ
  4996. }
  4997. // Fields returns all fields that were changed during this mutation. Note that in
  4998. // order to get all numeric fields that were incremented/decremented, call
  4999. // AddedFields().
  5000. func (m *EmployeeMutation) Fields() []string {
  5001. fields := make([]string, 0, 17)
  5002. if m.created_at != nil {
  5003. fields = append(fields, employee.FieldCreatedAt)
  5004. }
  5005. if m.updated_at != nil {
  5006. fields = append(fields, employee.FieldUpdatedAt)
  5007. }
  5008. if m.deleted_at != nil {
  5009. fields = append(fields, employee.FieldDeletedAt)
  5010. }
  5011. if m.title != nil {
  5012. fields = append(fields, employee.FieldTitle)
  5013. }
  5014. if m.avatar != nil {
  5015. fields = append(fields, employee.FieldAvatar)
  5016. }
  5017. if m.tags != nil {
  5018. fields = append(fields, employee.FieldTags)
  5019. }
  5020. if m.hire_count != nil {
  5021. fields = append(fields, employee.FieldHireCount)
  5022. }
  5023. if m.service_count != nil {
  5024. fields = append(fields, employee.FieldServiceCount)
  5025. }
  5026. if m.achievement_count != nil {
  5027. fields = append(fields, employee.FieldAchievementCount)
  5028. }
  5029. if m.intro != nil {
  5030. fields = append(fields, employee.FieldIntro)
  5031. }
  5032. if m.estimate != nil {
  5033. fields = append(fields, employee.FieldEstimate)
  5034. }
  5035. if m.skill != nil {
  5036. fields = append(fields, employee.FieldSkill)
  5037. }
  5038. if m.ability_type != nil {
  5039. fields = append(fields, employee.FieldAbilityType)
  5040. }
  5041. if m.scene != nil {
  5042. fields = append(fields, employee.FieldScene)
  5043. }
  5044. if m.switch_in != nil {
  5045. fields = append(fields, employee.FieldSwitchIn)
  5046. }
  5047. if m.video_url != nil {
  5048. fields = append(fields, employee.FieldVideoURL)
  5049. }
  5050. if m.organization_id != nil {
  5051. fields = append(fields, employee.FieldOrganizationID)
  5052. }
  5053. return fields
  5054. }
  5055. // Field returns the value of a field with the given name. The second boolean
  5056. // return value indicates that this field was not set, or was not defined in the
  5057. // schema.
  5058. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  5059. switch name {
  5060. case employee.FieldCreatedAt:
  5061. return m.CreatedAt()
  5062. case employee.FieldUpdatedAt:
  5063. return m.UpdatedAt()
  5064. case employee.FieldDeletedAt:
  5065. return m.DeletedAt()
  5066. case employee.FieldTitle:
  5067. return m.Title()
  5068. case employee.FieldAvatar:
  5069. return m.Avatar()
  5070. case employee.FieldTags:
  5071. return m.Tags()
  5072. case employee.FieldHireCount:
  5073. return m.HireCount()
  5074. case employee.FieldServiceCount:
  5075. return m.ServiceCount()
  5076. case employee.FieldAchievementCount:
  5077. return m.AchievementCount()
  5078. case employee.FieldIntro:
  5079. return m.Intro()
  5080. case employee.FieldEstimate:
  5081. return m.Estimate()
  5082. case employee.FieldSkill:
  5083. return m.Skill()
  5084. case employee.FieldAbilityType:
  5085. return m.AbilityType()
  5086. case employee.FieldScene:
  5087. return m.Scene()
  5088. case employee.FieldSwitchIn:
  5089. return m.SwitchIn()
  5090. case employee.FieldVideoURL:
  5091. return m.VideoURL()
  5092. case employee.FieldOrganizationID:
  5093. return m.OrganizationID()
  5094. }
  5095. return nil, false
  5096. }
  5097. // OldField returns the old value of the field from the database. An error is
  5098. // returned if the mutation operation is not UpdateOne, or the query to the
  5099. // database failed.
  5100. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5101. switch name {
  5102. case employee.FieldCreatedAt:
  5103. return m.OldCreatedAt(ctx)
  5104. case employee.FieldUpdatedAt:
  5105. return m.OldUpdatedAt(ctx)
  5106. case employee.FieldDeletedAt:
  5107. return m.OldDeletedAt(ctx)
  5108. case employee.FieldTitle:
  5109. return m.OldTitle(ctx)
  5110. case employee.FieldAvatar:
  5111. return m.OldAvatar(ctx)
  5112. case employee.FieldTags:
  5113. return m.OldTags(ctx)
  5114. case employee.FieldHireCount:
  5115. return m.OldHireCount(ctx)
  5116. case employee.FieldServiceCount:
  5117. return m.OldServiceCount(ctx)
  5118. case employee.FieldAchievementCount:
  5119. return m.OldAchievementCount(ctx)
  5120. case employee.FieldIntro:
  5121. return m.OldIntro(ctx)
  5122. case employee.FieldEstimate:
  5123. return m.OldEstimate(ctx)
  5124. case employee.FieldSkill:
  5125. return m.OldSkill(ctx)
  5126. case employee.FieldAbilityType:
  5127. return m.OldAbilityType(ctx)
  5128. case employee.FieldScene:
  5129. return m.OldScene(ctx)
  5130. case employee.FieldSwitchIn:
  5131. return m.OldSwitchIn(ctx)
  5132. case employee.FieldVideoURL:
  5133. return m.OldVideoURL(ctx)
  5134. case employee.FieldOrganizationID:
  5135. return m.OldOrganizationID(ctx)
  5136. }
  5137. return nil, fmt.Errorf("unknown Employee field %s", name)
  5138. }
  5139. // SetField sets the value of a field with the given name. It returns an error if
  5140. // the field is not defined in the schema, or if the type mismatched the field
  5141. // type.
  5142. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  5143. switch name {
  5144. case employee.FieldCreatedAt:
  5145. v, ok := value.(time.Time)
  5146. if !ok {
  5147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5148. }
  5149. m.SetCreatedAt(v)
  5150. return nil
  5151. case employee.FieldUpdatedAt:
  5152. v, ok := value.(time.Time)
  5153. if !ok {
  5154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5155. }
  5156. m.SetUpdatedAt(v)
  5157. return nil
  5158. case employee.FieldDeletedAt:
  5159. v, ok := value.(time.Time)
  5160. if !ok {
  5161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5162. }
  5163. m.SetDeletedAt(v)
  5164. return nil
  5165. case employee.FieldTitle:
  5166. v, ok := value.(string)
  5167. if !ok {
  5168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5169. }
  5170. m.SetTitle(v)
  5171. return nil
  5172. case employee.FieldAvatar:
  5173. v, ok := value.(string)
  5174. if !ok {
  5175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5176. }
  5177. m.SetAvatar(v)
  5178. return nil
  5179. case employee.FieldTags:
  5180. v, ok := value.(string)
  5181. if !ok {
  5182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5183. }
  5184. m.SetTags(v)
  5185. return nil
  5186. case employee.FieldHireCount:
  5187. v, ok := value.(int)
  5188. if !ok {
  5189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5190. }
  5191. m.SetHireCount(v)
  5192. return nil
  5193. case employee.FieldServiceCount:
  5194. v, ok := value.(int)
  5195. if !ok {
  5196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5197. }
  5198. m.SetServiceCount(v)
  5199. return nil
  5200. case employee.FieldAchievementCount:
  5201. v, ok := value.(int)
  5202. if !ok {
  5203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5204. }
  5205. m.SetAchievementCount(v)
  5206. return nil
  5207. case employee.FieldIntro:
  5208. v, ok := value.(string)
  5209. if !ok {
  5210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5211. }
  5212. m.SetIntro(v)
  5213. return nil
  5214. case employee.FieldEstimate:
  5215. v, ok := value.(string)
  5216. if !ok {
  5217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5218. }
  5219. m.SetEstimate(v)
  5220. return nil
  5221. case employee.FieldSkill:
  5222. v, ok := value.(string)
  5223. if !ok {
  5224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5225. }
  5226. m.SetSkill(v)
  5227. return nil
  5228. case employee.FieldAbilityType:
  5229. v, ok := value.(string)
  5230. if !ok {
  5231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5232. }
  5233. m.SetAbilityType(v)
  5234. return nil
  5235. case employee.FieldScene:
  5236. v, ok := value.(string)
  5237. if !ok {
  5238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5239. }
  5240. m.SetScene(v)
  5241. return nil
  5242. case employee.FieldSwitchIn:
  5243. v, ok := value.(string)
  5244. if !ok {
  5245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5246. }
  5247. m.SetSwitchIn(v)
  5248. return nil
  5249. case employee.FieldVideoURL:
  5250. v, ok := value.(string)
  5251. if !ok {
  5252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5253. }
  5254. m.SetVideoURL(v)
  5255. return nil
  5256. case employee.FieldOrganizationID:
  5257. v, ok := value.(uint64)
  5258. if !ok {
  5259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5260. }
  5261. m.SetOrganizationID(v)
  5262. return nil
  5263. }
  5264. return fmt.Errorf("unknown Employee field %s", name)
  5265. }
  5266. // AddedFields returns all numeric fields that were incremented/decremented during
  5267. // this mutation.
  5268. func (m *EmployeeMutation) AddedFields() []string {
  5269. var fields []string
  5270. if m.addhire_count != nil {
  5271. fields = append(fields, employee.FieldHireCount)
  5272. }
  5273. if m.addservice_count != nil {
  5274. fields = append(fields, employee.FieldServiceCount)
  5275. }
  5276. if m.addachievement_count != nil {
  5277. fields = append(fields, employee.FieldAchievementCount)
  5278. }
  5279. if m.addorganization_id != nil {
  5280. fields = append(fields, employee.FieldOrganizationID)
  5281. }
  5282. return fields
  5283. }
  5284. // AddedField returns the numeric value that was incremented/decremented on a field
  5285. // with the given name. The second boolean return value indicates that this field
  5286. // was not set, or was not defined in the schema.
  5287. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  5288. switch name {
  5289. case employee.FieldHireCount:
  5290. return m.AddedHireCount()
  5291. case employee.FieldServiceCount:
  5292. return m.AddedServiceCount()
  5293. case employee.FieldAchievementCount:
  5294. return m.AddedAchievementCount()
  5295. case employee.FieldOrganizationID:
  5296. return m.AddedOrganizationID()
  5297. }
  5298. return nil, false
  5299. }
  5300. // AddField adds the value to the field with the given name. It returns an error if
  5301. // the field is not defined in the schema, or if the type mismatched the field
  5302. // type.
  5303. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  5304. switch name {
  5305. case employee.FieldHireCount:
  5306. v, ok := value.(int)
  5307. if !ok {
  5308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5309. }
  5310. m.AddHireCount(v)
  5311. return nil
  5312. case employee.FieldServiceCount:
  5313. v, ok := value.(int)
  5314. if !ok {
  5315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5316. }
  5317. m.AddServiceCount(v)
  5318. return nil
  5319. case employee.FieldAchievementCount:
  5320. v, ok := value.(int)
  5321. if !ok {
  5322. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5323. }
  5324. m.AddAchievementCount(v)
  5325. return nil
  5326. case employee.FieldOrganizationID:
  5327. v, ok := value.(int64)
  5328. if !ok {
  5329. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5330. }
  5331. m.AddOrganizationID(v)
  5332. return nil
  5333. }
  5334. return fmt.Errorf("unknown Employee numeric field %s", name)
  5335. }
  5336. // ClearedFields returns all nullable fields that were cleared during this
  5337. // mutation.
  5338. func (m *EmployeeMutation) ClearedFields() []string {
  5339. var fields []string
  5340. if m.FieldCleared(employee.FieldDeletedAt) {
  5341. fields = append(fields, employee.FieldDeletedAt)
  5342. }
  5343. return fields
  5344. }
  5345. // FieldCleared returns a boolean indicating if a field with the given name was
  5346. // cleared in this mutation.
  5347. func (m *EmployeeMutation) FieldCleared(name string) bool {
  5348. _, ok := m.clearedFields[name]
  5349. return ok
  5350. }
  5351. // ClearField clears the value of the field with the given name. It returns an
  5352. // error if the field is not defined in the schema.
  5353. func (m *EmployeeMutation) ClearField(name string) error {
  5354. switch name {
  5355. case employee.FieldDeletedAt:
  5356. m.ClearDeletedAt()
  5357. return nil
  5358. }
  5359. return fmt.Errorf("unknown Employee nullable field %s", name)
  5360. }
  5361. // ResetField resets all changes in the mutation for the field with the given name.
  5362. // It returns an error if the field is not defined in the schema.
  5363. func (m *EmployeeMutation) ResetField(name string) error {
  5364. switch name {
  5365. case employee.FieldCreatedAt:
  5366. m.ResetCreatedAt()
  5367. return nil
  5368. case employee.FieldUpdatedAt:
  5369. m.ResetUpdatedAt()
  5370. return nil
  5371. case employee.FieldDeletedAt:
  5372. m.ResetDeletedAt()
  5373. return nil
  5374. case employee.FieldTitle:
  5375. m.ResetTitle()
  5376. return nil
  5377. case employee.FieldAvatar:
  5378. m.ResetAvatar()
  5379. return nil
  5380. case employee.FieldTags:
  5381. m.ResetTags()
  5382. return nil
  5383. case employee.FieldHireCount:
  5384. m.ResetHireCount()
  5385. return nil
  5386. case employee.FieldServiceCount:
  5387. m.ResetServiceCount()
  5388. return nil
  5389. case employee.FieldAchievementCount:
  5390. m.ResetAchievementCount()
  5391. return nil
  5392. case employee.FieldIntro:
  5393. m.ResetIntro()
  5394. return nil
  5395. case employee.FieldEstimate:
  5396. m.ResetEstimate()
  5397. return nil
  5398. case employee.FieldSkill:
  5399. m.ResetSkill()
  5400. return nil
  5401. case employee.FieldAbilityType:
  5402. m.ResetAbilityType()
  5403. return nil
  5404. case employee.FieldScene:
  5405. m.ResetScene()
  5406. return nil
  5407. case employee.FieldSwitchIn:
  5408. m.ResetSwitchIn()
  5409. return nil
  5410. case employee.FieldVideoURL:
  5411. m.ResetVideoURL()
  5412. return nil
  5413. case employee.FieldOrganizationID:
  5414. m.ResetOrganizationID()
  5415. return nil
  5416. }
  5417. return fmt.Errorf("unknown Employee field %s", name)
  5418. }
  5419. // AddedEdges returns all edge names that were set/added in this mutation.
  5420. func (m *EmployeeMutation) AddedEdges() []string {
  5421. edges := make([]string, 0, 2)
  5422. if m.em_work_experiences != nil {
  5423. edges = append(edges, employee.EdgeEmWorkExperiences)
  5424. }
  5425. if m.em_tutorial != nil {
  5426. edges = append(edges, employee.EdgeEmTutorial)
  5427. }
  5428. return edges
  5429. }
  5430. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5431. // name in this mutation.
  5432. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  5433. switch name {
  5434. case employee.EdgeEmWorkExperiences:
  5435. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  5436. for id := range m.em_work_experiences {
  5437. ids = append(ids, id)
  5438. }
  5439. return ids
  5440. case employee.EdgeEmTutorial:
  5441. ids := make([]ent.Value, 0, len(m.em_tutorial))
  5442. for id := range m.em_tutorial {
  5443. ids = append(ids, id)
  5444. }
  5445. return ids
  5446. }
  5447. return nil
  5448. }
  5449. // RemovedEdges returns all edge names that were removed in this mutation.
  5450. func (m *EmployeeMutation) RemovedEdges() []string {
  5451. edges := make([]string, 0, 2)
  5452. if m.removedem_work_experiences != nil {
  5453. edges = append(edges, employee.EdgeEmWorkExperiences)
  5454. }
  5455. if m.removedem_tutorial != nil {
  5456. edges = append(edges, employee.EdgeEmTutorial)
  5457. }
  5458. return edges
  5459. }
  5460. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5461. // the given name in this mutation.
  5462. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  5463. switch name {
  5464. case employee.EdgeEmWorkExperiences:
  5465. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  5466. for id := range m.removedem_work_experiences {
  5467. ids = append(ids, id)
  5468. }
  5469. return ids
  5470. case employee.EdgeEmTutorial:
  5471. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  5472. for id := range m.removedem_tutorial {
  5473. ids = append(ids, id)
  5474. }
  5475. return ids
  5476. }
  5477. return nil
  5478. }
  5479. // ClearedEdges returns all edge names that were cleared in this mutation.
  5480. func (m *EmployeeMutation) ClearedEdges() []string {
  5481. edges := make([]string, 0, 2)
  5482. if m.clearedem_work_experiences {
  5483. edges = append(edges, employee.EdgeEmWorkExperiences)
  5484. }
  5485. if m.clearedem_tutorial {
  5486. edges = append(edges, employee.EdgeEmTutorial)
  5487. }
  5488. return edges
  5489. }
  5490. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5491. // was cleared in this mutation.
  5492. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  5493. switch name {
  5494. case employee.EdgeEmWorkExperiences:
  5495. return m.clearedem_work_experiences
  5496. case employee.EdgeEmTutorial:
  5497. return m.clearedem_tutorial
  5498. }
  5499. return false
  5500. }
  5501. // ClearEdge clears the value of the edge with the given name. It returns an error
  5502. // if that edge is not defined in the schema.
  5503. func (m *EmployeeMutation) ClearEdge(name string) error {
  5504. switch name {
  5505. }
  5506. return fmt.Errorf("unknown Employee unique edge %s", name)
  5507. }
  5508. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5509. // It returns an error if the edge is not defined in the schema.
  5510. func (m *EmployeeMutation) ResetEdge(name string) error {
  5511. switch name {
  5512. case employee.EdgeEmWorkExperiences:
  5513. m.ResetEmWorkExperiences()
  5514. return nil
  5515. case employee.EdgeEmTutorial:
  5516. m.ResetEmTutorial()
  5517. return nil
  5518. }
  5519. return fmt.Errorf("unknown Employee edge %s", name)
  5520. }
  5521. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  5522. type LabelMutation struct {
  5523. config
  5524. op Op
  5525. typ string
  5526. id *uint64
  5527. created_at *time.Time
  5528. updated_at *time.Time
  5529. status *uint8
  5530. addstatus *int8
  5531. _type *int
  5532. add_type *int
  5533. name *string
  5534. from *int
  5535. addfrom *int
  5536. mode *int
  5537. addmode *int
  5538. conditions *string
  5539. organization_id *uint64
  5540. addorganization_id *int64
  5541. clearedFields map[string]struct{}
  5542. label_relationships map[uint64]struct{}
  5543. removedlabel_relationships map[uint64]struct{}
  5544. clearedlabel_relationships bool
  5545. done bool
  5546. oldValue func(context.Context) (*Label, error)
  5547. predicates []predicate.Label
  5548. }
  5549. var _ ent.Mutation = (*LabelMutation)(nil)
  5550. // labelOption allows management of the mutation configuration using functional options.
  5551. type labelOption func(*LabelMutation)
  5552. // newLabelMutation creates new mutation for the Label entity.
  5553. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  5554. m := &LabelMutation{
  5555. config: c,
  5556. op: op,
  5557. typ: TypeLabel,
  5558. clearedFields: make(map[string]struct{}),
  5559. }
  5560. for _, opt := range opts {
  5561. opt(m)
  5562. }
  5563. return m
  5564. }
  5565. // withLabelID sets the ID field of the mutation.
  5566. func withLabelID(id uint64) labelOption {
  5567. return func(m *LabelMutation) {
  5568. var (
  5569. err error
  5570. once sync.Once
  5571. value *Label
  5572. )
  5573. m.oldValue = func(ctx context.Context) (*Label, error) {
  5574. once.Do(func() {
  5575. if m.done {
  5576. err = errors.New("querying old values post mutation is not allowed")
  5577. } else {
  5578. value, err = m.Client().Label.Get(ctx, id)
  5579. }
  5580. })
  5581. return value, err
  5582. }
  5583. m.id = &id
  5584. }
  5585. }
  5586. // withLabel sets the old Label of the mutation.
  5587. func withLabel(node *Label) labelOption {
  5588. return func(m *LabelMutation) {
  5589. m.oldValue = func(context.Context) (*Label, error) {
  5590. return node, nil
  5591. }
  5592. m.id = &node.ID
  5593. }
  5594. }
  5595. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5596. // executed in a transaction (ent.Tx), a transactional client is returned.
  5597. func (m LabelMutation) Client() *Client {
  5598. client := &Client{config: m.config}
  5599. client.init()
  5600. return client
  5601. }
  5602. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5603. // it returns an error otherwise.
  5604. func (m LabelMutation) Tx() (*Tx, error) {
  5605. if _, ok := m.driver.(*txDriver); !ok {
  5606. return nil, errors.New("ent: mutation is not running in a transaction")
  5607. }
  5608. tx := &Tx{config: m.config}
  5609. tx.init()
  5610. return tx, nil
  5611. }
  5612. // SetID sets the value of the id field. Note that this
  5613. // operation is only accepted on creation of Label entities.
  5614. func (m *LabelMutation) SetID(id uint64) {
  5615. m.id = &id
  5616. }
  5617. // ID returns the ID value in the mutation. Note that the ID is only available
  5618. // if it was provided to the builder or after it was returned from the database.
  5619. func (m *LabelMutation) ID() (id uint64, exists bool) {
  5620. if m.id == nil {
  5621. return
  5622. }
  5623. return *m.id, true
  5624. }
  5625. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5626. // That means, if the mutation is applied within a transaction with an isolation level such
  5627. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5628. // or updated by the mutation.
  5629. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  5630. switch {
  5631. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5632. id, exists := m.ID()
  5633. if exists {
  5634. return []uint64{id}, nil
  5635. }
  5636. fallthrough
  5637. case m.op.Is(OpUpdate | OpDelete):
  5638. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  5639. default:
  5640. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5641. }
  5642. }
  5643. // SetCreatedAt sets the "created_at" field.
  5644. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  5645. m.created_at = &t
  5646. }
  5647. // CreatedAt returns the value of the "created_at" field in the mutation.
  5648. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  5649. v := m.created_at
  5650. if v == nil {
  5651. return
  5652. }
  5653. return *v, true
  5654. }
  5655. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  5656. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  5657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5658. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5659. if !m.op.Is(OpUpdateOne) {
  5660. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5661. }
  5662. if m.id == nil || m.oldValue == nil {
  5663. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5664. }
  5665. oldValue, err := m.oldValue(ctx)
  5666. if err != nil {
  5667. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5668. }
  5669. return oldValue.CreatedAt, nil
  5670. }
  5671. // ResetCreatedAt resets all changes to the "created_at" field.
  5672. func (m *LabelMutation) ResetCreatedAt() {
  5673. m.created_at = nil
  5674. }
  5675. // SetUpdatedAt sets the "updated_at" field.
  5676. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  5677. m.updated_at = &t
  5678. }
  5679. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5680. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  5681. v := m.updated_at
  5682. if v == nil {
  5683. return
  5684. }
  5685. return *v, true
  5686. }
  5687. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  5688. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  5689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5690. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5691. if !m.op.Is(OpUpdateOne) {
  5692. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5693. }
  5694. if m.id == nil || m.oldValue == nil {
  5695. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5696. }
  5697. oldValue, err := m.oldValue(ctx)
  5698. if err != nil {
  5699. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5700. }
  5701. return oldValue.UpdatedAt, nil
  5702. }
  5703. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5704. func (m *LabelMutation) ResetUpdatedAt() {
  5705. m.updated_at = nil
  5706. }
  5707. // SetStatus sets the "status" field.
  5708. func (m *LabelMutation) SetStatus(u uint8) {
  5709. m.status = &u
  5710. m.addstatus = nil
  5711. }
  5712. // Status returns the value of the "status" field in the mutation.
  5713. func (m *LabelMutation) Status() (r uint8, exists bool) {
  5714. v := m.status
  5715. if v == nil {
  5716. return
  5717. }
  5718. return *v, true
  5719. }
  5720. // OldStatus returns the old "status" field's value of the Label entity.
  5721. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  5722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5723. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5724. if !m.op.Is(OpUpdateOne) {
  5725. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5726. }
  5727. if m.id == nil || m.oldValue == nil {
  5728. return v, errors.New("OldStatus requires an ID field in the mutation")
  5729. }
  5730. oldValue, err := m.oldValue(ctx)
  5731. if err != nil {
  5732. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5733. }
  5734. return oldValue.Status, nil
  5735. }
  5736. // AddStatus adds u to the "status" field.
  5737. func (m *LabelMutation) AddStatus(u int8) {
  5738. if m.addstatus != nil {
  5739. *m.addstatus += u
  5740. } else {
  5741. m.addstatus = &u
  5742. }
  5743. }
  5744. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5745. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  5746. v := m.addstatus
  5747. if v == nil {
  5748. return
  5749. }
  5750. return *v, true
  5751. }
  5752. // ClearStatus clears the value of the "status" field.
  5753. func (m *LabelMutation) ClearStatus() {
  5754. m.status = nil
  5755. m.addstatus = nil
  5756. m.clearedFields[label.FieldStatus] = struct{}{}
  5757. }
  5758. // StatusCleared returns if the "status" field was cleared in this mutation.
  5759. func (m *LabelMutation) StatusCleared() bool {
  5760. _, ok := m.clearedFields[label.FieldStatus]
  5761. return ok
  5762. }
  5763. // ResetStatus resets all changes to the "status" field.
  5764. func (m *LabelMutation) ResetStatus() {
  5765. m.status = nil
  5766. m.addstatus = nil
  5767. delete(m.clearedFields, label.FieldStatus)
  5768. }
  5769. // SetType sets the "type" field.
  5770. func (m *LabelMutation) SetType(i int) {
  5771. m._type = &i
  5772. m.add_type = nil
  5773. }
  5774. // GetType returns the value of the "type" field in the mutation.
  5775. func (m *LabelMutation) GetType() (r int, exists bool) {
  5776. v := m._type
  5777. if v == nil {
  5778. return
  5779. }
  5780. return *v, true
  5781. }
  5782. // OldType returns the old "type" field's value of the Label entity.
  5783. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  5784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5785. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  5786. if !m.op.Is(OpUpdateOne) {
  5787. return v, errors.New("OldType is only allowed on UpdateOne operations")
  5788. }
  5789. if m.id == nil || m.oldValue == nil {
  5790. return v, errors.New("OldType requires an ID field in the mutation")
  5791. }
  5792. oldValue, err := m.oldValue(ctx)
  5793. if err != nil {
  5794. return v, fmt.Errorf("querying old value for OldType: %w", err)
  5795. }
  5796. return oldValue.Type, nil
  5797. }
  5798. // AddType adds i to the "type" field.
  5799. func (m *LabelMutation) AddType(i int) {
  5800. if m.add_type != nil {
  5801. *m.add_type += i
  5802. } else {
  5803. m.add_type = &i
  5804. }
  5805. }
  5806. // AddedType returns the value that was added to the "type" field in this mutation.
  5807. func (m *LabelMutation) AddedType() (r int, exists bool) {
  5808. v := m.add_type
  5809. if v == nil {
  5810. return
  5811. }
  5812. return *v, true
  5813. }
  5814. // ResetType resets all changes to the "type" field.
  5815. func (m *LabelMutation) ResetType() {
  5816. m._type = nil
  5817. m.add_type = nil
  5818. }
  5819. // SetName sets the "name" field.
  5820. func (m *LabelMutation) SetName(s string) {
  5821. m.name = &s
  5822. }
  5823. // Name returns the value of the "name" field in the mutation.
  5824. func (m *LabelMutation) Name() (r string, exists bool) {
  5825. v := m.name
  5826. if v == nil {
  5827. return
  5828. }
  5829. return *v, true
  5830. }
  5831. // OldName returns the old "name" field's value of the Label entity.
  5832. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  5833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5834. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  5835. if !m.op.Is(OpUpdateOne) {
  5836. return v, errors.New("OldName is only allowed on UpdateOne operations")
  5837. }
  5838. if m.id == nil || m.oldValue == nil {
  5839. return v, errors.New("OldName requires an ID field in the mutation")
  5840. }
  5841. oldValue, err := m.oldValue(ctx)
  5842. if err != nil {
  5843. return v, fmt.Errorf("querying old value for OldName: %w", err)
  5844. }
  5845. return oldValue.Name, nil
  5846. }
  5847. // ResetName resets all changes to the "name" field.
  5848. func (m *LabelMutation) ResetName() {
  5849. m.name = nil
  5850. }
  5851. // SetFrom sets the "from" field.
  5852. func (m *LabelMutation) SetFrom(i int) {
  5853. m.from = &i
  5854. m.addfrom = nil
  5855. }
  5856. // From returns the value of the "from" field in the mutation.
  5857. func (m *LabelMutation) From() (r int, exists bool) {
  5858. v := m.from
  5859. if v == nil {
  5860. return
  5861. }
  5862. return *v, true
  5863. }
  5864. // OldFrom returns the old "from" field's value of the Label entity.
  5865. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  5866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5867. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  5868. if !m.op.Is(OpUpdateOne) {
  5869. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  5870. }
  5871. if m.id == nil || m.oldValue == nil {
  5872. return v, errors.New("OldFrom requires an ID field in the mutation")
  5873. }
  5874. oldValue, err := m.oldValue(ctx)
  5875. if err != nil {
  5876. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  5877. }
  5878. return oldValue.From, nil
  5879. }
  5880. // AddFrom adds i to the "from" field.
  5881. func (m *LabelMutation) AddFrom(i int) {
  5882. if m.addfrom != nil {
  5883. *m.addfrom += i
  5884. } else {
  5885. m.addfrom = &i
  5886. }
  5887. }
  5888. // AddedFrom returns the value that was added to the "from" field in this mutation.
  5889. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  5890. v := m.addfrom
  5891. if v == nil {
  5892. return
  5893. }
  5894. return *v, true
  5895. }
  5896. // ResetFrom resets all changes to the "from" field.
  5897. func (m *LabelMutation) ResetFrom() {
  5898. m.from = nil
  5899. m.addfrom = nil
  5900. }
  5901. // SetMode sets the "mode" field.
  5902. func (m *LabelMutation) SetMode(i int) {
  5903. m.mode = &i
  5904. m.addmode = nil
  5905. }
  5906. // Mode returns the value of the "mode" field in the mutation.
  5907. func (m *LabelMutation) Mode() (r int, exists bool) {
  5908. v := m.mode
  5909. if v == nil {
  5910. return
  5911. }
  5912. return *v, true
  5913. }
  5914. // OldMode returns the old "mode" field's value of the Label entity.
  5915. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  5916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5917. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  5918. if !m.op.Is(OpUpdateOne) {
  5919. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  5920. }
  5921. if m.id == nil || m.oldValue == nil {
  5922. return v, errors.New("OldMode requires an ID field in the mutation")
  5923. }
  5924. oldValue, err := m.oldValue(ctx)
  5925. if err != nil {
  5926. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  5927. }
  5928. return oldValue.Mode, nil
  5929. }
  5930. // AddMode adds i to the "mode" field.
  5931. func (m *LabelMutation) AddMode(i int) {
  5932. if m.addmode != nil {
  5933. *m.addmode += i
  5934. } else {
  5935. m.addmode = &i
  5936. }
  5937. }
  5938. // AddedMode returns the value that was added to the "mode" field in this mutation.
  5939. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  5940. v := m.addmode
  5941. if v == nil {
  5942. return
  5943. }
  5944. return *v, true
  5945. }
  5946. // ResetMode resets all changes to the "mode" field.
  5947. func (m *LabelMutation) ResetMode() {
  5948. m.mode = nil
  5949. m.addmode = nil
  5950. }
  5951. // SetConditions sets the "conditions" field.
  5952. func (m *LabelMutation) SetConditions(s string) {
  5953. m.conditions = &s
  5954. }
  5955. // Conditions returns the value of the "conditions" field in the mutation.
  5956. func (m *LabelMutation) Conditions() (r string, exists bool) {
  5957. v := m.conditions
  5958. if v == nil {
  5959. return
  5960. }
  5961. return *v, true
  5962. }
  5963. // OldConditions returns the old "conditions" field's value of the Label entity.
  5964. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  5965. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5966. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  5967. if !m.op.Is(OpUpdateOne) {
  5968. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  5969. }
  5970. if m.id == nil || m.oldValue == nil {
  5971. return v, errors.New("OldConditions requires an ID field in the mutation")
  5972. }
  5973. oldValue, err := m.oldValue(ctx)
  5974. if err != nil {
  5975. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  5976. }
  5977. return oldValue.Conditions, nil
  5978. }
  5979. // ClearConditions clears the value of the "conditions" field.
  5980. func (m *LabelMutation) ClearConditions() {
  5981. m.conditions = nil
  5982. m.clearedFields[label.FieldConditions] = struct{}{}
  5983. }
  5984. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  5985. func (m *LabelMutation) ConditionsCleared() bool {
  5986. _, ok := m.clearedFields[label.FieldConditions]
  5987. return ok
  5988. }
  5989. // ResetConditions resets all changes to the "conditions" field.
  5990. func (m *LabelMutation) ResetConditions() {
  5991. m.conditions = nil
  5992. delete(m.clearedFields, label.FieldConditions)
  5993. }
  5994. // SetOrganizationID sets the "organization_id" field.
  5995. func (m *LabelMutation) SetOrganizationID(u uint64) {
  5996. m.organization_id = &u
  5997. m.addorganization_id = nil
  5998. }
  5999. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6000. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  6001. v := m.organization_id
  6002. if v == nil {
  6003. return
  6004. }
  6005. return *v, true
  6006. }
  6007. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  6008. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  6009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6010. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6011. if !m.op.Is(OpUpdateOne) {
  6012. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6013. }
  6014. if m.id == nil || m.oldValue == nil {
  6015. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6016. }
  6017. oldValue, err := m.oldValue(ctx)
  6018. if err != nil {
  6019. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6020. }
  6021. return oldValue.OrganizationID, nil
  6022. }
  6023. // AddOrganizationID adds u to the "organization_id" field.
  6024. func (m *LabelMutation) AddOrganizationID(u int64) {
  6025. if m.addorganization_id != nil {
  6026. *m.addorganization_id += u
  6027. } else {
  6028. m.addorganization_id = &u
  6029. }
  6030. }
  6031. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6032. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  6033. v := m.addorganization_id
  6034. if v == nil {
  6035. return
  6036. }
  6037. return *v, true
  6038. }
  6039. // ClearOrganizationID clears the value of the "organization_id" field.
  6040. func (m *LabelMutation) ClearOrganizationID() {
  6041. m.organization_id = nil
  6042. m.addorganization_id = nil
  6043. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  6044. }
  6045. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  6046. func (m *LabelMutation) OrganizationIDCleared() bool {
  6047. _, ok := m.clearedFields[label.FieldOrganizationID]
  6048. return ok
  6049. }
  6050. // ResetOrganizationID resets all changes to the "organization_id" field.
  6051. func (m *LabelMutation) ResetOrganizationID() {
  6052. m.organization_id = nil
  6053. m.addorganization_id = nil
  6054. delete(m.clearedFields, label.FieldOrganizationID)
  6055. }
  6056. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  6057. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  6058. if m.label_relationships == nil {
  6059. m.label_relationships = make(map[uint64]struct{})
  6060. }
  6061. for i := range ids {
  6062. m.label_relationships[ids[i]] = struct{}{}
  6063. }
  6064. }
  6065. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  6066. func (m *LabelMutation) ClearLabelRelationships() {
  6067. m.clearedlabel_relationships = true
  6068. }
  6069. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  6070. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  6071. return m.clearedlabel_relationships
  6072. }
  6073. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  6074. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  6075. if m.removedlabel_relationships == nil {
  6076. m.removedlabel_relationships = make(map[uint64]struct{})
  6077. }
  6078. for i := range ids {
  6079. delete(m.label_relationships, ids[i])
  6080. m.removedlabel_relationships[ids[i]] = struct{}{}
  6081. }
  6082. }
  6083. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  6084. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  6085. for id := range m.removedlabel_relationships {
  6086. ids = append(ids, id)
  6087. }
  6088. return
  6089. }
  6090. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  6091. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  6092. for id := range m.label_relationships {
  6093. ids = append(ids, id)
  6094. }
  6095. return
  6096. }
  6097. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  6098. func (m *LabelMutation) ResetLabelRelationships() {
  6099. m.label_relationships = nil
  6100. m.clearedlabel_relationships = false
  6101. m.removedlabel_relationships = nil
  6102. }
  6103. // Where appends a list predicates to the LabelMutation builder.
  6104. func (m *LabelMutation) Where(ps ...predicate.Label) {
  6105. m.predicates = append(m.predicates, ps...)
  6106. }
  6107. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  6108. // users can use type-assertion to append predicates that do not depend on any generated package.
  6109. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  6110. p := make([]predicate.Label, len(ps))
  6111. for i := range ps {
  6112. p[i] = ps[i]
  6113. }
  6114. m.Where(p...)
  6115. }
  6116. // Op returns the operation name.
  6117. func (m *LabelMutation) Op() Op {
  6118. return m.op
  6119. }
  6120. // SetOp allows setting the mutation operation.
  6121. func (m *LabelMutation) SetOp(op Op) {
  6122. m.op = op
  6123. }
  6124. // Type returns the node type of this mutation (Label).
  6125. func (m *LabelMutation) Type() string {
  6126. return m.typ
  6127. }
  6128. // Fields returns all fields that were changed during this mutation. Note that in
  6129. // order to get all numeric fields that were incremented/decremented, call
  6130. // AddedFields().
  6131. func (m *LabelMutation) Fields() []string {
  6132. fields := make([]string, 0, 9)
  6133. if m.created_at != nil {
  6134. fields = append(fields, label.FieldCreatedAt)
  6135. }
  6136. if m.updated_at != nil {
  6137. fields = append(fields, label.FieldUpdatedAt)
  6138. }
  6139. if m.status != nil {
  6140. fields = append(fields, label.FieldStatus)
  6141. }
  6142. if m._type != nil {
  6143. fields = append(fields, label.FieldType)
  6144. }
  6145. if m.name != nil {
  6146. fields = append(fields, label.FieldName)
  6147. }
  6148. if m.from != nil {
  6149. fields = append(fields, label.FieldFrom)
  6150. }
  6151. if m.mode != nil {
  6152. fields = append(fields, label.FieldMode)
  6153. }
  6154. if m.conditions != nil {
  6155. fields = append(fields, label.FieldConditions)
  6156. }
  6157. if m.organization_id != nil {
  6158. fields = append(fields, label.FieldOrganizationID)
  6159. }
  6160. return fields
  6161. }
  6162. // Field returns the value of a field with the given name. The second boolean
  6163. // return value indicates that this field was not set, or was not defined in the
  6164. // schema.
  6165. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  6166. switch name {
  6167. case label.FieldCreatedAt:
  6168. return m.CreatedAt()
  6169. case label.FieldUpdatedAt:
  6170. return m.UpdatedAt()
  6171. case label.FieldStatus:
  6172. return m.Status()
  6173. case label.FieldType:
  6174. return m.GetType()
  6175. case label.FieldName:
  6176. return m.Name()
  6177. case label.FieldFrom:
  6178. return m.From()
  6179. case label.FieldMode:
  6180. return m.Mode()
  6181. case label.FieldConditions:
  6182. return m.Conditions()
  6183. case label.FieldOrganizationID:
  6184. return m.OrganizationID()
  6185. }
  6186. return nil, false
  6187. }
  6188. // OldField returns the old value of the field from the database. An error is
  6189. // returned if the mutation operation is not UpdateOne, or the query to the
  6190. // database failed.
  6191. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6192. switch name {
  6193. case label.FieldCreatedAt:
  6194. return m.OldCreatedAt(ctx)
  6195. case label.FieldUpdatedAt:
  6196. return m.OldUpdatedAt(ctx)
  6197. case label.FieldStatus:
  6198. return m.OldStatus(ctx)
  6199. case label.FieldType:
  6200. return m.OldType(ctx)
  6201. case label.FieldName:
  6202. return m.OldName(ctx)
  6203. case label.FieldFrom:
  6204. return m.OldFrom(ctx)
  6205. case label.FieldMode:
  6206. return m.OldMode(ctx)
  6207. case label.FieldConditions:
  6208. return m.OldConditions(ctx)
  6209. case label.FieldOrganizationID:
  6210. return m.OldOrganizationID(ctx)
  6211. }
  6212. return nil, fmt.Errorf("unknown Label field %s", name)
  6213. }
  6214. // SetField sets the value of a field with the given name. It returns an error if
  6215. // the field is not defined in the schema, or if the type mismatched the field
  6216. // type.
  6217. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  6218. switch name {
  6219. case label.FieldCreatedAt:
  6220. v, ok := value.(time.Time)
  6221. if !ok {
  6222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6223. }
  6224. m.SetCreatedAt(v)
  6225. return nil
  6226. case label.FieldUpdatedAt:
  6227. v, ok := value.(time.Time)
  6228. if !ok {
  6229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6230. }
  6231. m.SetUpdatedAt(v)
  6232. return nil
  6233. case label.FieldStatus:
  6234. v, ok := value.(uint8)
  6235. if !ok {
  6236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6237. }
  6238. m.SetStatus(v)
  6239. return nil
  6240. case label.FieldType:
  6241. v, ok := value.(int)
  6242. if !ok {
  6243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6244. }
  6245. m.SetType(v)
  6246. return nil
  6247. case label.FieldName:
  6248. v, ok := value.(string)
  6249. if !ok {
  6250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6251. }
  6252. m.SetName(v)
  6253. return nil
  6254. case label.FieldFrom:
  6255. v, ok := value.(int)
  6256. if !ok {
  6257. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6258. }
  6259. m.SetFrom(v)
  6260. return nil
  6261. case label.FieldMode:
  6262. v, ok := value.(int)
  6263. if !ok {
  6264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6265. }
  6266. m.SetMode(v)
  6267. return nil
  6268. case label.FieldConditions:
  6269. v, ok := value.(string)
  6270. if !ok {
  6271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6272. }
  6273. m.SetConditions(v)
  6274. return nil
  6275. case label.FieldOrganizationID:
  6276. v, ok := value.(uint64)
  6277. if !ok {
  6278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6279. }
  6280. m.SetOrganizationID(v)
  6281. return nil
  6282. }
  6283. return fmt.Errorf("unknown Label field %s", name)
  6284. }
  6285. // AddedFields returns all numeric fields that were incremented/decremented during
  6286. // this mutation.
  6287. func (m *LabelMutation) AddedFields() []string {
  6288. var fields []string
  6289. if m.addstatus != nil {
  6290. fields = append(fields, label.FieldStatus)
  6291. }
  6292. if m.add_type != nil {
  6293. fields = append(fields, label.FieldType)
  6294. }
  6295. if m.addfrom != nil {
  6296. fields = append(fields, label.FieldFrom)
  6297. }
  6298. if m.addmode != nil {
  6299. fields = append(fields, label.FieldMode)
  6300. }
  6301. if m.addorganization_id != nil {
  6302. fields = append(fields, label.FieldOrganizationID)
  6303. }
  6304. return fields
  6305. }
  6306. // AddedField returns the numeric value that was incremented/decremented on a field
  6307. // with the given name. The second boolean return value indicates that this field
  6308. // was not set, or was not defined in the schema.
  6309. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  6310. switch name {
  6311. case label.FieldStatus:
  6312. return m.AddedStatus()
  6313. case label.FieldType:
  6314. return m.AddedType()
  6315. case label.FieldFrom:
  6316. return m.AddedFrom()
  6317. case label.FieldMode:
  6318. return m.AddedMode()
  6319. case label.FieldOrganizationID:
  6320. return m.AddedOrganizationID()
  6321. }
  6322. return nil, false
  6323. }
  6324. // AddField adds the value to the field with the given name. It returns an error if
  6325. // the field is not defined in the schema, or if the type mismatched the field
  6326. // type.
  6327. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  6328. switch name {
  6329. case label.FieldStatus:
  6330. v, ok := value.(int8)
  6331. if !ok {
  6332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6333. }
  6334. m.AddStatus(v)
  6335. return nil
  6336. case label.FieldType:
  6337. v, ok := value.(int)
  6338. if !ok {
  6339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6340. }
  6341. m.AddType(v)
  6342. return nil
  6343. case label.FieldFrom:
  6344. v, ok := value.(int)
  6345. if !ok {
  6346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6347. }
  6348. m.AddFrom(v)
  6349. return nil
  6350. case label.FieldMode:
  6351. v, ok := value.(int)
  6352. if !ok {
  6353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6354. }
  6355. m.AddMode(v)
  6356. return nil
  6357. case label.FieldOrganizationID:
  6358. v, ok := value.(int64)
  6359. if !ok {
  6360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6361. }
  6362. m.AddOrganizationID(v)
  6363. return nil
  6364. }
  6365. return fmt.Errorf("unknown Label numeric field %s", name)
  6366. }
  6367. // ClearedFields returns all nullable fields that were cleared during this
  6368. // mutation.
  6369. func (m *LabelMutation) ClearedFields() []string {
  6370. var fields []string
  6371. if m.FieldCleared(label.FieldStatus) {
  6372. fields = append(fields, label.FieldStatus)
  6373. }
  6374. if m.FieldCleared(label.FieldConditions) {
  6375. fields = append(fields, label.FieldConditions)
  6376. }
  6377. if m.FieldCleared(label.FieldOrganizationID) {
  6378. fields = append(fields, label.FieldOrganizationID)
  6379. }
  6380. return fields
  6381. }
  6382. // FieldCleared returns a boolean indicating if a field with the given name was
  6383. // cleared in this mutation.
  6384. func (m *LabelMutation) FieldCleared(name string) bool {
  6385. _, ok := m.clearedFields[name]
  6386. return ok
  6387. }
  6388. // ClearField clears the value of the field with the given name. It returns an
  6389. // error if the field is not defined in the schema.
  6390. func (m *LabelMutation) ClearField(name string) error {
  6391. switch name {
  6392. case label.FieldStatus:
  6393. m.ClearStatus()
  6394. return nil
  6395. case label.FieldConditions:
  6396. m.ClearConditions()
  6397. return nil
  6398. case label.FieldOrganizationID:
  6399. m.ClearOrganizationID()
  6400. return nil
  6401. }
  6402. return fmt.Errorf("unknown Label nullable field %s", name)
  6403. }
  6404. // ResetField resets all changes in the mutation for the field with the given name.
  6405. // It returns an error if the field is not defined in the schema.
  6406. func (m *LabelMutation) ResetField(name string) error {
  6407. switch name {
  6408. case label.FieldCreatedAt:
  6409. m.ResetCreatedAt()
  6410. return nil
  6411. case label.FieldUpdatedAt:
  6412. m.ResetUpdatedAt()
  6413. return nil
  6414. case label.FieldStatus:
  6415. m.ResetStatus()
  6416. return nil
  6417. case label.FieldType:
  6418. m.ResetType()
  6419. return nil
  6420. case label.FieldName:
  6421. m.ResetName()
  6422. return nil
  6423. case label.FieldFrom:
  6424. m.ResetFrom()
  6425. return nil
  6426. case label.FieldMode:
  6427. m.ResetMode()
  6428. return nil
  6429. case label.FieldConditions:
  6430. m.ResetConditions()
  6431. return nil
  6432. case label.FieldOrganizationID:
  6433. m.ResetOrganizationID()
  6434. return nil
  6435. }
  6436. return fmt.Errorf("unknown Label field %s", name)
  6437. }
  6438. // AddedEdges returns all edge names that were set/added in this mutation.
  6439. func (m *LabelMutation) AddedEdges() []string {
  6440. edges := make([]string, 0, 1)
  6441. if m.label_relationships != nil {
  6442. edges = append(edges, label.EdgeLabelRelationships)
  6443. }
  6444. return edges
  6445. }
  6446. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6447. // name in this mutation.
  6448. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  6449. switch name {
  6450. case label.EdgeLabelRelationships:
  6451. ids := make([]ent.Value, 0, len(m.label_relationships))
  6452. for id := range m.label_relationships {
  6453. ids = append(ids, id)
  6454. }
  6455. return ids
  6456. }
  6457. return nil
  6458. }
  6459. // RemovedEdges returns all edge names that were removed in this mutation.
  6460. func (m *LabelMutation) RemovedEdges() []string {
  6461. edges := make([]string, 0, 1)
  6462. if m.removedlabel_relationships != nil {
  6463. edges = append(edges, label.EdgeLabelRelationships)
  6464. }
  6465. return edges
  6466. }
  6467. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6468. // the given name in this mutation.
  6469. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  6470. switch name {
  6471. case label.EdgeLabelRelationships:
  6472. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  6473. for id := range m.removedlabel_relationships {
  6474. ids = append(ids, id)
  6475. }
  6476. return ids
  6477. }
  6478. return nil
  6479. }
  6480. // ClearedEdges returns all edge names that were cleared in this mutation.
  6481. func (m *LabelMutation) ClearedEdges() []string {
  6482. edges := make([]string, 0, 1)
  6483. if m.clearedlabel_relationships {
  6484. edges = append(edges, label.EdgeLabelRelationships)
  6485. }
  6486. return edges
  6487. }
  6488. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6489. // was cleared in this mutation.
  6490. func (m *LabelMutation) EdgeCleared(name string) bool {
  6491. switch name {
  6492. case label.EdgeLabelRelationships:
  6493. return m.clearedlabel_relationships
  6494. }
  6495. return false
  6496. }
  6497. // ClearEdge clears the value of the edge with the given name. It returns an error
  6498. // if that edge is not defined in the schema.
  6499. func (m *LabelMutation) ClearEdge(name string) error {
  6500. switch name {
  6501. }
  6502. return fmt.Errorf("unknown Label unique edge %s", name)
  6503. }
  6504. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6505. // It returns an error if the edge is not defined in the schema.
  6506. func (m *LabelMutation) ResetEdge(name string) error {
  6507. switch name {
  6508. case label.EdgeLabelRelationships:
  6509. m.ResetLabelRelationships()
  6510. return nil
  6511. }
  6512. return fmt.Errorf("unknown Label edge %s", name)
  6513. }
  6514. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  6515. type LabelRelationshipMutation struct {
  6516. config
  6517. op Op
  6518. typ string
  6519. id *uint64
  6520. created_at *time.Time
  6521. updated_at *time.Time
  6522. status *uint8
  6523. addstatus *int8
  6524. deleted_at *time.Time
  6525. organization_id *uint64
  6526. addorganization_id *int64
  6527. clearedFields map[string]struct{}
  6528. contacts *uint64
  6529. clearedcontacts bool
  6530. labels *uint64
  6531. clearedlabels bool
  6532. done bool
  6533. oldValue func(context.Context) (*LabelRelationship, error)
  6534. predicates []predicate.LabelRelationship
  6535. }
  6536. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  6537. // labelrelationshipOption allows management of the mutation configuration using functional options.
  6538. type labelrelationshipOption func(*LabelRelationshipMutation)
  6539. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  6540. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  6541. m := &LabelRelationshipMutation{
  6542. config: c,
  6543. op: op,
  6544. typ: TypeLabelRelationship,
  6545. clearedFields: make(map[string]struct{}),
  6546. }
  6547. for _, opt := range opts {
  6548. opt(m)
  6549. }
  6550. return m
  6551. }
  6552. // withLabelRelationshipID sets the ID field of the mutation.
  6553. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  6554. return func(m *LabelRelationshipMutation) {
  6555. var (
  6556. err error
  6557. once sync.Once
  6558. value *LabelRelationship
  6559. )
  6560. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  6561. once.Do(func() {
  6562. if m.done {
  6563. err = errors.New("querying old values post mutation is not allowed")
  6564. } else {
  6565. value, err = m.Client().LabelRelationship.Get(ctx, id)
  6566. }
  6567. })
  6568. return value, err
  6569. }
  6570. m.id = &id
  6571. }
  6572. }
  6573. // withLabelRelationship sets the old LabelRelationship of the mutation.
  6574. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  6575. return func(m *LabelRelationshipMutation) {
  6576. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  6577. return node, nil
  6578. }
  6579. m.id = &node.ID
  6580. }
  6581. }
  6582. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6583. // executed in a transaction (ent.Tx), a transactional client is returned.
  6584. func (m LabelRelationshipMutation) Client() *Client {
  6585. client := &Client{config: m.config}
  6586. client.init()
  6587. return client
  6588. }
  6589. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6590. // it returns an error otherwise.
  6591. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  6592. if _, ok := m.driver.(*txDriver); !ok {
  6593. return nil, errors.New("ent: mutation is not running in a transaction")
  6594. }
  6595. tx := &Tx{config: m.config}
  6596. tx.init()
  6597. return tx, nil
  6598. }
  6599. // SetID sets the value of the id field. Note that this
  6600. // operation is only accepted on creation of LabelRelationship entities.
  6601. func (m *LabelRelationshipMutation) SetID(id uint64) {
  6602. m.id = &id
  6603. }
  6604. // ID returns the ID value in the mutation. Note that the ID is only available
  6605. // if it was provided to the builder or after it was returned from the database.
  6606. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  6607. if m.id == nil {
  6608. return
  6609. }
  6610. return *m.id, true
  6611. }
  6612. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6613. // That means, if the mutation is applied within a transaction with an isolation level such
  6614. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6615. // or updated by the mutation.
  6616. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  6617. switch {
  6618. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6619. id, exists := m.ID()
  6620. if exists {
  6621. return []uint64{id}, nil
  6622. }
  6623. fallthrough
  6624. case m.op.Is(OpUpdate | OpDelete):
  6625. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  6626. default:
  6627. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6628. }
  6629. }
  6630. // SetCreatedAt sets the "created_at" field.
  6631. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  6632. m.created_at = &t
  6633. }
  6634. // CreatedAt returns the value of the "created_at" field in the mutation.
  6635. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  6636. v := m.created_at
  6637. if v == nil {
  6638. return
  6639. }
  6640. return *v, true
  6641. }
  6642. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  6643. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  6644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6645. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6646. if !m.op.Is(OpUpdateOne) {
  6647. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6648. }
  6649. if m.id == nil || m.oldValue == nil {
  6650. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6651. }
  6652. oldValue, err := m.oldValue(ctx)
  6653. if err != nil {
  6654. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6655. }
  6656. return oldValue.CreatedAt, nil
  6657. }
  6658. // ResetCreatedAt resets all changes to the "created_at" field.
  6659. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  6660. m.created_at = nil
  6661. }
  6662. // SetUpdatedAt sets the "updated_at" field.
  6663. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  6664. m.updated_at = &t
  6665. }
  6666. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6667. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  6668. v := m.updated_at
  6669. if v == nil {
  6670. return
  6671. }
  6672. return *v, true
  6673. }
  6674. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  6675. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  6676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6677. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6678. if !m.op.Is(OpUpdateOne) {
  6679. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6680. }
  6681. if m.id == nil || m.oldValue == nil {
  6682. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6683. }
  6684. oldValue, err := m.oldValue(ctx)
  6685. if err != nil {
  6686. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6687. }
  6688. return oldValue.UpdatedAt, nil
  6689. }
  6690. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6691. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  6692. m.updated_at = nil
  6693. }
  6694. // SetStatus sets the "status" field.
  6695. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  6696. m.status = &u
  6697. m.addstatus = nil
  6698. }
  6699. // Status returns the value of the "status" field in the mutation.
  6700. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  6701. v := m.status
  6702. if v == nil {
  6703. return
  6704. }
  6705. return *v, true
  6706. }
  6707. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  6708. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  6709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6710. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  6711. if !m.op.Is(OpUpdateOne) {
  6712. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  6713. }
  6714. if m.id == nil || m.oldValue == nil {
  6715. return v, errors.New("OldStatus requires an ID field in the mutation")
  6716. }
  6717. oldValue, err := m.oldValue(ctx)
  6718. if err != nil {
  6719. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  6720. }
  6721. return oldValue.Status, nil
  6722. }
  6723. // AddStatus adds u to the "status" field.
  6724. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  6725. if m.addstatus != nil {
  6726. *m.addstatus += u
  6727. } else {
  6728. m.addstatus = &u
  6729. }
  6730. }
  6731. // AddedStatus returns the value that was added to the "status" field in this mutation.
  6732. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  6733. v := m.addstatus
  6734. if v == nil {
  6735. return
  6736. }
  6737. return *v, true
  6738. }
  6739. // ClearStatus clears the value of the "status" field.
  6740. func (m *LabelRelationshipMutation) ClearStatus() {
  6741. m.status = nil
  6742. m.addstatus = nil
  6743. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  6744. }
  6745. // StatusCleared returns if the "status" field was cleared in this mutation.
  6746. func (m *LabelRelationshipMutation) StatusCleared() bool {
  6747. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  6748. return ok
  6749. }
  6750. // ResetStatus resets all changes to the "status" field.
  6751. func (m *LabelRelationshipMutation) ResetStatus() {
  6752. m.status = nil
  6753. m.addstatus = nil
  6754. delete(m.clearedFields, labelrelationship.FieldStatus)
  6755. }
  6756. // SetDeletedAt sets the "deleted_at" field.
  6757. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  6758. m.deleted_at = &t
  6759. }
  6760. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6761. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  6762. v := m.deleted_at
  6763. if v == nil {
  6764. return
  6765. }
  6766. return *v, true
  6767. }
  6768. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  6769. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  6770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6771. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6772. if !m.op.Is(OpUpdateOne) {
  6773. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6774. }
  6775. if m.id == nil || m.oldValue == nil {
  6776. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6777. }
  6778. oldValue, err := m.oldValue(ctx)
  6779. if err != nil {
  6780. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6781. }
  6782. return oldValue.DeletedAt, nil
  6783. }
  6784. // ClearDeletedAt clears the value of the "deleted_at" field.
  6785. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  6786. m.deleted_at = nil
  6787. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  6788. }
  6789. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6790. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  6791. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  6792. return ok
  6793. }
  6794. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6795. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  6796. m.deleted_at = nil
  6797. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  6798. }
  6799. // SetLabelID sets the "label_id" field.
  6800. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  6801. m.labels = &u
  6802. }
  6803. // LabelID returns the value of the "label_id" field in the mutation.
  6804. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  6805. v := m.labels
  6806. if v == nil {
  6807. return
  6808. }
  6809. return *v, true
  6810. }
  6811. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  6812. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  6813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6814. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  6815. if !m.op.Is(OpUpdateOne) {
  6816. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  6817. }
  6818. if m.id == nil || m.oldValue == nil {
  6819. return v, errors.New("OldLabelID requires an ID field in the mutation")
  6820. }
  6821. oldValue, err := m.oldValue(ctx)
  6822. if err != nil {
  6823. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  6824. }
  6825. return oldValue.LabelID, nil
  6826. }
  6827. // ResetLabelID resets all changes to the "label_id" field.
  6828. func (m *LabelRelationshipMutation) ResetLabelID() {
  6829. m.labels = nil
  6830. }
  6831. // SetContactID sets the "contact_id" field.
  6832. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  6833. m.contacts = &u
  6834. }
  6835. // ContactID returns the value of the "contact_id" field in the mutation.
  6836. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  6837. v := m.contacts
  6838. if v == nil {
  6839. return
  6840. }
  6841. return *v, true
  6842. }
  6843. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  6844. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  6845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6846. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  6847. if !m.op.Is(OpUpdateOne) {
  6848. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  6849. }
  6850. if m.id == nil || m.oldValue == nil {
  6851. return v, errors.New("OldContactID requires an ID field in the mutation")
  6852. }
  6853. oldValue, err := m.oldValue(ctx)
  6854. if err != nil {
  6855. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  6856. }
  6857. return oldValue.ContactID, nil
  6858. }
  6859. // ResetContactID resets all changes to the "contact_id" field.
  6860. func (m *LabelRelationshipMutation) ResetContactID() {
  6861. m.contacts = nil
  6862. }
  6863. // SetOrganizationID sets the "organization_id" field.
  6864. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  6865. m.organization_id = &u
  6866. m.addorganization_id = nil
  6867. }
  6868. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6869. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  6870. v := m.organization_id
  6871. if v == nil {
  6872. return
  6873. }
  6874. return *v, true
  6875. }
  6876. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  6877. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  6878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6879. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6880. if !m.op.Is(OpUpdateOne) {
  6881. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6882. }
  6883. if m.id == nil || m.oldValue == nil {
  6884. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6885. }
  6886. oldValue, err := m.oldValue(ctx)
  6887. if err != nil {
  6888. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6889. }
  6890. return oldValue.OrganizationID, nil
  6891. }
  6892. // AddOrganizationID adds u to the "organization_id" field.
  6893. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  6894. if m.addorganization_id != nil {
  6895. *m.addorganization_id += u
  6896. } else {
  6897. m.addorganization_id = &u
  6898. }
  6899. }
  6900. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6901. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  6902. v := m.addorganization_id
  6903. if v == nil {
  6904. return
  6905. }
  6906. return *v, true
  6907. }
  6908. // ClearOrganizationID clears the value of the "organization_id" field.
  6909. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  6910. m.organization_id = nil
  6911. m.addorganization_id = nil
  6912. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  6913. }
  6914. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  6915. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  6916. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  6917. return ok
  6918. }
  6919. // ResetOrganizationID resets all changes to the "organization_id" field.
  6920. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  6921. m.organization_id = nil
  6922. m.addorganization_id = nil
  6923. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  6924. }
  6925. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  6926. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  6927. m.contacts = &id
  6928. }
  6929. // ClearContacts clears the "contacts" edge to the Contact entity.
  6930. func (m *LabelRelationshipMutation) ClearContacts() {
  6931. m.clearedcontacts = true
  6932. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  6933. }
  6934. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  6935. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  6936. return m.clearedcontacts
  6937. }
  6938. // ContactsID returns the "contacts" edge ID in the mutation.
  6939. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  6940. if m.contacts != nil {
  6941. return *m.contacts, true
  6942. }
  6943. return
  6944. }
  6945. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  6946. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  6947. // ContactsID instead. It exists only for internal usage by the builders.
  6948. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  6949. if id := m.contacts; id != nil {
  6950. ids = append(ids, *id)
  6951. }
  6952. return
  6953. }
  6954. // ResetContacts resets all changes to the "contacts" edge.
  6955. func (m *LabelRelationshipMutation) ResetContacts() {
  6956. m.contacts = nil
  6957. m.clearedcontacts = false
  6958. }
  6959. // SetLabelsID sets the "labels" edge to the Label entity by id.
  6960. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  6961. m.labels = &id
  6962. }
  6963. // ClearLabels clears the "labels" edge to the Label entity.
  6964. func (m *LabelRelationshipMutation) ClearLabels() {
  6965. m.clearedlabels = true
  6966. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  6967. }
  6968. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  6969. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  6970. return m.clearedlabels
  6971. }
  6972. // LabelsID returns the "labels" edge ID in the mutation.
  6973. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  6974. if m.labels != nil {
  6975. return *m.labels, true
  6976. }
  6977. return
  6978. }
  6979. // LabelsIDs returns the "labels" edge IDs in the mutation.
  6980. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  6981. // LabelsID instead. It exists only for internal usage by the builders.
  6982. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  6983. if id := m.labels; id != nil {
  6984. ids = append(ids, *id)
  6985. }
  6986. return
  6987. }
  6988. // ResetLabels resets all changes to the "labels" edge.
  6989. func (m *LabelRelationshipMutation) ResetLabels() {
  6990. m.labels = nil
  6991. m.clearedlabels = false
  6992. }
  6993. // Where appends a list predicates to the LabelRelationshipMutation builder.
  6994. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  6995. m.predicates = append(m.predicates, ps...)
  6996. }
  6997. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  6998. // users can use type-assertion to append predicates that do not depend on any generated package.
  6999. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  7000. p := make([]predicate.LabelRelationship, len(ps))
  7001. for i := range ps {
  7002. p[i] = ps[i]
  7003. }
  7004. m.Where(p...)
  7005. }
  7006. // Op returns the operation name.
  7007. func (m *LabelRelationshipMutation) Op() Op {
  7008. return m.op
  7009. }
  7010. // SetOp allows setting the mutation operation.
  7011. func (m *LabelRelationshipMutation) SetOp(op Op) {
  7012. m.op = op
  7013. }
  7014. // Type returns the node type of this mutation (LabelRelationship).
  7015. func (m *LabelRelationshipMutation) Type() string {
  7016. return m.typ
  7017. }
  7018. // Fields returns all fields that were changed during this mutation. Note that in
  7019. // order to get all numeric fields that were incremented/decremented, call
  7020. // AddedFields().
  7021. func (m *LabelRelationshipMutation) Fields() []string {
  7022. fields := make([]string, 0, 7)
  7023. if m.created_at != nil {
  7024. fields = append(fields, labelrelationship.FieldCreatedAt)
  7025. }
  7026. if m.updated_at != nil {
  7027. fields = append(fields, labelrelationship.FieldUpdatedAt)
  7028. }
  7029. if m.status != nil {
  7030. fields = append(fields, labelrelationship.FieldStatus)
  7031. }
  7032. if m.deleted_at != nil {
  7033. fields = append(fields, labelrelationship.FieldDeletedAt)
  7034. }
  7035. if m.labels != nil {
  7036. fields = append(fields, labelrelationship.FieldLabelID)
  7037. }
  7038. if m.contacts != nil {
  7039. fields = append(fields, labelrelationship.FieldContactID)
  7040. }
  7041. if m.organization_id != nil {
  7042. fields = append(fields, labelrelationship.FieldOrganizationID)
  7043. }
  7044. return fields
  7045. }
  7046. // Field returns the value of a field with the given name. The second boolean
  7047. // return value indicates that this field was not set, or was not defined in the
  7048. // schema.
  7049. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  7050. switch name {
  7051. case labelrelationship.FieldCreatedAt:
  7052. return m.CreatedAt()
  7053. case labelrelationship.FieldUpdatedAt:
  7054. return m.UpdatedAt()
  7055. case labelrelationship.FieldStatus:
  7056. return m.Status()
  7057. case labelrelationship.FieldDeletedAt:
  7058. return m.DeletedAt()
  7059. case labelrelationship.FieldLabelID:
  7060. return m.LabelID()
  7061. case labelrelationship.FieldContactID:
  7062. return m.ContactID()
  7063. case labelrelationship.FieldOrganizationID:
  7064. return m.OrganizationID()
  7065. }
  7066. return nil, false
  7067. }
  7068. // OldField returns the old value of the field from the database. An error is
  7069. // returned if the mutation operation is not UpdateOne, or the query to the
  7070. // database failed.
  7071. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7072. switch name {
  7073. case labelrelationship.FieldCreatedAt:
  7074. return m.OldCreatedAt(ctx)
  7075. case labelrelationship.FieldUpdatedAt:
  7076. return m.OldUpdatedAt(ctx)
  7077. case labelrelationship.FieldStatus:
  7078. return m.OldStatus(ctx)
  7079. case labelrelationship.FieldDeletedAt:
  7080. return m.OldDeletedAt(ctx)
  7081. case labelrelationship.FieldLabelID:
  7082. return m.OldLabelID(ctx)
  7083. case labelrelationship.FieldContactID:
  7084. return m.OldContactID(ctx)
  7085. case labelrelationship.FieldOrganizationID:
  7086. return m.OldOrganizationID(ctx)
  7087. }
  7088. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  7089. }
  7090. // SetField sets the value of a field with the given name. It returns an error if
  7091. // the field is not defined in the schema, or if the type mismatched the field
  7092. // type.
  7093. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  7094. switch name {
  7095. case labelrelationship.FieldCreatedAt:
  7096. v, ok := value.(time.Time)
  7097. if !ok {
  7098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7099. }
  7100. m.SetCreatedAt(v)
  7101. return nil
  7102. case labelrelationship.FieldUpdatedAt:
  7103. v, ok := value.(time.Time)
  7104. if !ok {
  7105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7106. }
  7107. m.SetUpdatedAt(v)
  7108. return nil
  7109. case labelrelationship.FieldStatus:
  7110. v, ok := value.(uint8)
  7111. if !ok {
  7112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7113. }
  7114. m.SetStatus(v)
  7115. return nil
  7116. case labelrelationship.FieldDeletedAt:
  7117. v, ok := value.(time.Time)
  7118. if !ok {
  7119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7120. }
  7121. m.SetDeletedAt(v)
  7122. return nil
  7123. case labelrelationship.FieldLabelID:
  7124. v, ok := value.(uint64)
  7125. if !ok {
  7126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7127. }
  7128. m.SetLabelID(v)
  7129. return nil
  7130. case labelrelationship.FieldContactID:
  7131. v, ok := value.(uint64)
  7132. if !ok {
  7133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7134. }
  7135. m.SetContactID(v)
  7136. return nil
  7137. case labelrelationship.FieldOrganizationID:
  7138. v, ok := value.(uint64)
  7139. if !ok {
  7140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7141. }
  7142. m.SetOrganizationID(v)
  7143. return nil
  7144. }
  7145. return fmt.Errorf("unknown LabelRelationship field %s", name)
  7146. }
  7147. // AddedFields returns all numeric fields that were incremented/decremented during
  7148. // this mutation.
  7149. func (m *LabelRelationshipMutation) AddedFields() []string {
  7150. var fields []string
  7151. if m.addstatus != nil {
  7152. fields = append(fields, labelrelationship.FieldStatus)
  7153. }
  7154. if m.addorganization_id != nil {
  7155. fields = append(fields, labelrelationship.FieldOrganizationID)
  7156. }
  7157. return fields
  7158. }
  7159. // AddedField returns the numeric value that was incremented/decremented on a field
  7160. // with the given name. The second boolean return value indicates that this field
  7161. // was not set, or was not defined in the schema.
  7162. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  7163. switch name {
  7164. case labelrelationship.FieldStatus:
  7165. return m.AddedStatus()
  7166. case labelrelationship.FieldOrganizationID:
  7167. return m.AddedOrganizationID()
  7168. }
  7169. return nil, false
  7170. }
  7171. // AddField adds the value to the field with the given name. It returns an error if
  7172. // the field is not defined in the schema, or if the type mismatched the field
  7173. // type.
  7174. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  7175. switch name {
  7176. case labelrelationship.FieldStatus:
  7177. v, ok := value.(int8)
  7178. if !ok {
  7179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7180. }
  7181. m.AddStatus(v)
  7182. return nil
  7183. case labelrelationship.FieldOrganizationID:
  7184. v, ok := value.(int64)
  7185. if !ok {
  7186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7187. }
  7188. m.AddOrganizationID(v)
  7189. return nil
  7190. }
  7191. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  7192. }
  7193. // ClearedFields returns all nullable fields that were cleared during this
  7194. // mutation.
  7195. func (m *LabelRelationshipMutation) ClearedFields() []string {
  7196. var fields []string
  7197. if m.FieldCleared(labelrelationship.FieldStatus) {
  7198. fields = append(fields, labelrelationship.FieldStatus)
  7199. }
  7200. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  7201. fields = append(fields, labelrelationship.FieldDeletedAt)
  7202. }
  7203. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  7204. fields = append(fields, labelrelationship.FieldOrganizationID)
  7205. }
  7206. return fields
  7207. }
  7208. // FieldCleared returns a boolean indicating if a field with the given name was
  7209. // cleared in this mutation.
  7210. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  7211. _, ok := m.clearedFields[name]
  7212. return ok
  7213. }
  7214. // ClearField clears the value of the field with the given name. It returns an
  7215. // error if the field is not defined in the schema.
  7216. func (m *LabelRelationshipMutation) ClearField(name string) error {
  7217. switch name {
  7218. case labelrelationship.FieldStatus:
  7219. m.ClearStatus()
  7220. return nil
  7221. case labelrelationship.FieldDeletedAt:
  7222. m.ClearDeletedAt()
  7223. return nil
  7224. case labelrelationship.FieldOrganizationID:
  7225. m.ClearOrganizationID()
  7226. return nil
  7227. }
  7228. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  7229. }
  7230. // ResetField resets all changes in the mutation for the field with the given name.
  7231. // It returns an error if the field is not defined in the schema.
  7232. func (m *LabelRelationshipMutation) ResetField(name string) error {
  7233. switch name {
  7234. case labelrelationship.FieldCreatedAt:
  7235. m.ResetCreatedAt()
  7236. return nil
  7237. case labelrelationship.FieldUpdatedAt:
  7238. m.ResetUpdatedAt()
  7239. return nil
  7240. case labelrelationship.FieldStatus:
  7241. m.ResetStatus()
  7242. return nil
  7243. case labelrelationship.FieldDeletedAt:
  7244. m.ResetDeletedAt()
  7245. return nil
  7246. case labelrelationship.FieldLabelID:
  7247. m.ResetLabelID()
  7248. return nil
  7249. case labelrelationship.FieldContactID:
  7250. m.ResetContactID()
  7251. return nil
  7252. case labelrelationship.FieldOrganizationID:
  7253. m.ResetOrganizationID()
  7254. return nil
  7255. }
  7256. return fmt.Errorf("unknown LabelRelationship field %s", name)
  7257. }
  7258. // AddedEdges returns all edge names that were set/added in this mutation.
  7259. func (m *LabelRelationshipMutation) AddedEdges() []string {
  7260. edges := make([]string, 0, 2)
  7261. if m.contacts != nil {
  7262. edges = append(edges, labelrelationship.EdgeContacts)
  7263. }
  7264. if m.labels != nil {
  7265. edges = append(edges, labelrelationship.EdgeLabels)
  7266. }
  7267. return edges
  7268. }
  7269. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7270. // name in this mutation.
  7271. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  7272. switch name {
  7273. case labelrelationship.EdgeContacts:
  7274. if id := m.contacts; id != nil {
  7275. return []ent.Value{*id}
  7276. }
  7277. case labelrelationship.EdgeLabels:
  7278. if id := m.labels; id != nil {
  7279. return []ent.Value{*id}
  7280. }
  7281. }
  7282. return nil
  7283. }
  7284. // RemovedEdges returns all edge names that were removed in this mutation.
  7285. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  7286. edges := make([]string, 0, 2)
  7287. return edges
  7288. }
  7289. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7290. // the given name in this mutation.
  7291. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  7292. return nil
  7293. }
  7294. // ClearedEdges returns all edge names that were cleared in this mutation.
  7295. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  7296. edges := make([]string, 0, 2)
  7297. if m.clearedcontacts {
  7298. edges = append(edges, labelrelationship.EdgeContacts)
  7299. }
  7300. if m.clearedlabels {
  7301. edges = append(edges, labelrelationship.EdgeLabels)
  7302. }
  7303. return edges
  7304. }
  7305. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7306. // was cleared in this mutation.
  7307. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  7308. switch name {
  7309. case labelrelationship.EdgeContacts:
  7310. return m.clearedcontacts
  7311. case labelrelationship.EdgeLabels:
  7312. return m.clearedlabels
  7313. }
  7314. return false
  7315. }
  7316. // ClearEdge clears the value of the edge with the given name. It returns an error
  7317. // if that edge is not defined in the schema.
  7318. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  7319. switch name {
  7320. case labelrelationship.EdgeContacts:
  7321. m.ClearContacts()
  7322. return nil
  7323. case labelrelationship.EdgeLabels:
  7324. m.ClearLabels()
  7325. return nil
  7326. }
  7327. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  7328. }
  7329. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7330. // It returns an error if the edge is not defined in the schema.
  7331. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  7332. switch name {
  7333. case labelrelationship.EdgeContacts:
  7334. m.ResetContacts()
  7335. return nil
  7336. case labelrelationship.EdgeLabels:
  7337. m.ResetLabels()
  7338. return nil
  7339. }
  7340. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  7341. }
  7342. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  7343. type MessageMutation struct {
  7344. config
  7345. op Op
  7346. typ string
  7347. id *int
  7348. wx_wxid *string
  7349. wxid *string
  7350. content *string
  7351. clearedFields map[string]struct{}
  7352. done bool
  7353. oldValue func(context.Context) (*Message, error)
  7354. predicates []predicate.Message
  7355. }
  7356. var _ ent.Mutation = (*MessageMutation)(nil)
  7357. // messageOption allows management of the mutation configuration using functional options.
  7358. type messageOption func(*MessageMutation)
  7359. // newMessageMutation creates new mutation for the Message entity.
  7360. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  7361. m := &MessageMutation{
  7362. config: c,
  7363. op: op,
  7364. typ: TypeMessage,
  7365. clearedFields: make(map[string]struct{}),
  7366. }
  7367. for _, opt := range opts {
  7368. opt(m)
  7369. }
  7370. return m
  7371. }
  7372. // withMessageID sets the ID field of the mutation.
  7373. func withMessageID(id int) messageOption {
  7374. return func(m *MessageMutation) {
  7375. var (
  7376. err error
  7377. once sync.Once
  7378. value *Message
  7379. )
  7380. m.oldValue = func(ctx context.Context) (*Message, error) {
  7381. once.Do(func() {
  7382. if m.done {
  7383. err = errors.New("querying old values post mutation is not allowed")
  7384. } else {
  7385. value, err = m.Client().Message.Get(ctx, id)
  7386. }
  7387. })
  7388. return value, err
  7389. }
  7390. m.id = &id
  7391. }
  7392. }
  7393. // withMessage sets the old Message of the mutation.
  7394. func withMessage(node *Message) messageOption {
  7395. return func(m *MessageMutation) {
  7396. m.oldValue = func(context.Context) (*Message, error) {
  7397. return node, nil
  7398. }
  7399. m.id = &node.ID
  7400. }
  7401. }
  7402. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7403. // executed in a transaction (ent.Tx), a transactional client is returned.
  7404. func (m MessageMutation) Client() *Client {
  7405. client := &Client{config: m.config}
  7406. client.init()
  7407. return client
  7408. }
  7409. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7410. // it returns an error otherwise.
  7411. func (m MessageMutation) Tx() (*Tx, error) {
  7412. if _, ok := m.driver.(*txDriver); !ok {
  7413. return nil, errors.New("ent: mutation is not running in a transaction")
  7414. }
  7415. tx := &Tx{config: m.config}
  7416. tx.init()
  7417. return tx, nil
  7418. }
  7419. // ID returns the ID value in the mutation. Note that the ID is only available
  7420. // if it was provided to the builder or after it was returned from the database.
  7421. func (m *MessageMutation) ID() (id int, exists bool) {
  7422. if m.id == nil {
  7423. return
  7424. }
  7425. return *m.id, true
  7426. }
  7427. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7428. // That means, if the mutation is applied within a transaction with an isolation level such
  7429. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7430. // or updated by the mutation.
  7431. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  7432. switch {
  7433. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7434. id, exists := m.ID()
  7435. if exists {
  7436. return []int{id}, nil
  7437. }
  7438. fallthrough
  7439. case m.op.Is(OpUpdate | OpDelete):
  7440. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  7441. default:
  7442. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7443. }
  7444. }
  7445. // SetWxWxid sets the "wx_wxid" field.
  7446. func (m *MessageMutation) SetWxWxid(s string) {
  7447. m.wx_wxid = &s
  7448. }
  7449. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7450. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  7451. v := m.wx_wxid
  7452. if v == nil {
  7453. return
  7454. }
  7455. return *v, true
  7456. }
  7457. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  7458. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  7459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7460. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  7461. if !m.op.Is(OpUpdateOne) {
  7462. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  7463. }
  7464. if m.id == nil || m.oldValue == nil {
  7465. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  7466. }
  7467. oldValue, err := m.oldValue(ctx)
  7468. if err != nil {
  7469. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  7470. }
  7471. return oldValue.WxWxid, nil
  7472. }
  7473. // ClearWxWxid clears the value of the "wx_wxid" field.
  7474. func (m *MessageMutation) ClearWxWxid() {
  7475. m.wx_wxid = nil
  7476. m.clearedFields[message.FieldWxWxid] = struct{}{}
  7477. }
  7478. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  7479. func (m *MessageMutation) WxWxidCleared() bool {
  7480. _, ok := m.clearedFields[message.FieldWxWxid]
  7481. return ok
  7482. }
  7483. // ResetWxWxid resets all changes to the "wx_wxid" field.
  7484. func (m *MessageMutation) ResetWxWxid() {
  7485. m.wx_wxid = nil
  7486. delete(m.clearedFields, message.FieldWxWxid)
  7487. }
  7488. // SetWxid sets the "wxid" field.
  7489. func (m *MessageMutation) SetWxid(s string) {
  7490. m.wxid = &s
  7491. }
  7492. // Wxid returns the value of the "wxid" field in the mutation.
  7493. func (m *MessageMutation) Wxid() (r string, exists bool) {
  7494. v := m.wxid
  7495. if v == nil {
  7496. return
  7497. }
  7498. return *v, true
  7499. }
  7500. // OldWxid returns the old "wxid" field's value of the Message entity.
  7501. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  7502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7503. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  7504. if !m.op.Is(OpUpdateOne) {
  7505. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  7506. }
  7507. if m.id == nil || m.oldValue == nil {
  7508. return v, errors.New("OldWxid requires an ID field in the mutation")
  7509. }
  7510. oldValue, err := m.oldValue(ctx)
  7511. if err != nil {
  7512. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  7513. }
  7514. return oldValue.Wxid, nil
  7515. }
  7516. // ResetWxid resets all changes to the "wxid" field.
  7517. func (m *MessageMutation) ResetWxid() {
  7518. m.wxid = nil
  7519. }
  7520. // SetContent sets the "content" field.
  7521. func (m *MessageMutation) SetContent(s string) {
  7522. m.content = &s
  7523. }
  7524. // Content returns the value of the "content" field in the mutation.
  7525. func (m *MessageMutation) Content() (r string, exists bool) {
  7526. v := m.content
  7527. if v == nil {
  7528. return
  7529. }
  7530. return *v, true
  7531. }
  7532. // OldContent returns the old "content" field's value of the Message entity.
  7533. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  7534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7535. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  7536. if !m.op.Is(OpUpdateOne) {
  7537. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  7538. }
  7539. if m.id == nil || m.oldValue == nil {
  7540. return v, errors.New("OldContent requires an ID field in the mutation")
  7541. }
  7542. oldValue, err := m.oldValue(ctx)
  7543. if err != nil {
  7544. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  7545. }
  7546. return oldValue.Content, nil
  7547. }
  7548. // ResetContent resets all changes to the "content" field.
  7549. func (m *MessageMutation) ResetContent() {
  7550. m.content = nil
  7551. }
  7552. // Where appends a list predicates to the MessageMutation builder.
  7553. func (m *MessageMutation) Where(ps ...predicate.Message) {
  7554. m.predicates = append(m.predicates, ps...)
  7555. }
  7556. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  7557. // users can use type-assertion to append predicates that do not depend on any generated package.
  7558. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  7559. p := make([]predicate.Message, len(ps))
  7560. for i := range ps {
  7561. p[i] = ps[i]
  7562. }
  7563. m.Where(p...)
  7564. }
  7565. // Op returns the operation name.
  7566. func (m *MessageMutation) Op() Op {
  7567. return m.op
  7568. }
  7569. // SetOp allows setting the mutation operation.
  7570. func (m *MessageMutation) SetOp(op Op) {
  7571. m.op = op
  7572. }
  7573. // Type returns the node type of this mutation (Message).
  7574. func (m *MessageMutation) Type() string {
  7575. return m.typ
  7576. }
  7577. // Fields returns all fields that were changed during this mutation. Note that in
  7578. // order to get all numeric fields that were incremented/decremented, call
  7579. // AddedFields().
  7580. func (m *MessageMutation) Fields() []string {
  7581. fields := make([]string, 0, 3)
  7582. if m.wx_wxid != nil {
  7583. fields = append(fields, message.FieldWxWxid)
  7584. }
  7585. if m.wxid != nil {
  7586. fields = append(fields, message.FieldWxid)
  7587. }
  7588. if m.content != nil {
  7589. fields = append(fields, message.FieldContent)
  7590. }
  7591. return fields
  7592. }
  7593. // Field returns the value of a field with the given name. The second boolean
  7594. // return value indicates that this field was not set, or was not defined in the
  7595. // schema.
  7596. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  7597. switch name {
  7598. case message.FieldWxWxid:
  7599. return m.WxWxid()
  7600. case message.FieldWxid:
  7601. return m.Wxid()
  7602. case message.FieldContent:
  7603. return m.Content()
  7604. }
  7605. return nil, false
  7606. }
  7607. // OldField returns the old value of the field from the database. An error is
  7608. // returned if the mutation operation is not UpdateOne, or the query to the
  7609. // database failed.
  7610. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7611. switch name {
  7612. case message.FieldWxWxid:
  7613. return m.OldWxWxid(ctx)
  7614. case message.FieldWxid:
  7615. return m.OldWxid(ctx)
  7616. case message.FieldContent:
  7617. return m.OldContent(ctx)
  7618. }
  7619. return nil, fmt.Errorf("unknown Message field %s", name)
  7620. }
  7621. // SetField sets the value of a field with the given name. It returns an error if
  7622. // the field is not defined in the schema, or if the type mismatched the field
  7623. // type.
  7624. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  7625. switch name {
  7626. case message.FieldWxWxid:
  7627. v, ok := value.(string)
  7628. if !ok {
  7629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7630. }
  7631. m.SetWxWxid(v)
  7632. return nil
  7633. case message.FieldWxid:
  7634. v, ok := value.(string)
  7635. if !ok {
  7636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7637. }
  7638. m.SetWxid(v)
  7639. return nil
  7640. case message.FieldContent:
  7641. v, ok := value.(string)
  7642. if !ok {
  7643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7644. }
  7645. m.SetContent(v)
  7646. return nil
  7647. }
  7648. return fmt.Errorf("unknown Message field %s", name)
  7649. }
  7650. // AddedFields returns all numeric fields that were incremented/decremented during
  7651. // this mutation.
  7652. func (m *MessageMutation) AddedFields() []string {
  7653. return nil
  7654. }
  7655. // AddedField returns the numeric value that was incremented/decremented on a field
  7656. // with the given name. The second boolean return value indicates that this field
  7657. // was not set, or was not defined in the schema.
  7658. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  7659. return nil, false
  7660. }
  7661. // AddField adds the value to the field with the given name. It returns an error if
  7662. // the field is not defined in the schema, or if the type mismatched the field
  7663. // type.
  7664. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  7665. switch name {
  7666. }
  7667. return fmt.Errorf("unknown Message numeric field %s", name)
  7668. }
  7669. // ClearedFields returns all nullable fields that were cleared during this
  7670. // mutation.
  7671. func (m *MessageMutation) ClearedFields() []string {
  7672. var fields []string
  7673. if m.FieldCleared(message.FieldWxWxid) {
  7674. fields = append(fields, message.FieldWxWxid)
  7675. }
  7676. return fields
  7677. }
  7678. // FieldCleared returns a boolean indicating if a field with the given name was
  7679. // cleared in this mutation.
  7680. func (m *MessageMutation) FieldCleared(name string) bool {
  7681. _, ok := m.clearedFields[name]
  7682. return ok
  7683. }
  7684. // ClearField clears the value of the field with the given name. It returns an
  7685. // error if the field is not defined in the schema.
  7686. func (m *MessageMutation) ClearField(name string) error {
  7687. switch name {
  7688. case message.FieldWxWxid:
  7689. m.ClearWxWxid()
  7690. return nil
  7691. }
  7692. return fmt.Errorf("unknown Message nullable field %s", name)
  7693. }
  7694. // ResetField resets all changes in the mutation for the field with the given name.
  7695. // It returns an error if the field is not defined in the schema.
  7696. func (m *MessageMutation) ResetField(name string) error {
  7697. switch name {
  7698. case message.FieldWxWxid:
  7699. m.ResetWxWxid()
  7700. return nil
  7701. case message.FieldWxid:
  7702. m.ResetWxid()
  7703. return nil
  7704. case message.FieldContent:
  7705. m.ResetContent()
  7706. return nil
  7707. }
  7708. return fmt.Errorf("unknown Message field %s", name)
  7709. }
  7710. // AddedEdges returns all edge names that were set/added in this mutation.
  7711. func (m *MessageMutation) AddedEdges() []string {
  7712. edges := make([]string, 0, 0)
  7713. return edges
  7714. }
  7715. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7716. // name in this mutation.
  7717. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  7718. return nil
  7719. }
  7720. // RemovedEdges returns all edge names that were removed in this mutation.
  7721. func (m *MessageMutation) RemovedEdges() []string {
  7722. edges := make([]string, 0, 0)
  7723. return edges
  7724. }
  7725. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7726. // the given name in this mutation.
  7727. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  7728. return nil
  7729. }
  7730. // ClearedEdges returns all edge names that were cleared in this mutation.
  7731. func (m *MessageMutation) ClearedEdges() []string {
  7732. edges := make([]string, 0, 0)
  7733. return edges
  7734. }
  7735. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7736. // was cleared in this mutation.
  7737. func (m *MessageMutation) EdgeCleared(name string) bool {
  7738. return false
  7739. }
  7740. // ClearEdge clears the value of the edge with the given name. It returns an error
  7741. // if that edge is not defined in the schema.
  7742. func (m *MessageMutation) ClearEdge(name string) error {
  7743. return fmt.Errorf("unknown Message unique edge %s", name)
  7744. }
  7745. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7746. // It returns an error if the edge is not defined in the schema.
  7747. func (m *MessageMutation) ResetEdge(name string) error {
  7748. return fmt.Errorf("unknown Message edge %s", name)
  7749. }
  7750. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  7751. type MessageRecordsMutation struct {
  7752. config
  7753. op Op
  7754. typ string
  7755. id *uint64
  7756. created_at *time.Time
  7757. updated_at *time.Time
  7758. status *uint8
  7759. addstatus *int8
  7760. deleted_at *time.Time
  7761. bot_wxid *string
  7762. contact_type *int
  7763. addcontact_type *int
  7764. contact_wxid *string
  7765. content_type *int
  7766. addcontent_type *int
  7767. content *string
  7768. meta *custom_types.Meta
  7769. error_detail *string
  7770. send_time *time.Time
  7771. source_type *int
  7772. addsource_type *int
  7773. organization_id *uint64
  7774. addorganization_id *int64
  7775. clearedFields map[string]struct{}
  7776. sop_stage *uint64
  7777. clearedsop_stage bool
  7778. sop_node *uint64
  7779. clearedsop_node bool
  7780. message_contact *uint64
  7781. clearedmessage_contact bool
  7782. done bool
  7783. oldValue func(context.Context) (*MessageRecords, error)
  7784. predicates []predicate.MessageRecords
  7785. }
  7786. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  7787. // messagerecordsOption allows management of the mutation configuration using functional options.
  7788. type messagerecordsOption func(*MessageRecordsMutation)
  7789. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  7790. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  7791. m := &MessageRecordsMutation{
  7792. config: c,
  7793. op: op,
  7794. typ: TypeMessageRecords,
  7795. clearedFields: make(map[string]struct{}),
  7796. }
  7797. for _, opt := range opts {
  7798. opt(m)
  7799. }
  7800. return m
  7801. }
  7802. // withMessageRecordsID sets the ID field of the mutation.
  7803. func withMessageRecordsID(id uint64) messagerecordsOption {
  7804. return func(m *MessageRecordsMutation) {
  7805. var (
  7806. err error
  7807. once sync.Once
  7808. value *MessageRecords
  7809. )
  7810. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  7811. once.Do(func() {
  7812. if m.done {
  7813. err = errors.New("querying old values post mutation is not allowed")
  7814. } else {
  7815. value, err = m.Client().MessageRecords.Get(ctx, id)
  7816. }
  7817. })
  7818. return value, err
  7819. }
  7820. m.id = &id
  7821. }
  7822. }
  7823. // withMessageRecords sets the old MessageRecords of the mutation.
  7824. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  7825. return func(m *MessageRecordsMutation) {
  7826. m.oldValue = func(context.Context) (*MessageRecords, error) {
  7827. return node, nil
  7828. }
  7829. m.id = &node.ID
  7830. }
  7831. }
  7832. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7833. // executed in a transaction (ent.Tx), a transactional client is returned.
  7834. func (m MessageRecordsMutation) Client() *Client {
  7835. client := &Client{config: m.config}
  7836. client.init()
  7837. return client
  7838. }
  7839. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7840. // it returns an error otherwise.
  7841. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  7842. if _, ok := m.driver.(*txDriver); !ok {
  7843. return nil, errors.New("ent: mutation is not running in a transaction")
  7844. }
  7845. tx := &Tx{config: m.config}
  7846. tx.init()
  7847. return tx, nil
  7848. }
  7849. // SetID sets the value of the id field. Note that this
  7850. // operation is only accepted on creation of MessageRecords entities.
  7851. func (m *MessageRecordsMutation) SetID(id uint64) {
  7852. m.id = &id
  7853. }
  7854. // ID returns the ID value in the mutation. Note that the ID is only available
  7855. // if it was provided to the builder or after it was returned from the database.
  7856. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  7857. if m.id == nil {
  7858. return
  7859. }
  7860. return *m.id, true
  7861. }
  7862. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7863. // That means, if the mutation is applied within a transaction with an isolation level such
  7864. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7865. // or updated by the mutation.
  7866. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  7867. switch {
  7868. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7869. id, exists := m.ID()
  7870. if exists {
  7871. return []uint64{id}, nil
  7872. }
  7873. fallthrough
  7874. case m.op.Is(OpUpdate | OpDelete):
  7875. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  7876. default:
  7877. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7878. }
  7879. }
  7880. // SetCreatedAt sets the "created_at" field.
  7881. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  7882. m.created_at = &t
  7883. }
  7884. // CreatedAt returns the value of the "created_at" field in the mutation.
  7885. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  7886. v := m.created_at
  7887. if v == nil {
  7888. return
  7889. }
  7890. return *v, true
  7891. }
  7892. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  7893. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  7894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7895. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7896. if !m.op.Is(OpUpdateOne) {
  7897. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7898. }
  7899. if m.id == nil || m.oldValue == nil {
  7900. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7901. }
  7902. oldValue, err := m.oldValue(ctx)
  7903. if err != nil {
  7904. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7905. }
  7906. return oldValue.CreatedAt, nil
  7907. }
  7908. // ResetCreatedAt resets all changes to the "created_at" field.
  7909. func (m *MessageRecordsMutation) ResetCreatedAt() {
  7910. m.created_at = nil
  7911. }
  7912. // SetUpdatedAt sets the "updated_at" field.
  7913. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  7914. m.updated_at = &t
  7915. }
  7916. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7917. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  7918. v := m.updated_at
  7919. if v == nil {
  7920. return
  7921. }
  7922. return *v, true
  7923. }
  7924. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  7925. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  7926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7927. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7928. if !m.op.Is(OpUpdateOne) {
  7929. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7930. }
  7931. if m.id == nil || m.oldValue == nil {
  7932. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7933. }
  7934. oldValue, err := m.oldValue(ctx)
  7935. if err != nil {
  7936. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7937. }
  7938. return oldValue.UpdatedAt, nil
  7939. }
  7940. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7941. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  7942. m.updated_at = nil
  7943. }
  7944. // SetStatus sets the "status" field.
  7945. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  7946. m.status = &u
  7947. m.addstatus = nil
  7948. }
  7949. // Status returns the value of the "status" field in the mutation.
  7950. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  7951. v := m.status
  7952. if v == nil {
  7953. return
  7954. }
  7955. return *v, true
  7956. }
  7957. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  7958. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  7959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7960. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7961. if !m.op.Is(OpUpdateOne) {
  7962. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7963. }
  7964. if m.id == nil || m.oldValue == nil {
  7965. return v, errors.New("OldStatus requires an ID field in the mutation")
  7966. }
  7967. oldValue, err := m.oldValue(ctx)
  7968. if err != nil {
  7969. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7970. }
  7971. return oldValue.Status, nil
  7972. }
  7973. // AddStatus adds u to the "status" field.
  7974. func (m *MessageRecordsMutation) AddStatus(u int8) {
  7975. if m.addstatus != nil {
  7976. *m.addstatus += u
  7977. } else {
  7978. m.addstatus = &u
  7979. }
  7980. }
  7981. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7982. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  7983. v := m.addstatus
  7984. if v == nil {
  7985. return
  7986. }
  7987. return *v, true
  7988. }
  7989. // ClearStatus clears the value of the "status" field.
  7990. func (m *MessageRecordsMutation) ClearStatus() {
  7991. m.status = nil
  7992. m.addstatus = nil
  7993. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  7994. }
  7995. // StatusCleared returns if the "status" field was cleared in this mutation.
  7996. func (m *MessageRecordsMutation) StatusCleared() bool {
  7997. _, ok := m.clearedFields[messagerecords.FieldStatus]
  7998. return ok
  7999. }
  8000. // ResetStatus resets all changes to the "status" field.
  8001. func (m *MessageRecordsMutation) ResetStatus() {
  8002. m.status = nil
  8003. m.addstatus = nil
  8004. delete(m.clearedFields, messagerecords.FieldStatus)
  8005. }
  8006. // SetDeletedAt sets the "deleted_at" field.
  8007. func (m *MessageRecordsMutation) SetDeletedAt(t time.Time) {
  8008. m.deleted_at = &t
  8009. }
  8010. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8011. func (m *MessageRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  8012. v := m.deleted_at
  8013. if v == nil {
  8014. return
  8015. }
  8016. return *v, true
  8017. }
  8018. // OldDeletedAt returns the old "deleted_at" field's value of the MessageRecords entity.
  8019. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8021. func (m *MessageRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8022. if !m.op.Is(OpUpdateOne) {
  8023. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8024. }
  8025. if m.id == nil || m.oldValue == nil {
  8026. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8027. }
  8028. oldValue, err := m.oldValue(ctx)
  8029. if err != nil {
  8030. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8031. }
  8032. return oldValue.DeletedAt, nil
  8033. }
  8034. // ClearDeletedAt clears the value of the "deleted_at" field.
  8035. func (m *MessageRecordsMutation) ClearDeletedAt() {
  8036. m.deleted_at = nil
  8037. m.clearedFields[messagerecords.FieldDeletedAt] = struct{}{}
  8038. }
  8039. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8040. func (m *MessageRecordsMutation) DeletedAtCleared() bool {
  8041. _, ok := m.clearedFields[messagerecords.FieldDeletedAt]
  8042. return ok
  8043. }
  8044. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8045. func (m *MessageRecordsMutation) ResetDeletedAt() {
  8046. m.deleted_at = nil
  8047. delete(m.clearedFields, messagerecords.FieldDeletedAt)
  8048. }
  8049. // SetBotWxid sets the "bot_wxid" field.
  8050. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  8051. m.bot_wxid = &s
  8052. }
  8053. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  8054. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  8055. v := m.bot_wxid
  8056. if v == nil {
  8057. return
  8058. }
  8059. return *v, true
  8060. }
  8061. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  8062. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8064. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  8065. if !m.op.Is(OpUpdateOne) {
  8066. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  8067. }
  8068. if m.id == nil || m.oldValue == nil {
  8069. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  8070. }
  8071. oldValue, err := m.oldValue(ctx)
  8072. if err != nil {
  8073. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  8074. }
  8075. return oldValue.BotWxid, nil
  8076. }
  8077. // ResetBotWxid resets all changes to the "bot_wxid" field.
  8078. func (m *MessageRecordsMutation) ResetBotWxid() {
  8079. m.bot_wxid = nil
  8080. }
  8081. // SetContactID sets the "contact_id" field.
  8082. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  8083. m.message_contact = &u
  8084. }
  8085. // ContactID returns the value of the "contact_id" field in the mutation.
  8086. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  8087. v := m.message_contact
  8088. if v == nil {
  8089. return
  8090. }
  8091. return *v, true
  8092. }
  8093. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  8094. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8095. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8096. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  8097. if !m.op.Is(OpUpdateOne) {
  8098. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  8099. }
  8100. if m.id == nil || m.oldValue == nil {
  8101. return v, errors.New("OldContactID requires an ID field in the mutation")
  8102. }
  8103. oldValue, err := m.oldValue(ctx)
  8104. if err != nil {
  8105. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  8106. }
  8107. return oldValue.ContactID, nil
  8108. }
  8109. // ClearContactID clears the value of the "contact_id" field.
  8110. func (m *MessageRecordsMutation) ClearContactID() {
  8111. m.message_contact = nil
  8112. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  8113. }
  8114. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  8115. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  8116. _, ok := m.clearedFields[messagerecords.FieldContactID]
  8117. return ok
  8118. }
  8119. // ResetContactID resets all changes to the "contact_id" field.
  8120. func (m *MessageRecordsMutation) ResetContactID() {
  8121. m.message_contact = nil
  8122. delete(m.clearedFields, messagerecords.FieldContactID)
  8123. }
  8124. // SetContactType sets the "contact_type" field.
  8125. func (m *MessageRecordsMutation) SetContactType(i int) {
  8126. m.contact_type = &i
  8127. m.addcontact_type = nil
  8128. }
  8129. // ContactType returns the value of the "contact_type" field in the mutation.
  8130. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  8131. v := m.contact_type
  8132. if v == nil {
  8133. return
  8134. }
  8135. return *v, true
  8136. }
  8137. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  8138. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8140. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  8141. if !m.op.Is(OpUpdateOne) {
  8142. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  8143. }
  8144. if m.id == nil || m.oldValue == nil {
  8145. return v, errors.New("OldContactType requires an ID field in the mutation")
  8146. }
  8147. oldValue, err := m.oldValue(ctx)
  8148. if err != nil {
  8149. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  8150. }
  8151. return oldValue.ContactType, nil
  8152. }
  8153. // AddContactType adds i to the "contact_type" field.
  8154. func (m *MessageRecordsMutation) AddContactType(i int) {
  8155. if m.addcontact_type != nil {
  8156. *m.addcontact_type += i
  8157. } else {
  8158. m.addcontact_type = &i
  8159. }
  8160. }
  8161. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  8162. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  8163. v := m.addcontact_type
  8164. if v == nil {
  8165. return
  8166. }
  8167. return *v, true
  8168. }
  8169. // ResetContactType resets all changes to the "contact_type" field.
  8170. func (m *MessageRecordsMutation) ResetContactType() {
  8171. m.contact_type = nil
  8172. m.addcontact_type = nil
  8173. }
  8174. // SetContactWxid sets the "contact_wxid" field.
  8175. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  8176. m.contact_wxid = &s
  8177. }
  8178. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  8179. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  8180. v := m.contact_wxid
  8181. if v == nil {
  8182. return
  8183. }
  8184. return *v, true
  8185. }
  8186. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  8187. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8189. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  8190. if !m.op.Is(OpUpdateOne) {
  8191. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  8192. }
  8193. if m.id == nil || m.oldValue == nil {
  8194. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  8195. }
  8196. oldValue, err := m.oldValue(ctx)
  8197. if err != nil {
  8198. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  8199. }
  8200. return oldValue.ContactWxid, nil
  8201. }
  8202. // ResetContactWxid resets all changes to the "contact_wxid" field.
  8203. func (m *MessageRecordsMutation) ResetContactWxid() {
  8204. m.contact_wxid = nil
  8205. }
  8206. // SetContentType sets the "content_type" field.
  8207. func (m *MessageRecordsMutation) SetContentType(i int) {
  8208. m.content_type = &i
  8209. m.addcontent_type = nil
  8210. }
  8211. // ContentType returns the value of the "content_type" field in the mutation.
  8212. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  8213. v := m.content_type
  8214. if v == nil {
  8215. return
  8216. }
  8217. return *v, true
  8218. }
  8219. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  8220. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8222. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  8223. if !m.op.Is(OpUpdateOne) {
  8224. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  8225. }
  8226. if m.id == nil || m.oldValue == nil {
  8227. return v, errors.New("OldContentType requires an ID field in the mutation")
  8228. }
  8229. oldValue, err := m.oldValue(ctx)
  8230. if err != nil {
  8231. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  8232. }
  8233. return oldValue.ContentType, nil
  8234. }
  8235. // AddContentType adds i to the "content_type" field.
  8236. func (m *MessageRecordsMutation) AddContentType(i int) {
  8237. if m.addcontent_type != nil {
  8238. *m.addcontent_type += i
  8239. } else {
  8240. m.addcontent_type = &i
  8241. }
  8242. }
  8243. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  8244. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  8245. v := m.addcontent_type
  8246. if v == nil {
  8247. return
  8248. }
  8249. return *v, true
  8250. }
  8251. // ResetContentType resets all changes to the "content_type" field.
  8252. func (m *MessageRecordsMutation) ResetContentType() {
  8253. m.content_type = nil
  8254. m.addcontent_type = nil
  8255. }
  8256. // SetContent sets the "content" field.
  8257. func (m *MessageRecordsMutation) SetContent(s string) {
  8258. m.content = &s
  8259. }
  8260. // Content returns the value of the "content" field in the mutation.
  8261. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  8262. v := m.content
  8263. if v == nil {
  8264. return
  8265. }
  8266. return *v, true
  8267. }
  8268. // OldContent returns the old "content" field's value of the MessageRecords entity.
  8269. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8271. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  8272. if !m.op.Is(OpUpdateOne) {
  8273. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  8274. }
  8275. if m.id == nil || m.oldValue == nil {
  8276. return v, errors.New("OldContent requires an ID field in the mutation")
  8277. }
  8278. oldValue, err := m.oldValue(ctx)
  8279. if err != nil {
  8280. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  8281. }
  8282. return oldValue.Content, nil
  8283. }
  8284. // ResetContent resets all changes to the "content" field.
  8285. func (m *MessageRecordsMutation) ResetContent() {
  8286. m.content = nil
  8287. }
  8288. // SetMeta sets the "meta" field.
  8289. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  8290. m.meta = &ct
  8291. }
  8292. // Meta returns the value of the "meta" field in the mutation.
  8293. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  8294. v := m.meta
  8295. if v == nil {
  8296. return
  8297. }
  8298. return *v, true
  8299. }
  8300. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  8301. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8303. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  8304. if !m.op.Is(OpUpdateOne) {
  8305. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  8306. }
  8307. if m.id == nil || m.oldValue == nil {
  8308. return v, errors.New("OldMeta requires an ID field in the mutation")
  8309. }
  8310. oldValue, err := m.oldValue(ctx)
  8311. if err != nil {
  8312. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  8313. }
  8314. return oldValue.Meta, nil
  8315. }
  8316. // ClearMeta clears the value of the "meta" field.
  8317. func (m *MessageRecordsMutation) ClearMeta() {
  8318. m.meta = nil
  8319. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  8320. }
  8321. // MetaCleared returns if the "meta" field was cleared in this mutation.
  8322. func (m *MessageRecordsMutation) MetaCleared() bool {
  8323. _, ok := m.clearedFields[messagerecords.FieldMeta]
  8324. return ok
  8325. }
  8326. // ResetMeta resets all changes to the "meta" field.
  8327. func (m *MessageRecordsMutation) ResetMeta() {
  8328. m.meta = nil
  8329. delete(m.clearedFields, messagerecords.FieldMeta)
  8330. }
  8331. // SetErrorDetail sets the "error_detail" field.
  8332. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  8333. m.error_detail = &s
  8334. }
  8335. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  8336. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  8337. v := m.error_detail
  8338. if v == nil {
  8339. return
  8340. }
  8341. return *v, true
  8342. }
  8343. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  8344. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8346. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  8347. if !m.op.Is(OpUpdateOne) {
  8348. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  8349. }
  8350. if m.id == nil || m.oldValue == nil {
  8351. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  8352. }
  8353. oldValue, err := m.oldValue(ctx)
  8354. if err != nil {
  8355. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  8356. }
  8357. return oldValue.ErrorDetail, nil
  8358. }
  8359. // ResetErrorDetail resets all changes to the "error_detail" field.
  8360. func (m *MessageRecordsMutation) ResetErrorDetail() {
  8361. m.error_detail = nil
  8362. }
  8363. // SetSendTime sets the "send_time" field.
  8364. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  8365. m.send_time = &t
  8366. }
  8367. // SendTime returns the value of the "send_time" field in the mutation.
  8368. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  8369. v := m.send_time
  8370. if v == nil {
  8371. return
  8372. }
  8373. return *v, true
  8374. }
  8375. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  8376. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8378. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  8379. if !m.op.Is(OpUpdateOne) {
  8380. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  8381. }
  8382. if m.id == nil || m.oldValue == nil {
  8383. return v, errors.New("OldSendTime requires an ID field in the mutation")
  8384. }
  8385. oldValue, err := m.oldValue(ctx)
  8386. if err != nil {
  8387. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  8388. }
  8389. return oldValue.SendTime, nil
  8390. }
  8391. // ClearSendTime clears the value of the "send_time" field.
  8392. func (m *MessageRecordsMutation) ClearSendTime() {
  8393. m.send_time = nil
  8394. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  8395. }
  8396. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  8397. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  8398. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  8399. return ok
  8400. }
  8401. // ResetSendTime resets all changes to the "send_time" field.
  8402. func (m *MessageRecordsMutation) ResetSendTime() {
  8403. m.send_time = nil
  8404. delete(m.clearedFields, messagerecords.FieldSendTime)
  8405. }
  8406. // SetSourceType sets the "source_type" field.
  8407. func (m *MessageRecordsMutation) SetSourceType(i int) {
  8408. m.source_type = &i
  8409. m.addsource_type = nil
  8410. }
  8411. // SourceType returns the value of the "source_type" field in the mutation.
  8412. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  8413. v := m.source_type
  8414. if v == nil {
  8415. return
  8416. }
  8417. return *v, true
  8418. }
  8419. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  8420. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8422. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  8423. if !m.op.Is(OpUpdateOne) {
  8424. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  8425. }
  8426. if m.id == nil || m.oldValue == nil {
  8427. return v, errors.New("OldSourceType requires an ID field in the mutation")
  8428. }
  8429. oldValue, err := m.oldValue(ctx)
  8430. if err != nil {
  8431. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  8432. }
  8433. return oldValue.SourceType, nil
  8434. }
  8435. // AddSourceType adds i to the "source_type" field.
  8436. func (m *MessageRecordsMutation) AddSourceType(i int) {
  8437. if m.addsource_type != nil {
  8438. *m.addsource_type += i
  8439. } else {
  8440. m.addsource_type = &i
  8441. }
  8442. }
  8443. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  8444. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  8445. v := m.addsource_type
  8446. if v == nil {
  8447. return
  8448. }
  8449. return *v, true
  8450. }
  8451. // ResetSourceType resets all changes to the "source_type" field.
  8452. func (m *MessageRecordsMutation) ResetSourceType() {
  8453. m.source_type = nil
  8454. m.addsource_type = nil
  8455. }
  8456. // SetSourceID sets the "source_id" field.
  8457. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  8458. m.sop_stage = &u
  8459. }
  8460. // SourceID returns the value of the "source_id" field in the mutation.
  8461. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  8462. v := m.sop_stage
  8463. if v == nil {
  8464. return
  8465. }
  8466. return *v, true
  8467. }
  8468. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  8469. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8470. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8471. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  8472. if !m.op.Is(OpUpdateOne) {
  8473. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  8474. }
  8475. if m.id == nil || m.oldValue == nil {
  8476. return v, errors.New("OldSourceID requires an ID field in the mutation")
  8477. }
  8478. oldValue, err := m.oldValue(ctx)
  8479. if err != nil {
  8480. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  8481. }
  8482. return oldValue.SourceID, nil
  8483. }
  8484. // ClearSourceID clears the value of the "source_id" field.
  8485. func (m *MessageRecordsMutation) ClearSourceID() {
  8486. m.sop_stage = nil
  8487. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  8488. }
  8489. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  8490. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  8491. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  8492. return ok
  8493. }
  8494. // ResetSourceID resets all changes to the "source_id" field.
  8495. func (m *MessageRecordsMutation) ResetSourceID() {
  8496. m.sop_stage = nil
  8497. delete(m.clearedFields, messagerecords.FieldSourceID)
  8498. }
  8499. // SetSubSourceID sets the "sub_source_id" field.
  8500. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  8501. m.sop_node = &u
  8502. }
  8503. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  8504. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  8505. v := m.sop_node
  8506. if v == nil {
  8507. return
  8508. }
  8509. return *v, true
  8510. }
  8511. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  8512. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8514. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  8515. if !m.op.Is(OpUpdateOne) {
  8516. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  8517. }
  8518. if m.id == nil || m.oldValue == nil {
  8519. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  8520. }
  8521. oldValue, err := m.oldValue(ctx)
  8522. if err != nil {
  8523. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  8524. }
  8525. return oldValue.SubSourceID, nil
  8526. }
  8527. // ClearSubSourceID clears the value of the "sub_source_id" field.
  8528. func (m *MessageRecordsMutation) ClearSubSourceID() {
  8529. m.sop_node = nil
  8530. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  8531. }
  8532. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  8533. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  8534. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  8535. return ok
  8536. }
  8537. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  8538. func (m *MessageRecordsMutation) ResetSubSourceID() {
  8539. m.sop_node = nil
  8540. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  8541. }
  8542. // SetOrganizationID sets the "organization_id" field.
  8543. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  8544. m.organization_id = &u
  8545. m.addorganization_id = nil
  8546. }
  8547. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8548. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  8549. v := m.organization_id
  8550. if v == nil {
  8551. return
  8552. }
  8553. return *v, true
  8554. }
  8555. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  8556. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8558. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8559. if !m.op.Is(OpUpdateOne) {
  8560. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8561. }
  8562. if m.id == nil || m.oldValue == nil {
  8563. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8564. }
  8565. oldValue, err := m.oldValue(ctx)
  8566. if err != nil {
  8567. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8568. }
  8569. return oldValue.OrganizationID, nil
  8570. }
  8571. // AddOrganizationID adds u to the "organization_id" field.
  8572. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  8573. if m.addorganization_id != nil {
  8574. *m.addorganization_id += u
  8575. } else {
  8576. m.addorganization_id = &u
  8577. }
  8578. }
  8579. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8580. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  8581. v := m.addorganization_id
  8582. if v == nil {
  8583. return
  8584. }
  8585. return *v, true
  8586. }
  8587. // ClearOrganizationID clears the value of the "organization_id" field.
  8588. func (m *MessageRecordsMutation) ClearOrganizationID() {
  8589. m.organization_id = nil
  8590. m.addorganization_id = nil
  8591. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  8592. }
  8593. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  8594. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  8595. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  8596. return ok
  8597. }
  8598. // ResetOrganizationID resets all changes to the "organization_id" field.
  8599. func (m *MessageRecordsMutation) ResetOrganizationID() {
  8600. m.organization_id = nil
  8601. m.addorganization_id = nil
  8602. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  8603. }
  8604. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  8605. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  8606. m.sop_stage = &id
  8607. }
  8608. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  8609. func (m *MessageRecordsMutation) ClearSopStage() {
  8610. m.clearedsop_stage = true
  8611. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  8612. }
  8613. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  8614. func (m *MessageRecordsMutation) SopStageCleared() bool {
  8615. return m.SourceIDCleared() || m.clearedsop_stage
  8616. }
  8617. // SopStageID returns the "sop_stage" edge ID in the mutation.
  8618. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  8619. if m.sop_stage != nil {
  8620. return *m.sop_stage, true
  8621. }
  8622. return
  8623. }
  8624. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  8625. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  8626. // SopStageID instead. It exists only for internal usage by the builders.
  8627. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  8628. if id := m.sop_stage; id != nil {
  8629. ids = append(ids, *id)
  8630. }
  8631. return
  8632. }
  8633. // ResetSopStage resets all changes to the "sop_stage" edge.
  8634. func (m *MessageRecordsMutation) ResetSopStage() {
  8635. m.sop_stage = nil
  8636. m.clearedsop_stage = false
  8637. }
  8638. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  8639. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  8640. m.sop_node = &id
  8641. }
  8642. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  8643. func (m *MessageRecordsMutation) ClearSopNode() {
  8644. m.clearedsop_node = true
  8645. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  8646. }
  8647. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  8648. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  8649. return m.SubSourceIDCleared() || m.clearedsop_node
  8650. }
  8651. // SopNodeID returns the "sop_node" edge ID in the mutation.
  8652. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  8653. if m.sop_node != nil {
  8654. return *m.sop_node, true
  8655. }
  8656. return
  8657. }
  8658. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  8659. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  8660. // SopNodeID instead. It exists only for internal usage by the builders.
  8661. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  8662. if id := m.sop_node; id != nil {
  8663. ids = append(ids, *id)
  8664. }
  8665. return
  8666. }
  8667. // ResetSopNode resets all changes to the "sop_node" edge.
  8668. func (m *MessageRecordsMutation) ResetSopNode() {
  8669. m.sop_node = nil
  8670. m.clearedsop_node = false
  8671. }
  8672. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  8673. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  8674. m.message_contact = &id
  8675. }
  8676. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  8677. func (m *MessageRecordsMutation) ClearMessageContact() {
  8678. m.clearedmessage_contact = true
  8679. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  8680. }
  8681. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  8682. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  8683. return m.ContactIDCleared() || m.clearedmessage_contact
  8684. }
  8685. // MessageContactID returns the "message_contact" edge ID in the mutation.
  8686. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  8687. if m.message_contact != nil {
  8688. return *m.message_contact, true
  8689. }
  8690. return
  8691. }
  8692. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  8693. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  8694. // MessageContactID instead. It exists only for internal usage by the builders.
  8695. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  8696. if id := m.message_contact; id != nil {
  8697. ids = append(ids, *id)
  8698. }
  8699. return
  8700. }
  8701. // ResetMessageContact resets all changes to the "message_contact" edge.
  8702. func (m *MessageRecordsMutation) ResetMessageContact() {
  8703. m.message_contact = nil
  8704. m.clearedmessage_contact = false
  8705. }
  8706. // Where appends a list predicates to the MessageRecordsMutation builder.
  8707. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  8708. m.predicates = append(m.predicates, ps...)
  8709. }
  8710. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  8711. // users can use type-assertion to append predicates that do not depend on any generated package.
  8712. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  8713. p := make([]predicate.MessageRecords, len(ps))
  8714. for i := range ps {
  8715. p[i] = ps[i]
  8716. }
  8717. m.Where(p...)
  8718. }
  8719. // Op returns the operation name.
  8720. func (m *MessageRecordsMutation) Op() Op {
  8721. return m.op
  8722. }
  8723. // SetOp allows setting the mutation operation.
  8724. func (m *MessageRecordsMutation) SetOp(op Op) {
  8725. m.op = op
  8726. }
  8727. // Type returns the node type of this mutation (MessageRecords).
  8728. func (m *MessageRecordsMutation) Type() string {
  8729. return m.typ
  8730. }
  8731. // Fields returns all fields that were changed during this mutation. Note that in
  8732. // order to get all numeric fields that were incremented/decremented, call
  8733. // AddedFields().
  8734. func (m *MessageRecordsMutation) Fields() []string {
  8735. fields := make([]string, 0, 17)
  8736. if m.created_at != nil {
  8737. fields = append(fields, messagerecords.FieldCreatedAt)
  8738. }
  8739. if m.updated_at != nil {
  8740. fields = append(fields, messagerecords.FieldUpdatedAt)
  8741. }
  8742. if m.status != nil {
  8743. fields = append(fields, messagerecords.FieldStatus)
  8744. }
  8745. if m.deleted_at != nil {
  8746. fields = append(fields, messagerecords.FieldDeletedAt)
  8747. }
  8748. if m.bot_wxid != nil {
  8749. fields = append(fields, messagerecords.FieldBotWxid)
  8750. }
  8751. if m.message_contact != nil {
  8752. fields = append(fields, messagerecords.FieldContactID)
  8753. }
  8754. if m.contact_type != nil {
  8755. fields = append(fields, messagerecords.FieldContactType)
  8756. }
  8757. if m.contact_wxid != nil {
  8758. fields = append(fields, messagerecords.FieldContactWxid)
  8759. }
  8760. if m.content_type != nil {
  8761. fields = append(fields, messagerecords.FieldContentType)
  8762. }
  8763. if m.content != nil {
  8764. fields = append(fields, messagerecords.FieldContent)
  8765. }
  8766. if m.meta != nil {
  8767. fields = append(fields, messagerecords.FieldMeta)
  8768. }
  8769. if m.error_detail != nil {
  8770. fields = append(fields, messagerecords.FieldErrorDetail)
  8771. }
  8772. if m.send_time != nil {
  8773. fields = append(fields, messagerecords.FieldSendTime)
  8774. }
  8775. if m.source_type != nil {
  8776. fields = append(fields, messagerecords.FieldSourceType)
  8777. }
  8778. if m.sop_stage != nil {
  8779. fields = append(fields, messagerecords.FieldSourceID)
  8780. }
  8781. if m.sop_node != nil {
  8782. fields = append(fields, messagerecords.FieldSubSourceID)
  8783. }
  8784. if m.organization_id != nil {
  8785. fields = append(fields, messagerecords.FieldOrganizationID)
  8786. }
  8787. return fields
  8788. }
  8789. // Field returns the value of a field with the given name. The second boolean
  8790. // return value indicates that this field was not set, or was not defined in the
  8791. // schema.
  8792. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  8793. switch name {
  8794. case messagerecords.FieldCreatedAt:
  8795. return m.CreatedAt()
  8796. case messagerecords.FieldUpdatedAt:
  8797. return m.UpdatedAt()
  8798. case messagerecords.FieldStatus:
  8799. return m.Status()
  8800. case messagerecords.FieldDeletedAt:
  8801. return m.DeletedAt()
  8802. case messagerecords.FieldBotWxid:
  8803. return m.BotWxid()
  8804. case messagerecords.FieldContactID:
  8805. return m.ContactID()
  8806. case messagerecords.FieldContactType:
  8807. return m.ContactType()
  8808. case messagerecords.FieldContactWxid:
  8809. return m.ContactWxid()
  8810. case messagerecords.FieldContentType:
  8811. return m.ContentType()
  8812. case messagerecords.FieldContent:
  8813. return m.Content()
  8814. case messagerecords.FieldMeta:
  8815. return m.Meta()
  8816. case messagerecords.FieldErrorDetail:
  8817. return m.ErrorDetail()
  8818. case messagerecords.FieldSendTime:
  8819. return m.SendTime()
  8820. case messagerecords.FieldSourceType:
  8821. return m.SourceType()
  8822. case messagerecords.FieldSourceID:
  8823. return m.SourceID()
  8824. case messagerecords.FieldSubSourceID:
  8825. return m.SubSourceID()
  8826. case messagerecords.FieldOrganizationID:
  8827. return m.OrganizationID()
  8828. }
  8829. return nil, false
  8830. }
  8831. // OldField returns the old value of the field from the database. An error is
  8832. // returned if the mutation operation is not UpdateOne, or the query to the
  8833. // database failed.
  8834. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8835. switch name {
  8836. case messagerecords.FieldCreatedAt:
  8837. return m.OldCreatedAt(ctx)
  8838. case messagerecords.FieldUpdatedAt:
  8839. return m.OldUpdatedAt(ctx)
  8840. case messagerecords.FieldStatus:
  8841. return m.OldStatus(ctx)
  8842. case messagerecords.FieldDeletedAt:
  8843. return m.OldDeletedAt(ctx)
  8844. case messagerecords.FieldBotWxid:
  8845. return m.OldBotWxid(ctx)
  8846. case messagerecords.FieldContactID:
  8847. return m.OldContactID(ctx)
  8848. case messagerecords.FieldContactType:
  8849. return m.OldContactType(ctx)
  8850. case messagerecords.FieldContactWxid:
  8851. return m.OldContactWxid(ctx)
  8852. case messagerecords.FieldContentType:
  8853. return m.OldContentType(ctx)
  8854. case messagerecords.FieldContent:
  8855. return m.OldContent(ctx)
  8856. case messagerecords.FieldMeta:
  8857. return m.OldMeta(ctx)
  8858. case messagerecords.FieldErrorDetail:
  8859. return m.OldErrorDetail(ctx)
  8860. case messagerecords.FieldSendTime:
  8861. return m.OldSendTime(ctx)
  8862. case messagerecords.FieldSourceType:
  8863. return m.OldSourceType(ctx)
  8864. case messagerecords.FieldSourceID:
  8865. return m.OldSourceID(ctx)
  8866. case messagerecords.FieldSubSourceID:
  8867. return m.OldSubSourceID(ctx)
  8868. case messagerecords.FieldOrganizationID:
  8869. return m.OldOrganizationID(ctx)
  8870. }
  8871. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  8872. }
  8873. // SetField sets the value of a field with the given name. It returns an error if
  8874. // the field is not defined in the schema, or if the type mismatched the field
  8875. // type.
  8876. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  8877. switch name {
  8878. case messagerecords.FieldCreatedAt:
  8879. v, ok := value.(time.Time)
  8880. if !ok {
  8881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8882. }
  8883. m.SetCreatedAt(v)
  8884. return nil
  8885. case messagerecords.FieldUpdatedAt:
  8886. v, ok := value.(time.Time)
  8887. if !ok {
  8888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8889. }
  8890. m.SetUpdatedAt(v)
  8891. return nil
  8892. case messagerecords.FieldStatus:
  8893. v, ok := value.(uint8)
  8894. if !ok {
  8895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8896. }
  8897. m.SetStatus(v)
  8898. return nil
  8899. case messagerecords.FieldDeletedAt:
  8900. v, ok := value.(time.Time)
  8901. if !ok {
  8902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8903. }
  8904. m.SetDeletedAt(v)
  8905. return nil
  8906. case messagerecords.FieldBotWxid:
  8907. v, ok := value.(string)
  8908. if !ok {
  8909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8910. }
  8911. m.SetBotWxid(v)
  8912. return nil
  8913. case messagerecords.FieldContactID:
  8914. v, ok := value.(uint64)
  8915. if !ok {
  8916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8917. }
  8918. m.SetContactID(v)
  8919. return nil
  8920. case messagerecords.FieldContactType:
  8921. v, ok := value.(int)
  8922. if !ok {
  8923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8924. }
  8925. m.SetContactType(v)
  8926. return nil
  8927. case messagerecords.FieldContactWxid:
  8928. v, ok := value.(string)
  8929. if !ok {
  8930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8931. }
  8932. m.SetContactWxid(v)
  8933. return nil
  8934. case messagerecords.FieldContentType:
  8935. v, ok := value.(int)
  8936. if !ok {
  8937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8938. }
  8939. m.SetContentType(v)
  8940. return nil
  8941. case messagerecords.FieldContent:
  8942. v, ok := value.(string)
  8943. if !ok {
  8944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8945. }
  8946. m.SetContent(v)
  8947. return nil
  8948. case messagerecords.FieldMeta:
  8949. v, ok := value.(custom_types.Meta)
  8950. if !ok {
  8951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8952. }
  8953. m.SetMeta(v)
  8954. return nil
  8955. case messagerecords.FieldErrorDetail:
  8956. v, ok := value.(string)
  8957. if !ok {
  8958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8959. }
  8960. m.SetErrorDetail(v)
  8961. return nil
  8962. case messagerecords.FieldSendTime:
  8963. v, ok := value.(time.Time)
  8964. if !ok {
  8965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8966. }
  8967. m.SetSendTime(v)
  8968. return nil
  8969. case messagerecords.FieldSourceType:
  8970. v, ok := value.(int)
  8971. if !ok {
  8972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8973. }
  8974. m.SetSourceType(v)
  8975. return nil
  8976. case messagerecords.FieldSourceID:
  8977. v, ok := value.(uint64)
  8978. if !ok {
  8979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8980. }
  8981. m.SetSourceID(v)
  8982. return nil
  8983. case messagerecords.FieldSubSourceID:
  8984. v, ok := value.(uint64)
  8985. if !ok {
  8986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8987. }
  8988. m.SetSubSourceID(v)
  8989. return nil
  8990. case messagerecords.FieldOrganizationID:
  8991. v, ok := value.(uint64)
  8992. if !ok {
  8993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8994. }
  8995. m.SetOrganizationID(v)
  8996. return nil
  8997. }
  8998. return fmt.Errorf("unknown MessageRecords field %s", name)
  8999. }
  9000. // AddedFields returns all numeric fields that were incremented/decremented during
  9001. // this mutation.
  9002. func (m *MessageRecordsMutation) AddedFields() []string {
  9003. var fields []string
  9004. if m.addstatus != nil {
  9005. fields = append(fields, messagerecords.FieldStatus)
  9006. }
  9007. if m.addcontact_type != nil {
  9008. fields = append(fields, messagerecords.FieldContactType)
  9009. }
  9010. if m.addcontent_type != nil {
  9011. fields = append(fields, messagerecords.FieldContentType)
  9012. }
  9013. if m.addsource_type != nil {
  9014. fields = append(fields, messagerecords.FieldSourceType)
  9015. }
  9016. if m.addorganization_id != nil {
  9017. fields = append(fields, messagerecords.FieldOrganizationID)
  9018. }
  9019. return fields
  9020. }
  9021. // AddedField returns the numeric value that was incremented/decremented on a field
  9022. // with the given name. The second boolean return value indicates that this field
  9023. // was not set, or was not defined in the schema.
  9024. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  9025. switch name {
  9026. case messagerecords.FieldStatus:
  9027. return m.AddedStatus()
  9028. case messagerecords.FieldContactType:
  9029. return m.AddedContactType()
  9030. case messagerecords.FieldContentType:
  9031. return m.AddedContentType()
  9032. case messagerecords.FieldSourceType:
  9033. return m.AddedSourceType()
  9034. case messagerecords.FieldOrganizationID:
  9035. return m.AddedOrganizationID()
  9036. }
  9037. return nil, false
  9038. }
  9039. // AddField adds the value to the field with the given name. It returns an error if
  9040. // the field is not defined in the schema, or if the type mismatched the field
  9041. // type.
  9042. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  9043. switch name {
  9044. case messagerecords.FieldStatus:
  9045. v, ok := value.(int8)
  9046. if !ok {
  9047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9048. }
  9049. m.AddStatus(v)
  9050. return nil
  9051. case messagerecords.FieldContactType:
  9052. v, ok := value.(int)
  9053. if !ok {
  9054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9055. }
  9056. m.AddContactType(v)
  9057. return nil
  9058. case messagerecords.FieldContentType:
  9059. v, ok := value.(int)
  9060. if !ok {
  9061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9062. }
  9063. m.AddContentType(v)
  9064. return nil
  9065. case messagerecords.FieldSourceType:
  9066. v, ok := value.(int)
  9067. if !ok {
  9068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9069. }
  9070. m.AddSourceType(v)
  9071. return nil
  9072. case messagerecords.FieldOrganizationID:
  9073. v, ok := value.(int64)
  9074. if !ok {
  9075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9076. }
  9077. m.AddOrganizationID(v)
  9078. return nil
  9079. }
  9080. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  9081. }
  9082. // ClearedFields returns all nullable fields that were cleared during this
  9083. // mutation.
  9084. func (m *MessageRecordsMutation) ClearedFields() []string {
  9085. var fields []string
  9086. if m.FieldCleared(messagerecords.FieldStatus) {
  9087. fields = append(fields, messagerecords.FieldStatus)
  9088. }
  9089. if m.FieldCleared(messagerecords.FieldDeletedAt) {
  9090. fields = append(fields, messagerecords.FieldDeletedAt)
  9091. }
  9092. if m.FieldCleared(messagerecords.FieldContactID) {
  9093. fields = append(fields, messagerecords.FieldContactID)
  9094. }
  9095. if m.FieldCleared(messagerecords.FieldMeta) {
  9096. fields = append(fields, messagerecords.FieldMeta)
  9097. }
  9098. if m.FieldCleared(messagerecords.FieldSendTime) {
  9099. fields = append(fields, messagerecords.FieldSendTime)
  9100. }
  9101. if m.FieldCleared(messagerecords.FieldSourceID) {
  9102. fields = append(fields, messagerecords.FieldSourceID)
  9103. }
  9104. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  9105. fields = append(fields, messagerecords.FieldSubSourceID)
  9106. }
  9107. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  9108. fields = append(fields, messagerecords.FieldOrganizationID)
  9109. }
  9110. return fields
  9111. }
  9112. // FieldCleared returns a boolean indicating if a field with the given name was
  9113. // cleared in this mutation.
  9114. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  9115. _, ok := m.clearedFields[name]
  9116. return ok
  9117. }
  9118. // ClearField clears the value of the field with the given name. It returns an
  9119. // error if the field is not defined in the schema.
  9120. func (m *MessageRecordsMutation) ClearField(name string) error {
  9121. switch name {
  9122. case messagerecords.FieldStatus:
  9123. m.ClearStatus()
  9124. return nil
  9125. case messagerecords.FieldDeletedAt:
  9126. m.ClearDeletedAt()
  9127. return nil
  9128. case messagerecords.FieldContactID:
  9129. m.ClearContactID()
  9130. return nil
  9131. case messagerecords.FieldMeta:
  9132. m.ClearMeta()
  9133. return nil
  9134. case messagerecords.FieldSendTime:
  9135. m.ClearSendTime()
  9136. return nil
  9137. case messagerecords.FieldSourceID:
  9138. m.ClearSourceID()
  9139. return nil
  9140. case messagerecords.FieldSubSourceID:
  9141. m.ClearSubSourceID()
  9142. return nil
  9143. case messagerecords.FieldOrganizationID:
  9144. m.ClearOrganizationID()
  9145. return nil
  9146. }
  9147. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  9148. }
  9149. // ResetField resets all changes in the mutation for the field with the given name.
  9150. // It returns an error if the field is not defined in the schema.
  9151. func (m *MessageRecordsMutation) ResetField(name string) error {
  9152. switch name {
  9153. case messagerecords.FieldCreatedAt:
  9154. m.ResetCreatedAt()
  9155. return nil
  9156. case messagerecords.FieldUpdatedAt:
  9157. m.ResetUpdatedAt()
  9158. return nil
  9159. case messagerecords.FieldStatus:
  9160. m.ResetStatus()
  9161. return nil
  9162. case messagerecords.FieldDeletedAt:
  9163. m.ResetDeletedAt()
  9164. return nil
  9165. case messagerecords.FieldBotWxid:
  9166. m.ResetBotWxid()
  9167. return nil
  9168. case messagerecords.FieldContactID:
  9169. m.ResetContactID()
  9170. return nil
  9171. case messagerecords.FieldContactType:
  9172. m.ResetContactType()
  9173. return nil
  9174. case messagerecords.FieldContactWxid:
  9175. m.ResetContactWxid()
  9176. return nil
  9177. case messagerecords.FieldContentType:
  9178. m.ResetContentType()
  9179. return nil
  9180. case messagerecords.FieldContent:
  9181. m.ResetContent()
  9182. return nil
  9183. case messagerecords.FieldMeta:
  9184. m.ResetMeta()
  9185. return nil
  9186. case messagerecords.FieldErrorDetail:
  9187. m.ResetErrorDetail()
  9188. return nil
  9189. case messagerecords.FieldSendTime:
  9190. m.ResetSendTime()
  9191. return nil
  9192. case messagerecords.FieldSourceType:
  9193. m.ResetSourceType()
  9194. return nil
  9195. case messagerecords.FieldSourceID:
  9196. m.ResetSourceID()
  9197. return nil
  9198. case messagerecords.FieldSubSourceID:
  9199. m.ResetSubSourceID()
  9200. return nil
  9201. case messagerecords.FieldOrganizationID:
  9202. m.ResetOrganizationID()
  9203. return nil
  9204. }
  9205. return fmt.Errorf("unknown MessageRecords field %s", name)
  9206. }
  9207. // AddedEdges returns all edge names that were set/added in this mutation.
  9208. func (m *MessageRecordsMutation) AddedEdges() []string {
  9209. edges := make([]string, 0, 3)
  9210. if m.sop_stage != nil {
  9211. edges = append(edges, messagerecords.EdgeSopStage)
  9212. }
  9213. if m.sop_node != nil {
  9214. edges = append(edges, messagerecords.EdgeSopNode)
  9215. }
  9216. if m.message_contact != nil {
  9217. edges = append(edges, messagerecords.EdgeMessageContact)
  9218. }
  9219. return edges
  9220. }
  9221. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9222. // name in this mutation.
  9223. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  9224. switch name {
  9225. case messagerecords.EdgeSopStage:
  9226. if id := m.sop_stage; id != nil {
  9227. return []ent.Value{*id}
  9228. }
  9229. case messagerecords.EdgeSopNode:
  9230. if id := m.sop_node; id != nil {
  9231. return []ent.Value{*id}
  9232. }
  9233. case messagerecords.EdgeMessageContact:
  9234. if id := m.message_contact; id != nil {
  9235. return []ent.Value{*id}
  9236. }
  9237. }
  9238. return nil
  9239. }
  9240. // RemovedEdges returns all edge names that were removed in this mutation.
  9241. func (m *MessageRecordsMutation) RemovedEdges() []string {
  9242. edges := make([]string, 0, 3)
  9243. return edges
  9244. }
  9245. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9246. // the given name in this mutation.
  9247. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  9248. return nil
  9249. }
  9250. // ClearedEdges returns all edge names that were cleared in this mutation.
  9251. func (m *MessageRecordsMutation) ClearedEdges() []string {
  9252. edges := make([]string, 0, 3)
  9253. if m.clearedsop_stage {
  9254. edges = append(edges, messagerecords.EdgeSopStage)
  9255. }
  9256. if m.clearedsop_node {
  9257. edges = append(edges, messagerecords.EdgeSopNode)
  9258. }
  9259. if m.clearedmessage_contact {
  9260. edges = append(edges, messagerecords.EdgeMessageContact)
  9261. }
  9262. return edges
  9263. }
  9264. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9265. // was cleared in this mutation.
  9266. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  9267. switch name {
  9268. case messagerecords.EdgeSopStage:
  9269. return m.clearedsop_stage
  9270. case messagerecords.EdgeSopNode:
  9271. return m.clearedsop_node
  9272. case messagerecords.EdgeMessageContact:
  9273. return m.clearedmessage_contact
  9274. }
  9275. return false
  9276. }
  9277. // ClearEdge clears the value of the edge with the given name. It returns an error
  9278. // if that edge is not defined in the schema.
  9279. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  9280. switch name {
  9281. case messagerecords.EdgeSopStage:
  9282. m.ClearSopStage()
  9283. return nil
  9284. case messagerecords.EdgeSopNode:
  9285. m.ClearSopNode()
  9286. return nil
  9287. case messagerecords.EdgeMessageContact:
  9288. m.ClearMessageContact()
  9289. return nil
  9290. }
  9291. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  9292. }
  9293. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9294. // It returns an error if the edge is not defined in the schema.
  9295. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  9296. switch name {
  9297. case messagerecords.EdgeSopStage:
  9298. m.ResetSopStage()
  9299. return nil
  9300. case messagerecords.EdgeSopNode:
  9301. m.ResetSopNode()
  9302. return nil
  9303. case messagerecords.EdgeMessageContact:
  9304. m.ResetMessageContact()
  9305. return nil
  9306. }
  9307. return fmt.Errorf("unknown MessageRecords edge %s", name)
  9308. }
  9309. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  9310. type MsgMutation struct {
  9311. config
  9312. op Op
  9313. typ string
  9314. id *uint64
  9315. created_at *time.Time
  9316. updated_at *time.Time
  9317. deleted_at *time.Time
  9318. status *uint8
  9319. addstatus *int8
  9320. fromwxid *string
  9321. toid *string
  9322. msgtype *int32
  9323. addmsgtype *int32
  9324. msg *string
  9325. batch_no *string
  9326. clearedFields map[string]struct{}
  9327. done bool
  9328. oldValue func(context.Context) (*Msg, error)
  9329. predicates []predicate.Msg
  9330. }
  9331. var _ ent.Mutation = (*MsgMutation)(nil)
  9332. // msgOption allows management of the mutation configuration using functional options.
  9333. type msgOption func(*MsgMutation)
  9334. // newMsgMutation creates new mutation for the Msg entity.
  9335. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  9336. m := &MsgMutation{
  9337. config: c,
  9338. op: op,
  9339. typ: TypeMsg,
  9340. clearedFields: make(map[string]struct{}),
  9341. }
  9342. for _, opt := range opts {
  9343. opt(m)
  9344. }
  9345. return m
  9346. }
  9347. // withMsgID sets the ID field of the mutation.
  9348. func withMsgID(id uint64) msgOption {
  9349. return func(m *MsgMutation) {
  9350. var (
  9351. err error
  9352. once sync.Once
  9353. value *Msg
  9354. )
  9355. m.oldValue = func(ctx context.Context) (*Msg, error) {
  9356. once.Do(func() {
  9357. if m.done {
  9358. err = errors.New("querying old values post mutation is not allowed")
  9359. } else {
  9360. value, err = m.Client().Msg.Get(ctx, id)
  9361. }
  9362. })
  9363. return value, err
  9364. }
  9365. m.id = &id
  9366. }
  9367. }
  9368. // withMsg sets the old Msg of the mutation.
  9369. func withMsg(node *Msg) msgOption {
  9370. return func(m *MsgMutation) {
  9371. m.oldValue = func(context.Context) (*Msg, error) {
  9372. return node, nil
  9373. }
  9374. m.id = &node.ID
  9375. }
  9376. }
  9377. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9378. // executed in a transaction (ent.Tx), a transactional client is returned.
  9379. func (m MsgMutation) Client() *Client {
  9380. client := &Client{config: m.config}
  9381. client.init()
  9382. return client
  9383. }
  9384. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9385. // it returns an error otherwise.
  9386. func (m MsgMutation) Tx() (*Tx, error) {
  9387. if _, ok := m.driver.(*txDriver); !ok {
  9388. return nil, errors.New("ent: mutation is not running in a transaction")
  9389. }
  9390. tx := &Tx{config: m.config}
  9391. tx.init()
  9392. return tx, nil
  9393. }
  9394. // SetID sets the value of the id field. Note that this
  9395. // operation is only accepted on creation of Msg entities.
  9396. func (m *MsgMutation) SetID(id uint64) {
  9397. m.id = &id
  9398. }
  9399. // ID returns the ID value in the mutation. Note that the ID is only available
  9400. // if it was provided to the builder or after it was returned from the database.
  9401. func (m *MsgMutation) ID() (id uint64, exists bool) {
  9402. if m.id == nil {
  9403. return
  9404. }
  9405. return *m.id, true
  9406. }
  9407. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9408. // That means, if the mutation is applied within a transaction with an isolation level such
  9409. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9410. // or updated by the mutation.
  9411. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  9412. switch {
  9413. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9414. id, exists := m.ID()
  9415. if exists {
  9416. return []uint64{id}, nil
  9417. }
  9418. fallthrough
  9419. case m.op.Is(OpUpdate | OpDelete):
  9420. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  9421. default:
  9422. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9423. }
  9424. }
  9425. // SetCreatedAt sets the "created_at" field.
  9426. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  9427. m.created_at = &t
  9428. }
  9429. // CreatedAt returns the value of the "created_at" field in the mutation.
  9430. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  9431. v := m.created_at
  9432. if v == nil {
  9433. return
  9434. }
  9435. return *v, true
  9436. }
  9437. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  9438. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  9439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9440. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9441. if !m.op.Is(OpUpdateOne) {
  9442. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9443. }
  9444. if m.id == nil || m.oldValue == nil {
  9445. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9446. }
  9447. oldValue, err := m.oldValue(ctx)
  9448. if err != nil {
  9449. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9450. }
  9451. return oldValue.CreatedAt, nil
  9452. }
  9453. // ResetCreatedAt resets all changes to the "created_at" field.
  9454. func (m *MsgMutation) ResetCreatedAt() {
  9455. m.created_at = nil
  9456. }
  9457. // SetUpdatedAt sets the "updated_at" field.
  9458. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  9459. m.updated_at = &t
  9460. }
  9461. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9462. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  9463. v := m.updated_at
  9464. if v == nil {
  9465. return
  9466. }
  9467. return *v, true
  9468. }
  9469. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  9470. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  9471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9472. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9473. if !m.op.Is(OpUpdateOne) {
  9474. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9475. }
  9476. if m.id == nil || m.oldValue == nil {
  9477. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9478. }
  9479. oldValue, err := m.oldValue(ctx)
  9480. if err != nil {
  9481. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9482. }
  9483. return oldValue.UpdatedAt, nil
  9484. }
  9485. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9486. func (m *MsgMutation) ResetUpdatedAt() {
  9487. m.updated_at = nil
  9488. }
  9489. // SetDeletedAt sets the "deleted_at" field.
  9490. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  9491. m.deleted_at = &t
  9492. }
  9493. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9494. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  9495. v := m.deleted_at
  9496. if v == nil {
  9497. return
  9498. }
  9499. return *v, true
  9500. }
  9501. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  9502. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  9503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9504. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9505. if !m.op.Is(OpUpdateOne) {
  9506. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9507. }
  9508. if m.id == nil || m.oldValue == nil {
  9509. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9510. }
  9511. oldValue, err := m.oldValue(ctx)
  9512. if err != nil {
  9513. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9514. }
  9515. return oldValue.DeletedAt, nil
  9516. }
  9517. // ClearDeletedAt clears the value of the "deleted_at" field.
  9518. func (m *MsgMutation) ClearDeletedAt() {
  9519. m.deleted_at = nil
  9520. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  9521. }
  9522. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9523. func (m *MsgMutation) DeletedAtCleared() bool {
  9524. _, ok := m.clearedFields[msg.FieldDeletedAt]
  9525. return ok
  9526. }
  9527. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9528. func (m *MsgMutation) ResetDeletedAt() {
  9529. m.deleted_at = nil
  9530. delete(m.clearedFields, msg.FieldDeletedAt)
  9531. }
  9532. // SetStatus sets the "status" field.
  9533. func (m *MsgMutation) SetStatus(u uint8) {
  9534. m.status = &u
  9535. m.addstatus = nil
  9536. }
  9537. // Status returns the value of the "status" field in the mutation.
  9538. func (m *MsgMutation) Status() (r uint8, exists bool) {
  9539. v := m.status
  9540. if v == nil {
  9541. return
  9542. }
  9543. return *v, true
  9544. }
  9545. // OldStatus returns the old "status" field's value of the Msg entity.
  9546. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  9547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9548. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9549. if !m.op.Is(OpUpdateOne) {
  9550. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9551. }
  9552. if m.id == nil || m.oldValue == nil {
  9553. return v, errors.New("OldStatus requires an ID field in the mutation")
  9554. }
  9555. oldValue, err := m.oldValue(ctx)
  9556. if err != nil {
  9557. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9558. }
  9559. return oldValue.Status, nil
  9560. }
  9561. // AddStatus adds u to the "status" field.
  9562. func (m *MsgMutation) AddStatus(u int8) {
  9563. if m.addstatus != nil {
  9564. *m.addstatus += u
  9565. } else {
  9566. m.addstatus = &u
  9567. }
  9568. }
  9569. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9570. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  9571. v := m.addstatus
  9572. if v == nil {
  9573. return
  9574. }
  9575. return *v, true
  9576. }
  9577. // ClearStatus clears the value of the "status" field.
  9578. func (m *MsgMutation) ClearStatus() {
  9579. m.status = nil
  9580. m.addstatus = nil
  9581. m.clearedFields[msg.FieldStatus] = struct{}{}
  9582. }
  9583. // StatusCleared returns if the "status" field was cleared in this mutation.
  9584. func (m *MsgMutation) StatusCleared() bool {
  9585. _, ok := m.clearedFields[msg.FieldStatus]
  9586. return ok
  9587. }
  9588. // ResetStatus resets all changes to the "status" field.
  9589. func (m *MsgMutation) ResetStatus() {
  9590. m.status = nil
  9591. m.addstatus = nil
  9592. delete(m.clearedFields, msg.FieldStatus)
  9593. }
  9594. // SetFromwxid sets the "fromwxid" field.
  9595. func (m *MsgMutation) SetFromwxid(s string) {
  9596. m.fromwxid = &s
  9597. }
  9598. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  9599. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  9600. v := m.fromwxid
  9601. if v == nil {
  9602. return
  9603. }
  9604. return *v, true
  9605. }
  9606. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  9607. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  9608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9609. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  9610. if !m.op.Is(OpUpdateOne) {
  9611. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  9612. }
  9613. if m.id == nil || m.oldValue == nil {
  9614. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  9615. }
  9616. oldValue, err := m.oldValue(ctx)
  9617. if err != nil {
  9618. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  9619. }
  9620. return oldValue.Fromwxid, nil
  9621. }
  9622. // ClearFromwxid clears the value of the "fromwxid" field.
  9623. func (m *MsgMutation) ClearFromwxid() {
  9624. m.fromwxid = nil
  9625. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  9626. }
  9627. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  9628. func (m *MsgMutation) FromwxidCleared() bool {
  9629. _, ok := m.clearedFields[msg.FieldFromwxid]
  9630. return ok
  9631. }
  9632. // ResetFromwxid resets all changes to the "fromwxid" field.
  9633. func (m *MsgMutation) ResetFromwxid() {
  9634. m.fromwxid = nil
  9635. delete(m.clearedFields, msg.FieldFromwxid)
  9636. }
  9637. // SetToid sets the "toid" field.
  9638. func (m *MsgMutation) SetToid(s string) {
  9639. m.toid = &s
  9640. }
  9641. // Toid returns the value of the "toid" field in the mutation.
  9642. func (m *MsgMutation) Toid() (r string, exists bool) {
  9643. v := m.toid
  9644. if v == nil {
  9645. return
  9646. }
  9647. return *v, true
  9648. }
  9649. // OldToid returns the old "toid" field's value of the Msg entity.
  9650. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  9651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9652. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  9653. if !m.op.Is(OpUpdateOne) {
  9654. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  9655. }
  9656. if m.id == nil || m.oldValue == nil {
  9657. return v, errors.New("OldToid requires an ID field in the mutation")
  9658. }
  9659. oldValue, err := m.oldValue(ctx)
  9660. if err != nil {
  9661. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  9662. }
  9663. return oldValue.Toid, nil
  9664. }
  9665. // ClearToid clears the value of the "toid" field.
  9666. func (m *MsgMutation) ClearToid() {
  9667. m.toid = nil
  9668. m.clearedFields[msg.FieldToid] = struct{}{}
  9669. }
  9670. // ToidCleared returns if the "toid" field was cleared in this mutation.
  9671. func (m *MsgMutation) ToidCleared() bool {
  9672. _, ok := m.clearedFields[msg.FieldToid]
  9673. return ok
  9674. }
  9675. // ResetToid resets all changes to the "toid" field.
  9676. func (m *MsgMutation) ResetToid() {
  9677. m.toid = nil
  9678. delete(m.clearedFields, msg.FieldToid)
  9679. }
  9680. // SetMsgtype sets the "msgtype" field.
  9681. func (m *MsgMutation) SetMsgtype(i int32) {
  9682. m.msgtype = &i
  9683. m.addmsgtype = nil
  9684. }
  9685. // Msgtype returns the value of the "msgtype" field in the mutation.
  9686. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  9687. v := m.msgtype
  9688. if v == nil {
  9689. return
  9690. }
  9691. return *v, true
  9692. }
  9693. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  9694. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  9695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9696. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  9697. if !m.op.Is(OpUpdateOne) {
  9698. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  9699. }
  9700. if m.id == nil || m.oldValue == nil {
  9701. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  9702. }
  9703. oldValue, err := m.oldValue(ctx)
  9704. if err != nil {
  9705. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  9706. }
  9707. return oldValue.Msgtype, nil
  9708. }
  9709. // AddMsgtype adds i to the "msgtype" field.
  9710. func (m *MsgMutation) AddMsgtype(i int32) {
  9711. if m.addmsgtype != nil {
  9712. *m.addmsgtype += i
  9713. } else {
  9714. m.addmsgtype = &i
  9715. }
  9716. }
  9717. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  9718. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  9719. v := m.addmsgtype
  9720. if v == nil {
  9721. return
  9722. }
  9723. return *v, true
  9724. }
  9725. // ClearMsgtype clears the value of the "msgtype" field.
  9726. func (m *MsgMutation) ClearMsgtype() {
  9727. m.msgtype = nil
  9728. m.addmsgtype = nil
  9729. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  9730. }
  9731. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  9732. func (m *MsgMutation) MsgtypeCleared() bool {
  9733. _, ok := m.clearedFields[msg.FieldMsgtype]
  9734. return ok
  9735. }
  9736. // ResetMsgtype resets all changes to the "msgtype" field.
  9737. func (m *MsgMutation) ResetMsgtype() {
  9738. m.msgtype = nil
  9739. m.addmsgtype = nil
  9740. delete(m.clearedFields, msg.FieldMsgtype)
  9741. }
  9742. // SetMsg sets the "msg" field.
  9743. func (m *MsgMutation) SetMsg(s string) {
  9744. m.msg = &s
  9745. }
  9746. // Msg returns the value of the "msg" field in the mutation.
  9747. func (m *MsgMutation) Msg() (r string, exists bool) {
  9748. v := m.msg
  9749. if v == nil {
  9750. return
  9751. }
  9752. return *v, true
  9753. }
  9754. // OldMsg returns the old "msg" field's value of the Msg entity.
  9755. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  9756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9757. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  9758. if !m.op.Is(OpUpdateOne) {
  9759. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  9760. }
  9761. if m.id == nil || m.oldValue == nil {
  9762. return v, errors.New("OldMsg requires an ID field in the mutation")
  9763. }
  9764. oldValue, err := m.oldValue(ctx)
  9765. if err != nil {
  9766. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  9767. }
  9768. return oldValue.Msg, nil
  9769. }
  9770. // ClearMsg clears the value of the "msg" field.
  9771. func (m *MsgMutation) ClearMsg() {
  9772. m.msg = nil
  9773. m.clearedFields[msg.FieldMsg] = struct{}{}
  9774. }
  9775. // MsgCleared returns if the "msg" field was cleared in this mutation.
  9776. func (m *MsgMutation) MsgCleared() bool {
  9777. _, ok := m.clearedFields[msg.FieldMsg]
  9778. return ok
  9779. }
  9780. // ResetMsg resets all changes to the "msg" field.
  9781. func (m *MsgMutation) ResetMsg() {
  9782. m.msg = nil
  9783. delete(m.clearedFields, msg.FieldMsg)
  9784. }
  9785. // SetBatchNo sets the "batch_no" field.
  9786. func (m *MsgMutation) SetBatchNo(s string) {
  9787. m.batch_no = &s
  9788. }
  9789. // BatchNo returns the value of the "batch_no" field in the mutation.
  9790. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  9791. v := m.batch_no
  9792. if v == nil {
  9793. return
  9794. }
  9795. return *v, true
  9796. }
  9797. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  9798. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  9799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9800. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  9801. if !m.op.Is(OpUpdateOne) {
  9802. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  9803. }
  9804. if m.id == nil || m.oldValue == nil {
  9805. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  9806. }
  9807. oldValue, err := m.oldValue(ctx)
  9808. if err != nil {
  9809. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  9810. }
  9811. return oldValue.BatchNo, nil
  9812. }
  9813. // ClearBatchNo clears the value of the "batch_no" field.
  9814. func (m *MsgMutation) ClearBatchNo() {
  9815. m.batch_no = nil
  9816. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  9817. }
  9818. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  9819. func (m *MsgMutation) BatchNoCleared() bool {
  9820. _, ok := m.clearedFields[msg.FieldBatchNo]
  9821. return ok
  9822. }
  9823. // ResetBatchNo resets all changes to the "batch_no" field.
  9824. func (m *MsgMutation) ResetBatchNo() {
  9825. m.batch_no = nil
  9826. delete(m.clearedFields, msg.FieldBatchNo)
  9827. }
  9828. // Where appends a list predicates to the MsgMutation builder.
  9829. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  9830. m.predicates = append(m.predicates, ps...)
  9831. }
  9832. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  9833. // users can use type-assertion to append predicates that do not depend on any generated package.
  9834. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  9835. p := make([]predicate.Msg, len(ps))
  9836. for i := range ps {
  9837. p[i] = ps[i]
  9838. }
  9839. m.Where(p...)
  9840. }
  9841. // Op returns the operation name.
  9842. func (m *MsgMutation) Op() Op {
  9843. return m.op
  9844. }
  9845. // SetOp allows setting the mutation operation.
  9846. func (m *MsgMutation) SetOp(op Op) {
  9847. m.op = op
  9848. }
  9849. // Type returns the node type of this mutation (Msg).
  9850. func (m *MsgMutation) Type() string {
  9851. return m.typ
  9852. }
  9853. // Fields returns all fields that were changed during this mutation. Note that in
  9854. // order to get all numeric fields that were incremented/decremented, call
  9855. // AddedFields().
  9856. func (m *MsgMutation) Fields() []string {
  9857. fields := make([]string, 0, 9)
  9858. if m.created_at != nil {
  9859. fields = append(fields, msg.FieldCreatedAt)
  9860. }
  9861. if m.updated_at != nil {
  9862. fields = append(fields, msg.FieldUpdatedAt)
  9863. }
  9864. if m.deleted_at != nil {
  9865. fields = append(fields, msg.FieldDeletedAt)
  9866. }
  9867. if m.status != nil {
  9868. fields = append(fields, msg.FieldStatus)
  9869. }
  9870. if m.fromwxid != nil {
  9871. fields = append(fields, msg.FieldFromwxid)
  9872. }
  9873. if m.toid != nil {
  9874. fields = append(fields, msg.FieldToid)
  9875. }
  9876. if m.msgtype != nil {
  9877. fields = append(fields, msg.FieldMsgtype)
  9878. }
  9879. if m.msg != nil {
  9880. fields = append(fields, msg.FieldMsg)
  9881. }
  9882. if m.batch_no != nil {
  9883. fields = append(fields, msg.FieldBatchNo)
  9884. }
  9885. return fields
  9886. }
  9887. // Field returns the value of a field with the given name. The second boolean
  9888. // return value indicates that this field was not set, or was not defined in the
  9889. // schema.
  9890. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  9891. switch name {
  9892. case msg.FieldCreatedAt:
  9893. return m.CreatedAt()
  9894. case msg.FieldUpdatedAt:
  9895. return m.UpdatedAt()
  9896. case msg.FieldDeletedAt:
  9897. return m.DeletedAt()
  9898. case msg.FieldStatus:
  9899. return m.Status()
  9900. case msg.FieldFromwxid:
  9901. return m.Fromwxid()
  9902. case msg.FieldToid:
  9903. return m.Toid()
  9904. case msg.FieldMsgtype:
  9905. return m.Msgtype()
  9906. case msg.FieldMsg:
  9907. return m.Msg()
  9908. case msg.FieldBatchNo:
  9909. return m.BatchNo()
  9910. }
  9911. return nil, false
  9912. }
  9913. // OldField returns the old value of the field from the database. An error is
  9914. // returned if the mutation operation is not UpdateOne, or the query to the
  9915. // database failed.
  9916. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9917. switch name {
  9918. case msg.FieldCreatedAt:
  9919. return m.OldCreatedAt(ctx)
  9920. case msg.FieldUpdatedAt:
  9921. return m.OldUpdatedAt(ctx)
  9922. case msg.FieldDeletedAt:
  9923. return m.OldDeletedAt(ctx)
  9924. case msg.FieldStatus:
  9925. return m.OldStatus(ctx)
  9926. case msg.FieldFromwxid:
  9927. return m.OldFromwxid(ctx)
  9928. case msg.FieldToid:
  9929. return m.OldToid(ctx)
  9930. case msg.FieldMsgtype:
  9931. return m.OldMsgtype(ctx)
  9932. case msg.FieldMsg:
  9933. return m.OldMsg(ctx)
  9934. case msg.FieldBatchNo:
  9935. return m.OldBatchNo(ctx)
  9936. }
  9937. return nil, fmt.Errorf("unknown Msg field %s", name)
  9938. }
  9939. // SetField sets the value of a field with the given name. It returns an error if
  9940. // the field is not defined in the schema, or if the type mismatched the field
  9941. // type.
  9942. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  9943. switch name {
  9944. case msg.FieldCreatedAt:
  9945. v, ok := value.(time.Time)
  9946. if !ok {
  9947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9948. }
  9949. m.SetCreatedAt(v)
  9950. return nil
  9951. case msg.FieldUpdatedAt:
  9952. v, ok := value.(time.Time)
  9953. if !ok {
  9954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9955. }
  9956. m.SetUpdatedAt(v)
  9957. return nil
  9958. case msg.FieldDeletedAt:
  9959. v, ok := value.(time.Time)
  9960. if !ok {
  9961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9962. }
  9963. m.SetDeletedAt(v)
  9964. return nil
  9965. case msg.FieldStatus:
  9966. v, ok := value.(uint8)
  9967. if !ok {
  9968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9969. }
  9970. m.SetStatus(v)
  9971. return nil
  9972. case msg.FieldFromwxid:
  9973. v, ok := value.(string)
  9974. if !ok {
  9975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9976. }
  9977. m.SetFromwxid(v)
  9978. return nil
  9979. case msg.FieldToid:
  9980. v, ok := value.(string)
  9981. if !ok {
  9982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9983. }
  9984. m.SetToid(v)
  9985. return nil
  9986. case msg.FieldMsgtype:
  9987. v, ok := value.(int32)
  9988. if !ok {
  9989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9990. }
  9991. m.SetMsgtype(v)
  9992. return nil
  9993. case msg.FieldMsg:
  9994. v, ok := value.(string)
  9995. if !ok {
  9996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9997. }
  9998. m.SetMsg(v)
  9999. return nil
  10000. case msg.FieldBatchNo:
  10001. v, ok := value.(string)
  10002. if !ok {
  10003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10004. }
  10005. m.SetBatchNo(v)
  10006. return nil
  10007. }
  10008. return fmt.Errorf("unknown Msg field %s", name)
  10009. }
  10010. // AddedFields returns all numeric fields that were incremented/decremented during
  10011. // this mutation.
  10012. func (m *MsgMutation) AddedFields() []string {
  10013. var fields []string
  10014. if m.addstatus != nil {
  10015. fields = append(fields, msg.FieldStatus)
  10016. }
  10017. if m.addmsgtype != nil {
  10018. fields = append(fields, msg.FieldMsgtype)
  10019. }
  10020. return fields
  10021. }
  10022. // AddedField returns the numeric value that was incremented/decremented on a field
  10023. // with the given name. The second boolean return value indicates that this field
  10024. // was not set, or was not defined in the schema.
  10025. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  10026. switch name {
  10027. case msg.FieldStatus:
  10028. return m.AddedStatus()
  10029. case msg.FieldMsgtype:
  10030. return m.AddedMsgtype()
  10031. }
  10032. return nil, false
  10033. }
  10034. // AddField adds the value to the field with the given name. It returns an error if
  10035. // the field is not defined in the schema, or if the type mismatched the field
  10036. // type.
  10037. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  10038. switch name {
  10039. case msg.FieldStatus:
  10040. v, ok := value.(int8)
  10041. if !ok {
  10042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10043. }
  10044. m.AddStatus(v)
  10045. return nil
  10046. case msg.FieldMsgtype:
  10047. v, ok := value.(int32)
  10048. if !ok {
  10049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10050. }
  10051. m.AddMsgtype(v)
  10052. return nil
  10053. }
  10054. return fmt.Errorf("unknown Msg numeric field %s", name)
  10055. }
  10056. // ClearedFields returns all nullable fields that were cleared during this
  10057. // mutation.
  10058. func (m *MsgMutation) ClearedFields() []string {
  10059. var fields []string
  10060. if m.FieldCleared(msg.FieldDeletedAt) {
  10061. fields = append(fields, msg.FieldDeletedAt)
  10062. }
  10063. if m.FieldCleared(msg.FieldStatus) {
  10064. fields = append(fields, msg.FieldStatus)
  10065. }
  10066. if m.FieldCleared(msg.FieldFromwxid) {
  10067. fields = append(fields, msg.FieldFromwxid)
  10068. }
  10069. if m.FieldCleared(msg.FieldToid) {
  10070. fields = append(fields, msg.FieldToid)
  10071. }
  10072. if m.FieldCleared(msg.FieldMsgtype) {
  10073. fields = append(fields, msg.FieldMsgtype)
  10074. }
  10075. if m.FieldCleared(msg.FieldMsg) {
  10076. fields = append(fields, msg.FieldMsg)
  10077. }
  10078. if m.FieldCleared(msg.FieldBatchNo) {
  10079. fields = append(fields, msg.FieldBatchNo)
  10080. }
  10081. return fields
  10082. }
  10083. // FieldCleared returns a boolean indicating if a field with the given name was
  10084. // cleared in this mutation.
  10085. func (m *MsgMutation) FieldCleared(name string) bool {
  10086. _, ok := m.clearedFields[name]
  10087. return ok
  10088. }
  10089. // ClearField clears the value of the field with the given name. It returns an
  10090. // error if the field is not defined in the schema.
  10091. func (m *MsgMutation) ClearField(name string) error {
  10092. switch name {
  10093. case msg.FieldDeletedAt:
  10094. m.ClearDeletedAt()
  10095. return nil
  10096. case msg.FieldStatus:
  10097. m.ClearStatus()
  10098. return nil
  10099. case msg.FieldFromwxid:
  10100. m.ClearFromwxid()
  10101. return nil
  10102. case msg.FieldToid:
  10103. m.ClearToid()
  10104. return nil
  10105. case msg.FieldMsgtype:
  10106. m.ClearMsgtype()
  10107. return nil
  10108. case msg.FieldMsg:
  10109. m.ClearMsg()
  10110. return nil
  10111. case msg.FieldBatchNo:
  10112. m.ClearBatchNo()
  10113. return nil
  10114. }
  10115. return fmt.Errorf("unknown Msg nullable field %s", name)
  10116. }
  10117. // ResetField resets all changes in the mutation for the field with the given name.
  10118. // It returns an error if the field is not defined in the schema.
  10119. func (m *MsgMutation) ResetField(name string) error {
  10120. switch name {
  10121. case msg.FieldCreatedAt:
  10122. m.ResetCreatedAt()
  10123. return nil
  10124. case msg.FieldUpdatedAt:
  10125. m.ResetUpdatedAt()
  10126. return nil
  10127. case msg.FieldDeletedAt:
  10128. m.ResetDeletedAt()
  10129. return nil
  10130. case msg.FieldStatus:
  10131. m.ResetStatus()
  10132. return nil
  10133. case msg.FieldFromwxid:
  10134. m.ResetFromwxid()
  10135. return nil
  10136. case msg.FieldToid:
  10137. m.ResetToid()
  10138. return nil
  10139. case msg.FieldMsgtype:
  10140. m.ResetMsgtype()
  10141. return nil
  10142. case msg.FieldMsg:
  10143. m.ResetMsg()
  10144. return nil
  10145. case msg.FieldBatchNo:
  10146. m.ResetBatchNo()
  10147. return nil
  10148. }
  10149. return fmt.Errorf("unknown Msg field %s", name)
  10150. }
  10151. // AddedEdges returns all edge names that were set/added in this mutation.
  10152. func (m *MsgMutation) AddedEdges() []string {
  10153. edges := make([]string, 0, 0)
  10154. return edges
  10155. }
  10156. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10157. // name in this mutation.
  10158. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  10159. return nil
  10160. }
  10161. // RemovedEdges returns all edge names that were removed in this mutation.
  10162. func (m *MsgMutation) RemovedEdges() []string {
  10163. edges := make([]string, 0, 0)
  10164. return edges
  10165. }
  10166. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10167. // the given name in this mutation.
  10168. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  10169. return nil
  10170. }
  10171. // ClearedEdges returns all edge names that were cleared in this mutation.
  10172. func (m *MsgMutation) ClearedEdges() []string {
  10173. edges := make([]string, 0, 0)
  10174. return edges
  10175. }
  10176. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10177. // was cleared in this mutation.
  10178. func (m *MsgMutation) EdgeCleared(name string) bool {
  10179. return false
  10180. }
  10181. // ClearEdge clears the value of the edge with the given name. It returns an error
  10182. // if that edge is not defined in the schema.
  10183. func (m *MsgMutation) ClearEdge(name string) error {
  10184. return fmt.Errorf("unknown Msg unique edge %s", name)
  10185. }
  10186. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10187. // It returns an error if the edge is not defined in the schema.
  10188. func (m *MsgMutation) ResetEdge(name string) error {
  10189. return fmt.Errorf("unknown Msg edge %s", name)
  10190. }
  10191. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  10192. type ServerMutation struct {
  10193. config
  10194. op Op
  10195. typ string
  10196. id *uint64
  10197. created_at *time.Time
  10198. updated_at *time.Time
  10199. status *uint8
  10200. addstatus *int8
  10201. deleted_at *time.Time
  10202. name *string
  10203. public_ip *string
  10204. private_ip *string
  10205. admin_port *string
  10206. clearedFields map[string]struct{}
  10207. wxs map[uint64]struct{}
  10208. removedwxs map[uint64]struct{}
  10209. clearedwxs bool
  10210. done bool
  10211. oldValue func(context.Context) (*Server, error)
  10212. predicates []predicate.Server
  10213. }
  10214. var _ ent.Mutation = (*ServerMutation)(nil)
  10215. // serverOption allows management of the mutation configuration using functional options.
  10216. type serverOption func(*ServerMutation)
  10217. // newServerMutation creates new mutation for the Server entity.
  10218. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  10219. m := &ServerMutation{
  10220. config: c,
  10221. op: op,
  10222. typ: TypeServer,
  10223. clearedFields: make(map[string]struct{}),
  10224. }
  10225. for _, opt := range opts {
  10226. opt(m)
  10227. }
  10228. return m
  10229. }
  10230. // withServerID sets the ID field of the mutation.
  10231. func withServerID(id uint64) serverOption {
  10232. return func(m *ServerMutation) {
  10233. var (
  10234. err error
  10235. once sync.Once
  10236. value *Server
  10237. )
  10238. m.oldValue = func(ctx context.Context) (*Server, error) {
  10239. once.Do(func() {
  10240. if m.done {
  10241. err = errors.New("querying old values post mutation is not allowed")
  10242. } else {
  10243. value, err = m.Client().Server.Get(ctx, id)
  10244. }
  10245. })
  10246. return value, err
  10247. }
  10248. m.id = &id
  10249. }
  10250. }
  10251. // withServer sets the old Server of the mutation.
  10252. func withServer(node *Server) serverOption {
  10253. return func(m *ServerMutation) {
  10254. m.oldValue = func(context.Context) (*Server, error) {
  10255. return node, nil
  10256. }
  10257. m.id = &node.ID
  10258. }
  10259. }
  10260. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10261. // executed in a transaction (ent.Tx), a transactional client is returned.
  10262. func (m ServerMutation) Client() *Client {
  10263. client := &Client{config: m.config}
  10264. client.init()
  10265. return client
  10266. }
  10267. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10268. // it returns an error otherwise.
  10269. func (m ServerMutation) Tx() (*Tx, error) {
  10270. if _, ok := m.driver.(*txDriver); !ok {
  10271. return nil, errors.New("ent: mutation is not running in a transaction")
  10272. }
  10273. tx := &Tx{config: m.config}
  10274. tx.init()
  10275. return tx, nil
  10276. }
  10277. // SetID sets the value of the id field. Note that this
  10278. // operation is only accepted on creation of Server entities.
  10279. func (m *ServerMutation) SetID(id uint64) {
  10280. m.id = &id
  10281. }
  10282. // ID returns the ID value in the mutation. Note that the ID is only available
  10283. // if it was provided to the builder or after it was returned from the database.
  10284. func (m *ServerMutation) ID() (id uint64, exists bool) {
  10285. if m.id == nil {
  10286. return
  10287. }
  10288. return *m.id, true
  10289. }
  10290. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10291. // That means, if the mutation is applied within a transaction with an isolation level such
  10292. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10293. // or updated by the mutation.
  10294. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  10295. switch {
  10296. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10297. id, exists := m.ID()
  10298. if exists {
  10299. return []uint64{id}, nil
  10300. }
  10301. fallthrough
  10302. case m.op.Is(OpUpdate | OpDelete):
  10303. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  10304. default:
  10305. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10306. }
  10307. }
  10308. // SetCreatedAt sets the "created_at" field.
  10309. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  10310. m.created_at = &t
  10311. }
  10312. // CreatedAt returns the value of the "created_at" field in the mutation.
  10313. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  10314. v := m.created_at
  10315. if v == nil {
  10316. return
  10317. }
  10318. return *v, true
  10319. }
  10320. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  10321. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  10322. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10323. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10324. if !m.op.Is(OpUpdateOne) {
  10325. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10326. }
  10327. if m.id == nil || m.oldValue == nil {
  10328. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10329. }
  10330. oldValue, err := m.oldValue(ctx)
  10331. if err != nil {
  10332. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10333. }
  10334. return oldValue.CreatedAt, nil
  10335. }
  10336. // ResetCreatedAt resets all changes to the "created_at" field.
  10337. func (m *ServerMutation) ResetCreatedAt() {
  10338. m.created_at = nil
  10339. }
  10340. // SetUpdatedAt sets the "updated_at" field.
  10341. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  10342. m.updated_at = &t
  10343. }
  10344. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10345. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  10346. v := m.updated_at
  10347. if v == nil {
  10348. return
  10349. }
  10350. return *v, true
  10351. }
  10352. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  10353. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  10354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10355. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10356. if !m.op.Is(OpUpdateOne) {
  10357. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10358. }
  10359. if m.id == nil || m.oldValue == nil {
  10360. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10361. }
  10362. oldValue, err := m.oldValue(ctx)
  10363. if err != nil {
  10364. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10365. }
  10366. return oldValue.UpdatedAt, nil
  10367. }
  10368. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10369. func (m *ServerMutation) ResetUpdatedAt() {
  10370. m.updated_at = nil
  10371. }
  10372. // SetStatus sets the "status" field.
  10373. func (m *ServerMutation) SetStatus(u uint8) {
  10374. m.status = &u
  10375. m.addstatus = nil
  10376. }
  10377. // Status returns the value of the "status" field in the mutation.
  10378. func (m *ServerMutation) Status() (r uint8, exists bool) {
  10379. v := m.status
  10380. if v == nil {
  10381. return
  10382. }
  10383. return *v, true
  10384. }
  10385. // OldStatus returns the old "status" field's value of the Server entity.
  10386. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  10387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10388. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  10389. if !m.op.Is(OpUpdateOne) {
  10390. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10391. }
  10392. if m.id == nil || m.oldValue == nil {
  10393. return v, errors.New("OldStatus requires an ID field in the mutation")
  10394. }
  10395. oldValue, err := m.oldValue(ctx)
  10396. if err != nil {
  10397. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10398. }
  10399. return oldValue.Status, nil
  10400. }
  10401. // AddStatus adds u to the "status" field.
  10402. func (m *ServerMutation) AddStatus(u int8) {
  10403. if m.addstatus != nil {
  10404. *m.addstatus += u
  10405. } else {
  10406. m.addstatus = &u
  10407. }
  10408. }
  10409. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10410. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  10411. v := m.addstatus
  10412. if v == nil {
  10413. return
  10414. }
  10415. return *v, true
  10416. }
  10417. // ClearStatus clears the value of the "status" field.
  10418. func (m *ServerMutation) ClearStatus() {
  10419. m.status = nil
  10420. m.addstatus = nil
  10421. m.clearedFields[server.FieldStatus] = struct{}{}
  10422. }
  10423. // StatusCleared returns if the "status" field was cleared in this mutation.
  10424. func (m *ServerMutation) StatusCleared() bool {
  10425. _, ok := m.clearedFields[server.FieldStatus]
  10426. return ok
  10427. }
  10428. // ResetStatus resets all changes to the "status" field.
  10429. func (m *ServerMutation) ResetStatus() {
  10430. m.status = nil
  10431. m.addstatus = nil
  10432. delete(m.clearedFields, server.FieldStatus)
  10433. }
  10434. // SetDeletedAt sets the "deleted_at" field.
  10435. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  10436. m.deleted_at = &t
  10437. }
  10438. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10439. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  10440. v := m.deleted_at
  10441. if v == nil {
  10442. return
  10443. }
  10444. return *v, true
  10445. }
  10446. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  10447. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  10448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10449. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10450. if !m.op.Is(OpUpdateOne) {
  10451. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10452. }
  10453. if m.id == nil || m.oldValue == nil {
  10454. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10455. }
  10456. oldValue, err := m.oldValue(ctx)
  10457. if err != nil {
  10458. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10459. }
  10460. return oldValue.DeletedAt, nil
  10461. }
  10462. // ClearDeletedAt clears the value of the "deleted_at" field.
  10463. func (m *ServerMutation) ClearDeletedAt() {
  10464. m.deleted_at = nil
  10465. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  10466. }
  10467. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10468. func (m *ServerMutation) DeletedAtCleared() bool {
  10469. _, ok := m.clearedFields[server.FieldDeletedAt]
  10470. return ok
  10471. }
  10472. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10473. func (m *ServerMutation) ResetDeletedAt() {
  10474. m.deleted_at = nil
  10475. delete(m.clearedFields, server.FieldDeletedAt)
  10476. }
  10477. // SetName sets the "name" field.
  10478. func (m *ServerMutation) SetName(s string) {
  10479. m.name = &s
  10480. }
  10481. // Name returns the value of the "name" field in the mutation.
  10482. func (m *ServerMutation) Name() (r string, exists bool) {
  10483. v := m.name
  10484. if v == nil {
  10485. return
  10486. }
  10487. return *v, true
  10488. }
  10489. // OldName returns the old "name" field's value of the Server entity.
  10490. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  10491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10492. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  10493. if !m.op.Is(OpUpdateOne) {
  10494. return v, errors.New("OldName is only allowed on UpdateOne operations")
  10495. }
  10496. if m.id == nil || m.oldValue == nil {
  10497. return v, errors.New("OldName requires an ID field in the mutation")
  10498. }
  10499. oldValue, err := m.oldValue(ctx)
  10500. if err != nil {
  10501. return v, fmt.Errorf("querying old value for OldName: %w", err)
  10502. }
  10503. return oldValue.Name, nil
  10504. }
  10505. // ResetName resets all changes to the "name" field.
  10506. func (m *ServerMutation) ResetName() {
  10507. m.name = nil
  10508. }
  10509. // SetPublicIP sets the "public_ip" field.
  10510. func (m *ServerMutation) SetPublicIP(s string) {
  10511. m.public_ip = &s
  10512. }
  10513. // PublicIP returns the value of the "public_ip" field in the mutation.
  10514. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  10515. v := m.public_ip
  10516. if v == nil {
  10517. return
  10518. }
  10519. return *v, true
  10520. }
  10521. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  10522. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  10523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10524. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  10525. if !m.op.Is(OpUpdateOne) {
  10526. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  10527. }
  10528. if m.id == nil || m.oldValue == nil {
  10529. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  10530. }
  10531. oldValue, err := m.oldValue(ctx)
  10532. if err != nil {
  10533. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  10534. }
  10535. return oldValue.PublicIP, nil
  10536. }
  10537. // ResetPublicIP resets all changes to the "public_ip" field.
  10538. func (m *ServerMutation) ResetPublicIP() {
  10539. m.public_ip = nil
  10540. }
  10541. // SetPrivateIP sets the "private_ip" field.
  10542. func (m *ServerMutation) SetPrivateIP(s string) {
  10543. m.private_ip = &s
  10544. }
  10545. // PrivateIP returns the value of the "private_ip" field in the mutation.
  10546. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  10547. v := m.private_ip
  10548. if v == nil {
  10549. return
  10550. }
  10551. return *v, true
  10552. }
  10553. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  10554. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  10555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10556. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  10557. if !m.op.Is(OpUpdateOne) {
  10558. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  10559. }
  10560. if m.id == nil || m.oldValue == nil {
  10561. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  10562. }
  10563. oldValue, err := m.oldValue(ctx)
  10564. if err != nil {
  10565. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  10566. }
  10567. return oldValue.PrivateIP, nil
  10568. }
  10569. // ResetPrivateIP resets all changes to the "private_ip" field.
  10570. func (m *ServerMutation) ResetPrivateIP() {
  10571. m.private_ip = nil
  10572. }
  10573. // SetAdminPort sets the "admin_port" field.
  10574. func (m *ServerMutation) SetAdminPort(s string) {
  10575. m.admin_port = &s
  10576. }
  10577. // AdminPort returns the value of the "admin_port" field in the mutation.
  10578. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  10579. v := m.admin_port
  10580. if v == nil {
  10581. return
  10582. }
  10583. return *v, true
  10584. }
  10585. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  10586. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  10587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10588. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  10589. if !m.op.Is(OpUpdateOne) {
  10590. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  10591. }
  10592. if m.id == nil || m.oldValue == nil {
  10593. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  10594. }
  10595. oldValue, err := m.oldValue(ctx)
  10596. if err != nil {
  10597. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  10598. }
  10599. return oldValue.AdminPort, nil
  10600. }
  10601. // ResetAdminPort resets all changes to the "admin_port" field.
  10602. func (m *ServerMutation) ResetAdminPort() {
  10603. m.admin_port = nil
  10604. }
  10605. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  10606. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  10607. if m.wxs == nil {
  10608. m.wxs = make(map[uint64]struct{})
  10609. }
  10610. for i := range ids {
  10611. m.wxs[ids[i]] = struct{}{}
  10612. }
  10613. }
  10614. // ClearWxs clears the "wxs" edge to the Wx entity.
  10615. func (m *ServerMutation) ClearWxs() {
  10616. m.clearedwxs = true
  10617. }
  10618. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  10619. func (m *ServerMutation) WxsCleared() bool {
  10620. return m.clearedwxs
  10621. }
  10622. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  10623. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  10624. if m.removedwxs == nil {
  10625. m.removedwxs = make(map[uint64]struct{})
  10626. }
  10627. for i := range ids {
  10628. delete(m.wxs, ids[i])
  10629. m.removedwxs[ids[i]] = struct{}{}
  10630. }
  10631. }
  10632. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  10633. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  10634. for id := range m.removedwxs {
  10635. ids = append(ids, id)
  10636. }
  10637. return
  10638. }
  10639. // WxsIDs returns the "wxs" edge IDs in the mutation.
  10640. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  10641. for id := range m.wxs {
  10642. ids = append(ids, id)
  10643. }
  10644. return
  10645. }
  10646. // ResetWxs resets all changes to the "wxs" edge.
  10647. func (m *ServerMutation) ResetWxs() {
  10648. m.wxs = nil
  10649. m.clearedwxs = false
  10650. m.removedwxs = nil
  10651. }
  10652. // Where appends a list predicates to the ServerMutation builder.
  10653. func (m *ServerMutation) Where(ps ...predicate.Server) {
  10654. m.predicates = append(m.predicates, ps...)
  10655. }
  10656. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  10657. // users can use type-assertion to append predicates that do not depend on any generated package.
  10658. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  10659. p := make([]predicate.Server, len(ps))
  10660. for i := range ps {
  10661. p[i] = ps[i]
  10662. }
  10663. m.Where(p...)
  10664. }
  10665. // Op returns the operation name.
  10666. func (m *ServerMutation) Op() Op {
  10667. return m.op
  10668. }
  10669. // SetOp allows setting the mutation operation.
  10670. func (m *ServerMutation) SetOp(op Op) {
  10671. m.op = op
  10672. }
  10673. // Type returns the node type of this mutation (Server).
  10674. func (m *ServerMutation) Type() string {
  10675. return m.typ
  10676. }
  10677. // Fields returns all fields that were changed during this mutation. Note that in
  10678. // order to get all numeric fields that were incremented/decremented, call
  10679. // AddedFields().
  10680. func (m *ServerMutation) Fields() []string {
  10681. fields := make([]string, 0, 8)
  10682. if m.created_at != nil {
  10683. fields = append(fields, server.FieldCreatedAt)
  10684. }
  10685. if m.updated_at != nil {
  10686. fields = append(fields, server.FieldUpdatedAt)
  10687. }
  10688. if m.status != nil {
  10689. fields = append(fields, server.FieldStatus)
  10690. }
  10691. if m.deleted_at != nil {
  10692. fields = append(fields, server.FieldDeletedAt)
  10693. }
  10694. if m.name != nil {
  10695. fields = append(fields, server.FieldName)
  10696. }
  10697. if m.public_ip != nil {
  10698. fields = append(fields, server.FieldPublicIP)
  10699. }
  10700. if m.private_ip != nil {
  10701. fields = append(fields, server.FieldPrivateIP)
  10702. }
  10703. if m.admin_port != nil {
  10704. fields = append(fields, server.FieldAdminPort)
  10705. }
  10706. return fields
  10707. }
  10708. // Field returns the value of a field with the given name. The second boolean
  10709. // return value indicates that this field was not set, or was not defined in the
  10710. // schema.
  10711. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  10712. switch name {
  10713. case server.FieldCreatedAt:
  10714. return m.CreatedAt()
  10715. case server.FieldUpdatedAt:
  10716. return m.UpdatedAt()
  10717. case server.FieldStatus:
  10718. return m.Status()
  10719. case server.FieldDeletedAt:
  10720. return m.DeletedAt()
  10721. case server.FieldName:
  10722. return m.Name()
  10723. case server.FieldPublicIP:
  10724. return m.PublicIP()
  10725. case server.FieldPrivateIP:
  10726. return m.PrivateIP()
  10727. case server.FieldAdminPort:
  10728. return m.AdminPort()
  10729. }
  10730. return nil, false
  10731. }
  10732. // OldField returns the old value of the field from the database. An error is
  10733. // returned if the mutation operation is not UpdateOne, or the query to the
  10734. // database failed.
  10735. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10736. switch name {
  10737. case server.FieldCreatedAt:
  10738. return m.OldCreatedAt(ctx)
  10739. case server.FieldUpdatedAt:
  10740. return m.OldUpdatedAt(ctx)
  10741. case server.FieldStatus:
  10742. return m.OldStatus(ctx)
  10743. case server.FieldDeletedAt:
  10744. return m.OldDeletedAt(ctx)
  10745. case server.FieldName:
  10746. return m.OldName(ctx)
  10747. case server.FieldPublicIP:
  10748. return m.OldPublicIP(ctx)
  10749. case server.FieldPrivateIP:
  10750. return m.OldPrivateIP(ctx)
  10751. case server.FieldAdminPort:
  10752. return m.OldAdminPort(ctx)
  10753. }
  10754. return nil, fmt.Errorf("unknown Server field %s", name)
  10755. }
  10756. // SetField sets the value of a field with the given name. It returns an error if
  10757. // the field is not defined in the schema, or if the type mismatched the field
  10758. // type.
  10759. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  10760. switch name {
  10761. case server.FieldCreatedAt:
  10762. v, ok := value.(time.Time)
  10763. if !ok {
  10764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10765. }
  10766. m.SetCreatedAt(v)
  10767. return nil
  10768. case server.FieldUpdatedAt:
  10769. v, ok := value.(time.Time)
  10770. if !ok {
  10771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10772. }
  10773. m.SetUpdatedAt(v)
  10774. return nil
  10775. case server.FieldStatus:
  10776. v, ok := value.(uint8)
  10777. if !ok {
  10778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10779. }
  10780. m.SetStatus(v)
  10781. return nil
  10782. case server.FieldDeletedAt:
  10783. v, ok := value.(time.Time)
  10784. if !ok {
  10785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10786. }
  10787. m.SetDeletedAt(v)
  10788. return nil
  10789. case server.FieldName:
  10790. v, ok := value.(string)
  10791. if !ok {
  10792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10793. }
  10794. m.SetName(v)
  10795. return nil
  10796. case server.FieldPublicIP:
  10797. v, ok := value.(string)
  10798. if !ok {
  10799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10800. }
  10801. m.SetPublicIP(v)
  10802. return nil
  10803. case server.FieldPrivateIP:
  10804. v, ok := value.(string)
  10805. if !ok {
  10806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10807. }
  10808. m.SetPrivateIP(v)
  10809. return nil
  10810. case server.FieldAdminPort:
  10811. v, ok := value.(string)
  10812. if !ok {
  10813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10814. }
  10815. m.SetAdminPort(v)
  10816. return nil
  10817. }
  10818. return fmt.Errorf("unknown Server field %s", name)
  10819. }
  10820. // AddedFields returns all numeric fields that were incremented/decremented during
  10821. // this mutation.
  10822. func (m *ServerMutation) AddedFields() []string {
  10823. var fields []string
  10824. if m.addstatus != nil {
  10825. fields = append(fields, server.FieldStatus)
  10826. }
  10827. return fields
  10828. }
  10829. // AddedField returns the numeric value that was incremented/decremented on a field
  10830. // with the given name. The second boolean return value indicates that this field
  10831. // was not set, or was not defined in the schema.
  10832. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  10833. switch name {
  10834. case server.FieldStatus:
  10835. return m.AddedStatus()
  10836. }
  10837. return nil, false
  10838. }
  10839. // AddField adds the value to the field with the given name. It returns an error if
  10840. // the field is not defined in the schema, or if the type mismatched the field
  10841. // type.
  10842. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  10843. switch name {
  10844. case server.FieldStatus:
  10845. v, ok := value.(int8)
  10846. if !ok {
  10847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10848. }
  10849. m.AddStatus(v)
  10850. return nil
  10851. }
  10852. return fmt.Errorf("unknown Server numeric field %s", name)
  10853. }
  10854. // ClearedFields returns all nullable fields that were cleared during this
  10855. // mutation.
  10856. func (m *ServerMutation) ClearedFields() []string {
  10857. var fields []string
  10858. if m.FieldCleared(server.FieldStatus) {
  10859. fields = append(fields, server.FieldStatus)
  10860. }
  10861. if m.FieldCleared(server.FieldDeletedAt) {
  10862. fields = append(fields, server.FieldDeletedAt)
  10863. }
  10864. return fields
  10865. }
  10866. // FieldCleared returns a boolean indicating if a field with the given name was
  10867. // cleared in this mutation.
  10868. func (m *ServerMutation) FieldCleared(name string) bool {
  10869. _, ok := m.clearedFields[name]
  10870. return ok
  10871. }
  10872. // ClearField clears the value of the field with the given name. It returns an
  10873. // error if the field is not defined in the schema.
  10874. func (m *ServerMutation) ClearField(name string) error {
  10875. switch name {
  10876. case server.FieldStatus:
  10877. m.ClearStatus()
  10878. return nil
  10879. case server.FieldDeletedAt:
  10880. m.ClearDeletedAt()
  10881. return nil
  10882. }
  10883. return fmt.Errorf("unknown Server nullable field %s", name)
  10884. }
  10885. // ResetField resets all changes in the mutation for the field with the given name.
  10886. // It returns an error if the field is not defined in the schema.
  10887. func (m *ServerMutation) ResetField(name string) error {
  10888. switch name {
  10889. case server.FieldCreatedAt:
  10890. m.ResetCreatedAt()
  10891. return nil
  10892. case server.FieldUpdatedAt:
  10893. m.ResetUpdatedAt()
  10894. return nil
  10895. case server.FieldStatus:
  10896. m.ResetStatus()
  10897. return nil
  10898. case server.FieldDeletedAt:
  10899. m.ResetDeletedAt()
  10900. return nil
  10901. case server.FieldName:
  10902. m.ResetName()
  10903. return nil
  10904. case server.FieldPublicIP:
  10905. m.ResetPublicIP()
  10906. return nil
  10907. case server.FieldPrivateIP:
  10908. m.ResetPrivateIP()
  10909. return nil
  10910. case server.FieldAdminPort:
  10911. m.ResetAdminPort()
  10912. return nil
  10913. }
  10914. return fmt.Errorf("unknown Server field %s", name)
  10915. }
  10916. // AddedEdges returns all edge names that were set/added in this mutation.
  10917. func (m *ServerMutation) AddedEdges() []string {
  10918. edges := make([]string, 0, 1)
  10919. if m.wxs != nil {
  10920. edges = append(edges, server.EdgeWxs)
  10921. }
  10922. return edges
  10923. }
  10924. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10925. // name in this mutation.
  10926. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  10927. switch name {
  10928. case server.EdgeWxs:
  10929. ids := make([]ent.Value, 0, len(m.wxs))
  10930. for id := range m.wxs {
  10931. ids = append(ids, id)
  10932. }
  10933. return ids
  10934. }
  10935. return nil
  10936. }
  10937. // RemovedEdges returns all edge names that were removed in this mutation.
  10938. func (m *ServerMutation) RemovedEdges() []string {
  10939. edges := make([]string, 0, 1)
  10940. if m.removedwxs != nil {
  10941. edges = append(edges, server.EdgeWxs)
  10942. }
  10943. return edges
  10944. }
  10945. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10946. // the given name in this mutation.
  10947. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  10948. switch name {
  10949. case server.EdgeWxs:
  10950. ids := make([]ent.Value, 0, len(m.removedwxs))
  10951. for id := range m.removedwxs {
  10952. ids = append(ids, id)
  10953. }
  10954. return ids
  10955. }
  10956. return nil
  10957. }
  10958. // ClearedEdges returns all edge names that were cleared in this mutation.
  10959. func (m *ServerMutation) ClearedEdges() []string {
  10960. edges := make([]string, 0, 1)
  10961. if m.clearedwxs {
  10962. edges = append(edges, server.EdgeWxs)
  10963. }
  10964. return edges
  10965. }
  10966. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10967. // was cleared in this mutation.
  10968. func (m *ServerMutation) EdgeCleared(name string) bool {
  10969. switch name {
  10970. case server.EdgeWxs:
  10971. return m.clearedwxs
  10972. }
  10973. return false
  10974. }
  10975. // ClearEdge clears the value of the edge with the given name. It returns an error
  10976. // if that edge is not defined in the schema.
  10977. func (m *ServerMutation) ClearEdge(name string) error {
  10978. switch name {
  10979. }
  10980. return fmt.Errorf("unknown Server unique edge %s", name)
  10981. }
  10982. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10983. // It returns an error if the edge is not defined in the schema.
  10984. func (m *ServerMutation) ResetEdge(name string) error {
  10985. switch name {
  10986. case server.EdgeWxs:
  10987. m.ResetWxs()
  10988. return nil
  10989. }
  10990. return fmt.Errorf("unknown Server edge %s", name)
  10991. }
  10992. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  10993. type SopNodeMutation struct {
  10994. config
  10995. op Op
  10996. typ string
  10997. id *uint64
  10998. created_at *time.Time
  10999. updated_at *time.Time
  11000. status *uint8
  11001. addstatus *int8
  11002. deleted_at *time.Time
  11003. parent_id *uint64
  11004. addparent_id *int64
  11005. name *string
  11006. condition_type *int
  11007. addcondition_type *int
  11008. condition_list *[]string
  11009. appendcondition_list []string
  11010. no_reply_condition *uint64
  11011. addno_reply_condition *int64
  11012. action_message *[]custom_types.Action
  11013. appendaction_message []custom_types.Action
  11014. action_label *[]uint64
  11015. appendaction_label []uint64
  11016. clearedFields map[string]struct{}
  11017. sop_stage *uint64
  11018. clearedsop_stage bool
  11019. node_messages map[uint64]struct{}
  11020. removednode_messages map[uint64]struct{}
  11021. clearednode_messages bool
  11022. done bool
  11023. oldValue func(context.Context) (*SopNode, error)
  11024. predicates []predicate.SopNode
  11025. }
  11026. var _ ent.Mutation = (*SopNodeMutation)(nil)
  11027. // sopnodeOption allows management of the mutation configuration using functional options.
  11028. type sopnodeOption func(*SopNodeMutation)
  11029. // newSopNodeMutation creates new mutation for the SopNode entity.
  11030. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  11031. m := &SopNodeMutation{
  11032. config: c,
  11033. op: op,
  11034. typ: TypeSopNode,
  11035. clearedFields: make(map[string]struct{}),
  11036. }
  11037. for _, opt := range opts {
  11038. opt(m)
  11039. }
  11040. return m
  11041. }
  11042. // withSopNodeID sets the ID field of the mutation.
  11043. func withSopNodeID(id uint64) sopnodeOption {
  11044. return func(m *SopNodeMutation) {
  11045. var (
  11046. err error
  11047. once sync.Once
  11048. value *SopNode
  11049. )
  11050. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  11051. once.Do(func() {
  11052. if m.done {
  11053. err = errors.New("querying old values post mutation is not allowed")
  11054. } else {
  11055. value, err = m.Client().SopNode.Get(ctx, id)
  11056. }
  11057. })
  11058. return value, err
  11059. }
  11060. m.id = &id
  11061. }
  11062. }
  11063. // withSopNode sets the old SopNode of the mutation.
  11064. func withSopNode(node *SopNode) sopnodeOption {
  11065. return func(m *SopNodeMutation) {
  11066. m.oldValue = func(context.Context) (*SopNode, error) {
  11067. return node, nil
  11068. }
  11069. m.id = &node.ID
  11070. }
  11071. }
  11072. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11073. // executed in a transaction (ent.Tx), a transactional client is returned.
  11074. func (m SopNodeMutation) Client() *Client {
  11075. client := &Client{config: m.config}
  11076. client.init()
  11077. return client
  11078. }
  11079. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11080. // it returns an error otherwise.
  11081. func (m SopNodeMutation) Tx() (*Tx, error) {
  11082. if _, ok := m.driver.(*txDriver); !ok {
  11083. return nil, errors.New("ent: mutation is not running in a transaction")
  11084. }
  11085. tx := &Tx{config: m.config}
  11086. tx.init()
  11087. return tx, nil
  11088. }
  11089. // SetID sets the value of the id field. Note that this
  11090. // operation is only accepted on creation of SopNode entities.
  11091. func (m *SopNodeMutation) SetID(id uint64) {
  11092. m.id = &id
  11093. }
  11094. // ID returns the ID value in the mutation. Note that the ID is only available
  11095. // if it was provided to the builder or after it was returned from the database.
  11096. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  11097. if m.id == nil {
  11098. return
  11099. }
  11100. return *m.id, true
  11101. }
  11102. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11103. // That means, if the mutation is applied within a transaction with an isolation level such
  11104. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11105. // or updated by the mutation.
  11106. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  11107. switch {
  11108. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11109. id, exists := m.ID()
  11110. if exists {
  11111. return []uint64{id}, nil
  11112. }
  11113. fallthrough
  11114. case m.op.Is(OpUpdate | OpDelete):
  11115. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  11116. default:
  11117. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11118. }
  11119. }
  11120. // SetCreatedAt sets the "created_at" field.
  11121. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  11122. m.created_at = &t
  11123. }
  11124. // CreatedAt returns the value of the "created_at" field in the mutation.
  11125. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  11126. v := m.created_at
  11127. if v == nil {
  11128. return
  11129. }
  11130. return *v, true
  11131. }
  11132. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  11133. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11135. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11136. if !m.op.Is(OpUpdateOne) {
  11137. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11138. }
  11139. if m.id == nil || m.oldValue == nil {
  11140. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11141. }
  11142. oldValue, err := m.oldValue(ctx)
  11143. if err != nil {
  11144. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11145. }
  11146. return oldValue.CreatedAt, nil
  11147. }
  11148. // ResetCreatedAt resets all changes to the "created_at" field.
  11149. func (m *SopNodeMutation) ResetCreatedAt() {
  11150. m.created_at = nil
  11151. }
  11152. // SetUpdatedAt sets the "updated_at" field.
  11153. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  11154. m.updated_at = &t
  11155. }
  11156. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11157. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  11158. v := m.updated_at
  11159. if v == nil {
  11160. return
  11161. }
  11162. return *v, true
  11163. }
  11164. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  11165. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11167. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11168. if !m.op.Is(OpUpdateOne) {
  11169. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11170. }
  11171. if m.id == nil || m.oldValue == nil {
  11172. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11173. }
  11174. oldValue, err := m.oldValue(ctx)
  11175. if err != nil {
  11176. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11177. }
  11178. return oldValue.UpdatedAt, nil
  11179. }
  11180. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11181. func (m *SopNodeMutation) ResetUpdatedAt() {
  11182. m.updated_at = nil
  11183. }
  11184. // SetStatus sets the "status" field.
  11185. func (m *SopNodeMutation) SetStatus(u uint8) {
  11186. m.status = &u
  11187. m.addstatus = nil
  11188. }
  11189. // Status returns the value of the "status" field in the mutation.
  11190. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  11191. v := m.status
  11192. if v == nil {
  11193. return
  11194. }
  11195. return *v, true
  11196. }
  11197. // OldStatus returns the old "status" field's value of the SopNode entity.
  11198. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11200. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11201. if !m.op.Is(OpUpdateOne) {
  11202. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11203. }
  11204. if m.id == nil || m.oldValue == nil {
  11205. return v, errors.New("OldStatus requires an ID field in the mutation")
  11206. }
  11207. oldValue, err := m.oldValue(ctx)
  11208. if err != nil {
  11209. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11210. }
  11211. return oldValue.Status, nil
  11212. }
  11213. // AddStatus adds u to the "status" field.
  11214. func (m *SopNodeMutation) AddStatus(u int8) {
  11215. if m.addstatus != nil {
  11216. *m.addstatus += u
  11217. } else {
  11218. m.addstatus = &u
  11219. }
  11220. }
  11221. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11222. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  11223. v := m.addstatus
  11224. if v == nil {
  11225. return
  11226. }
  11227. return *v, true
  11228. }
  11229. // ClearStatus clears the value of the "status" field.
  11230. func (m *SopNodeMutation) ClearStatus() {
  11231. m.status = nil
  11232. m.addstatus = nil
  11233. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  11234. }
  11235. // StatusCleared returns if the "status" field was cleared in this mutation.
  11236. func (m *SopNodeMutation) StatusCleared() bool {
  11237. _, ok := m.clearedFields[sopnode.FieldStatus]
  11238. return ok
  11239. }
  11240. // ResetStatus resets all changes to the "status" field.
  11241. func (m *SopNodeMutation) ResetStatus() {
  11242. m.status = nil
  11243. m.addstatus = nil
  11244. delete(m.clearedFields, sopnode.FieldStatus)
  11245. }
  11246. // SetDeletedAt sets the "deleted_at" field.
  11247. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  11248. m.deleted_at = &t
  11249. }
  11250. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11251. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  11252. v := m.deleted_at
  11253. if v == nil {
  11254. return
  11255. }
  11256. return *v, true
  11257. }
  11258. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  11259. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11261. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11262. if !m.op.Is(OpUpdateOne) {
  11263. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11264. }
  11265. if m.id == nil || m.oldValue == nil {
  11266. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11267. }
  11268. oldValue, err := m.oldValue(ctx)
  11269. if err != nil {
  11270. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11271. }
  11272. return oldValue.DeletedAt, nil
  11273. }
  11274. // ClearDeletedAt clears the value of the "deleted_at" field.
  11275. func (m *SopNodeMutation) ClearDeletedAt() {
  11276. m.deleted_at = nil
  11277. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  11278. }
  11279. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11280. func (m *SopNodeMutation) DeletedAtCleared() bool {
  11281. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  11282. return ok
  11283. }
  11284. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11285. func (m *SopNodeMutation) ResetDeletedAt() {
  11286. m.deleted_at = nil
  11287. delete(m.clearedFields, sopnode.FieldDeletedAt)
  11288. }
  11289. // SetStageID sets the "stage_id" field.
  11290. func (m *SopNodeMutation) SetStageID(u uint64) {
  11291. m.sop_stage = &u
  11292. }
  11293. // StageID returns the value of the "stage_id" field in the mutation.
  11294. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  11295. v := m.sop_stage
  11296. if v == nil {
  11297. return
  11298. }
  11299. return *v, true
  11300. }
  11301. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  11302. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11304. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  11305. if !m.op.Is(OpUpdateOne) {
  11306. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  11307. }
  11308. if m.id == nil || m.oldValue == nil {
  11309. return v, errors.New("OldStageID requires an ID field in the mutation")
  11310. }
  11311. oldValue, err := m.oldValue(ctx)
  11312. if err != nil {
  11313. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  11314. }
  11315. return oldValue.StageID, nil
  11316. }
  11317. // ResetStageID resets all changes to the "stage_id" field.
  11318. func (m *SopNodeMutation) ResetStageID() {
  11319. m.sop_stage = nil
  11320. }
  11321. // SetParentID sets the "parent_id" field.
  11322. func (m *SopNodeMutation) SetParentID(u uint64) {
  11323. m.parent_id = &u
  11324. m.addparent_id = nil
  11325. }
  11326. // ParentID returns the value of the "parent_id" field in the mutation.
  11327. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  11328. v := m.parent_id
  11329. if v == nil {
  11330. return
  11331. }
  11332. return *v, true
  11333. }
  11334. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  11335. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11337. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  11338. if !m.op.Is(OpUpdateOne) {
  11339. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  11340. }
  11341. if m.id == nil || m.oldValue == nil {
  11342. return v, errors.New("OldParentID requires an ID field in the mutation")
  11343. }
  11344. oldValue, err := m.oldValue(ctx)
  11345. if err != nil {
  11346. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  11347. }
  11348. return oldValue.ParentID, nil
  11349. }
  11350. // AddParentID adds u to the "parent_id" field.
  11351. func (m *SopNodeMutation) AddParentID(u int64) {
  11352. if m.addparent_id != nil {
  11353. *m.addparent_id += u
  11354. } else {
  11355. m.addparent_id = &u
  11356. }
  11357. }
  11358. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  11359. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  11360. v := m.addparent_id
  11361. if v == nil {
  11362. return
  11363. }
  11364. return *v, true
  11365. }
  11366. // ResetParentID resets all changes to the "parent_id" field.
  11367. func (m *SopNodeMutation) ResetParentID() {
  11368. m.parent_id = nil
  11369. m.addparent_id = nil
  11370. }
  11371. // SetName sets the "name" field.
  11372. func (m *SopNodeMutation) SetName(s string) {
  11373. m.name = &s
  11374. }
  11375. // Name returns the value of the "name" field in the mutation.
  11376. func (m *SopNodeMutation) Name() (r string, exists bool) {
  11377. v := m.name
  11378. if v == nil {
  11379. return
  11380. }
  11381. return *v, true
  11382. }
  11383. // OldName returns the old "name" field's value of the SopNode entity.
  11384. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11386. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  11387. if !m.op.Is(OpUpdateOne) {
  11388. return v, errors.New("OldName is only allowed on UpdateOne operations")
  11389. }
  11390. if m.id == nil || m.oldValue == nil {
  11391. return v, errors.New("OldName requires an ID field in the mutation")
  11392. }
  11393. oldValue, err := m.oldValue(ctx)
  11394. if err != nil {
  11395. return v, fmt.Errorf("querying old value for OldName: %w", err)
  11396. }
  11397. return oldValue.Name, nil
  11398. }
  11399. // ResetName resets all changes to the "name" field.
  11400. func (m *SopNodeMutation) ResetName() {
  11401. m.name = nil
  11402. }
  11403. // SetConditionType sets the "condition_type" field.
  11404. func (m *SopNodeMutation) SetConditionType(i int) {
  11405. m.condition_type = &i
  11406. m.addcondition_type = nil
  11407. }
  11408. // ConditionType returns the value of the "condition_type" field in the mutation.
  11409. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  11410. v := m.condition_type
  11411. if v == nil {
  11412. return
  11413. }
  11414. return *v, true
  11415. }
  11416. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  11417. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11419. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  11420. if !m.op.Is(OpUpdateOne) {
  11421. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  11422. }
  11423. if m.id == nil || m.oldValue == nil {
  11424. return v, errors.New("OldConditionType requires an ID field in the mutation")
  11425. }
  11426. oldValue, err := m.oldValue(ctx)
  11427. if err != nil {
  11428. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  11429. }
  11430. return oldValue.ConditionType, nil
  11431. }
  11432. // AddConditionType adds i to the "condition_type" field.
  11433. func (m *SopNodeMutation) AddConditionType(i int) {
  11434. if m.addcondition_type != nil {
  11435. *m.addcondition_type += i
  11436. } else {
  11437. m.addcondition_type = &i
  11438. }
  11439. }
  11440. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  11441. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  11442. v := m.addcondition_type
  11443. if v == nil {
  11444. return
  11445. }
  11446. return *v, true
  11447. }
  11448. // ResetConditionType resets all changes to the "condition_type" field.
  11449. func (m *SopNodeMutation) ResetConditionType() {
  11450. m.condition_type = nil
  11451. m.addcondition_type = nil
  11452. }
  11453. // SetConditionList sets the "condition_list" field.
  11454. func (m *SopNodeMutation) SetConditionList(s []string) {
  11455. m.condition_list = &s
  11456. m.appendcondition_list = nil
  11457. }
  11458. // ConditionList returns the value of the "condition_list" field in the mutation.
  11459. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  11460. v := m.condition_list
  11461. if v == nil {
  11462. return
  11463. }
  11464. return *v, true
  11465. }
  11466. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  11467. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11469. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  11470. if !m.op.Is(OpUpdateOne) {
  11471. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  11472. }
  11473. if m.id == nil || m.oldValue == nil {
  11474. return v, errors.New("OldConditionList requires an ID field in the mutation")
  11475. }
  11476. oldValue, err := m.oldValue(ctx)
  11477. if err != nil {
  11478. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  11479. }
  11480. return oldValue.ConditionList, nil
  11481. }
  11482. // AppendConditionList adds s to the "condition_list" field.
  11483. func (m *SopNodeMutation) AppendConditionList(s []string) {
  11484. m.appendcondition_list = append(m.appendcondition_list, s...)
  11485. }
  11486. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  11487. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  11488. if len(m.appendcondition_list) == 0 {
  11489. return nil, false
  11490. }
  11491. return m.appendcondition_list, true
  11492. }
  11493. // ClearConditionList clears the value of the "condition_list" field.
  11494. func (m *SopNodeMutation) ClearConditionList() {
  11495. m.condition_list = nil
  11496. m.appendcondition_list = nil
  11497. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  11498. }
  11499. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  11500. func (m *SopNodeMutation) ConditionListCleared() bool {
  11501. _, ok := m.clearedFields[sopnode.FieldConditionList]
  11502. return ok
  11503. }
  11504. // ResetConditionList resets all changes to the "condition_list" field.
  11505. func (m *SopNodeMutation) ResetConditionList() {
  11506. m.condition_list = nil
  11507. m.appendcondition_list = nil
  11508. delete(m.clearedFields, sopnode.FieldConditionList)
  11509. }
  11510. // SetNoReplyCondition sets the "no_reply_condition" field.
  11511. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  11512. m.no_reply_condition = &u
  11513. m.addno_reply_condition = nil
  11514. }
  11515. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  11516. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  11517. v := m.no_reply_condition
  11518. if v == nil {
  11519. return
  11520. }
  11521. return *v, true
  11522. }
  11523. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  11524. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11526. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  11527. if !m.op.Is(OpUpdateOne) {
  11528. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  11529. }
  11530. if m.id == nil || m.oldValue == nil {
  11531. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  11532. }
  11533. oldValue, err := m.oldValue(ctx)
  11534. if err != nil {
  11535. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  11536. }
  11537. return oldValue.NoReplyCondition, nil
  11538. }
  11539. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  11540. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  11541. if m.addno_reply_condition != nil {
  11542. *m.addno_reply_condition += u
  11543. } else {
  11544. m.addno_reply_condition = &u
  11545. }
  11546. }
  11547. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  11548. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  11549. v := m.addno_reply_condition
  11550. if v == nil {
  11551. return
  11552. }
  11553. return *v, true
  11554. }
  11555. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  11556. func (m *SopNodeMutation) ResetNoReplyCondition() {
  11557. m.no_reply_condition = nil
  11558. m.addno_reply_condition = nil
  11559. }
  11560. // SetActionMessage sets the "action_message" field.
  11561. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  11562. m.action_message = &ct
  11563. m.appendaction_message = nil
  11564. }
  11565. // ActionMessage returns the value of the "action_message" field in the mutation.
  11566. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  11567. v := m.action_message
  11568. if v == nil {
  11569. return
  11570. }
  11571. return *v, true
  11572. }
  11573. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  11574. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11576. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  11577. if !m.op.Is(OpUpdateOne) {
  11578. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  11579. }
  11580. if m.id == nil || m.oldValue == nil {
  11581. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  11582. }
  11583. oldValue, err := m.oldValue(ctx)
  11584. if err != nil {
  11585. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  11586. }
  11587. return oldValue.ActionMessage, nil
  11588. }
  11589. // AppendActionMessage adds ct to the "action_message" field.
  11590. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  11591. m.appendaction_message = append(m.appendaction_message, ct...)
  11592. }
  11593. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  11594. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  11595. if len(m.appendaction_message) == 0 {
  11596. return nil, false
  11597. }
  11598. return m.appendaction_message, true
  11599. }
  11600. // ClearActionMessage clears the value of the "action_message" field.
  11601. func (m *SopNodeMutation) ClearActionMessage() {
  11602. m.action_message = nil
  11603. m.appendaction_message = nil
  11604. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  11605. }
  11606. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  11607. func (m *SopNodeMutation) ActionMessageCleared() bool {
  11608. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  11609. return ok
  11610. }
  11611. // ResetActionMessage resets all changes to the "action_message" field.
  11612. func (m *SopNodeMutation) ResetActionMessage() {
  11613. m.action_message = nil
  11614. m.appendaction_message = nil
  11615. delete(m.clearedFields, sopnode.FieldActionMessage)
  11616. }
  11617. // SetActionLabel sets the "action_label" field.
  11618. func (m *SopNodeMutation) SetActionLabel(u []uint64) {
  11619. m.action_label = &u
  11620. m.appendaction_label = nil
  11621. }
  11622. // ActionLabel returns the value of the "action_label" field in the mutation.
  11623. func (m *SopNodeMutation) ActionLabel() (r []uint64, exists bool) {
  11624. v := m.action_label
  11625. if v == nil {
  11626. return
  11627. }
  11628. return *v, true
  11629. }
  11630. // OldActionLabel returns the old "action_label" field's value of the SopNode entity.
  11631. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11633. func (m *SopNodeMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  11634. if !m.op.Is(OpUpdateOne) {
  11635. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  11636. }
  11637. if m.id == nil || m.oldValue == nil {
  11638. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  11639. }
  11640. oldValue, err := m.oldValue(ctx)
  11641. if err != nil {
  11642. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  11643. }
  11644. return oldValue.ActionLabel, nil
  11645. }
  11646. // AppendActionLabel adds u to the "action_label" field.
  11647. func (m *SopNodeMutation) AppendActionLabel(u []uint64) {
  11648. m.appendaction_label = append(m.appendaction_label, u...)
  11649. }
  11650. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  11651. func (m *SopNodeMutation) AppendedActionLabel() ([]uint64, bool) {
  11652. if len(m.appendaction_label) == 0 {
  11653. return nil, false
  11654. }
  11655. return m.appendaction_label, true
  11656. }
  11657. // ClearActionLabel clears the value of the "action_label" field.
  11658. func (m *SopNodeMutation) ClearActionLabel() {
  11659. m.action_label = nil
  11660. m.appendaction_label = nil
  11661. m.clearedFields[sopnode.FieldActionLabel] = struct{}{}
  11662. }
  11663. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  11664. func (m *SopNodeMutation) ActionLabelCleared() bool {
  11665. _, ok := m.clearedFields[sopnode.FieldActionLabel]
  11666. return ok
  11667. }
  11668. // ResetActionLabel resets all changes to the "action_label" field.
  11669. func (m *SopNodeMutation) ResetActionLabel() {
  11670. m.action_label = nil
  11671. m.appendaction_label = nil
  11672. delete(m.clearedFields, sopnode.FieldActionLabel)
  11673. }
  11674. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  11675. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  11676. m.sop_stage = &id
  11677. }
  11678. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  11679. func (m *SopNodeMutation) ClearSopStage() {
  11680. m.clearedsop_stage = true
  11681. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  11682. }
  11683. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  11684. func (m *SopNodeMutation) SopStageCleared() bool {
  11685. return m.clearedsop_stage
  11686. }
  11687. // SopStageID returns the "sop_stage" edge ID in the mutation.
  11688. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  11689. if m.sop_stage != nil {
  11690. return *m.sop_stage, true
  11691. }
  11692. return
  11693. }
  11694. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  11695. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  11696. // SopStageID instead. It exists only for internal usage by the builders.
  11697. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  11698. if id := m.sop_stage; id != nil {
  11699. ids = append(ids, *id)
  11700. }
  11701. return
  11702. }
  11703. // ResetSopStage resets all changes to the "sop_stage" edge.
  11704. func (m *SopNodeMutation) ResetSopStage() {
  11705. m.sop_stage = nil
  11706. m.clearedsop_stage = false
  11707. }
  11708. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  11709. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  11710. if m.node_messages == nil {
  11711. m.node_messages = make(map[uint64]struct{})
  11712. }
  11713. for i := range ids {
  11714. m.node_messages[ids[i]] = struct{}{}
  11715. }
  11716. }
  11717. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  11718. func (m *SopNodeMutation) ClearNodeMessages() {
  11719. m.clearednode_messages = true
  11720. }
  11721. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  11722. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  11723. return m.clearednode_messages
  11724. }
  11725. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  11726. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  11727. if m.removednode_messages == nil {
  11728. m.removednode_messages = make(map[uint64]struct{})
  11729. }
  11730. for i := range ids {
  11731. delete(m.node_messages, ids[i])
  11732. m.removednode_messages[ids[i]] = struct{}{}
  11733. }
  11734. }
  11735. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  11736. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  11737. for id := range m.removednode_messages {
  11738. ids = append(ids, id)
  11739. }
  11740. return
  11741. }
  11742. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  11743. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  11744. for id := range m.node_messages {
  11745. ids = append(ids, id)
  11746. }
  11747. return
  11748. }
  11749. // ResetNodeMessages resets all changes to the "node_messages" edge.
  11750. func (m *SopNodeMutation) ResetNodeMessages() {
  11751. m.node_messages = nil
  11752. m.clearednode_messages = false
  11753. m.removednode_messages = nil
  11754. }
  11755. // Where appends a list predicates to the SopNodeMutation builder.
  11756. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  11757. m.predicates = append(m.predicates, ps...)
  11758. }
  11759. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  11760. // users can use type-assertion to append predicates that do not depend on any generated package.
  11761. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  11762. p := make([]predicate.SopNode, len(ps))
  11763. for i := range ps {
  11764. p[i] = ps[i]
  11765. }
  11766. m.Where(p...)
  11767. }
  11768. // Op returns the operation name.
  11769. func (m *SopNodeMutation) Op() Op {
  11770. return m.op
  11771. }
  11772. // SetOp allows setting the mutation operation.
  11773. func (m *SopNodeMutation) SetOp(op Op) {
  11774. m.op = op
  11775. }
  11776. // Type returns the node type of this mutation (SopNode).
  11777. func (m *SopNodeMutation) Type() string {
  11778. return m.typ
  11779. }
  11780. // Fields returns all fields that were changed during this mutation. Note that in
  11781. // order to get all numeric fields that were incremented/decremented, call
  11782. // AddedFields().
  11783. func (m *SopNodeMutation) Fields() []string {
  11784. fields := make([]string, 0, 12)
  11785. if m.created_at != nil {
  11786. fields = append(fields, sopnode.FieldCreatedAt)
  11787. }
  11788. if m.updated_at != nil {
  11789. fields = append(fields, sopnode.FieldUpdatedAt)
  11790. }
  11791. if m.status != nil {
  11792. fields = append(fields, sopnode.FieldStatus)
  11793. }
  11794. if m.deleted_at != nil {
  11795. fields = append(fields, sopnode.FieldDeletedAt)
  11796. }
  11797. if m.sop_stage != nil {
  11798. fields = append(fields, sopnode.FieldStageID)
  11799. }
  11800. if m.parent_id != nil {
  11801. fields = append(fields, sopnode.FieldParentID)
  11802. }
  11803. if m.name != nil {
  11804. fields = append(fields, sopnode.FieldName)
  11805. }
  11806. if m.condition_type != nil {
  11807. fields = append(fields, sopnode.FieldConditionType)
  11808. }
  11809. if m.condition_list != nil {
  11810. fields = append(fields, sopnode.FieldConditionList)
  11811. }
  11812. if m.no_reply_condition != nil {
  11813. fields = append(fields, sopnode.FieldNoReplyCondition)
  11814. }
  11815. if m.action_message != nil {
  11816. fields = append(fields, sopnode.FieldActionMessage)
  11817. }
  11818. if m.action_label != nil {
  11819. fields = append(fields, sopnode.FieldActionLabel)
  11820. }
  11821. return fields
  11822. }
  11823. // Field returns the value of a field with the given name. The second boolean
  11824. // return value indicates that this field was not set, or was not defined in the
  11825. // schema.
  11826. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  11827. switch name {
  11828. case sopnode.FieldCreatedAt:
  11829. return m.CreatedAt()
  11830. case sopnode.FieldUpdatedAt:
  11831. return m.UpdatedAt()
  11832. case sopnode.FieldStatus:
  11833. return m.Status()
  11834. case sopnode.FieldDeletedAt:
  11835. return m.DeletedAt()
  11836. case sopnode.FieldStageID:
  11837. return m.StageID()
  11838. case sopnode.FieldParentID:
  11839. return m.ParentID()
  11840. case sopnode.FieldName:
  11841. return m.Name()
  11842. case sopnode.FieldConditionType:
  11843. return m.ConditionType()
  11844. case sopnode.FieldConditionList:
  11845. return m.ConditionList()
  11846. case sopnode.FieldNoReplyCondition:
  11847. return m.NoReplyCondition()
  11848. case sopnode.FieldActionMessage:
  11849. return m.ActionMessage()
  11850. case sopnode.FieldActionLabel:
  11851. return m.ActionLabel()
  11852. }
  11853. return nil, false
  11854. }
  11855. // OldField returns the old value of the field from the database. An error is
  11856. // returned if the mutation operation is not UpdateOne, or the query to the
  11857. // database failed.
  11858. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11859. switch name {
  11860. case sopnode.FieldCreatedAt:
  11861. return m.OldCreatedAt(ctx)
  11862. case sopnode.FieldUpdatedAt:
  11863. return m.OldUpdatedAt(ctx)
  11864. case sopnode.FieldStatus:
  11865. return m.OldStatus(ctx)
  11866. case sopnode.FieldDeletedAt:
  11867. return m.OldDeletedAt(ctx)
  11868. case sopnode.FieldStageID:
  11869. return m.OldStageID(ctx)
  11870. case sopnode.FieldParentID:
  11871. return m.OldParentID(ctx)
  11872. case sopnode.FieldName:
  11873. return m.OldName(ctx)
  11874. case sopnode.FieldConditionType:
  11875. return m.OldConditionType(ctx)
  11876. case sopnode.FieldConditionList:
  11877. return m.OldConditionList(ctx)
  11878. case sopnode.FieldNoReplyCondition:
  11879. return m.OldNoReplyCondition(ctx)
  11880. case sopnode.FieldActionMessage:
  11881. return m.OldActionMessage(ctx)
  11882. case sopnode.FieldActionLabel:
  11883. return m.OldActionLabel(ctx)
  11884. }
  11885. return nil, fmt.Errorf("unknown SopNode field %s", name)
  11886. }
  11887. // SetField sets the value of a field with the given name. It returns an error if
  11888. // the field is not defined in the schema, or if the type mismatched the field
  11889. // type.
  11890. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  11891. switch name {
  11892. case sopnode.FieldCreatedAt:
  11893. v, ok := value.(time.Time)
  11894. if !ok {
  11895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11896. }
  11897. m.SetCreatedAt(v)
  11898. return nil
  11899. case sopnode.FieldUpdatedAt:
  11900. v, ok := value.(time.Time)
  11901. if !ok {
  11902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11903. }
  11904. m.SetUpdatedAt(v)
  11905. return nil
  11906. case sopnode.FieldStatus:
  11907. v, ok := value.(uint8)
  11908. if !ok {
  11909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11910. }
  11911. m.SetStatus(v)
  11912. return nil
  11913. case sopnode.FieldDeletedAt:
  11914. v, ok := value.(time.Time)
  11915. if !ok {
  11916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11917. }
  11918. m.SetDeletedAt(v)
  11919. return nil
  11920. case sopnode.FieldStageID:
  11921. v, ok := value.(uint64)
  11922. if !ok {
  11923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11924. }
  11925. m.SetStageID(v)
  11926. return nil
  11927. case sopnode.FieldParentID:
  11928. v, ok := value.(uint64)
  11929. if !ok {
  11930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11931. }
  11932. m.SetParentID(v)
  11933. return nil
  11934. case sopnode.FieldName:
  11935. v, ok := value.(string)
  11936. if !ok {
  11937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11938. }
  11939. m.SetName(v)
  11940. return nil
  11941. case sopnode.FieldConditionType:
  11942. v, ok := value.(int)
  11943. if !ok {
  11944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11945. }
  11946. m.SetConditionType(v)
  11947. return nil
  11948. case sopnode.FieldConditionList:
  11949. v, ok := value.([]string)
  11950. if !ok {
  11951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11952. }
  11953. m.SetConditionList(v)
  11954. return nil
  11955. case sopnode.FieldNoReplyCondition:
  11956. v, ok := value.(uint64)
  11957. if !ok {
  11958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11959. }
  11960. m.SetNoReplyCondition(v)
  11961. return nil
  11962. case sopnode.FieldActionMessage:
  11963. v, ok := value.([]custom_types.Action)
  11964. if !ok {
  11965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11966. }
  11967. m.SetActionMessage(v)
  11968. return nil
  11969. case sopnode.FieldActionLabel:
  11970. v, ok := value.([]uint64)
  11971. if !ok {
  11972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11973. }
  11974. m.SetActionLabel(v)
  11975. return nil
  11976. }
  11977. return fmt.Errorf("unknown SopNode field %s", name)
  11978. }
  11979. // AddedFields returns all numeric fields that were incremented/decremented during
  11980. // this mutation.
  11981. func (m *SopNodeMutation) AddedFields() []string {
  11982. var fields []string
  11983. if m.addstatus != nil {
  11984. fields = append(fields, sopnode.FieldStatus)
  11985. }
  11986. if m.addparent_id != nil {
  11987. fields = append(fields, sopnode.FieldParentID)
  11988. }
  11989. if m.addcondition_type != nil {
  11990. fields = append(fields, sopnode.FieldConditionType)
  11991. }
  11992. if m.addno_reply_condition != nil {
  11993. fields = append(fields, sopnode.FieldNoReplyCondition)
  11994. }
  11995. return fields
  11996. }
  11997. // AddedField returns the numeric value that was incremented/decremented on a field
  11998. // with the given name. The second boolean return value indicates that this field
  11999. // was not set, or was not defined in the schema.
  12000. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  12001. switch name {
  12002. case sopnode.FieldStatus:
  12003. return m.AddedStatus()
  12004. case sopnode.FieldParentID:
  12005. return m.AddedParentID()
  12006. case sopnode.FieldConditionType:
  12007. return m.AddedConditionType()
  12008. case sopnode.FieldNoReplyCondition:
  12009. return m.AddedNoReplyCondition()
  12010. }
  12011. return nil, false
  12012. }
  12013. // AddField adds the value to the field with the given name. It returns an error if
  12014. // the field is not defined in the schema, or if the type mismatched the field
  12015. // type.
  12016. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  12017. switch name {
  12018. case sopnode.FieldStatus:
  12019. v, ok := value.(int8)
  12020. if !ok {
  12021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12022. }
  12023. m.AddStatus(v)
  12024. return nil
  12025. case sopnode.FieldParentID:
  12026. v, ok := value.(int64)
  12027. if !ok {
  12028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12029. }
  12030. m.AddParentID(v)
  12031. return nil
  12032. case sopnode.FieldConditionType:
  12033. v, ok := value.(int)
  12034. if !ok {
  12035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12036. }
  12037. m.AddConditionType(v)
  12038. return nil
  12039. case sopnode.FieldNoReplyCondition:
  12040. v, ok := value.(int64)
  12041. if !ok {
  12042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12043. }
  12044. m.AddNoReplyCondition(v)
  12045. return nil
  12046. }
  12047. return fmt.Errorf("unknown SopNode numeric field %s", name)
  12048. }
  12049. // ClearedFields returns all nullable fields that were cleared during this
  12050. // mutation.
  12051. func (m *SopNodeMutation) ClearedFields() []string {
  12052. var fields []string
  12053. if m.FieldCleared(sopnode.FieldStatus) {
  12054. fields = append(fields, sopnode.FieldStatus)
  12055. }
  12056. if m.FieldCleared(sopnode.FieldDeletedAt) {
  12057. fields = append(fields, sopnode.FieldDeletedAt)
  12058. }
  12059. if m.FieldCleared(sopnode.FieldConditionList) {
  12060. fields = append(fields, sopnode.FieldConditionList)
  12061. }
  12062. if m.FieldCleared(sopnode.FieldActionMessage) {
  12063. fields = append(fields, sopnode.FieldActionMessage)
  12064. }
  12065. if m.FieldCleared(sopnode.FieldActionLabel) {
  12066. fields = append(fields, sopnode.FieldActionLabel)
  12067. }
  12068. return fields
  12069. }
  12070. // FieldCleared returns a boolean indicating if a field with the given name was
  12071. // cleared in this mutation.
  12072. func (m *SopNodeMutation) FieldCleared(name string) bool {
  12073. _, ok := m.clearedFields[name]
  12074. return ok
  12075. }
  12076. // ClearField clears the value of the field with the given name. It returns an
  12077. // error if the field is not defined in the schema.
  12078. func (m *SopNodeMutation) ClearField(name string) error {
  12079. switch name {
  12080. case sopnode.FieldStatus:
  12081. m.ClearStatus()
  12082. return nil
  12083. case sopnode.FieldDeletedAt:
  12084. m.ClearDeletedAt()
  12085. return nil
  12086. case sopnode.FieldConditionList:
  12087. m.ClearConditionList()
  12088. return nil
  12089. case sopnode.FieldActionMessage:
  12090. m.ClearActionMessage()
  12091. return nil
  12092. case sopnode.FieldActionLabel:
  12093. m.ClearActionLabel()
  12094. return nil
  12095. }
  12096. return fmt.Errorf("unknown SopNode nullable field %s", name)
  12097. }
  12098. // ResetField resets all changes in the mutation for the field with the given name.
  12099. // It returns an error if the field is not defined in the schema.
  12100. func (m *SopNodeMutation) ResetField(name string) error {
  12101. switch name {
  12102. case sopnode.FieldCreatedAt:
  12103. m.ResetCreatedAt()
  12104. return nil
  12105. case sopnode.FieldUpdatedAt:
  12106. m.ResetUpdatedAt()
  12107. return nil
  12108. case sopnode.FieldStatus:
  12109. m.ResetStatus()
  12110. return nil
  12111. case sopnode.FieldDeletedAt:
  12112. m.ResetDeletedAt()
  12113. return nil
  12114. case sopnode.FieldStageID:
  12115. m.ResetStageID()
  12116. return nil
  12117. case sopnode.FieldParentID:
  12118. m.ResetParentID()
  12119. return nil
  12120. case sopnode.FieldName:
  12121. m.ResetName()
  12122. return nil
  12123. case sopnode.FieldConditionType:
  12124. m.ResetConditionType()
  12125. return nil
  12126. case sopnode.FieldConditionList:
  12127. m.ResetConditionList()
  12128. return nil
  12129. case sopnode.FieldNoReplyCondition:
  12130. m.ResetNoReplyCondition()
  12131. return nil
  12132. case sopnode.FieldActionMessage:
  12133. m.ResetActionMessage()
  12134. return nil
  12135. case sopnode.FieldActionLabel:
  12136. m.ResetActionLabel()
  12137. return nil
  12138. }
  12139. return fmt.Errorf("unknown SopNode field %s", name)
  12140. }
  12141. // AddedEdges returns all edge names that were set/added in this mutation.
  12142. func (m *SopNodeMutation) AddedEdges() []string {
  12143. edges := make([]string, 0, 2)
  12144. if m.sop_stage != nil {
  12145. edges = append(edges, sopnode.EdgeSopStage)
  12146. }
  12147. if m.node_messages != nil {
  12148. edges = append(edges, sopnode.EdgeNodeMessages)
  12149. }
  12150. return edges
  12151. }
  12152. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12153. // name in this mutation.
  12154. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  12155. switch name {
  12156. case sopnode.EdgeSopStage:
  12157. if id := m.sop_stage; id != nil {
  12158. return []ent.Value{*id}
  12159. }
  12160. case sopnode.EdgeNodeMessages:
  12161. ids := make([]ent.Value, 0, len(m.node_messages))
  12162. for id := range m.node_messages {
  12163. ids = append(ids, id)
  12164. }
  12165. return ids
  12166. }
  12167. return nil
  12168. }
  12169. // RemovedEdges returns all edge names that were removed in this mutation.
  12170. func (m *SopNodeMutation) RemovedEdges() []string {
  12171. edges := make([]string, 0, 2)
  12172. if m.removednode_messages != nil {
  12173. edges = append(edges, sopnode.EdgeNodeMessages)
  12174. }
  12175. return edges
  12176. }
  12177. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12178. // the given name in this mutation.
  12179. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  12180. switch name {
  12181. case sopnode.EdgeNodeMessages:
  12182. ids := make([]ent.Value, 0, len(m.removednode_messages))
  12183. for id := range m.removednode_messages {
  12184. ids = append(ids, id)
  12185. }
  12186. return ids
  12187. }
  12188. return nil
  12189. }
  12190. // ClearedEdges returns all edge names that were cleared in this mutation.
  12191. func (m *SopNodeMutation) ClearedEdges() []string {
  12192. edges := make([]string, 0, 2)
  12193. if m.clearedsop_stage {
  12194. edges = append(edges, sopnode.EdgeSopStage)
  12195. }
  12196. if m.clearednode_messages {
  12197. edges = append(edges, sopnode.EdgeNodeMessages)
  12198. }
  12199. return edges
  12200. }
  12201. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12202. // was cleared in this mutation.
  12203. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  12204. switch name {
  12205. case sopnode.EdgeSopStage:
  12206. return m.clearedsop_stage
  12207. case sopnode.EdgeNodeMessages:
  12208. return m.clearednode_messages
  12209. }
  12210. return false
  12211. }
  12212. // ClearEdge clears the value of the edge with the given name. It returns an error
  12213. // if that edge is not defined in the schema.
  12214. func (m *SopNodeMutation) ClearEdge(name string) error {
  12215. switch name {
  12216. case sopnode.EdgeSopStage:
  12217. m.ClearSopStage()
  12218. return nil
  12219. }
  12220. return fmt.Errorf("unknown SopNode unique edge %s", name)
  12221. }
  12222. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12223. // It returns an error if the edge is not defined in the schema.
  12224. func (m *SopNodeMutation) ResetEdge(name string) error {
  12225. switch name {
  12226. case sopnode.EdgeSopStage:
  12227. m.ResetSopStage()
  12228. return nil
  12229. case sopnode.EdgeNodeMessages:
  12230. m.ResetNodeMessages()
  12231. return nil
  12232. }
  12233. return fmt.Errorf("unknown SopNode edge %s", name)
  12234. }
  12235. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  12236. type SopStageMutation struct {
  12237. config
  12238. op Op
  12239. typ string
  12240. id *uint64
  12241. created_at *time.Time
  12242. updated_at *time.Time
  12243. status *uint8
  12244. addstatus *int8
  12245. deleted_at *time.Time
  12246. name *string
  12247. condition_type *int
  12248. addcondition_type *int
  12249. condition_operator *int
  12250. addcondition_operator *int
  12251. condition_list *[]custom_types.Condition
  12252. appendcondition_list []custom_types.Condition
  12253. action_message *[]custom_types.Action
  12254. appendaction_message []custom_types.Action
  12255. action_label *[]uint64
  12256. appendaction_label []uint64
  12257. index_sort *int
  12258. addindex_sort *int
  12259. clearedFields map[string]struct{}
  12260. sop_task *uint64
  12261. clearedsop_task bool
  12262. stage_nodes map[uint64]struct{}
  12263. removedstage_nodes map[uint64]struct{}
  12264. clearedstage_nodes bool
  12265. stage_messages map[uint64]struct{}
  12266. removedstage_messages map[uint64]struct{}
  12267. clearedstage_messages bool
  12268. done bool
  12269. oldValue func(context.Context) (*SopStage, error)
  12270. predicates []predicate.SopStage
  12271. }
  12272. var _ ent.Mutation = (*SopStageMutation)(nil)
  12273. // sopstageOption allows management of the mutation configuration using functional options.
  12274. type sopstageOption func(*SopStageMutation)
  12275. // newSopStageMutation creates new mutation for the SopStage entity.
  12276. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  12277. m := &SopStageMutation{
  12278. config: c,
  12279. op: op,
  12280. typ: TypeSopStage,
  12281. clearedFields: make(map[string]struct{}),
  12282. }
  12283. for _, opt := range opts {
  12284. opt(m)
  12285. }
  12286. return m
  12287. }
  12288. // withSopStageID sets the ID field of the mutation.
  12289. func withSopStageID(id uint64) sopstageOption {
  12290. return func(m *SopStageMutation) {
  12291. var (
  12292. err error
  12293. once sync.Once
  12294. value *SopStage
  12295. )
  12296. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  12297. once.Do(func() {
  12298. if m.done {
  12299. err = errors.New("querying old values post mutation is not allowed")
  12300. } else {
  12301. value, err = m.Client().SopStage.Get(ctx, id)
  12302. }
  12303. })
  12304. return value, err
  12305. }
  12306. m.id = &id
  12307. }
  12308. }
  12309. // withSopStage sets the old SopStage of the mutation.
  12310. func withSopStage(node *SopStage) sopstageOption {
  12311. return func(m *SopStageMutation) {
  12312. m.oldValue = func(context.Context) (*SopStage, error) {
  12313. return node, nil
  12314. }
  12315. m.id = &node.ID
  12316. }
  12317. }
  12318. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12319. // executed in a transaction (ent.Tx), a transactional client is returned.
  12320. func (m SopStageMutation) Client() *Client {
  12321. client := &Client{config: m.config}
  12322. client.init()
  12323. return client
  12324. }
  12325. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12326. // it returns an error otherwise.
  12327. func (m SopStageMutation) Tx() (*Tx, error) {
  12328. if _, ok := m.driver.(*txDriver); !ok {
  12329. return nil, errors.New("ent: mutation is not running in a transaction")
  12330. }
  12331. tx := &Tx{config: m.config}
  12332. tx.init()
  12333. return tx, nil
  12334. }
  12335. // SetID sets the value of the id field. Note that this
  12336. // operation is only accepted on creation of SopStage entities.
  12337. func (m *SopStageMutation) SetID(id uint64) {
  12338. m.id = &id
  12339. }
  12340. // ID returns the ID value in the mutation. Note that the ID is only available
  12341. // if it was provided to the builder or after it was returned from the database.
  12342. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  12343. if m.id == nil {
  12344. return
  12345. }
  12346. return *m.id, true
  12347. }
  12348. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12349. // That means, if the mutation is applied within a transaction with an isolation level such
  12350. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12351. // or updated by the mutation.
  12352. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  12353. switch {
  12354. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12355. id, exists := m.ID()
  12356. if exists {
  12357. return []uint64{id}, nil
  12358. }
  12359. fallthrough
  12360. case m.op.Is(OpUpdate | OpDelete):
  12361. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  12362. default:
  12363. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12364. }
  12365. }
  12366. // SetCreatedAt sets the "created_at" field.
  12367. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  12368. m.created_at = &t
  12369. }
  12370. // CreatedAt returns the value of the "created_at" field in the mutation.
  12371. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  12372. v := m.created_at
  12373. if v == nil {
  12374. return
  12375. }
  12376. return *v, true
  12377. }
  12378. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  12379. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12381. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12382. if !m.op.Is(OpUpdateOne) {
  12383. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12384. }
  12385. if m.id == nil || m.oldValue == nil {
  12386. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12387. }
  12388. oldValue, err := m.oldValue(ctx)
  12389. if err != nil {
  12390. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12391. }
  12392. return oldValue.CreatedAt, nil
  12393. }
  12394. // ResetCreatedAt resets all changes to the "created_at" field.
  12395. func (m *SopStageMutation) ResetCreatedAt() {
  12396. m.created_at = nil
  12397. }
  12398. // SetUpdatedAt sets the "updated_at" field.
  12399. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  12400. m.updated_at = &t
  12401. }
  12402. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12403. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  12404. v := m.updated_at
  12405. if v == nil {
  12406. return
  12407. }
  12408. return *v, true
  12409. }
  12410. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  12411. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12413. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12414. if !m.op.Is(OpUpdateOne) {
  12415. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12416. }
  12417. if m.id == nil || m.oldValue == nil {
  12418. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12419. }
  12420. oldValue, err := m.oldValue(ctx)
  12421. if err != nil {
  12422. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12423. }
  12424. return oldValue.UpdatedAt, nil
  12425. }
  12426. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12427. func (m *SopStageMutation) ResetUpdatedAt() {
  12428. m.updated_at = nil
  12429. }
  12430. // SetStatus sets the "status" field.
  12431. func (m *SopStageMutation) SetStatus(u uint8) {
  12432. m.status = &u
  12433. m.addstatus = nil
  12434. }
  12435. // Status returns the value of the "status" field in the mutation.
  12436. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  12437. v := m.status
  12438. if v == nil {
  12439. return
  12440. }
  12441. return *v, true
  12442. }
  12443. // OldStatus returns the old "status" field's value of the SopStage entity.
  12444. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12446. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12447. if !m.op.Is(OpUpdateOne) {
  12448. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12449. }
  12450. if m.id == nil || m.oldValue == nil {
  12451. return v, errors.New("OldStatus requires an ID field in the mutation")
  12452. }
  12453. oldValue, err := m.oldValue(ctx)
  12454. if err != nil {
  12455. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12456. }
  12457. return oldValue.Status, nil
  12458. }
  12459. // AddStatus adds u to the "status" field.
  12460. func (m *SopStageMutation) AddStatus(u int8) {
  12461. if m.addstatus != nil {
  12462. *m.addstatus += u
  12463. } else {
  12464. m.addstatus = &u
  12465. }
  12466. }
  12467. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12468. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  12469. v := m.addstatus
  12470. if v == nil {
  12471. return
  12472. }
  12473. return *v, true
  12474. }
  12475. // ClearStatus clears the value of the "status" field.
  12476. func (m *SopStageMutation) ClearStatus() {
  12477. m.status = nil
  12478. m.addstatus = nil
  12479. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  12480. }
  12481. // StatusCleared returns if the "status" field was cleared in this mutation.
  12482. func (m *SopStageMutation) StatusCleared() bool {
  12483. _, ok := m.clearedFields[sopstage.FieldStatus]
  12484. return ok
  12485. }
  12486. // ResetStatus resets all changes to the "status" field.
  12487. func (m *SopStageMutation) ResetStatus() {
  12488. m.status = nil
  12489. m.addstatus = nil
  12490. delete(m.clearedFields, sopstage.FieldStatus)
  12491. }
  12492. // SetDeletedAt sets the "deleted_at" field.
  12493. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  12494. m.deleted_at = &t
  12495. }
  12496. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12497. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  12498. v := m.deleted_at
  12499. if v == nil {
  12500. return
  12501. }
  12502. return *v, true
  12503. }
  12504. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  12505. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12507. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12508. if !m.op.Is(OpUpdateOne) {
  12509. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12510. }
  12511. if m.id == nil || m.oldValue == nil {
  12512. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12513. }
  12514. oldValue, err := m.oldValue(ctx)
  12515. if err != nil {
  12516. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12517. }
  12518. return oldValue.DeletedAt, nil
  12519. }
  12520. // ClearDeletedAt clears the value of the "deleted_at" field.
  12521. func (m *SopStageMutation) ClearDeletedAt() {
  12522. m.deleted_at = nil
  12523. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  12524. }
  12525. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12526. func (m *SopStageMutation) DeletedAtCleared() bool {
  12527. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  12528. return ok
  12529. }
  12530. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12531. func (m *SopStageMutation) ResetDeletedAt() {
  12532. m.deleted_at = nil
  12533. delete(m.clearedFields, sopstage.FieldDeletedAt)
  12534. }
  12535. // SetTaskID sets the "task_id" field.
  12536. func (m *SopStageMutation) SetTaskID(u uint64) {
  12537. m.sop_task = &u
  12538. }
  12539. // TaskID returns the value of the "task_id" field in the mutation.
  12540. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  12541. v := m.sop_task
  12542. if v == nil {
  12543. return
  12544. }
  12545. return *v, true
  12546. }
  12547. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  12548. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12550. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  12551. if !m.op.Is(OpUpdateOne) {
  12552. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  12553. }
  12554. if m.id == nil || m.oldValue == nil {
  12555. return v, errors.New("OldTaskID requires an ID field in the mutation")
  12556. }
  12557. oldValue, err := m.oldValue(ctx)
  12558. if err != nil {
  12559. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  12560. }
  12561. return oldValue.TaskID, nil
  12562. }
  12563. // ResetTaskID resets all changes to the "task_id" field.
  12564. func (m *SopStageMutation) ResetTaskID() {
  12565. m.sop_task = nil
  12566. }
  12567. // SetName sets the "name" field.
  12568. func (m *SopStageMutation) SetName(s string) {
  12569. m.name = &s
  12570. }
  12571. // Name returns the value of the "name" field in the mutation.
  12572. func (m *SopStageMutation) Name() (r string, exists bool) {
  12573. v := m.name
  12574. if v == nil {
  12575. return
  12576. }
  12577. return *v, true
  12578. }
  12579. // OldName returns the old "name" field's value of the SopStage entity.
  12580. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12582. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  12583. if !m.op.Is(OpUpdateOne) {
  12584. return v, errors.New("OldName is only allowed on UpdateOne operations")
  12585. }
  12586. if m.id == nil || m.oldValue == nil {
  12587. return v, errors.New("OldName requires an ID field in the mutation")
  12588. }
  12589. oldValue, err := m.oldValue(ctx)
  12590. if err != nil {
  12591. return v, fmt.Errorf("querying old value for OldName: %w", err)
  12592. }
  12593. return oldValue.Name, nil
  12594. }
  12595. // ResetName resets all changes to the "name" field.
  12596. func (m *SopStageMutation) ResetName() {
  12597. m.name = nil
  12598. }
  12599. // SetConditionType sets the "condition_type" field.
  12600. func (m *SopStageMutation) SetConditionType(i int) {
  12601. m.condition_type = &i
  12602. m.addcondition_type = nil
  12603. }
  12604. // ConditionType returns the value of the "condition_type" field in the mutation.
  12605. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  12606. v := m.condition_type
  12607. if v == nil {
  12608. return
  12609. }
  12610. return *v, true
  12611. }
  12612. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  12613. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12615. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  12616. if !m.op.Is(OpUpdateOne) {
  12617. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  12618. }
  12619. if m.id == nil || m.oldValue == nil {
  12620. return v, errors.New("OldConditionType requires an ID field in the mutation")
  12621. }
  12622. oldValue, err := m.oldValue(ctx)
  12623. if err != nil {
  12624. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  12625. }
  12626. return oldValue.ConditionType, nil
  12627. }
  12628. // AddConditionType adds i to the "condition_type" field.
  12629. func (m *SopStageMutation) AddConditionType(i int) {
  12630. if m.addcondition_type != nil {
  12631. *m.addcondition_type += i
  12632. } else {
  12633. m.addcondition_type = &i
  12634. }
  12635. }
  12636. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  12637. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  12638. v := m.addcondition_type
  12639. if v == nil {
  12640. return
  12641. }
  12642. return *v, true
  12643. }
  12644. // ResetConditionType resets all changes to the "condition_type" field.
  12645. func (m *SopStageMutation) ResetConditionType() {
  12646. m.condition_type = nil
  12647. m.addcondition_type = nil
  12648. }
  12649. // SetConditionOperator sets the "condition_operator" field.
  12650. func (m *SopStageMutation) SetConditionOperator(i int) {
  12651. m.condition_operator = &i
  12652. m.addcondition_operator = nil
  12653. }
  12654. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  12655. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  12656. v := m.condition_operator
  12657. if v == nil {
  12658. return
  12659. }
  12660. return *v, true
  12661. }
  12662. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  12663. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12665. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  12666. if !m.op.Is(OpUpdateOne) {
  12667. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  12668. }
  12669. if m.id == nil || m.oldValue == nil {
  12670. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  12671. }
  12672. oldValue, err := m.oldValue(ctx)
  12673. if err != nil {
  12674. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  12675. }
  12676. return oldValue.ConditionOperator, nil
  12677. }
  12678. // AddConditionOperator adds i to the "condition_operator" field.
  12679. func (m *SopStageMutation) AddConditionOperator(i int) {
  12680. if m.addcondition_operator != nil {
  12681. *m.addcondition_operator += i
  12682. } else {
  12683. m.addcondition_operator = &i
  12684. }
  12685. }
  12686. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  12687. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  12688. v := m.addcondition_operator
  12689. if v == nil {
  12690. return
  12691. }
  12692. return *v, true
  12693. }
  12694. // ResetConditionOperator resets all changes to the "condition_operator" field.
  12695. func (m *SopStageMutation) ResetConditionOperator() {
  12696. m.condition_operator = nil
  12697. m.addcondition_operator = nil
  12698. }
  12699. // SetConditionList sets the "condition_list" field.
  12700. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  12701. m.condition_list = &ct
  12702. m.appendcondition_list = nil
  12703. }
  12704. // ConditionList returns the value of the "condition_list" field in the mutation.
  12705. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  12706. v := m.condition_list
  12707. if v == nil {
  12708. return
  12709. }
  12710. return *v, true
  12711. }
  12712. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  12713. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12715. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  12716. if !m.op.Is(OpUpdateOne) {
  12717. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  12718. }
  12719. if m.id == nil || m.oldValue == nil {
  12720. return v, errors.New("OldConditionList requires an ID field in the mutation")
  12721. }
  12722. oldValue, err := m.oldValue(ctx)
  12723. if err != nil {
  12724. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  12725. }
  12726. return oldValue.ConditionList, nil
  12727. }
  12728. // AppendConditionList adds ct to the "condition_list" field.
  12729. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  12730. m.appendcondition_list = append(m.appendcondition_list, ct...)
  12731. }
  12732. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  12733. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  12734. if len(m.appendcondition_list) == 0 {
  12735. return nil, false
  12736. }
  12737. return m.appendcondition_list, true
  12738. }
  12739. // ResetConditionList resets all changes to the "condition_list" field.
  12740. func (m *SopStageMutation) ResetConditionList() {
  12741. m.condition_list = nil
  12742. m.appendcondition_list = nil
  12743. }
  12744. // SetActionMessage sets the "action_message" field.
  12745. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  12746. m.action_message = &ct
  12747. m.appendaction_message = nil
  12748. }
  12749. // ActionMessage returns the value of the "action_message" field in the mutation.
  12750. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  12751. v := m.action_message
  12752. if v == nil {
  12753. return
  12754. }
  12755. return *v, true
  12756. }
  12757. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  12758. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12760. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  12761. if !m.op.Is(OpUpdateOne) {
  12762. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  12763. }
  12764. if m.id == nil || m.oldValue == nil {
  12765. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  12766. }
  12767. oldValue, err := m.oldValue(ctx)
  12768. if err != nil {
  12769. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  12770. }
  12771. return oldValue.ActionMessage, nil
  12772. }
  12773. // AppendActionMessage adds ct to the "action_message" field.
  12774. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  12775. m.appendaction_message = append(m.appendaction_message, ct...)
  12776. }
  12777. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  12778. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  12779. if len(m.appendaction_message) == 0 {
  12780. return nil, false
  12781. }
  12782. return m.appendaction_message, true
  12783. }
  12784. // ClearActionMessage clears the value of the "action_message" field.
  12785. func (m *SopStageMutation) ClearActionMessage() {
  12786. m.action_message = nil
  12787. m.appendaction_message = nil
  12788. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  12789. }
  12790. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  12791. func (m *SopStageMutation) ActionMessageCleared() bool {
  12792. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  12793. return ok
  12794. }
  12795. // ResetActionMessage resets all changes to the "action_message" field.
  12796. func (m *SopStageMutation) ResetActionMessage() {
  12797. m.action_message = nil
  12798. m.appendaction_message = nil
  12799. delete(m.clearedFields, sopstage.FieldActionMessage)
  12800. }
  12801. // SetActionLabel sets the "action_label" field.
  12802. func (m *SopStageMutation) SetActionLabel(u []uint64) {
  12803. m.action_label = &u
  12804. m.appendaction_label = nil
  12805. }
  12806. // ActionLabel returns the value of the "action_label" field in the mutation.
  12807. func (m *SopStageMutation) ActionLabel() (r []uint64, exists bool) {
  12808. v := m.action_label
  12809. if v == nil {
  12810. return
  12811. }
  12812. return *v, true
  12813. }
  12814. // OldActionLabel returns the old "action_label" field's value of the SopStage entity.
  12815. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12817. func (m *SopStageMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  12818. if !m.op.Is(OpUpdateOne) {
  12819. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  12820. }
  12821. if m.id == nil || m.oldValue == nil {
  12822. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  12823. }
  12824. oldValue, err := m.oldValue(ctx)
  12825. if err != nil {
  12826. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  12827. }
  12828. return oldValue.ActionLabel, nil
  12829. }
  12830. // AppendActionLabel adds u to the "action_label" field.
  12831. func (m *SopStageMutation) AppendActionLabel(u []uint64) {
  12832. m.appendaction_label = append(m.appendaction_label, u...)
  12833. }
  12834. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  12835. func (m *SopStageMutation) AppendedActionLabel() ([]uint64, bool) {
  12836. if len(m.appendaction_label) == 0 {
  12837. return nil, false
  12838. }
  12839. return m.appendaction_label, true
  12840. }
  12841. // ClearActionLabel clears the value of the "action_label" field.
  12842. func (m *SopStageMutation) ClearActionLabel() {
  12843. m.action_label = nil
  12844. m.appendaction_label = nil
  12845. m.clearedFields[sopstage.FieldActionLabel] = struct{}{}
  12846. }
  12847. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  12848. func (m *SopStageMutation) ActionLabelCleared() bool {
  12849. _, ok := m.clearedFields[sopstage.FieldActionLabel]
  12850. return ok
  12851. }
  12852. // ResetActionLabel resets all changes to the "action_label" field.
  12853. func (m *SopStageMutation) ResetActionLabel() {
  12854. m.action_label = nil
  12855. m.appendaction_label = nil
  12856. delete(m.clearedFields, sopstage.FieldActionLabel)
  12857. }
  12858. // SetIndexSort sets the "index_sort" field.
  12859. func (m *SopStageMutation) SetIndexSort(i int) {
  12860. m.index_sort = &i
  12861. m.addindex_sort = nil
  12862. }
  12863. // IndexSort returns the value of the "index_sort" field in the mutation.
  12864. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  12865. v := m.index_sort
  12866. if v == nil {
  12867. return
  12868. }
  12869. return *v, true
  12870. }
  12871. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  12872. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12874. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  12875. if !m.op.Is(OpUpdateOne) {
  12876. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  12877. }
  12878. if m.id == nil || m.oldValue == nil {
  12879. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  12880. }
  12881. oldValue, err := m.oldValue(ctx)
  12882. if err != nil {
  12883. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  12884. }
  12885. return oldValue.IndexSort, nil
  12886. }
  12887. // AddIndexSort adds i to the "index_sort" field.
  12888. func (m *SopStageMutation) AddIndexSort(i int) {
  12889. if m.addindex_sort != nil {
  12890. *m.addindex_sort += i
  12891. } else {
  12892. m.addindex_sort = &i
  12893. }
  12894. }
  12895. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  12896. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  12897. v := m.addindex_sort
  12898. if v == nil {
  12899. return
  12900. }
  12901. return *v, true
  12902. }
  12903. // ClearIndexSort clears the value of the "index_sort" field.
  12904. func (m *SopStageMutation) ClearIndexSort() {
  12905. m.index_sort = nil
  12906. m.addindex_sort = nil
  12907. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  12908. }
  12909. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  12910. func (m *SopStageMutation) IndexSortCleared() bool {
  12911. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  12912. return ok
  12913. }
  12914. // ResetIndexSort resets all changes to the "index_sort" field.
  12915. func (m *SopStageMutation) ResetIndexSort() {
  12916. m.index_sort = nil
  12917. m.addindex_sort = nil
  12918. delete(m.clearedFields, sopstage.FieldIndexSort)
  12919. }
  12920. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  12921. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  12922. m.sop_task = &id
  12923. }
  12924. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  12925. func (m *SopStageMutation) ClearSopTask() {
  12926. m.clearedsop_task = true
  12927. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  12928. }
  12929. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  12930. func (m *SopStageMutation) SopTaskCleared() bool {
  12931. return m.clearedsop_task
  12932. }
  12933. // SopTaskID returns the "sop_task" edge ID in the mutation.
  12934. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  12935. if m.sop_task != nil {
  12936. return *m.sop_task, true
  12937. }
  12938. return
  12939. }
  12940. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  12941. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12942. // SopTaskID instead. It exists only for internal usage by the builders.
  12943. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  12944. if id := m.sop_task; id != nil {
  12945. ids = append(ids, *id)
  12946. }
  12947. return
  12948. }
  12949. // ResetSopTask resets all changes to the "sop_task" edge.
  12950. func (m *SopStageMutation) ResetSopTask() {
  12951. m.sop_task = nil
  12952. m.clearedsop_task = false
  12953. }
  12954. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  12955. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  12956. if m.stage_nodes == nil {
  12957. m.stage_nodes = make(map[uint64]struct{})
  12958. }
  12959. for i := range ids {
  12960. m.stage_nodes[ids[i]] = struct{}{}
  12961. }
  12962. }
  12963. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  12964. func (m *SopStageMutation) ClearStageNodes() {
  12965. m.clearedstage_nodes = true
  12966. }
  12967. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  12968. func (m *SopStageMutation) StageNodesCleared() bool {
  12969. return m.clearedstage_nodes
  12970. }
  12971. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  12972. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  12973. if m.removedstage_nodes == nil {
  12974. m.removedstage_nodes = make(map[uint64]struct{})
  12975. }
  12976. for i := range ids {
  12977. delete(m.stage_nodes, ids[i])
  12978. m.removedstage_nodes[ids[i]] = struct{}{}
  12979. }
  12980. }
  12981. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  12982. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  12983. for id := range m.removedstage_nodes {
  12984. ids = append(ids, id)
  12985. }
  12986. return
  12987. }
  12988. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  12989. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  12990. for id := range m.stage_nodes {
  12991. ids = append(ids, id)
  12992. }
  12993. return
  12994. }
  12995. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  12996. func (m *SopStageMutation) ResetStageNodes() {
  12997. m.stage_nodes = nil
  12998. m.clearedstage_nodes = false
  12999. m.removedstage_nodes = nil
  13000. }
  13001. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  13002. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  13003. if m.stage_messages == nil {
  13004. m.stage_messages = make(map[uint64]struct{})
  13005. }
  13006. for i := range ids {
  13007. m.stage_messages[ids[i]] = struct{}{}
  13008. }
  13009. }
  13010. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  13011. func (m *SopStageMutation) ClearStageMessages() {
  13012. m.clearedstage_messages = true
  13013. }
  13014. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  13015. func (m *SopStageMutation) StageMessagesCleared() bool {
  13016. return m.clearedstage_messages
  13017. }
  13018. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  13019. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  13020. if m.removedstage_messages == nil {
  13021. m.removedstage_messages = make(map[uint64]struct{})
  13022. }
  13023. for i := range ids {
  13024. delete(m.stage_messages, ids[i])
  13025. m.removedstage_messages[ids[i]] = struct{}{}
  13026. }
  13027. }
  13028. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  13029. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  13030. for id := range m.removedstage_messages {
  13031. ids = append(ids, id)
  13032. }
  13033. return
  13034. }
  13035. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  13036. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  13037. for id := range m.stage_messages {
  13038. ids = append(ids, id)
  13039. }
  13040. return
  13041. }
  13042. // ResetStageMessages resets all changes to the "stage_messages" edge.
  13043. func (m *SopStageMutation) ResetStageMessages() {
  13044. m.stage_messages = nil
  13045. m.clearedstage_messages = false
  13046. m.removedstage_messages = nil
  13047. }
  13048. // Where appends a list predicates to the SopStageMutation builder.
  13049. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  13050. m.predicates = append(m.predicates, ps...)
  13051. }
  13052. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  13053. // users can use type-assertion to append predicates that do not depend on any generated package.
  13054. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  13055. p := make([]predicate.SopStage, len(ps))
  13056. for i := range ps {
  13057. p[i] = ps[i]
  13058. }
  13059. m.Where(p...)
  13060. }
  13061. // Op returns the operation name.
  13062. func (m *SopStageMutation) Op() Op {
  13063. return m.op
  13064. }
  13065. // SetOp allows setting the mutation operation.
  13066. func (m *SopStageMutation) SetOp(op Op) {
  13067. m.op = op
  13068. }
  13069. // Type returns the node type of this mutation (SopStage).
  13070. func (m *SopStageMutation) Type() string {
  13071. return m.typ
  13072. }
  13073. // Fields returns all fields that were changed during this mutation. Note that in
  13074. // order to get all numeric fields that were incremented/decremented, call
  13075. // AddedFields().
  13076. func (m *SopStageMutation) Fields() []string {
  13077. fields := make([]string, 0, 12)
  13078. if m.created_at != nil {
  13079. fields = append(fields, sopstage.FieldCreatedAt)
  13080. }
  13081. if m.updated_at != nil {
  13082. fields = append(fields, sopstage.FieldUpdatedAt)
  13083. }
  13084. if m.status != nil {
  13085. fields = append(fields, sopstage.FieldStatus)
  13086. }
  13087. if m.deleted_at != nil {
  13088. fields = append(fields, sopstage.FieldDeletedAt)
  13089. }
  13090. if m.sop_task != nil {
  13091. fields = append(fields, sopstage.FieldTaskID)
  13092. }
  13093. if m.name != nil {
  13094. fields = append(fields, sopstage.FieldName)
  13095. }
  13096. if m.condition_type != nil {
  13097. fields = append(fields, sopstage.FieldConditionType)
  13098. }
  13099. if m.condition_operator != nil {
  13100. fields = append(fields, sopstage.FieldConditionOperator)
  13101. }
  13102. if m.condition_list != nil {
  13103. fields = append(fields, sopstage.FieldConditionList)
  13104. }
  13105. if m.action_message != nil {
  13106. fields = append(fields, sopstage.FieldActionMessage)
  13107. }
  13108. if m.action_label != nil {
  13109. fields = append(fields, sopstage.FieldActionLabel)
  13110. }
  13111. if m.index_sort != nil {
  13112. fields = append(fields, sopstage.FieldIndexSort)
  13113. }
  13114. return fields
  13115. }
  13116. // Field returns the value of a field with the given name. The second boolean
  13117. // return value indicates that this field was not set, or was not defined in the
  13118. // schema.
  13119. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  13120. switch name {
  13121. case sopstage.FieldCreatedAt:
  13122. return m.CreatedAt()
  13123. case sopstage.FieldUpdatedAt:
  13124. return m.UpdatedAt()
  13125. case sopstage.FieldStatus:
  13126. return m.Status()
  13127. case sopstage.FieldDeletedAt:
  13128. return m.DeletedAt()
  13129. case sopstage.FieldTaskID:
  13130. return m.TaskID()
  13131. case sopstage.FieldName:
  13132. return m.Name()
  13133. case sopstage.FieldConditionType:
  13134. return m.ConditionType()
  13135. case sopstage.FieldConditionOperator:
  13136. return m.ConditionOperator()
  13137. case sopstage.FieldConditionList:
  13138. return m.ConditionList()
  13139. case sopstage.FieldActionMessage:
  13140. return m.ActionMessage()
  13141. case sopstage.FieldActionLabel:
  13142. return m.ActionLabel()
  13143. case sopstage.FieldIndexSort:
  13144. return m.IndexSort()
  13145. }
  13146. return nil, false
  13147. }
  13148. // OldField returns the old value of the field from the database. An error is
  13149. // returned if the mutation operation is not UpdateOne, or the query to the
  13150. // database failed.
  13151. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13152. switch name {
  13153. case sopstage.FieldCreatedAt:
  13154. return m.OldCreatedAt(ctx)
  13155. case sopstage.FieldUpdatedAt:
  13156. return m.OldUpdatedAt(ctx)
  13157. case sopstage.FieldStatus:
  13158. return m.OldStatus(ctx)
  13159. case sopstage.FieldDeletedAt:
  13160. return m.OldDeletedAt(ctx)
  13161. case sopstage.FieldTaskID:
  13162. return m.OldTaskID(ctx)
  13163. case sopstage.FieldName:
  13164. return m.OldName(ctx)
  13165. case sopstage.FieldConditionType:
  13166. return m.OldConditionType(ctx)
  13167. case sopstage.FieldConditionOperator:
  13168. return m.OldConditionOperator(ctx)
  13169. case sopstage.FieldConditionList:
  13170. return m.OldConditionList(ctx)
  13171. case sopstage.FieldActionMessage:
  13172. return m.OldActionMessage(ctx)
  13173. case sopstage.FieldActionLabel:
  13174. return m.OldActionLabel(ctx)
  13175. case sopstage.FieldIndexSort:
  13176. return m.OldIndexSort(ctx)
  13177. }
  13178. return nil, fmt.Errorf("unknown SopStage field %s", name)
  13179. }
  13180. // SetField sets the value of a field with the given name. It returns an error if
  13181. // the field is not defined in the schema, or if the type mismatched the field
  13182. // type.
  13183. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  13184. switch name {
  13185. case sopstage.FieldCreatedAt:
  13186. v, ok := value.(time.Time)
  13187. if !ok {
  13188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13189. }
  13190. m.SetCreatedAt(v)
  13191. return nil
  13192. case sopstage.FieldUpdatedAt:
  13193. v, ok := value.(time.Time)
  13194. if !ok {
  13195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13196. }
  13197. m.SetUpdatedAt(v)
  13198. return nil
  13199. case sopstage.FieldStatus:
  13200. v, ok := value.(uint8)
  13201. if !ok {
  13202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13203. }
  13204. m.SetStatus(v)
  13205. return nil
  13206. case sopstage.FieldDeletedAt:
  13207. v, ok := value.(time.Time)
  13208. if !ok {
  13209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13210. }
  13211. m.SetDeletedAt(v)
  13212. return nil
  13213. case sopstage.FieldTaskID:
  13214. v, ok := value.(uint64)
  13215. if !ok {
  13216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13217. }
  13218. m.SetTaskID(v)
  13219. return nil
  13220. case sopstage.FieldName:
  13221. v, ok := value.(string)
  13222. if !ok {
  13223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13224. }
  13225. m.SetName(v)
  13226. return nil
  13227. case sopstage.FieldConditionType:
  13228. v, ok := value.(int)
  13229. if !ok {
  13230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13231. }
  13232. m.SetConditionType(v)
  13233. return nil
  13234. case sopstage.FieldConditionOperator:
  13235. v, ok := value.(int)
  13236. if !ok {
  13237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13238. }
  13239. m.SetConditionOperator(v)
  13240. return nil
  13241. case sopstage.FieldConditionList:
  13242. v, ok := value.([]custom_types.Condition)
  13243. if !ok {
  13244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13245. }
  13246. m.SetConditionList(v)
  13247. return nil
  13248. case sopstage.FieldActionMessage:
  13249. v, ok := value.([]custom_types.Action)
  13250. if !ok {
  13251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13252. }
  13253. m.SetActionMessage(v)
  13254. return nil
  13255. case sopstage.FieldActionLabel:
  13256. v, ok := value.([]uint64)
  13257. if !ok {
  13258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13259. }
  13260. m.SetActionLabel(v)
  13261. return nil
  13262. case sopstage.FieldIndexSort:
  13263. v, ok := value.(int)
  13264. if !ok {
  13265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13266. }
  13267. m.SetIndexSort(v)
  13268. return nil
  13269. }
  13270. return fmt.Errorf("unknown SopStage field %s", name)
  13271. }
  13272. // AddedFields returns all numeric fields that were incremented/decremented during
  13273. // this mutation.
  13274. func (m *SopStageMutation) AddedFields() []string {
  13275. var fields []string
  13276. if m.addstatus != nil {
  13277. fields = append(fields, sopstage.FieldStatus)
  13278. }
  13279. if m.addcondition_type != nil {
  13280. fields = append(fields, sopstage.FieldConditionType)
  13281. }
  13282. if m.addcondition_operator != nil {
  13283. fields = append(fields, sopstage.FieldConditionOperator)
  13284. }
  13285. if m.addindex_sort != nil {
  13286. fields = append(fields, sopstage.FieldIndexSort)
  13287. }
  13288. return fields
  13289. }
  13290. // AddedField returns the numeric value that was incremented/decremented on a field
  13291. // with the given name. The second boolean return value indicates that this field
  13292. // was not set, or was not defined in the schema.
  13293. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  13294. switch name {
  13295. case sopstage.FieldStatus:
  13296. return m.AddedStatus()
  13297. case sopstage.FieldConditionType:
  13298. return m.AddedConditionType()
  13299. case sopstage.FieldConditionOperator:
  13300. return m.AddedConditionOperator()
  13301. case sopstage.FieldIndexSort:
  13302. return m.AddedIndexSort()
  13303. }
  13304. return nil, false
  13305. }
  13306. // AddField adds the value to the field with the given name. It returns an error if
  13307. // the field is not defined in the schema, or if the type mismatched the field
  13308. // type.
  13309. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  13310. switch name {
  13311. case sopstage.FieldStatus:
  13312. v, ok := value.(int8)
  13313. if !ok {
  13314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13315. }
  13316. m.AddStatus(v)
  13317. return nil
  13318. case sopstage.FieldConditionType:
  13319. v, ok := value.(int)
  13320. if !ok {
  13321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13322. }
  13323. m.AddConditionType(v)
  13324. return nil
  13325. case sopstage.FieldConditionOperator:
  13326. v, ok := value.(int)
  13327. if !ok {
  13328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13329. }
  13330. m.AddConditionOperator(v)
  13331. return nil
  13332. case sopstage.FieldIndexSort:
  13333. v, ok := value.(int)
  13334. if !ok {
  13335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13336. }
  13337. m.AddIndexSort(v)
  13338. return nil
  13339. }
  13340. return fmt.Errorf("unknown SopStage numeric field %s", name)
  13341. }
  13342. // ClearedFields returns all nullable fields that were cleared during this
  13343. // mutation.
  13344. func (m *SopStageMutation) ClearedFields() []string {
  13345. var fields []string
  13346. if m.FieldCleared(sopstage.FieldStatus) {
  13347. fields = append(fields, sopstage.FieldStatus)
  13348. }
  13349. if m.FieldCleared(sopstage.FieldDeletedAt) {
  13350. fields = append(fields, sopstage.FieldDeletedAt)
  13351. }
  13352. if m.FieldCleared(sopstage.FieldActionMessage) {
  13353. fields = append(fields, sopstage.FieldActionMessage)
  13354. }
  13355. if m.FieldCleared(sopstage.FieldActionLabel) {
  13356. fields = append(fields, sopstage.FieldActionLabel)
  13357. }
  13358. if m.FieldCleared(sopstage.FieldIndexSort) {
  13359. fields = append(fields, sopstage.FieldIndexSort)
  13360. }
  13361. return fields
  13362. }
  13363. // FieldCleared returns a boolean indicating if a field with the given name was
  13364. // cleared in this mutation.
  13365. func (m *SopStageMutation) FieldCleared(name string) bool {
  13366. _, ok := m.clearedFields[name]
  13367. return ok
  13368. }
  13369. // ClearField clears the value of the field with the given name. It returns an
  13370. // error if the field is not defined in the schema.
  13371. func (m *SopStageMutation) ClearField(name string) error {
  13372. switch name {
  13373. case sopstage.FieldStatus:
  13374. m.ClearStatus()
  13375. return nil
  13376. case sopstage.FieldDeletedAt:
  13377. m.ClearDeletedAt()
  13378. return nil
  13379. case sopstage.FieldActionMessage:
  13380. m.ClearActionMessage()
  13381. return nil
  13382. case sopstage.FieldActionLabel:
  13383. m.ClearActionLabel()
  13384. return nil
  13385. case sopstage.FieldIndexSort:
  13386. m.ClearIndexSort()
  13387. return nil
  13388. }
  13389. return fmt.Errorf("unknown SopStage nullable field %s", name)
  13390. }
  13391. // ResetField resets all changes in the mutation for the field with the given name.
  13392. // It returns an error if the field is not defined in the schema.
  13393. func (m *SopStageMutation) ResetField(name string) error {
  13394. switch name {
  13395. case sopstage.FieldCreatedAt:
  13396. m.ResetCreatedAt()
  13397. return nil
  13398. case sopstage.FieldUpdatedAt:
  13399. m.ResetUpdatedAt()
  13400. return nil
  13401. case sopstage.FieldStatus:
  13402. m.ResetStatus()
  13403. return nil
  13404. case sopstage.FieldDeletedAt:
  13405. m.ResetDeletedAt()
  13406. return nil
  13407. case sopstage.FieldTaskID:
  13408. m.ResetTaskID()
  13409. return nil
  13410. case sopstage.FieldName:
  13411. m.ResetName()
  13412. return nil
  13413. case sopstage.FieldConditionType:
  13414. m.ResetConditionType()
  13415. return nil
  13416. case sopstage.FieldConditionOperator:
  13417. m.ResetConditionOperator()
  13418. return nil
  13419. case sopstage.FieldConditionList:
  13420. m.ResetConditionList()
  13421. return nil
  13422. case sopstage.FieldActionMessage:
  13423. m.ResetActionMessage()
  13424. return nil
  13425. case sopstage.FieldActionLabel:
  13426. m.ResetActionLabel()
  13427. return nil
  13428. case sopstage.FieldIndexSort:
  13429. m.ResetIndexSort()
  13430. return nil
  13431. }
  13432. return fmt.Errorf("unknown SopStage field %s", name)
  13433. }
  13434. // AddedEdges returns all edge names that were set/added in this mutation.
  13435. func (m *SopStageMutation) AddedEdges() []string {
  13436. edges := make([]string, 0, 3)
  13437. if m.sop_task != nil {
  13438. edges = append(edges, sopstage.EdgeSopTask)
  13439. }
  13440. if m.stage_nodes != nil {
  13441. edges = append(edges, sopstage.EdgeStageNodes)
  13442. }
  13443. if m.stage_messages != nil {
  13444. edges = append(edges, sopstage.EdgeStageMessages)
  13445. }
  13446. return edges
  13447. }
  13448. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13449. // name in this mutation.
  13450. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  13451. switch name {
  13452. case sopstage.EdgeSopTask:
  13453. if id := m.sop_task; id != nil {
  13454. return []ent.Value{*id}
  13455. }
  13456. case sopstage.EdgeStageNodes:
  13457. ids := make([]ent.Value, 0, len(m.stage_nodes))
  13458. for id := range m.stage_nodes {
  13459. ids = append(ids, id)
  13460. }
  13461. return ids
  13462. case sopstage.EdgeStageMessages:
  13463. ids := make([]ent.Value, 0, len(m.stage_messages))
  13464. for id := range m.stage_messages {
  13465. ids = append(ids, id)
  13466. }
  13467. return ids
  13468. }
  13469. return nil
  13470. }
  13471. // RemovedEdges returns all edge names that were removed in this mutation.
  13472. func (m *SopStageMutation) RemovedEdges() []string {
  13473. edges := make([]string, 0, 3)
  13474. if m.removedstage_nodes != nil {
  13475. edges = append(edges, sopstage.EdgeStageNodes)
  13476. }
  13477. if m.removedstage_messages != nil {
  13478. edges = append(edges, sopstage.EdgeStageMessages)
  13479. }
  13480. return edges
  13481. }
  13482. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13483. // the given name in this mutation.
  13484. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  13485. switch name {
  13486. case sopstage.EdgeStageNodes:
  13487. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  13488. for id := range m.removedstage_nodes {
  13489. ids = append(ids, id)
  13490. }
  13491. return ids
  13492. case sopstage.EdgeStageMessages:
  13493. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  13494. for id := range m.removedstage_messages {
  13495. ids = append(ids, id)
  13496. }
  13497. return ids
  13498. }
  13499. return nil
  13500. }
  13501. // ClearedEdges returns all edge names that were cleared in this mutation.
  13502. func (m *SopStageMutation) ClearedEdges() []string {
  13503. edges := make([]string, 0, 3)
  13504. if m.clearedsop_task {
  13505. edges = append(edges, sopstage.EdgeSopTask)
  13506. }
  13507. if m.clearedstage_nodes {
  13508. edges = append(edges, sopstage.EdgeStageNodes)
  13509. }
  13510. if m.clearedstage_messages {
  13511. edges = append(edges, sopstage.EdgeStageMessages)
  13512. }
  13513. return edges
  13514. }
  13515. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13516. // was cleared in this mutation.
  13517. func (m *SopStageMutation) EdgeCleared(name string) bool {
  13518. switch name {
  13519. case sopstage.EdgeSopTask:
  13520. return m.clearedsop_task
  13521. case sopstage.EdgeStageNodes:
  13522. return m.clearedstage_nodes
  13523. case sopstage.EdgeStageMessages:
  13524. return m.clearedstage_messages
  13525. }
  13526. return false
  13527. }
  13528. // ClearEdge clears the value of the edge with the given name. It returns an error
  13529. // if that edge is not defined in the schema.
  13530. func (m *SopStageMutation) ClearEdge(name string) error {
  13531. switch name {
  13532. case sopstage.EdgeSopTask:
  13533. m.ClearSopTask()
  13534. return nil
  13535. }
  13536. return fmt.Errorf("unknown SopStage unique edge %s", name)
  13537. }
  13538. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13539. // It returns an error if the edge is not defined in the schema.
  13540. func (m *SopStageMutation) ResetEdge(name string) error {
  13541. switch name {
  13542. case sopstage.EdgeSopTask:
  13543. m.ResetSopTask()
  13544. return nil
  13545. case sopstage.EdgeStageNodes:
  13546. m.ResetStageNodes()
  13547. return nil
  13548. case sopstage.EdgeStageMessages:
  13549. m.ResetStageMessages()
  13550. return nil
  13551. }
  13552. return fmt.Errorf("unknown SopStage edge %s", name)
  13553. }
  13554. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  13555. type SopTaskMutation struct {
  13556. config
  13557. op Op
  13558. typ string
  13559. id *uint64
  13560. created_at *time.Time
  13561. updated_at *time.Time
  13562. status *uint8
  13563. addstatus *int8
  13564. deleted_at *time.Time
  13565. name *string
  13566. bot_wxid_list *[]string
  13567. appendbot_wxid_list []string
  13568. _type *int
  13569. add_type *int
  13570. plan_start_time *time.Time
  13571. plan_end_time *time.Time
  13572. creator_id *string
  13573. organization_id *uint64
  13574. addorganization_id *int64
  13575. clearedFields map[string]struct{}
  13576. task_stages map[uint64]struct{}
  13577. removedtask_stages map[uint64]struct{}
  13578. clearedtask_stages bool
  13579. done bool
  13580. oldValue func(context.Context) (*SopTask, error)
  13581. predicates []predicate.SopTask
  13582. }
  13583. var _ ent.Mutation = (*SopTaskMutation)(nil)
  13584. // soptaskOption allows management of the mutation configuration using functional options.
  13585. type soptaskOption func(*SopTaskMutation)
  13586. // newSopTaskMutation creates new mutation for the SopTask entity.
  13587. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  13588. m := &SopTaskMutation{
  13589. config: c,
  13590. op: op,
  13591. typ: TypeSopTask,
  13592. clearedFields: make(map[string]struct{}),
  13593. }
  13594. for _, opt := range opts {
  13595. opt(m)
  13596. }
  13597. return m
  13598. }
  13599. // withSopTaskID sets the ID field of the mutation.
  13600. func withSopTaskID(id uint64) soptaskOption {
  13601. return func(m *SopTaskMutation) {
  13602. var (
  13603. err error
  13604. once sync.Once
  13605. value *SopTask
  13606. )
  13607. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  13608. once.Do(func() {
  13609. if m.done {
  13610. err = errors.New("querying old values post mutation is not allowed")
  13611. } else {
  13612. value, err = m.Client().SopTask.Get(ctx, id)
  13613. }
  13614. })
  13615. return value, err
  13616. }
  13617. m.id = &id
  13618. }
  13619. }
  13620. // withSopTask sets the old SopTask of the mutation.
  13621. func withSopTask(node *SopTask) soptaskOption {
  13622. return func(m *SopTaskMutation) {
  13623. m.oldValue = func(context.Context) (*SopTask, error) {
  13624. return node, nil
  13625. }
  13626. m.id = &node.ID
  13627. }
  13628. }
  13629. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13630. // executed in a transaction (ent.Tx), a transactional client is returned.
  13631. func (m SopTaskMutation) Client() *Client {
  13632. client := &Client{config: m.config}
  13633. client.init()
  13634. return client
  13635. }
  13636. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13637. // it returns an error otherwise.
  13638. func (m SopTaskMutation) Tx() (*Tx, error) {
  13639. if _, ok := m.driver.(*txDriver); !ok {
  13640. return nil, errors.New("ent: mutation is not running in a transaction")
  13641. }
  13642. tx := &Tx{config: m.config}
  13643. tx.init()
  13644. return tx, nil
  13645. }
  13646. // SetID sets the value of the id field. Note that this
  13647. // operation is only accepted on creation of SopTask entities.
  13648. func (m *SopTaskMutation) SetID(id uint64) {
  13649. m.id = &id
  13650. }
  13651. // ID returns the ID value in the mutation. Note that the ID is only available
  13652. // if it was provided to the builder or after it was returned from the database.
  13653. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  13654. if m.id == nil {
  13655. return
  13656. }
  13657. return *m.id, true
  13658. }
  13659. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13660. // That means, if the mutation is applied within a transaction with an isolation level such
  13661. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13662. // or updated by the mutation.
  13663. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  13664. switch {
  13665. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13666. id, exists := m.ID()
  13667. if exists {
  13668. return []uint64{id}, nil
  13669. }
  13670. fallthrough
  13671. case m.op.Is(OpUpdate | OpDelete):
  13672. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  13673. default:
  13674. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13675. }
  13676. }
  13677. // SetCreatedAt sets the "created_at" field.
  13678. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  13679. m.created_at = &t
  13680. }
  13681. // CreatedAt returns the value of the "created_at" field in the mutation.
  13682. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  13683. v := m.created_at
  13684. if v == nil {
  13685. return
  13686. }
  13687. return *v, true
  13688. }
  13689. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  13690. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  13691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13692. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13693. if !m.op.Is(OpUpdateOne) {
  13694. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13695. }
  13696. if m.id == nil || m.oldValue == nil {
  13697. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13698. }
  13699. oldValue, err := m.oldValue(ctx)
  13700. if err != nil {
  13701. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13702. }
  13703. return oldValue.CreatedAt, nil
  13704. }
  13705. // ResetCreatedAt resets all changes to the "created_at" field.
  13706. func (m *SopTaskMutation) ResetCreatedAt() {
  13707. m.created_at = nil
  13708. }
  13709. // SetUpdatedAt sets the "updated_at" field.
  13710. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  13711. m.updated_at = &t
  13712. }
  13713. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13714. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  13715. v := m.updated_at
  13716. if v == nil {
  13717. return
  13718. }
  13719. return *v, true
  13720. }
  13721. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  13722. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  13723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13724. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13725. if !m.op.Is(OpUpdateOne) {
  13726. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13727. }
  13728. if m.id == nil || m.oldValue == nil {
  13729. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13730. }
  13731. oldValue, err := m.oldValue(ctx)
  13732. if err != nil {
  13733. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13734. }
  13735. return oldValue.UpdatedAt, nil
  13736. }
  13737. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13738. func (m *SopTaskMutation) ResetUpdatedAt() {
  13739. m.updated_at = nil
  13740. }
  13741. // SetStatus sets the "status" field.
  13742. func (m *SopTaskMutation) SetStatus(u uint8) {
  13743. m.status = &u
  13744. m.addstatus = nil
  13745. }
  13746. // Status returns the value of the "status" field in the mutation.
  13747. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  13748. v := m.status
  13749. if v == nil {
  13750. return
  13751. }
  13752. return *v, true
  13753. }
  13754. // OldStatus returns the old "status" field's value of the SopTask entity.
  13755. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  13756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13757. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13758. if !m.op.Is(OpUpdateOne) {
  13759. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13760. }
  13761. if m.id == nil || m.oldValue == nil {
  13762. return v, errors.New("OldStatus requires an ID field in the mutation")
  13763. }
  13764. oldValue, err := m.oldValue(ctx)
  13765. if err != nil {
  13766. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13767. }
  13768. return oldValue.Status, nil
  13769. }
  13770. // AddStatus adds u to the "status" field.
  13771. func (m *SopTaskMutation) AddStatus(u int8) {
  13772. if m.addstatus != nil {
  13773. *m.addstatus += u
  13774. } else {
  13775. m.addstatus = &u
  13776. }
  13777. }
  13778. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13779. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  13780. v := m.addstatus
  13781. if v == nil {
  13782. return
  13783. }
  13784. return *v, true
  13785. }
  13786. // ClearStatus clears the value of the "status" field.
  13787. func (m *SopTaskMutation) ClearStatus() {
  13788. m.status = nil
  13789. m.addstatus = nil
  13790. m.clearedFields[soptask.FieldStatus] = struct{}{}
  13791. }
  13792. // StatusCleared returns if the "status" field was cleared in this mutation.
  13793. func (m *SopTaskMutation) StatusCleared() bool {
  13794. _, ok := m.clearedFields[soptask.FieldStatus]
  13795. return ok
  13796. }
  13797. // ResetStatus resets all changes to the "status" field.
  13798. func (m *SopTaskMutation) ResetStatus() {
  13799. m.status = nil
  13800. m.addstatus = nil
  13801. delete(m.clearedFields, soptask.FieldStatus)
  13802. }
  13803. // SetDeletedAt sets the "deleted_at" field.
  13804. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  13805. m.deleted_at = &t
  13806. }
  13807. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13808. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  13809. v := m.deleted_at
  13810. if v == nil {
  13811. return
  13812. }
  13813. return *v, true
  13814. }
  13815. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  13816. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  13817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13818. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13819. if !m.op.Is(OpUpdateOne) {
  13820. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13821. }
  13822. if m.id == nil || m.oldValue == nil {
  13823. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13824. }
  13825. oldValue, err := m.oldValue(ctx)
  13826. if err != nil {
  13827. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13828. }
  13829. return oldValue.DeletedAt, nil
  13830. }
  13831. // ClearDeletedAt clears the value of the "deleted_at" field.
  13832. func (m *SopTaskMutation) ClearDeletedAt() {
  13833. m.deleted_at = nil
  13834. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  13835. }
  13836. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13837. func (m *SopTaskMutation) DeletedAtCleared() bool {
  13838. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  13839. return ok
  13840. }
  13841. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13842. func (m *SopTaskMutation) ResetDeletedAt() {
  13843. m.deleted_at = nil
  13844. delete(m.clearedFields, soptask.FieldDeletedAt)
  13845. }
  13846. // SetName sets the "name" field.
  13847. func (m *SopTaskMutation) SetName(s string) {
  13848. m.name = &s
  13849. }
  13850. // Name returns the value of the "name" field in the mutation.
  13851. func (m *SopTaskMutation) Name() (r string, exists bool) {
  13852. v := m.name
  13853. if v == nil {
  13854. return
  13855. }
  13856. return *v, true
  13857. }
  13858. // OldName returns the old "name" field's value of the SopTask entity.
  13859. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  13860. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13861. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  13862. if !m.op.Is(OpUpdateOne) {
  13863. return v, errors.New("OldName is only allowed on UpdateOne operations")
  13864. }
  13865. if m.id == nil || m.oldValue == nil {
  13866. return v, errors.New("OldName requires an ID field in the mutation")
  13867. }
  13868. oldValue, err := m.oldValue(ctx)
  13869. if err != nil {
  13870. return v, fmt.Errorf("querying old value for OldName: %w", err)
  13871. }
  13872. return oldValue.Name, nil
  13873. }
  13874. // ResetName resets all changes to the "name" field.
  13875. func (m *SopTaskMutation) ResetName() {
  13876. m.name = nil
  13877. }
  13878. // SetBotWxidList sets the "bot_wxid_list" field.
  13879. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  13880. m.bot_wxid_list = &s
  13881. m.appendbot_wxid_list = nil
  13882. }
  13883. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  13884. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  13885. v := m.bot_wxid_list
  13886. if v == nil {
  13887. return
  13888. }
  13889. return *v, true
  13890. }
  13891. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  13892. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  13893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13894. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  13895. if !m.op.Is(OpUpdateOne) {
  13896. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  13897. }
  13898. if m.id == nil || m.oldValue == nil {
  13899. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  13900. }
  13901. oldValue, err := m.oldValue(ctx)
  13902. if err != nil {
  13903. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  13904. }
  13905. return oldValue.BotWxidList, nil
  13906. }
  13907. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  13908. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  13909. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  13910. }
  13911. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  13912. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  13913. if len(m.appendbot_wxid_list) == 0 {
  13914. return nil, false
  13915. }
  13916. return m.appendbot_wxid_list, true
  13917. }
  13918. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  13919. func (m *SopTaskMutation) ClearBotWxidList() {
  13920. m.bot_wxid_list = nil
  13921. m.appendbot_wxid_list = nil
  13922. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  13923. }
  13924. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  13925. func (m *SopTaskMutation) BotWxidListCleared() bool {
  13926. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  13927. return ok
  13928. }
  13929. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  13930. func (m *SopTaskMutation) ResetBotWxidList() {
  13931. m.bot_wxid_list = nil
  13932. m.appendbot_wxid_list = nil
  13933. delete(m.clearedFields, soptask.FieldBotWxidList)
  13934. }
  13935. // SetType sets the "type" field.
  13936. func (m *SopTaskMutation) SetType(i int) {
  13937. m._type = &i
  13938. m.add_type = nil
  13939. }
  13940. // GetType returns the value of the "type" field in the mutation.
  13941. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  13942. v := m._type
  13943. if v == nil {
  13944. return
  13945. }
  13946. return *v, true
  13947. }
  13948. // OldType returns the old "type" field's value of the SopTask entity.
  13949. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  13950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13951. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  13952. if !m.op.Is(OpUpdateOne) {
  13953. return v, errors.New("OldType is only allowed on UpdateOne operations")
  13954. }
  13955. if m.id == nil || m.oldValue == nil {
  13956. return v, errors.New("OldType requires an ID field in the mutation")
  13957. }
  13958. oldValue, err := m.oldValue(ctx)
  13959. if err != nil {
  13960. return v, fmt.Errorf("querying old value for OldType: %w", err)
  13961. }
  13962. return oldValue.Type, nil
  13963. }
  13964. // AddType adds i to the "type" field.
  13965. func (m *SopTaskMutation) AddType(i int) {
  13966. if m.add_type != nil {
  13967. *m.add_type += i
  13968. } else {
  13969. m.add_type = &i
  13970. }
  13971. }
  13972. // AddedType returns the value that was added to the "type" field in this mutation.
  13973. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  13974. v := m.add_type
  13975. if v == nil {
  13976. return
  13977. }
  13978. return *v, true
  13979. }
  13980. // ResetType resets all changes to the "type" field.
  13981. func (m *SopTaskMutation) ResetType() {
  13982. m._type = nil
  13983. m.add_type = nil
  13984. }
  13985. // SetPlanStartTime sets the "plan_start_time" field.
  13986. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  13987. m.plan_start_time = &t
  13988. }
  13989. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  13990. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  13991. v := m.plan_start_time
  13992. if v == nil {
  13993. return
  13994. }
  13995. return *v, true
  13996. }
  13997. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  13998. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  13999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14000. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  14001. if !m.op.Is(OpUpdateOne) {
  14002. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  14003. }
  14004. if m.id == nil || m.oldValue == nil {
  14005. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  14006. }
  14007. oldValue, err := m.oldValue(ctx)
  14008. if err != nil {
  14009. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  14010. }
  14011. return oldValue.PlanStartTime, nil
  14012. }
  14013. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  14014. func (m *SopTaskMutation) ClearPlanStartTime() {
  14015. m.plan_start_time = nil
  14016. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  14017. }
  14018. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  14019. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  14020. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  14021. return ok
  14022. }
  14023. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  14024. func (m *SopTaskMutation) ResetPlanStartTime() {
  14025. m.plan_start_time = nil
  14026. delete(m.clearedFields, soptask.FieldPlanStartTime)
  14027. }
  14028. // SetPlanEndTime sets the "plan_end_time" field.
  14029. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  14030. m.plan_end_time = &t
  14031. }
  14032. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  14033. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  14034. v := m.plan_end_time
  14035. if v == nil {
  14036. return
  14037. }
  14038. return *v, true
  14039. }
  14040. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  14041. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14043. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  14044. if !m.op.Is(OpUpdateOne) {
  14045. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  14046. }
  14047. if m.id == nil || m.oldValue == nil {
  14048. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  14049. }
  14050. oldValue, err := m.oldValue(ctx)
  14051. if err != nil {
  14052. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  14053. }
  14054. return oldValue.PlanEndTime, nil
  14055. }
  14056. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  14057. func (m *SopTaskMutation) ClearPlanEndTime() {
  14058. m.plan_end_time = nil
  14059. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  14060. }
  14061. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  14062. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  14063. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  14064. return ok
  14065. }
  14066. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  14067. func (m *SopTaskMutation) ResetPlanEndTime() {
  14068. m.plan_end_time = nil
  14069. delete(m.clearedFields, soptask.FieldPlanEndTime)
  14070. }
  14071. // SetCreatorID sets the "creator_id" field.
  14072. func (m *SopTaskMutation) SetCreatorID(s string) {
  14073. m.creator_id = &s
  14074. }
  14075. // CreatorID returns the value of the "creator_id" field in the mutation.
  14076. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  14077. v := m.creator_id
  14078. if v == nil {
  14079. return
  14080. }
  14081. return *v, true
  14082. }
  14083. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  14084. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14086. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  14087. if !m.op.Is(OpUpdateOne) {
  14088. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  14089. }
  14090. if m.id == nil || m.oldValue == nil {
  14091. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  14092. }
  14093. oldValue, err := m.oldValue(ctx)
  14094. if err != nil {
  14095. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  14096. }
  14097. return oldValue.CreatorID, nil
  14098. }
  14099. // ClearCreatorID clears the value of the "creator_id" field.
  14100. func (m *SopTaskMutation) ClearCreatorID() {
  14101. m.creator_id = nil
  14102. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  14103. }
  14104. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  14105. func (m *SopTaskMutation) CreatorIDCleared() bool {
  14106. _, ok := m.clearedFields[soptask.FieldCreatorID]
  14107. return ok
  14108. }
  14109. // ResetCreatorID resets all changes to the "creator_id" field.
  14110. func (m *SopTaskMutation) ResetCreatorID() {
  14111. m.creator_id = nil
  14112. delete(m.clearedFields, soptask.FieldCreatorID)
  14113. }
  14114. // SetOrganizationID sets the "organization_id" field.
  14115. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  14116. m.organization_id = &u
  14117. m.addorganization_id = nil
  14118. }
  14119. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14120. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  14121. v := m.organization_id
  14122. if v == nil {
  14123. return
  14124. }
  14125. return *v, true
  14126. }
  14127. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  14128. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14130. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14131. if !m.op.Is(OpUpdateOne) {
  14132. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14133. }
  14134. if m.id == nil || m.oldValue == nil {
  14135. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14136. }
  14137. oldValue, err := m.oldValue(ctx)
  14138. if err != nil {
  14139. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14140. }
  14141. return oldValue.OrganizationID, nil
  14142. }
  14143. // AddOrganizationID adds u to the "organization_id" field.
  14144. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  14145. if m.addorganization_id != nil {
  14146. *m.addorganization_id += u
  14147. } else {
  14148. m.addorganization_id = &u
  14149. }
  14150. }
  14151. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14152. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  14153. v := m.addorganization_id
  14154. if v == nil {
  14155. return
  14156. }
  14157. return *v, true
  14158. }
  14159. // ClearOrganizationID clears the value of the "organization_id" field.
  14160. func (m *SopTaskMutation) ClearOrganizationID() {
  14161. m.organization_id = nil
  14162. m.addorganization_id = nil
  14163. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  14164. }
  14165. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14166. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  14167. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  14168. return ok
  14169. }
  14170. // ResetOrganizationID resets all changes to the "organization_id" field.
  14171. func (m *SopTaskMutation) ResetOrganizationID() {
  14172. m.organization_id = nil
  14173. m.addorganization_id = nil
  14174. delete(m.clearedFields, soptask.FieldOrganizationID)
  14175. }
  14176. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  14177. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  14178. if m.task_stages == nil {
  14179. m.task_stages = make(map[uint64]struct{})
  14180. }
  14181. for i := range ids {
  14182. m.task_stages[ids[i]] = struct{}{}
  14183. }
  14184. }
  14185. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  14186. func (m *SopTaskMutation) ClearTaskStages() {
  14187. m.clearedtask_stages = true
  14188. }
  14189. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  14190. func (m *SopTaskMutation) TaskStagesCleared() bool {
  14191. return m.clearedtask_stages
  14192. }
  14193. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  14194. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  14195. if m.removedtask_stages == nil {
  14196. m.removedtask_stages = make(map[uint64]struct{})
  14197. }
  14198. for i := range ids {
  14199. delete(m.task_stages, ids[i])
  14200. m.removedtask_stages[ids[i]] = struct{}{}
  14201. }
  14202. }
  14203. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  14204. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  14205. for id := range m.removedtask_stages {
  14206. ids = append(ids, id)
  14207. }
  14208. return
  14209. }
  14210. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  14211. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  14212. for id := range m.task_stages {
  14213. ids = append(ids, id)
  14214. }
  14215. return
  14216. }
  14217. // ResetTaskStages resets all changes to the "task_stages" edge.
  14218. func (m *SopTaskMutation) ResetTaskStages() {
  14219. m.task_stages = nil
  14220. m.clearedtask_stages = false
  14221. m.removedtask_stages = nil
  14222. }
  14223. // Where appends a list predicates to the SopTaskMutation builder.
  14224. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  14225. m.predicates = append(m.predicates, ps...)
  14226. }
  14227. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  14228. // users can use type-assertion to append predicates that do not depend on any generated package.
  14229. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  14230. p := make([]predicate.SopTask, len(ps))
  14231. for i := range ps {
  14232. p[i] = ps[i]
  14233. }
  14234. m.Where(p...)
  14235. }
  14236. // Op returns the operation name.
  14237. func (m *SopTaskMutation) Op() Op {
  14238. return m.op
  14239. }
  14240. // SetOp allows setting the mutation operation.
  14241. func (m *SopTaskMutation) SetOp(op Op) {
  14242. m.op = op
  14243. }
  14244. // Type returns the node type of this mutation (SopTask).
  14245. func (m *SopTaskMutation) Type() string {
  14246. return m.typ
  14247. }
  14248. // Fields returns all fields that were changed during this mutation. Note that in
  14249. // order to get all numeric fields that were incremented/decremented, call
  14250. // AddedFields().
  14251. func (m *SopTaskMutation) Fields() []string {
  14252. fields := make([]string, 0, 11)
  14253. if m.created_at != nil {
  14254. fields = append(fields, soptask.FieldCreatedAt)
  14255. }
  14256. if m.updated_at != nil {
  14257. fields = append(fields, soptask.FieldUpdatedAt)
  14258. }
  14259. if m.status != nil {
  14260. fields = append(fields, soptask.FieldStatus)
  14261. }
  14262. if m.deleted_at != nil {
  14263. fields = append(fields, soptask.FieldDeletedAt)
  14264. }
  14265. if m.name != nil {
  14266. fields = append(fields, soptask.FieldName)
  14267. }
  14268. if m.bot_wxid_list != nil {
  14269. fields = append(fields, soptask.FieldBotWxidList)
  14270. }
  14271. if m._type != nil {
  14272. fields = append(fields, soptask.FieldType)
  14273. }
  14274. if m.plan_start_time != nil {
  14275. fields = append(fields, soptask.FieldPlanStartTime)
  14276. }
  14277. if m.plan_end_time != nil {
  14278. fields = append(fields, soptask.FieldPlanEndTime)
  14279. }
  14280. if m.creator_id != nil {
  14281. fields = append(fields, soptask.FieldCreatorID)
  14282. }
  14283. if m.organization_id != nil {
  14284. fields = append(fields, soptask.FieldOrganizationID)
  14285. }
  14286. return fields
  14287. }
  14288. // Field returns the value of a field with the given name. The second boolean
  14289. // return value indicates that this field was not set, or was not defined in the
  14290. // schema.
  14291. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  14292. switch name {
  14293. case soptask.FieldCreatedAt:
  14294. return m.CreatedAt()
  14295. case soptask.FieldUpdatedAt:
  14296. return m.UpdatedAt()
  14297. case soptask.FieldStatus:
  14298. return m.Status()
  14299. case soptask.FieldDeletedAt:
  14300. return m.DeletedAt()
  14301. case soptask.FieldName:
  14302. return m.Name()
  14303. case soptask.FieldBotWxidList:
  14304. return m.BotWxidList()
  14305. case soptask.FieldType:
  14306. return m.GetType()
  14307. case soptask.FieldPlanStartTime:
  14308. return m.PlanStartTime()
  14309. case soptask.FieldPlanEndTime:
  14310. return m.PlanEndTime()
  14311. case soptask.FieldCreatorID:
  14312. return m.CreatorID()
  14313. case soptask.FieldOrganizationID:
  14314. return m.OrganizationID()
  14315. }
  14316. return nil, false
  14317. }
  14318. // OldField returns the old value of the field from the database. An error is
  14319. // returned if the mutation operation is not UpdateOne, or the query to the
  14320. // database failed.
  14321. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14322. switch name {
  14323. case soptask.FieldCreatedAt:
  14324. return m.OldCreatedAt(ctx)
  14325. case soptask.FieldUpdatedAt:
  14326. return m.OldUpdatedAt(ctx)
  14327. case soptask.FieldStatus:
  14328. return m.OldStatus(ctx)
  14329. case soptask.FieldDeletedAt:
  14330. return m.OldDeletedAt(ctx)
  14331. case soptask.FieldName:
  14332. return m.OldName(ctx)
  14333. case soptask.FieldBotWxidList:
  14334. return m.OldBotWxidList(ctx)
  14335. case soptask.FieldType:
  14336. return m.OldType(ctx)
  14337. case soptask.FieldPlanStartTime:
  14338. return m.OldPlanStartTime(ctx)
  14339. case soptask.FieldPlanEndTime:
  14340. return m.OldPlanEndTime(ctx)
  14341. case soptask.FieldCreatorID:
  14342. return m.OldCreatorID(ctx)
  14343. case soptask.FieldOrganizationID:
  14344. return m.OldOrganizationID(ctx)
  14345. }
  14346. return nil, fmt.Errorf("unknown SopTask field %s", name)
  14347. }
  14348. // SetField sets the value of a field with the given name. It returns an error if
  14349. // the field is not defined in the schema, or if the type mismatched the field
  14350. // type.
  14351. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  14352. switch name {
  14353. case soptask.FieldCreatedAt:
  14354. v, ok := value.(time.Time)
  14355. if !ok {
  14356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14357. }
  14358. m.SetCreatedAt(v)
  14359. return nil
  14360. case soptask.FieldUpdatedAt:
  14361. v, ok := value.(time.Time)
  14362. if !ok {
  14363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14364. }
  14365. m.SetUpdatedAt(v)
  14366. return nil
  14367. case soptask.FieldStatus:
  14368. v, ok := value.(uint8)
  14369. if !ok {
  14370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14371. }
  14372. m.SetStatus(v)
  14373. return nil
  14374. case soptask.FieldDeletedAt:
  14375. v, ok := value.(time.Time)
  14376. if !ok {
  14377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14378. }
  14379. m.SetDeletedAt(v)
  14380. return nil
  14381. case soptask.FieldName:
  14382. v, ok := value.(string)
  14383. if !ok {
  14384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14385. }
  14386. m.SetName(v)
  14387. return nil
  14388. case soptask.FieldBotWxidList:
  14389. v, ok := value.([]string)
  14390. if !ok {
  14391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14392. }
  14393. m.SetBotWxidList(v)
  14394. return nil
  14395. case soptask.FieldType:
  14396. v, ok := value.(int)
  14397. if !ok {
  14398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14399. }
  14400. m.SetType(v)
  14401. return nil
  14402. case soptask.FieldPlanStartTime:
  14403. v, ok := value.(time.Time)
  14404. if !ok {
  14405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14406. }
  14407. m.SetPlanStartTime(v)
  14408. return nil
  14409. case soptask.FieldPlanEndTime:
  14410. v, ok := value.(time.Time)
  14411. if !ok {
  14412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14413. }
  14414. m.SetPlanEndTime(v)
  14415. return nil
  14416. case soptask.FieldCreatorID:
  14417. v, ok := value.(string)
  14418. if !ok {
  14419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14420. }
  14421. m.SetCreatorID(v)
  14422. return nil
  14423. case soptask.FieldOrganizationID:
  14424. v, ok := value.(uint64)
  14425. if !ok {
  14426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14427. }
  14428. m.SetOrganizationID(v)
  14429. return nil
  14430. }
  14431. return fmt.Errorf("unknown SopTask field %s", name)
  14432. }
  14433. // AddedFields returns all numeric fields that were incremented/decremented during
  14434. // this mutation.
  14435. func (m *SopTaskMutation) AddedFields() []string {
  14436. var fields []string
  14437. if m.addstatus != nil {
  14438. fields = append(fields, soptask.FieldStatus)
  14439. }
  14440. if m.add_type != nil {
  14441. fields = append(fields, soptask.FieldType)
  14442. }
  14443. if m.addorganization_id != nil {
  14444. fields = append(fields, soptask.FieldOrganizationID)
  14445. }
  14446. return fields
  14447. }
  14448. // AddedField returns the numeric value that was incremented/decremented on a field
  14449. // with the given name. The second boolean return value indicates that this field
  14450. // was not set, or was not defined in the schema.
  14451. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  14452. switch name {
  14453. case soptask.FieldStatus:
  14454. return m.AddedStatus()
  14455. case soptask.FieldType:
  14456. return m.AddedType()
  14457. case soptask.FieldOrganizationID:
  14458. return m.AddedOrganizationID()
  14459. }
  14460. return nil, false
  14461. }
  14462. // AddField adds the value to the field with the given name. It returns an error if
  14463. // the field is not defined in the schema, or if the type mismatched the field
  14464. // type.
  14465. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  14466. switch name {
  14467. case soptask.FieldStatus:
  14468. v, ok := value.(int8)
  14469. if !ok {
  14470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14471. }
  14472. m.AddStatus(v)
  14473. return nil
  14474. case soptask.FieldType:
  14475. v, ok := value.(int)
  14476. if !ok {
  14477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14478. }
  14479. m.AddType(v)
  14480. return nil
  14481. case soptask.FieldOrganizationID:
  14482. v, ok := value.(int64)
  14483. if !ok {
  14484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14485. }
  14486. m.AddOrganizationID(v)
  14487. return nil
  14488. }
  14489. return fmt.Errorf("unknown SopTask numeric field %s", name)
  14490. }
  14491. // ClearedFields returns all nullable fields that were cleared during this
  14492. // mutation.
  14493. func (m *SopTaskMutation) ClearedFields() []string {
  14494. var fields []string
  14495. if m.FieldCleared(soptask.FieldStatus) {
  14496. fields = append(fields, soptask.FieldStatus)
  14497. }
  14498. if m.FieldCleared(soptask.FieldDeletedAt) {
  14499. fields = append(fields, soptask.FieldDeletedAt)
  14500. }
  14501. if m.FieldCleared(soptask.FieldBotWxidList) {
  14502. fields = append(fields, soptask.FieldBotWxidList)
  14503. }
  14504. if m.FieldCleared(soptask.FieldPlanStartTime) {
  14505. fields = append(fields, soptask.FieldPlanStartTime)
  14506. }
  14507. if m.FieldCleared(soptask.FieldPlanEndTime) {
  14508. fields = append(fields, soptask.FieldPlanEndTime)
  14509. }
  14510. if m.FieldCleared(soptask.FieldCreatorID) {
  14511. fields = append(fields, soptask.FieldCreatorID)
  14512. }
  14513. if m.FieldCleared(soptask.FieldOrganizationID) {
  14514. fields = append(fields, soptask.FieldOrganizationID)
  14515. }
  14516. return fields
  14517. }
  14518. // FieldCleared returns a boolean indicating if a field with the given name was
  14519. // cleared in this mutation.
  14520. func (m *SopTaskMutation) FieldCleared(name string) bool {
  14521. _, ok := m.clearedFields[name]
  14522. return ok
  14523. }
  14524. // ClearField clears the value of the field with the given name. It returns an
  14525. // error if the field is not defined in the schema.
  14526. func (m *SopTaskMutation) ClearField(name string) error {
  14527. switch name {
  14528. case soptask.FieldStatus:
  14529. m.ClearStatus()
  14530. return nil
  14531. case soptask.FieldDeletedAt:
  14532. m.ClearDeletedAt()
  14533. return nil
  14534. case soptask.FieldBotWxidList:
  14535. m.ClearBotWxidList()
  14536. return nil
  14537. case soptask.FieldPlanStartTime:
  14538. m.ClearPlanStartTime()
  14539. return nil
  14540. case soptask.FieldPlanEndTime:
  14541. m.ClearPlanEndTime()
  14542. return nil
  14543. case soptask.FieldCreatorID:
  14544. m.ClearCreatorID()
  14545. return nil
  14546. case soptask.FieldOrganizationID:
  14547. m.ClearOrganizationID()
  14548. return nil
  14549. }
  14550. return fmt.Errorf("unknown SopTask nullable field %s", name)
  14551. }
  14552. // ResetField resets all changes in the mutation for the field with the given name.
  14553. // It returns an error if the field is not defined in the schema.
  14554. func (m *SopTaskMutation) ResetField(name string) error {
  14555. switch name {
  14556. case soptask.FieldCreatedAt:
  14557. m.ResetCreatedAt()
  14558. return nil
  14559. case soptask.FieldUpdatedAt:
  14560. m.ResetUpdatedAt()
  14561. return nil
  14562. case soptask.FieldStatus:
  14563. m.ResetStatus()
  14564. return nil
  14565. case soptask.FieldDeletedAt:
  14566. m.ResetDeletedAt()
  14567. return nil
  14568. case soptask.FieldName:
  14569. m.ResetName()
  14570. return nil
  14571. case soptask.FieldBotWxidList:
  14572. m.ResetBotWxidList()
  14573. return nil
  14574. case soptask.FieldType:
  14575. m.ResetType()
  14576. return nil
  14577. case soptask.FieldPlanStartTime:
  14578. m.ResetPlanStartTime()
  14579. return nil
  14580. case soptask.FieldPlanEndTime:
  14581. m.ResetPlanEndTime()
  14582. return nil
  14583. case soptask.FieldCreatorID:
  14584. m.ResetCreatorID()
  14585. return nil
  14586. case soptask.FieldOrganizationID:
  14587. m.ResetOrganizationID()
  14588. return nil
  14589. }
  14590. return fmt.Errorf("unknown SopTask field %s", name)
  14591. }
  14592. // AddedEdges returns all edge names that were set/added in this mutation.
  14593. func (m *SopTaskMutation) AddedEdges() []string {
  14594. edges := make([]string, 0, 1)
  14595. if m.task_stages != nil {
  14596. edges = append(edges, soptask.EdgeTaskStages)
  14597. }
  14598. return edges
  14599. }
  14600. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14601. // name in this mutation.
  14602. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  14603. switch name {
  14604. case soptask.EdgeTaskStages:
  14605. ids := make([]ent.Value, 0, len(m.task_stages))
  14606. for id := range m.task_stages {
  14607. ids = append(ids, id)
  14608. }
  14609. return ids
  14610. }
  14611. return nil
  14612. }
  14613. // RemovedEdges returns all edge names that were removed in this mutation.
  14614. func (m *SopTaskMutation) RemovedEdges() []string {
  14615. edges := make([]string, 0, 1)
  14616. if m.removedtask_stages != nil {
  14617. edges = append(edges, soptask.EdgeTaskStages)
  14618. }
  14619. return edges
  14620. }
  14621. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14622. // the given name in this mutation.
  14623. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  14624. switch name {
  14625. case soptask.EdgeTaskStages:
  14626. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  14627. for id := range m.removedtask_stages {
  14628. ids = append(ids, id)
  14629. }
  14630. return ids
  14631. }
  14632. return nil
  14633. }
  14634. // ClearedEdges returns all edge names that were cleared in this mutation.
  14635. func (m *SopTaskMutation) ClearedEdges() []string {
  14636. edges := make([]string, 0, 1)
  14637. if m.clearedtask_stages {
  14638. edges = append(edges, soptask.EdgeTaskStages)
  14639. }
  14640. return edges
  14641. }
  14642. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14643. // was cleared in this mutation.
  14644. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  14645. switch name {
  14646. case soptask.EdgeTaskStages:
  14647. return m.clearedtask_stages
  14648. }
  14649. return false
  14650. }
  14651. // ClearEdge clears the value of the edge with the given name. It returns an error
  14652. // if that edge is not defined in the schema.
  14653. func (m *SopTaskMutation) ClearEdge(name string) error {
  14654. switch name {
  14655. }
  14656. return fmt.Errorf("unknown SopTask unique edge %s", name)
  14657. }
  14658. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14659. // It returns an error if the edge is not defined in the schema.
  14660. func (m *SopTaskMutation) ResetEdge(name string) error {
  14661. switch name {
  14662. case soptask.EdgeTaskStages:
  14663. m.ResetTaskStages()
  14664. return nil
  14665. }
  14666. return fmt.Errorf("unknown SopTask edge %s", name)
  14667. }
  14668. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  14669. type TokenMutation struct {
  14670. config
  14671. op Op
  14672. typ string
  14673. id *uint64
  14674. created_at *time.Time
  14675. updated_at *time.Time
  14676. deleted_at *time.Time
  14677. expire_at *time.Time
  14678. token *string
  14679. mac *string
  14680. clearedFields map[string]struct{}
  14681. done bool
  14682. oldValue func(context.Context) (*Token, error)
  14683. predicates []predicate.Token
  14684. }
  14685. var _ ent.Mutation = (*TokenMutation)(nil)
  14686. // tokenOption allows management of the mutation configuration using functional options.
  14687. type tokenOption func(*TokenMutation)
  14688. // newTokenMutation creates new mutation for the Token entity.
  14689. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  14690. m := &TokenMutation{
  14691. config: c,
  14692. op: op,
  14693. typ: TypeToken,
  14694. clearedFields: make(map[string]struct{}),
  14695. }
  14696. for _, opt := range opts {
  14697. opt(m)
  14698. }
  14699. return m
  14700. }
  14701. // withTokenID sets the ID field of the mutation.
  14702. func withTokenID(id uint64) tokenOption {
  14703. return func(m *TokenMutation) {
  14704. var (
  14705. err error
  14706. once sync.Once
  14707. value *Token
  14708. )
  14709. m.oldValue = func(ctx context.Context) (*Token, error) {
  14710. once.Do(func() {
  14711. if m.done {
  14712. err = errors.New("querying old values post mutation is not allowed")
  14713. } else {
  14714. value, err = m.Client().Token.Get(ctx, id)
  14715. }
  14716. })
  14717. return value, err
  14718. }
  14719. m.id = &id
  14720. }
  14721. }
  14722. // withToken sets the old Token of the mutation.
  14723. func withToken(node *Token) tokenOption {
  14724. return func(m *TokenMutation) {
  14725. m.oldValue = func(context.Context) (*Token, error) {
  14726. return node, nil
  14727. }
  14728. m.id = &node.ID
  14729. }
  14730. }
  14731. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14732. // executed in a transaction (ent.Tx), a transactional client is returned.
  14733. func (m TokenMutation) Client() *Client {
  14734. client := &Client{config: m.config}
  14735. client.init()
  14736. return client
  14737. }
  14738. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14739. // it returns an error otherwise.
  14740. func (m TokenMutation) Tx() (*Tx, error) {
  14741. if _, ok := m.driver.(*txDriver); !ok {
  14742. return nil, errors.New("ent: mutation is not running in a transaction")
  14743. }
  14744. tx := &Tx{config: m.config}
  14745. tx.init()
  14746. return tx, nil
  14747. }
  14748. // SetID sets the value of the id field. Note that this
  14749. // operation is only accepted on creation of Token entities.
  14750. func (m *TokenMutation) SetID(id uint64) {
  14751. m.id = &id
  14752. }
  14753. // ID returns the ID value in the mutation. Note that the ID is only available
  14754. // if it was provided to the builder or after it was returned from the database.
  14755. func (m *TokenMutation) ID() (id uint64, exists bool) {
  14756. if m.id == nil {
  14757. return
  14758. }
  14759. return *m.id, true
  14760. }
  14761. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14762. // That means, if the mutation is applied within a transaction with an isolation level such
  14763. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14764. // or updated by the mutation.
  14765. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  14766. switch {
  14767. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14768. id, exists := m.ID()
  14769. if exists {
  14770. return []uint64{id}, nil
  14771. }
  14772. fallthrough
  14773. case m.op.Is(OpUpdate | OpDelete):
  14774. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  14775. default:
  14776. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14777. }
  14778. }
  14779. // SetCreatedAt sets the "created_at" field.
  14780. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  14781. m.created_at = &t
  14782. }
  14783. // CreatedAt returns the value of the "created_at" field in the mutation.
  14784. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  14785. v := m.created_at
  14786. if v == nil {
  14787. return
  14788. }
  14789. return *v, true
  14790. }
  14791. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  14792. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  14793. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14794. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14795. if !m.op.Is(OpUpdateOne) {
  14796. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14797. }
  14798. if m.id == nil || m.oldValue == nil {
  14799. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14800. }
  14801. oldValue, err := m.oldValue(ctx)
  14802. if err != nil {
  14803. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14804. }
  14805. return oldValue.CreatedAt, nil
  14806. }
  14807. // ResetCreatedAt resets all changes to the "created_at" field.
  14808. func (m *TokenMutation) ResetCreatedAt() {
  14809. m.created_at = nil
  14810. }
  14811. // SetUpdatedAt sets the "updated_at" field.
  14812. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  14813. m.updated_at = &t
  14814. }
  14815. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14816. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  14817. v := m.updated_at
  14818. if v == nil {
  14819. return
  14820. }
  14821. return *v, true
  14822. }
  14823. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  14824. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  14825. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14826. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14827. if !m.op.Is(OpUpdateOne) {
  14828. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14829. }
  14830. if m.id == nil || m.oldValue == nil {
  14831. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14832. }
  14833. oldValue, err := m.oldValue(ctx)
  14834. if err != nil {
  14835. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14836. }
  14837. return oldValue.UpdatedAt, nil
  14838. }
  14839. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14840. func (m *TokenMutation) ResetUpdatedAt() {
  14841. m.updated_at = nil
  14842. }
  14843. // SetDeletedAt sets the "deleted_at" field.
  14844. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  14845. m.deleted_at = &t
  14846. }
  14847. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14848. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  14849. v := m.deleted_at
  14850. if v == nil {
  14851. return
  14852. }
  14853. return *v, true
  14854. }
  14855. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  14856. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  14857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14858. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14859. if !m.op.Is(OpUpdateOne) {
  14860. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14861. }
  14862. if m.id == nil || m.oldValue == nil {
  14863. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14864. }
  14865. oldValue, err := m.oldValue(ctx)
  14866. if err != nil {
  14867. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14868. }
  14869. return oldValue.DeletedAt, nil
  14870. }
  14871. // ClearDeletedAt clears the value of the "deleted_at" field.
  14872. func (m *TokenMutation) ClearDeletedAt() {
  14873. m.deleted_at = nil
  14874. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  14875. }
  14876. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14877. func (m *TokenMutation) DeletedAtCleared() bool {
  14878. _, ok := m.clearedFields[token.FieldDeletedAt]
  14879. return ok
  14880. }
  14881. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14882. func (m *TokenMutation) ResetDeletedAt() {
  14883. m.deleted_at = nil
  14884. delete(m.clearedFields, token.FieldDeletedAt)
  14885. }
  14886. // SetExpireAt sets the "expire_at" field.
  14887. func (m *TokenMutation) SetExpireAt(t time.Time) {
  14888. m.expire_at = &t
  14889. }
  14890. // ExpireAt returns the value of the "expire_at" field in the mutation.
  14891. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  14892. v := m.expire_at
  14893. if v == nil {
  14894. return
  14895. }
  14896. return *v, true
  14897. }
  14898. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  14899. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  14900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14901. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  14902. if !m.op.Is(OpUpdateOne) {
  14903. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  14904. }
  14905. if m.id == nil || m.oldValue == nil {
  14906. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  14907. }
  14908. oldValue, err := m.oldValue(ctx)
  14909. if err != nil {
  14910. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  14911. }
  14912. return oldValue.ExpireAt, nil
  14913. }
  14914. // ClearExpireAt clears the value of the "expire_at" field.
  14915. func (m *TokenMutation) ClearExpireAt() {
  14916. m.expire_at = nil
  14917. m.clearedFields[token.FieldExpireAt] = struct{}{}
  14918. }
  14919. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  14920. func (m *TokenMutation) ExpireAtCleared() bool {
  14921. _, ok := m.clearedFields[token.FieldExpireAt]
  14922. return ok
  14923. }
  14924. // ResetExpireAt resets all changes to the "expire_at" field.
  14925. func (m *TokenMutation) ResetExpireAt() {
  14926. m.expire_at = nil
  14927. delete(m.clearedFields, token.FieldExpireAt)
  14928. }
  14929. // SetToken sets the "token" field.
  14930. func (m *TokenMutation) SetToken(s string) {
  14931. m.token = &s
  14932. }
  14933. // Token returns the value of the "token" field in the mutation.
  14934. func (m *TokenMutation) Token() (r string, exists bool) {
  14935. v := m.token
  14936. if v == nil {
  14937. return
  14938. }
  14939. return *v, true
  14940. }
  14941. // OldToken returns the old "token" field's value of the Token entity.
  14942. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  14943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14944. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  14945. if !m.op.Is(OpUpdateOne) {
  14946. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  14947. }
  14948. if m.id == nil || m.oldValue == nil {
  14949. return v, errors.New("OldToken requires an ID field in the mutation")
  14950. }
  14951. oldValue, err := m.oldValue(ctx)
  14952. if err != nil {
  14953. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  14954. }
  14955. return oldValue.Token, nil
  14956. }
  14957. // ClearToken clears the value of the "token" field.
  14958. func (m *TokenMutation) ClearToken() {
  14959. m.token = nil
  14960. m.clearedFields[token.FieldToken] = struct{}{}
  14961. }
  14962. // TokenCleared returns if the "token" field was cleared in this mutation.
  14963. func (m *TokenMutation) TokenCleared() bool {
  14964. _, ok := m.clearedFields[token.FieldToken]
  14965. return ok
  14966. }
  14967. // ResetToken resets all changes to the "token" field.
  14968. func (m *TokenMutation) ResetToken() {
  14969. m.token = nil
  14970. delete(m.clearedFields, token.FieldToken)
  14971. }
  14972. // SetMAC sets the "mac" field.
  14973. func (m *TokenMutation) SetMAC(s string) {
  14974. m.mac = &s
  14975. }
  14976. // MAC returns the value of the "mac" field in the mutation.
  14977. func (m *TokenMutation) MAC() (r string, exists bool) {
  14978. v := m.mac
  14979. if v == nil {
  14980. return
  14981. }
  14982. return *v, true
  14983. }
  14984. // OldMAC returns the old "mac" field's value of the Token entity.
  14985. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  14986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14987. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  14988. if !m.op.Is(OpUpdateOne) {
  14989. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  14990. }
  14991. if m.id == nil || m.oldValue == nil {
  14992. return v, errors.New("OldMAC requires an ID field in the mutation")
  14993. }
  14994. oldValue, err := m.oldValue(ctx)
  14995. if err != nil {
  14996. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  14997. }
  14998. return oldValue.MAC, nil
  14999. }
  15000. // ResetMAC resets all changes to the "mac" field.
  15001. func (m *TokenMutation) ResetMAC() {
  15002. m.mac = nil
  15003. }
  15004. // Where appends a list predicates to the TokenMutation builder.
  15005. func (m *TokenMutation) Where(ps ...predicate.Token) {
  15006. m.predicates = append(m.predicates, ps...)
  15007. }
  15008. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  15009. // users can use type-assertion to append predicates that do not depend on any generated package.
  15010. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  15011. p := make([]predicate.Token, len(ps))
  15012. for i := range ps {
  15013. p[i] = ps[i]
  15014. }
  15015. m.Where(p...)
  15016. }
  15017. // Op returns the operation name.
  15018. func (m *TokenMutation) Op() Op {
  15019. return m.op
  15020. }
  15021. // SetOp allows setting the mutation operation.
  15022. func (m *TokenMutation) SetOp(op Op) {
  15023. m.op = op
  15024. }
  15025. // Type returns the node type of this mutation (Token).
  15026. func (m *TokenMutation) Type() string {
  15027. return m.typ
  15028. }
  15029. // Fields returns all fields that were changed during this mutation. Note that in
  15030. // order to get all numeric fields that were incremented/decremented, call
  15031. // AddedFields().
  15032. func (m *TokenMutation) Fields() []string {
  15033. fields := make([]string, 0, 6)
  15034. if m.created_at != nil {
  15035. fields = append(fields, token.FieldCreatedAt)
  15036. }
  15037. if m.updated_at != nil {
  15038. fields = append(fields, token.FieldUpdatedAt)
  15039. }
  15040. if m.deleted_at != nil {
  15041. fields = append(fields, token.FieldDeletedAt)
  15042. }
  15043. if m.expire_at != nil {
  15044. fields = append(fields, token.FieldExpireAt)
  15045. }
  15046. if m.token != nil {
  15047. fields = append(fields, token.FieldToken)
  15048. }
  15049. if m.mac != nil {
  15050. fields = append(fields, token.FieldMAC)
  15051. }
  15052. return fields
  15053. }
  15054. // Field returns the value of a field with the given name. The second boolean
  15055. // return value indicates that this field was not set, or was not defined in the
  15056. // schema.
  15057. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  15058. switch name {
  15059. case token.FieldCreatedAt:
  15060. return m.CreatedAt()
  15061. case token.FieldUpdatedAt:
  15062. return m.UpdatedAt()
  15063. case token.FieldDeletedAt:
  15064. return m.DeletedAt()
  15065. case token.FieldExpireAt:
  15066. return m.ExpireAt()
  15067. case token.FieldToken:
  15068. return m.Token()
  15069. case token.FieldMAC:
  15070. return m.MAC()
  15071. }
  15072. return nil, false
  15073. }
  15074. // OldField returns the old value of the field from the database. An error is
  15075. // returned if the mutation operation is not UpdateOne, or the query to the
  15076. // database failed.
  15077. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15078. switch name {
  15079. case token.FieldCreatedAt:
  15080. return m.OldCreatedAt(ctx)
  15081. case token.FieldUpdatedAt:
  15082. return m.OldUpdatedAt(ctx)
  15083. case token.FieldDeletedAt:
  15084. return m.OldDeletedAt(ctx)
  15085. case token.FieldExpireAt:
  15086. return m.OldExpireAt(ctx)
  15087. case token.FieldToken:
  15088. return m.OldToken(ctx)
  15089. case token.FieldMAC:
  15090. return m.OldMAC(ctx)
  15091. }
  15092. return nil, fmt.Errorf("unknown Token field %s", name)
  15093. }
  15094. // SetField sets the value of a field with the given name. It returns an error if
  15095. // the field is not defined in the schema, or if the type mismatched the field
  15096. // type.
  15097. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  15098. switch name {
  15099. case token.FieldCreatedAt:
  15100. v, ok := value.(time.Time)
  15101. if !ok {
  15102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15103. }
  15104. m.SetCreatedAt(v)
  15105. return nil
  15106. case token.FieldUpdatedAt:
  15107. v, ok := value.(time.Time)
  15108. if !ok {
  15109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15110. }
  15111. m.SetUpdatedAt(v)
  15112. return nil
  15113. case token.FieldDeletedAt:
  15114. v, ok := value.(time.Time)
  15115. if !ok {
  15116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15117. }
  15118. m.SetDeletedAt(v)
  15119. return nil
  15120. case token.FieldExpireAt:
  15121. v, ok := value.(time.Time)
  15122. if !ok {
  15123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15124. }
  15125. m.SetExpireAt(v)
  15126. return nil
  15127. case token.FieldToken:
  15128. v, ok := value.(string)
  15129. if !ok {
  15130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15131. }
  15132. m.SetToken(v)
  15133. return nil
  15134. case token.FieldMAC:
  15135. v, ok := value.(string)
  15136. if !ok {
  15137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15138. }
  15139. m.SetMAC(v)
  15140. return nil
  15141. }
  15142. return fmt.Errorf("unknown Token field %s", name)
  15143. }
  15144. // AddedFields returns all numeric fields that were incremented/decremented during
  15145. // this mutation.
  15146. func (m *TokenMutation) AddedFields() []string {
  15147. return nil
  15148. }
  15149. // AddedField returns the numeric value that was incremented/decremented on a field
  15150. // with the given name. The second boolean return value indicates that this field
  15151. // was not set, or was not defined in the schema.
  15152. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  15153. return nil, false
  15154. }
  15155. // AddField adds the value to the field with the given name. It returns an error if
  15156. // the field is not defined in the schema, or if the type mismatched the field
  15157. // type.
  15158. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  15159. switch name {
  15160. }
  15161. return fmt.Errorf("unknown Token numeric field %s", name)
  15162. }
  15163. // ClearedFields returns all nullable fields that were cleared during this
  15164. // mutation.
  15165. func (m *TokenMutation) ClearedFields() []string {
  15166. var fields []string
  15167. if m.FieldCleared(token.FieldDeletedAt) {
  15168. fields = append(fields, token.FieldDeletedAt)
  15169. }
  15170. if m.FieldCleared(token.FieldExpireAt) {
  15171. fields = append(fields, token.FieldExpireAt)
  15172. }
  15173. if m.FieldCleared(token.FieldToken) {
  15174. fields = append(fields, token.FieldToken)
  15175. }
  15176. return fields
  15177. }
  15178. // FieldCleared returns a boolean indicating if a field with the given name was
  15179. // cleared in this mutation.
  15180. func (m *TokenMutation) FieldCleared(name string) bool {
  15181. _, ok := m.clearedFields[name]
  15182. return ok
  15183. }
  15184. // ClearField clears the value of the field with the given name. It returns an
  15185. // error if the field is not defined in the schema.
  15186. func (m *TokenMutation) ClearField(name string) error {
  15187. switch name {
  15188. case token.FieldDeletedAt:
  15189. m.ClearDeletedAt()
  15190. return nil
  15191. case token.FieldExpireAt:
  15192. m.ClearExpireAt()
  15193. return nil
  15194. case token.FieldToken:
  15195. m.ClearToken()
  15196. return nil
  15197. }
  15198. return fmt.Errorf("unknown Token nullable field %s", name)
  15199. }
  15200. // ResetField resets all changes in the mutation for the field with the given name.
  15201. // It returns an error if the field is not defined in the schema.
  15202. func (m *TokenMutation) ResetField(name string) error {
  15203. switch name {
  15204. case token.FieldCreatedAt:
  15205. m.ResetCreatedAt()
  15206. return nil
  15207. case token.FieldUpdatedAt:
  15208. m.ResetUpdatedAt()
  15209. return nil
  15210. case token.FieldDeletedAt:
  15211. m.ResetDeletedAt()
  15212. return nil
  15213. case token.FieldExpireAt:
  15214. m.ResetExpireAt()
  15215. return nil
  15216. case token.FieldToken:
  15217. m.ResetToken()
  15218. return nil
  15219. case token.FieldMAC:
  15220. m.ResetMAC()
  15221. return nil
  15222. }
  15223. return fmt.Errorf("unknown Token field %s", name)
  15224. }
  15225. // AddedEdges returns all edge names that were set/added in this mutation.
  15226. func (m *TokenMutation) AddedEdges() []string {
  15227. edges := make([]string, 0, 0)
  15228. return edges
  15229. }
  15230. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15231. // name in this mutation.
  15232. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  15233. return nil
  15234. }
  15235. // RemovedEdges returns all edge names that were removed in this mutation.
  15236. func (m *TokenMutation) RemovedEdges() []string {
  15237. edges := make([]string, 0, 0)
  15238. return edges
  15239. }
  15240. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15241. // the given name in this mutation.
  15242. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  15243. return nil
  15244. }
  15245. // ClearedEdges returns all edge names that were cleared in this mutation.
  15246. func (m *TokenMutation) ClearedEdges() []string {
  15247. edges := make([]string, 0, 0)
  15248. return edges
  15249. }
  15250. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15251. // was cleared in this mutation.
  15252. func (m *TokenMutation) EdgeCleared(name string) bool {
  15253. return false
  15254. }
  15255. // ClearEdge clears the value of the edge with the given name. It returns an error
  15256. // if that edge is not defined in the schema.
  15257. func (m *TokenMutation) ClearEdge(name string) error {
  15258. return fmt.Errorf("unknown Token unique edge %s", name)
  15259. }
  15260. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15261. // It returns an error if the edge is not defined in the schema.
  15262. func (m *TokenMutation) ResetEdge(name string) error {
  15263. return fmt.Errorf("unknown Token edge %s", name)
  15264. }
  15265. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  15266. type TutorialMutation struct {
  15267. config
  15268. op Op
  15269. typ string
  15270. id *uint64
  15271. created_at *time.Time
  15272. updated_at *time.Time
  15273. deleted_at *time.Time
  15274. index *int
  15275. addindex *int
  15276. title *string
  15277. content *string
  15278. organization_id *uint64
  15279. addorganization_id *int64
  15280. clearedFields map[string]struct{}
  15281. employee *uint64
  15282. clearedemployee bool
  15283. done bool
  15284. oldValue func(context.Context) (*Tutorial, error)
  15285. predicates []predicate.Tutorial
  15286. }
  15287. var _ ent.Mutation = (*TutorialMutation)(nil)
  15288. // tutorialOption allows management of the mutation configuration using functional options.
  15289. type tutorialOption func(*TutorialMutation)
  15290. // newTutorialMutation creates new mutation for the Tutorial entity.
  15291. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  15292. m := &TutorialMutation{
  15293. config: c,
  15294. op: op,
  15295. typ: TypeTutorial,
  15296. clearedFields: make(map[string]struct{}),
  15297. }
  15298. for _, opt := range opts {
  15299. opt(m)
  15300. }
  15301. return m
  15302. }
  15303. // withTutorialID sets the ID field of the mutation.
  15304. func withTutorialID(id uint64) tutorialOption {
  15305. return func(m *TutorialMutation) {
  15306. var (
  15307. err error
  15308. once sync.Once
  15309. value *Tutorial
  15310. )
  15311. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  15312. once.Do(func() {
  15313. if m.done {
  15314. err = errors.New("querying old values post mutation is not allowed")
  15315. } else {
  15316. value, err = m.Client().Tutorial.Get(ctx, id)
  15317. }
  15318. })
  15319. return value, err
  15320. }
  15321. m.id = &id
  15322. }
  15323. }
  15324. // withTutorial sets the old Tutorial of the mutation.
  15325. func withTutorial(node *Tutorial) tutorialOption {
  15326. return func(m *TutorialMutation) {
  15327. m.oldValue = func(context.Context) (*Tutorial, error) {
  15328. return node, nil
  15329. }
  15330. m.id = &node.ID
  15331. }
  15332. }
  15333. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15334. // executed in a transaction (ent.Tx), a transactional client is returned.
  15335. func (m TutorialMutation) Client() *Client {
  15336. client := &Client{config: m.config}
  15337. client.init()
  15338. return client
  15339. }
  15340. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15341. // it returns an error otherwise.
  15342. func (m TutorialMutation) Tx() (*Tx, error) {
  15343. if _, ok := m.driver.(*txDriver); !ok {
  15344. return nil, errors.New("ent: mutation is not running in a transaction")
  15345. }
  15346. tx := &Tx{config: m.config}
  15347. tx.init()
  15348. return tx, nil
  15349. }
  15350. // SetID sets the value of the id field. Note that this
  15351. // operation is only accepted on creation of Tutorial entities.
  15352. func (m *TutorialMutation) SetID(id uint64) {
  15353. m.id = &id
  15354. }
  15355. // ID returns the ID value in the mutation. Note that the ID is only available
  15356. // if it was provided to the builder or after it was returned from the database.
  15357. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  15358. if m.id == nil {
  15359. return
  15360. }
  15361. return *m.id, true
  15362. }
  15363. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15364. // That means, if the mutation is applied within a transaction with an isolation level such
  15365. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15366. // or updated by the mutation.
  15367. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  15368. switch {
  15369. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15370. id, exists := m.ID()
  15371. if exists {
  15372. return []uint64{id}, nil
  15373. }
  15374. fallthrough
  15375. case m.op.Is(OpUpdate | OpDelete):
  15376. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  15377. default:
  15378. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15379. }
  15380. }
  15381. // SetCreatedAt sets the "created_at" field.
  15382. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  15383. m.created_at = &t
  15384. }
  15385. // CreatedAt returns the value of the "created_at" field in the mutation.
  15386. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  15387. v := m.created_at
  15388. if v == nil {
  15389. return
  15390. }
  15391. return *v, true
  15392. }
  15393. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  15394. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  15395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15396. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15397. if !m.op.Is(OpUpdateOne) {
  15398. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15399. }
  15400. if m.id == nil || m.oldValue == nil {
  15401. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15402. }
  15403. oldValue, err := m.oldValue(ctx)
  15404. if err != nil {
  15405. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15406. }
  15407. return oldValue.CreatedAt, nil
  15408. }
  15409. // ResetCreatedAt resets all changes to the "created_at" field.
  15410. func (m *TutorialMutation) ResetCreatedAt() {
  15411. m.created_at = nil
  15412. }
  15413. // SetUpdatedAt sets the "updated_at" field.
  15414. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  15415. m.updated_at = &t
  15416. }
  15417. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15418. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  15419. v := m.updated_at
  15420. if v == nil {
  15421. return
  15422. }
  15423. return *v, true
  15424. }
  15425. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  15426. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  15427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15428. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15429. if !m.op.Is(OpUpdateOne) {
  15430. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15431. }
  15432. if m.id == nil || m.oldValue == nil {
  15433. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15434. }
  15435. oldValue, err := m.oldValue(ctx)
  15436. if err != nil {
  15437. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15438. }
  15439. return oldValue.UpdatedAt, nil
  15440. }
  15441. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15442. func (m *TutorialMutation) ResetUpdatedAt() {
  15443. m.updated_at = nil
  15444. }
  15445. // SetDeletedAt sets the "deleted_at" field.
  15446. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  15447. m.deleted_at = &t
  15448. }
  15449. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15450. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  15451. v := m.deleted_at
  15452. if v == nil {
  15453. return
  15454. }
  15455. return *v, true
  15456. }
  15457. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  15458. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  15459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15460. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15461. if !m.op.Is(OpUpdateOne) {
  15462. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15463. }
  15464. if m.id == nil || m.oldValue == nil {
  15465. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15466. }
  15467. oldValue, err := m.oldValue(ctx)
  15468. if err != nil {
  15469. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15470. }
  15471. return oldValue.DeletedAt, nil
  15472. }
  15473. // ClearDeletedAt clears the value of the "deleted_at" field.
  15474. func (m *TutorialMutation) ClearDeletedAt() {
  15475. m.deleted_at = nil
  15476. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  15477. }
  15478. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15479. func (m *TutorialMutation) DeletedAtCleared() bool {
  15480. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  15481. return ok
  15482. }
  15483. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15484. func (m *TutorialMutation) ResetDeletedAt() {
  15485. m.deleted_at = nil
  15486. delete(m.clearedFields, tutorial.FieldDeletedAt)
  15487. }
  15488. // SetEmployeeID sets the "employee_id" field.
  15489. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  15490. m.employee = &u
  15491. }
  15492. // EmployeeID returns the value of the "employee_id" field in the mutation.
  15493. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  15494. v := m.employee
  15495. if v == nil {
  15496. return
  15497. }
  15498. return *v, true
  15499. }
  15500. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  15501. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  15502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15503. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  15504. if !m.op.Is(OpUpdateOne) {
  15505. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  15506. }
  15507. if m.id == nil || m.oldValue == nil {
  15508. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  15509. }
  15510. oldValue, err := m.oldValue(ctx)
  15511. if err != nil {
  15512. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  15513. }
  15514. return oldValue.EmployeeID, nil
  15515. }
  15516. // ResetEmployeeID resets all changes to the "employee_id" field.
  15517. func (m *TutorialMutation) ResetEmployeeID() {
  15518. m.employee = nil
  15519. }
  15520. // SetIndex sets the "index" field.
  15521. func (m *TutorialMutation) SetIndex(i int) {
  15522. m.index = &i
  15523. m.addindex = nil
  15524. }
  15525. // Index returns the value of the "index" field in the mutation.
  15526. func (m *TutorialMutation) Index() (r int, exists bool) {
  15527. v := m.index
  15528. if v == nil {
  15529. return
  15530. }
  15531. return *v, true
  15532. }
  15533. // OldIndex returns the old "index" field's value of the Tutorial entity.
  15534. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  15535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15536. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  15537. if !m.op.Is(OpUpdateOne) {
  15538. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  15539. }
  15540. if m.id == nil || m.oldValue == nil {
  15541. return v, errors.New("OldIndex requires an ID field in the mutation")
  15542. }
  15543. oldValue, err := m.oldValue(ctx)
  15544. if err != nil {
  15545. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  15546. }
  15547. return oldValue.Index, nil
  15548. }
  15549. // AddIndex adds i to the "index" field.
  15550. func (m *TutorialMutation) AddIndex(i int) {
  15551. if m.addindex != nil {
  15552. *m.addindex += i
  15553. } else {
  15554. m.addindex = &i
  15555. }
  15556. }
  15557. // AddedIndex returns the value that was added to the "index" field in this mutation.
  15558. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  15559. v := m.addindex
  15560. if v == nil {
  15561. return
  15562. }
  15563. return *v, true
  15564. }
  15565. // ResetIndex resets all changes to the "index" field.
  15566. func (m *TutorialMutation) ResetIndex() {
  15567. m.index = nil
  15568. m.addindex = nil
  15569. }
  15570. // SetTitle sets the "title" field.
  15571. func (m *TutorialMutation) SetTitle(s string) {
  15572. m.title = &s
  15573. }
  15574. // Title returns the value of the "title" field in the mutation.
  15575. func (m *TutorialMutation) Title() (r string, exists bool) {
  15576. v := m.title
  15577. if v == nil {
  15578. return
  15579. }
  15580. return *v, true
  15581. }
  15582. // OldTitle returns the old "title" field's value of the Tutorial entity.
  15583. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  15584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15585. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  15586. if !m.op.Is(OpUpdateOne) {
  15587. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  15588. }
  15589. if m.id == nil || m.oldValue == nil {
  15590. return v, errors.New("OldTitle requires an ID field in the mutation")
  15591. }
  15592. oldValue, err := m.oldValue(ctx)
  15593. if err != nil {
  15594. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  15595. }
  15596. return oldValue.Title, nil
  15597. }
  15598. // ResetTitle resets all changes to the "title" field.
  15599. func (m *TutorialMutation) ResetTitle() {
  15600. m.title = nil
  15601. }
  15602. // SetContent sets the "content" field.
  15603. func (m *TutorialMutation) SetContent(s string) {
  15604. m.content = &s
  15605. }
  15606. // Content returns the value of the "content" field in the mutation.
  15607. func (m *TutorialMutation) Content() (r string, exists bool) {
  15608. v := m.content
  15609. if v == nil {
  15610. return
  15611. }
  15612. return *v, true
  15613. }
  15614. // OldContent returns the old "content" field's value of the Tutorial entity.
  15615. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  15616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15617. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  15618. if !m.op.Is(OpUpdateOne) {
  15619. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  15620. }
  15621. if m.id == nil || m.oldValue == nil {
  15622. return v, errors.New("OldContent requires an ID field in the mutation")
  15623. }
  15624. oldValue, err := m.oldValue(ctx)
  15625. if err != nil {
  15626. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  15627. }
  15628. return oldValue.Content, nil
  15629. }
  15630. // ResetContent resets all changes to the "content" field.
  15631. func (m *TutorialMutation) ResetContent() {
  15632. m.content = nil
  15633. }
  15634. // SetOrganizationID sets the "organization_id" field.
  15635. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  15636. m.organization_id = &u
  15637. m.addorganization_id = nil
  15638. }
  15639. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15640. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  15641. v := m.organization_id
  15642. if v == nil {
  15643. return
  15644. }
  15645. return *v, true
  15646. }
  15647. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  15648. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  15649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15650. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15651. if !m.op.Is(OpUpdateOne) {
  15652. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15653. }
  15654. if m.id == nil || m.oldValue == nil {
  15655. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15656. }
  15657. oldValue, err := m.oldValue(ctx)
  15658. if err != nil {
  15659. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15660. }
  15661. return oldValue.OrganizationID, nil
  15662. }
  15663. // AddOrganizationID adds u to the "organization_id" field.
  15664. func (m *TutorialMutation) AddOrganizationID(u int64) {
  15665. if m.addorganization_id != nil {
  15666. *m.addorganization_id += u
  15667. } else {
  15668. m.addorganization_id = &u
  15669. }
  15670. }
  15671. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15672. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  15673. v := m.addorganization_id
  15674. if v == nil {
  15675. return
  15676. }
  15677. return *v, true
  15678. }
  15679. // ResetOrganizationID resets all changes to the "organization_id" field.
  15680. func (m *TutorialMutation) ResetOrganizationID() {
  15681. m.organization_id = nil
  15682. m.addorganization_id = nil
  15683. }
  15684. // ClearEmployee clears the "employee" edge to the Employee entity.
  15685. func (m *TutorialMutation) ClearEmployee() {
  15686. m.clearedemployee = true
  15687. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  15688. }
  15689. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  15690. func (m *TutorialMutation) EmployeeCleared() bool {
  15691. return m.clearedemployee
  15692. }
  15693. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  15694. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15695. // EmployeeID instead. It exists only for internal usage by the builders.
  15696. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  15697. if id := m.employee; id != nil {
  15698. ids = append(ids, *id)
  15699. }
  15700. return
  15701. }
  15702. // ResetEmployee resets all changes to the "employee" edge.
  15703. func (m *TutorialMutation) ResetEmployee() {
  15704. m.employee = nil
  15705. m.clearedemployee = false
  15706. }
  15707. // Where appends a list predicates to the TutorialMutation builder.
  15708. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  15709. m.predicates = append(m.predicates, ps...)
  15710. }
  15711. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  15712. // users can use type-assertion to append predicates that do not depend on any generated package.
  15713. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  15714. p := make([]predicate.Tutorial, len(ps))
  15715. for i := range ps {
  15716. p[i] = ps[i]
  15717. }
  15718. m.Where(p...)
  15719. }
  15720. // Op returns the operation name.
  15721. func (m *TutorialMutation) Op() Op {
  15722. return m.op
  15723. }
  15724. // SetOp allows setting the mutation operation.
  15725. func (m *TutorialMutation) SetOp(op Op) {
  15726. m.op = op
  15727. }
  15728. // Type returns the node type of this mutation (Tutorial).
  15729. func (m *TutorialMutation) Type() string {
  15730. return m.typ
  15731. }
  15732. // Fields returns all fields that were changed during this mutation. Note that in
  15733. // order to get all numeric fields that were incremented/decremented, call
  15734. // AddedFields().
  15735. func (m *TutorialMutation) Fields() []string {
  15736. fields := make([]string, 0, 8)
  15737. if m.created_at != nil {
  15738. fields = append(fields, tutorial.FieldCreatedAt)
  15739. }
  15740. if m.updated_at != nil {
  15741. fields = append(fields, tutorial.FieldUpdatedAt)
  15742. }
  15743. if m.deleted_at != nil {
  15744. fields = append(fields, tutorial.FieldDeletedAt)
  15745. }
  15746. if m.employee != nil {
  15747. fields = append(fields, tutorial.FieldEmployeeID)
  15748. }
  15749. if m.index != nil {
  15750. fields = append(fields, tutorial.FieldIndex)
  15751. }
  15752. if m.title != nil {
  15753. fields = append(fields, tutorial.FieldTitle)
  15754. }
  15755. if m.content != nil {
  15756. fields = append(fields, tutorial.FieldContent)
  15757. }
  15758. if m.organization_id != nil {
  15759. fields = append(fields, tutorial.FieldOrganizationID)
  15760. }
  15761. return fields
  15762. }
  15763. // Field returns the value of a field with the given name. The second boolean
  15764. // return value indicates that this field was not set, or was not defined in the
  15765. // schema.
  15766. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  15767. switch name {
  15768. case tutorial.FieldCreatedAt:
  15769. return m.CreatedAt()
  15770. case tutorial.FieldUpdatedAt:
  15771. return m.UpdatedAt()
  15772. case tutorial.FieldDeletedAt:
  15773. return m.DeletedAt()
  15774. case tutorial.FieldEmployeeID:
  15775. return m.EmployeeID()
  15776. case tutorial.FieldIndex:
  15777. return m.Index()
  15778. case tutorial.FieldTitle:
  15779. return m.Title()
  15780. case tutorial.FieldContent:
  15781. return m.Content()
  15782. case tutorial.FieldOrganizationID:
  15783. return m.OrganizationID()
  15784. }
  15785. return nil, false
  15786. }
  15787. // OldField returns the old value of the field from the database. An error is
  15788. // returned if the mutation operation is not UpdateOne, or the query to the
  15789. // database failed.
  15790. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15791. switch name {
  15792. case tutorial.FieldCreatedAt:
  15793. return m.OldCreatedAt(ctx)
  15794. case tutorial.FieldUpdatedAt:
  15795. return m.OldUpdatedAt(ctx)
  15796. case tutorial.FieldDeletedAt:
  15797. return m.OldDeletedAt(ctx)
  15798. case tutorial.FieldEmployeeID:
  15799. return m.OldEmployeeID(ctx)
  15800. case tutorial.FieldIndex:
  15801. return m.OldIndex(ctx)
  15802. case tutorial.FieldTitle:
  15803. return m.OldTitle(ctx)
  15804. case tutorial.FieldContent:
  15805. return m.OldContent(ctx)
  15806. case tutorial.FieldOrganizationID:
  15807. return m.OldOrganizationID(ctx)
  15808. }
  15809. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  15810. }
  15811. // SetField sets the value of a field with the given name. It returns an error if
  15812. // the field is not defined in the schema, or if the type mismatched the field
  15813. // type.
  15814. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  15815. switch name {
  15816. case tutorial.FieldCreatedAt:
  15817. v, ok := value.(time.Time)
  15818. if !ok {
  15819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15820. }
  15821. m.SetCreatedAt(v)
  15822. return nil
  15823. case tutorial.FieldUpdatedAt:
  15824. v, ok := value.(time.Time)
  15825. if !ok {
  15826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15827. }
  15828. m.SetUpdatedAt(v)
  15829. return nil
  15830. case tutorial.FieldDeletedAt:
  15831. v, ok := value.(time.Time)
  15832. if !ok {
  15833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15834. }
  15835. m.SetDeletedAt(v)
  15836. return nil
  15837. case tutorial.FieldEmployeeID:
  15838. v, ok := value.(uint64)
  15839. if !ok {
  15840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15841. }
  15842. m.SetEmployeeID(v)
  15843. return nil
  15844. case tutorial.FieldIndex:
  15845. v, ok := value.(int)
  15846. if !ok {
  15847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15848. }
  15849. m.SetIndex(v)
  15850. return nil
  15851. case tutorial.FieldTitle:
  15852. v, ok := value.(string)
  15853. if !ok {
  15854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15855. }
  15856. m.SetTitle(v)
  15857. return nil
  15858. case tutorial.FieldContent:
  15859. v, ok := value.(string)
  15860. if !ok {
  15861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15862. }
  15863. m.SetContent(v)
  15864. return nil
  15865. case tutorial.FieldOrganizationID:
  15866. v, ok := value.(uint64)
  15867. if !ok {
  15868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15869. }
  15870. m.SetOrganizationID(v)
  15871. return nil
  15872. }
  15873. return fmt.Errorf("unknown Tutorial field %s", name)
  15874. }
  15875. // AddedFields returns all numeric fields that were incremented/decremented during
  15876. // this mutation.
  15877. func (m *TutorialMutation) AddedFields() []string {
  15878. var fields []string
  15879. if m.addindex != nil {
  15880. fields = append(fields, tutorial.FieldIndex)
  15881. }
  15882. if m.addorganization_id != nil {
  15883. fields = append(fields, tutorial.FieldOrganizationID)
  15884. }
  15885. return fields
  15886. }
  15887. // AddedField returns the numeric value that was incremented/decremented on a field
  15888. // with the given name. The second boolean return value indicates that this field
  15889. // was not set, or was not defined in the schema.
  15890. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  15891. switch name {
  15892. case tutorial.FieldIndex:
  15893. return m.AddedIndex()
  15894. case tutorial.FieldOrganizationID:
  15895. return m.AddedOrganizationID()
  15896. }
  15897. return nil, false
  15898. }
  15899. // AddField adds the value to the field with the given name. It returns an error if
  15900. // the field is not defined in the schema, or if the type mismatched the field
  15901. // type.
  15902. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  15903. switch name {
  15904. case tutorial.FieldIndex:
  15905. v, ok := value.(int)
  15906. if !ok {
  15907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15908. }
  15909. m.AddIndex(v)
  15910. return nil
  15911. case tutorial.FieldOrganizationID:
  15912. v, ok := value.(int64)
  15913. if !ok {
  15914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15915. }
  15916. m.AddOrganizationID(v)
  15917. return nil
  15918. }
  15919. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  15920. }
  15921. // ClearedFields returns all nullable fields that were cleared during this
  15922. // mutation.
  15923. func (m *TutorialMutation) ClearedFields() []string {
  15924. var fields []string
  15925. if m.FieldCleared(tutorial.FieldDeletedAt) {
  15926. fields = append(fields, tutorial.FieldDeletedAt)
  15927. }
  15928. return fields
  15929. }
  15930. // FieldCleared returns a boolean indicating if a field with the given name was
  15931. // cleared in this mutation.
  15932. func (m *TutorialMutation) FieldCleared(name string) bool {
  15933. _, ok := m.clearedFields[name]
  15934. return ok
  15935. }
  15936. // ClearField clears the value of the field with the given name. It returns an
  15937. // error if the field is not defined in the schema.
  15938. func (m *TutorialMutation) ClearField(name string) error {
  15939. switch name {
  15940. case tutorial.FieldDeletedAt:
  15941. m.ClearDeletedAt()
  15942. return nil
  15943. }
  15944. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  15945. }
  15946. // ResetField resets all changes in the mutation for the field with the given name.
  15947. // It returns an error if the field is not defined in the schema.
  15948. func (m *TutorialMutation) ResetField(name string) error {
  15949. switch name {
  15950. case tutorial.FieldCreatedAt:
  15951. m.ResetCreatedAt()
  15952. return nil
  15953. case tutorial.FieldUpdatedAt:
  15954. m.ResetUpdatedAt()
  15955. return nil
  15956. case tutorial.FieldDeletedAt:
  15957. m.ResetDeletedAt()
  15958. return nil
  15959. case tutorial.FieldEmployeeID:
  15960. m.ResetEmployeeID()
  15961. return nil
  15962. case tutorial.FieldIndex:
  15963. m.ResetIndex()
  15964. return nil
  15965. case tutorial.FieldTitle:
  15966. m.ResetTitle()
  15967. return nil
  15968. case tutorial.FieldContent:
  15969. m.ResetContent()
  15970. return nil
  15971. case tutorial.FieldOrganizationID:
  15972. m.ResetOrganizationID()
  15973. return nil
  15974. }
  15975. return fmt.Errorf("unknown Tutorial field %s", name)
  15976. }
  15977. // AddedEdges returns all edge names that were set/added in this mutation.
  15978. func (m *TutorialMutation) AddedEdges() []string {
  15979. edges := make([]string, 0, 1)
  15980. if m.employee != nil {
  15981. edges = append(edges, tutorial.EdgeEmployee)
  15982. }
  15983. return edges
  15984. }
  15985. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15986. // name in this mutation.
  15987. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  15988. switch name {
  15989. case tutorial.EdgeEmployee:
  15990. if id := m.employee; id != nil {
  15991. return []ent.Value{*id}
  15992. }
  15993. }
  15994. return nil
  15995. }
  15996. // RemovedEdges returns all edge names that were removed in this mutation.
  15997. func (m *TutorialMutation) RemovedEdges() []string {
  15998. edges := make([]string, 0, 1)
  15999. return edges
  16000. }
  16001. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16002. // the given name in this mutation.
  16003. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  16004. return nil
  16005. }
  16006. // ClearedEdges returns all edge names that were cleared in this mutation.
  16007. func (m *TutorialMutation) ClearedEdges() []string {
  16008. edges := make([]string, 0, 1)
  16009. if m.clearedemployee {
  16010. edges = append(edges, tutorial.EdgeEmployee)
  16011. }
  16012. return edges
  16013. }
  16014. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16015. // was cleared in this mutation.
  16016. func (m *TutorialMutation) EdgeCleared(name string) bool {
  16017. switch name {
  16018. case tutorial.EdgeEmployee:
  16019. return m.clearedemployee
  16020. }
  16021. return false
  16022. }
  16023. // ClearEdge clears the value of the edge with the given name. It returns an error
  16024. // if that edge is not defined in the schema.
  16025. func (m *TutorialMutation) ClearEdge(name string) error {
  16026. switch name {
  16027. case tutorial.EdgeEmployee:
  16028. m.ClearEmployee()
  16029. return nil
  16030. }
  16031. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  16032. }
  16033. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16034. // It returns an error if the edge is not defined in the schema.
  16035. func (m *TutorialMutation) ResetEdge(name string) error {
  16036. switch name {
  16037. case tutorial.EdgeEmployee:
  16038. m.ResetEmployee()
  16039. return nil
  16040. }
  16041. return fmt.Errorf("unknown Tutorial edge %s", name)
  16042. }
  16043. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  16044. type WorkExperienceMutation struct {
  16045. config
  16046. op Op
  16047. typ string
  16048. id *uint64
  16049. created_at *time.Time
  16050. updated_at *time.Time
  16051. deleted_at *time.Time
  16052. start_date *time.Time
  16053. end_date *time.Time
  16054. company *string
  16055. experience *string
  16056. organization_id *uint64
  16057. addorganization_id *int64
  16058. clearedFields map[string]struct{}
  16059. employee *uint64
  16060. clearedemployee bool
  16061. done bool
  16062. oldValue func(context.Context) (*WorkExperience, error)
  16063. predicates []predicate.WorkExperience
  16064. }
  16065. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  16066. // workexperienceOption allows management of the mutation configuration using functional options.
  16067. type workexperienceOption func(*WorkExperienceMutation)
  16068. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  16069. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  16070. m := &WorkExperienceMutation{
  16071. config: c,
  16072. op: op,
  16073. typ: TypeWorkExperience,
  16074. clearedFields: make(map[string]struct{}),
  16075. }
  16076. for _, opt := range opts {
  16077. opt(m)
  16078. }
  16079. return m
  16080. }
  16081. // withWorkExperienceID sets the ID field of the mutation.
  16082. func withWorkExperienceID(id uint64) workexperienceOption {
  16083. return func(m *WorkExperienceMutation) {
  16084. var (
  16085. err error
  16086. once sync.Once
  16087. value *WorkExperience
  16088. )
  16089. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  16090. once.Do(func() {
  16091. if m.done {
  16092. err = errors.New("querying old values post mutation is not allowed")
  16093. } else {
  16094. value, err = m.Client().WorkExperience.Get(ctx, id)
  16095. }
  16096. })
  16097. return value, err
  16098. }
  16099. m.id = &id
  16100. }
  16101. }
  16102. // withWorkExperience sets the old WorkExperience of the mutation.
  16103. func withWorkExperience(node *WorkExperience) workexperienceOption {
  16104. return func(m *WorkExperienceMutation) {
  16105. m.oldValue = func(context.Context) (*WorkExperience, error) {
  16106. return node, nil
  16107. }
  16108. m.id = &node.ID
  16109. }
  16110. }
  16111. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16112. // executed in a transaction (ent.Tx), a transactional client is returned.
  16113. func (m WorkExperienceMutation) Client() *Client {
  16114. client := &Client{config: m.config}
  16115. client.init()
  16116. return client
  16117. }
  16118. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16119. // it returns an error otherwise.
  16120. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  16121. if _, ok := m.driver.(*txDriver); !ok {
  16122. return nil, errors.New("ent: mutation is not running in a transaction")
  16123. }
  16124. tx := &Tx{config: m.config}
  16125. tx.init()
  16126. return tx, nil
  16127. }
  16128. // SetID sets the value of the id field. Note that this
  16129. // operation is only accepted on creation of WorkExperience entities.
  16130. func (m *WorkExperienceMutation) SetID(id uint64) {
  16131. m.id = &id
  16132. }
  16133. // ID returns the ID value in the mutation. Note that the ID is only available
  16134. // if it was provided to the builder or after it was returned from the database.
  16135. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  16136. if m.id == nil {
  16137. return
  16138. }
  16139. return *m.id, true
  16140. }
  16141. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16142. // That means, if the mutation is applied within a transaction with an isolation level such
  16143. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16144. // or updated by the mutation.
  16145. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  16146. switch {
  16147. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16148. id, exists := m.ID()
  16149. if exists {
  16150. return []uint64{id}, nil
  16151. }
  16152. fallthrough
  16153. case m.op.Is(OpUpdate | OpDelete):
  16154. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  16155. default:
  16156. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16157. }
  16158. }
  16159. // SetCreatedAt sets the "created_at" field.
  16160. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  16161. m.created_at = &t
  16162. }
  16163. // CreatedAt returns the value of the "created_at" field in the mutation.
  16164. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  16165. v := m.created_at
  16166. if v == nil {
  16167. return
  16168. }
  16169. return *v, true
  16170. }
  16171. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  16172. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16174. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16175. if !m.op.Is(OpUpdateOne) {
  16176. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16177. }
  16178. if m.id == nil || m.oldValue == nil {
  16179. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16180. }
  16181. oldValue, err := m.oldValue(ctx)
  16182. if err != nil {
  16183. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16184. }
  16185. return oldValue.CreatedAt, nil
  16186. }
  16187. // ResetCreatedAt resets all changes to the "created_at" field.
  16188. func (m *WorkExperienceMutation) ResetCreatedAt() {
  16189. m.created_at = nil
  16190. }
  16191. // SetUpdatedAt sets the "updated_at" field.
  16192. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  16193. m.updated_at = &t
  16194. }
  16195. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16196. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  16197. v := m.updated_at
  16198. if v == nil {
  16199. return
  16200. }
  16201. return *v, true
  16202. }
  16203. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  16204. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16206. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16207. if !m.op.Is(OpUpdateOne) {
  16208. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16209. }
  16210. if m.id == nil || m.oldValue == nil {
  16211. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16212. }
  16213. oldValue, err := m.oldValue(ctx)
  16214. if err != nil {
  16215. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16216. }
  16217. return oldValue.UpdatedAt, nil
  16218. }
  16219. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16220. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  16221. m.updated_at = nil
  16222. }
  16223. // SetDeletedAt sets the "deleted_at" field.
  16224. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  16225. m.deleted_at = &t
  16226. }
  16227. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16228. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  16229. v := m.deleted_at
  16230. if v == nil {
  16231. return
  16232. }
  16233. return *v, true
  16234. }
  16235. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  16236. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16238. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16239. if !m.op.Is(OpUpdateOne) {
  16240. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16241. }
  16242. if m.id == nil || m.oldValue == nil {
  16243. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16244. }
  16245. oldValue, err := m.oldValue(ctx)
  16246. if err != nil {
  16247. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16248. }
  16249. return oldValue.DeletedAt, nil
  16250. }
  16251. // ClearDeletedAt clears the value of the "deleted_at" field.
  16252. func (m *WorkExperienceMutation) ClearDeletedAt() {
  16253. m.deleted_at = nil
  16254. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  16255. }
  16256. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16257. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  16258. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  16259. return ok
  16260. }
  16261. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16262. func (m *WorkExperienceMutation) ResetDeletedAt() {
  16263. m.deleted_at = nil
  16264. delete(m.clearedFields, workexperience.FieldDeletedAt)
  16265. }
  16266. // SetEmployeeID sets the "employee_id" field.
  16267. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  16268. m.employee = &u
  16269. }
  16270. // EmployeeID returns the value of the "employee_id" field in the mutation.
  16271. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  16272. v := m.employee
  16273. if v == nil {
  16274. return
  16275. }
  16276. return *v, true
  16277. }
  16278. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  16279. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16281. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  16282. if !m.op.Is(OpUpdateOne) {
  16283. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  16284. }
  16285. if m.id == nil || m.oldValue == nil {
  16286. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  16287. }
  16288. oldValue, err := m.oldValue(ctx)
  16289. if err != nil {
  16290. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  16291. }
  16292. return oldValue.EmployeeID, nil
  16293. }
  16294. // ResetEmployeeID resets all changes to the "employee_id" field.
  16295. func (m *WorkExperienceMutation) ResetEmployeeID() {
  16296. m.employee = nil
  16297. }
  16298. // SetStartDate sets the "start_date" field.
  16299. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  16300. m.start_date = &t
  16301. }
  16302. // StartDate returns the value of the "start_date" field in the mutation.
  16303. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  16304. v := m.start_date
  16305. if v == nil {
  16306. return
  16307. }
  16308. return *v, true
  16309. }
  16310. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  16311. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16313. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  16314. if !m.op.Is(OpUpdateOne) {
  16315. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  16316. }
  16317. if m.id == nil || m.oldValue == nil {
  16318. return v, errors.New("OldStartDate requires an ID field in the mutation")
  16319. }
  16320. oldValue, err := m.oldValue(ctx)
  16321. if err != nil {
  16322. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  16323. }
  16324. return oldValue.StartDate, nil
  16325. }
  16326. // ResetStartDate resets all changes to the "start_date" field.
  16327. func (m *WorkExperienceMutation) ResetStartDate() {
  16328. m.start_date = nil
  16329. }
  16330. // SetEndDate sets the "end_date" field.
  16331. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  16332. m.end_date = &t
  16333. }
  16334. // EndDate returns the value of the "end_date" field in the mutation.
  16335. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  16336. v := m.end_date
  16337. if v == nil {
  16338. return
  16339. }
  16340. return *v, true
  16341. }
  16342. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  16343. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16345. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  16346. if !m.op.Is(OpUpdateOne) {
  16347. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  16348. }
  16349. if m.id == nil || m.oldValue == nil {
  16350. return v, errors.New("OldEndDate requires an ID field in the mutation")
  16351. }
  16352. oldValue, err := m.oldValue(ctx)
  16353. if err != nil {
  16354. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  16355. }
  16356. return oldValue.EndDate, nil
  16357. }
  16358. // ResetEndDate resets all changes to the "end_date" field.
  16359. func (m *WorkExperienceMutation) ResetEndDate() {
  16360. m.end_date = nil
  16361. }
  16362. // SetCompany sets the "company" field.
  16363. func (m *WorkExperienceMutation) SetCompany(s string) {
  16364. m.company = &s
  16365. }
  16366. // Company returns the value of the "company" field in the mutation.
  16367. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  16368. v := m.company
  16369. if v == nil {
  16370. return
  16371. }
  16372. return *v, true
  16373. }
  16374. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  16375. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16377. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  16378. if !m.op.Is(OpUpdateOne) {
  16379. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  16380. }
  16381. if m.id == nil || m.oldValue == nil {
  16382. return v, errors.New("OldCompany requires an ID field in the mutation")
  16383. }
  16384. oldValue, err := m.oldValue(ctx)
  16385. if err != nil {
  16386. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  16387. }
  16388. return oldValue.Company, nil
  16389. }
  16390. // ResetCompany resets all changes to the "company" field.
  16391. func (m *WorkExperienceMutation) ResetCompany() {
  16392. m.company = nil
  16393. }
  16394. // SetExperience sets the "experience" field.
  16395. func (m *WorkExperienceMutation) SetExperience(s string) {
  16396. m.experience = &s
  16397. }
  16398. // Experience returns the value of the "experience" field in the mutation.
  16399. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  16400. v := m.experience
  16401. if v == nil {
  16402. return
  16403. }
  16404. return *v, true
  16405. }
  16406. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  16407. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16409. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  16410. if !m.op.Is(OpUpdateOne) {
  16411. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  16412. }
  16413. if m.id == nil || m.oldValue == nil {
  16414. return v, errors.New("OldExperience requires an ID field in the mutation")
  16415. }
  16416. oldValue, err := m.oldValue(ctx)
  16417. if err != nil {
  16418. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  16419. }
  16420. return oldValue.Experience, nil
  16421. }
  16422. // ResetExperience resets all changes to the "experience" field.
  16423. func (m *WorkExperienceMutation) ResetExperience() {
  16424. m.experience = nil
  16425. }
  16426. // SetOrganizationID sets the "organization_id" field.
  16427. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  16428. m.organization_id = &u
  16429. m.addorganization_id = nil
  16430. }
  16431. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16432. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  16433. v := m.organization_id
  16434. if v == nil {
  16435. return
  16436. }
  16437. return *v, true
  16438. }
  16439. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  16440. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16442. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16443. if !m.op.Is(OpUpdateOne) {
  16444. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16445. }
  16446. if m.id == nil || m.oldValue == nil {
  16447. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16448. }
  16449. oldValue, err := m.oldValue(ctx)
  16450. if err != nil {
  16451. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16452. }
  16453. return oldValue.OrganizationID, nil
  16454. }
  16455. // AddOrganizationID adds u to the "organization_id" field.
  16456. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  16457. if m.addorganization_id != nil {
  16458. *m.addorganization_id += u
  16459. } else {
  16460. m.addorganization_id = &u
  16461. }
  16462. }
  16463. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16464. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  16465. v := m.addorganization_id
  16466. if v == nil {
  16467. return
  16468. }
  16469. return *v, true
  16470. }
  16471. // ResetOrganizationID resets all changes to the "organization_id" field.
  16472. func (m *WorkExperienceMutation) ResetOrganizationID() {
  16473. m.organization_id = nil
  16474. m.addorganization_id = nil
  16475. }
  16476. // ClearEmployee clears the "employee" edge to the Employee entity.
  16477. func (m *WorkExperienceMutation) ClearEmployee() {
  16478. m.clearedemployee = true
  16479. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  16480. }
  16481. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  16482. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  16483. return m.clearedemployee
  16484. }
  16485. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  16486. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  16487. // EmployeeID instead. It exists only for internal usage by the builders.
  16488. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  16489. if id := m.employee; id != nil {
  16490. ids = append(ids, *id)
  16491. }
  16492. return
  16493. }
  16494. // ResetEmployee resets all changes to the "employee" edge.
  16495. func (m *WorkExperienceMutation) ResetEmployee() {
  16496. m.employee = nil
  16497. m.clearedemployee = false
  16498. }
  16499. // Where appends a list predicates to the WorkExperienceMutation builder.
  16500. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  16501. m.predicates = append(m.predicates, ps...)
  16502. }
  16503. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  16504. // users can use type-assertion to append predicates that do not depend on any generated package.
  16505. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  16506. p := make([]predicate.WorkExperience, len(ps))
  16507. for i := range ps {
  16508. p[i] = ps[i]
  16509. }
  16510. m.Where(p...)
  16511. }
  16512. // Op returns the operation name.
  16513. func (m *WorkExperienceMutation) Op() Op {
  16514. return m.op
  16515. }
  16516. // SetOp allows setting the mutation operation.
  16517. func (m *WorkExperienceMutation) SetOp(op Op) {
  16518. m.op = op
  16519. }
  16520. // Type returns the node type of this mutation (WorkExperience).
  16521. func (m *WorkExperienceMutation) Type() string {
  16522. return m.typ
  16523. }
  16524. // Fields returns all fields that were changed during this mutation. Note that in
  16525. // order to get all numeric fields that were incremented/decremented, call
  16526. // AddedFields().
  16527. func (m *WorkExperienceMutation) Fields() []string {
  16528. fields := make([]string, 0, 9)
  16529. if m.created_at != nil {
  16530. fields = append(fields, workexperience.FieldCreatedAt)
  16531. }
  16532. if m.updated_at != nil {
  16533. fields = append(fields, workexperience.FieldUpdatedAt)
  16534. }
  16535. if m.deleted_at != nil {
  16536. fields = append(fields, workexperience.FieldDeletedAt)
  16537. }
  16538. if m.employee != nil {
  16539. fields = append(fields, workexperience.FieldEmployeeID)
  16540. }
  16541. if m.start_date != nil {
  16542. fields = append(fields, workexperience.FieldStartDate)
  16543. }
  16544. if m.end_date != nil {
  16545. fields = append(fields, workexperience.FieldEndDate)
  16546. }
  16547. if m.company != nil {
  16548. fields = append(fields, workexperience.FieldCompany)
  16549. }
  16550. if m.experience != nil {
  16551. fields = append(fields, workexperience.FieldExperience)
  16552. }
  16553. if m.organization_id != nil {
  16554. fields = append(fields, workexperience.FieldOrganizationID)
  16555. }
  16556. return fields
  16557. }
  16558. // Field returns the value of a field with the given name. The second boolean
  16559. // return value indicates that this field was not set, or was not defined in the
  16560. // schema.
  16561. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  16562. switch name {
  16563. case workexperience.FieldCreatedAt:
  16564. return m.CreatedAt()
  16565. case workexperience.FieldUpdatedAt:
  16566. return m.UpdatedAt()
  16567. case workexperience.FieldDeletedAt:
  16568. return m.DeletedAt()
  16569. case workexperience.FieldEmployeeID:
  16570. return m.EmployeeID()
  16571. case workexperience.FieldStartDate:
  16572. return m.StartDate()
  16573. case workexperience.FieldEndDate:
  16574. return m.EndDate()
  16575. case workexperience.FieldCompany:
  16576. return m.Company()
  16577. case workexperience.FieldExperience:
  16578. return m.Experience()
  16579. case workexperience.FieldOrganizationID:
  16580. return m.OrganizationID()
  16581. }
  16582. return nil, false
  16583. }
  16584. // OldField returns the old value of the field from the database. An error is
  16585. // returned if the mutation operation is not UpdateOne, or the query to the
  16586. // database failed.
  16587. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16588. switch name {
  16589. case workexperience.FieldCreatedAt:
  16590. return m.OldCreatedAt(ctx)
  16591. case workexperience.FieldUpdatedAt:
  16592. return m.OldUpdatedAt(ctx)
  16593. case workexperience.FieldDeletedAt:
  16594. return m.OldDeletedAt(ctx)
  16595. case workexperience.FieldEmployeeID:
  16596. return m.OldEmployeeID(ctx)
  16597. case workexperience.FieldStartDate:
  16598. return m.OldStartDate(ctx)
  16599. case workexperience.FieldEndDate:
  16600. return m.OldEndDate(ctx)
  16601. case workexperience.FieldCompany:
  16602. return m.OldCompany(ctx)
  16603. case workexperience.FieldExperience:
  16604. return m.OldExperience(ctx)
  16605. case workexperience.FieldOrganizationID:
  16606. return m.OldOrganizationID(ctx)
  16607. }
  16608. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  16609. }
  16610. // SetField sets the value of a field with the given name. It returns an error if
  16611. // the field is not defined in the schema, or if the type mismatched the field
  16612. // type.
  16613. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  16614. switch name {
  16615. case workexperience.FieldCreatedAt:
  16616. v, ok := value.(time.Time)
  16617. if !ok {
  16618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16619. }
  16620. m.SetCreatedAt(v)
  16621. return nil
  16622. case workexperience.FieldUpdatedAt:
  16623. v, ok := value.(time.Time)
  16624. if !ok {
  16625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16626. }
  16627. m.SetUpdatedAt(v)
  16628. return nil
  16629. case workexperience.FieldDeletedAt:
  16630. v, ok := value.(time.Time)
  16631. if !ok {
  16632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16633. }
  16634. m.SetDeletedAt(v)
  16635. return nil
  16636. case workexperience.FieldEmployeeID:
  16637. v, ok := value.(uint64)
  16638. if !ok {
  16639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16640. }
  16641. m.SetEmployeeID(v)
  16642. return nil
  16643. case workexperience.FieldStartDate:
  16644. v, ok := value.(time.Time)
  16645. if !ok {
  16646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16647. }
  16648. m.SetStartDate(v)
  16649. return nil
  16650. case workexperience.FieldEndDate:
  16651. v, ok := value.(time.Time)
  16652. if !ok {
  16653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16654. }
  16655. m.SetEndDate(v)
  16656. return nil
  16657. case workexperience.FieldCompany:
  16658. v, ok := value.(string)
  16659. if !ok {
  16660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16661. }
  16662. m.SetCompany(v)
  16663. return nil
  16664. case workexperience.FieldExperience:
  16665. v, ok := value.(string)
  16666. if !ok {
  16667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16668. }
  16669. m.SetExperience(v)
  16670. return nil
  16671. case workexperience.FieldOrganizationID:
  16672. v, ok := value.(uint64)
  16673. if !ok {
  16674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16675. }
  16676. m.SetOrganizationID(v)
  16677. return nil
  16678. }
  16679. return fmt.Errorf("unknown WorkExperience field %s", name)
  16680. }
  16681. // AddedFields returns all numeric fields that were incremented/decremented during
  16682. // this mutation.
  16683. func (m *WorkExperienceMutation) AddedFields() []string {
  16684. var fields []string
  16685. if m.addorganization_id != nil {
  16686. fields = append(fields, workexperience.FieldOrganizationID)
  16687. }
  16688. return fields
  16689. }
  16690. // AddedField returns the numeric value that was incremented/decremented on a field
  16691. // with the given name. The second boolean return value indicates that this field
  16692. // was not set, or was not defined in the schema.
  16693. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  16694. switch name {
  16695. case workexperience.FieldOrganizationID:
  16696. return m.AddedOrganizationID()
  16697. }
  16698. return nil, false
  16699. }
  16700. // AddField adds the value to the field with the given name. It returns an error if
  16701. // the field is not defined in the schema, or if the type mismatched the field
  16702. // type.
  16703. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  16704. switch name {
  16705. case workexperience.FieldOrganizationID:
  16706. v, ok := value.(int64)
  16707. if !ok {
  16708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16709. }
  16710. m.AddOrganizationID(v)
  16711. return nil
  16712. }
  16713. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  16714. }
  16715. // ClearedFields returns all nullable fields that were cleared during this
  16716. // mutation.
  16717. func (m *WorkExperienceMutation) ClearedFields() []string {
  16718. var fields []string
  16719. if m.FieldCleared(workexperience.FieldDeletedAt) {
  16720. fields = append(fields, workexperience.FieldDeletedAt)
  16721. }
  16722. return fields
  16723. }
  16724. // FieldCleared returns a boolean indicating if a field with the given name was
  16725. // cleared in this mutation.
  16726. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  16727. _, ok := m.clearedFields[name]
  16728. return ok
  16729. }
  16730. // ClearField clears the value of the field with the given name. It returns an
  16731. // error if the field is not defined in the schema.
  16732. func (m *WorkExperienceMutation) ClearField(name string) error {
  16733. switch name {
  16734. case workexperience.FieldDeletedAt:
  16735. m.ClearDeletedAt()
  16736. return nil
  16737. }
  16738. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  16739. }
  16740. // ResetField resets all changes in the mutation for the field with the given name.
  16741. // It returns an error if the field is not defined in the schema.
  16742. func (m *WorkExperienceMutation) ResetField(name string) error {
  16743. switch name {
  16744. case workexperience.FieldCreatedAt:
  16745. m.ResetCreatedAt()
  16746. return nil
  16747. case workexperience.FieldUpdatedAt:
  16748. m.ResetUpdatedAt()
  16749. return nil
  16750. case workexperience.FieldDeletedAt:
  16751. m.ResetDeletedAt()
  16752. return nil
  16753. case workexperience.FieldEmployeeID:
  16754. m.ResetEmployeeID()
  16755. return nil
  16756. case workexperience.FieldStartDate:
  16757. m.ResetStartDate()
  16758. return nil
  16759. case workexperience.FieldEndDate:
  16760. m.ResetEndDate()
  16761. return nil
  16762. case workexperience.FieldCompany:
  16763. m.ResetCompany()
  16764. return nil
  16765. case workexperience.FieldExperience:
  16766. m.ResetExperience()
  16767. return nil
  16768. case workexperience.FieldOrganizationID:
  16769. m.ResetOrganizationID()
  16770. return nil
  16771. }
  16772. return fmt.Errorf("unknown WorkExperience field %s", name)
  16773. }
  16774. // AddedEdges returns all edge names that were set/added in this mutation.
  16775. func (m *WorkExperienceMutation) AddedEdges() []string {
  16776. edges := make([]string, 0, 1)
  16777. if m.employee != nil {
  16778. edges = append(edges, workexperience.EdgeEmployee)
  16779. }
  16780. return edges
  16781. }
  16782. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16783. // name in this mutation.
  16784. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  16785. switch name {
  16786. case workexperience.EdgeEmployee:
  16787. if id := m.employee; id != nil {
  16788. return []ent.Value{*id}
  16789. }
  16790. }
  16791. return nil
  16792. }
  16793. // RemovedEdges returns all edge names that were removed in this mutation.
  16794. func (m *WorkExperienceMutation) RemovedEdges() []string {
  16795. edges := make([]string, 0, 1)
  16796. return edges
  16797. }
  16798. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16799. // the given name in this mutation.
  16800. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  16801. return nil
  16802. }
  16803. // ClearedEdges returns all edge names that were cleared in this mutation.
  16804. func (m *WorkExperienceMutation) ClearedEdges() []string {
  16805. edges := make([]string, 0, 1)
  16806. if m.clearedemployee {
  16807. edges = append(edges, workexperience.EdgeEmployee)
  16808. }
  16809. return edges
  16810. }
  16811. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16812. // was cleared in this mutation.
  16813. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  16814. switch name {
  16815. case workexperience.EdgeEmployee:
  16816. return m.clearedemployee
  16817. }
  16818. return false
  16819. }
  16820. // ClearEdge clears the value of the edge with the given name. It returns an error
  16821. // if that edge is not defined in the schema.
  16822. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  16823. switch name {
  16824. case workexperience.EdgeEmployee:
  16825. m.ClearEmployee()
  16826. return nil
  16827. }
  16828. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  16829. }
  16830. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16831. // It returns an error if the edge is not defined in the schema.
  16832. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  16833. switch name {
  16834. case workexperience.EdgeEmployee:
  16835. m.ResetEmployee()
  16836. return nil
  16837. }
  16838. return fmt.Errorf("unknown WorkExperience edge %s", name)
  16839. }
  16840. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  16841. type WxMutation struct {
  16842. config
  16843. op Op
  16844. typ string
  16845. id *uint64
  16846. created_at *time.Time
  16847. updated_at *time.Time
  16848. status *uint8
  16849. addstatus *int8
  16850. deleted_at *time.Time
  16851. port *string
  16852. process_id *string
  16853. callback *string
  16854. wxid *string
  16855. account *string
  16856. nickname *string
  16857. tel *string
  16858. head_big *string
  16859. organization_id *uint64
  16860. addorganization_id *int64
  16861. clearedFields map[string]struct{}
  16862. server *uint64
  16863. clearedserver bool
  16864. agent *uint64
  16865. clearedagent bool
  16866. done bool
  16867. oldValue func(context.Context) (*Wx, error)
  16868. predicates []predicate.Wx
  16869. }
  16870. var _ ent.Mutation = (*WxMutation)(nil)
  16871. // wxOption allows management of the mutation configuration using functional options.
  16872. type wxOption func(*WxMutation)
  16873. // newWxMutation creates new mutation for the Wx entity.
  16874. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  16875. m := &WxMutation{
  16876. config: c,
  16877. op: op,
  16878. typ: TypeWx,
  16879. clearedFields: make(map[string]struct{}),
  16880. }
  16881. for _, opt := range opts {
  16882. opt(m)
  16883. }
  16884. return m
  16885. }
  16886. // withWxID sets the ID field of the mutation.
  16887. func withWxID(id uint64) wxOption {
  16888. return func(m *WxMutation) {
  16889. var (
  16890. err error
  16891. once sync.Once
  16892. value *Wx
  16893. )
  16894. m.oldValue = func(ctx context.Context) (*Wx, error) {
  16895. once.Do(func() {
  16896. if m.done {
  16897. err = errors.New("querying old values post mutation is not allowed")
  16898. } else {
  16899. value, err = m.Client().Wx.Get(ctx, id)
  16900. }
  16901. })
  16902. return value, err
  16903. }
  16904. m.id = &id
  16905. }
  16906. }
  16907. // withWx sets the old Wx of the mutation.
  16908. func withWx(node *Wx) wxOption {
  16909. return func(m *WxMutation) {
  16910. m.oldValue = func(context.Context) (*Wx, error) {
  16911. return node, nil
  16912. }
  16913. m.id = &node.ID
  16914. }
  16915. }
  16916. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16917. // executed in a transaction (ent.Tx), a transactional client is returned.
  16918. func (m WxMutation) Client() *Client {
  16919. client := &Client{config: m.config}
  16920. client.init()
  16921. return client
  16922. }
  16923. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16924. // it returns an error otherwise.
  16925. func (m WxMutation) Tx() (*Tx, error) {
  16926. if _, ok := m.driver.(*txDriver); !ok {
  16927. return nil, errors.New("ent: mutation is not running in a transaction")
  16928. }
  16929. tx := &Tx{config: m.config}
  16930. tx.init()
  16931. return tx, nil
  16932. }
  16933. // SetID sets the value of the id field. Note that this
  16934. // operation is only accepted on creation of Wx entities.
  16935. func (m *WxMutation) SetID(id uint64) {
  16936. m.id = &id
  16937. }
  16938. // ID returns the ID value in the mutation. Note that the ID is only available
  16939. // if it was provided to the builder or after it was returned from the database.
  16940. func (m *WxMutation) ID() (id uint64, exists bool) {
  16941. if m.id == nil {
  16942. return
  16943. }
  16944. return *m.id, true
  16945. }
  16946. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16947. // That means, if the mutation is applied within a transaction with an isolation level such
  16948. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16949. // or updated by the mutation.
  16950. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  16951. switch {
  16952. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16953. id, exists := m.ID()
  16954. if exists {
  16955. return []uint64{id}, nil
  16956. }
  16957. fallthrough
  16958. case m.op.Is(OpUpdate | OpDelete):
  16959. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  16960. default:
  16961. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16962. }
  16963. }
  16964. // SetCreatedAt sets the "created_at" field.
  16965. func (m *WxMutation) SetCreatedAt(t time.Time) {
  16966. m.created_at = &t
  16967. }
  16968. // CreatedAt returns the value of the "created_at" field in the mutation.
  16969. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  16970. v := m.created_at
  16971. if v == nil {
  16972. return
  16973. }
  16974. return *v, true
  16975. }
  16976. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  16977. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  16978. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16979. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16980. if !m.op.Is(OpUpdateOne) {
  16981. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16982. }
  16983. if m.id == nil || m.oldValue == nil {
  16984. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16985. }
  16986. oldValue, err := m.oldValue(ctx)
  16987. if err != nil {
  16988. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16989. }
  16990. return oldValue.CreatedAt, nil
  16991. }
  16992. // ResetCreatedAt resets all changes to the "created_at" field.
  16993. func (m *WxMutation) ResetCreatedAt() {
  16994. m.created_at = nil
  16995. }
  16996. // SetUpdatedAt sets the "updated_at" field.
  16997. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  16998. m.updated_at = &t
  16999. }
  17000. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17001. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  17002. v := m.updated_at
  17003. if v == nil {
  17004. return
  17005. }
  17006. return *v, true
  17007. }
  17008. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  17009. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17010. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17011. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17012. if !m.op.Is(OpUpdateOne) {
  17013. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17014. }
  17015. if m.id == nil || m.oldValue == nil {
  17016. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17017. }
  17018. oldValue, err := m.oldValue(ctx)
  17019. if err != nil {
  17020. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17021. }
  17022. return oldValue.UpdatedAt, nil
  17023. }
  17024. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17025. func (m *WxMutation) ResetUpdatedAt() {
  17026. m.updated_at = nil
  17027. }
  17028. // SetStatus sets the "status" field.
  17029. func (m *WxMutation) SetStatus(u uint8) {
  17030. m.status = &u
  17031. m.addstatus = nil
  17032. }
  17033. // Status returns the value of the "status" field in the mutation.
  17034. func (m *WxMutation) Status() (r uint8, exists bool) {
  17035. v := m.status
  17036. if v == nil {
  17037. return
  17038. }
  17039. return *v, true
  17040. }
  17041. // OldStatus returns the old "status" field's value of the Wx entity.
  17042. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17044. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17045. if !m.op.Is(OpUpdateOne) {
  17046. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17047. }
  17048. if m.id == nil || m.oldValue == nil {
  17049. return v, errors.New("OldStatus requires an ID field in the mutation")
  17050. }
  17051. oldValue, err := m.oldValue(ctx)
  17052. if err != nil {
  17053. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17054. }
  17055. return oldValue.Status, nil
  17056. }
  17057. // AddStatus adds u to the "status" field.
  17058. func (m *WxMutation) AddStatus(u int8) {
  17059. if m.addstatus != nil {
  17060. *m.addstatus += u
  17061. } else {
  17062. m.addstatus = &u
  17063. }
  17064. }
  17065. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17066. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  17067. v := m.addstatus
  17068. if v == nil {
  17069. return
  17070. }
  17071. return *v, true
  17072. }
  17073. // ClearStatus clears the value of the "status" field.
  17074. func (m *WxMutation) ClearStatus() {
  17075. m.status = nil
  17076. m.addstatus = nil
  17077. m.clearedFields[wx.FieldStatus] = struct{}{}
  17078. }
  17079. // StatusCleared returns if the "status" field was cleared in this mutation.
  17080. func (m *WxMutation) StatusCleared() bool {
  17081. _, ok := m.clearedFields[wx.FieldStatus]
  17082. return ok
  17083. }
  17084. // ResetStatus resets all changes to the "status" field.
  17085. func (m *WxMutation) ResetStatus() {
  17086. m.status = nil
  17087. m.addstatus = nil
  17088. delete(m.clearedFields, wx.FieldStatus)
  17089. }
  17090. // SetDeletedAt sets the "deleted_at" field.
  17091. func (m *WxMutation) SetDeletedAt(t time.Time) {
  17092. m.deleted_at = &t
  17093. }
  17094. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17095. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  17096. v := m.deleted_at
  17097. if v == nil {
  17098. return
  17099. }
  17100. return *v, true
  17101. }
  17102. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  17103. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17105. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17106. if !m.op.Is(OpUpdateOne) {
  17107. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17108. }
  17109. if m.id == nil || m.oldValue == nil {
  17110. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17111. }
  17112. oldValue, err := m.oldValue(ctx)
  17113. if err != nil {
  17114. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17115. }
  17116. return oldValue.DeletedAt, nil
  17117. }
  17118. // ClearDeletedAt clears the value of the "deleted_at" field.
  17119. func (m *WxMutation) ClearDeletedAt() {
  17120. m.deleted_at = nil
  17121. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  17122. }
  17123. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17124. func (m *WxMutation) DeletedAtCleared() bool {
  17125. _, ok := m.clearedFields[wx.FieldDeletedAt]
  17126. return ok
  17127. }
  17128. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17129. func (m *WxMutation) ResetDeletedAt() {
  17130. m.deleted_at = nil
  17131. delete(m.clearedFields, wx.FieldDeletedAt)
  17132. }
  17133. // SetServerID sets the "server_id" field.
  17134. func (m *WxMutation) SetServerID(u uint64) {
  17135. m.server = &u
  17136. }
  17137. // ServerID returns the value of the "server_id" field in the mutation.
  17138. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  17139. v := m.server
  17140. if v == nil {
  17141. return
  17142. }
  17143. return *v, true
  17144. }
  17145. // OldServerID returns the old "server_id" field's value of the Wx entity.
  17146. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17148. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  17149. if !m.op.Is(OpUpdateOne) {
  17150. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  17151. }
  17152. if m.id == nil || m.oldValue == nil {
  17153. return v, errors.New("OldServerID requires an ID field in the mutation")
  17154. }
  17155. oldValue, err := m.oldValue(ctx)
  17156. if err != nil {
  17157. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  17158. }
  17159. return oldValue.ServerID, nil
  17160. }
  17161. // ClearServerID clears the value of the "server_id" field.
  17162. func (m *WxMutation) ClearServerID() {
  17163. m.server = nil
  17164. m.clearedFields[wx.FieldServerID] = struct{}{}
  17165. }
  17166. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  17167. func (m *WxMutation) ServerIDCleared() bool {
  17168. _, ok := m.clearedFields[wx.FieldServerID]
  17169. return ok
  17170. }
  17171. // ResetServerID resets all changes to the "server_id" field.
  17172. func (m *WxMutation) ResetServerID() {
  17173. m.server = nil
  17174. delete(m.clearedFields, wx.FieldServerID)
  17175. }
  17176. // SetPort sets the "port" field.
  17177. func (m *WxMutation) SetPort(s string) {
  17178. m.port = &s
  17179. }
  17180. // Port returns the value of the "port" field in the mutation.
  17181. func (m *WxMutation) Port() (r string, exists bool) {
  17182. v := m.port
  17183. if v == nil {
  17184. return
  17185. }
  17186. return *v, true
  17187. }
  17188. // OldPort returns the old "port" field's value of the Wx entity.
  17189. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17191. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  17192. if !m.op.Is(OpUpdateOne) {
  17193. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  17194. }
  17195. if m.id == nil || m.oldValue == nil {
  17196. return v, errors.New("OldPort requires an ID field in the mutation")
  17197. }
  17198. oldValue, err := m.oldValue(ctx)
  17199. if err != nil {
  17200. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  17201. }
  17202. return oldValue.Port, nil
  17203. }
  17204. // ResetPort resets all changes to the "port" field.
  17205. func (m *WxMutation) ResetPort() {
  17206. m.port = nil
  17207. }
  17208. // SetProcessID sets the "process_id" field.
  17209. func (m *WxMutation) SetProcessID(s string) {
  17210. m.process_id = &s
  17211. }
  17212. // ProcessID returns the value of the "process_id" field in the mutation.
  17213. func (m *WxMutation) ProcessID() (r string, exists bool) {
  17214. v := m.process_id
  17215. if v == nil {
  17216. return
  17217. }
  17218. return *v, true
  17219. }
  17220. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  17221. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17223. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  17224. if !m.op.Is(OpUpdateOne) {
  17225. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  17226. }
  17227. if m.id == nil || m.oldValue == nil {
  17228. return v, errors.New("OldProcessID requires an ID field in the mutation")
  17229. }
  17230. oldValue, err := m.oldValue(ctx)
  17231. if err != nil {
  17232. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  17233. }
  17234. return oldValue.ProcessID, nil
  17235. }
  17236. // ResetProcessID resets all changes to the "process_id" field.
  17237. func (m *WxMutation) ResetProcessID() {
  17238. m.process_id = nil
  17239. }
  17240. // SetCallback sets the "callback" field.
  17241. func (m *WxMutation) SetCallback(s string) {
  17242. m.callback = &s
  17243. }
  17244. // Callback returns the value of the "callback" field in the mutation.
  17245. func (m *WxMutation) Callback() (r string, exists bool) {
  17246. v := m.callback
  17247. if v == nil {
  17248. return
  17249. }
  17250. return *v, true
  17251. }
  17252. // OldCallback returns the old "callback" field's value of the Wx entity.
  17253. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17255. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  17256. if !m.op.Is(OpUpdateOne) {
  17257. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  17258. }
  17259. if m.id == nil || m.oldValue == nil {
  17260. return v, errors.New("OldCallback requires an ID field in the mutation")
  17261. }
  17262. oldValue, err := m.oldValue(ctx)
  17263. if err != nil {
  17264. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  17265. }
  17266. return oldValue.Callback, nil
  17267. }
  17268. // ResetCallback resets all changes to the "callback" field.
  17269. func (m *WxMutation) ResetCallback() {
  17270. m.callback = nil
  17271. }
  17272. // SetWxid sets the "wxid" field.
  17273. func (m *WxMutation) SetWxid(s string) {
  17274. m.wxid = &s
  17275. }
  17276. // Wxid returns the value of the "wxid" field in the mutation.
  17277. func (m *WxMutation) Wxid() (r string, exists bool) {
  17278. v := m.wxid
  17279. if v == nil {
  17280. return
  17281. }
  17282. return *v, true
  17283. }
  17284. // OldWxid returns the old "wxid" field's value of the Wx entity.
  17285. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17287. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  17288. if !m.op.Is(OpUpdateOne) {
  17289. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  17290. }
  17291. if m.id == nil || m.oldValue == nil {
  17292. return v, errors.New("OldWxid requires an ID field in the mutation")
  17293. }
  17294. oldValue, err := m.oldValue(ctx)
  17295. if err != nil {
  17296. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  17297. }
  17298. return oldValue.Wxid, nil
  17299. }
  17300. // ResetWxid resets all changes to the "wxid" field.
  17301. func (m *WxMutation) ResetWxid() {
  17302. m.wxid = nil
  17303. }
  17304. // SetAccount sets the "account" field.
  17305. func (m *WxMutation) SetAccount(s string) {
  17306. m.account = &s
  17307. }
  17308. // Account returns the value of the "account" field in the mutation.
  17309. func (m *WxMutation) Account() (r string, exists bool) {
  17310. v := m.account
  17311. if v == nil {
  17312. return
  17313. }
  17314. return *v, true
  17315. }
  17316. // OldAccount returns the old "account" field's value of the Wx entity.
  17317. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17319. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  17320. if !m.op.Is(OpUpdateOne) {
  17321. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  17322. }
  17323. if m.id == nil || m.oldValue == nil {
  17324. return v, errors.New("OldAccount requires an ID field in the mutation")
  17325. }
  17326. oldValue, err := m.oldValue(ctx)
  17327. if err != nil {
  17328. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  17329. }
  17330. return oldValue.Account, nil
  17331. }
  17332. // ResetAccount resets all changes to the "account" field.
  17333. func (m *WxMutation) ResetAccount() {
  17334. m.account = nil
  17335. }
  17336. // SetNickname sets the "nickname" field.
  17337. func (m *WxMutation) SetNickname(s string) {
  17338. m.nickname = &s
  17339. }
  17340. // Nickname returns the value of the "nickname" field in the mutation.
  17341. func (m *WxMutation) Nickname() (r string, exists bool) {
  17342. v := m.nickname
  17343. if v == nil {
  17344. return
  17345. }
  17346. return *v, true
  17347. }
  17348. // OldNickname returns the old "nickname" field's value of the Wx entity.
  17349. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17351. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  17352. if !m.op.Is(OpUpdateOne) {
  17353. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  17354. }
  17355. if m.id == nil || m.oldValue == nil {
  17356. return v, errors.New("OldNickname requires an ID field in the mutation")
  17357. }
  17358. oldValue, err := m.oldValue(ctx)
  17359. if err != nil {
  17360. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  17361. }
  17362. return oldValue.Nickname, nil
  17363. }
  17364. // ResetNickname resets all changes to the "nickname" field.
  17365. func (m *WxMutation) ResetNickname() {
  17366. m.nickname = nil
  17367. }
  17368. // SetTel sets the "tel" field.
  17369. func (m *WxMutation) SetTel(s string) {
  17370. m.tel = &s
  17371. }
  17372. // Tel returns the value of the "tel" field in the mutation.
  17373. func (m *WxMutation) Tel() (r string, exists bool) {
  17374. v := m.tel
  17375. if v == nil {
  17376. return
  17377. }
  17378. return *v, true
  17379. }
  17380. // OldTel returns the old "tel" field's value of the Wx entity.
  17381. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17383. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  17384. if !m.op.Is(OpUpdateOne) {
  17385. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  17386. }
  17387. if m.id == nil || m.oldValue == nil {
  17388. return v, errors.New("OldTel requires an ID field in the mutation")
  17389. }
  17390. oldValue, err := m.oldValue(ctx)
  17391. if err != nil {
  17392. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  17393. }
  17394. return oldValue.Tel, nil
  17395. }
  17396. // ResetTel resets all changes to the "tel" field.
  17397. func (m *WxMutation) ResetTel() {
  17398. m.tel = nil
  17399. }
  17400. // SetHeadBig sets the "head_big" field.
  17401. func (m *WxMutation) SetHeadBig(s string) {
  17402. m.head_big = &s
  17403. }
  17404. // HeadBig returns the value of the "head_big" field in the mutation.
  17405. func (m *WxMutation) HeadBig() (r string, exists bool) {
  17406. v := m.head_big
  17407. if v == nil {
  17408. return
  17409. }
  17410. return *v, true
  17411. }
  17412. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  17413. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17415. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  17416. if !m.op.Is(OpUpdateOne) {
  17417. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  17418. }
  17419. if m.id == nil || m.oldValue == nil {
  17420. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  17421. }
  17422. oldValue, err := m.oldValue(ctx)
  17423. if err != nil {
  17424. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  17425. }
  17426. return oldValue.HeadBig, nil
  17427. }
  17428. // ResetHeadBig resets all changes to the "head_big" field.
  17429. func (m *WxMutation) ResetHeadBig() {
  17430. m.head_big = nil
  17431. }
  17432. // SetOrganizationID sets the "organization_id" field.
  17433. func (m *WxMutation) SetOrganizationID(u uint64) {
  17434. m.organization_id = &u
  17435. m.addorganization_id = nil
  17436. }
  17437. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17438. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  17439. v := m.organization_id
  17440. if v == nil {
  17441. return
  17442. }
  17443. return *v, true
  17444. }
  17445. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  17446. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17447. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17448. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17449. if !m.op.Is(OpUpdateOne) {
  17450. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17451. }
  17452. if m.id == nil || m.oldValue == nil {
  17453. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17454. }
  17455. oldValue, err := m.oldValue(ctx)
  17456. if err != nil {
  17457. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17458. }
  17459. return oldValue.OrganizationID, nil
  17460. }
  17461. // AddOrganizationID adds u to the "organization_id" field.
  17462. func (m *WxMutation) AddOrganizationID(u int64) {
  17463. if m.addorganization_id != nil {
  17464. *m.addorganization_id += u
  17465. } else {
  17466. m.addorganization_id = &u
  17467. }
  17468. }
  17469. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17470. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  17471. v := m.addorganization_id
  17472. if v == nil {
  17473. return
  17474. }
  17475. return *v, true
  17476. }
  17477. // ClearOrganizationID clears the value of the "organization_id" field.
  17478. func (m *WxMutation) ClearOrganizationID() {
  17479. m.organization_id = nil
  17480. m.addorganization_id = nil
  17481. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  17482. }
  17483. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17484. func (m *WxMutation) OrganizationIDCleared() bool {
  17485. _, ok := m.clearedFields[wx.FieldOrganizationID]
  17486. return ok
  17487. }
  17488. // ResetOrganizationID resets all changes to the "organization_id" field.
  17489. func (m *WxMutation) ResetOrganizationID() {
  17490. m.organization_id = nil
  17491. m.addorganization_id = nil
  17492. delete(m.clearedFields, wx.FieldOrganizationID)
  17493. }
  17494. // SetAgentID sets the "agent_id" field.
  17495. func (m *WxMutation) SetAgentID(u uint64) {
  17496. m.agent = &u
  17497. }
  17498. // AgentID returns the value of the "agent_id" field in the mutation.
  17499. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  17500. v := m.agent
  17501. if v == nil {
  17502. return
  17503. }
  17504. return *v, true
  17505. }
  17506. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  17507. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17509. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  17510. if !m.op.Is(OpUpdateOne) {
  17511. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  17512. }
  17513. if m.id == nil || m.oldValue == nil {
  17514. return v, errors.New("OldAgentID requires an ID field in the mutation")
  17515. }
  17516. oldValue, err := m.oldValue(ctx)
  17517. if err != nil {
  17518. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  17519. }
  17520. return oldValue.AgentID, nil
  17521. }
  17522. // ResetAgentID resets all changes to the "agent_id" field.
  17523. func (m *WxMutation) ResetAgentID() {
  17524. m.agent = nil
  17525. }
  17526. // ClearServer clears the "server" edge to the Server entity.
  17527. func (m *WxMutation) ClearServer() {
  17528. m.clearedserver = true
  17529. m.clearedFields[wx.FieldServerID] = struct{}{}
  17530. }
  17531. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  17532. func (m *WxMutation) ServerCleared() bool {
  17533. return m.ServerIDCleared() || m.clearedserver
  17534. }
  17535. // ServerIDs returns the "server" edge IDs in the mutation.
  17536. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17537. // ServerID instead. It exists only for internal usage by the builders.
  17538. func (m *WxMutation) ServerIDs() (ids []uint64) {
  17539. if id := m.server; id != nil {
  17540. ids = append(ids, *id)
  17541. }
  17542. return
  17543. }
  17544. // ResetServer resets all changes to the "server" edge.
  17545. func (m *WxMutation) ResetServer() {
  17546. m.server = nil
  17547. m.clearedserver = false
  17548. }
  17549. // ClearAgent clears the "agent" edge to the Agent entity.
  17550. func (m *WxMutation) ClearAgent() {
  17551. m.clearedagent = true
  17552. m.clearedFields[wx.FieldAgentID] = struct{}{}
  17553. }
  17554. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  17555. func (m *WxMutation) AgentCleared() bool {
  17556. return m.clearedagent
  17557. }
  17558. // AgentIDs returns the "agent" edge IDs in the mutation.
  17559. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17560. // AgentID instead. It exists only for internal usage by the builders.
  17561. func (m *WxMutation) AgentIDs() (ids []uint64) {
  17562. if id := m.agent; id != nil {
  17563. ids = append(ids, *id)
  17564. }
  17565. return
  17566. }
  17567. // ResetAgent resets all changes to the "agent" edge.
  17568. func (m *WxMutation) ResetAgent() {
  17569. m.agent = nil
  17570. m.clearedagent = false
  17571. }
  17572. // Where appends a list predicates to the WxMutation builder.
  17573. func (m *WxMutation) Where(ps ...predicate.Wx) {
  17574. m.predicates = append(m.predicates, ps...)
  17575. }
  17576. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  17577. // users can use type-assertion to append predicates that do not depend on any generated package.
  17578. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  17579. p := make([]predicate.Wx, len(ps))
  17580. for i := range ps {
  17581. p[i] = ps[i]
  17582. }
  17583. m.Where(p...)
  17584. }
  17585. // Op returns the operation name.
  17586. func (m *WxMutation) Op() Op {
  17587. return m.op
  17588. }
  17589. // SetOp allows setting the mutation operation.
  17590. func (m *WxMutation) SetOp(op Op) {
  17591. m.op = op
  17592. }
  17593. // Type returns the node type of this mutation (Wx).
  17594. func (m *WxMutation) Type() string {
  17595. return m.typ
  17596. }
  17597. // Fields returns all fields that were changed during this mutation. Note that in
  17598. // order to get all numeric fields that were incremented/decremented, call
  17599. // AddedFields().
  17600. func (m *WxMutation) Fields() []string {
  17601. fields := make([]string, 0, 15)
  17602. if m.created_at != nil {
  17603. fields = append(fields, wx.FieldCreatedAt)
  17604. }
  17605. if m.updated_at != nil {
  17606. fields = append(fields, wx.FieldUpdatedAt)
  17607. }
  17608. if m.status != nil {
  17609. fields = append(fields, wx.FieldStatus)
  17610. }
  17611. if m.deleted_at != nil {
  17612. fields = append(fields, wx.FieldDeletedAt)
  17613. }
  17614. if m.server != nil {
  17615. fields = append(fields, wx.FieldServerID)
  17616. }
  17617. if m.port != nil {
  17618. fields = append(fields, wx.FieldPort)
  17619. }
  17620. if m.process_id != nil {
  17621. fields = append(fields, wx.FieldProcessID)
  17622. }
  17623. if m.callback != nil {
  17624. fields = append(fields, wx.FieldCallback)
  17625. }
  17626. if m.wxid != nil {
  17627. fields = append(fields, wx.FieldWxid)
  17628. }
  17629. if m.account != nil {
  17630. fields = append(fields, wx.FieldAccount)
  17631. }
  17632. if m.nickname != nil {
  17633. fields = append(fields, wx.FieldNickname)
  17634. }
  17635. if m.tel != nil {
  17636. fields = append(fields, wx.FieldTel)
  17637. }
  17638. if m.head_big != nil {
  17639. fields = append(fields, wx.FieldHeadBig)
  17640. }
  17641. if m.organization_id != nil {
  17642. fields = append(fields, wx.FieldOrganizationID)
  17643. }
  17644. if m.agent != nil {
  17645. fields = append(fields, wx.FieldAgentID)
  17646. }
  17647. return fields
  17648. }
  17649. // Field returns the value of a field with the given name. The second boolean
  17650. // return value indicates that this field was not set, or was not defined in the
  17651. // schema.
  17652. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  17653. switch name {
  17654. case wx.FieldCreatedAt:
  17655. return m.CreatedAt()
  17656. case wx.FieldUpdatedAt:
  17657. return m.UpdatedAt()
  17658. case wx.FieldStatus:
  17659. return m.Status()
  17660. case wx.FieldDeletedAt:
  17661. return m.DeletedAt()
  17662. case wx.FieldServerID:
  17663. return m.ServerID()
  17664. case wx.FieldPort:
  17665. return m.Port()
  17666. case wx.FieldProcessID:
  17667. return m.ProcessID()
  17668. case wx.FieldCallback:
  17669. return m.Callback()
  17670. case wx.FieldWxid:
  17671. return m.Wxid()
  17672. case wx.FieldAccount:
  17673. return m.Account()
  17674. case wx.FieldNickname:
  17675. return m.Nickname()
  17676. case wx.FieldTel:
  17677. return m.Tel()
  17678. case wx.FieldHeadBig:
  17679. return m.HeadBig()
  17680. case wx.FieldOrganizationID:
  17681. return m.OrganizationID()
  17682. case wx.FieldAgentID:
  17683. return m.AgentID()
  17684. }
  17685. return nil, false
  17686. }
  17687. // OldField returns the old value of the field from the database. An error is
  17688. // returned if the mutation operation is not UpdateOne, or the query to the
  17689. // database failed.
  17690. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17691. switch name {
  17692. case wx.FieldCreatedAt:
  17693. return m.OldCreatedAt(ctx)
  17694. case wx.FieldUpdatedAt:
  17695. return m.OldUpdatedAt(ctx)
  17696. case wx.FieldStatus:
  17697. return m.OldStatus(ctx)
  17698. case wx.FieldDeletedAt:
  17699. return m.OldDeletedAt(ctx)
  17700. case wx.FieldServerID:
  17701. return m.OldServerID(ctx)
  17702. case wx.FieldPort:
  17703. return m.OldPort(ctx)
  17704. case wx.FieldProcessID:
  17705. return m.OldProcessID(ctx)
  17706. case wx.FieldCallback:
  17707. return m.OldCallback(ctx)
  17708. case wx.FieldWxid:
  17709. return m.OldWxid(ctx)
  17710. case wx.FieldAccount:
  17711. return m.OldAccount(ctx)
  17712. case wx.FieldNickname:
  17713. return m.OldNickname(ctx)
  17714. case wx.FieldTel:
  17715. return m.OldTel(ctx)
  17716. case wx.FieldHeadBig:
  17717. return m.OldHeadBig(ctx)
  17718. case wx.FieldOrganizationID:
  17719. return m.OldOrganizationID(ctx)
  17720. case wx.FieldAgentID:
  17721. return m.OldAgentID(ctx)
  17722. }
  17723. return nil, fmt.Errorf("unknown Wx field %s", name)
  17724. }
  17725. // SetField sets the value of a field with the given name. It returns an error if
  17726. // the field is not defined in the schema, or if the type mismatched the field
  17727. // type.
  17728. func (m *WxMutation) SetField(name string, value ent.Value) error {
  17729. switch name {
  17730. case wx.FieldCreatedAt:
  17731. v, ok := value.(time.Time)
  17732. if !ok {
  17733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17734. }
  17735. m.SetCreatedAt(v)
  17736. return nil
  17737. case wx.FieldUpdatedAt:
  17738. v, ok := value.(time.Time)
  17739. if !ok {
  17740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17741. }
  17742. m.SetUpdatedAt(v)
  17743. return nil
  17744. case wx.FieldStatus:
  17745. v, ok := value.(uint8)
  17746. if !ok {
  17747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17748. }
  17749. m.SetStatus(v)
  17750. return nil
  17751. case wx.FieldDeletedAt:
  17752. v, ok := value.(time.Time)
  17753. if !ok {
  17754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17755. }
  17756. m.SetDeletedAt(v)
  17757. return nil
  17758. case wx.FieldServerID:
  17759. v, ok := value.(uint64)
  17760. if !ok {
  17761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17762. }
  17763. m.SetServerID(v)
  17764. return nil
  17765. case wx.FieldPort:
  17766. v, ok := value.(string)
  17767. if !ok {
  17768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17769. }
  17770. m.SetPort(v)
  17771. return nil
  17772. case wx.FieldProcessID:
  17773. v, ok := value.(string)
  17774. if !ok {
  17775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17776. }
  17777. m.SetProcessID(v)
  17778. return nil
  17779. case wx.FieldCallback:
  17780. v, ok := value.(string)
  17781. if !ok {
  17782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17783. }
  17784. m.SetCallback(v)
  17785. return nil
  17786. case wx.FieldWxid:
  17787. v, ok := value.(string)
  17788. if !ok {
  17789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17790. }
  17791. m.SetWxid(v)
  17792. return nil
  17793. case wx.FieldAccount:
  17794. v, ok := value.(string)
  17795. if !ok {
  17796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17797. }
  17798. m.SetAccount(v)
  17799. return nil
  17800. case wx.FieldNickname:
  17801. v, ok := value.(string)
  17802. if !ok {
  17803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17804. }
  17805. m.SetNickname(v)
  17806. return nil
  17807. case wx.FieldTel:
  17808. v, ok := value.(string)
  17809. if !ok {
  17810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17811. }
  17812. m.SetTel(v)
  17813. return nil
  17814. case wx.FieldHeadBig:
  17815. v, ok := value.(string)
  17816. if !ok {
  17817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17818. }
  17819. m.SetHeadBig(v)
  17820. return nil
  17821. case wx.FieldOrganizationID:
  17822. v, ok := value.(uint64)
  17823. if !ok {
  17824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17825. }
  17826. m.SetOrganizationID(v)
  17827. return nil
  17828. case wx.FieldAgentID:
  17829. v, ok := value.(uint64)
  17830. if !ok {
  17831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17832. }
  17833. m.SetAgentID(v)
  17834. return nil
  17835. }
  17836. return fmt.Errorf("unknown Wx field %s", name)
  17837. }
  17838. // AddedFields returns all numeric fields that were incremented/decremented during
  17839. // this mutation.
  17840. func (m *WxMutation) AddedFields() []string {
  17841. var fields []string
  17842. if m.addstatus != nil {
  17843. fields = append(fields, wx.FieldStatus)
  17844. }
  17845. if m.addorganization_id != nil {
  17846. fields = append(fields, wx.FieldOrganizationID)
  17847. }
  17848. return fields
  17849. }
  17850. // AddedField returns the numeric value that was incremented/decremented on a field
  17851. // with the given name. The second boolean return value indicates that this field
  17852. // was not set, or was not defined in the schema.
  17853. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  17854. switch name {
  17855. case wx.FieldStatus:
  17856. return m.AddedStatus()
  17857. case wx.FieldOrganizationID:
  17858. return m.AddedOrganizationID()
  17859. }
  17860. return nil, false
  17861. }
  17862. // AddField adds the value to the field with the given name. It returns an error if
  17863. // the field is not defined in the schema, or if the type mismatched the field
  17864. // type.
  17865. func (m *WxMutation) AddField(name string, value ent.Value) error {
  17866. switch name {
  17867. case wx.FieldStatus:
  17868. v, ok := value.(int8)
  17869. if !ok {
  17870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17871. }
  17872. m.AddStatus(v)
  17873. return nil
  17874. case wx.FieldOrganizationID:
  17875. v, ok := value.(int64)
  17876. if !ok {
  17877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17878. }
  17879. m.AddOrganizationID(v)
  17880. return nil
  17881. }
  17882. return fmt.Errorf("unknown Wx numeric field %s", name)
  17883. }
  17884. // ClearedFields returns all nullable fields that were cleared during this
  17885. // mutation.
  17886. func (m *WxMutation) ClearedFields() []string {
  17887. var fields []string
  17888. if m.FieldCleared(wx.FieldStatus) {
  17889. fields = append(fields, wx.FieldStatus)
  17890. }
  17891. if m.FieldCleared(wx.FieldDeletedAt) {
  17892. fields = append(fields, wx.FieldDeletedAt)
  17893. }
  17894. if m.FieldCleared(wx.FieldServerID) {
  17895. fields = append(fields, wx.FieldServerID)
  17896. }
  17897. if m.FieldCleared(wx.FieldOrganizationID) {
  17898. fields = append(fields, wx.FieldOrganizationID)
  17899. }
  17900. return fields
  17901. }
  17902. // FieldCleared returns a boolean indicating if a field with the given name was
  17903. // cleared in this mutation.
  17904. func (m *WxMutation) FieldCleared(name string) bool {
  17905. _, ok := m.clearedFields[name]
  17906. return ok
  17907. }
  17908. // ClearField clears the value of the field with the given name. It returns an
  17909. // error if the field is not defined in the schema.
  17910. func (m *WxMutation) ClearField(name string) error {
  17911. switch name {
  17912. case wx.FieldStatus:
  17913. m.ClearStatus()
  17914. return nil
  17915. case wx.FieldDeletedAt:
  17916. m.ClearDeletedAt()
  17917. return nil
  17918. case wx.FieldServerID:
  17919. m.ClearServerID()
  17920. return nil
  17921. case wx.FieldOrganizationID:
  17922. m.ClearOrganizationID()
  17923. return nil
  17924. }
  17925. return fmt.Errorf("unknown Wx nullable field %s", name)
  17926. }
  17927. // ResetField resets all changes in the mutation for the field with the given name.
  17928. // It returns an error if the field is not defined in the schema.
  17929. func (m *WxMutation) ResetField(name string) error {
  17930. switch name {
  17931. case wx.FieldCreatedAt:
  17932. m.ResetCreatedAt()
  17933. return nil
  17934. case wx.FieldUpdatedAt:
  17935. m.ResetUpdatedAt()
  17936. return nil
  17937. case wx.FieldStatus:
  17938. m.ResetStatus()
  17939. return nil
  17940. case wx.FieldDeletedAt:
  17941. m.ResetDeletedAt()
  17942. return nil
  17943. case wx.FieldServerID:
  17944. m.ResetServerID()
  17945. return nil
  17946. case wx.FieldPort:
  17947. m.ResetPort()
  17948. return nil
  17949. case wx.FieldProcessID:
  17950. m.ResetProcessID()
  17951. return nil
  17952. case wx.FieldCallback:
  17953. m.ResetCallback()
  17954. return nil
  17955. case wx.FieldWxid:
  17956. m.ResetWxid()
  17957. return nil
  17958. case wx.FieldAccount:
  17959. m.ResetAccount()
  17960. return nil
  17961. case wx.FieldNickname:
  17962. m.ResetNickname()
  17963. return nil
  17964. case wx.FieldTel:
  17965. m.ResetTel()
  17966. return nil
  17967. case wx.FieldHeadBig:
  17968. m.ResetHeadBig()
  17969. return nil
  17970. case wx.FieldOrganizationID:
  17971. m.ResetOrganizationID()
  17972. return nil
  17973. case wx.FieldAgentID:
  17974. m.ResetAgentID()
  17975. return nil
  17976. }
  17977. return fmt.Errorf("unknown Wx field %s", name)
  17978. }
  17979. // AddedEdges returns all edge names that were set/added in this mutation.
  17980. func (m *WxMutation) AddedEdges() []string {
  17981. edges := make([]string, 0, 2)
  17982. if m.server != nil {
  17983. edges = append(edges, wx.EdgeServer)
  17984. }
  17985. if m.agent != nil {
  17986. edges = append(edges, wx.EdgeAgent)
  17987. }
  17988. return edges
  17989. }
  17990. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17991. // name in this mutation.
  17992. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  17993. switch name {
  17994. case wx.EdgeServer:
  17995. if id := m.server; id != nil {
  17996. return []ent.Value{*id}
  17997. }
  17998. case wx.EdgeAgent:
  17999. if id := m.agent; id != nil {
  18000. return []ent.Value{*id}
  18001. }
  18002. }
  18003. return nil
  18004. }
  18005. // RemovedEdges returns all edge names that were removed in this mutation.
  18006. func (m *WxMutation) RemovedEdges() []string {
  18007. edges := make([]string, 0, 2)
  18008. return edges
  18009. }
  18010. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18011. // the given name in this mutation.
  18012. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  18013. return nil
  18014. }
  18015. // ClearedEdges returns all edge names that were cleared in this mutation.
  18016. func (m *WxMutation) ClearedEdges() []string {
  18017. edges := make([]string, 0, 2)
  18018. if m.clearedserver {
  18019. edges = append(edges, wx.EdgeServer)
  18020. }
  18021. if m.clearedagent {
  18022. edges = append(edges, wx.EdgeAgent)
  18023. }
  18024. return edges
  18025. }
  18026. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18027. // was cleared in this mutation.
  18028. func (m *WxMutation) EdgeCleared(name string) bool {
  18029. switch name {
  18030. case wx.EdgeServer:
  18031. return m.clearedserver
  18032. case wx.EdgeAgent:
  18033. return m.clearedagent
  18034. }
  18035. return false
  18036. }
  18037. // ClearEdge clears the value of the edge with the given name. It returns an error
  18038. // if that edge is not defined in the schema.
  18039. func (m *WxMutation) ClearEdge(name string) error {
  18040. switch name {
  18041. case wx.EdgeServer:
  18042. m.ClearServer()
  18043. return nil
  18044. case wx.EdgeAgent:
  18045. m.ClearAgent()
  18046. return nil
  18047. }
  18048. return fmt.Errorf("unknown Wx unique edge %s", name)
  18049. }
  18050. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18051. // It returns an error if the edge is not defined in the schema.
  18052. func (m *WxMutation) ResetEdge(name string) error {
  18053. switch name {
  18054. case wx.EdgeServer:
  18055. m.ResetServer()
  18056. return nil
  18057. case wx.EdgeAgent:
  18058. m.ResetAgent()
  18059. return nil
  18060. }
  18061. return fmt.Errorf("unknown Wx edge %s", name)
  18062. }