mutation.go 580 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792
  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. send_time *time.Time
  998. _type *int32
  999. add_type *int32
  1000. clearedFields map[string]struct{}
  1001. done bool
  1002. oldValue func(context.Context) (*BatchMsg, error)
  1003. predicates []predicate.BatchMsg
  1004. }
  1005. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  1006. // batchmsgOption allows management of the mutation configuration using functional options.
  1007. type batchmsgOption func(*BatchMsgMutation)
  1008. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  1009. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  1010. m := &BatchMsgMutation{
  1011. config: c,
  1012. op: op,
  1013. typ: TypeBatchMsg,
  1014. clearedFields: make(map[string]struct{}),
  1015. }
  1016. for _, opt := range opts {
  1017. opt(m)
  1018. }
  1019. return m
  1020. }
  1021. // withBatchMsgID sets the ID field of the mutation.
  1022. func withBatchMsgID(id uint64) batchmsgOption {
  1023. return func(m *BatchMsgMutation) {
  1024. var (
  1025. err error
  1026. once sync.Once
  1027. value *BatchMsg
  1028. )
  1029. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  1030. once.Do(func() {
  1031. if m.done {
  1032. err = errors.New("querying old values post mutation is not allowed")
  1033. } else {
  1034. value, err = m.Client().BatchMsg.Get(ctx, id)
  1035. }
  1036. })
  1037. return value, err
  1038. }
  1039. m.id = &id
  1040. }
  1041. }
  1042. // withBatchMsg sets the old BatchMsg of the mutation.
  1043. func withBatchMsg(node *BatchMsg) batchmsgOption {
  1044. return func(m *BatchMsgMutation) {
  1045. m.oldValue = func(context.Context) (*BatchMsg, error) {
  1046. return node, nil
  1047. }
  1048. m.id = &node.ID
  1049. }
  1050. }
  1051. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1052. // executed in a transaction (ent.Tx), a transactional client is returned.
  1053. func (m BatchMsgMutation) Client() *Client {
  1054. client := &Client{config: m.config}
  1055. client.init()
  1056. return client
  1057. }
  1058. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1059. // it returns an error otherwise.
  1060. func (m BatchMsgMutation) Tx() (*Tx, error) {
  1061. if _, ok := m.driver.(*txDriver); !ok {
  1062. return nil, errors.New("ent: mutation is not running in a transaction")
  1063. }
  1064. tx := &Tx{config: m.config}
  1065. tx.init()
  1066. return tx, nil
  1067. }
  1068. // SetID sets the value of the id field. Note that this
  1069. // operation is only accepted on creation of BatchMsg entities.
  1070. func (m *BatchMsgMutation) SetID(id uint64) {
  1071. m.id = &id
  1072. }
  1073. // ID returns the ID value in the mutation. Note that the ID is only available
  1074. // if it was provided to the builder or after it was returned from the database.
  1075. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  1076. if m.id == nil {
  1077. return
  1078. }
  1079. return *m.id, true
  1080. }
  1081. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1082. // That means, if the mutation is applied within a transaction with an isolation level such
  1083. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1084. // or updated by the mutation.
  1085. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  1086. switch {
  1087. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1088. id, exists := m.ID()
  1089. if exists {
  1090. return []uint64{id}, nil
  1091. }
  1092. fallthrough
  1093. case m.op.Is(OpUpdate | OpDelete):
  1094. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  1095. default:
  1096. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1097. }
  1098. }
  1099. // SetCreatedAt sets the "created_at" field.
  1100. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  1101. m.created_at = &t
  1102. }
  1103. // CreatedAt returns the value of the "created_at" field in the mutation.
  1104. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  1105. v := m.created_at
  1106. if v == nil {
  1107. return
  1108. }
  1109. return *v, true
  1110. }
  1111. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  1112. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1114. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  1115. if !m.op.Is(OpUpdateOne) {
  1116. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  1117. }
  1118. if m.id == nil || m.oldValue == nil {
  1119. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  1120. }
  1121. oldValue, err := m.oldValue(ctx)
  1122. if err != nil {
  1123. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  1124. }
  1125. return oldValue.CreatedAt, nil
  1126. }
  1127. // ResetCreatedAt resets all changes to the "created_at" field.
  1128. func (m *BatchMsgMutation) ResetCreatedAt() {
  1129. m.created_at = nil
  1130. }
  1131. // SetUpdatedAt sets the "updated_at" field.
  1132. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  1133. m.updated_at = &t
  1134. }
  1135. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  1136. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  1137. v := m.updated_at
  1138. if v == nil {
  1139. return
  1140. }
  1141. return *v, true
  1142. }
  1143. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  1144. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1146. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  1147. if !m.op.Is(OpUpdateOne) {
  1148. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  1149. }
  1150. if m.id == nil || m.oldValue == nil {
  1151. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  1152. }
  1153. oldValue, err := m.oldValue(ctx)
  1154. if err != nil {
  1155. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  1156. }
  1157. return oldValue.UpdatedAt, nil
  1158. }
  1159. // ResetUpdatedAt resets all changes to the "updated_at" field.
  1160. func (m *BatchMsgMutation) ResetUpdatedAt() {
  1161. m.updated_at = nil
  1162. }
  1163. // SetDeletedAt sets the "deleted_at" field.
  1164. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  1165. m.deleted_at = &t
  1166. }
  1167. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  1168. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  1169. v := m.deleted_at
  1170. if v == nil {
  1171. return
  1172. }
  1173. return *v, true
  1174. }
  1175. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  1176. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1178. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  1179. if !m.op.Is(OpUpdateOne) {
  1180. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  1181. }
  1182. if m.id == nil || m.oldValue == nil {
  1183. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  1184. }
  1185. oldValue, err := m.oldValue(ctx)
  1186. if err != nil {
  1187. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  1188. }
  1189. return oldValue.DeletedAt, nil
  1190. }
  1191. // ClearDeletedAt clears the value of the "deleted_at" field.
  1192. func (m *BatchMsgMutation) ClearDeletedAt() {
  1193. m.deleted_at = nil
  1194. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  1195. }
  1196. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  1197. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  1198. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  1199. return ok
  1200. }
  1201. // ResetDeletedAt resets all changes to the "deleted_at" field.
  1202. func (m *BatchMsgMutation) ResetDeletedAt() {
  1203. m.deleted_at = nil
  1204. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  1205. }
  1206. // SetStatus sets the "status" field.
  1207. func (m *BatchMsgMutation) SetStatus(u uint8) {
  1208. m.status = &u
  1209. m.addstatus = nil
  1210. }
  1211. // Status returns the value of the "status" field in the mutation.
  1212. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  1213. v := m.status
  1214. if v == nil {
  1215. return
  1216. }
  1217. return *v, true
  1218. }
  1219. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  1220. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1222. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  1223. if !m.op.Is(OpUpdateOne) {
  1224. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  1225. }
  1226. if m.id == nil || m.oldValue == nil {
  1227. return v, errors.New("OldStatus requires an ID field in the mutation")
  1228. }
  1229. oldValue, err := m.oldValue(ctx)
  1230. if err != nil {
  1231. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  1232. }
  1233. return oldValue.Status, nil
  1234. }
  1235. // AddStatus adds u to the "status" field.
  1236. func (m *BatchMsgMutation) AddStatus(u int8) {
  1237. if m.addstatus != nil {
  1238. *m.addstatus += u
  1239. } else {
  1240. m.addstatus = &u
  1241. }
  1242. }
  1243. // AddedStatus returns the value that was added to the "status" field in this mutation.
  1244. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  1245. v := m.addstatus
  1246. if v == nil {
  1247. return
  1248. }
  1249. return *v, true
  1250. }
  1251. // ClearStatus clears the value of the "status" field.
  1252. func (m *BatchMsgMutation) ClearStatus() {
  1253. m.status = nil
  1254. m.addstatus = nil
  1255. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  1256. }
  1257. // StatusCleared returns if the "status" field was cleared in this mutation.
  1258. func (m *BatchMsgMutation) StatusCleared() bool {
  1259. _, ok := m.clearedFields[batchmsg.FieldStatus]
  1260. return ok
  1261. }
  1262. // ResetStatus resets all changes to the "status" field.
  1263. func (m *BatchMsgMutation) ResetStatus() {
  1264. m.status = nil
  1265. m.addstatus = nil
  1266. delete(m.clearedFields, batchmsg.FieldStatus)
  1267. }
  1268. // SetBatchNo sets the "batch_no" field.
  1269. func (m *BatchMsgMutation) SetBatchNo(s string) {
  1270. m.batch_no = &s
  1271. }
  1272. // BatchNo returns the value of the "batch_no" field in the mutation.
  1273. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  1274. v := m.batch_no
  1275. if v == nil {
  1276. return
  1277. }
  1278. return *v, true
  1279. }
  1280. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  1281. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1282. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1283. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  1284. if !m.op.Is(OpUpdateOne) {
  1285. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  1286. }
  1287. if m.id == nil || m.oldValue == nil {
  1288. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  1289. }
  1290. oldValue, err := m.oldValue(ctx)
  1291. if err != nil {
  1292. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  1293. }
  1294. return oldValue.BatchNo, nil
  1295. }
  1296. // ClearBatchNo clears the value of the "batch_no" field.
  1297. func (m *BatchMsgMutation) ClearBatchNo() {
  1298. m.batch_no = nil
  1299. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  1300. }
  1301. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  1302. func (m *BatchMsgMutation) BatchNoCleared() bool {
  1303. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  1304. return ok
  1305. }
  1306. // ResetBatchNo resets all changes to the "batch_no" field.
  1307. func (m *BatchMsgMutation) ResetBatchNo() {
  1308. m.batch_no = nil
  1309. delete(m.clearedFields, batchmsg.FieldBatchNo)
  1310. }
  1311. // SetTaskName sets the "task_name" field.
  1312. func (m *BatchMsgMutation) SetTaskName(s string) {
  1313. m.task_name = &s
  1314. }
  1315. // TaskName returns the value of the "task_name" field in the mutation.
  1316. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  1317. v := m.task_name
  1318. if v == nil {
  1319. return
  1320. }
  1321. return *v, true
  1322. }
  1323. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  1324. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1326. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  1327. if !m.op.Is(OpUpdateOne) {
  1328. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  1329. }
  1330. if m.id == nil || m.oldValue == nil {
  1331. return v, errors.New("OldTaskName requires an ID field in the mutation")
  1332. }
  1333. oldValue, err := m.oldValue(ctx)
  1334. if err != nil {
  1335. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  1336. }
  1337. return oldValue.TaskName, nil
  1338. }
  1339. // ClearTaskName clears the value of the "task_name" field.
  1340. func (m *BatchMsgMutation) ClearTaskName() {
  1341. m.task_name = nil
  1342. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  1343. }
  1344. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  1345. func (m *BatchMsgMutation) TaskNameCleared() bool {
  1346. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  1347. return ok
  1348. }
  1349. // ResetTaskName resets all changes to the "task_name" field.
  1350. func (m *BatchMsgMutation) ResetTaskName() {
  1351. m.task_name = nil
  1352. delete(m.clearedFields, batchmsg.FieldTaskName)
  1353. }
  1354. // SetFromwxid sets the "fromwxid" field.
  1355. func (m *BatchMsgMutation) SetFromwxid(s string) {
  1356. m.fromwxid = &s
  1357. }
  1358. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  1359. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  1360. v := m.fromwxid
  1361. if v == nil {
  1362. return
  1363. }
  1364. return *v, true
  1365. }
  1366. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  1367. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1369. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  1370. if !m.op.Is(OpUpdateOne) {
  1371. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  1372. }
  1373. if m.id == nil || m.oldValue == nil {
  1374. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  1375. }
  1376. oldValue, err := m.oldValue(ctx)
  1377. if err != nil {
  1378. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  1379. }
  1380. return oldValue.Fromwxid, nil
  1381. }
  1382. // ClearFromwxid clears the value of the "fromwxid" field.
  1383. func (m *BatchMsgMutation) ClearFromwxid() {
  1384. m.fromwxid = nil
  1385. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  1386. }
  1387. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  1388. func (m *BatchMsgMutation) FromwxidCleared() bool {
  1389. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  1390. return ok
  1391. }
  1392. // ResetFromwxid resets all changes to the "fromwxid" field.
  1393. func (m *BatchMsgMutation) ResetFromwxid() {
  1394. m.fromwxid = nil
  1395. delete(m.clearedFields, batchmsg.FieldFromwxid)
  1396. }
  1397. // SetMsg sets the "msg" field.
  1398. func (m *BatchMsgMutation) SetMsg(s string) {
  1399. m.msg = &s
  1400. }
  1401. // Msg returns the value of the "msg" field in the mutation.
  1402. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  1403. v := m.msg
  1404. if v == nil {
  1405. return
  1406. }
  1407. return *v, true
  1408. }
  1409. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  1410. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1412. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  1413. if !m.op.Is(OpUpdateOne) {
  1414. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  1415. }
  1416. if m.id == nil || m.oldValue == nil {
  1417. return v, errors.New("OldMsg requires an ID field in the mutation")
  1418. }
  1419. oldValue, err := m.oldValue(ctx)
  1420. if err != nil {
  1421. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  1422. }
  1423. return oldValue.Msg, nil
  1424. }
  1425. // ClearMsg clears the value of the "msg" field.
  1426. func (m *BatchMsgMutation) ClearMsg() {
  1427. m.msg = nil
  1428. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  1429. }
  1430. // MsgCleared returns if the "msg" field was cleared in this mutation.
  1431. func (m *BatchMsgMutation) MsgCleared() bool {
  1432. _, ok := m.clearedFields[batchmsg.FieldMsg]
  1433. return ok
  1434. }
  1435. // ResetMsg resets all changes to the "msg" field.
  1436. func (m *BatchMsgMutation) ResetMsg() {
  1437. m.msg = nil
  1438. delete(m.clearedFields, batchmsg.FieldMsg)
  1439. }
  1440. // SetTag sets the "tag" field.
  1441. func (m *BatchMsgMutation) SetTag(s string) {
  1442. m.tag = &s
  1443. }
  1444. // Tag returns the value of the "tag" field in the mutation.
  1445. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  1446. v := m.tag
  1447. if v == nil {
  1448. return
  1449. }
  1450. return *v, true
  1451. }
  1452. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  1453. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1455. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  1456. if !m.op.Is(OpUpdateOne) {
  1457. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  1458. }
  1459. if m.id == nil || m.oldValue == nil {
  1460. return v, errors.New("OldTag requires an ID field in the mutation")
  1461. }
  1462. oldValue, err := m.oldValue(ctx)
  1463. if err != nil {
  1464. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  1465. }
  1466. return oldValue.Tag, nil
  1467. }
  1468. // ClearTag clears the value of the "tag" field.
  1469. func (m *BatchMsgMutation) ClearTag() {
  1470. m.tag = nil
  1471. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  1472. }
  1473. // TagCleared returns if the "tag" field was cleared in this mutation.
  1474. func (m *BatchMsgMutation) TagCleared() bool {
  1475. _, ok := m.clearedFields[batchmsg.FieldTag]
  1476. return ok
  1477. }
  1478. // ResetTag resets all changes to the "tag" field.
  1479. func (m *BatchMsgMutation) ResetTag() {
  1480. m.tag = nil
  1481. delete(m.clearedFields, batchmsg.FieldTag)
  1482. }
  1483. // SetTotal sets the "total" field.
  1484. func (m *BatchMsgMutation) SetTotal(i int32) {
  1485. m.total = &i
  1486. m.addtotal = nil
  1487. }
  1488. // Total returns the value of the "total" field in the mutation.
  1489. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  1490. v := m.total
  1491. if v == nil {
  1492. return
  1493. }
  1494. return *v, true
  1495. }
  1496. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  1497. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1499. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  1500. if !m.op.Is(OpUpdateOne) {
  1501. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  1502. }
  1503. if m.id == nil || m.oldValue == nil {
  1504. return v, errors.New("OldTotal requires an ID field in the mutation")
  1505. }
  1506. oldValue, err := m.oldValue(ctx)
  1507. if err != nil {
  1508. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  1509. }
  1510. return oldValue.Total, nil
  1511. }
  1512. // AddTotal adds i to the "total" field.
  1513. func (m *BatchMsgMutation) AddTotal(i int32) {
  1514. if m.addtotal != nil {
  1515. *m.addtotal += i
  1516. } else {
  1517. m.addtotal = &i
  1518. }
  1519. }
  1520. // AddedTotal returns the value that was added to the "total" field in this mutation.
  1521. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  1522. v := m.addtotal
  1523. if v == nil {
  1524. return
  1525. }
  1526. return *v, true
  1527. }
  1528. // ClearTotal clears the value of the "total" field.
  1529. func (m *BatchMsgMutation) ClearTotal() {
  1530. m.total = nil
  1531. m.addtotal = nil
  1532. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  1533. }
  1534. // TotalCleared returns if the "total" field was cleared in this mutation.
  1535. func (m *BatchMsgMutation) TotalCleared() bool {
  1536. _, ok := m.clearedFields[batchmsg.FieldTotal]
  1537. return ok
  1538. }
  1539. // ResetTotal resets all changes to the "total" field.
  1540. func (m *BatchMsgMutation) ResetTotal() {
  1541. m.total = nil
  1542. m.addtotal = nil
  1543. delete(m.clearedFields, batchmsg.FieldTotal)
  1544. }
  1545. // SetSuccess sets the "success" field.
  1546. func (m *BatchMsgMutation) SetSuccess(i int32) {
  1547. m.success = &i
  1548. m.addsuccess = nil
  1549. }
  1550. // Success returns the value of the "success" field in the mutation.
  1551. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  1552. v := m.success
  1553. if v == nil {
  1554. return
  1555. }
  1556. return *v, true
  1557. }
  1558. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  1559. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1561. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  1562. if !m.op.Is(OpUpdateOne) {
  1563. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  1564. }
  1565. if m.id == nil || m.oldValue == nil {
  1566. return v, errors.New("OldSuccess requires an ID field in the mutation")
  1567. }
  1568. oldValue, err := m.oldValue(ctx)
  1569. if err != nil {
  1570. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  1571. }
  1572. return oldValue.Success, nil
  1573. }
  1574. // AddSuccess adds i to the "success" field.
  1575. func (m *BatchMsgMutation) AddSuccess(i int32) {
  1576. if m.addsuccess != nil {
  1577. *m.addsuccess += i
  1578. } else {
  1579. m.addsuccess = &i
  1580. }
  1581. }
  1582. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  1583. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  1584. v := m.addsuccess
  1585. if v == nil {
  1586. return
  1587. }
  1588. return *v, true
  1589. }
  1590. // ClearSuccess clears the value of the "success" field.
  1591. func (m *BatchMsgMutation) ClearSuccess() {
  1592. m.success = nil
  1593. m.addsuccess = nil
  1594. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  1595. }
  1596. // SuccessCleared returns if the "success" field was cleared in this mutation.
  1597. func (m *BatchMsgMutation) SuccessCleared() bool {
  1598. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  1599. return ok
  1600. }
  1601. // ResetSuccess resets all changes to the "success" field.
  1602. func (m *BatchMsgMutation) ResetSuccess() {
  1603. m.success = nil
  1604. m.addsuccess = nil
  1605. delete(m.clearedFields, batchmsg.FieldSuccess)
  1606. }
  1607. // SetFail sets the "fail" field.
  1608. func (m *BatchMsgMutation) SetFail(i int32) {
  1609. m.fail = &i
  1610. m.addfail = nil
  1611. }
  1612. // Fail returns the value of the "fail" field in the mutation.
  1613. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  1614. v := m.fail
  1615. if v == nil {
  1616. return
  1617. }
  1618. return *v, true
  1619. }
  1620. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  1621. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1623. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  1624. if !m.op.Is(OpUpdateOne) {
  1625. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  1626. }
  1627. if m.id == nil || m.oldValue == nil {
  1628. return v, errors.New("OldFail requires an ID field in the mutation")
  1629. }
  1630. oldValue, err := m.oldValue(ctx)
  1631. if err != nil {
  1632. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  1633. }
  1634. return oldValue.Fail, nil
  1635. }
  1636. // AddFail adds i to the "fail" field.
  1637. func (m *BatchMsgMutation) AddFail(i int32) {
  1638. if m.addfail != nil {
  1639. *m.addfail += i
  1640. } else {
  1641. m.addfail = &i
  1642. }
  1643. }
  1644. // AddedFail returns the value that was added to the "fail" field in this mutation.
  1645. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  1646. v := m.addfail
  1647. if v == nil {
  1648. return
  1649. }
  1650. return *v, true
  1651. }
  1652. // ClearFail clears the value of the "fail" field.
  1653. func (m *BatchMsgMutation) ClearFail() {
  1654. m.fail = nil
  1655. m.addfail = nil
  1656. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  1657. }
  1658. // FailCleared returns if the "fail" field was cleared in this mutation.
  1659. func (m *BatchMsgMutation) FailCleared() bool {
  1660. _, ok := m.clearedFields[batchmsg.FieldFail]
  1661. return ok
  1662. }
  1663. // ResetFail resets all changes to the "fail" field.
  1664. func (m *BatchMsgMutation) ResetFail() {
  1665. m.fail = nil
  1666. m.addfail = nil
  1667. delete(m.clearedFields, batchmsg.FieldFail)
  1668. }
  1669. // SetStartTime sets the "start_time" field.
  1670. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  1671. m.start_time = &t
  1672. }
  1673. // StartTime returns the value of the "start_time" field in the mutation.
  1674. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  1675. v := m.start_time
  1676. if v == nil {
  1677. return
  1678. }
  1679. return *v, true
  1680. }
  1681. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  1682. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1684. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  1685. if !m.op.Is(OpUpdateOne) {
  1686. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  1687. }
  1688. if m.id == nil || m.oldValue == nil {
  1689. return v, errors.New("OldStartTime requires an ID field in the mutation")
  1690. }
  1691. oldValue, err := m.oldValue(ctx)
  1692. if err != nil {
  1693. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  1694. }
  1695. return oldValue.StartTime, nil
  1696. }
  1697. // ClearStartTime clears the value of the "start_time" field.
  1698. func (m *BatchMsgMutation) ClearStartTime() {
  1699. m.start_time = nil
  1700. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  1701. }
  1702. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  1703. func (m *BatchMsgMutation) StartTimeCleared() bool {
  1704. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  1705. return ok
  1706. }
  1707. // ResetStartTime resets all changes to the "start_time" field.
  1708. func (m *BatchMsgMutation) ResetStartTime() {
  1709. m.start_time = nil
  1710. delete(m.clearedFields, batchmsg.FieldStartTime)
  1711. }
  1712. // SetStopTime sets the "stop_time" field.
  1713. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  1714. m.stop_time = &t
  1715. }
  1716. // StopTime returns the value of the "stop_time" field in the mutation.
  1717. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  1718. v := m.stop_time
  1719. if v == nil {
  1720. return
  1721. }
  1722. return *v, true
  1723. }
  1724. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  1725. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1727. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  1728. if !m.op.Is(OpUpdateOne) {
  1729. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  1730. }
  1731. if m.id == nil || m.oldValue == nil {
  1732. return v, errors.New("OldStopTime requires an ID field in the mutation")
  1733. }
  1734. oldValue, err := m.oldValue(ctx)
  1735. if err != nil {
  1736. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  1737. }
  1738. return oldValue.StopTime, nil
  1739. }
  1740. // ClearStopTime clears the value of the "stop_time" field.
  1741. func (m *BatchMsgMutation) ClearStopTime() {
  1742. m.stop_time = nil
  1743. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  1744. }
  1745. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  1746. func (m *BatchMsgMutation) StopTimeCleared() bool {
  1747. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  1748. return ok
  1749. }
  1750. // ResetStopTime resets all changes to the "stop_time" field.
  1751. func (m *BatchMsgMutation) ResetStopTime() {
  1752. m.stop_time = nil
  1753. delete(m.clearedFields, batchmsg.FieldStopTime)
  1754. }
  1755. // SetSendTime sets the "send_time" field.
  1756. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  1757. m.send_time = &t
  1758. }
  1759. // SendTime returns the value of the "send_time" field in the mutation.
  1760. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  1761. v := m.send_time
  1762. if v == nil {
  1763. return
  1764. }
  1765. return *v, true
  1766. }
  1767. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  1768. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1769. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1770. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  1771. if !m.op.Is(OpUpdateOne) {
  1772. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  1773. }
  1774. if m.id == nil || m.oldValue == nil {
  1775. return v, errors.New("OldSendTime requires an ID field in the mutation")
  1776. }
  1777. oldValue, err := m.oldValue(ctx)
  1778. if err != nil {
  1779. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  1780. }
  1781. return oldValue.SendTime, nil
  1782. }
  1783. // ClearSendTime clears the value of the "send_time" field.
  1784. func (m *BatchMsgMutation) ClearSendTime() {
  1785. m.send_time = nil
  1786. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  1787. }
  1788. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  1789. func (m *BatchMsgMutation) SendTimeCleared() bool {
  1790. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  1791. return ok
  1792. }
  1793. // ResetSendTime resets all changes to the "send_time" field.
  1794. func (m *BatchMsgMutation) ResetSendTime() {
  1795. m.send_time = nil
  1796. delete(m.clearedFields, batchmsg.FieldSendTime)
  1797. }
  1798. // SetType sets the "type" field.
  1799. func (m *BatchMsgMutation) SetType(i int32) {
  1800. m._type = &i
  1801. m.add_type = nil
  1802. }
  1803. // GetType returns the value of the "type" field in the mutation.
  1804. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  1805. v := m._type
  1806. if v == nil {
  1807. return
  1808. }
  1809. return *v, true
  1810. }
  1811. // OldType returns the old "type" field's value of the BatchMsg entity.
  1812. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1814. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  1815. if !m.op.Is(OpUpdateOne) {
  1816. return v, errors.New("OldType is only allowed on UpdateOne operations")
  1817. }
  1818. if m.id == nil || m.oldValue == nil {
  1819. return v, errors.New("OldType requires an ID field in the mutation")
  1820. }
  1821. oldValue, err := m.oldValue(ctx)
  1822. if err != nil {
  1823. return v, fmt.Errorf("querying old value for OldType: %w", err)
  1824. }
  1825. return oldValue.Type, nil
  1826. }
  1827. // AddType adds i to the "type" field.
  1828. func (m *BatchMsgMutation) AddType(i int32) {
  1829. if m.add_type != nil {
  1830. *m.add_type += i
  1831. } else {
  1832. m.add_type = &i
  1833. }
  1834. }
  1835. // AddedType returns the value that was added to the "type" field in this mutation.
  1836. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  1837. v := m.add_type
  1838. if v == nil {
  1839. return
  1840. }
  1841. return *v, true
  1842. }
  1843. // ClearType clears the value of the "type" field.
  1844. func (m *BatchMsgMutation) ClearType() {
  1845. m._type = nil
  1846. m.add_type = nil
  1847. m.clearedFields[batchmsg.FieldType] = struct{}{}
  1848. }
  1849. // TypeCleared returns if the "type" field was cleared in this mutation.
  1850. func (m *BatchMsgMutation) TypeCleared() bool {
  1851. _, ok := m.clearedFields[batchmsg.FieldType]
  1852. return ok
  1853. }
  1854. // ResetType resets all changes to the "type" field.
  1855. func (m *BatchMsgMutation) ResetType() {
  1856. m._type = nil
  1857. m.add_type = nil
  1858. delete(m.clearedFields, batchmsg.FieldType)
  1859. }
  1860. // Where appends a list predicates to the BatchMsgMutation builder.
  1861. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  1862. m.predicates = append(m.predicates, ps...)
  1863. }
  1864. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  1865. // users can use type-assertion to append predicates that do not depend on any generated package.
  1866. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  1867. p := make([]predicate.BatchMsg, len(ps))
  1868. for i := range ps {
  1869. p[i] = ps[i]
  1870. }
  1871. m.Where(p...)
  1872. }
  1873. // Op returns the operation name.
  1874. func (m *BatchMsgMutation) Op() Op {
  1875. return m.op
  1876. }
  1877. // SetOp allows setting the mutation operation.
  1878. func (m *BatchMsgMutation) SetOp(op Op) {
  1879. m.op = op
  1880. }
  1881. // Type returns the node type of this mutation (BatchMsg).
  1882. func (m *BatchMsgMutation) Type() string {
  1883. return m.typ
  1884. }
  1885. // Fields returns all fields that were changed during this mutation. Note that in
  1886. // order to get all numeric fields that were incremented/decremented, call
  1887. // AddedFields().
  1888. func (m *BatchMsgMutation) Fields() []string {
  1889. fields := make([]string, 0, 16)
  1890. if m.created_at != nil {
  1891. fields = append(fields, batchmsg.FieldCreatedAt)
  1892. }
  1893. if m.updated_at != nil {
  1894. fields = append(fields, batchmsg.FieldUpdatedAt)
  1895. }
  1896. if m.deleted_at != nil {
  1897. fields = append(fields, batchmsg.FieldDeletedAt)
  1898. }
  1899. if m.status != nil {
  1900. fields = append(fields, batchmsg.FieldStatus)
  1901. }
  1902. if m.batch_no != nil {
  1903. fields = append(fields, batchmsg.FieldBatchNo)
  1904. }
  1905. if m.task_name != nil {
  1906. fields = append(fields, batchmsg.FieldTaskName)
  1907. }
  1908. if m.fromwxid != nil {
  1909. fields = append(fields, batchmsg.FieldFromwxid)
  1910. }
  1911. if m.msg != nil {
  1912. fields = append(fields, batchmsg.FieldMsg)
  1913. }
  1914. if m.tag != nil {
  1915. fields = append(fields, batchmsg.FieldTag)
  1916. }
  1917. if m.total != nil {
  1918. fields = append(fields, batchmsg.FieldTotal)
  1919. }
  1920. if m.success != nil {
  1921. fields = append(fields, batchmsg.FieldSuccess)
  1922. }
  1923. if m.fail != nil {
  1924. fields = append(fields, batchmsg.FieldFail)
  1925. }
  1926. if m.start_time != nil {
  1927. fields = append(fields, batchmsg.FieldStartTime)
  1928. }
  1929. if m.stop_time != nil {
  1930. fields = append(fields, batchmsg.FieldStopTime)
  1931. }
  1932. if m.send_time != nil {
  1933. fields = append(fields, batchmsg.FieldSendTime)
  1934. }
  1935. if m._type != nil {
  1936. fields = append(fields, batchmsg.FieldType)
  1937. }
  1938. return fields
  1939. }
  1940. // Field returns the value of a field with the given name. The second boolean
  1941. // return value indicates that this field was not set, or was not defined in the
  1942. // schema.
  1943. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  1944. switch name {
  1945. case batchmsg.FieldCreatedAt:
  1946. return m.CreatedAt()
  1947. case batchmsg.FieldUpdatedAt:
  1948. return m.UpdatedAt()
  1949. case batchmsg.FieldDeletedAt:
  1950. return m.DeletedAt()
  1951. case batchmsg.FieldStatus:
  1952. return m.Status()
  1953. case batchmsg.FieldBatchNo:
  1954. return m.BatchNo()
  1955. case batchmsg.FieldTaskName:
  1956. return m.TaskName()
  1957. case batchmsg.FieldFromwxid:
  1958. return m.Fromwxid()
  1959. case batchmsg.FieldMsg:
  1960. return m.Msg()
  1961. case batchmsg.FieldTag:
  1962. return m.Tag()
  1963. case batchmsg.FieldTotal:
  1964. return m.Total()
  1965. case batchmsg.FieldSuccess:
  1966. return m.Success()
  1967. case batchmsg.FieldFail:
  1968. return m.Fail()
  1969. case batchmsg.FieldStartTime:
  1970. return m.StartTime()
  1971. case batchmsg.FieldStopTime:
  1972. return m.StopTime()
  1973. case batchmsg.FieldSendTime:
  1974. return m.SendTime()
  1975. case batchmsg.FieldType:
  1976. return m.GetType()
  1977. }
  1978. return nil, false
  1979. }
  1980. // OldField returns the old value of the field from the database. An error is
  1981. // returned if the mutation operation is not UpdateOne, or the query to the
  1982. // database failed.
  1983. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1984. switch name {
  1985. case batchmsg.FieldCreatedAt:
  1986. return m.OldCreatedAt(ctx)
  1987. case batchmsg.FieldUpdatedAt:
  1988. return m.OldUpdatedAt(ctx)
  1989. case batchmsg.FieldDeletedAt:
  1990. return m.OldDeletedAt(ctx)
  1991. case batchmsg.FieldStatus:
  1992. return m.OldStatus(ctx)
  1993. case batchmsg.FieldBatchNo:
  1994. return m.OldBatchNo(ctx)
  1995. case batchmsg.FieldTaskName:
  1996. return m.OldTaskName(ctx)
  1997. case batchmsg.FieldFromwxid:
  1998. return m.OldFromwxid(ctx)
  1999. case batchmsg.FieldMsg:
  2000. return m.OldMsg(ctx)
  2001. case batchmsg.FieldTag:
  2002. return m.OldTag(ctx)
  2003. case batchmsg.FieldTotal:
  2004. return m.OldTotal(ctx)
  2005. case batchmsg.FieldSuccess:
  2006. return m.OldSuccess(ctx)
  2007. case batchmsg.FieldFail:
  2008. return m.OldFail(ctx)
  2009. case batchmsg.FieldStartTime:
  2010. return m.OldStartTime(ctx)
  2011. case batchmsg.FieldStopTime:
  2012. return m.OldStopTime(ctx)
  2013. case batchmsg.FieldSendTime:
  2014. return m.OldSendTime(ctx)
  2015. case batchmsg.FieldType:
  2016. return m.OldType(ctx)
  2017. }
  2018. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  2019. }
  2020. // SetField sets the value of a field with the given name. It returns an error if
  2021. // the field is not defined in the schema, or if the type mismatched the field
  2022. // type.
  2023. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  2024. switch name {
  2025. case batchmsg.FieldCreatedAt:
  2026. v, ok := value.(time.Time)
  2027. if !ok {
  2028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2029. }
  2030. m.SetCreatedAt(v)
  2031. return nil
  2032. case batchmsg.FieldUpdatedAt:
  2033. v, ok := value.(time.Time)
  2034. if !ok {
  2035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2036. }
  2037. m.SetUpdatedAt(v)
  2038. return nil
  2039. case batchmsg.FieldDeletedAt:
  2040. v, ok := value.(time.Time)
  2041. if !ok {
  2042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2043. }
  2044. m.SetDeletedAt(v)
  2045. return nil
  2046. case batchmsg.FieldStatus:
  2047. v, ok := value.(uint8)
  2048. if !ok {
  2049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2050. }
  2051. m.SetStatus(v)
  2052. return nil
  2053. case batchmsg.FieldBatchNo:
  2054. v, ok := value.(string)
  2055. if !ok {
  2056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2057. }
  2058. m.SetBatchNo(v)
  2059. return nil
  2060. case batchmsg.FieldTaskName:
  2061. v, ok := value.(string)
  2062. if !ok {
  2063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2064. }
  2065. m.SetTaskName(v)
  2066. return nil
  2067. case batchmsg.FieldFromwxid:
  2068. v, ok := value.(string)
  2069. if !ok {
  2070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2071. }
  2072. m.SetFromwxid(v)
  2073. return nil
  2074. case batchmsg.FieldMsg:
  2075. v, ok := value.(string)
  2076. if !ok {
  2077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2078. }
  2079. m.SetMsg(v)
  2080. return nil
  2081. case batchmsg.FieldTag:
  2082. v, ok := value.(string)
  2083. if !ok {
  2084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2085. }
  2086. m.SetTag(v)
  2087. return nil
  2088. case batchmsg.FieldTotal:
  2089. v, ok := value.(int32)
  2090. if !ok {
  2091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2092. }
  2093. m.SetTotal(v)
  2094. return nil
  2095. case batchmsg.FieldSuccess:
  2096. v, ok := value.(int32)
  2097. if !ok {
  2098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2099. }
  2100. m.SetSuccess(v)
  2101. return nil
  2102. case batchmsg.FieldFail:
  2103. v, ok := value.(int32)
  2104. if !ok {
  2105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2106. }
  2107. m.SetFail(v)
  2108. return nil
  2109. case batchmsg.FieldStartTime:
  2110. v, ok := value.(time.Time)
  2111. if !ok {
  2112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2113. }
  2114. m.SetStartTime(v)
  2115. return nil
  2116. case batchmsg.FieldStopTime:
  2117. v, ok := value.(time.Time)
  2118. if !ok {
  2119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2120. }
  2121. m.SetStopTime(v)
  2122. return nil
  2123. case batchmsg.FieldSendTime:
  2124. v, ok := value.(time.Time)
  2125. if !ok {
  2126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2127. }
  2128. m.SetSendTime(v)
  2129. return nil
  2130. case batchmsg.FieldType:
  2131. v, ok := value.(int32)
  2132. if !ok {
  2133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2134. }
  2135. m.SetType(v)
  2136. return nil
  2137. }
  2138. return fmt.Errorf("unknown BatchMsg field %s", name)
  2139. }
  2140. // AddedFields returns all numeric fields that were incremented/decremented during
  2141. // this mutation.
  2142. func (m *BatchMsgMutation) AddedFields() []string {
  2143. var fields []string
  2144. if m.addstatus != nil {
  2145. fields = append(fields, batchmsg.FieldStatus)
  2146. }
  2147. if m.addtotal != nil {
  2148. fields = append(fields, batchmsg.FieldTotal)
  2149. }
  2150. if m.addsuccess != nil {
  2151. fields = append(fields, batchmsg.FieldSuccess)
  2152. }
  2153. if m.addfail != nil {
  2154. fields = append(fields, batchmsg.FieldFail)
  2155. }
  2156. if m.add_type != nil {
  2157. fields = append(fields, batchmsg.FieldType)
  2158. }
  2159. return fields
  2160. }
  2161. // AddedField returns the numeric value that was incremented/decremented on a field
  2162. // with the given name. The second boolean return value indicates that this field
  2163. // was not set, or was not defined in the schema.
  2164. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  2165. switch name {
  2166. case batchmsg.FieldStatus:
  2167. return m.AddedStatus()
  2168. case batchmsg.FieldTotal:
  2169. return m.AddedTotal()
  2170. case batchmsg.FieldSuccess:
  2171. return m.AddedSuccess()
  2172. case batchmsg.FieldFail:
  2173. return m.AddedFail()
  2174. case batchmsg.FieldType:
  2175. return m.AddedType()
  2176. }
  2177. return nil, false
  2178. }
  2179. // AddField adds the value to the field with the given name. It returns an error if
  2180. // the field is not defined in the schema, or if the type mismatched the field
  2181. // type.
  2182. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  2183. switch name {
  2184. case batchmsg.FieldStatus:
  2185. v, ok := value.(int8)
  2186. if !ok {
  2187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2188. }
  2189. m.AddStatus(v)
  2190. return nil
  2191. case batchmsg.FieldTotal:
  2192. v, ok := value.(int32)
  2193. if !ok {
  2194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2195. }
  2196. m.AddTotal(v)
  2197. return nil
  2198. case batchmsg.FieldSuccess:
  2199. v, ok := value.(int32)
  2200. if !ok {
  2201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2202. }
  2203. m.AddSuccess(v)
  2204. return nil
  2205. case batchmsg.FieldFail:
  2206. v, ok := value.(int32)
  2207. if !ok {
  2208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2209. }
  2210. m.AddFail(v)
  2211. return nil
  2212. case batchmsg.FieldType:
  2213. v, ok := value.(int32)
  2214. if !ok {
  2215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2216. }
  2217. m.AddType(v)
  2218. return nil
  2219. }
  2220. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  2221. }
  2222. // ClearedFields returns all nullable fields that were cleared during this
  2223. // mutation.
  2224. func (m *BatchMsgMutation) ClearedFields() []string {
  2225. var fields []string
  2226. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  2227. fields = append(fields, batchmsg.FieldDeletedAt)
  2228. }
  2229. if m.FieldCleared(batchmsg.FieldStatus) {
  2230. fields = append(fields, batchmsg.FieldStatus)
  2231. }
  2232. if m.FieldCleared(batchmsg.FieldBatchNo) {
  2233. fields = append(fields, batchmsg.FieldBatchNo)
  2234. }
  2235. if m.FieldCleared(batchmsg.FieldTaskName) {
  2236. fields = append(fields, batchmsg.FieldTaskName)
  2237. }
  2238. if m.FieldCleared(batchmsg.FieldFromwxid) {
  2239. fields = append(fields, batchmsg.FieldFromwxid)
  2240. }
  2241. if m.FieldCleared(batchmsg.FieldMsg) {
  2242. fields = append(fields, batchmsg.FieldMsg)
  2243. }
  2244. if m.FieldCleared(batchmsg.FieldTag) {
  2245. fields = append(fields, batchmsg.FieldTag)
  2246. }
  2247. if m.FieldCleared(batchmsg.FieldTotal) {
  2248. fields = append(fields, batchmsg.FieldTotal)
  2249. }
  2250. if m.FieldCleared(batchmsg.FieldSuccess) {
  2251. fields = append(fields, batchmsg.FieldSuccess)
  2252. }
  2253. if m.FieldCleared(batchmsg.FieldFail) {
  2254. fields = append(fields, batchmsg.FieldFail)
  2255. }
  2256. if m.FieldCleared(batchmsg.FieldStartTime) {
  2257. fields = append(fields, batchmsg.FieldStartTime)
  2258. }
  2259. if m.FieldCleared(batchmsg.FieldStopTime) {
  2260. fields = append(fields, batchmsg.FieldStopTime)
  2261. }
  2262. if m.FieldCleared(batchmsg.FieldSendTime) {
  2263. fields = append(fields, batchmsg.FieldSendTime)
  2264. }
  2265. if m.FieldCleared(batchmsg.FieldType) {
  2266. fields = append(fields, batchmsg.FieldType)
  2267. }
  2268. return fields
  2269. }
  2270. // FieldCleared returns a boolean indicating if a field with the given name was
  2271. // cleared in this mutation.
  2272. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  2273. _, ok := m.clearedFields[name]
  2274. return ok
  2275. }
  2276. // ClearField clears the value of the field with the given name. It returns an
  2277. // error if the field is not defined in the schema.
  2278. func (m *BatchMsgMutation) ClearField(name string) error {
  2279. switch name {
  2280. case batchmsg.FieldDeletedAt:
  2281. m.ClearDeletedAt()
  2282. return nil
  2283. case batchmsg.FieldStatus:
  2284. m.ClearStatus()
  2285. return nil
  2286. case batchmsg.FieldBatchNo:
  2287. m.ClearBatchNo()
  2288. return nil
  2289. case batchmsg.FieldTaskName:
  2290. m.ClearTaskName()
  2291. return nil
  2292. case batchmsg.FieldFromwxid:
  2293. m.ClearFromwxid()
  2294. return nil
  2295. case batchmsg.FieldMsg:
  2296. m.ClearMsg()
  2297. return nil
  2298. case batchmsg.FieldTag:
  2299. m.ClearTag()
  2300. return nil
  2301. case batchmsg.FieldTotal:
  2302. m.ClearTotal()
  2303. return nil
  2304. case batchmsg.FieldSuccess:
  2305. m.ClearSuccess()
  2306. return nil
  2307. case batchmsg.FieldFail:
  2308. m.ClearFail()
  2309. return nil
  2310. case batchmsg.FieldStartTime:
  2311. m.ClearStartTime()
  2312. return nil
  2313. case batchmsg.FieldStopTime:
  2314. m.ClearStopTime()
  2315. return nil
  2316. case batchmsg.FieldSendTime:
  2317. m.ClearSendTime()
  2318. return nil
  2319. case batchmsg.FieldType:
  2320. m.ClearType()
  2321. return nil
  2322. }
  2323. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  2324. }
  2325. // ResetField resets all changes in the mutation for the field with the given name.
  2326. // It returns an error if the field is not defined in the schema.
  2327. func (m *BatchMsgMutation) ResetField(name string) error {
  2328. switch name {
  2329. case batchmsg.FieldCreatedAt:
  2330. m.ResetCreatedAt()
  2331. return nil
  2332. case batchmsg.FieldUpdatedAt:
  2333. m.ResetUpdatedAt()
  2334. return nil
  2335. case batchmsg.FieldDeletedAt:
  2336. m.ResetDeletedAt()
  2337. return nil
  2338. case batchmsg.FieldStatus:
  2339. m.ResetStatus()
  2340. return nil
  2341. case batchmsg.FieldBatchNo:
  2342. m.ResetBatchNo()
  2343. return nil
  2344. case batchmsg.FieldTaskName:
  2345. m.ResetTaskName()
  2346. return nil
  2347. case batchmsg.FieldFromwxid:
  2348. m.ResetFromwxid()
  2349. return nil
  2350. case batchmsg.FieldMsg:
  2351. m.ResetMsg()
  2352. return nil
  2353. case batchmsg.FieldTag:
  2354. m.ResetTag()
  2355. return nil
  2356. case batchmsg.FieldTotal:
  2357. m.ResetTotal()
  2358. return nil
  2359. case batchmsg.FieldSuccess:
  2360. m.ResetSuccess()
  2361. return nil
  2362. case batchmsg.FieldFail:
  2363. m.ResetFail()
  2364. return nil
  2365. case batchmsg.FieldStartTime:
  2366. m.ResetStartTime()
  2367. return nil
  2368. case batchmsg.FieldStopTime:
  2369. m.ResetStopTime()
  2370. return nil
  2371. case batchmsg.FieldSendTime:
  2372. m.ResetSendTime()
  2373. return nil
  2374. case batchmsg.FieldType:
  2375. m.ResetType()
  2376. return nil
  2377. }
  2378. return fmt.Errorf("unknown BatchMsg field %s", name)
  2379. }
  2380. // AddedEdges returns all edge names that were set/added in this mutation.
  2381. func (m *BatchMsgMutation) AddedEdges() []string {
  2382. edges := make([]string, 0, 0)
  2383. return edges
  2384. }
  2385. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2386. // name in this mutation.
  2387. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  2388. return nil
  2389. }
  2390. // RemovedEdges returns all edge names that were removed in this mutation.
  2391. func (m *BatchMsgMutation) RemovedEdges() []string {
  2392. edges := make([]string, 0, 0)
  2393. return edges
  2394. }
  2395. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2396. // the given name in this mutation.
  2397. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  2398. return nil
  2399. }
  2400. // ClearedEdges returns all edge names that were cleared in this mutation.
  2401. func (m *BatchMsgMutation) ClearedEdges() []string {
  2402. edges := make([]string, 0, 0)
  2403. return edges
  2404. }
  2405. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2406. // was cleared in this mutation.
  2407. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  2408. return false
  2409. }
  2410. // ClearEdge clears the value of the edge with the given name. It returns an error
  2411. // if that edge is not defined in the schema.
  2412. func (m *BatchMsgMutation) ClearEdge(name string) error {
  2413. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  2414. }
  2415. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2416. // It returns an error if the edge is not defined in the schema.
  2417. func (m *BatchMsgMutation) ResetEdge(name string) error {
  2418. return fmt.Errorf("unknown BatchMsg edge %s", name)
  2419. }
  2420. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  2421. type ContactMutation struct {
  2422. config
  2423. op Op
  2424. typ string
  2425. id *uint64
  2426. created_at *time.Time
  2427. updated_at *time.Time
  2428. status *uint8
  2429. addstatus *int8
  2430. deleted_at *time.Time
  2431. wx_wxid *string
  2432. _type *int
  2433. add_type *int
  2434. wxid *string
  2435. account *string
  2436. nickname *string
  2437. markname *string
  2438. headimg *string
  2439. sex *int
  2440. addsex *int
  2441. starrole *string
  2442. dontseeit *int
  2443. adddontseeit *int
  2444. dontseeme *int
  2445. adddontseeme *int
  2446. lag *string
  2447. gid *string
  2448. gname *string
  2449. v3 *string
  2450. organization_id *uint64
  2451. addorganization_id *int64
  2452. clearedFields map[string]struct{}
  2453. contact_relationships map[uint64]struct{}
  2454. removedcontact_relationships map[uint64]struct{}
  2455. clearedcontact_relationships bool
  2456. contact_messages map[uint64]struct{}
  2457. removedcontact_messages map[uint64]struct{}
  2458. clearedcontact_messages bool
  2459. done bool
  2460. oldValue func(context.Context) (*Contact, error)
  2461. predicates []predicate.Contact
  2462. }
  2463. var _ ent.Mutation = (*ContactMutation)(nil)
  2464. // contactOption allows management of the mutation configuration using functional options.
  2465. type contactOption func(*ContactMutation)
  2466. // newContactMutation creates new mutation for the Contact entity.
  2467. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  2468. m := &ContactMutation{
  2469. config: c,
  2470. op: op,
  2471. typ: TypeContact,
  2472. clearedFields: make(map[string]struct{}),
  2473. }
  2474. for _, opt := range opts {
  2475. opt(m)
  2476. }
  2477. return m
  2478. }
  2479. // withContactID sets the ID field of the mutation.
  2480. func withContactID(id uint64) contactOption {
  2481. return func(m *ContactMutation) {
  2482. var (
  2483. err error
  2484. once sync.Once
  2485. value *Contact
  2486. )
  2487. m.oldValue = func(ctx context.Context) (*Contact, error) {
  2488. once.Do(func() {
  2489. if m.done {
  2490. err = errors.New("querying old values post mutation is not allowed")
  2491. } else {
  2492. value, err = m.Client().Contact.Get(ctx, id)
  2493. }
  2494. })
  2495. return value, err
  2496. }
  2497. m.id = &id
  2498. }
  2499. }
  2500. // withContact sets the old Contact of the mutation.
  2501. func withContact(node *Contact) contactOption {
  2502. return func(m *ContactMutation) {
  2503. m.oldValue = func(context.Context) (*Contact, error) {
  2504. return node, nil
  2505. }
  2506. m.id = &node.ID
  2507. }
  2508. }
  2509. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2510. // executed in a transaction (ent.Tx), a transactional client is returned.
  2511. func (m ContactMutation) Client() *Client {
  2512. client := &Client{config: m.config}
  2513. client.init()
  2514. return client
  2515. }
  2516. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2517. // it returns an error otherwise.
  2518. func (m ContactMutation) Tx() (*Tx, error) {
  2519. if _, ok := m.driver.(*txDriver); !ok {
  2520. return nil, errors.New("ent: mutation is not running in a transaction")
  2521. }
  2522. tx := &Tx{config: m.config}
  2523. tx.init()
  2524. return tx, nil
  2525. }
  2526. // SetID sets the value of the id field. Note that this
  2527. // operation is only accepted on creation of Contact entities.
  2528. func (m *ContactMutation) SetID(id uint64) {
  2529. m.id = &id
  2530. }
  2531. // ID returns the ID value in the mutation. Note that the ID is only available
  2532. // if it was provided to the builder or after it was returned from the database.
  2533. func (m *ContactMutation) ID() (id uint64, exists bool) {
  2534. if m.id == nil {
  2535. return
  2536. }
  2537. return *m.id, true
  2538. }
  2539. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2540. // That means, if the mutation is applied within a transaction with an isolation level such
  2541. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2542. // or updated by the mutation.
  2543. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  2544. switch {
  2545. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2546. id, exists := m.ID()
  2547. if exists {
  2548. return []uint64{id}, nil
  2549. }
  2550. fallthrough
  2551. case m.op.Is(OpUpdate | OpDelete):
  2552. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  2553. default:
  2554. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2555. }
  2556. }
  2557. // SetCreatedAt sets the "created_at" field.
  2558. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  2559. m.created_at = &t
  2560. }
  2561. // CreatedAt returns the value of the "created_at" field in the mutation.
  2562. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  2563. v := m.created_at
  2564. if v == nil {
  2565. return
  2566. }
  2567. return *v, true
  2568. }
  2569. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  2570. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2572. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2573. if !m.op.Is(OpUpdateOne) {
  2574. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2575. }
  2576. if m.id == nil || m.oldValue == nil {
  2577. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2578. }
  2579. oldValue, err := m.oldValue(ctx)
  2580. if err != nil {
  2581. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2582. }
  2583. return oldValue.CreatedAt, nil
  2584. }
  2585. // ResetCreatedAt resets all changes to the "created_at" field.
  2586. func (m *ContactMutation) ResetCreatedAt() {
  2587. m.created_at = nil
  2588. }
  2589. // SetUpdatedAt sets the "updated_at" field.
  2590. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  2591. m.updated_at = &t
  2592. }
  2593. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2594. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  2595. v := m.updated_at
  2596. if v == nil {
  2597. return
  2598. }
  2599. return *v, true
  2600. }
  2601. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  2602. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2604. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2605. if !m.op.Is(OpUpdateOne) {
  2606. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2607. }
  2608. if m.id == nil || m.oldValue == nil {
  2609. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2610. }
  2611. oldValue, err := m.oldValue(ctx)
  2612. if err != nil {
  2613. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2614. }
  2615. return oldValue.UpdatedAt, nil
  2616. }
  2617. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2618. func (m *ContactMutation) ResetUpdatedAt() {
  2619. m.updated_at = nil
  2620. }
  2621. // SetStatus sets the "status" field.
  2622. func (m *ContactMutation) SetStatus(u uint8) {
  2623. m.status = &u
  2624. m.addstatus = nil
  2625. }
  2626. // Status returns the value of the "status" field in the mutation.
  2627. func (m *ContactMutation) Status() (r uint8, exists bool) {
  2628. v := m.status
  2629. if v == nil {
  2630. return
  2631. }
  2632. return *v, true
  2633. }
  2634. // OldStatus returns the old "status" field's value of the Contact entity.
  2635. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2637. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  2638. if !m.op.Is(OpUpdateOne) {
  2639. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  2640. }
  2641. if m.id == nil || m.oldValue == nil {
  2642. return v, errors.New("OldStatus requires an ID field in the mutation")
  2643. }
  2644. oldValue, err := m.oldValue(ctx)
  2645. if err != nil {
  2646. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  2647. }
  2648. return oldValue.Status, nil
  2649. }
  2650. // AddStatus adds u to the "status" field.
  2651. func (m *ContactMutation) AddStatus(u int8) {
  2652. if m.addstatus != nil {
  2653. *m.addstatus += u
  2654. } else {
  2655. m.addstatus = &u
  2656. }
  2657. }
  2658. // AddedStatus returns the value that was added to the "status" field in this mutation.
  2659. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  2660. v := m.addstatus
  2661. if v == nil {
  2662. return
  2663. }
  2664. return *v, true
  2665. }
  2666. // ClearStatus clears the value of the "status" field.
  2667. func (m *ContactMutation) ClearStatus() {
  2668. m.status = nil
  2669. m.addstatus = nil
  2670. m.clearedFields[contact.FieldStatus] = struct{}{}
  2671. }
  2672. // StatusCleared returns if the "status" field was cleared in this mutation.
  2673. func (m *ContactMutation) StatusCleared() bool {
  2674. _, ok := m.clearedFields[contact.FieldStatus]
  2675. return ok
  2676. }
  2677. // ResetStatus resets all changes to the "status" field.
  2678. func (m *ContactMutation) ResetStatus() {
  2679. m.status = nil
  2680. m.addstatus = nil
  2681. delete(m.clearedFields, contact.FieldStatus)
  2682. }
  2683. // SetDeletedAt sets the "deleted_at" field.
  2684. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  2685. m.deleted_at = &t
  2686. }
  2687. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2688. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  2689. v := m.deleted_at
  2690. if v == nil {
  2691. return
  2692. }
  2693. return *v, true
  2694. }
  2695. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  2696. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2698. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2699. if !m.op.Is(OpUpdateOne) {
  2700. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2701. }
  2702. if m.id == nil || m.oldValue == nil {
  2703. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2704. }
  2705. oldValue, err := m.oldValue(ctx)
  2706. if err != nil {
  2707. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2708. }
  2709. return oldValue.DeletedAt, nil
  2710. }
  2711. // ClearDeletedAt clears the value of the "deleted_at" field.
  2712. func (m *ContactMutation) ClearDeletedAt() {
  2713. m.deleted_at = nil
  2714. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  2715. }
  2716. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2717. func (m *ContactMutation) DeletedAtCleared() bool {
  2718. _, ok := m.clearedFields[contact.FieldDeletedAt]
  2719. return ok
  2720. }
  2721. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2722. func (m *ContactMutation) ResetDeletedAt() {
  2723. m.deleted_at = nil
  2724. delete(m.clearedFields, contact.FieldDeletedAt)
  2725. }
  2726. // SetWxWxid sets the "wx_wxid" field.
  2727. func (m *ContactMutation) SetWxWxid(s string) {
  2728. m.wx_wxid = &s
  2729. }
  2730. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  2731. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  2732. v := m.wx_wxid
  2733. if v == nil {
  2734. return
  2735. }
  2736. return *v, true
  2737. }
  2738. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  2739. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2741. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  2742. if !m.op.Is(OpUpdateOne) {
  2743. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  2744. }
  2745. if m.id == nil || m.oldValue == nil {
  2746. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  2747. }
  2748. oldValue, err := m.oldValue(ctx)
  2749. if err != nil {
  2750. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  2751. }
  2752. return oldValue.WxWxid, nil
  2753. }
  2754. // ClearWxWxid clears the value of the "wx_wxid" field.
  2755. func (m *ContactMutation) ClearWxWxid() {
  2756. m.wx_wxid = nil
  2757. m.clearedFields[contact.FieldWxWxid] = struct{}{}
  2758. }
  2759. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  2760. func (m *ContactMutation) WxWxidCleared() bool {
  2761. _, ok := m.clearedFields[contact.FieldWxWxid]
  2762. return ok
  2763. }
  2764. // ResetWxWxid resets all changes to the "wx_wxid" field.
  2765. func (m *ContactMutation) ResetWxWxid() {
  2766. m.wx_wxid = nil
  2767. delete(m.clearedFields, contact.FieldWxWxid)
  2768. }
  2769. // SetType sets the "type" field.
  2770. func (m *ContactMutation) SetType(i int) {
  2771. m._type = &i
  2772. m.add_type = nil
  2773. }
  2774. // GetType returns the value of the "type" field in the mutation.
  2775. func (m *ContactMutation) GetType() (r int, exists bool) {
  2776. v := m._type
  2777. if v == nil {
  2778. return
  2779. }
  2780. return *v, true
  2781. }
  2782. // OldType returns the old "type" field's value of the Contact entity.
  2783. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2785. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  2786. if !m.op.Is(OpUpdateOne) {
  2787. return v, errors.New("OldType is only allowed on UpdateOne operations")
  2788. }
  2789. if m.id == nil || m.oldValue == nil {
  2790. return v, errors.New("OldType requires an ID field in the mutation")
  2791. }
  2792. oldValue, err := m.oldValue(ctx)
  2793. if err != nil {
  2794. return v, fmt.Errorf("querying old value for OldType: %w", err)
  2795. }
  2796. return oldValue.Type, nil
  2797. }
  2798. // AddType adds i to the "type" field.
  2799. func (m *ContactMutation) AddType(i int) {
  2800. if m.add_type != nil {
  2801. *m.add_type += i
  2802. } else {
  2803. m.add_type = &i
  2804. }
  2805. }
  2806. // AddedType returns the value that was added to the "type" field in this mutation.
  2807. func (m *ContactMutation) AddedType() (r int, exists bool) {
  2808. v := m.add_type
  2809. if v == nil {
  2810. return
  2811. }
  2812. return *v, true
  2813. }
  2814. // ClearType clears the value of the "type" field.
  2815. func (m *ContactMutation) ClearType() {
  2816. m._type = nil
  2817. m.add_type = nil
  2818. m.clearedFields[contact.FieldType] = struct{}{}
  2819. }
  2820. // TypeCleared returns if the "type" field was cleared in this mutation.
  2821. func (m *ContactMutation) TypeCleared() bool {
  2822. _, ok := m.clearedFields[contact.FieldType]
  2823. return ok
  2824. }
  2825. // ResetType resets all changes to the "type" field.
  2826. func (m *ContactMutation) ResetType() {
  2827. m._type = nil
  2828. m.add_type = nil
  2829. delete(m.clearedFields, contact.FieldType)
  2830. }
  2831. // SetWxid sets the "wxid" field.
  2832. func (m *ContactMutation) SetWxid(s string) {
  2833. m.wxid = &s
  2834. }
  2835. // Wxid returns the value of the "wxid" field in the mutation.
  2836. func (m *ContactMutation) Wxid() (r string, exists bool) {
  2837. v := m.wxid
  2838. if v == nil {
  2839. return
  2840. }
  2841. return *v, true
  2842. }
  2843. // OldWxid returns the old "wxid" field's value of the Contact entity.
  2844. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2846. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  2847. if !m.op.Is(OpUpdateOne) {
  2848. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  2849. }
  2850. if m.id == nil || m.oldValue == nil {
  2851. return v, errors.New("OldWxid requires an ID field in the mutation")
  2852. }
  2853. oldValue, err := m.oldValue(ctx)
  2854. if err != nil {
  2855. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  2856. }
  2857. return oldValue.Wxid, nil
  2858. }
  2859. // ResetWxid resets all changes to the "wxid" field.
  2860. func (m *ContactMutation) ResetWxid() {
  2861. m.wxid = nil
  2862. }
  2863. // SetAccount sets the "account" field.
  2864. func (m *ContactMutation) SetAccount(s string) {
  2865. m.account = &s
  2866. }
  2867. // Account returns the value of the "account" field in the mutation.
  2868. func (m *ContactMutation) Account() (r string, exists bool) {
  2869. v := m.account
  2870. if v == nil {
  2871. return
  2872. }
  2873. return *v, true
  2874. }
  2875. // OldAccount returns the old "account" field's value of the Contact entity.
  2876. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2878. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  2879. if !m.op.Is(OpUpdateOne) {
  2880. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  2881. }
  2882. if m.id == nil || m.oldValue == nil {
  2883. return v, errors.New("OldAccount requires an ID field in the mutation")
  2884. }
  2885. oldValue, err := m.oldValue(ctx)
  2886. if err != nil {
  2887. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  2888. }
  2889. return oldValue.Account, nil
  2890. }
  2891. // ResetAccount resets all changes to the "account" field.
  2892. func (m *ContactMutation) ResetAccount() {
  2893. m.account = nil
  2894. }
  2895. // SetNickname sets the "nickname" field.
  2896. func (m *ContactMutation) SetNickname(s string) {
  2897. m.nickname = &s
  2898. }
  2899. // Nickname returns the value of the "nickname" field in the mutation.
  2900. func (m *ContactMutation) Nickname() (r string, exists bool) {
  2901. v := m.nickname
  2902. if v == nil {
  2903. return
  2904. }
  2905. return *v, true
  2906. }
  2907. // OldNickname returns the old "nickname" field's value of the Contact entity.
  2908. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2910. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  2911. if !m.op.Is(OpUpdateOne) {
  2912. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  2913. }
  2914. if m.id == nil || m.oldValue == nil {
  2915. return v, errors.New("OldNickname requires an ID field in the mutation")
  2916. }
  2917. oldValue, err := m.oldValue(ctx)
  2918. if err != nil {
  2919. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  2920. }
  2921. return oldValue.Nickname, nil
  2922. }
  2923. // ResetNickname resets all changes to the "nickname" field.
  2924. func (m *ContactMutation) ResetNickname() {
  2925. m.nickname = nil
  2926. }
  2927. // SetMarkname sets the "markname" field.
  2928. func (m *ContactMutation) SetMarkname(s string) {
  2929. m.markname = &s
  2930. }
  2931. // Markname returns the value of the "markname" field in the mutation.
  2932. func (m *ContactMutation) Markname() (r string, exists bool) {
  2933. v := m.markname
  2934. if v == nil {
  2935. return
  2936. }
  2937. return *v, true
  2938. }
  2939. // OldMarkname returns the old "markname" field's value of the Contact entity.
  2940. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2942. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  2943. if !m.op.Is(OpUpdateOne) {
  2944. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  2945. }
  2946. if m.id == nil || m.oldValue == nil {
  2947. return v, errors.New("OldMarkname requires an ID field in the mutation")
  2948. }
  2949. oldValue, err := m.oldValue(ctx)
  2950. if err != nil {
  2951. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  2952. }
  2953. return oldValue.Markname, nil
  2954. }
  2955. // ResetMarkname resets all changes to the "markname" field.
  2956. func (m *ContactMutation) ResetMarkname() {
  2957. m.markname = nil
  2958. }
  2959. // SetHeadimg sets the "headimg" field.
  2960. func (m *ContactMutation) SetHeadimg(s string) {
  2961. m.headimg = &s
  2962. }
  2963. // Headimg returns the value of the "headimg" field in the mutation.
  2964. func (m *ContactMutation) Headimg() (r string, exists bool) {
  2965. v := m.headimg
  2966. if v == nil {
  2967. return
  2968. }
  2969. return *v, true
  2970. }
  2971. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  2972. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2974. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  2975. if !m.op.Is(OpUpdateOne) {
  2976. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  2977. }
  2978. if m.id == nil || m.oldValue == nil {
  2979. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  2980. }
  2981. oldValue, err := m.oldValue(ctx)
  2982. if err != nil {
  2983. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  2984. }
  2985. return oldValue.Headimg, nil
  2986. }
  2987. // ResetHeadimg resets all changes to the "headimg" field.
  2988. func (m *ContactMutation) ResetHeadimg() {
  2989. m.headimg = nil
  2990. }
  2991. // SetSex sets the "sex" field.
  2992. func (m *ContactMutation) SetSex(i int) {
  2993. m.sex = &i
  2994. m.addsex = nil
  2995. }
  2996. // Sex returns the value of the "sex" field in the mutation.
  2997. func (m *ContactMutation) Sex() (r int, exists bool) {
  2998. v := m.sex
  2999. if v == nil {
  3000. return
  3001. }
  3002. return *v, true
  3003. }
  3004. // OldSex returns the old "sex" field's value of the Contact entity.
  3005. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3007. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  3008. if !m.op.Is(OpUpdateOne) {
  3009. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  3010. }
  3011. if m.id == nil || m.oldValue == nil {
  3012. return v, errors.New("OldSex requires an ID field in the mutation")
  3013. }
  3014. oldValue, err := m.oldValue(ctx)
  3015. if err != nil {
  3016. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  3017. }
  3018. return oldValue.Sex, nil
  3019. }
  3020. // AddSex adds i to the "sex" field.
  3021. func (m *ContactMutation) AddSex(i int) {
  3022. if m.addsex != nil {
  3023. *m.addsex += i
  3024. } else {
  3025. m.addsex = &i
  3026. }
  3027. }
  3028. // AddedSex returns the value that was added to the "sex" field in this mutation.
  3029. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  3030. v := m.addsex
  3031. if v == nil {
  3032. return
  3033. }
  3034. return *v, true
  3035. }
  3036. // ResetSex resets all changes to the "sex" field.
  3037. func (m *ContactMutation) ResetSex() {
  3038. m.sex = nil
  3039. m.addsex = nil
  3040. }
  3041. // SetStarrole sets the "starrole" field.
  3042. func (m *ContactMutation) SetStarrole(s string) {
  3043. m.starrole = &s
  3044. }
  3045. // Starrole returns the value of the "starrole" field in the mutation.
  3046. func (m *ContactMutation) Starrole() (r string, exists bool) {
  3047. v := m.starrole
  3048. if v == nil {
  3049. return
  3050. }
  3051. return *v, true
  3052. }
  3053. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  3054. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3056. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  3057. if !m.op.Is(OpUpdateOne) {
  3058. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  3059. }
  3060. if m.id == nil || m.oldValue == nil {
  3061. return v, errors.New("OldStarrole requires an ID field in the mutation")
  3062. }
  3063. oldValue, err := m.oldValue(ctx)
  3064. if err != nil {
  3065. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  3066. }
  3067. return oldValue.Starrole, nil
  3068. }
  3069. // ResetStarrole resets all changes to the "starrole" field.
  3070. func (m *ContactMutation) ResetStarrole() {
  3071. m.starrole = nil
  3072. }
  3073. // SetDontseeit sets the "dontseeit" field.
  3074. func (m *ContactMutation) SetDontseeit(i int) {
  3075. m.dontseeit = &i
  3076. m.adddontseeit = nil
  3077. }
  3078. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  3079. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  3080. v := m.dontseeit
  3081. if v == nil {
  3082. return
  3083. }
  3084. return *v, true
  3085. }
  3086. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  3087. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3089. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  3090. if !m.op.Is(OpUpdateOne) {
  3091. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  3092. }
  3093. if m.id == nil || m.oldValue == nil {
  3094. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  3095. }
  3096. oldValue, err := m.oldValue(ctx)
  3097. if err != nil {
  3098. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  3099. }
  3100. return oldValue.Dontseeit, nil
  3101. }
  3102. // AddDontseeit adds i to the "dontseeit" field.
  3103. func (m *ContactMutation) AddDontseeit(i int) {
  3104. if m.adddontseeit != nil {
  3105. *m.adddontseeit += i
  3106. } else {
  3107. m.adddontseeit = &i
  3108. }
  3109. }
  3110. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  3111. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  3112. v := m.adddontseeit
  3113. if v == nil {
  3114. return
  3115. }
  3116. return *v, true
  3117. }
  3118. // ResetDontseeit resets all changes to the "dontseeit" field.
  3119. func (m *ContactMutation) ResetDontseeit() {
  3120. m.dontseeit = nil
  3121. m.adddontseeit = nil
  3122. }
  3123. // SetDontseeme sets the "dontseeme" field.
  3124. func (m *ContactMutation) SetDontseeme(i int) {
  3125. m.dontseeme = &i
  3126. m.adddontseeme = nil
  3127. }
  3128. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  3129. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  3130. v := m.dontseeme
  3131. if v == nil {
  3132. return
  3133. }
  3134. return *v, true
  3135. }
  3136. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  3137. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3139. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  3140. if !m.op.Is(OpUpdateOne) {
  3141. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  3142. }
  3143. if m.id == nil || m.oldValue == nil {
  3144. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  3145. }
  3146. oldValue, err := m.oldValue(ctx)
  3147. if err != nil {
  3148. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  3149. }
  3150. return oldValue.Dontseeme, nil
  3151. }
  3152. // AddDontseeme adds i to the "dontseeme" field.
  3153. func (m *ContactMutation) AddDontseeme(i int) {
  3154. if m.adddontseeme != nil {
  3155. *m.adddontseeme += i
  3156. } else {
  3157. m.adddontseeme = &i
  3158. }
  3159. }
  3160. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  3161. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  3162. v := m.adddontseeme
  3163. if v == nil {
  3164. return
  3165. }
  3166. return *v, true
  3167. }
  3168. // ResetDontseeme resets all changes to the "dontseeme" field.
  3169. func (m *ContactMutation) ResetDontseeme() {
  3170. m.dontseeme = nil
  3171. m.adddontseeme = nil
  3172. }
  3173. // SetLag sets the "lag" field.
  3174. func (m *ContactMutation) SetLag(s string) {
  3175. m.lag = &s
  3176. }
  3177. // Lag returns the value of the "lag" field in the mutation.
  3178. func (m *ContactMutation) Lag() (r string, exists bool) {
  3179. v := m.lag
  3180. if v == nil {
  3181. return
  3182. }
  3183. return *v, true
  3184. }
  3185. // OldLag returns the old "lag" field's value of the Contact entity.
  3186. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3188. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  3189. if !m.op.Is(OpUpdateOne) {
  3190. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  3191. }
  3192. if m.id == nil || m.oldValue == nil {
  3193. return v, errors.New("OldLag requires an ID field in the mutation")
  3194. }
  3195. oldValue, err := m.oldValue(ctx)
  3196. if err != nil {
  3197. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  3198. }
  3199. return oldValue.Lag, nil
  3200. }
  3201. // ResetLag resets all changes to the "lag" field.
  3202. func (m *ContactMutation) ResetLag() {
  3203. m.lag = nil
  3204. }
  3205. // SetGid sets the "gid" field.
  3206. func (m *ContactMutation) SetGid(s string) {
  3207. m.gid = &s
  3208. }
  3209. // Gid returns the value of the "gid" field in the mutation.
  3210. func (m *ContactMutation) Gid() (r string, exists bool) {
  3211. v := m.gid
  3212. if v == nil {
  3213. return
  3214. }
  3215. return *v, true
  3216. }
  3217. // OldGid returns the old "gid" field's value of the Contact entity.
  3218. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3220. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  3221. if !m.op.Is(OpUpdateOne) {
  3222. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  3223. }
  3224. if m.id == nil || m.oldValue == nil {
  3225. return v, errors.New("OldGid requires an ID field in the mutation")
  3226. }
  3227. oldValue, err := m.oldValue(ctx)
  3228. if err != nil {
  3229. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  3230. }
  3231. return oldValue.Gid, nil
  3232. }
  3233. // ResetGid resets all changes to the "gid" field.
  3234. func (m *ContactMutation) ResetGid() {
  3235. m.gid = nil
  3236. }
  3237. // SetGname sets the "gname" field.
  3238. func (m *ContactMutation) SetGname(s string) {
  3239. m.gname = &s
  3240. }
  3241. // Gname returns the value of the "gname" field in the mutation.
  3242. func (m *ContactMutation) Gname() (r string, exists bool) {
  3243. v := m.gname
  3244. if v == nil {
  3245. return
  3246. }
  3247. return *v, true
  3248. }
  3249. // OldGname returns the old "gname" field's value of the Contact entity.
  3250. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3252. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  3253. if !m.op.Is(OpUpdateOne) {
  3254. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  3255. }
  3256. if m.id == nil || m.oldValue == nil {
  3257. return v, errors.New("OldGname requires an ID field in the mutation")
  3258. }
  3259. oldValue, err := m.oldValue(ctx)
  3260. if err != nil {
  3261. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  3262. }
  3263. return oldValue.Gname, nil
  3264. }
  3265. // ResetGname resets all changes to the "gname" field.
  3266. func (m *ContactMutation) ResetGname() {
  3267. m.gname = nil
  3268. }
  3269. // SetV3 sets the "v3" field.
  3270. func (m *ContactMutation) SetV3(s string) {
  3271. m.v3 = &s
  3272. }
  3273. // V3 returns the value of the "v3" field in the mutation.
  3274. func (m *ContactMutation) V3() (r string, exists bool) {
  3275. v := m.v3
  3276. if v == nil {
  3277. return
  3278. }
  3279. return *v, true
  3280. }
  3281. // OldV3 returns the old "v3" field's value of the Contact entity.
  3282. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3284. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  3285. if !m.op.Is(OpUpdateOne) {
  3286. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  3287. }
  3288. if m.id == nil || m.oldValue == nil {
  3289. return v, errors.New("OldV3 requires an ID field in the mutation")
  3290. }
  3291. oldValue, err := m.oldValue(ctx)
  3292. if err != nil {
  3293. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  3294. }
  3295. return oldValue.V3, nil
  3296. }
  3297. // ResetV3 resets all changes to the "v3" field.
  3298. func (m *ContactMutation) ResetV3() {
  3299. m.v3 = nil
  3300. }
  3301. // SetOrganizationID sets the "organization_id" field.
  3302. func (m *ContactMutation) SetOrganizationID(u uint64) {
  3303. m.organization_id = &u
  3304. m.addorganization_id = nil
  3305. }
  3306. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3307. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  3308. v := m.organization_id
  3309. if v == nil {
  3310. return
  3311. }
  3312. return *v, true
  3313. }
  3314. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  3315. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3317. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3318. if !m.op.Is(OpUpdateOne) {
  3319. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3320. }
  3321. if m.id == nil || m.oldValue == nil {
  3322. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3323. }
  3324. oldValue, err := m.oldValue(ctx)
  3325. if err != nil {
  3326. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3327. }
  3328. return oldValue.OrganizationID, nil
  3329. }
  3330. // AddOrganizationID adds u to the "organization_id" field.
  3331. func (m *ContactMutation) AddOrganizationID(u int64) {
  3332. if m.addorganization_id != nil {
  3333. *m.addorganization_id += u
  3334. } else {
  3335. m.addorganization_id = &u
  3336. }
  3337. }
  3338. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3339. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  3340. v := m.addorganization_id
  3341. if v == nil {
  3342. return
  3343. }
  3344. return *v, true
  3345. }
  3346. // ClearOrganizationID clears the value of the "organization_id" field.
  3347. func (m *ContactMutation) ClearOrganizationID() {
  3348. m.organization_id = nil
  3349. m.addorganization_id = nil
  3350. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  3351. }
  3352. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3353. func (m *ContactMutation) OrganizationIDCleared() bool {
  3354. _, ok := m.clearedFields[contact.FieldOrganizationID]
  3355. return ok
  3356. }
  3357. // ResetOrganizationID resets all changes to the "organization_id" field.
  3358. func (m *ContactMutation) ResetOrganizationID() {
  3359. m.organization_id = nil
  3360. m.addorganization_id = nil
  3361. delete(m.clearedFields, contact.FieldOrganizationID)
  3362. }
  3363. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  3364. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  3365. if m.contact_relationships == nil {
  3366. m.contact_relationships = make(map[uint64]struct{})
  3367. }
  3368. for i := range ids {
  3369. m.contact_relationships[ids[i]] = struct{}{}
  3370. }
  3371. }
  3372. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  3373. func (m *ContactMutation) ClearContactRelationships() {
  3374. m.clearedcontact_relationships = true
  3375. }
  3376. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  3377. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  3378. return m.clearedcontact_relationships
  3379. }
  3380. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  3381. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  3382. if m.removedcontact_relationships == nil {
  3383. m.removedcontact_relationships = make(map[uint64]struct{})
  3384. }
  3385. for i := range ids {
  3386. delete(m.contact_relationships, ids[i])
  3387. m.removedcontact_relationships[ids[i]] = struct{}{}
  3388. }
  3389. }
  3390. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  3391. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  3392. for id := range m.removedcontact_relationships {
  3393. ids = append(ids, id)
  3394. }
  3395. return
  3396. }
  3397. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  3398. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  3399. for id := range m.contact_relationships {
  3400. ids = append(ids, id)
  3401. }
  3402. return
  3403. }
  3404. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  3405. func (m *ContactMutation) ResetContactRelationships() {
  3406. m.contact_relationships = nil
  3407. m.clearedcontact_relationships = false
  3408. m.removedcontact_relationships = nil
  3409. }
  3410. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  3411. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  3412. if m.contact_messages == nil {
  3413. m.contact_messages = make(map[uint64]struct{})
  3414. }
  3415. for i := range ids {
  3416. m.contact_messages[ids[i]] = struct{}{}
  3417. }
  3418. }
  3419. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  3420. func (m *ContactMutation) ClearContactMessages() {
  3421. m.clearedcontact_messages = true
  3422. }
  3423. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  3424. func (m *ContactMutation) ContactMessagesCleared() bool {
  3425. return m.clearedcontact_messages
  3426. }
  3427. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  3428. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  3429. if m.removedcontact_messages == nil {
  3430. m.removedcontact_messages = make(map[uint64]struct{})
  3431. }
  3432. for i := range ids {
  3433. delete(m.contact_messages, ids[i])
  3434. m.removedcontact_messages[ids[i]] = struct{}{}
  3435. }
  3436. }
  3437. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  3438. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  3439. for id := range m.removedcontact_messages {
  3440. ids = append(ids, id)
  3441. }
  3442. return
  3443. }
  3444. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  3445. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  3446. for id := range m.contact_messages {
  3447. ids = append(ids, id)
  3448. }
  3449. return
  3450. }
  3451. // ResetContactMessages resets all changes to the "contact_messages" edge.
  3452. func (m *ContactMutation) ResetContactMessages() {
  3453. m.contact_messages = nil
  3454. m.clearedcontact_messages = false
  3455. m.removedcontact_messages = nil
  3456. }
  3457. // Where appends a list predicates to the ContactMutation builder.
  3458. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  3459. m.predicates = append(m.predicates, ps...)
  3460. }
  3461. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  3462. // users can use type-assertion to append predicates that do not depend on any generated package.
  3463. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  3464. p := make([]predicate.Contact, len(ps))
  3465. for i := range ps {
  3466. p[i] = ps[i]
  3467. }
  3468. m.Where(p...)
  3469. }
  3470. // Op returns the operation name.
  3471. func (m *ContactMutation) Op() Op {
  3472. return m.op
  3473. }
  3474. // SetOp allows setting the mutation operation.
  3475. func (m *ContactMutation) SetOp(op Op) {
  3476. m.op = op
  3477. }
  3478. // Type returns the node type of this mutation (Contact).
  3479. func (m *ContactMutation) Type() string {
  3480. return m.typ
  3481. }
  3482. // Fields returns all fields that were changed during this mutation. Note that in
  3483. // order to get all numeric fields that were incremented/decremented, call
  3484. // AddedFields().
  3485. func (m *ContactMutation) Fields() []string {
  3486. fields := make([]string, 0, 20)
  3487. if m.created_at != nil {
  3488. fields = append(fields, contact.FieldCreatedAt)
  3489. }
  3490. if m.updated_at != nil {
  3491. fields = append(fields, contact.FieldUpdatedAt)
  3492. }
  3493. if m.status != nil {
  3494. fields = append(fields, contact.FieldStatus)
  3495. }
  3496. if m.deleted_at != nil {
  3497. fields = append(fields, contact.FieldDeletedAt)
  3498. }
  3499. if m.wx_wxid != nil {
  3500. fields = append(fields, contact.FieldWxWxid)
  3501. }
  3502. if m._type != nil {
  3503. fields = append(fields, contact.FieldType)
  3504. }
  3505. if m.wxid != nil {
  3506. fields = append(fields, contact.FieldWxid)
  3507. }
  3508. if m.account != nil {
  3509. fields = append(fields, contact.FieldAccount)
  3510. }
  3511. if m.nickname != nil {
  3512. fields = append(fields, contact.FieldNickname)
  3513. }
  3514. if m.markname != nil {
  3515. fields = append(fields, contact.FieldMarkname)
  3516. }
  3517. if m.headimg != nil {
  3518. fields = append(fields, contact.FieldHeadimg)
  3519. }
  3520. if m.sex != nil {
  3521. fields = append(fields, contact.FieldSex)
  3522. }
  3523. if m.starrole != nil {
  3524. fields = append(fields, contact.FieldStarrole)
  3525. }
  3526. if m.dontseeit != nil {
  3527. fields = append(fields, contact.FieldDontseeit)
  3528. }
  3529. if m.dontseeme != nil {
  3530. fields = append(fields, contact.FieldDontseeme)
  3531. }
  3532. if m.lag != nil {
  3533. fields = append(fields, contact.FieldLag)
  3534. }
  3535. if m.gid != nil {
  3536. fields = append(fields, contact.FieldGid)
  3537. }
  3538. if m.gname != nil {
  3539. fields = append(fields, contact.FieldGname)
  3540. }
  3541. if m.v3 != nil {
  3542. fields = append(fields, contact.FieldV3)
  3543. }
  3544. if m.organization_id != nil {
  3545. fields = append(fields, contact.FieldOrganizationID)
  3546. }
  3547. return fields
  3548. }
  3549. // Field returns the value of a field with the given name. The second boolean
  3550. // return value indicates that this field was not set, or was not defined in the
  3551. // schema.
  3552. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  3553. switch name {
  3554. case contact.FieldCreatedAt:
  3555. return m.CreatedAt()
  3556. case contact.FieldUpdatedAt:
  3557. return m.UpdatedAt()
  3558. case contact.FieldStatus:
  3559. return m.Status()
  3560. case contact.FieldDeletedAt:
  3561. return m.DeletedAt()
  3562. case contact.FieldWxWxid:
  3563. return m.WxWxid()
  3564. case contact.FieldType:
  3565. return m.GetType()
  3566. case contact.FieldWxid:
  3567. return m.Wxid()
  3568. case contact.FieldAccount:
  3569. return m.Account()
  3570. case contact.FieldNickname:
  3571. return m.Nickname()
  3572. case contact.FieldMarkname:
  3573. return m.Markname()
  3574. case contact.FieldHeadimg:
  3575. return m.Headimg()
  3576. case contact.FieldSex:
  3577. return m.Sex()
  3578. case contact.FieldStarrole:
  3579. return m.Starrole()
  3580. case contact.FieldDontseeit:
  3581. return m.Dontseeit()
  3582. case contact.FieldDontseeme:
  3583. return m.Dontseeme()
  3584. case contact.FieldLag:
  3585. return m.Lag()
  3586. case contact.FieldGid:
  3587. return m.Gid()
  3588. case contact.FieldGname:
  3589. return m.Gname()
  3590. case contact.FieldV3:
  3591. return m.V3()
  3592. case contact.FieldOrganizationID:
  3593. return m.OrganizationID()
  3594. }
  3595. return nil, false
  3596. }
  3597. // OldField returns the old value of the field from the database. An error is
  3598. // returned if the mutation operation is not UpdateOne, or the query to the
  3599. // database failed.
  3600. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3601. switch name {
  3602. case contact.FieldCreatedAt:
  3603. return m.OldCreatedAt(ctx)
  3604. case contact.FieldUpdatedAt:
  3605. return m.OldUpdatedAt(ctx)
  3606. case contact.FieldStatus:
  3607. return m.OldStatus(ctx)
  3608. case contact.FieldDeletedAt:
  3609. return m.OldDeletedAt(ctx)
  3610. case contact.FieldWxWxid:
  3611. return m.OldWxWxid(ctx)
  3612. case contact.FieldType:
  3613. return m.OldType(ctx)
  3614. case contact.FieldWxid:
  3615. return m.OldWxid(ctx)
  3616. case contact.FieldAccount:
  3617. return m.OldAccount(ctx)
  3618. case contact.FieldNickname:
  3619. return m.OldNickname(ctx)
  3620. case contact.FieldMarkname:
  3621. return m.OldMarkname(ctx)
  3622. case contact.FieldHeadimg:
  3623. return m.OldHeadimg(ctx)
  3624. case contact.FieldSex:
  3625. return m.OldSex(ctx)
  3626. case contact.FieldStarrole:
  3627. return m.OldStarrole(ctx)
  3628. case contact.FieldDontseeit:
  3629. return m.OldDontseeit(ctx)
  3630. case contact.FieldDontseeme:
  3631. return m.OldDontseeme(ctx)
  3632. case contact.FieldLag:
  3633. return m.OldLag(ctx)
  3634. case contact.FieldGid:
  3635. return m.OldGid(ctx)
  3636. case contact.FieldGname:
  3637. return m.OldGname(ctx)
  3638. case contact.FieldV3:
  3639. return m.OldV3(ctx)
  3640. case contact.FieldOrganizationID:
  3641. return m.OldOrganizationID(ctx)
  3642. }
  3643. return nil, fmt.Errorf("unknown Contact field %s", name)
  3644. }
  3645. // SetField sets the value of a field with the given name. It returns an error if
  3646. // the field is not defined in the schema, or if the type mismatched the field
  3647. // type.
  3648. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  3649. switch name {
  3650. case contact.FieldCreatedAt:
  3651. v, ok := value.(time.Time)
  3652. if !ok {
  3653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3654. }
  3655. m.SetCreatedAt(v)
  3656. return nil
  3657. case contact.FieldUpdatedAt:
  3658. v, ok := value.(time.Time)
  3659. if !ok {
  3660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3661. }
  3662. m.SetUpdatedAt(v)
  3663. return nil
  3664. case contact.FieldStatus:
  3665. v, ok := value.(uint8)
  3666. if !ok {
  3667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3668. }
  3669. m.SetStatus(v)
  3670. return nil
  3671. case contact.FieldDeletedAt:
  3672. v, ok := value.(time.Time)
  3673. if !ok {
  3674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3675. }
  3676. m.SetDeletedAt(v)
  3677. return nil
  3678. case contact.FieldWxWxid:
  3679. v, ok := value.(string)
  3680. if !ok {
  3681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3682. }
  3683. m.SetWxWxid(v)
  3684. return nil
  3685. case contact.FieldType:
  3686. v, ok := value.(int)
  3687. if !ok {
  3688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3689. }
  3690. m.SetType(v)
  3691. return nil
  3692. case contact.FieldWxid:
  3693. v, ok := value.(string)
  3694. if !ok {
  3695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3696. }
  3697. m.SetWxid(v)
  3698. return nil
  3699. case contact.FieldAccount:
  3700. v, ok := value.(string)
  3701. if !ok {
  3702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3703. }
  3704. m.SetAccount(v)
  3705. return nil
  3706. case contact.FieldNickname:
  3707. v, ok := value.(string)
  3708. if !ok {
  3709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3710. }
  3711. m.SetNickname(v)
  3712. return nil
  3713. case contact.FieldMarkname:
  3714. v, ok := value.(string)
  3715. if !ok {
  3716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3717. }
  3718. m.SetMarkname(v)
  3719. return nil
  3720. case contact.FieldHeadimg:
  3721. v, ok := value.(string)
  3722. if !ok {
  3723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3724. }
  3725. m.SetHeadimg(v)
  3726. return nil
  3727. case contact.FieldSex:
  3728. v, ok := value.(int)
  3729. if !ok {
  3730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3731. }
  3732. m.SetSex(v)
  3733. return nil
  3734. case contact.FieldStarrole:
  3735. v, ok := value.(string)
  3736. if !ok {
  3737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3738. }
  3739. m.SetStarrole(v)
  3740. return nil
  3741. case contact.FieldDontseeit:
  3742. v, ok := value.(int)
  3743. if !ok {
  3744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3745. }
  3746. m.SetDontseeit(v)
  3747. return nil
  3748. case contact.FieldDontseeme:
  3749. v, ok := value.(int)
  3750. if !ok {
  3751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3752. }
  3753. m.SetDontseeme(v)
  3754. return nil
  3755. case contact.FieldLag:
  3756. v, ok := value.(string)
  3757. if !ok {
  3758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3759. }
  3760. m.SetLag(v)
  3761. return nil
  3762. case contact.FieldGid:
  3763. v, ok := value.(string)
  3764. if !ok {
  3765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3766. }
  3767. m.SetGid(v)
  3768. return nil
  3769. case contact.FieldGname:
  3770. v, ok := value.(string)
  3771. if !ok {
  3772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3773. }
  3774. m.SetGname(v)
  3775. return nil
  3776. case contact.FieldV3:
  3777. v, ok := value.(string)
  3778. if !ok {
  3779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3780. }
  3781. m.SetV3(v)
  3782. return nil
  3783. case contact.FieldOrganizationID:
  3784. v, ok := value.(uint64)
  3785. if !ok {
  3786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3787. }
  3788. m.SetOrganizationID(v)
  3789. return nil
  3790. }
  3791. return fmt.Errorf("unknown Contact field %s", name)
  3792. }
  3793. // AddedFields returns all numeric fields that were incremented/decremented during
  3794. // this mutation.
  3795. func (m *ContactMutation) AddedFields() []string {
  3796. var fields []string
  3797. if m.addstatus != nil {
  3798. fields = append(fields, contact.FieldStatus)
  3799. }
  3800. if m.add_type != nil {
  3801. fields = append(fields, contact.FieldType)
  3802. }
  3803. if m.addsex != nil {
  3804. fields = append(fields, contact.FieldSex)
  3805. }
  3806. if m.adddontseeit != nil {
  3807. fields = append(fields, contact.FieldDontseeit)
  3808. }
  3809. if m.adddontseeme != nil {
  3810. fields = append(fields, contact.FieldDontseeme)
  3811. }
  3812. if m.addorganization_id != nil {
  3813. fields = append(fields, contact.FieldOrganizationID)
  3814. }
  3815. return fields
  3816. }
  3817. // AddedField returns the numeric value that was incremented/decremented on a field
  3818. // with the given name. The second boolean return value indicates that this field
  3819. // was not set, or was not defined in the schema.
  3820. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  3821. switch name {
  3822. case contact.FieldStatus:
  3823. return m.AddedStatus()
  3824. case contact.FieldType:
  3825. return m.AddedType()
  3826. case contact.FieldSex:
  3827. return m.AddedSex()
  3828. case contact.FieldDontseeit:
  3829. return m.AddedDontseeit()
  3830. case contact.FieldDontseeme:
  3831. return m.AddedDontseeme()
  3832. case contact.FieldOrganizationID:
  3833. return m.AddedOrganizationID()
  3834. }
  3835. return nil, false
  3836. }
  3837. // AddField adds the value to the field with the given name. It returns an error if
  3838. // the field is not defined in the schema, or if the type mismatched the field
  3839. // type.
  3840. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  3841. switch name {
  3842. case contact.FieldStatus:
  3843. v, ok := value.(int8)
  3844. if !ok {
  3845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3846. }
  3847. m.AddStatus(v)
  3848. return nil
  3849. case contact.FieldType:
  3850. v, ok := value.(int)
  3851. if !ok {
  3852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3853. }
  3854. m.AddType(v)
  3855. return nil
  3856. case contact.FieldSex:
  3857. v, ok := value.(int)
  3858. if !ok {
  3859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3860. }
  3861. m.AddSex(v)
  3862. return nil
  3863. case contact.FieldDontseeit:
  3864. v, ok := value.(int)
  3865. if !ok {
  3866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3867. }
  3868. m.AddDontseeit(v)
  3869. return nil
  3870. case contact.FieldDontseeme:
  3871. v, ok := value.(int)
  3872. if !ok {
  3873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3874. }
  3875. m.AddDontseeme(v)
  3876. return nil
  3877. case contact.FieldOrganizationID:
  3878. v, ok := value.(int64)
  3879. if !ok {
  3880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3881. }
  3882. m.AddOrganizationID(v)
  3883. return nil
  3884. }
  3885. return fmt.Errorf("unknown Contact numeric field %s", name)
  3886. }
  3887. // ClearedFields returns all nullable fields that were cleared during this
  3888. // mutation.
  3889. func (m *ContactMutation) ClearedFields() []string {
  3890. var fields []string
  3891. if m.FieldCleared(contact.FieldStatus) {
  3892. fields = append(fields, contact.FieldStatus)
  3893. }
  3894. if m.FieldCleared(contact.FieldDeletedAt) {
  3895. fields = append(fields, contact.FieldDeletedAt)
  3896. }
  3897. if m.FieldCleared(contact.FieldWxWxid) {
  3898. fields = append(fields, contact.FieldWxWxid)
  3899. }
  3900. if m.FieldCleared(contact.FieldType) {
  3901. fields = append(fields, contact.FieldType)
  3902. }
  3903. if m.FieldCleared(contact.FieldOrganizationID) {
  3904. fields = append(fields, contact.FieldOrganizationID)
  3905. }
  3906. return fields
  3907. }
  3908. // FieldCleared returns a boolean indicating if a field with the given name was
  3909. // cleared in this mutation.
  3910. func (m *ContactMutation) FieldCleared(name string) bool {
  3911. _, ok := m.clearedFields[name]
  3912. return ok
  3913. }
  3914. // ClearField clears the value of the field with the given name. It returns an
  3915. // error if the field is not defined in the schema.
  3916. func (m *ContactMutation) ClearField(name string) error {
  3917. switch name {
  3918. case contact.FieldStatus:
  3919. m.ClearStatus()
  3920. return nil
  3921. case contact.FieldDeletedAt:
  3922. m.ClearDeletedAt()
  3923. return nil
  3924. case contact.FieldWxWxid:
  3925. m.ClearWxWxid()
  3926. return nil
  3927. case contact.FieldType:
  3928. m.ClearType()
  3929. return nil
  3930. case contact.FieldOrganizationID:
  3931. m.ClearOrganizationID()
  3932. return nil
  3933. }
  3934. return fmt.Errorf("unknown Contact nullable field %s", name)
  3935. }
  3936. // ResetField resets all changes in the mutation for the field with the given name.
  3937. // It returns an error if the field is not defined in the schema.
  3938. func (m *ContactMutation) ResetField(name string) error {
  3939. switch name {
  3940. case contact.FieldCreatedAt:
  3941. m.ResetCreatedAt()
  3942. return nil
  3943. case contact.FieldUpdatedAt:
  3944. m.ResetUpdatedAt()
  3945. return nil
  3946. case contact.FieldStatus:
  3947. m.ResetStatus()
  3948. return nil
  3949. case contact.FieldDeletedAt:
  3950. m.ResetDeletedAt()
  3951. return nil
  3952. case contact.FieldWxWxid:
  3953. m.ResetWxWxid()
  3954. return nil
  3955. case contact.FieldType:
  3956. m.ResetType()
  3957. return nil
  3958. case contact.FieldWxid:
  3959. m.ResetWxid()
  3960. return nil
  3961. case contact.FieldAccount:
  3962. m.ResetAccount()
  3963. return nil
  3964. case contact.FieldNickname:
  3965. m.ResetNickname()
  3966. return nil
  3967. case contact.FieldMarkname:
  3968. m.ResetMarkname()
  3969. return nil
  3970. case contact.FieldHeadimg:
  3971. m.ResetHeadimg()
  3972. return nil
  3973. case contact.FieldSex:
  3974. m.ResetSex()
  3975. return nil
  3976. case contact.FieldStarrole:
  3977. m.ResetStarrole()
  3978. return nil
  3979. case contact.FieldDontseeit:
  3980. m.ResetDontseeit()
  3981. return nil
  3982. case contact.FieldDontseeme:
  3983. m.ResetDontseeme()
  3984. return nil
  3985. case contact.FieldLag:
  3986. m.ResetLag()
  3987. return nil
  3988. case contact.FieldGid:
  3989. m.ResetGid()
  3990. return nil
  3991. case contact.FieldGname:
  3992. m.ResetGname()
  3993. return nil
  3994. case contact.FieldV3:
  3995. m.ResetV3()
  3996. return nil
  3997. case contact.FieldOrganizationID:
  3998. m.ResetOrganizationID()
  3999. return nil
  4000. }
  4001. return fmt.Errorf("unknown Contact field %s", name)
  4002. }
  4003. // AddedEdges returns all edge names that were set/added in this mutation.
  4004. func (m *ContactMutation) AddedEdges() []string {
  4005. edges := make([]string, 0, 2)
  4006. if m.contact_relationships != nil {
  4007. edges = append(edges, contact.EdgeContactRelationships)
  4008. }
  4009. if m.contact_messages != nil {
  4010. edges = append(edges, contact.EdgeContactMessages)
  4011. }
  4012. return edges
  4013. }
  4014. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4015. // name in this mutation.
  4016. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  4017. switch name {
  4018. case contact.EdgeContactRelationships:
  4019. ids := make([]ent.Value, 0, len(m.contact_relationships))
  4020. for id := range m.contact_relationships {
  4021. ids = append(ids, id)
  4022. }
  4023. return ids
  4024. case contact.EdgeContactMessages:
  4025. ids := make([]ent.Value, 0, len(m.contact_messages))
  4026. for id := range m.contact_messages {
  4027. ids = append(ids, id)
  4028. }
  4029. return ids
  4030. }
  4031. return nil
  4032. }
  4033. // RemovedEdges returns all edge names that were removed in this mutation.
  4034. func (m *ContactMutation) RemovedEdges() []string {
  4035. edges := make([]string, 0, 2)
  4036. if m.removedcontact_relationships != nil {
  4037. edges = append(edges, contact.EdgeContactRelationships)
  4038. }
  4039. if m.removedcontact_messages != nil {
  4040. edges = append(edges, contact.EdgeContactMessages)
  4041. }
  4042. return edges
  4043. }
  4044. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4045. // the given name in this mutation.
  4046. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  4047. switch name {
  4048. case contact.EdgeContactRelationships:
  4049. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  4050. for id := range m.removedcontact_relationships {
  4051. ids = append(ids, id)
  4052. }
  4053. return ids
  4054. case contact.EdgeContactMessages:
  4055. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  4056. for id := range m.removedcontact_messages {
  4057. ids = append(ids, id)
  4058. }
  4059. return ids
  4060. }
  4061. return nil
  4062. }
  4063. // ClearedEdges returns all edge names that were cleared in this mutation.
  4064. func (m *ContactMutation) ClearedEdges() []string {
  4065. edges := make([]string, 0, 2)
  4066. if m.clearedcontact_relationships {
  4067. edges = append(edges, contact.EdgeContactRelationships)
  4068. }
  4069. if m.clearedcontact_messages {
  4070. edges = append(edges, contact.EdgeContactMessages)
  4071. }
  4072. return edges
  4073. }
  4074. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4075. // was cleared in this mutation.
  4076. func (m *ContactMutation) EdgeCleared(name string) bool {
  4077. switch name {
  4078. case contact.EdgeContactRelationships:
  4079. return m.clearedcontact_relationships
  4080. case contact.EdgeContactMessages:
  4081. return m.clearedcontact_messages
  4082. }
  4083. return false
  4084. }
  4085. // ClearEdge clears the value of the edge with the given name. It returns an error
  4086. // if that edge is not defined in the schema.
  4087. func (m *ContactMutation) ClearEdge(name string) error {
  4088. switch name {
  4089. }
  4090. return fmt.Errorf("unknown Contact unique edge %s", name)
  4091. }
  4092. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4093. // It returns an error if the edge is not defined in the schema.
  4094. func (m *ContactMutation) ResetEdge(name string) error {
  4095. switch name {
  4096. case contact.EdgeContactRelationships:
  4097. m.ResetContactRelationships()
  4098. return nil
  4099. case contact.EdgeContactMessages:
  4100. m.ResetContactMessages()
  4101. return nil
  4102. }
  4103. return fmt.Errorf("unknown Contact edge %s", name)
  4104. }
  4105. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  4106. type EmployeeMutation struct {
  4107. config
  4108. op Op
  4109. typ string
  4110. id *uint64
  4111. created_at *time.Time
  4112. updated_at *time.Time
  4113. deleted_at *time.Time
  4114. title *string
  4115. avatar *string
  4116. tags *string
  4117. hire_count *int
  4118. addhire_count *int
  4119. service_count *int
  4120. addservice_count *int
  4121. achievement_count *int
  4122. addachievement_count *int
  4123. intro *string
  4124. estimate *string
  4125. skill *string
  4126. ability_type *string
  4127. scene *string
  4128. switch_in *string
  4129. video_url *string
  4130. organization_id *uint64
  4131. addorganization_id *int64
  4132. clearedFields map[string]struct{}
  4133. em_work_experiences map[uint64]struct{}
  4134. removedem_work_experiences map[uint64]struct{}
  4135. clearedem_work_experiences bool
  4136. em_tutorial map[uint64]struct{}
  4137. removedem_tutorial map[uint64]struct{}
  4138. clearedem_tutorial bool
  4139. done bool
  4140. oldValue func(context.Context) (*Employee, error)
  4141. predicates []predicate.Employee
  4142. }
  4143. var _ ent.Mutation = (*EmployeeMutation)(nil)
  4144. // employeeOption allows management of the mutation configuration using functional options.
  4145. type employeeOption func(*EmployeeMutation)
  4146. // newEmployeeMutation creates new mutation for the Employee entity.
  4147. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  4148. m := &EmployeeMutation{
  4149. config: c,
  4150. op: op,
  4151. typ: TypeEmployee,
  4152. clearedFields: make(map[string]struct{}),
  4153. }
  4154. for _, opt := range opts {
  4155. opt(m)
  4156. }
  4157. return m
  4158. }
  4159. // withEmployeeID sets the ID field of the mutation.
  4160. func withEmployeeID(id uint64) employeeOption {
  4161. return func(m *EmployeeMutation) {
  4162. var (
  4163. err error
  4164. once sync.Once
  4165. value *Employee
  4166. )
  4167. m.oldValue = func(ctx context.Context) (*Employee, error) {
  4168. once.Do(func() {
  4169. if m.done {
  4170. err = errors.New("querying old values post mutation is not allowed")
  4171. } else {
  4172. value, err = m.Client().Employee.Get(ctx, id)
  4173. }
  4174. })
  4175. return value, err
  4176. }
  4177. m.id = &id
  4178. }
  4179. }
  4180. // withEmployee sets the old Employee of the mutation.
  4181. func withEmployee(node *Employee) employeeOption {
  4182. return func(m *EmployeeMutation) {
  4183. m.oldValue = func(context.Context) (*Employee, error) {
  4184. return node, nil
  4185. }
  4186. m.id = &node.ID
  4187. }
  4188. }
  4189. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4190. // executed in a transaction (ent.Tx), a transactional client is returned.
  4191. func (m EmployeeMutation) Client() *Client {
  4192. client := &Client{config: m.config}
  4193. client.init()
  4194. return client
  4195. }
  4196. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4197. // it returns an error otherwise.
  4198. func (m EmployeeMutation) Tx() (*Tx, error) {
  4199. if _, ok := m.driver.(*txDriver); !ok {
  4200. return nil, errors.New("ent: mutation is not running in a transaction")
  4201. }
  4202. tx := &Tx{config: m.config}
  4203. tx.init()
  4204. return tx, nil
  4205. }
  4206. // SetID sets the value of the id field. Note that this
  4207. // operation is only accepted on creation of Employee entities.
  4208. func (m *EmployeeMutation) SetID(id uint64) {
  4209. m.id = &id
  4210. }
  4211. // ID returns the ID value in the mutation. Note that the ID is only available
  4212. // if it was provided to the builder or after it was returned from the database.
  4213. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  4214. if m.id == nil {
  4215. return
  4216. }
  4217. return *m.id, true
  4218. }
  4219. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4220. // That means, if the mutation is applied within a transaction with an isolation level such
  4221. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4222. // or updated by the mutation.
  4223. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  4224. switch {
  4225. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4226. id, exists := m.ID()
  4227. if exists {
  4228. return []uint64{id}, nil
  4229. }
  4230. fallthrough
  4231. case m.op.Is(OpUpdate | OpDelete):
  4232. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  4233. default:
  4234. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4235. }
  4236. }
  4237. // SetCreatedAt sets the "created_at" field.
  4238. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  4239. m.created_at = &t
  4240. }
  4241. // CreatedAt returns the value of the "created_at" field in the mutation.
  4242. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  4243. v := m.created_at
  4244. if v == nil {
  4245. return
  4246. }
  4247. return *v, true
  4248. }
  4249. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  4250. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4252. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4253. if !m.op.Is(OpUpdateOne) {
  4254. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4255. }
  4256. if m.id == nil || m.oldValue == nil {
  4257. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4258. }
  4259. oldValue, err := m.oldValue(ctx)
  4260. if err != nil {
  4261. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4262. }
  4263. return oldValue.CreatedAt, nil
  4264. }
  4265. // ResetCreatedAt resets all changes to the "created_at" field.
  4266. func (m *EmployeeMutation) ResetCreatedAt() {
  4267. m.created_at = nil
  4268. }
  4269. // SetUpdatedAt sets the "updated_at" field.
  4270. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  4271. m.updated_at = &t
  4272. }
  4273. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4274. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  4275. v := m.updated_at
  4276. if v == nil {
  4277. return
  4278. }
  4279. return *v, true
  4280. }
  4281. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  4282. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4284. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4285. if !m.op.Is(OpUpdateOne) {
  4286. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4287. }
  4288. if m.id == nil || m.oldValue == nil {
  4289. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4290. }
  4291. oldValue, err := m.oldValue(ctx)
  4292. if err != nil {
  4293. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4294. }
  4295. return oldValue.UpdatedAt, nil
  4296. }
  4297. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4298. func (m *EmployeeMutation) ResetUpdatedAt() {
  4299. m.updated_at = nil
  4300. }
  4301. // SetDeletedAt sets the "deleted_at" field.
  4302. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  4303. m.deleted_at = &t
  4304. }
  4305. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4306. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  4307. v := m.deleted_at
  4308. if v == nil {
  4309. return
  4310. }
  4311. return *v, true
  4312. }
  4313. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  4314. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4316. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4317. if !m.op.Is(OpUpdateOne) {
  4318. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4319. }
  4320. if m.id == nil || m.oldValue == nil {
  4321. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4322. }
  4323. oldValue, err := m.oldValue(ctx)
  4324. if err != nil {
  4325. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4326. }
  4327. return oldValue.DeletedAt, nil
  4328. }
  4329. // ClearDeletedAt clears the value of the "deleted_at" field.
  4330. func (m *EmployeeMutation) ClearDeletedAt() {
  4331. m.deleted_at = nil
  4332. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  4333. }
  4334. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4335. func (m *EmployeeMutation) DeletedAtCleared() bool {
  4336. _, ok := m.clearedFields[employee.FieldDeletedAt]
  4337. return ok
  4338. }
  4339. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4340. func (m *EmployeeMutation) ResetDeletedAt() {
  4341. m.deleted_at = nil
  4342. delete(m.clearedFields, employee.FieldDeletedAt)
  4343. }
  4344. // SetTitle sets the "title" field.
  4345. func (m *EmployeeMutation) SetTitle(s string) {
  4346. m.title = &s
  4347. }
  4348. // Title returns the value of the "title" field in the mutation.
  4349. func (m *EmployeeMutation) Title() (r string, exists bool) {
  4350. v := m.title
  4351. if v == nil {
  4352. return
  4353. }
  4354. return *v, true
  4355. }
  4356. // OldTitle returns the old "title" field's value of the Employee entity.
  4357. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4359. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  4360. if !m.op.Is(OpUpdateOne) {
  4361. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4362. }
  4363. if m.id == nil || m.oldValue == nil {
  4364. return v, errors.New("OldTitle requires an ID field in the mutation")
  4365. }
  4366. oldValue, err := m.oldValue(ctx)
  4367. if err != nil {
  4368. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4369. }
  4370. return oldValue.Title, nil
  4371. }
  4372. // ResetTitle resets all changes to the "title" field.
  4373. func (m *EmployeeMutation) ResetTitle() {
  4374. m.title = nil
  4375. }
  4376. // SetAvatar sets the "avatar" field.
  4377. func (m *EmployeeMutation) SetAvatar(s string) {
  4378. m.avatar = &s
  4379. }
  4380. // Avatar returns the value of the "avatar" field in the mutation.
  4381. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  4382. v := m.avatar
  4383. if v == nil {
  4384. return
  4385. }
  4386. return *v, true
  4387. }
  4388. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  4389. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4391. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  4392. if !m.op.Is(OpUpdateOne) {
  4393. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  4394. }
  4395. if m.id == nil || m.oldValue == nil {
  4396. return v, errors.New("OldAvatar requires an ID field in the mutation")
  4397. }
  4398. oldValue, err := m.oldValue(ctx)
  4399. if err != nil {
  4400. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  4401. }
  4402. return oldValue.Avatar, nil
  4403. }
  4404. // ResetAvatar resets all changes to the "avatar" field.
  4405. func (m *EmployeeMutation) ResetAvatar() {
  4406. m.avatar = nil
  4407. }
  4408. // SetTags sets the "tags" field.
  4409. func (m *EmployeeMutation) SetTags(s string) {
  4410. m.tags = &s
  4411. }
  4412. // Tags returns the value of the "tags" field in the mutation.
  4413. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  4414. v := m.tags
  4415. if v == nil {
  4416. return
  4417. }
  4418. return *v, true
  4419. }
  4420. // OldTags returns the old "tags" field's value of the Employee entity.
  4421. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4423. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  4424. if !m.op.Is(OpUpdateOne) {
  4425. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  4426. }
  4427. if m.id == nil || m.oldValue == nil {
  4428. return v, errors.New("OldTags requires an ID field in the mutation")
  4429. }
  4430. oldValue, err := m.oldValue(ctx)
  4431. if err != nil {
  4432. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  4433. }
  4434. return oldValue.Tags, nil
  4435. }
  4436. // ResetTags resets all changes to the "tags" field.
  4437. func (m *EmployeeMutation) ResetTags() {
  4438. m.tags = nil
  4439. }
  4440. // SetHireCount sets the "hire_count" field.
  4441. func (m *EmployeeMutation) SetHireCount(i int) {
  4442. m.hire_count = &i
  4443. m.addhire_count = nil
  4444. }
  4445. // HireCount returns the value of the "hire_count" field in the mutation.
  4446. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  4447. v := m.hire_count
  4448. if v == nil {
  4449. return
  4450. }
  4451. return *v, true
  4452. }
  4453. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  4454. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4456. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  4457. if !m.op.Is(OpUpdateOne) {
  4458. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  4459. }
  4460. if m.id == nil || m.oldValue == nil {
  4461. return v, errors.New("OldHireCount requires an ID field in the mutation")
  4462. }
  4463. oldValue, err := m.oldValue(ctx)
  4464. if err != nil {
  4465. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  4466. }
  4467. return oldValue.HireCount, nil
  4468. }
  4469. // AddHireCount adds i to the "hire_count" field.
  4470. func (m *EmployeeMutation) AddHireCount(i int) {
  4471. if m.addhire_count != nil {
  4472. *m.addhire_count += i
  4473. } else {
  4474. m.addhire_count = &i
  4475. }
  4476. }
  4477. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  4478. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  4479. v := m.addhire_count
  4480. if v == nil {
  4481. return
  4482. }
  4483. return *v, true
  4484. }
  4485. // ResetHireCount resets all changes to the "hire_count" field.
  4486. func (m *EmployeeMutation) ResetHireCount() {
  4487. m.hire_count = nil
  4488. m.addhire_count = nil
  4489. }
  4490. // SetServiceCount sets the "service_count" field.
  4491. func (m *EmployeeMutation) SetServiceCount(i int) {
  4492. m.service_count = &i
  4493. m.addservice_count = nil
  4494. }
  4495. // ServiceCount returns the value of the "service_count" field in the mutation.
  4496. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  4497. v := m.service_count
  4498. if v == nil {
  4499. return
  4500. }
  4501. return *v, true
  4502. }
  4503. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  4504. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4506. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  4507. if !m.op.Is(OpUpdateOne) {
  4508. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  4509. }
  4510. if m.id == nil || m.oldValue == nil {
  4511. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  4512. }
  4513. oldValue, err := m.oldValue(ctx)
  4514. if err != nil {
  4515. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  4516. }
  4517. return oldValue.ServiceCount, nil
  4518. }
  4519. // AddServiceCount adds i to the "service_count" field.
  4520. func (m *EmployeeMutation) AddServiceCount(i int) {
  4521. if m.addservice_count != nil {
  4522. *m.addservice_count += i
  4523. } else {
  4524. m.addservice_count = &i
  4525. }
  4526. }
  4527. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  4528. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  4529. v := m.addservice_count
  4530. if v == nil {
  4531. return
  4532. }
  4533. return *v, true
  4534. }
  4535. // ResetServiceCount resets all changes to the "service_count" field.
  4536. func (m *EmployeeMutation) ResetServiceCount() {
  4537. m.service_count = nil
  4538. m.addservice_count = nil
  4539. }
  4540. // SetAchievementCount sets the "achievement_count" field.
  4541. func (m *EmployeeMutation) SetAchievementCount(i int) {
  4542. m.achievement_count = &i
  4543. m.addachievement_count = nil
  4544. }
  4545. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  4546. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  4547. v := m.achievement_count
  4548. if v == nil {
  4549. return
  4550. }
  4551. return *v, true
  4552. }
  4553. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  4554. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4556. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  4557. if !m.op.Is(OpUpdateOne) {
  4558. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  4559. }
  4560. if m.id == nil || m.oldValue == nil {
  4561. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  4562. }
  4563. oldValue, err := m.oldValue(ctx)
  4564. if err != nil {
  4565. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  4566. }
  4567. return oldValue.AchievementCount, nil
  4568. }
  4569. // AddAchievementCount adds i to the "achievement_count" field.
  4570. func (m *EmployeeMutation) AddAchievementCount(i int) {
  4571. if m.addachievement_count != nil {
  4572. *m.addachievement_count += i
  4573. } else {
  4574. m.addachievement_count = &i
  4575. }
  4576. }
  4577. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  4578. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  4579. v := m.addachievement_count
  4580. if v == nil {
  4581. return
  4582. }
  4583. return *v, true
  4584. }
  4585. // ResetAchievementCount resets all changes to the "achievement_count" field.
  4586. func (m *EmployeeMutation) ResetAchievementCount() {
  4587. m.achievement_count = nil
  4588. m.addachievement_count = nil
  4589. }
  4590. // SetIntro sets the "intro" field.
  4591. func (m *EmployeeMutation) SetIntro(s string) {
  4592. m.intro = &s
  4593. }
  4594. // Intro returns the value of the "intro" field in the mutation.
  4595. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  4596. v := m.intro
  4597. if v == nil {
  4598. return
  4599. }
  4600. return *v, true
  4601. }
  4602. // OldIntro returns the old "intro" field's value of the Employee entity.
  4603. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4605. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  4606. if !m.op.Is(OpUpdateOne) {
  4607. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  4608. }
  4609. if m.id == nil || m.oldValue == nil {
  4610. return v, errors.New("OldIntro requires an ID field in the mutation")
  4611. }
  4612. oldValue, err := m.oldValue(ctx)
  4613. if err != nil {
  4614. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  4615. }
  4616. return oldValue.Intro, nil
  4617. }
  4618. // ResetIntro resets all changes to the "intro" field.
  4619. func (m *EmployeeMutation) ResetIntro() {
  4620. m.intro = nil
  4621. }
  4622. // SetEstimate sets the "estimate" field.
  4623. func (m *EmployeeMutation) SetEstimate(s string) {
  4624. m.estimate = &s
  4625. }
  4626. // Estimate returns the value of the "estimate" field in the mutation.
  4627. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  4628. v := m.estimate
  4629. if v == nil {
  4630. return
  4631. }
  4632. return *v, true
  4633. }
  4634. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  4635. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4637. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  4638. if !m.op.Is(OpUpdateOne) {
  4639. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  4640. }
  4641. if m.id == nil || m.oldValue == nil {
  4642. return v, errors.New("OldEstimate requires an ID field in the mutation")
  4643. }
  4644. oldValue, err := m.oldValue(ctx)
  4645. if err != nil {
  4646. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  4647. }
  4648. return oldValue.Estimate, nil
  4649. }
  4650. // ResetEstimate resets all changes to the "estimate" field.
  4651. func (m *EmployeeMutation) ResetEstimate() {
  4652. m.estimate = nil
  4653. }
  4654. // SetSkill sets the "skill" field.
  4655. func (m *EmployeeMutation) SetSkill(s string) {
  4656. m.skill = &s
  4657. }
  4658. // Skill returns the value of the "skill" field in the mutation.
  4659. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  4660. v := m.skill
  4661. if v == nil {
  4662. return
  4663. }
  4664. return *v, true
  4665. }
  4666. // OldSkill returns the old "skill" field's value of the Employee entity.
  4667. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4669. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  4670. if !m.op.Is(OpUpdateOne) {
  4671. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  4672. }
  4673. if m.id == nil || m.oldValue == nil {
  4674. return v, errors.New("OldSkill requires an ID field in the mutation")
  4675. }
  4676. oldValue, err := m.oldValue(ctx)
  4677. if err != nil {
  4678. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  4679. }
  4680. return oldValue.Skill, nil
  4681. }
  4682. // ResetSkill resets all changes to the "skill" field.
  4683. func (m *EmployeeMutation) ResetSkill() {
  4684. m.skill = nil
  4685. }
  4686. // SetAbilityType sets the "ability_type" field.
  4687. func (m *EmployeeMutation) SetAbilityType(s string) {
  4688. m.ability_type = &s
  4689. }
  4690. // AbilityType returns the value of the "ability_type" field in the mutation.
  4691. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  4692. v := m.ability_type
  4693. if v == nil {
  4694. return
  4695. }
  4696. return *v, true
  4697. }
  4698. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  4699. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4701. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  4702. if !m.op.Is(OpUpdateOne) {
  4703. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  4704. }
  4705. if m.id == nil || m.oldValue == nil {
  4706. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  4707. }
  4708. oldValue, err := m.oldValue(ctx)
  4709. if err != nil {
  4710. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  4711. }
  4712. return oldValue.AbilityType, nil
  4713. }
  4714. // ResetAbilityType resets all changes to the "ability_type" field.
  4715. func (m *EmployeeMutation) ResetAbilityType() {
  4716. m.ability_type = nil
  4717. }
  4718. // SetScene sets the "scene" field.
  4719. func (m *EmployeeMutation) SetScene(s string) {
  4720. m.scene = &s
  4721. }
  4722. // Scene returns the value of the "scene" field in the mutation.
  4723. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  4724. v := m.scene
  4725. if v == nil {
  4726. return
  4727. }
  4728. return *v, true
  4729. }
  4730. // OldScene returns the old "scene" field's value of the Employee entity.
  4731. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4733. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  4734. if !m.op.Is(OpUpdateOne) {
  4735. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  4736. }
  4737. if m.id == nil || m.oldValue == nil {
  4738. return v, errors.New("OldScene requires an ID field in the mutation")
  4739. }
  4740. oldValue, err := m.oldValue(ctx)
  4741. if err != nil {
  4742. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  4743. }
  4744. return oldValue.Scene, nil
  4745. }
  4746. // ResetScene resets all changes to the "scene" field.
  4747. func (m *EmployeeMutation) ResetScene() {
  4748. m.scene = nil
  4749. }
  4750. // SetSwitchIn sets the "switch_in" field.
  4751. func (m *EmployeeMutation) SetSwitchIn(s string) {
  4752. m.switch_in = &s
  4753. }
  4754. // SwitchIn returns the value of the "switch_in" field in the mutation.
  4755. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  4756. v := m.switch_in
  4757. if v == nil {
  4758. return
  4759. }
  4760. return *v, true
  4761. }
  4762. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  4763. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4765. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  4766. if !m.op.Is(OpUpdateOne) {
  4767. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  4768. }
  4769. if m.id == nil || m.oldValue == nil {
  4770. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  4771. }
  4772. oldValue, err := m.oldValue(ctx)
  4773. if err != nil {
  4774. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  4775. }
  4776. return oldValue.SwitchIn, nil
  4777. }
  4778. // ResetSwitchIn resets all changes to the "switch_in" field.
  4779. func (m *EmployeeMutation) ResetSwitchIn() {
  4780. m.switch_in = nil
  4781. }
  4782. // SetVideoURL sets the "video_url" field.
  4783. func (m *EmployeeMutation) SetVideoURL(s string) {
  4784. m.video_url = &s
  4785. }
  4786. // VideoURL returns the value of the "video_url" field in the mutation.
  4787. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  4788. v := m.video_url
  4789. if v == nil {
  4790. return
  4791. }
  4792. return *v, true
  4793. }
  4794. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  4795. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4797. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  4798. if !m.op.Is(OpUpdateOne) {
  4799. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  4800. }
  4801. if m.id == nil || m.oldValue == nil {
  4802. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  4803. }
  4804. oldValue, err := m.oldValue(ctx)
  4805. if err != nil {
  4806. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  4807. }
  4808. return oldValue.VideoURL, nil
  4809. }
  4810. // ResetVideoURL resets all changes to the "video_url" field.
  4811. func (m *EmployeeMutation) ResetVideoURL() {
  4812. m.video_url = nil
  4813. }
  4814. // SetOrganizationID sets the "organization_id" field.
  4815. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  4816. m.organization_id = &u
  4817. m.addorganization_id = nil
  4818. }
  4819. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4820. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  4821. v := m.organization_id
  4822. if v == nil {
  4823. return
  4824. }
  4825. return *v, true
  4826. }
  4827. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  4828. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4829. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4830. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4831. if !m.op.Is(OpUpdateOne) {
  4832. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4833. }
  4834. if m.id == nil || m.oldValue == nil {
  4835. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4836. }
  4837. oldValue, err := m.oldValue(ctx)
  4838. if err != nil {
  4839. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4840. }
  4841. return oldValue.OrganizationID, nil
  4842. }
  4843. // AddOrganizationID adds u to the "organization_id" field.
  4844. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  4845. if m.addorganization_id != nil {
  4846. *m.addorganization_id += u
  4847. } else {
  4848. m.addorganization_id = &u
  4849. }
  4850. }
  4851. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4852. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  4853. v := m.addorganization_id
  4854. if v == nil {
  4855. return
  4856. }
  4857. return *v, true
  4858. }
  4859. // ResetOrganizationID resets all changes to the "organization_id" field.
  4860. func (m *EmployeeMutation) ResetOrganizationID() {
  4861. m.organization_id = nil
  4862. m.addorganization_id = nil
  4863. }
  4864. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  4865. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  4866. if m.em_work_experiences == nil {
  4867. m.em_work_experiences = make(map[uint64]struct{})
  4868. }
  4869. for i := range ids {
  4870. m.em_work_experiences[ids[i]] = struct{}{}
  4871. }
  4872. }
  4873. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  4874. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  4875. m.clearedem_work_experiences = true
  4876. }
  4877. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  4878. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  4879. return m.clearedem_work_experiences
  4880. }
  4881. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  4882. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  4883. if m.removedem_work_experiences == nil {
  4884. m.removedem_work_experiences = make(map[uint64]struct{})
  4885. }
  4886. for i := range ids {
  4887. delete(m.em_work_experiences, ids[i])
  4888. m.removedem_work_experiences[ids[i]] = struct{}{}
  4889. }
  4890. }
  4891. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  4892. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  4893. for id := range m.removedem_work_experiences {
  4894. ids = append(ids, id)
  4895. }
  4896. return
  4897. }
  4898. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  4899. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  4900. for id := range m.em_work_experiences {
  4901. ids = append(ids, id)
  4902. }
  4903. return
  4904. }
  4905. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  4906. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  4907. m.em_work_experiences = nil
  4908. m.clearedem_work_experiences = false
  4909. m.removedem_work_experiences = nil
  4910. }
  4911. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  4912. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  4913. if m.em_tutorial == nil {
  4914. m.em_tutorial = make(map[uint64]struct{})
  4915. }
  4916. for i := range ids {
  4917. m.em_tutorial[ids[i]] = struct{}{}
  4918. }
  4919. }
  4920. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  4921. func (m *EmployeeMutation) ClearEmTutorial() {
  4922. m.clearedem_tutorial = true
  4923. }
  4924. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  4925. func (m *EmployeeMutation) EmTutorialCleared() bool {
  4926. return m.clearedem_tutorial
  4927. }
  4928. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  4929. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  4930. if m.removedem_tutorial == nil {
  4931. m.removedem_tutorial = make(map[uint64]struct{})
  4932. }
  4933. for i := range ids {
  4934. delete(m.em_tutorial, ids[i])
  4935. m.removedem_tutorial[ids[i]] = struct{}{}
  4936. }
  4937. }
  4938. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  4939. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  4940. for id := range m.removedem_tutorial {
  4941. ids = append(ids, id)
  4942. }
  4943. return
  4944. }
  4945. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  4946. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  4947. for id := range m.em_tutorial {
  4948. ids = append(ids, id)
  4949. }
  4950. return
  4951. }
  4952. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  4953. func (m *EmployeeMutation) ResetEmTutorial() {
  4954. m.em_tutorial = nil
  4955. m.clearedem_tutorial = false
  4956. m.removedem_tutorial = nil
  4957. }
  4958. // Where appends a list predicates to the EmployeeMutation builder.
  4959. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  4960. m.predicates = append(m.predicates, ps...)
  4961. }
  4962. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  4963. // users can use type-assertion to append predicates that do not depend on any generated package.
  4964. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  4965. p := make([]predicate.Employee, len(ps))
  4966. for i := range ps {
  4967. p[i] = ps[i]
  4968. }
  4969. m.Where(p...)
  4970. }
  4971. // Op returns the operation name.
  4972. func (m *EmployeeMutation) Op() Op {
  4973. return m.op
  4974. }
  4975. // SetOp allows setting the mutation operation.
  4976. func (m *EmployeeMutation) SetOp(op Op) {
  4977. m.op = op
  4978. }
  4979. // Type returns the node type of this mutation (Employee).
  4980. func (m *EmployeeMutation) Type() string {
  4981. return m.typ
  4982. }
  4983. // Fields returns all fields that were changed during this mutation. Note that in
  4984. // order to get all numeric fields that were incremented/decremented, call
  4985. // AddedFields().
  4986. func (m *EmployeeMutation) Fields() []string {
  4987. fields := make([]string, 0, 17)
  4988. if m.created_at != nil {
  4989. fields = append(fields, employee.FieldCreatedAt)
  4990. }
  4991. if m.updated_at != nil {
  4992. fields = append(fields, employee.FieldUpdatedAt)
  4993. }
  4994. if m.deleted_at != nil {
  4995. fields = append(fields, employee.FieldDeletedAt)
  4996. }
  4997. if m.title != nil {
  4998. fields = append(fields, employee.FieldTitle)
  4999. }
  5000. if m.avatar != nil {
  5001. fields = append(fields, employee.FieldAvatar)
  5002. }
  5003. if m.tags != nil {
  5004. fields = append(fields, employee.FieldTags)
  5005. }
  5006. if m.hire_count != nil {
  5007. fields = append(fields, employee.FieldHireCount)
  5008. }
  5009. if m.service_count != nil {
  5010. fields = append(fields, employee.FieldServiceCount)
  5011. }
  5012. if m.achievement_count != nil {
  5013. fields = append(fields, employee.FieldAchievementCount)
  5014. }
  5015. if m.intro != nil {
  5016. fields = append(fields, employee.FieldIntro)
  5017. }
  5018. if m.estimate != nil {
  5019. fields = append(fields, employee.FieldEstimate)
  5020. }
  5021. if m.skill != nil {
  5022. fields = append(fields, employee.FieldSkill)
  5023. }
  5024. if m.ability_type != nil {
  5025. fields = append(fields, employee.FieldAbilityType)
  5026. }
  5027. if m.scene != nil {
  5028. fields = append(fields, employee.FieldScene)
  5029. }
  5030. if m.switch_in != nil {
  5031. fields = append(fields, employee.FieldSwitchIn)
  5032. }
  5033. if m.video_url != nil {
  5034. fields = append(fields, employee.FieldVideoURL)
  5035. }
  5036. if m.organization_id != nil {
  5037. fields = append(fields, employee.FieldOrganizationID)
  5038. }
  5039. return fields
  5040. }
  5041. // Field returns the value of a field with the given name. The second boolean
  5042. // return value indicates that this field was not set, or was not defined in the
  5043. // schema.
  5044. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  5045. switch name {
  5046. case employee.FieldCreatedAt:
  5047. return m.CreatedAt()
  5048. case employee.FieldUpdatedAt:
  5049. return m.UpdatedAt()
  5050. case employee.FieldDeletedAt:
  5051. return m.DeletedAt()
  5052. case employee.FieldTitle:
  5053. return m.Title()
  5054. case employee.FieldAvatar:
  5055. return m.Avatar()
  5056. case employee.FieldTags:
  5057. return m.Tags()
  5058. case employee.FieldHireCount:
  5059. return m.HireCount()
  5060. case employee.FieldServiceCount:
  5061. return m.ServiceCount()
  5062. case employee.FieldAchievementCount:
  5063. return m.AchievementCount()
  5064. case employee.FieldIntro:
  5065. return m.Intro()
  5066. case employee.FieldEstimate:
  5067. return m.Estimate()
  5068. case employee.FieldSkill:
  5069. return m.Skill()
  5070. case employee.FieldAbilityType:
  5071. return m.AbilityType()
  5072. case employee.FieldScene:
  5073. return m.Scene()
  5074. case employee.FieldSwitchIn:
  5075. return m.SwitchIn()
  5076. case employee.FieldVideoURL:
  5077. return m.VideoURL()
  5078. case employee.FieldOrganizationID:
  5079. return m.OrganizationID()
  5080. }
  5081. return nil, false
  5082. }
  5083. // OldField returns the old value of the field from the database. An error is
  5084. // returned if the mutation operation is not UpdateOne, or the query to the
  5085. // database failed.
  5086. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5087. switch name {
  5088. case employee.FieldCreatedAt:
  5089. return m.OldCreatedAt(ctx)
  5090. case employee.FieldUpdatedAt:
  5091. return m.OldUpdatedAt(ctx)
  5092. case employee.FieldDeletedAt:
  5093. return m.OldDeletedAt(ctx)
  5094. case employee.FieldTitle:
  5095. return m.OldTitle(ctx)
  5096. case employee.FieldAvatar:
  5097. return m.OldAvatar(ctx)
  5098. case employee.FieldTags:
  5099. return m.OldTags(ctx)
  5100. case employee.FieldHireCount:
  5101. return m.OldHireCount(ctx)
  5102. case employee.FieldServiceCount:
  5103. return m.OldServiceCount(ctx)
  5104. case employee.FieldAchievementCount:
  5105. return m.OldAchievementCount(ctx)
  5106. case employee.FieldIntro:
  5107. return m.OldIntro(ctx)
  5108. case employee.FieldEstimate:
  5109. return m.OldEstimate(ctx)
  5110. case employee.FieldSkill:
  5111. return m.OldSkill(ctx)
  5112. case employee.FieldAbilityType:
  5113. return m.OldAbilityType(ctx)
  5114. case employee.FieldScene:
  5115. return m.OldScene(ctx)
  5116. case employee.FieldSwitchIn:
  5117. return m.OldSwitchIn(ctx)
  5118. case employee.FieldVideoURL:
  5119. return m.OldVideoURL(ctx)
  5120. case employee.FieldOrganizationID:
  5121. return m.OldOrganizationID(ctx)
  5122. }
  5123. return nil, fmt.Errorf("unknown Employee field %s", name)
  5124. }
  5125. // SetField sets the value of a field with the given name. It returns an error if
  5126. // the field is not defined in the schema, or if the type mismatched the field
  5127. // type.
  5128. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  5129. switch name {
  5130. case employee.FieldCreatedAt:
  5131. v, ok := value.(time.Time)
  5132. if !ok {
  5133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5134. }
  5135. m.SetCreatedAt(v)
  5136. return nil
  5137. case employee.FieldUpdatedAt:
  5138. v, ok := value.(time.Time)
  5139. if !ok {
  5140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5141. }
  5142. m.SetUpdatedAt(v)
  5143. return nil
  5144. case employee.FieldDeletedAt:
  5145. v, ok := value.(time.Time)
  5146. if !ok {
  5147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5148. }
  5149. m.SetDeletedAt(v)
  5150. return nil
  5151. case employee.FieldTitle:
  5152. v, ok := value.(string)
  5153. if !ok {
  5154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5155. }
  5156. m.SetTitle(v)
  5157. return nil
  5158. case employee.FieldAvatar:
  5159. v, ok := value.(string)
  5160. if !ok {
  5161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5162. }
  5163. m.SetAvatar(v)
  5164. return nil
  5165. case employee.FieldTags:
  5166. v, ok := value.(string)
  5167. if !ok {
  5168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5169. }
  5170. m.SetTags(v)
  5171. return nil
  5172. case employee.FieldHireCount:
  5173. v, ok := value.(int)
  5174. if !ok {
  5175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5176. }
  5177. m.SetHireCount(v)
  5178. return nil
  5179. case employee.FieldServiceCount:
  5180. v, ok := value.(int)
  5181. if !ok {
  5182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5183. }
  5184. m.SetServiceCount(v)
  5185. return nil
  5186. case employee.FieldAchievementCount:
  5187. v, ok := value.(int)
  5188. if !ok {
  5189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5190. }
  5191. m.SetAchievementCount(v)
  5192. return nil
  5193. case employee.FieldIntro:
  5194. v, ok := value.(string)
  5195. if !ok {
  5196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5197. }
  5198. m.SetIntro(v)
  5199. return nil
  5200. case employee.FieldEstimate:
  5201. v, ok := value.(string)
  5202. if !ok {
  5203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5204. }
  5205. m.SetEstimate(v)
  5206. return nil
  5207. case employee.FieldSkill:
  5208. v, ok := value.(string)
  5209. if !ok {
  5210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5211. }
  5212. m.SetSkill(v)
  5213. return nil
  5214. case employee.FieldAbilityType:
  5215. v, ok := value.(string)
  5216. if !ok {
  5217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5218. }
  5219. m.SetAbilityType(v)
  5220. return nil
  5221. case employee.FieldScene:
  5222. v, ok := value.(string)
  5223. if !ok {
  5224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5225. }
  5226. m.SetScene(v)
  5227. return nil
  5228. case employee.FieldSwitchIn:
  5229. v, ok := value.(string)
  5230. if !ok {
  5231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5232. }
  5233. m.SetSwitchIn(v)
  5234. return nil
  5235. case employee.FieldVideoURL:
  5236. v, ok := value.(string)
  5237. if !ok {
  5238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5239. }
  5240. m.SetVideoURL(v)
  5241. return nil
  5242. case employee.FieldOrganizationID:
  5243. v, ok := value.(uint64)
  5244. if !ok {
  5245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5246. }
  5247. m.SetOrganizationID(v)
  5248. return nil
  5249. }
  5250. return fmt.Errorf("unknown Employee field %s", name)
  5251. }
  5252. // AddedFields returns all numeric fields that were incremented/decremented during
  5253. // this mutation.
  5254. func (m *EmployeeMutation) AddedFields() []string {
  5255. var fields []string
  5256. if m.addhire_count != nil {
  5257. fields = append(fields, employee.FieldHireCount)
  5258. }
  5259. if m.addservice_count != nil {
  5260. fields = append(fields, employee.FieldServiceCount)
  5261. }
  5262. if m.addachievement_count != nil {
  5263. fields = append(fields, employee.FieldAchievementCount)
  5264. }
  5265. if m.addorganization_id != nil {
  5266. fields = append(fields, employee.FieldOrganizationID)
  5267. }
  5268. return fields
  5269. }
  5270. // AddedField returns the numeric value that was incremented/decremented on a field
  5271. // with the given name. The second boolean return value indicates that this field
  5272. // was not set, or was not defined in the schema.
  5273. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  5274. switch name {
  5275. case employee.FieldHireCount:
  5276. return m.AddedHireCount()
  5277. case employee.FieldServiceCount:
  5278. return m.AddedServiceCount()
  5279. case employee.FieldAchievementCount:
  5280. return m.AddedAchievementCount()
  5281. case employee.FieldOrganizationID:
  5282. return m.AddedOrganizationID()
  5283. }
  5284. return nil, false
  5285. }
  5286. // AddField adds the value to the field with the given name. It returns an error if
  5287. // the field is not defined in the schema, or if the type mismatched the field
  5288. // type.
  5289. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  5290. switch name {
  5291. case employee.FieldHireCount:
  5292. v, ok := value.(int)
  5293. if !ok {
  5294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5295. }
  5296. m.AddHireCount(v)
  5297. return nil
  5298. case employee.FieldServiceCount:
  5299. v, ok := value.(int)
  5300. if !ok {
  5301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5302. }
  5303. m.AddServiceCount(v)
  5304. return nil
  5305. case employee.FieldAchievementCount:
  5306. v, ok := value.(int)
  5307. if !ok {
  5308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5309. }
  5310. m.AddAchievementCount(v)
  5311. return nil
  5312. case employee.FieldOrganizationID:
  5313. v, ok := value.(int64)
  5314. if !ok {
  5315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5316. }
  5317. m.AddOrganizationID(v)
  5318. return nil
  5319. }
  5320. return fmt.Errorf("unknown Employee numeric field %s", name)
  5321. }
  5322. // ClearedFields returns all nullable fields that were cleared during this
  5323. // mutation.
  5324. func (m *EmployeeMutation) ClearedFields() []string {
  5325. var fields []string
  5326. if m.FieldCleared(employee.FieldDeletedAt) {
  5327. fields = append(fields, employee.FieldDeletedAt)
  5328. }
  5329. return fields
  5330. }
  5331. // FieldCleared returns a boolean indicating if a field with the given name was
  5332. // cleared in this mutation.
  5333. func (m *EmployeeMutation) FieldCleared(name string) bool {
  5334. _, ok := m.clearedFields[name]
  5335. return ok
  5336. }
  5337. // ClearField clears the value of the field with the given name. It returns an
  5338. // error if the field is not defined in the schema.
  5339. func (m *EmployeeMutation) ClearField(name string) error {
  5340. switch name {
  5341. case employee.FieldDeletedAt:
  5342. m.ClearDeletedAt()
  5343. return nil
  5344. }
  5345. return fmt.Errorf("unknown Employee nullable field %s", name)
  5346. }
  5347. // ResetField resets all changes in the mutation for the field with the given name.
  5348. // It returns an error if the field is not defined in the schema.
  5349. func (m *EmployeeMutation) ResetField(name string) error {
  5350. switch name {
  5351. case employee.FieldCreatedAt:
  5352. m.ResetCreatedAt()
  5353. return nil
  5354. case employee.FieldUpdatedAt:
  5355. m.ResetUpdatedAt()
  5356. return nil
  5357. case employee.FieldDeletedAt:
  5358. m.ResetDeletedAt()
  5359. return nil
  5360. case employee.FieldTitle:
  5361. m.ResetTitle()
  5362. return nil
  5363. case employee.FieldAvatar:
  5364. m.ResetAvatar()
  5365. return nil
  5366. case employee.FieldTags:
  5367. m.ResetTags()
  5368. return nil
  5369. case employee.FieldHireCount:
  5370. m.ResetHireCount()
  5371. return nil
  5372. case employee.FieldServiceCount:
  5373. m.ResetServiceCount()
  5374. return nil
  5375. case employee.FieldAchievementCount:
  5376. m.ResetAchievementCount()
  5377. return nil
  5378. case employee.FieldIntro:
  5379. m.ResetIntro()
  5380. return nil
  5381. case employee.FieldEstimate:
  5382. m.ResetEstimate()
  5383. return nil
  5384. case employee.FieldSkill:
  5385. m.ResetSkill()
  5386. return nil
  5387. case employee.FieldAbilityType:
  5388. m.ResetAbilityType()
  5389. return nil
  5390. case employee.FieldScene:
  5391. m.ResetScene()
  5392. return nil
  5393. case employee.FieldSwitchIn:
  5394. m.ResetSwitchIn()
  5395. return nil
  5396. case employee.FieldVideoURL:
  5397. m.ResetVideoURL()
  5398. return nil
  5399. case employee.FieldOrganizationID:
  5400. m.ResetOrganizationID()
  5401. return nil
  5402. }
  5403. return fmt.Errorf("unknown Employee field %s", name)
  5404. }
  5405. // AddedEdges returns all edge names that were set/added in this mutation.
  5406. func (m *EmployeeMutation) AddedEdges() []string {
  5407. edges := make([]string, 0, 2)
  5408. if m.em_work_experiences != nil {
  5409. edges = append(edges, employee.EdgeEmWorkExperiences)
  5410. }
  5411. if m.em_tutorial != nil {
  5412. edges = append(edges, employee.EdgeEmTutorial)
  5413. }
  5414. return edges
  5415. }
  5416. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5417. // name in this mutation.
  5418. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  5419. switch name {
  5420. case employee.EdgeEmWorkExperiences:
  5421. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  5422. for id := range m.em_work_experiences {
  5423. ids = append(ids, id)
  5424. }
  5425. return ids
  5426. case employee.EdgeEmTutorial:
  5427. ids := make([]ent.Value, 0, len(m.em_tutorial))
  5428. for id := range m.em_tutorial {
  5429. ids = append(ids, id)
  5430. }
  5431. return ids
  5432. }
  5433. return nil
  5434. }
  5435. // RemovedEdges returns all edge names that were removed in this mutation.
  5436. func (m *EmployeeMutation) RemovedEdges() []string {
  5437. edges := make([]string, 0, 2)
  5438. if m.removedem_work_experiences != nil {
  5439. edges = append(edges, employee.EdgeEmWorkExperiences)
  5440. }
  5441. if m.removedem_tutorial != nil {
  5442. edges = append(edges, employee.EdgeEmTutorial)
  5443. }
  5444. return edges
  5445. }
  5446. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5447. // the given name in this mutation.
  5448. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  5449. switch name {
  5450. case employee.EdgeEmWorkExperiences:
  5451. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  5452. for id := range m.removedem_work_experiences {
  5453. ids = append(ids, id)
  5454. }
  5455. return ids
  5456. case employee.EdgeEmTutorial:
  5457. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  5458. for id := range m.removedem_tutorial {
  5459. ids = append(ids, id)
  5460. }
  5461. return ids
  5462. }
  5463. return nil
  5464. }
  5465. // ClearedEdges returns all edge names that were cleared in this mutation.
  5466. func (m *EmployeeMutation) ClearedEdges() []string {
  5467. edges := make([]string, 0, 2)
  5468. if m.clearedem_work_experiences {
  5469. edges = append(edges, employee.EdgeEmWorkExperiences)
  5470. }
  5471. if m.clearedem_tutorial {
  5472. edges = append(edges, employee.EdgeEmTutorial)
  5473. }
  5474. return edges
  5475. }
  5476. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5477. // was cleared in this mutation.
  5478. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  5479. switch name {
  5480. case employee.EdgeEmWorkExperiences:
  5481. return m.clearedem_work_experiences
  5482. case employee.EdgeEmTutorial:
  5483. return m.clearedem_tutorial
  5484. }
  5485. return false
  5486. }
  5487. // ClearEdge clears the value of the edge with the given name. It returns an error
  5488. // if that edge is not defined in the schema.
  5489. func (m *EmployeeMutation) ClearEdge(name string) error {
  5490. switch name {
  5491. }
  5492. return fmt.Errorf("unknown Employee unique edge %s", name)
  5493. }
  5494. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5495. // It returns an error if the edge is not defined in the schema.
  5496. func (m *EmployeeMutation) ResetEdge(name string) error {
  5497. switch name {
  5498. case employee.EdgeEmWorkExperiences:
  5499. m.ResetEmWorkExperiences()
  5500. return nil
  5501. case employee.EdgeEmTutorial:
  5502. m.ResetEmTutorial()
  5503. return nil
  5504. }
  5505. return fmt.Errorf("unknown Employee edge %s", name)
  5506. }
  5507. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  5508. type LabelMutation struct {
  5509. config
  5510. op Op
  5511. typ string
  5512. id *uint64
  5513. created_at *time.Time
  5514. updated_at *time.Time
  5515. status *uint8
  5516. addstatus *int8
  5517. _type *int
  5518. add_type *int
  5519. name *string
  5520. from *int
  5521. addfrom *int
  5522. mode *int
  5523. addmode *int
  5524. conditions *string
  5525. organization_id *uint64
  5526. addorganization_id *int64
  5527. clearedFields map[string]struct{}
  5528. label_relationships map[uint64]struct{}
  5529. removedlabel_relationships map[uint64]struct{}
  5530. clearedlabel_relationships bool
  5531. done bool
  5532. oldValue func(context.Context) (*Label, error)
  5533. predicates []predicate.Label
  5534. }
  5535. var _ ent.Mutation = (*LabelMutation)(nil)
  5536. // labelOption allows management of the mutation configuration using functional options.
  5537. type labelOption func(*LabelMutation)
  5538. // newLabelMutation creates new mutation for the Label entity.
  5539. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  5540. m := &LabelMutation{
  5541. config: c,
  5542. op: op,
  5543. typ: TypeLabel,
  5544. clearedFields: make(map[string]struct{}),
  5545. }
  5546. for _, opt := range opts {
  5547. opt(m)
  5548. }
  5549. return m
  5550. }
  5551. // withLabelID sets the ID field of the mutation.
  5552. func withLabelID(id uint64) labelOption {
  5553. return func(m *LabelMutation) {
  5554. var (
  5555. err error
  5556. once sync.Once
  5557. value *Label
  5558. )
  5559. m.oldValue = func(ctx context.Context) (*Label, error) {
  5560. once.Do(func() {
  5561. if m.done {
  5562. err = errors.New("querying old values post mutation is not allowed")
  5563. } else {
  5564. value, err = m.Client().Label.Get(ctx, id)
  5565. }
  5566. })
  5567. return value, err
  5568. }
  5569. m.id = &id
  5570. }
  5571. }
  5572. // withLabel sets the old Label of the mutation.
  5573. func withLabel(node *Label) labelOption {
  5574. return func(m *LabelMutation) {
  5575. m.oldValue = func(context.Context) (*Label, error) {
  5576. return node, nil
  5577. }
  5578. m.id = &node.ID
  5579. }
  5580. }
  5581. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5582. // executed in a transaction (ent.Tx), a transactional client is returned.
  5583. func (m LabelMutation) Client() *Client {
  5584. client := &Client{config: m.config}
  5585. client.init()
  5586. return client
  5587. }
  5588. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5589. // it returns an error otherwise.
  5590. func (m LabelMutation) Tx() (*Tx, error) {
  5591. if _, ok := m.driver.(*txDriver); !ok {
  5592. return nil, errors.New("ent: mutation is not running in a transaction")
  5593. }
  5594. tx := &Tx{config: m.config}
  5595. tx.init()
  5596. return tx, nil
  5597. }
  5598. // SetID sets the value of the id field. Note that this
  5599. // operation is only accepted on creation of Label entities.
  5600. func (m *LabelMutation) SetID(id uint64) {
  5601. m.id = &id
  5602. }
  5603. // ID returns the ID value in the mutation. Note that the ID is only available
  5604. // if it was provided to the builder or after it was returned from the database.
  5605. func (m *LabelMutation) ID() (id uint64, exists bool) {
  5606. if m.id == nil {
  5607. return
  5608. }
  5609. return *m.id, true
  5610. }
  5611. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5612. // That means, if the mutation is applied within a transaction with an isolation level such
  5613. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5614. // or updated by the mutation.
  5615. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  5616. switch {
  5617. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5618. id, exists := m.ID()
  5619. if exists {
  5620. return []uint64{id}, nil
  5621. }
  5622. fallthrough
  5623. case m.op.Is(OpUpdate | OpDelete):
  5624. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  5625. default:
  5626. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5627. }
  5628. }
  5629. // SetCreatedAt sets the "created_at" field.
  5630. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  5631. m.created_at = &t
  5632. }
  5633. // CreatedAt returns the value of the "created_at" field in the mutation.
  5634. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  5635. v := m.created_at
  5636. if v == nil {
  5637. return
  5638. }
  5639. return *v, true
  5640. }
  5641. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  5642. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  5643. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5644. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5645. if !m.op.Is(OpUpdateOne) {
  5646. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5647. }
  5648. if m.id == nil || m.oldValue == nil {
  5649. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5650. }
  5651. oldValue, err := m.oldValue(ctx)
  5652. if err != nil {
  5653. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5654. }
  5655. return oldValue.CreatedAt, nil
  5656. }
  5657. // ResetCreatedAt resets all changes to the "created_at" field.
  5658. func (m *LabelMutation) ResetCreatedAt() {
  5659. m.created_at = nil
  5660. }
  5661. // SetUpdatedAt sets the "updated_at" field.
  5662. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  5663. m.updated_at = &t
  5664. }
  5665. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5666. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  5667. v := m.updated_at
  5668. if v == nil {
  5669. return
  5670. }
  5671. return *v, true
  5672. }
  5673. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  5674. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  5675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5676. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5677. if !m.op.Is(OpUpdateOne) {
  5678. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5679. }
  5680. if m.id == nil || m.oldValue == nil {
  5681. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5682. }
  5683. oldValue, err := m.oldValue(ctx)
  5684. if err != nil {
  5685. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5686. }
  5687. return oldValue.UpdatedAt, nil
  5688. }
  5689. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5690. func (m *LabelMutation) ResetUpdatedAt() {
  5691. m.updated_at = nil
  5692. }
  5693. // SetStatus sets the "status" field.
  5694. func (m *LabelMutation) SetStatus(u uint8) {
  5695. m.status = &u
  5696. m.addstatus = nil
  5697. }
  5698. // Status returns the value of the "status" field in the mutation.
  5699. func (m *LabelMutation) Status() (r uint8, exists bool) {
  5700. v := m.status
  5701. if v == nil {
  5702. return
  5703. }
  5704. return *v, true
  5705. }
  5706. // OldStatus returns the old "status" field's value of the Label entity.
  5707. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  5708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5709. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5710. if !m.op.Is(OpUpdateOne) {
  5711. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5712. }
  5713. if m.id == nil || m.oldValue == nil {
  5714. return v, errors.New("OldStatus requires an ID field in the mutation")
  5715. }
  5716. oldValue, err := m.oldValue(ctx)
  5717. if err != nil {
  5718. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5719. }
  5720. return oldValue.Status, nil
  5721. }
  5722. // AddStatus adds u to the "status" field.
  5723. func (m *LabelMutation) AddStatus(u int8) {
  5724. if m.addstatus != nil {
  5725. *m.addstatus += u
  5726. } else {
  5727. m.addstatus = &u
  5728. }
  5729. }
  5730. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5731. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  5732. v := m.addstatus
  5733. if v == nil {
  5734. return
  5735. }
  5736. return *v, true
  5737. }
  5738. // ClearStatus clears the value of the "status" field.
  5739. func (m *LabelMutation) ClearStatus() {
  5740. m.status = nil
  5741. m.addstatus = nil
  5742. m.clearedFields[label.FieldStatus] = struct{}{}
  5743. }
  5744. // StatusCleared returns if the "status" field was cleared in this mutation.
  5745. func (m *LabelMutation) StatusCleared() bool {
  5746. _, ok := m.clearedFields[label.FieldStatus]
  5747. return ok
  5748. }
  5749. // ResetStatus resets all changes to the "status" field.
  5750. func (m *LabelMutation) ResetStatus() {
  5751. m.status = nil
  5752. m.addstatus = nil
  5753. delete(m.clearedFields, label.FieldStatus)
  5754. }
  5755. // SetType sets the "type" field.
  5756. func (m *LabelMutation) SetType(i int) {
  5757. m._type = &i
  5758. m.add_type = nil
  5759. }
  5760. // GetType returns the value of the "type" field in the mutation.
  5761. func (m *LabelMutation) GetType() (r int, exists bool) {
  5762. v := m._type
  5763. if v == nil {
  5764. return
  5765. }
  5766. return *v, true
  5767. }
  5768. // OldType returns the old "type" field's value of the Label entity.
  5769. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  5770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5771. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  5772. if !m.op.Is(OpUpdateOne) {
  5773. return v, errors.New("OldType is only allowed on UpdateOne operations")
  5774. }
  5775. if m.id == nil || m.oldValue == nil {
  5776. return v, errors.New("OldType requires an ID field in the mutation")
  5777. }
  5778. oldValue, err := m.oldValue(ctx)
  5779. if err != nil {
  5780. return v, fmt.Errorf("querying old value for OldType: %w", err)
  5781. }
  5782. return oldValue.Type, nil
  5783. }
  5784. // AddType adds i to the "type" field.
  5785. func (m *LabelMutation) AddType(i int) {
  5786. if m.add_type != nil {
  5787. *m.add_type += i
  5788. } else {
  5789. m.add_type = &i
  5790. }
  5791. }
  5792. // AddedType returns the value that was added to the "type" field in this mutation.
  5793. func (m *LabelMutation) AddedType() (r int, exists bool) {
  5794. v := m.add_type
  5795. if v == nil {
  5796. return
  5797. }
  5798. return *v, true
  5799. }
  5800. // ResetType resets all changes to the "type" field.
  5801. func (m *LabelMutation) ResetType() {
  5802. m._type = nil
  5803. m.add_type = nil
  5804. }
  5805. // SetName sets the "name" field.
  5806. func (m *LabelMutation) SetName(s string) {
  5807. m.name = &s
  5808. }
  5809. // Name returns the value of the "name" field in the mutation.
  5810. func (m *LabelMutation) Name() (r string, exists bool) {
  5811. v := m.name
  5812. if v == nil {
  5813. return
  5814. }
  5815. return *v, true
  5816. }
  5817. // OldName returns the old "name" field's value of the Label entity.
  5818. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  5819. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5820. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  5821. if !m.op.Is(OpUpdateOne) {
  5822. return v, errors.New("OldName is only allowed on UpdateOne operations")
  5823. }
  5824. if m.id == nil || m.oldValue == nil {
  5825. return v, errors.New("OldName requires an ID field in the mutation")
  5826. }
  5827. oldValue, err := m.oldValue(ctx)
  5828. if err != nil {
  5829. return v, fmt.Errorf("querying old value for OldName: %w", err)
  5830. }
  5831. return oldValue.Name, nil
  5832. }
  5833. // ResetName resets all changes to the "name" field.
  5834. func (m *LabelMutation) ResetName() {
  5835. m.name = nil
  5836. }
  5837. // SetFrom sets the "from" field.
  5838. func (m *LabelMutation) SetFrom(i int) {
  5839. m.from = &i
  5840. m.addfrom = nil
  5841. }
  5842. // From returns the value of the "from" field in the mutation.
  5843. func (m *LabelMutation) From() (r int, exists bool) {
  5844. v := m.from
  5845. if v == nil {
  5846. return
  5847. }
  5848. return *v, true
  5849. }
  5850. // OldFrom returns the old "from" field's value of the Label entity.
  5851. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  5852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5853. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  5854. if !m.op.Is(OpUpdateOne) {
  5855. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  5856. }
  5857. if m.id == nil || m.oldValue == nil {
  5858. return v, errors.New("OldFrom requires an ID field in the mutation")
  5859. }
  5860. oldValue, err := m.oldValue(ctx)
  5861. if err != nil {
  5862. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  5863. }
  5864. return oldValue.From, nil
  5865. }
  5866. // AddFrom adds i to the "from" field.
  5867. func (m *LabelMutation) AddFrom(i int) {
  5868. if m.addfrom != nil {
  5869. *m.addfrom += i
  5870. } else {
  5871. m.addfrom = &i
  5872. }
  5873. }
  5874. // AddedFrom returns the value that was added to the "from" field in this mutation.
  5875. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  5876. v := m.addfrom
  5877. if v == nil {
  5878. return
  5879. }
  5880. return *v, true
  5881. }
  5882. // ResetFrom resets all changes to the "from" field.
  5883. func (m *LabelMutation) ResetFrom() {
  5884. m.from = nil
  5885. m.addfrom = nil
  5886. }
  5887. // SetMode sets the "mode" field.
  5888. func (m *LabelMutation) SetMode(i int) {
  5889. m.mode = &i
  5890. m.addmode = nil
  5891. }
  5892. // Mode returns the value of the "mode" field in the mutation.
  5893. func (m *LabelMutation) Mode() (r int, exists bool) {
  5894. v := m.mode
  5895. if v == nil {
  5896. return
  5897. }
  5898. return *v, true
  5899. }
  5900. // OldMode returns the old "mode" field's value of the Label entity.
  5901. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  5902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5903. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  5904. if !m.op.Is(OpUpdateOne) {
  5905. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  5906. }
  5907. if m.id == nil || m.oldValue == nil {
  5908. return v, errors.New("OldMode requires an ID field in the mutation")
  5909. }
  5910. oldValue, err := m.oldValue(ctx)
  5911. if err != nil {
  5912. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  5913. }
  5914. return oldValue.Mode, nil
  5915. }
  5916. // AddMode adds i to the "mode" field.
  5917. func (m *LabelMutation) AddMode(i int) {
  5918. if m.addmode != nil {
  5919. *m.addmode += i
  5920. } else {
  5921. m.addmode = &i
  5922. }
  5923. }
  5924. // AddedMode returns the value that was added to the "mode" field in this mutation.
  5925. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  5926. v := m.addmode
  5927. if v == nil {
  5928. return
  5929. }
  5930. return *v, true
  5931. }
  5932. // ResetMode resets all changes to the "mode" field.
  5933. func (m *LabelMutation) ResetMode() {
  5934. m.mode = nil
  5935. m.addmode = nil
  5936. }
  5937. // SetConditions sets the "conditions" field.
  5938. func (m *LabelMutation) SetConditions(s string) {
  5939. m.conditions = &s
  5940. }
  5941. // Conditions returns the value of the "conditions" field in the mutation.
  5942. func (m *LabelMutation) Conditions() (r string, exists bool) {
  5943. v := m.conditions
  5944. if v == nil {
  5945. return
  5946. }
  5947. return *v, true
  5948. }
  5949. // OldConditions returns the old "conditions" field's value of the Label entity.
  5950. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  5951. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5952. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  5953. if !m.op.Is(OpUpdateOne) {
  5954. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  5955. }
  5956. if m.id == nil || m.oldValue == nil {
  5957. return v, errors.New("OldConditions requires an ID field in the mutation")
  5958. }
  5959. oldValue, err := m.oldValue(ctx)
  5960. if err != nil {
  5961. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  5962. }
  5963. return oldValue.Conditions, nil
  5964. }
  5965. // ClearConditions clears the value of the "conditions" field.
  5966. func (m *LabelMutation) ClearConditions() {
  5967. m.conditions = nil
  5968. m.clearedFields[label.FieldConditions] = struct{}{}
  5969. }
  5970. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  5971. func (m *LabelMutation) ConditionsCleared() bool {
  5972. _, ok := m.clearedFields[label.FieldConditions]
  5973. return ok
  5974. }
  5975. // ResetConditions resets all changes to the "conditions" field.
  5976. func (m *LabelMutation) ResetConditions() {
  5977. m.conditions = nil
  5978. delete(m.clearedFields, label.FieldConditions)
  5979. }
  5980. // SetOrganizationID sets the "organization_id" field.
  5981. func (m *LabelMutation) SetOrganizationID(u uint64) {
  5982. m.organization_id = &u
  5983. m.addorganization_id = nil
  5984. }
  5985. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5986. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  5987. v := m.organization_id
  5988. if v == nil {
  5989. return
  5990. }
  5991. return *v, true
  5992. }
  5993. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  5994. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  5995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5996. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5997. if !m.op.Is(OpUpdateOne) {
  5998. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5999. }
  6000. if m.id == nil || m.oldValue == nil {
  6001. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6002. }
  6003. oldValue, err := m.oldValue(ctx)
  6004. if err != nil {
  6005. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6006. }
  6007. return oldValue.OrganizationID, nil
  6008. }
  6009. // AddOrganizationID adds u to the "organization_id" field.
  6010. func (m *LabelMutation) AddOrganizationID(u int64) {
  6011. if m.addorganization_id != nil {
  6012. *m.addorganization_id += u
  6013. } else {
  6014. m.addorganization_id = &u
  6015. }
  6016. }
  6017. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6018. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  6019. v := m.addorganization_id
  6020. if v == nil {
  6021. return
  6022. }
  6023. return *v, true
  6024. }
  6025. // ClearOrganizationID clears the value of the "organization_id" field.
  6026. func (m *LabelMutation) ClearOrganizationID() {
  6027. m.organization_id = nil
  6028. m.addorganization_id = nil
  6029. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  6030. }
  6031. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  6032. func (m *LabelMutation) OrganizationIDCleared() bool {
  6033. _, ok := m.clearedFields[label.FieldOrganizationID]
  6034. return ok
  6035. }
  6036. // ResetOrganizationID resets all changes to the "organization_id" field.
  6037. func (m *LabelMutation) ResetOrganizationID() {
  6038. m.organization_id = nil
  6039. m.addorganization_id = nil
  6040. delete(m.clearedFields, label.FieldOrganizationID)
  6041. }
  6042. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  6043. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  6044. if m.label_relationships == nil {
  6045. m.label_relationships = make(map[uint64]struct{})
  6046. }
  6047. for i := range ids {
  6048. m.label_relationships[ids[i]] = struct{}{}
  6049. }
  6050. }
  6051. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  6052. func (m *LabelMutation) ClearLabelRelationships() {
  6053. m.clearedlabel_relationships = true
  6054. }
  6055. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  6056. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  6057. return m.clearedlabel_relationships
  6058. }
  6059. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  6060. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  6061. if m.removedlabel_relationships == nil {
  6062. m.removedlabel_relationships = make(map[uint64]struct{})
  6063. }
  6064. for i := range ids {
  6065. delete(m.label_relationships, ids[i])
  6066. m.removedlabel_relationships[ids[i]] = struct{}{}
  6067. }
  6068. }
  6069. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  6070. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  6071. for id := range m.removedlabel_relationships {
  6072. ids = append(ids, id)
  6073. }
  6074. return
  6075. }
  6076. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  6077. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  6078. for id := range m.label_relationships {
  6079. ids = append(ids, id)
  6080. }
  6081. return
  6082. }
  6083. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  6084. func (m *LabelMutation) ResetLabelRelationships() {
  6085. m.label_relationships = nil
  6086. m.clearedlabel_relationships = false
  6087. m.removedlabel_relationships = nil
  6088. }
  6089. // Where appends a list predicates to the LabelMutation builder.
  6090. func (m *LabelMutation) Where(ps ...predicate.Label) {
  6091. m.predicates = append(m.predicates, ps...)
  6092. }
  6093. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  6094. // users can use type-assertion to append predicates that do not depend on any generated package.
  6095. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  6096. p := make([]predicate.Label, len(ps))
  6097. for i := range ps {
  6098. p[i] = ps[i]
  6099. }
  6100. m.Where(p...)
  6101. }
  6102. // Op returns the operation name.
  6103. func (m *LabelMutation) Op() Op {
  6104. return m.op
  6105. }
  6106. // SetOp allows setting the mutation operation.
  6107. func (m *LabelMutation) SetOp(op Op) {
  6108. m.op = op
  6109. }
  6110. // Type returns the node type of this mutation (Label).
  6111. func (m *LabelMutation) Type() string {
  6112. return m.typ
  6113. }
  6114. // Fields returns all fields that were changed during this mutation. Note that in
  6115. // order to get all numeric fields that were incremented/decremented, call
  6116. // AddedFields().
  6117. func (m *LabelMutation) Fields() []string {
  6118. fields := make([]string, 0, 9)
  6119. if m.created_at != nil {
  6120. fields = append(fields, label.FieldCreatedAt)
  6121. }
  6122. if m.updated_at != nil {
  6123. fields = append(fields, label.FieldUpdatedAt)
  6124. }
  6125. if m.status != nil {
  6126. fields = append(fields, label.FieldStatus)
  6127. }
  6128. if m._type != nil {
  6129. fields = append(fields, label.FieldType)
  6130. }
  6131. if m.name != nil {
  6132. fields = append(fields, label.FieldName)
  6133. }
  6134. if m.from != nil {
  6135. fields = append(fields, label.FieldFrom)
  6136. }
  6137. if m.mode != nil {
  6138. fields = append(fields, label.FieldMode)
  6139. }
  6140. if m.conditions != nil {
  6141. fields = append(fields, label.FieldConditions)
  6142. }
  6143. if m.organization_id != nil {
  6144. fields = append(fields, label.FieldOrganizationID)
  6145. }
  6146. return fields
  6147. }
  6148. // Field returns the value of a field with the given name. The second boolean
  6149. // return value indicates that this field was not set, or was not defined in the
  6150. // schema.
  6151. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  6152. switch name {
  6153. case label.FieldCreatedAt:
  6154. return m.CreatedAt()
  6155. case label.FieldUpdatedAt:
  6156. return m.UpdatedAt()
  6157. case label.FieldStatus:
  6158. return m.Status()
  6159. case label.FieldType:
  6160. return m.GetType()
  6161. case label.FieldName:
  6162. return m.Name()
  6163. case label.FieldFrom:
  6164. return m.From()
  6165. case label.FieldMode:
  6166. return m.Mode()
  6167. case label.FieldConditions:
  6168. return m.Conditions()
  6169. case label.FieldOrganizationID:
  6170. return m.OrganizationID()
  6171. }
  6172. return nil, false
  6173. }
  6174. // OldField returns the old value of the field from the database. An error is
  6175. // returned if the mutation operation is not UpdateOne, or the query to the
  6176. // database failed.
  6177. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6178. switch name {
  6179. case label.FieldCreatedAt:
  6180. return m.OldCreatedAt(ctx)
  6181. case label.FieldUpdatedAt:
  6182. return m.OldUpdatedAt(ctx)
  6183. case label.FieldStatus:
  6184. return m.OldStatus(ctx)
  6185. case label.FieldType:
  6186. return m.OldType(ctx)
  6187. case label.FieldName:
  6188. return m.OldName(ctx)
  6189. case label.FieldFrom:
  6190. return m.OldFrom(ctx)
  6191. case label.FieldMode:
  6192. return m.OldMode(ctx)
  6193. case label.FieldConditions:
  6194. return m.OldConditions(ctx)
  6195. case label.FieldOrganizationID:
  6196. return m.OldOrganizationID(ctx)
  6197. }
  6198. return nil, fmt.Errorf("unknown Label field %s", name)
  6199. }
  6200. // SetField sets the value of a field with the given name. It returns an error if
  6201. // the field is not defined in the schema, or if the type mismatched the field
  6202. // type.
  6203. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  6204. switch name {
  6205. case label.FieldCreatedAt:
  6206. v, ok := value.(time.Time)
  6207. if !ok {
  6208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6209. }
  6210. m.SetCreatedAt(v)
  6211. return nil
  6212. case label.FieldUpdatedAt:
  6213. v, ok := value.(time.Time)
  6214. if !ok {
  6215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6216. }
  6217. m.SetUpdatedAt(v)
  6218. return nil
  6219. case label.FieldStatus:
  6220. v, ok := value.(uint8)
  6221. if !ok {
  6222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6223. }
  6224. m.SetStatus(v)
  6225. return nil
  6226. case label.FieldType:
  6227. v, ok := value.(int)
  6228. if !ok {
  6229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6230. }
  6231. m.SetType(v)
  6232. return nil
  6233. case label.FieldName:
  6234. v, ok := value.(string)
  6235. if !ok {
  6236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6237. }
  6238. m.SetName(v)
  6239. return nil
  6240. case label.FieldFrom:
  6241. v, ok := value.(int)
  6242. if !ok {
  6243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6244. }
  6245. m.SetFrom(v)
  6246. return nil
  6247. case label.FieldMode:
  6248. v, ok := value.(int)
  6249. if !ok {
  6250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6251. }
  6252. m.SetMode(v)
  6253. return nil
  6254. case label.FieldConditions:
  6255. v, ok := value.(string)
  6256. if !ok {
  6257. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6258. }
  6259. m.SetConditions(v)
  6260. return nil
  6261. case label.FieldOrganizationID:
  6262. v, ok := value.(uint64)
  6263. if !ok {
  6264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6265. }
  6266. m.SetOrganizationID(v)
  6267. return nil
  6268. }
  6269. return fmt.Errorf("unknown Label field %s", name)
  6270. }
  6271. // AddedFields returns all numeric fields that were incremented/decremented during
  6272. // this mutation.
  6273. func (m *LabelMutation) AddedFields() []string {
  6274. var fields []string
  6275. if m.addstatus != nil {
  6276. fields = append(fields, label.FieldStatus)
  6277. }
  6278. if m.add_type != nil {
  6279. fields = append(fields, label.FieldType)
  6280. }
  6281. if m.addfrom != nil {
  6282. fields = append(fields, label.FieldFrom)
  6283. }
  6284. if m.addmode != nil {
  6285. fields = append(fields, label.FieldMode)
  6286. }
  6287. if m.addorganization_id != nil {
  6288. fields = append(fields, label.FieldOrganizationID)
  6289. }
  6290. return fields
  6291. }
  6292. // AddedField returns the numeric value that was incremented/decremented on a field
  6293. // with the given name. The second boolean return value indicates that this field
  6294. // was not set, or was not defined in the schema.
  6295. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  6296. switch name {
  6297. case label.FieldStatus:
  6298. return m.AddedStatus()
  6299. case label.FieldType:
  6300. return m.AddedType()
  6301. case label.FieldFrom:
  6302. return m.AddedFrom()
  6303. case label.FieldMode:
  6304. return m.AddedMode()
  6305. case label.FieldOrganizationID:
  6306. return m.AddedOrganizationID()
  6307. }
  6308. return nil, false
  6309. }
  6310. // AddField adds the value to the field with the given name. It returns an error if
  6311. // the field is not defined in the schema, or if the type mismatched the field
  6312. // type.
  6313. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  6314. switch name {
  6315. case label.FieldStatus:
  6316. v, ok := value.(int8)
  6317. if !ok {
  6318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6319. }
  6320. m.AddStatus(v)
  6321. return nil
  6322. case label.FieldType:
  6323. v, ok := value.(int)
  6324. if !ok {
  6325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6326. }
  6327. m.AddType(v)
  6328. return nil
  6329. case label.FieldFrom:
  6330. v, ok := value.(int)
  6331. if !ok {
  6332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6333. }
  6334. m.AddFrom(v)
  6335. return nil
  6336. case label.FieldMode:
  6337. v, ok := value.(int)
  6338. if !ok {
  6339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6340. }
  6341. m.AddMode(v)
  6342. return nil
  6343. case label.FieldOrganizationID:
  6344. v, ok := value.(int64)
  6345. if !ok {
  6346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6347. }
  6348. m.AddOrganizationID(v)
  6349. return nil
  6350. }
  6351. return fmt.Errorf("unknown Label numeric field %s", name)
  6352. }
  6353. // ClearedFields returns all nullable fields that were cleared during this
  6354. // mutation.
  6355. func (m *LabelMutation) ClearedFields() []string {
  6356. var fields []string
  6357. if m.FieldCleared(label.FieldStatus) {
  6358. fields = append(fields, label.FieldStatus)
  6359. }
  6360. if m.FieldCleared(label.FieldConditions) {
  6361. fields = append(fields, label.FieldConditions)
  6362. }
  6363. if m.FieldCleared(label.FieldOrganizationID) {
  6364. fields = append(fields, label.FieldOrganizationID)
  6365. }
  6366. return fields
  6367. }
  6368. // FieldCleared returns a boolean indicating if a field with the given name was
  6369. // cleared in this mutation.
  6370. func (m *LabelMutation) FieldCleared(name string) bool {
  6371. _, ok := m.clearedFields[name]
  6372. return ok
  6373. }
  6374. // ClearField clears the value of the field with the given name. It returns an
  6375. // error if the field is not defined in the schema.
  6376. func (m *LabelMutation) ClearField(name string) error {
  6377. switch name {
  6378. case label.FieldStatus:
  6379. m.ClearStatus()
  6380. return nil
  6381. case label.FieldConditions:
  6382. m.ClearConditions()
  6383. return nil
  6384. case label.FieldOrganizationID:
  6385. m.ClearOrganizationID()
  6386. return nil
  6387. }
  6388. return fmt.Errorf("unknown Label nullable field %s", name)
  6389. }
  6390. // ResetField resets all changes in the mutation for the field with the given name.
  6391. // It returns an error if the field is not defined in the schema.
  6392. func (m *LabelMutation) ResetField(name string) error {
  6393. switch name {
  6394. case label.FieldCreatedAt:
  6395. m.ResetCreatedAt()
  6396. return nil
  6397. case label.FieldUpdatedAt:
  6398. m.ResetUpdatedAt()
  6399. return nil
  6400. case label.FieldStatus:
  6401. m.ResetStatus()
  6402. return nil
  6403. case label.FieldType:
  6404. m.ResetType()
  6405. return nil
  6406. case label.FieldName:
  6407. m.ResetName()
  6408. return nil
  6409. case label.FieldFrom:
  6410. m.ResetFrom()
  6411. return nil
  6412. case label.FieldMode:
  6413. m.ResetMode()
  6414. return nil
  6415. case label.FieldConditions:
  6416. m.ResetConditions()
  6417. return nil
  6418. case label.FieldOrganizationID:
  6419. m.ResetOrganizationID()
  6420. return nil
  6421. }
  6422. return fmt.Errorf("unknown Label field %s", name)
  6423. }
  6424. // AddedEdges returns all edge names that were set/added in this mutation.
  6425. func (m *LabelMutation) AddedEdges() []string {
  6426. edges := make([]string, 0, 1)
  6427. if m.label_relationships != nil {
  6428. edges = append(edges, label.EdgeLabelRelationships)
  6429. }
  6430. return edges
  6431. }
  6432. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6433. // name in this mutation.
  6434. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  6435. switch name {
  6436. case label.EdgeLabelRelationships:
  6437. ids := make([]ent.Value, 0, len(m.label_relationships))
  6438. for id := range m.label_relationships {
  6439. ids = append(ids, id)
  6440. }
  6441. return ids
  6442. }
  6443. return nil
  6444. }
  6445. // RemovedEdges returns all edge names that were removed in this mutation.
  6446. func (m *LabelMutation) RemovedEdges() []string {
  6447. edges := make([]string, 0, 1)
  6448. if m.removedlabel_relationships != nil {
  6449. edges = append(edges, label.EdgeLabelRelationships)
  6450. }
  6451. return edges
  6452. }
  6453. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6454. // the given name in this mutation.
  6455. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  6456. switch name {
  6457. case label.EdgeLabelRelationships:
  6458. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  6459. for id := range m.removedlabel_relationships {
  6460. ids = append(ids, id)
  6461. }
  6462. return ids
  6463. }
  6464. return nil
  6465. }
  6466. // ClearedEdges returns all edge names that were cleared in this mutation.
  6467. func (m *LabelMutation) ClearedEdges() []string {
  6468. edges := make([]string, 0, 1)
  6469. if m.clearedlabel_relationships {
  6470. edges = append(edges, label.EdgeLabelRelationships)
  6471. }
  6472. return edges
  6473. }
  6474. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6475. // was cleared in this mutation.
  6476. func (m *LabelMutation) EdgeCleared(name string) bool {
  6477. switch name {
  6478. case label.EdgeLabelRelationships:
  6479. return m.clearedlabel_relationships
  6480. }
  6481. return false
  6482. }
  6483. // ClearEdge clears the value of the edge with the given name. It returns an error
  6484. // if that edge is not defined in the schema.
  6485. func (m *LabelMutation) ClearEdge(name string) error {
  6486. switch name {
  6487. }
  6488. return fmt.Errorf("unknown Label unique edge %s", name)
  6489. }
  6490. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6491. // It returns an error if the edge is not defined in the schema.
  6492. func (m *LabelMutation) ResetEdge(name string) error {
  6493. switch name {
  6494. case label.EdgeLabelRelationships:
  6495. m.ResetLabelRelationships()
  6496. return nil
  6497. }
  6498. return fmt.Errorf("unknown Label edge %s", name)
  6499. }
  6500. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  6501. type LabelRelationshipMutation struct {
  6502. config
  6503. op Op
  6504. typ string
  6505. id *uint64
  6506. created_at *time.Time
  6507. updated_at *time.Time
  6508. status *uint8
  6509. addstatus *int8
  6510. deleted_at *time.Time
  6511. organization_id *uint64
  6512. addorganization_id *int64
  6513. clearedFields map[string]struct{}
  6514. contacts *uint64
  6515. clearedcontacts bool
  6516. labels *uint64
  6517. clearedlabels bool
  6518. done bool
  6519. oldValue func(context.Context) (*LabelRelationship, error)
  6520. predicates []predicate.LabelRelationship
  6521. }
  6522. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  6523. // labelrelationshipOption allows management of the mutation configuration using functional options.
  6524. type labelrelationshipOption func(*LabelRelationshipMutation)
  6525. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  6526. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  6527. m := &LabelRelationshipMutation{
  6528. config: c,
  6529. op: op,
  6530. typ: TypeLabelRelationship,
  6531. clearedFields: make(map[string]struct{}),
  6532. }
  6533. for _, opt := range opts {
  6534. opt(m)
  6535. }
  6536. return m
  6537. }
  6538. // withLabelRelationshipID sets the ID field of the mutation.
  6539. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  6540. return func(m *LabelRelationshipMutation) {
  6541. var (
  6542. err error
  6543. once sync.Once
  6544. value *LabelRelationship
  6545. )
  6546. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  6547. once.Do(func() {
  6548. if m.done {
  6549. err = errors.New("querying old values post mutation is not allowed")
  6550. } else {
  6551. value, err = m.Client().LabelRelationship.Get(ctx, id)
  6552. }
  6553. })
  6554. return value, err
  6555. }
  6556. m.id = &id
  6557. }
  6558. }
  6559. // withLabelRelationship sets the old LabelRelationship of the mutation.
  6560. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  6561. return func(m *LabelRelationshipMutation) {
  6562. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  6563. return node, nil
  6564. }
  6565. m.id = &node.ID
  6566. }
  6567. }
  6568. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6569. // executed in a transaction (ent.Tx), a transactional client is returned.
  6570. func (m LabelRelationshipMutation) Client() *Client {
  6571. client := &Client{config: m.config}
  6572. client.init()
  6573. return client
  6574. }
  6575. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6576. // it returns an error otherwise.
  6577. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  6578. if _, ok := m.driver.(*txDriver); !ok {
  6579. return nil, errors.New("ent: mutation is not running in a transaction")
  6580. }
  6581. tx := &Tx{config: m.config}
  6582. tx.init()
  6583. return tx, nil
  6584. }
  6585. // SetID sets the value of the id field. Note that this
  6586. // operation is only accepted on creation of LabelRelationship entities.
  6587. func (m *LabelRelationshipMutation) SetID(id uint64) {
  6588. m.id = &id
  6589. }
  6590. // ID returns the ID value in the mutation. Note that the ID is only available
  6591. // if it was provided to the builder or after it was returned from the database.
  6592. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  6593. if m.id == nil {
  6594. return
  6595. }
  6596. return *m.id, true
  6597. }
  6598. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6599. // That means, if the mutation is applied within a transaction with an isolation level such
  6600. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6601. // or updated by the mutation.
  6602. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  6603. switch {
  6604. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6605. id, exists := m.ID()
  6606. if exists {
  6607. return []uint64{id}, nil
  6608. }
  6609. fallthrough
  6610. case m.op.Is(OpUpdate | OpDelete):
  6611. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  6612. default:
  6613. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6614. }
  6615. }
  6616. // SetCreatedAt sets the "created_at" field.
  6617. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  6618. m.created_at = &t
  6619. }
  6620. // CreatedAt returns the value of the "created_at" field in the mutation.
  6621. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  6622. v := m.created_at
  6623. if v == nil {
  6624. return
  6625. }
  6626. return *v, true
  6627. }
  6628. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  6629. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  6630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6631. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6632. if !m.op.Is(OpUpdateOne) {
  6633. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6634. }
  6635. if m.id == nil || m.oldValue == nil {
  6636. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6637. }
  6638. oldValue, err := m.oldValue(ctx)
  6639. if err != nil {
  6640. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6641. }
  6642. return oldValue.CreatedAt, nil
  6643. }
  6644. // ResetCreatedAt resets all changes to the "created_at" field.
  6645. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  6646. m.created_at = nil
  6647. }
  6648. // SetUpdatedAt sets the "updated_at" field.
  6649. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  6650. m.updated_at = &t
  6651. }
  6652. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6653. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  6654. v := m.updated_at
  6655. if v == nil {
  6656. return
  6657. }
  6658. return *v, true
  6659. }
  6660. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  6661. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  6662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6663. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6664. if !m.op.Is(OpUpdateOne) {
  6665. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6666. }
  6667. if m.id == nil || m.oldValue == nil {
  6668. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6669. }
  6670. oldValue, err := m.oldValue(ctx)
  6671. if err != nil {
  6672. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6673. }
  6674. return oldValue.UpdatedAt, nil
  6675. }
  6676. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6677. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  6678. m.updated_at = nil
  6679. }
  6680. // SetStatus sets the "status" field.
  6681. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  6682. m.status = &u
  6683. m.addstatus = nil
  6684. }
  6685. // Status returns the value of the "status" field in the mutation.
  6686. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  6687. v := m.status
  6688. if v == nil {
  6689. return
  6690. }
  6691. return *v, true
  6692. }
  6693. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  6694. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  6695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6696. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  6697. if !m.op.Is(OpUpdateOne) {
  6698. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  6699. }
  6700. if m.id == nil || m.oldValue == nil {
  6701. return v, errors.New("OldStatus requires an ID field in the mutation")
  6702. }
  6703. oldValue, err := m.oldValue(ctx)
  6704. if err != nil {
  6705. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  6706. }
  6707. return oldValue.Status, nil
  6708. }
  6709. // AddStatus adds u to the "status" field.
  6710. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  6711. if m.addstatus != nil {
  6712. *m.addstatus += u
  6713. } else {
  6714. m.addstatus = &u
  6715. }
  6716. }
  6717. // AddedStatus returns the value that was added to the "status" field in this mutation.
  6718. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  6719. v := m.addstatus
  6720. if v == nil {
  6721. return
  6722. }
  6723. return *v, true
  6724. }
  6725. // ClearStatus clears the value of the "status" field.
  6726. func (m *LabelRelationshipMutation) ClearStatus() {
  6727. m.status = nil
  6728. m.addstatus = nil
  6729. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  6730. }
  6731. // StatusCleared returns if the "status" field was cleared in this mutation.
  6732. func (m *LabelRelationshipMutation) StatusCleared() bool {
  6733. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  6734. return ok
  6735. }
  6736. // ResetStatus resets all changes to the "status" field.
  6737. func (m *LabelRelationshipMutation) ResetStatus() {
  6738. m.status = nil
  6739. m.addstatus = nil
  6740. delete(m.clearedFields, labelrelationship.FieldStatus)
  6741. }
  6742. // SetDeletedAt sets the "deleted_at" field.
  6743. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  6744. m.deleted_at = &t
  6745. }
  6746. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6747. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  6748. v := m.deleted_at
  6749. if v == nil {
  6750. return
  6751. }
  6752. return *v, true
  6753. }
  6754. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  6755. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  6756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6757. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6758. if !m.op.Is(OpUpdateOne) {
  6759. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6760. }
  6761. if m.id == nil || m.oldValue == nil {
  6762. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6763. }
  6764. oldValue, err := m.oldValue(ctx)
  6765. if err != nil {
  6766. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6767. }
  6768. return oldValue.DeletedAt, nil
  6769. }
  6770. // ClearDeletedAt clears the value of the "deleted_at" field.
  6771. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  6772. m.deleted_at = nil
  6773. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  6774. }
  6775. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6776. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  6777. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  6778. return ok
  6779. }
  6780. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6781. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  6782. m.deleted_at = nil
  6783. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  6784. }
  6785. // SetLabelID sets the "label_id" field.
  6786. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  6787. m.labels = &u
  6788. }
  6789. // LabelID returns the value of the "label_id" field in the mutation.
  6790. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  6791. v := m.labels
  6792. if v == nil {
  6793. return
  6794. }
  6795. return *v, true
  6796. }
  6797. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  6798. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  6799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6800. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  6801. if !m.op.Is(OpUpdateOne) {
  6802. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  6803. }
  6804. if m.id == nil || m.oldValue == nil {
  6805. return v, errors.New("OldLabelID requires an ID field in the mutation")
  6806. }
  6807. oldValue, err := m.oldValue(ctx)
  6808. if err != nil {
  6809. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  6810. }
  6811. return oldValue.LabelID, nil
  6812. }
  6813. // ResetLabelID resets all changes to the "label_id" field.
  6814. func (m *LabelRelationshipMutation) ResetLabelID() {
  6815. m.labels = nil
  6816. }
  6817. // SetContactID sets the "contact_id" field.
  6818. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  6819. m.contacts = &u
  6820. }
  6821. // ContactID returns the value of the "contact_id" field in the mutation.
  6822. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  6823. v := m.contacts
  6824. if v == nil {
  6825. return
  6826. }
  6827. return *v, true
  6828. }
  6829. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  6830. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  6831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6832. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  6833. if !m.op.Is(OpUpdateOne) {
  6834. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  6835. }
  6836. if m.id == nil || m.oldValue == nil {
  6837. return v, errors.New("OldContactID requires an ID field in the mutation")
  6838. }
  6839. oldValue, err := m.oldValue(ctx)
  6840. if err != nil {
  6841. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  6842. }
  6843. return oldValue.ContactID, nil
  6844. }
  6845. // ResetContactID resets all changes to the "contact_id" field.
  6846. func (m *LabelRelationshipMutation) ResetContactID() {
  6847. m.contacts = nil
  6848. }
  6849. // SetOrganizationID sets the "organization_id" field.
  6850. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  6851. m.organization_id = &u
  6852. m.addorganization_id = nil
  6853. }
  6854. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6855. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  6856. v := m.organization_id
  6857. if v == nil {
  6858. return
  6859. }
  6860. return *v, true
  6861. }
  6862. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  6863. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  6864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6865. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6866. if !m.op.Is(OpUpdateOne) {
  6867. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6868. }
  6869. if m.id == nil || m.oldValue == nil {
  6870. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6871. }
  6872. oldValue, err := m.oldValue(ctx)
  6873. if err != nil {
  6874. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6875. }
  6876. return oldValue.OrganizationID, nil
  6877. }
  6878. // AddOrganizationID adds u to the "organization_id" field.
  6879. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  6880. if m.addorganization_id != nil {
  6881. *m.addorganization_id += u
  6882. } else {
  6883. m.addorganization_id = &u
  6884. }
  6885. }
  6886. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6887. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  6888. v := m.addorganization_id
  6889. if v == nil {
  6890. return
  6891. }
  6892. return *v, true
  6893. }
  6894. // ClearOrganizationID clears the value of the "organization_id" field.
  6895. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  6896. m.organization_id = nil
  6897. m.addorganization_id = nil
  6898. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  6899. }
  6900. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  6901. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  6902. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  6903. return ok
  6904. }
  6905. // ResetOrganizationID resets all changes to the "organization_id" field.
  6906. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  6907. m.organization_id = nil
  6908. m.addorganization_id = nil
  6909. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  6910. }
  6911. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  6912. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  6913. m.contacts = &id
  6914. }
  6915. // ClearContacts clears the "contacts" edge to the Contact entity.
  6916. func (m *LabelRelationshipMutation) ClearContacts() {
  6917. m.clearedcontacts = true
  6918. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  6919. }
  6920. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  6921. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  6922. return m.clearedcontacts
  6923. }
  6924. // ContactsID returns the "contacts" edge ID in the mutation.
  6925. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  6926. if m.contacts != nil {
  6927. return *m.contacts, true
  6928. }
  6929. return
  6930. }
  6931. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  6932. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  6933. // ContactsID instead. It exists only for internal usage by the builders.
  6934. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  6935. if id := m.contacts; id != nil {
  6936. ids = append(ids, *id)
  6937. }
  6938. return
  6939. }
  6940. // ResetContacts resets all changes to the "contacts" edge.
  6941. func (m *LabelRelationshipMutation) ResetContacts() {
  6942. m.contacts = nil
  6943. m.clearedcontacts = false
  6944. }
  6945. // SetLabelsID sets the "labels" edge to the Label entity by id.
  6946. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  6947. m.labels = &id
  6948. }
  6949. // ClearLabels clears the "labels" edge to the Label entity.
  6950. func (m *LabelRelationshipMutation) ClearLabels() {
  6951. m.clearedlabels = true
  6952. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  6953. }
  6954. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  6955. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  6956. return m.clearedlabels
  6957. }
  6958. // LabelsID returns the "labels" edge ID in the mutation.
  6959. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  6960. if m.labels != nil {
  6961. return *m.labels, true
  6962. }
  6963. return
  6964. }
  6965. // LabelsIDs returns the "labels" edge IDs in the mutation.
  6966. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  6967. // LabelsID instead. It exists only for internal usage by the builders.
  6968. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  6969. if id := m.labels; id != nil {
  6970. ids = append(ids, *id)
  6971. }
  6972. return
  6973. }
  6974. // ResetLabels resets all changes to the "labels" edge.
  6975. func (m *LabelRelationshipMutation) ResetLabels() {
  6976. m.labels = nil
  6977. m.clearedlabels = false
  6978. }
  6979. // Where appends a list predicates to the LabelRelationshipMutation builder.
  6980. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  6981. m.predicates = append(m.predicates, ps...)
  6982. }
  6983. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  6984. // users can use type-assertion to append predicates that do not depend on any generated package.
  6985. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  6986. p := make([]predicate.LabelRelationship, len(ps))
  6987. for i := range ps {
  6988. p[i] = ps[i]
  6989. }
  6990. m.Where(p...)
  6991. }
  6992. // Op returns the operation name.
  6993. func (m *LabelRelationshipMutation) Op() Op {
  6994. return m.op
  6995. }
  6996. // SetOp allows setting the mutation operation.
  6997. func (m *LabelRelationshipMutation) SetOp(op Op) {
  6998. m.op = op
  6999. }
  7000. // Type returns the node type of this mutation (LabelRelationship).
  7001. func (m *LabelRelationshipMutation) Type() string {
  7002. return m.typ
  7003. }
  7004. // Fields returns all fields that were changed during this mutation. Note that in
  7005. // order to get all numeric fields that were incremented/decremented, call
  7006. // AddedFields().
  7007. func (m *LabelRelationshipMutation) Fields() []string {
  7008. fields := make([]string, 0, 7)
  7009. if m.created_at != nil {
  7010. fields = append(fields, labelrelationship.FieldCreatedAt)
  7011. }
  7012. if m.updated_at != nil {
  7013. fields = append(fields, labelrelationship.FieldUpdatedAt)
  7014. }
  7015. if m.status != nil {
  7016. fields = append(fields, labelrelationship.FieldStatus)
  7017. }
  7018. if m.deleted_at != nil {
  7019. fields = append(fields, labelrelationship.FieldDeletedAt)
  7020. }
  7021. if m.labels != nil {
  7022. fields = append(fields, labelrelationship.FieldLabelID)
  7023. }
  7024. if m.contacts != nil {
  7025. fields = append(fields, labelrelationship.FieldContactID)
  7026. }
  7027. if m.organization_id != nil {
  7028. fields = append(fields, labelrelationship.FieldOrganizationID)
  7029. }
  7030. return fields
  7031. }
  7032. // Field returns the value of a field with the given name. The second boolean
  7033. // return value indicates that this field was not set, or was not defined in the
  7034. // schema.
  7035. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  7036. switch name {
  7037. case labelrelationship.FieldCreatedAt:
  7038. return m.CreatedAt()
  7039. case labelrelationship.FieldUpdatedAt:
  7040. return m.UpdatedAt()
  7041. case labelrelationship.FieldStatus:
  7042. return m.Status()
  7043. case labelrelationship.FieldDeletedAt:
  7044. return m.DeletedAt()
  7045. case labelrelationship.FieldLabelID:
  7046. return m.LabelID()
  7047. case labelrelationship.FieldContactID:
  7048. return m.ContactID()
  7049. case labelrelationship.FieldOrganizationID:
  7050. return m.OrganizationID()
  7051. }
  7052. return nil, false
  7053. }
  7054. // OldField returns the old value of the field from the database. An error is
  7055. // returned if the mutation operation is not UpdateOne, or the query to the
  7056. // database failed.
  7057. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7058. switch name {
  7059. case labelrelationship.FieldCreatedAt:
  7060. return m.OldCreatedAt(ctx)
  7061. case labelrelationship.FieldUpdatedAt:
  7062. return m.OldUpdatedAt(ctx)
  7063. case labelrelationship.FieldStatus:
  7064. return m.OldStatus(ctx)
  7065. case labelrelationship.FieldDeletedAt:
  7066. return m.OldDeletedAt(ctx)
  7067. case labelrelationship.FieldLabelID:
  7068. return m.OldLabelID(ctx)
  7069. case labelrelationship.FieldContactID:
  7070. return m.OldContactID(ctx)
  7071. case labelrelationship.FieldOrganizationID:
  7072. return m.OldOrganizationID(ctx)
  7073. }
  7074. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  7075. }
  7076. // SetField sets the value of a field with the given name. It returns an error if
  7077. // the field is not defined in the schema, or if the type mismatched the field
  7078. // type.
  7079. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  7080. switch name {
  7081. case labelrelationship.FieldCreatedAt:
  7082. v, ok := value.(time.Time)
  7083. if !ok {
  7084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7085. }
  7086. m.SetCreatedAt(v)
  7087. return nil
  7088. case labelrelationship.FieldUpdatedAt:
  7089. v, ok := value.(time.Time)
  7090. if !ok {
  7091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7092. }
  7093. m.SetUpdatedAt(v)
  7094. return nil
  7095. case labelrelationship.FieldStatus:
  7096. v, ok := value.(uint8)
  7097. if !ok {
  7098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7099. }
  7100. m.SetStatus(v)
  7101. return nil
  7102. case labelrelationship.FieldDeletedAt:
  7103. v, ok := value.(time.Time)
  7104. if !ok {
  7105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7106. }
  7107. m.SetDeletedAt(v)
  7108. return nil
  7109. case labelrelationship.FieldLabelID:
  7110. v, ok := value.(uint64)
  7111. if !ok {
  7112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7113. }
  7114. m.SetLabelID(v)
  7115. return nil
  7116. case labelrelationship.FieldContactID:
  7117. v, ok := value.(uint64)
  7118. if !ok {
  7119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7120. }
  7121. m.SetContactID(v)
  7122. return nil
  7123. case labelrelationship.FieldOrganizationID:
  7124. v, ok := value.(uint64)
  7125. if !ok {
  7126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7127. }
  7128. m.SetOrganizationID(v)
  7129. return nil
  7130. }
  7131. return fmt.Errorf("unknown LabelRelationship field %s", name)
  7132. }
  7133. // AddedFields returns all numeric fields that were incremented/decremented during
  7134. // this mutation.
  7135. func (m *LabelRelationshipMutation) AddedFields() []string {
  7136. var fields []string
  7137. if m.addstatus != nil {
  7138. fields = append(fields, labelrelationship.FieldStatus)
  7139. }
  7140. if m.addorganization_id != nil {
  7141. fields = append(fields, labelrelationship.FieldOrganizationID)
  7142. }
  7143. return fields
  7144. }
  7145. // AddedField returns the numeric value that was incremented/decremented on a field
  7146. // with the given name. The second boolean return value indicates that this field
  7147. // was not set, or was not defined in the schema.
  7148. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  7149. switch name {
  7150. case labelrelationship.FieldStatus:
  7151. return m.AddedStatus()
  7152. case labelrelationship.FieldOrganizationID:
  7153. return m.AddedOrganizationID()
  7154. }
  7155. return nil, false
  7156. }
  7157. // AddField adds the value to the field with the given name. It returns an error if
  7158. // the field is not defined in the schema, or if the type mismatched the field
  7159. // type.
  7160. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  7161. switch name {
  7162. case labelrelationship.FieldStatus:
  7163. v, ok := value.(int8)
  7164. if !ok {
  7165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7166. }
  7167. m.AddStatus(v)
  7168. return nil
  7169. case labelrelationship.FieldOrganizationID:
  7170. v, ok := value.(int64)
  7171. if !ok {
  7172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7173. }
  7174. m.AddOrganizationID(v)
  7175. return nil
  7176. }
  7177. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  7178. }
  7179. // ClearedFields returns all nullable fields that were cleared during this
  7180. // mutation.
  7181. func (m *LabelRelationshipMutation) ClearedFields() []string {
  7182. var fields []string
  7183. if m.FieldCleared(labelrelationship.FieldStatus) {
  7184. fields = append(fields, labelrelationship.FieldStatus)
  7185. }
  7186. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  7187. fields = append(fields, labelrelationship.FieldDeletedAt)
  7188. }
  7189. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  7190. fields = append(fields, labelrelationship.FieldOrganizationID)
  7191. }
  7192. return fields
  7193. }
  7194. // FieldCleared returns a boolean indicating if a field with the given name was
  7195. // cleared in this mutation.
  7196. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  7197. _, ok := m.clearedFields[name]
  7198. return ok
  7199. }
  7200. // ClearField clears the value of the field with the given name. It returns an
  7201. // error if the field is not defined in the schema.
  7202. func (m *LabelRelationshipMutation) ClearField(name string) error {
  7203. switch name {
  7204. case labelrelationship.FieldStatus:
  7205. m.ClearStatus()
  7206. return nil
  7207. case labelrelationship.FieldDeletedAt:
  7208. m.ClearDeletedAt()
  7209. return nil
  7210. case labelrelationship.FieldOrganizationID:
  7211. m.ClearOrganizationID()
  7212. return nil
  7213. }
  7214. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  7215. }
  7216. // ResetField resets all changes in the mutation for the field with the given name.
  7217. // It returns an error if the field is not defined in the schema.
  7218. func (m *LabelRelationshipMutation) ResetField(name string) error {
  7219. switch name {
  7220. case labelrelationship.FieldCreatedAt:
  7221. m.ResetCreatedAt()
  7222. return nil
  7223. case labelrelationship.FieldUpdatedAt:
  7224. m.ResetUpdatedAt()
  7225. return nil
  7226. case labelrelationship.FieldStatus:
  7227. m.ResetStatus()
  7228. return nil
  7229. case labelrelationship.FieldDeletedAt:
  7230. m.ResetDeletedAt()
  7231. return nil
  7232. case labelrelationship.FieldLabelID:
  7233. m.ResetLabelID()
  7234. return nil
  7235. case labelrelationship.FieldContactID:
  7236. m.ResetContactID()
  7237. return nil
  7238. case labelrelationship.FieldOrganizationID:
  7239. m.ResetOrganizationID()
  7240. return nil
  7241. }
  7242. return fmt.Errorf("unknown LabelRelationship field %s", name)
  7243. }
  7244. // AddedEdges returns all edge names that were set/added in this mutation.
  7245. func (m *LabelRelationshipMutation) AddedEdges() []string {
  7246. edges := make([]string, 0, 2)
  7247. if m.contacts != nil {
  7248. edges = append(edges, labelrelationship.EdgeContacts)
  7249. }
  7250. if m.labels != nil {
  7251. edges = append(edges, labelrelationship.EdgeLabels)
  7252. }
  7253. return edges
  7254. }
  7255. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7256. // name in this mutation.
  7257. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  7258. switch name {
  7259. case labelrelationship.EdgeContacts:
  7260. if id := m.contacts; id != nil {
  7261. return []ent.Value{*id}
  7262. }
  7263. case labelrelationship.EdgeLabels:
  7264. if id := m.labels; id != nil {
  7265. return []ent.Value{*id}
  7266. }
  7267. }
  7268. return nil
  7269. }
  7270. // RemovedEdges returns all edge names that were removed in this mutation.
  7271. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  7272. edges := make([]string, 0, 2)
  7273. return edges
  7274. }
  7275. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7276. // the given name in this mutation.
  7277. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  7278. return nil
  7279. }
  7280. // ClearedEdges returns all edge names that were cleared in this mutation.
  7281. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  7282. edges := make([]string, 0, 2)
  7283. if m.clearedcontacts {
  7284. edges = append(edges, labelrelationship.EdgeContacts)
  7285. }
  7286. if m.clearedlabels {
  7287. edges = append(edges, labelrelationship.EdgeLabels)
  7288. }
  7289. return edges
  7290. }
  7291. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7292. // was cleared in this mutation.
  7293. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  7294. switch name {
  7295. case labelrelationship.EdgeContacts:
  7296. return m.clearedcontacts
  7297. case labelrelationship.EdgeLabels:
  7298. return m.clearedlabels
  7299. }
  7300. return false
  7301. }
  7302. // ClearEdge clears the value of the edge with the given name. It returns an error
  7303. // if that edge is not defined in the schema.
  7304. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  7305. switch name {
  7306. case labelrelationship.EdgeContacts:
  7307. m.ClearContacts()
  7308. return nil
  7309. case labelrelationship.EdgeLabels:
  7310. m.ClearLabels()
  7311. return nil
  7312. }
  7313. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  7314. }
  7315. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7316. // It returns an error if the edge is not defined in the schema.
  7317. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  7318. switch name {
  7319. case labelrelationship.EdgeContacts:
  7320. m.ResetContacts()
  7321. return nil
  7322. case labelrelationship.EdgeLabels:
  7323. m.ResetLabels()
  7324. return nil
  7325. }
  7326. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  7327. }
  7328. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  7329. type MessageMutation struct {
  7330. config
  7331. op Op
  7332. typ string
  7333. id *int
  7334. wx_wxid *string
  7335. wxid *string
  7336. content *string
  7337. clearedFields map[string]struct{}
  7338. done bool
  7339. oldValue func(context.Context) (*Message, error)
  7340. predicates []predicate.Message
  7341. }
  7342. var _ ent.Mutation = (*MessageMutation)(nil)
  7343. // messageOption allows management of the mutation configuration using functional options.
  7344. type messageOption func(*MessageMutation)
  7345. // newMessageMutation creates new mutation for the Message entity.
  7346. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  7347. m := &MessageMutation{
  7348. config: c,
  7349. op: op,
  7350. typ: TypeMessage,
  7351. clearedFields: make(map[string]struct{}),
  7352. }
  7353. for _, opt := range opts {
  7354. opt(m)
  7355. }
  7356. return m
  7357. }
  7358. // withMessageID sets the ID field of the mutation.
  7359. func withMessageID(id int) messageOption {
  7360. return func(m *MessageMutation) {
  7361. var (
  7362. err error
  7363. once sync.Once
  7364. value *Message
  7365. )
  7366. m.oldValue = func(ctx context.Context) (*Message, error) {
  7367. once.Do(func() {
  7368. if m.done {
  7369. err = errors.New("querying old values post mutation is not allowed")
  7370. } else {
  7371. value, err = m.Client().Message.Get(ctx, id)
  7372. }
  7373. })
  7374. return value, err
  7375. }
  7376. m.id = &id
  7377. }
  7378. }
  7379. // withMessage sets the old Message of the mutation.
  7380. func withMessage(node *Message) messageOption {
  7381. return func(m *MessageMutation) {
  7382. m.oldValue = func(context.Context) (*Message, error) {
  7383. return node, nil
  7384. }
  7385. m.id = &node.ID
  7386. }
  7387. }
  7388. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7389. // executed in a transaction (ent.Tx), a transactional client is returned.
  7390. func (m MessageMutation) Client() *Client {
  7391. client := &Client{config: m.config}
  7392. client.init()
  7393. return client
  7394. }
  7395. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7396. // it returns an error otherwise.
  7397. func (m MessageMutation) Tx() (*Tx, error) {
  7398. if _, ok := m.driver.(*txDriver); !ok {
  7399. return nil, errors.New("ent: mutation is not running in a transaction")
  7400. }
  7401. tx := &Tx{config: m.config}
  7402. tx.init()
  7403. return tx, nil
  7404. }
  7405. // ID returns the ID value in the mutation. Note that the ID is only available
  7406. // if it was provided to the builder or after it was returned from the database.
  7407. func (m *MessageMutation) ID() (id int, exists bool) {
  7408. if m.id == nil {
  7409. return
  7410. }
  7411. return *m.id, true
  7412. }
  7413. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7414. // That means, if the mutation is applied within a transaction with an isolation level such
  7415. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7416. // or updated by the mutation.
  7417. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  7418. switch {
  7419. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7420. id, exists := m.ID()
  7421. if exists {
  7422. return []int{id}, nil
  7423. }
  7424. fallthrough
  7425. case m.op.Is(OpUpdate | OpDelete):
  7426. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  7427. default:
  7428. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7429. }
  7430. }
  7431. // SetWxWxid sets the "wx_wxid" field.
  7432. func (m *MessageMutation) SetWxWxid(s string) {
  7433. m.wx_wxid = &s
  7434. }
  7435. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7436. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  7437. v := m.wx_wxid
  7438. if v == nil {
  7439. return
  7440. }
  7441. return *v, true
  7442. }
  7443. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  7444. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  7445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7446. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  7447. if !m.op.Is(OpUpdateOne) {
  7448. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  7449. }
  7450. if m.id == nil || m.oldValue == nil {
  7451. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  7452. }
  7453. oldValue, err := m.oldValue(ctx)
  7454. if err != nil {
  7455. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  7456. }
  7457. return oldValue.WxWxid, nil
  7458. }
  7459. // ClearWxWxid clears the value of the "wx_wxid" field.
  7460. func (m *MessageMutation) ClearWxWxid() {
  7461. m.wx_wxid = nil
  7462. m.clearedFields[message.FieldWxWxid] = struct{}{}
  7463. }
  7464. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  7465. func (m *MessageMutation) WxWxidCleared() bool {
  7466. _, ok := m.clearedFields[message.FieldWxWxid]
  7467. return ok
  7468. }
  7469. // ResetWxWxid resets all changes to the "wx_wxid" field.
  7470. func (m *MessageMutation) ResetWxWxid() {
  7471. m.wx_wxid = nil
  7472. delete(m.clearedFields, message.FieldWxWxid)
  7473. }
  7474. // SetWxid sets the "wxid" field.
  7475. func (m *MessageMutation) SetWxid(s string) {
  7476. m.wxid = &s
  7477. }
  7478. // Wxid returns the value of the "wxid" field in the mutation.
  7479. func (m *MessageMutation) Wxid() (r string, exists bool) {
  7480. v := m.wxid
  7481. if v == nil {
  7482. return
  7483. }
  7484. return *v, true
  7485. }
  7486. // OldWxid returns the old "wxid" field's value of the Message entity.
  7487. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  7488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7489. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  7490. if !m.op.Is(OpUpdateOne) {
  7491. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  7492. }
  7493. if m.id == nil || m.oldValue == nil {
  7494. return v, errors.New("OldWxid requires an ID field in the mutation")
  7495. }
  7496. oldValue, err := m.oldValue(ctx)
  7497. if err != nil {
  7498. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  7499. }
  7500. return oldValue.Wxid, nil
  7501. }
  7502. // ResetWxid resets all changes to the "wxid" field.
  7503. func (m *MessageMutation) ResetWxid() {
  7504. m.wxid = nil
  7505. }
  7506. // SetContent sets the "content" field.
  7507. func (m *MessageMutation) SetContent(s string) {
  7508. m.content = &s
  7509. }
  7510. // Content returns the value of the "content" field in the mutation.
  7511. func (m *MessageMutation) Content() (r string, exists bool) {
  7512. v := m.content
  7513. if v == nil {
  7514. return
  7515. }
  7516. return *v, true
  7517. }
  7518. // OldContent returns the old "content" field's value of the Message entity.
  7519. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  7520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7521. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  7522. if !m.op.Is(OpUpdateOne) {
  7523. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  7524. }
  7525. if m.id == nil || m.oldValue == nil {
  7526. return v, errors.New("OldContent requires an ID field in the mutation")
  7527. }
  7528. oldValue, err := m.oldValue(ctx)
  7529. if err != nil {
  7530. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  7531. }
  7532. return oldValue.Content, nil
  7533. }
  7534. // ResetContent resets all changes to the "content" field.
  7535. func (m *MessageMutation) ResetContent() {
  7536. m.content = nil
  7537. }
  7538. // Where appends a list predicates to the MessageMutation builder.
  7539. func (m *MessageMutation) Where(ps ...predicate.Message) {
  7540. m.predicates = append(m.predicates, ps...)
  7541. }
  7542. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  7543. // users can use type-assertion to append predicates that do not depend on any generated package.
  7544. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  7545. p := make([]predicate.Message, len(ps))
  7546. for i := range ps {
  7547. p[i] = ps[i]
  7548. }
  7549. m.Where(p...)
  7550. }
  7551. // Op returns the operation name.
  7552. func (m *MessageMutation) Op() Op {
  7553. return m.op
  7554. }
  7555. // SetOp allows setting the mutation operation.
  7556. func (m *MessageMutation) SetOp(op Op) {
  7557. m.op = op
  7558. }
  7559. // Type returns the node type of this mutation (Message).
  7560. func (m *MessageMutation) Type() string {
  7561. return m.typ
  7562. }
  7563. // Fields returns all fields that were changed during this mutation. Note that in
  7564. // order to get all numeric fields that were incremented/decremented, call
  7565. // AddedFields().
  7566. func (m *MessageMutation) Fields() []string {
  7567. fields := make([]string, 0, 3)
  7568. if m.wx_wxid != nil {
  7569. fields = append(fields, message.FieldWxWxid)
  7570. }
  7571. if m.wxid != nil {
  7572. fields = append(fields, message.FieldWxid)
  7573. }
  7574. if m.content != nil {
  7575. fields = append(fields, message.FieldContent)
  7576. }
  7577. return fields
  7578. }
  7579. // Field returns the value of a field with the given name. The second boolean
  7580. // return value indicates that this field was not set, or was not defined in the
  7581. // schema.
  7582. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  7583. switch name {
  7584. case message.FieldWxWxid:
  7585. return m.WxWxid()
  7586. case message.FieldWxid:
  7587. return m.Wxid()
  7588. case message.FieldContent:
  7589. return m.Content()
  7590. }
  7591. return nil, false
  7592. }
  7593. // OldField returns the old value of the field from the database. An error is
  7594. // returned if the mutation operation is not UpdateOne, or the query to the
  7595. // database failed.
  7596. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7597. switch name {
  7598. case message.FieldWxWxid:
  7599. return m.OldWxWxid(ctx)
  7600. case message.FieldWxid:
  7601. return m.OldWxid(ctx)
  7602. case message.FieldContent:
  7603. return m.OldContent(ctx)
  7604. }
  7605. return nil, fmt.Errorf("unknown Message field %s", name)
  7606. }
  7607. // SetField sets the value of a field with the given name. It returns an error if
  7608. // the field is not defined in the schema, or if the type mismatched the field
  7609. // type.
  7610. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  7611. switch name {
  7612. case message.FieldWxWxid:
  7613. v, ok := value.(string)
  7614. if !ok {
  7615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7616. }
  7617. m.SetWxWxid(v)
  7618. return nil
  7619. case message.FieldWxid:
  7620. v, ok := value.(string)
  7621. if !ok {
  7622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7623. }
  7624. m.SetWxid(v)
  7625. return nil
  7626. case message.FieldContent:
  7627. v, ok := value.(string)
  7628. if !ok {
  7629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7630. }
  7631. m.SetContent(v)
  7632. return nil
  7633. }
  7634. return fmt.Errorf("unknown Message field %s", name)
  7635. }
  7636. // AddedFields returns all numeric fields that were incremented/decremented during
  7637. // this mutation.
  7638. func (m *MessageMutation) AddedFields() []string {
  7639. return nil
  7640. }
  7641. // AddedField returns the numeric value that was incremented/decremented on a field
  7642. // with the given name. The second boolean return value indicates that this field
  7643. // was not set, or was not defined in the schema.
  7644. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  7645. return nil, false
  7646. }
  7647. // AddField adds the value to the field with the given name. It returns an error if
  7648. // the field is not defined in the schema, or if the type mismatched the field
  7649. // type.
  7650. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  7651. switch name {
  7652. }
  7653. return fmt.Errorf("unknown Message numeric field %s", name)
  7654. }
  7655. // ClearedFields returns all nullable fields that were cleared during this
  7656. // mutation.
  7657. func (m *MessageMutation) ClearedFields() []string {
  7658. var fields []string
  7659. if m.FieldCleared(message.FieldWxWxid) {
  7660. fields = append(fields, message.FieldWxWxid)
  7661. }
  7662. return fields
  7663. }
  7664. // FieldCleared returns a boolean indicating if a field with the given name was
  7665. // cleared in this mutation.
  7666. func (m *MessageMutation) FieldCleared(name string) bool {
  7667. _, ok := m.clearedFields[name]
  7668. return ok
  7669. }
  7670. // ClearField clears the value of the field with the given name. It returns an
  7671. // error if the field is not defined in the schema.
  7672. func (m *MessageMutation) ClearField(name string) error {
  7673. switch name {
  7674. case message.FieldWxWxid:
  7675. m.ClearWxWxid()
  7676. return nil
  7677. }
  7678. return fmt.Errorf("unknown Message nullable field %s", name)
  7679. }
  7680. // ResetField resets all changes in the mutation for the field with the given name.
  7681. // It returns an error if the field is not defined in the schema.
  7682. func (m *MessageMutation) ResetField(name string) error {
  7683. switch name {
  7684. case message.FieldWxWxid:
  7685. m.ResetWxWxid()
  7686. return nil
  7687. case message.FieldWxid:
  7688. m.ResetWxid()
  7689. return nil
  7690. case message.FieldContent:
  7691. m.ResetContent()
  7692. return nil
  7693. }
  7694. return fmt.Errorf("unknown Message field %s", name)
  7695. }
  7696. // AddedEdges returns all edge names that were set/added in this mutation.
  7697. func (m *MessageMutation) AddedEdges() []string {
  7698. edges := make([]string, 0, 0)
  7699. return edges
  7700. }
  7701. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7702. // name in this mutation.
  7703. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  7704. return nil
  7705. }
  7706. // RemovedEdges returns all edge names that were removed in this mutation.
  7707. func (m *MessageMutation) RemovedEdges() []string {
  7708. edges := make([]string, 0, 0)
  7709. return edges
  7710. }
  7711. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7712. // the given name in this mutation.
  7713. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  7714. return nil
  7715. }
  7716. // ClearedEdges returns all edge names that were cleared in this mutation.
  7717. func (m *MessageMutation) ClearedEdges() []string {
  7718. edges := make([]string, 0, 0)
  7719. return edges
  7720. }
  7721. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7722. // was cleared in this mutation.
  7723. func (m *MessageMutation) EdgeCleared(name string) bool {
  7724. return false
  7725. }
  7726. // ClearEdge clears the value of the edge with the given name. It returns an error
  7727. // if that edge is not defined in the schema.
  7728. func (m *MessageMutation) ClearEdge(name string) error {
  7729. return fmt.Errorf("unknown Message unique edge %s", name)
  7730. }
  7731. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7732. // It returns an error if the edge is not defined in the schema.
  7733. func (m *MessageMutation) ResetEdge(name string) error {
  7734. return fmt.Errorf("unknown Message edge %s", name)
  7735. }
  7736. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  7737. type MessageRecordsMutation struct {
  7738. config
  7739. op Op
  7740. typ string
  7741. id *uint64
  7742. created_at *time.Time
  7743. updated_at *time.Time
  7744. status *uint8
  7745. addstatus *int8
  7746. deleted_at *time.Time
  7747. bot_wxid *string
  7748. contact_type *int
  7749. addcontact_type *int
  7750. contact_wxid *string
  7751. content_type *int
  7752. addcontent_type *int
  7753. content *string
  7754. meta *custom_types.Meta
  7755. error_detail *string
  7756. send_time *time.Time
  7757. source_type *int
  7758. addsource_type *int
  7759. organization_id *uint64
  7760. addorganization_id *int64
  7761. clearedFields map[string]struct{}
  7762. sop_stage *uint64
  7763. clearedsop_stage bool
  7764. sop_node *uint64
  7765. clearedsop_node bool
  7766. message_contact *uint64
  7767. clearedmessage_contact bool
  7768. done bool
  7769. oldValue func(context.Context) (*MessageRecords, error)
  7770. predicates []predicate.MessageRecords
  7771. }
  7772. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  7773. // messagerecordsOption allows management of the mutation configuration using functional options.
  7774. type messagerecordsOption func(*MessageRecordsMutation)
  7775. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  7776. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  7777. m := &MessageRecordsMutation{
  7778. config: c,
  7779. op: op,
  7780. typ: TypeMessageRecords,
  7781. clearedFields: make(map[string]struct{}),
  7782. }
  7783. for _, opt := range opts {
  7784. opt(m)
  7785. }
  7786. return m
  7787. }
  7788. // withMessageRecordsID sets the ID field of the mutation.
  7789. func withMessageRecordsID(id uint64) messagerecordsOption {
  7790. return func(m *MessageRecordsMutation) {
  7791. var (
  7792. err error
  7793. once sync.Once
  7794. value *MessageRecords
  7795. )
  7796. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  7797. once.Do(func() {
  7798. if m.done {
  7799. err = errors.New("querying old values post mutation is not allowed")
  7800. } else {
  7801. value, err = m.Client().MessageRecords.Get(ctx, id)
  7802. }
  7803. })
  7804. return value, err
  7805. }
  7806. m.id = &id
  7807. }
  7808. }
  7809. // withMessageRecords sets the old MessageRecords of the mutation.
  7810. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  7811. return func(m *MessageRecordsMutation) {
  7812. m.oldValue = func(context.Context) (*MessageRecords, error) {
  7813. return node, nil
  7814. }
  7815. m.id = &node.ID
  7816. }
  7817. }
  7818. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7819. // executed in a transaction (ent.Tx), a transactional client is returned.
  7820. func (m MessageRecordsMutation) Client() *Client {
  7821. client := &Client{config: m.config}
  7822. client.init()
  7823. return client
  7824. }
  7825. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7826. // it returns an error otherwise.
  7827. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  7828. if _, ok := m.driver.(*txDriver); !ok {
  7829. return nil, errors.New("ent: mutation is not running in a transaction")
  7830. }
  7831. tx := &Tx{config: m.config}
  7832. tx.init()
  7833. return tx, nil
  7834. }
  7835. // SetID sets the value of the id field. Note that this
  7836. // operation is only accepted on creation of MessageRecords entities.
  7837. func (m *MessageRecordsMutation) SetID(id uint64) {
  7838. m.id = &id
  7839. }
  7840. // ID returns the ID value in the mutation. Note that the ID is only available
  7841. // if it was provided to the builder or after it was returned from the database.
  7842. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  7843. if m.id == nil {
  7844. return
  7845. }
  7846. return *m.id, true
  7847. }
  7848. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7849. // That means, if the mutation is applied within a transaction with an isolation level such
  7850. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7851. // or updated by the mutation.
  7852. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  7853. switch {
  7854. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7855. id, exists := m.ID()
  7856. if exists {
  7857. return []uint64{id}, nil
  7858. }
  7859. fallthrough
  7860. case m.op.Is(OpUpdate | OpDelete):
  7861. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  7862. default:
  7863. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7864. }
  7865. }
  7866. // SetCreatedAt sets the "created_at" field.
  7867. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  7868. m.created_at = &t
  7869. }
  7870. // CreatedAt returns the value of the "created_at" field in the mutation.
  7871. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  7872. v := m.created_at
  7873. if v == nil {
  7874. return
  7875. }
  7876. return *v, true
  7877. }
  7878. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  7879. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  7880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7881. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7882. if !m.op.Is(OpUpdateOne) {
  7883. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7884. }
  7885. if m.id == nil || m.oldValue == nil {
  7886. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7887. }
  7888. oldValue, err := m.oldValue(ctx)
  7889. if err != nil {
  7890. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7891. }
  7892. return oldValue.CreatedAt, nil
  7893. }
  7894. // ResetCreatedAt resets all changes to the "created_at" field.
  7895. func (m *MessageRecordsMutation) ResetCreatedAt() {
  7896. m.created_at = nil
  7897. }
  7898. // SetUpdatedAt sets the "updated_at" field.
  7899. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  7900. m.updated_at = &t
  7901. }
  7902. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7903. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  7904. v := m.updated_at
  7905. if v == nil {
  7906. return
  7907. }
  7908. return *v, true
  7909. }
  7910. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  7911. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  7912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7913. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7914. if !m.op.Is(OpUpdateOne) {
  7915. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7916. }
  7917. if m.id == nil || m.oldValue == nil {
  7918. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7919. }
  7920. oldValue, err := m.oldValue(ctx)
  7921. if err != nil {
  7922. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7923. }
  7924. return oldValue.UpdatedAt, nil
  7925. }
  7926. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7927. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  7928. m.updated_at = nil
  7929. }
  7930. // SetStatus sets the "status" field.
  7931. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  7932. m.status = &u
  7933. m.addstatus = nil
  7934. }
  7935. // Status returns the value of the "status" field in the mutation.
  7936. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  7937. v := m.status
  7938. if v == nil {
  7939. return
  7940. }
  7941. return *v, true
  7942. }
  7943. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  7944. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  7945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7946. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7947. if !m.op.Is(OpUpdateOne) {
  7948. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7949. }
  7950. if m.id == nil || m.oldValue == nil {
  7951. return v, errors.New("OldStatus requires an ID field in the mutation")
  7952. }
  7953. oldValue, err := m.oldValue(ctx)
  7954. if err != nil {
  7955. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7956. }
  7957. return oldValue.Status, nil
  7958. }
  7959. // AddStatus adds u to the "status" field.
  7960. func (m *MessageRecordsMutation) AddStatus(u int8) {
  7961. if m.addstatus != nil {
  7962. *m.addstatus += u
  7963. } else {
  7964. m.addstatus = &u
  7965. }
  7966. }
  7967. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7968. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  7969. v := m.addstatus
  7970. if v == nil {
  7971. return
  7972. }
  7973. return *v, true
  7974. }
  7975. // ClearStatus clears the value of the "status" field.
  7976. func (m *MessageRecordsMutation) ClearStatus() {
  7977. m.status = nil
  7978. m.addstatus = nil
  7979. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  7980. }
  7981. // StatusCleared returns if the "status" field was cleared in this mutation.
  7982. func (m *MessageRecordsMutation) StatusCleared() bool {
  7983. _, ok := m.clearedFields[messagerecords.FieldStatus]
  7984. return ok
  7985. }
  7986. // ResetStatus resets all changes to the "status" field.
  7987. func (m *MessageRecordsMutation) ResetStatus() {
  7988. m.status = nil
  7989. m.addstatus = nil
  7990. delete(m.clearedFields, messagerecords.FieldStatus)
  7991. }
  7992. // SetDeletedAt sets the "deleted_at" field.
  7993. func (m *MessageRecordsMutation) SetDeletedAt(t time.Time) {
  7994. m.deleted_at = &t
  7995. }
  7996. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7997. func (m *MessageRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  7998. v := m.deleted_at
  7999. if v == nil {
  8000. return
  8001. }
  8002. return *v, true
  8003. }
  8004. // OldDeletedAt returns the old "deleted_at" field's value of the MessageRecords entity.
  8005. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8007. func (m *MessageRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8008. if !m.op.Is(OpUpdateOne) {
  8009. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8010. }
  8011. if m.id == nil || m.oldValue == nil {
  8012. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8013. }
  8014. oldValue, err := m.oldValue(ctx)
  8015. if err != nil {
  8016. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8017. }
  8018. return oldValue.DeletedAt, nil
  8019. }
  8020. // ClearDeletedAt clears the value of the "deleted_at" field.
  8021. func (m *MessageRecordsMutation) ClearDeletedAt() {
  8022. m.deleted_at = nil
  8023. m.clearedFields[messagerecords.FieldDeletedAt] = struct{}{}
  8024. }
  8025. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8026. func (m *MessageRecordsMutation) DeletedAtCleared() bool {
  8027. _, ok := m.clearedFields[messagerecords.FieldDeletedAt]
  8028. return ok
  8029. }
  8030. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8031. func (m *MessageRecordsMutation) ResetDeletedAt() {
  8032. m.deleted_at = nil
  8033. delete(m.clearedFields, messagerecords.FieldDeletedAt)
  8034. }
  8035. // SetBotWxid sets the "bot_wxid" field.
  8036. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  8037. m.bot_wxid = &s
  8038. }
  8039. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  8040. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  8041. v := m.bot_wxid
  8042. if v == nil {
  8043. return
  8044. }
  8045. return *v, true
  8046. }
  8047. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  8048. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8050. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  8051. if !m.op.Is(OpUpdateOne) {
  8052. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  8053. }
  8054. if m.id == nil || m.oldValue == nil {
  8055. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  8056. }
  8057. oldValue, err := m.oldValue(ctx)
  8058. if err != nil {
  8059. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  8060. }
  8061. return oldValue.BotWxid, nil
  8062. }
  8063. // ResetBotWxid resets all changes to the "bot_wxid" field.
  8064. func (m *MessageRecordsMutation) ResetBotWxid() {
  8065. m.bot_wxid = nil
  8066. }
  8067. // SetContactID sets the "contact_id" field.
  8068. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  8069. m.message_contact = &u
  8070. }
  8071. // ContactID returns the value of the "contact_id" field in the mutation.
  8072. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  8073. v := m.message_contact
  8074. if v == nil {
  8075. return
  8076. }
  8077. return *v, true
  8078. }
  8079. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  8080. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8082. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  8083. if !m.op.Is(OpUpdateOne) {
  8084. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  8085. }
  8086. if m.id == nil || m.oldValue == nil {
  8087. return v, errors.New("OldContactID requires an ID field in the mutation")
  8088. }
  8089. oldValue, err := m.oldValue(ctx)
  8090. if err != nil {
  8091. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  8092. }
  8093. return oldValue.ContactID, nil
  8094. }
  8095. // ClearContactID clears the value of the "contact_id" field.
  8096. func (m *MessageRecordsMutation) ClearContactID() {
  8097. m.message_contact = nil
  8098. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  8099. }
  8100. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  8101. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  8102. _, ok := m.clearedFields[messagerecords.FieldContactID]
  8103. return ok
  8104. }
  8105. // ResetContactID resets all changes to the "contact_id" field.
  8106. func (m *MessageRecordsMutation) ResetContactID() {
  8107. m.message_contact = nil
  8108. delete(m.clearedFields, messagerecords.FieldContactID)
  8109. }
  8110. // SetContactType sets the "contact_type" field.
  8111. func (m *MessageRecordsMutation) SetContactType(i int) {
  8112. m.contact_type = &i
  8113. m.addcontact_type = nil
  8114. }
  8115. // ContactType returns the value of the "contact_type" field in the mutation.
  8116. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  8117. v := m.contact_type
  8118. if v == nil {
  8119. return
  8120. }
  8121. return *v, true
  8122. }
  8123. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  8124. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8125. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8126. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  8127. if !m.op.Is(OpUpdateOne) {
  8128. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  8129. }
  8130. if m.id == nil || m.oldValue == nil {
  8131. return v, errors.New("OldContactType requires an ID field in the mutation")
  8132. }
  8133. oldValue, err := m.oldValue(ctx)
  8134. if err != nil {
  8135. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  8136. }
  8137. return oldValue.ContactType, nil
  8138. }
  8139. // AddContactType adds i to the "contact_type" field.
  8140. func (m *MessageRecordsMutation) AddContactType(i int) {
  8141. if m.addcontact_type != nil {
  8142. *m.addcontact_type += i
  8143. } else {
  8144. m.addcontact_type = &i
  8145. }
  8146. }
  8147. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  8148. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  8149. v := m.addcontact_type
  8150. if v == nil {
  8151. return
  8152. }
  8153. return *v, true
  8154. }
  8155. // ResetContactType resets all changes to the "contact_type" field.
  8156. func (m *MessageRecordsMutation) ResetContactType() {
  8157. m.contact_type = nil
  8158. m.addcontact_type = nil
  8159. }
  8160. // SetContactWxid sets the "contact_wxid" field.
  8161. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  8162. m.contact_wxid = &s
  8163. }
  8164. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  8165. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  8166. v := m.contact_wxid
  8167. if v == nil {
  8168. return
  8169. }
  8170. return *v, true
  8171. }
  8172. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  8173. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8175. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  8176. if !m.op.Is(OpUpdateOne) {
  8177. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  8178. }
  8179. if m.id == nil || m.oldValue == nil {
  8180. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  8181. }
  8182. oldValue, err := m.oldValue(ctx)
  8183. if err != nil {
  8184. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  8185. }
  8186. return oldValue.ContactWxid, nil
  8187. }
  8188. // ResetContactWxid resets all changes to the "contact_wxid" field.
  8189. func (m *MessageRecordsMutation) ResetContactWxid() {
  8190. m.contact_wxid = nil
  8191. }
  8192. // SetContentType sets the "content_type" field.
  8193. func (m *MessageRecordsMutation) SetContentType(i int) {
  8194. m.content_type = &i
  8195. m.addcontent_type = nil
  8196. }
  8197. // ContentType returns the value of the "content_type" field in the mutation.
  8198. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  8199. v := m.content_type
  8200. if v == nil {
  8201. return
  8202. }
  8203. return *v, true
  8204. }
  8205. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  8206. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8208. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  8209. if !m.op.Is(OpUpdateOne) {
  8210. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  8211. }
  8212. if m.id == nil || m.oldValue == nil {
  8213. return v, errors.New("OldContentType requires an ID field in the mutation")
  8214. }
  8215. oldValue, err := m.oldValue(ctx)
  8216. if err != nil {
  8217. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  8218. }
  8219. return oldValue.ContentType, nil
  8220. }
  8221. // AddContentType adds i to the "content_type" field.
  8222. func (m *MessageRecordsMutation) AddContentType(i int) {
  8223. if m.addcontent_type != nil {
  8224. *m.addcontent_type += i
  8225. } else {
  8226. m.addcontent_type = &i
  8227. }
  8228. }
  8229. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  8230. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  8231. v := m.addcontent_type
  8232. if v == nil {
  8233. return
  8234. }
  8235. return *v, true
  8236. }
  8237. // ResetContentType resets all changes to the "content_type" field.
  8238. func (m *MessageRecordsMutation) ResetContentType() {
  8239. m.content_type = nil
  8240. m.addcontent_type = nil
  8241. }
  8242. // SetContent sets the "content" field.
  8243. func (m *MessageRecordsMutation) SetContent(s string) {
  8244. m.content = &s
  8245. }
  8246. // Content returns the value of the "content" field in the mutation.
  8247. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  8248. v := m.content
  8249. if v == nil {
  8250. return
  8251. }
  8252. return *v, true
  8253. }
  8254. // OldContent returns the old "content" field's value of the MessageRecords entity.
  8255. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8257. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  8258. if !m.op.Is(OpUpdateOne) {
  8259. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  8260. }
  8261. if m.id == nil || m.oldValue == nil {
  8262. return v, errors.New("OldContent requires an ID field in the mutation")
  8263. }
  8264. oldValue, err := m.oldValue(ctx)
  8265. if err != nil {
  8266. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  8267. }
  8268. return oldValue.Content, nil
  8269. }
  8270. // ResetContent resets all changes to the "content" field.
  8271. func (m *MessageRecordsMutation) ResetContent() {
  8272. m.content = nil
  8273. }
  8274. // SetMeta sets the "meta" field.
  8275. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  8276. m.meta = &ct
  8277. }
  8278. // Meta returns the value of the "meta" field in the mutation.
  8279. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  8280. v := m.meta
  8281. if v == nil {
  8282. return
  8283. }
  8284. return *v, true
  8285. }
  8286. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  8287. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8289. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  8290. if !m.op.Is(OpUpdateOne) {
  8291. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  8292. }
  8293. if m.id == nil || m.oldValue == nil {
  8294. return v, errors.New("OldMeta requires an ID field in the mutation")
  8295. }
  8296. oldValue, err := m.oldValue(ctx)
  8297. if err != nil {
  8298. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  8299. }
  8300. return oldValue.Meta, nil
  8301. }
  8302. // ClearMeta clears the value of the "meta" field.
  8303. func (m *MessageRecordsMutation) ClearMeta() {
  8304. m.meta = nil
  8305. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  8306. }
  8307. // MetaCleared returns if the "meta" field was cleared in this mutation.
  8308. func (m *MessageRecordsMutation) MetaCleared() bool {
  8309. _, ok := m.clearedFields[messagerecords.FieldMeta]
  8310. return ok
  8311. }
  8312. // ResetMeta resets all changes to the "meta" field.
  8313. func (m *MessageRecordsMutation) ResetMeta() {
  8314. m.meta = nil
  8315. delete(m.clearedFields, messagerecords.FieldMeta)
  8316. }
  8317. // SetErrorDetail sets the "error_detail" field.
  8318. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  8319. m.error_detail = &s
  8320. }
  8321. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  8322. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  8323. v := m.error_detail
  8324. if v == nil {
  8325. return
  8326. }
  8327. return *v, true
  8328. }
  8329. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  8330. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8332. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  8333. if !m.op.Is(OpUpdateOne) {
  8334. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  8335. }
  8336. if m.id == nil || m.oldValue == nil {
  8337. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  8338. }
  8339. oldValue, err := m.oldValue(ctx)
  8340. if err != nil {
  8341. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  8342. }
  8343. return oldValue.ErrorDetail, nil
  8344. }
  8345. // ResetErrorDetail resets all changes to the "error_detail" field.
  8346. func (m *MessageRecordsMutation) ResetErrorDetail() {
  8347. m.error_detail = nil
  8348. }
  8349. // SetSendTime sets the "send_time" field.
  8350. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  8351. m.send_time = &t
  8352. }
  8353. // SendTime returns the value of the "send_time" field in the mutation.
  8354. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  8355. v := m.send_time
  8356. if v == nil {
  8357. return
  8358. }
  8359. return *v, true
  8360. }
  8361. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  8362. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8364. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  8365. if !m.op.Is(OpUpdateOne) {
  8366. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  8367. }
  8368. if m.id == nil || m.oldValue == nil {
  8369. return v, errors.New("OldSendTime requires an ID field in the mutation")
  8370. }
  8371. oldValue, err := m.oldValue(ctx)
  8372. if err != nil {
  8373. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  8374. }
  8375. return oldValue.SendTime, nil
  8376. }
  8377. // ClearSendTime clears the value of the "send_time" field.
  8378. func (m *MessageRecordsMutation) ClearSendTime() {
  8379. m.send_time = nil
  8380. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  8381. }
  8382. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  8383. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  8384. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  8385. return ok
  8386. }
  8387. // ResetSendTime resets all changes to the "send_time" field.
  8388. func (m *MessageRecordsMutation) ResetSendTime() {
  8389. m.send_time = nil
  8390. delete(m.clearedFields, messagerecords.FieldSendTime)
  8391. }
  8392. // SetSourceType sets the "source_type" field.
  8393. func (m *MessageRecordsMutation) SetSourceType(i int) {
  8394. m.source_type = &i
  8395. m.addsource_type = nil
  8396. }
  8397. // SourceType returns the value of the "source_type" field in the mutation.
  8398. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  8399. v := m.source_type
  8400. if v == nil {
  8401. return
  8402. }
  8403. return *v, true
  8404. }
  8405. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  8406. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8408. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  8409. if !m.op.Is(OpUpdateOne) {
  8410. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  8411. }
  8412. if m.id == nil || m.oldValue == nil {
  8413. return v, errors.New("OldSourceType requires an ID field in the mutation")
  8414. }
  8415. oldValue, err := m.oldValue(ctx)
  8416. if err != nil {
  8417. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  8418. }
  8419. return oldValue.SourceType, nil
  8420. }
  8421. // AddSourceType adds i to the "source_type" field.
  8422. func (m *MessageRecordsMutation) AddSourceType(i int) {
  8423. if m.addsource_type != nil {
  8424. *m.addsource_type += i
  8425. } else {
  8426. m.addsource_type = &i
  8427. }
  8428. }
  8429. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  8430. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  8431. v := m.addsource_type
  8432. if v == nil {
  8433. return
  8434. }
  8435. return *v, true
  8436. }
  8437. // ResetSourceType resets all changes to the "source_type" field.
  8438. func (m *MessageRecordsMutation) ResetSourceType() {
  8439. m.source_type = nil
  8440. m.addsource_type = nil
  8441. }
  8442. // SetSourceID sets the "source_id" field.
  8443. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  8444. m.sop_stage = &u
  8445. }
  8446. // SourceID returns the value of the "source_id" field in the mutation.
  8447. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  8448. v := m.sop_stage
  8449. if v == nil {
  8450. return
  8451. }
  8452. return *v, true
  8453. }
  8454. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  8455. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8457. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  8458. if !m.op.Is(OpUpdateOne) {
  8459. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  8460. }
  8461. if m.id == nil || m.oldValue == nil {
  8462. return v, errors.New("OldSourceID requires an ID field in the mutation")
  8463. }
  8464. oldValue, err := m.oldValue(ctx)
  8465. if err != nil {
  8466. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  8467. }
  8468. return oldValue.SourceID, nil
  8469. }
  8470. // ClearSourceID clears the value of the "source_id" field.
  8471. func (m *MessageRecordsMutation) ClearSourceID() {
  8472. m.sop_stage = nil
  8473. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  8474. }
  8475. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  8476. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  8477. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  8478. return ok
  8479. }
  8480. // ResetSourceID resets all changes to the "source_id" field.
  8481. func (m *MessageRecordsMutation) ResetSourceID() {
  8482. m.sop_stage = nil
  8483. delete(m.clearedFields, messagerecords.FieldSourceID)
  8484. }
  8485. // SetSubSourceID sets the "sub_source_id" field.
  8486. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  8487. m.sop_node = &u
  8488. }
  8489. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  8490. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  8491. v := m.sop_node
  8492. if v == nil {
  8493. return
  8494. }
  8495. return *v, true
  8496. }
  8497. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  8498. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8499. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8500. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  8501. if !m.op.Is(OpUpdateOne) {
  8502. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  8503. }
  8504. if m.id == nil || m.oldValue == nil {
  8505. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  8506. }
  8507. oldValue, err := m.oldValue(ctx)
  8508. if err != nil {
  8509. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  8510. }
  8511. return oldValue.SubSourceID, nil
  8512. }
  8513. // ClearSubSourceID clears the value of the "sub_source_id" field.
  8514. func (m *MessageRecordsMutation) ClearSubSourceID() {
  8515. m.sop_node = nil
  8516. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  8517. }
  8518. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  8519. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  8520. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  8521. return ok
  8522. }
  8523. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  8524. func (m *MessageRecordsMutation) ResetSubSourceID() {
  8525. m.sop_node = nil
  8526. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  8527. }
  8528. // SetOrganizationID sets the "organization_id" field.
  8529. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  8530. m.organization_id = &u
  8531. m.addorganization_id = nil
  8532. }
  8533. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8534. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  8535. v := m.organization_id
  8536. if v == nil {
  8537. return
  8538. }
  8539. return *v, true
  8540. }
  8541. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  8542. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8544. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8545. if !m.op.Is(OpUpdateOne) {
  8546. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8547. }
  8548. if m.id == nil || m.oldValue == nil {
  8549. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8550. }
  8551. oldValue, err := m.oldValue(ctx)
  8552. if err != nil {
  8553. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8554. }
  8555. return oldValue.OrganizationID, nil
  8556. }
  8557. // AddOrganizationID adds u to the "organization_id" field.
  8558. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  8559. if m.addorganization_id != nil {
  8560. *m.addorganization_id += u
  8561. } else {
  8562. m.addorganization_id = &u
  8563. }
  8564. }
  8565. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8566. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  8567. v := m.addorganization_id
  8568. if v == nil {
  8569. return
  8570. }
  8571. return *v, true
  8572. }
  8573. // ClearOrganizationID clears the value of the "organization_id" field.
  8574. func (m *MessageRecordsMutation) ClearOrganizationID() {
  8575. m.organization_id = nil
  8576. m.addorganization_id = nil
  8577. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  8578. }
  8579. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  8580. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  8581. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  8582. return ok
  8583. }
  8584. // ResetOrganizationID resets all changes to the "organization_id" field.
  8585. func (m *MessageRecordsMutation) ResetOrganizationID() {
  8586. m.organization_id = nil
  8587. m.addorganization_id = nil
  8588. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  8589. }
  8590. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  8591. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  8592. m.sop_stage = &id
  8593. }
  8594. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  8595. func (m *MessageRecordsMutation) ClearSopStage() {
  8596. m.clearedsop_stage = true
  8597. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  8598. }
  8599. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  8600. func (m *MessageRecordsMutation) SopStageCleared() bool {
  8601. return m.SourceIDCleared() || m.clearedsop_stage
  8602. }
  8603. // SopStageID returns the "sop_stage" edge ID in the mutation.
  8604. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  8605. if m.sop_stage != nil {
  8606. return *m.sop_stage, true
  8607. }
  8608. return
  8609. }
  8610. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  8611. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  8612. // SopStageID instead. It exists only for internal usage by the builders.
  8613. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  8614. if id := m.sop_stage; id != nil {
  8615. ids = append(ids, *id)
  8616. }
  8617. return
  8618. }
  8619. // ResetSopStage resets all changes to the "sop_stage" edge.
  8620. func (m *MessageRecordsMutation) ResetSopStage() {
  8621. m.sop_stage = nil
  8622. m.clearedsop_stage = false
  8623. }
  8624. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  8625. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  8626. m.sop_node = &id
  8627. }
  8628. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  8629. func (m *MessageRecordsMutation) ClearSopNode() {
  8630. m.clearedsop_node = true
  8631. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  8632. }
  8633. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  8634. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  8635. return m.SubSourceIDCleared() || m.clearedsop_node
  8636. }
  8637. // SopNodeID returns the "sop_node" edge ID in the mutation.
  8638. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  8639. if m.sop_node != nil {
  8640. return *m.sop_node, true
  8641. }
  8642. return
  8643. }
  8644. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  8645. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  8646. // SopNodeID instead. It exists only for internal usage by the builders.
  8647. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  8648. if id := m.sop_node; id != nil {
  8649. ids = append(ids, *id)
  8650. }
  8651. return
  8652. }
  8653. // ResetSopNode resets all changes to the "sop_node" edge.
  8654. func (m *MessageRecordsMutation) ResetSopNode() {
  8655. m.sop_node = nil
  8656. m.clearedsop_node = false
  8657. }
  8658. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  8659. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  8660. m.message_contact = &id
  8661. }
  8662. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  8663. func (m *MessageRecordsMutation) ClearMessageContact() {
  8664. m.clearedmessage_contact = true
  8665. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  8666. }
  8667. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  8668. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  8669. return m.ContactIDCleared() || m.clearedmessage_contact
  8670. }
  8671. // MessageContactID returns the "message_contact" edge ID in the mutation.
  8672. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  8673. if m.message_contact != nil {
  8674. return *m.message_contact, true
  8675. }
  8676. return
  8677. }
  8678. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  8679. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  8680. // MessageContactID instead. It exists only for internal usage by the builders.
  8681. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  8682. if id := m.message_contact; id != nil {
  8683. ids = append(ids, *id)
  8684. }
  8685. return
  8686. }
  8687. // ResetMessageContact resets all changes to the "message_contact" edge.
  8688. func (m *MessageRecordsMutation) ResetMessageContact() {
  8689. m.message_contact = nil
  8690. m.clearedmessage_contact = false
  8691. }
  8692. // Where appends a list predicates to the MessageRecordsMutation builder.
  8693. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  8694. m.predicates = append(m.predicates, ps...)
  8695. }
  8696. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  8697. // users can use type-assertion to append predicates that do not depend on any generated package.
  8698. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  8699. p := make([]predicate.MessageRecords, len(ps))
  8700. for i := range ps {
  8701. p[i] = ps[i]
  8702. }
  8703. m.Where(p...)
  8704. }
  8705. // Op returns the operation name.
  8706. func (m *MessageRecordsMutation) Op() Op {
  8707. return m.op
  8708. }
  8709. // SetOp allows setting the mutation operation.
  8710. func (m *MessageRecordsMutation) SetOp(op Op) {
  8711. m.op = op
  8712. }
  8713. // Type returns the node type of this mutation (MessageRecords).
  8714. func (m *MessageRecordsMutation) Type() string {
  8715. return m.typ
  8716. }
  8717. // Fields returns all fields that were changed during this mutation. Note that in
  8718. // order to get all numeric fields that were incremented/decremented, call
  8719. // AddedFields().
  8720. func (m *MessageRecordsMutation) Fields() []string {
  8721. fields := make([]string, 0, 17)
  8722. if m.created_at != nil {
  8723. fields = append(fields, messagerecords.FieldCreatedAt)
  8724. }
  8725. if m.updated_at != nil {
  8726. fields = append(fields, messagerecords.FieldUpdatedAt)
  8727. }
  8728. if m.status != nil {
  8729. fields = append(fields, messagerecords.FieldStatus)
  8730. }
  8731. if m.deleted_at != nil {
  8732. fields = append(fields, messagerecords.FieldDeletedAt)
  8733. }
  8734. if m.bot_wxid != nil {
  8735. fields = append(fields, messagerecords.FieldBotWxid)
  8736. }
  8737. if m.message_contact != nil {
  8738. fields = append(fields, messagerecords.FieldContactID)
  8739. }
  8740. if m.contact_type != nil {
  8741. fields = append(fields, messagerecords.FieldContactType)
  8742. }
  8743. if m.contact_wxid != nil {
  8744. fields = append(fields, messagerecords.FieldContactWxid)
  8745. }
  8746. if m.content_type != nil {
  8747. fields = append(fields, messagerecords.FieldContentType)
  8748. }
  8749. if m.content != nil {
  8750. fields = append(fields, messagerecords.FieldContent)
  8751. }
  8752. if m.meta != nil {
  8753. fields = append(fields, messagerecords.FieldMeta)
  8754. }
  8755. if m.error_detail != nil {
  8756. fields = append(fields, messagerecords.FieldErrorDetail)
  8757. }
  8758. if m.send_time != nil {
  8759. fields = append(fields, messagerecords.FieldSendTime)
  8760. }
  8761. if m.source_type != nil {
  8762. fields = append(fields, messagerecords.FieldSourceType)
  8763. }
  8764. if m.sop_stage != nil {
  8765. fields = append(fields, messagerecords.FieldSourceID)
  8766. }
  8767. if m.sop_node != nil {
  8768. fields = append(fields, messagerecords.FieldSubSourceID)
  8769. }
  8770. if m.organization_id != nil {
  8771. fields = append(fields, messagerecords.FieldOrganizationID)
  8772. }
  8773. return fields
  8774. }
  8775. // Field returns the value of a field with the given name. The second boolean
  8776. // return value indicates that this field was not set, or was not defined in the
  8777. // schema.
  8778. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  8779. switch name {
  8780. case messagerecords.FieldCreatedAt:
  8781. return m.CreatedAt()
  8782. case messagerecords.FieldUpdatedAt:
  8783. return m.UpdatedAt()
  8784. case messagerecords.FieldStatus:
  8785. return m.Status()
  8786. case messagerecords.FieldDeletedAt:
  8787. return m.DeletedAt()
  8788. case messagerecords.FieldBotWxid:
  8789. return m.BotWxid()
  8790. case messagerecords.FieldContactID:
  8791. return m.ContactID()
  8792. case messagerecords.FieldContactType:
  8793. return m.ContactType()
  8794. case messagerecords.FieldContactWxid:
  8795. return m.ContactWxid()
  8796. case messagerecords.FieldContentType:
  8797. return m.ContentType()
  8798. case messagerecords.FieldContent:
  8799. return m.Content()
  8800. case messagerecords.FieldMeta:
  8801. return m.Meta()
  8802. case messagerecords.FieldErrorDetail:
  8803. return m.ErrorDetail()
  8804. case messagerecords.FieldSendTime:
  8805. return m.SendTime()
  8806. case messagerecords.FieldSourceType:
  8807. return m.SourceType()
  8808. case messagerecords.FieldSourceID:
  8809. return m.SourceID()
  8810. case messagerecords.FieldSubSourceID:
  8811. return m.SubSourceID()
  8812. case messagerecords.FieldOrganizationID:
  8813. return m.OrganizationID()
  8814. }
  8815. return nil, false
  8816. }
  8817. // OldField returns the old value of the field from the database. An error is
  8818. // returned if the mutation operation is not UpdateOne, or the query to the
  8819. // database failed.
  8820. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8821. switch name {
  8822. case messagerecords.FieldCreatedAt:
  8823. return m.OldCreatedAt(ctx)
  8824. case messagerecords.FieldUpdatedAt:
  8825. return m.OldUpdatedAt(ctx)
  8826. case messagerecords.FieldStatus:
  8827. return m.OldStatus(ctx)
  8828. case messagerecords.FieldDeletedAt:
  8829. return m.OldDeletedAt(ctx)
  8830. case messagerecords.FieldBotWxid:
  8831. return m.OldBotWxid(ctx)
  8832. case messagerecords.FieldContactID:
  8833. return m.OldContactID(ctx)
  8834. case messagerecords.FieldContactType:
  8835. return m.OldContactType(ctx)
  8836. case messagerecords.FieldContactWxid:
  8837. return m.OldContactWxid(ctx)
  8838. case messagerecords.FieldContentType:
  8839. return m.OldContentType(ctx)
  8840. case messagerecords.FieldContent:
  8841. return m.OldContent(ctx)
  8842. case messagerecords.FieldMeta:
  8843. return m.OldMeta(ctx)
  8844. case messagerecords.FieldErrorDetail:
  8845. return m.OldErrorDetail(ctx)
  8846. case messagerecords.FieldSendTime:
  8847. return m.OldSendTime(ctx)
  8848. case messagerecords.FieldSourceType:
  8849. return m.OldSourceType(ctx)
  8850. case messagerecords.FieldSourceID:
  8851. return m.OldSourceID(ctx)
  8852. case messagerecords.FieldSubSourceID:
  8853. return m.OldSubSourceID(ctx)
  8854. case messagerecords.FieldOrganizationID:
  8855. return m.OldOrganizationID(ctx)
  8856. }
  8857. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  8858. }
  8859. // SetField sets the value of a field with the given name. It returns an error if
  8860. // the field is not defined in the schema, or if the type mismatched the field
  8861. // type.
  8862. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  8863. switch name {
  8864. case messagerecords.FieldCreatedAt:
  8865. v, ok := value.(time.Time)
  8866. if !ok {
  8867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8868. }
  8869. m.SetCreatedAt(v)
  8870. return nil
  8871. case messagerecords.FieldUpdatedAt:
  8872. v, ok := value.(time.Time)
  8873. if !ok {
  8874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8875. }
  8876. m.SetUpdatedAt(v)
  8877. return nil
  8878. case messagerecords.FieldStatus:
  8879. v, ok := value.(uint8)
  8880. if !ok {
  8881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8882. }
  8883. m.SetStatus(v)
  8884. return nil
  8885. case messagerecords.FieldDeletedAt:
  8886. v, ok := value.(time.Time)
  8887. if !ok {
  8888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8889. }
  8890. m.SetDeletedAt(v)
  8891. return nil
  8892. case messagerecords.FieldBotWxid:
  8893. v, ok := value.(string)
  8894. if !ok {
  8895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8896. }
  8897. m.SetBotWxid(v)
  8898. return nil
  8899. case messagerecords.FieldContactID:
  8900. v, ok := value.(uint64)
  8901. if !ok {
  8902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8903. }
  8904. m.SetContactID(v)
  8905. return nil
  8906. case messagerecords.FieldContactType:
  8907. v, ok := value.(int)
  8908. if !ok {
  8909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8910. }
  8911. m.SetContactType(v)
  8912. return nil
  8913. case messagerecords.FieldContactWxid:
  8914. v, ok := value.(string)
  8915. if !ok {
  8916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8917. }
  8918. m.SetContactWxid(v)
  8919. return nil
  8920. case messagerecords.FieldContentType:
  8921. v, ok := value.(int)
  8922. if !ok {
  8923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8924. }
  8925. m.SetContentType(v)
  8926. return nil
  8927. case messagerecords.FieldContent:
  8928. v, ok := value.(string)
  8929. if !ok {
  8930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8931. }
  8932. m.SetContent(v)
  8933. return nil
  8934. case messagerecords.FieldMeta:
  8935. v, ok := value.(custom_types.Meta)
  8936. if !ok {
  8937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8938. }
  8939. m.SetMeta(v)
  8940. return nil
  8941. case messagerecords.FieldErrorDetail:
  8942. v, ok := value.(string)
  8943. if !ok {
  8944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8945. }
  8946. m.SetErrorDetail(v)
  8947. return nil
  8948. case messagerecords.FieldSendTime:
  8949. v, ok := value.(time.Time)
  8950. if !ok {
  8951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8952. }
  8953. m.SetSendTime(v)
  8954. return nil
  8955. case messagerecords.FieldSourceType:
  8956. v, ok := value.(int)
  8957. if !ok {
  8958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8959. }
  8960. m.SetSourceType(v)
  8961. return nil
  8962. case messagerecords.FieldSourceID:
  8963. v, ok := value.(uint64)
  8964. if !ok {
  8965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8966. }
  8967. m.SetSourceID(v)
  8968. return nil
  8969. case messagerecords.FieldSubSourceID:
  8970. v, ok := value.(uint64)
  8971. if !ok {
  8972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8973. }
  8974. m.SetSubSourceID(v)
  8975. return nil
  8976. case messagerecords.FieldOrganizationID:
  8977. v, ok := value.(uint64)
  8978. if !ok {
  8979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8980. }
  8981. m.SetOrganizationID(v)
  8982. return nil
  8983. }
  8984. return fmt.Errorf("unknown MessageRecords field %s", name)
  8985. }
  8986. // AddedFields returns all numeric fields that were incremented/decremented during
  8987. // this mutation.
  8988. func (m *MessageRecordsMutation) AddedFields() []string {
  8989. var fields []string
  8990. if m.addstatus != nil {
  8991. fields = append(fields, messagerecords.FieldStatus)
  8992. }
  8993. if m.addcontact_type != nil {
  8994. fields = append(fields, messagerecords.FieldContactType)
  8995. }
  8996. if m.addcontent_type != nil {
  8997. fields = append(fields, messagerecords.FieldContentType)
  8998. }
  8999. if m.addsource_type != nil {
  9000. fields = append(fields, messagerecords.FieldSourceType)
  9001. }
  9002. if m.addorganization_id != nil {
  9003. fields = append(fields, messagerecords.FieldOrganizationID)
  9004. }
  9005. return fields
  9006. }
  9007. // AddedField returns the numeric value that was incremented/decremented on a field
  9008. // with the given name. The second boolean return value indicates that this field
  9009. // was not set, or was not defined in the schema.
  9010. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  9011. switch name {
  9012. case messagerecords.FieldStatus:
  9013. return m.AddedStatus()
  9014. case messagerecords.FieldContactType:
  9015. return m.AddedContactType()
  9016. case messagerecords.FieldContentType:
  9017. return m.AddedContentType()
  9018. case messagerecords.FieldSourceType:
  9019. return m.AddedSourceType()
  9020. case messagerecords.FieldOrganizationID:
  9021. return m.AddedOrganizationID()
  9022. }
  9023. return nil, false
  9024. }
  9025. // AddField adds the value to the field with the given name. It returns an error if
  9026. // the field is not defined in the schema, or if the type mismatched the field
  9027. // type.
  9028. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  9029. switch name {
  9030. case messagerecords.FieldStatus:
  9031. v, ok := value.(int8)
  9032. if !ok {
  9033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9034. }
  9035. m.AddStatus(v)
  9036. return nil
  9037. case messagerecords.FieldContactType:
  9038. v, ok := value.(int)
  9039. if !ok {
  9040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9041. }
  9042. m.AddContactType(v)
  9043. return nil
  9044. case messagerecords.FieldContentType:
  9045. v, ok := value.(int)
  9046. if !ok {
  9047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9048. }
  9049. m.AddContentType(v)
  9050. return nil
  9051. case messagerecords.FieldSourceType:
  9052. v, ok := value.(int)
  9053. if !ok {
  9054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9055. }
  9056. m.AddSourceType(v)
  9057. return nil
  9058. case messagerecords.FieldOrganizationID:
  9059. v, ok := value.(int64)
  9060. if !ok {
  9061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9062. }
  9063. m.AddOrganizationID(v)
  9064. return nil
  9065. }
  9066. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  9067. }
  9068. // ClearedFields returns all nullable fields that were cleared during this
  9069. // mutation.
  9070. func (m *MessageRecordsMutation) ClearedFields() []string {
  9071. var fields []string
  9072. if m.FieldCleared(messagerecords.FieldStatus) {
  9073. fields = append(fields, messagerecords.FieldStatus)
  9074. }
  9075. if m.FieldCleared(messagerecords.FieldDeletedAt) {
  9076. fields = append(fields, messagerecords.FieldDeletedAt)
  9077. }
  9078. if m.FieldCleared(messagerecords.FieldContactID) {
  9079. fields = append(fields, messagerecords.FieldContactID)
  9080. }
  9081. if m.FieldCleared(messagerecords.FieldMeta) {
  9082. fields = append(fields, messagerecords.FieldMeta)
  9083. }
  9084. if m.FieldCleared(messagerecords.FieldSendTime) {
  9085. fields = append(fields, messagerecords.FieldSendTime)
  9086. }
  9087. if m.FieldCleared(messagerecords.FieldSourceID) {
  9088. fields = append(fields, messagerecords.FieldSourceID)
  9089. }
  9090. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  9091. fields = append(fields, messagerecords.FieldSubSourceID)
  9092. }
  9093. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  9094. fields = append(fields, messagerecords.FieldOrganizationID)
  9095. }
  9096. return fields
  9097. }
  9098. // FieldCleared returns a boolean indicating if a field with the given name was
  9099. // cleared in this mutation.
  9100. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  9101. _, ok := m.clearedFields[name]
  9102. return ok
  9103. }
  9104. // ClearField clears the value of the field with the given name. It returns an
  9105. // error if the field is not defined in the schema.
  9106. func (m *MessageRecordsMutation) ClearField(name string) error {
  9107. switch name {
  9108. case messagerecords.FieldStatus:
  9109. m.ClearStatus()
  9110. return nil
  9111. case messagerecords.FieldDeletedAt:
  9112. m.ClearDeletedAt()
  9113. return nil
  9114. case messagerecords.FieldContactID:
  9115. m.ClearContactID()
  9116. return nil
  9117. case messagerecords.FieldMeta:
  9118. m.ClearMeta()
  9119. return nil
  9120. case messagerecords.FieldSendTime:
  9121. m.ClearSendTime()
  9122. return nil
  9123. case messagerecords.FieldSourceID:
  9124. m.ClearSourceID()
  9125. return nil
  9126. case messagerecords.FieldSubSourceID:
  9127. m.ClearSubSourceID()
  9128. return nil
  9129. case messagerecords.FieldOrganizationID:
  9130. m.ClearOrganizationID()
  9131. return nil
  9132. }
  9133. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  9134. }
  9135. // ResetField resets all changes in the mutation for the field with the given name.
  9136. // It returns an error if the field is not defined in the schema.
  9137. func (m *MessageRecordsMutation) ResetField(name string) error {
  9138. switch name {
  9139. case messagerecords.FieldCreatedAt:
  9140. m.ResetCreatedAt()
  9141. return nil
  9142. case messagerecords.FieldUpdatedAt:
  9143. m.ResetUpdatedAt()
  9144. return nil
  9145. case messagerecords.FieldStatus:
  9146. m.ResetStatus()
  9147. return nil
  9148. case messagerecords.FieldDeletedAt:
  9149. m.ResetDeletedAt()
  9150. return nil
  9151. case messagerecords.FieldBotWxid:
  9152. m.ResetBotWxid()
  9153. return nil
  9154. case messagerecords.FieldContactID:
  9155. m.ResetContactID()
  9156. return nil
  9157. case messagerecords.FieldContactType:
  9158. m.ResetContactType()
  9159. return nil
  9160. case messagerecords.FieldContactWxid:
  9161. m.ResetContactWxid()
  9162. return nil
  9163. case messagerecords.FieldContentType:
  9164. m.ResetContentType()
  9165. return nil
  9166. case messagerecords.FieldContent:
  9167. m.ResetContent()
  9168. return nil
  9169. case messagerecords.FieldMeta:
  9170. m.ResetMeta()
  9171. return nil
  9172. case messagerecords.FieldErrorDetail:
  9173. m.ResetErrorDetail()
  9174. return nil
  9175. case messagerecords.FieldSendTime:
  9176. m.ResetSendTime()
  9177. return nil
  9178. case messagerecords.FieldSourceType:
  9179. m.ResetSourceType()
  9180. return nil
  9181. case messagerecords.FieldSourceID:
  9182. m.ResetSourceID()
  9183. return nil
  9184. case messagerecords.FieldSubSourceID:
  9185. m.ResetSubSourceID()
  9186. return nil
  9187. case messagerecords.FieldOrganizationID:
  9188. m.ResetOrganizationID()
  9189. return nil
  9190. }
  9191. return fmt.Errorf("unknown MessageRecords field %s", name)
  9192. }
  9193. // AddedEdges returns all edge names that were set/added in this mutation.
  9194. func (m *MessageRecordsMutation) AddedEdges() []string {
  9195. edges := make([]string, 0, 3)
  9196. if m.sop_stage != nil {
  9197. edges = append(edges, messagerecords.EdgeSopStage)
  9198. }
  9199. if m.sop_node != nil {
  9200. edges = append(edges, messagerecords.EdgeSopNode)
  9201. }
  9202. if m.message_contact != nil {
  9203. edges = append(edges, messagerecords.EdgeMessageContact)
  9204. }
  9205. return edges
  9206. }
  9207. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9208. // name in this mutation.
  9209. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  9210. switch name {
  9211. case messagerecords.EdgeSopStage:
  9212. if id := m.sop_stage; id != nil {
  9213. return []ent.Value{*id}
  9214. }
  9215. case messagerecords.EdgeSopNode:
  9216. if id := m.sop_node; id != nil {
  9217. return []ent.Value{*id}
  9218. }
  9219. case messagerecords.EdgeMessageContact:
  9220. if id := m.message_contact; id != nil {
  9221. return []ent.Value{*id}
  9222. }
  9223. }
  9224. return nil
  9225. }
  9226. // RemovedEdges returns all edge names that were removed in this mutation.
  9227. func (m *MessageRecordsMutation) RemovedEdges() []string {
  9228. edges := make([]string, 0, 3)
  9229. return edges
  9230. }
  9231. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9232. // the given name in this mutation.
  9233. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  9234. return nil
  9235. }
  9236. // ClearedEdges returns all edge names that were cleared in this mutation.
  9237. func (m *MessageRecordsMutation) ClearedEdges() []string {
  9238. edges := make([]string, 0, 3)
  9239. if m.clearedsop_stage {
  9240. edges = append(edges, messagerecords.EdgeSopStage)
  9241. }
  9242. if m.clearedsop_node {
  9243. edges = append(edges, messagerecords.EdgeSopNode)
  9244. }
  9245. if m.clearedmessage_contact {
  9246. edges = append(edges, messagerecords.EdgeMessageContact)
  9247. }
  9248. return edges
  9249. }
  9250. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9251. // was cleared in this mutation.
  9252. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  9253. switch name {
  9254. case messagerecords.EdgeSopStage:
  9255. return m.clearedsop_stage
  9256. case messagerecords.EdgeSopNode:
  9257. return m.clearedsop_node
  9258. case messagerecords.EdgeMessageContact:
  9259. return m.clearedmessage_contact
  9260. }
  9261. return false
  9262. }
  9263. // ClearEdge clears the value of the edge with the given name. It returns an error
  9264. // if that edge is not defined in the schema.
  9265. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  9266. switch name {
  9267. case messagerecords.EdgeSopStage:
  9268. m.ClearSopStage()
  9269. return nil
  9270. case messagerecords.EdgeSopNode:
  9271. m.ClearSopNode()
  9272. return nil
  9273. case messagerecords.EdgeMessageContact:
  9274. m.ClearMessageContact()
  9275. return nil
  9276. }
  9277. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  9278. }
  9279. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9280. // It returns an error if the edge is not defined in the schema.
  9281. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  9282. switch name {
  9283. case messagerecords.EdgeSopStage:
  9284. m.ResetSopStage()
  9285. return nil
  9286. case messagerecords.EdgeSopNode:
  9287. m.ResetSopNode()
  9288. return nil
  9289. case messagerecords.EdgeMessageContact:
  9290. m.ResetMessageContact()
  9291. return nil
  9292. }
  9293. return fmt.Errorf("unknown MessageRecords edge %s", name)
  9294. }
  9295. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  9296. type MsgMutation struct {
  9297. config
  9298. op Op
  9299. typ string
  9300. id *uint64
  9301. created_at *time.Time
  9302. updated_at *time.Time
  9303. deleted_at *time.Time
  9304. status *uint8
  9305. addstatus *int8
  9306. fromwxid *string
  9307. toid *string
  9308. msgtype *int32
  9309. addmsgtype *int32
  9310. msg *string
  9311. batch_no *string
  9312. clearedFields map[string]struct{}
  9313. done bool
  9314. oldValue func(context.Context) (*Msg, error)
  9315. predicates []predicate.Msg
  9316. }
  9317. var _ ent.Mutation = (*MsgMutation)(nil)
  9318. // msgOption allows management of the mutation configuration using functional options.
  9319. type msgOption func(*MsgMutation)
  9320. // newMsgMutation creates new mutation for the Msg entity.
  9321. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  9322. m := &MsgMutation{
  9323. config: c,
  9324. op: op,
  9325. typ: TypeMsg,
  9326. clearedFields: make(map[string]struct{}),
  9327. }
  9328. for _, opt := range opts {
  9329. opt(m)
  9330. }
  9331. return m
  9332. }
  9333. // withMsgID sets the ID field of the mutation.
  9334. func withMsgID(id uint64) msgOption {
  9335. return func(m *MsgMutation) {
  9336. var (
  9337. err error
  9338. once sync.Once
  9339. value *Msg
  9340. )
  9341. m.oldValue = func(ctx context.Context) (*Msg, error) {
  9342. once.Do(func() {
  9343. if m.done {
  9344. err = errors.New("querying old values post mutation is not allowed")
  9345. } else {
  9346. value, err = m.Client().Msg.Get(ctx, id)
  9347. }
  9348. })
  9349. return value, err
  9350. }
  9351. m.id = &id
  9352. }
  9353. }
  9354. // withMsg sets the old Msg of the mutation.
  9355. func withMsg(node *Msg) msgOption {
  9356. return func(m *MsgMutation) {
  9357. m.oldValue = func(context.Context) (*Msg, error) {
  9358. return node, nil
  9359. }
  9360. m.id = &node.ID
  9361. }
  9362. }
  9363. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9364. // executed in a transaction (ent.Tx), a transactional client is returned.
  9365. func (m MsgMutation) Client() *Client {
  9366. client := &Client{config: m.config}
  9367. client.init()
  9368. return client
  9369. }
  9370. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9371. // it returns an error otherwise.
  9372. func (m MsgMutation) Tx() (*Tx, error) {
  9373. if _, ok := m.driver.(*txDriver); !ok {
  9374. return nil, errors.New("ent: mutation is not running in a transaction")
  9375. }
  9376. tx := &Tx{config: m.config}
  9377. tx.init()
  9378. return tx, nil
  9379. }
  9380. // SetID sets the value of the id field. Note that this
  9381. // operation is only accepted on creation of Msg entities.
  9382. func (m *MsgMutation) SetID(id uint64) {
  9383. m.id = &id
  9384. }
  9385. // ID returns the ID value in the mutation. Note that the ID is only available
  9386. // if it was provided to the builder or after it was returned from the database.
  9387. func (m *MsgMutation) ID() (id uint64, exists bool) {
  9388. if m.id == nil {
  9389. return
  9390. }
  9391. return *m.id, true
  9392. }
  9393. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9394. // That means, if the mutation is applied within a transaction with an isolation level such
  9395. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9396. // or updated by the mutation.
  9397. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  9398. switch {
  9399. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9400. id, exists := m.ID()
  9401. if exists {
  9402. return []uint64{id}, nil
  9403. }
  9404. fallthrough
  9405. case m.op.Is(OpUpdate | OpDelete):
  9406. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  9407. default:
  9408. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9409. }
  9410. }
  9411. // SetCreatedAt sets the "created_at" field.
  9412. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  9413. m.created_at = &t
  9414. }
  9415. // CreatedAt returns the value of the "created_at" field in the mutation.
  9416. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  9417. v := m.created_at
  9418. if v == nil {
  9419. return
  9420. }
  9421. return *v, true
  9422. }
  9423. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  9424. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  9425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9426. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9427. if !m.op.Is(OpUpdateOne) {
  9428. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9429. }
  9430. if m.id == nil || m.oldValue == nil {
  9431. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9432. }
  9433. oldValue, err := m.oldValue(ctx)
  9434. if err != nil {
  9435. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9436. }
  9437. return oldValue.CreatedAt, nil
  9438. }
  9439. // ResetCreatedAt resets all changes to the "created_at" field.
  9440. func (m *MsgMutation) ResetCreatedAt() {
  9441. m.created_at = nil
  9442. }
  9443. // SetUpdatedAt sets the "updated_at" field.
  9444. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  9445. m.updated_at = &t
  9446. }
  9447. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9448. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  9449. v := m.updated_at
  9450. if v == nil {
  9451. return
  9452. }
  9453. return *v, true
  9454. }
  9455. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  9456. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  9457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9458. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9459. if !m.op.Is(OpUpdateOne) {
  9460. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9461. }
  9462. if m.id == nil || m.oldValue == nil {
  9463. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9464. }
  9465. oldValue, err := m.oldValue(ctx)
  9466. if err != nil {
  9467. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9468. }
  9469. return oldValue.UpdatedAt, nil
  9470. }
  9471. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9472. func (m *MsgMutation) ResetUpdatedAt() {
  9473. m.updated_at = nil
  9474. }
  9475. // SetDeletedAt sets the "deleted_at" field.
  9476. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  9477. m.deleted_at = &t
  9478. }
  9479. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9480. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  9481. v := m.deleted_at
  9482. if v == nil {
  9483. return
  9484. }
  9485. return *v, true
  9486. }
  9487. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  9488. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  9489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9490. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9491. if !m.op.Is(OpUpdateOne) {
  9492. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9493. }
  9494. if m.id == nil || m.oldValue == nil {
  9495. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9496. }
  9497. oldValue, err := m.oldValue(ctx)
  9498. if err != nil {
  9499. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9500. }
  9501. return oldValue.DeletedAt, nil
  9502. }
  9503. // ClearDeletedAt clears the value of the "deleted_at" field.
  9504. func (m *MsgMutation) ClearDeletedAt() {
  9505. m.deleted_at = nil
  9506. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  9507. }
  9508. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9509. func (m *MsgMutation) DeletedAtCleared() bool {
  9510. _, ok := m.clearedFields[msg.FieldDeletedAt]
  9511. return ok
  9512. }
  9513. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9514. func (m *MsgMutation) ResetDeletedAt() {
  9515. m.deleted_at = nil
  9516. delete(m.clearedFields, msg.FieldDeletedAt)
  9517. }
  9518. // SetStatus sets the "status" field.
  9519. func (m *MsgMutation) SetStatus(u uint8) {
  9520. m.status = &u
  9521. m.addstatus = nil
  9522. }
  9523. // Status returns the value of the "status" field in the mutation.
  9524. func (m *MsgMutation) Status() (r uint8, exists bool) {
  9525. v := m.status
  9526. if v == nil {
  9527. return
  9528. }
  9529. return *v, true
  9530. }
  9531. // OldStatus returns the old "status" field's value of the Msg entity.
  9532. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  9533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9534. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9535. if !m.op.Is(OpUpdateOne) {
  9536. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9537. }
  9538. if m.id == nil || m.oldValue == nil {
  9539. return v, errors.New("OldStatus requires an ID field in the mutation")
  9540. }
  9541. oldValue, err := m.oldValue(ctx)
  9542. if err != nil {
  9543. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9544. }
  9545. return oldValue.Status, nil
  9546. }
  9547. // AddStatus adds u to the "status" field.
  9548. func (m *MsgMutation) AddStatus(u int8) {
  9549. if m.addstatus != nil {
  9550. *m.addstatus += u
  9551. } else {
  9552. m.addstatus = &u
  9553. }
  9554. }
  9555. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9556. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  9557. v := m.addstatus
  9558. if v == nil {
  9559. return
  9560. }
  9561. return *v, true
  9562. }
  9563. // ClearStatus clears the value of the "status" field.
  9564. func (m *MsgMutation) ClearStatus() {
  9565. m.status = nil
  9566. m.addstatus = nil
  9567. m.clearedFields[msg.FieldStatus] = struct{}{}
  9568. }
  9569. // StatusCleared returns if the "status" field was cleared in this mutation.
  9570. func (m *MsgMutation) StatusCleared() bool {
  9571. _, ok := m.clearedFields[msg.FieldStatus]
  9572. return ok
  9573. }
  9574. // ResetStatus resets all changes to the "status" field.
  9575. func (m *MsgMutation) ResetStatus() {
  9576. m.status = nil
  9577. m.addstatus = nil
  9578. delete(m.clearedFields, msg.FieldStatus)
  9579. }
  9580. // SetFromwxid sets the "fromwxid" field.
  9581. func (m *MsgMutation) SetFromwxid(s string) {
  9582. m.fromwxid = &s
  9583. }
  9584. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  9585. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  9586. v := m.fromwxid
  9587. if v == nil {
  9588. return
  9589. }
  9590. return *v, true
  9591. }
  9592. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  9593. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  9594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9595. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  9596. if !m.op.Is(OpUpdateOne) {
  9597. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  9598. }
  9599. if m.id == nil || m.oldValue == nil {
  9600. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  9601. }
  9602. oldValue, err := m.oldValue(ctx)
  9603. if err != nil {
  9604. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  9605. }
  9606. return oldValue.Fromwxid, nil
  9607. }
  9608. // ClearFromwxid clears the value of the "fromwxid" field.
  9609. func (m *MsgMutation) ClearFromwxid() {
  9610. m.fromwxid = nil
  9611. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  9612. }
  9613. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  9614. func (m *MsgMutation) FromwxidCleared() bool {
  9615. _, ok := m.clearedFields[msg.FieldFromwxid]
  9616. return ok
  9617. }
  9618. // ResetFromwxid resets all changes to the "fromwxid" field.
  9619. func (m *MsgMutation) ResetFromwxid() {
  9620. m.fromwxid = nil
  9621. delete(m.clearedFields, msg.FieldFromwxid)
  9622. }
  9623. // SetToid sets the "toid" field.
  9624. func (m *MsgMutation) SetToid(s string) {
  9625. m.toid = &s
  9626. }
  9627. // Toid returns the value of the "toid" field in the mutation.
  9628. func (m *MsgMutation) Toid() (r string, exists bool) {
  9629. v := m.toid
  9630. if v == nil {
  9631. return
  9632. }
  9633. return *v, true
  9634. }
  9635. // OldToid returns the old "toid" field's value of the Msg entity.
  9636. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  9637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9638. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  9639. if !m.op.Is(OpUpdateOne) {
  9640. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  9641. }
  9642. if m.id == nil || m.oldValue == nil {
  9643. return v, errors.New("OldToid requires an ID field in the mutation")
  9644. }
  9645. oldValue, err := m.oldValue(ctx)
  9646. if err != nil {
  9647. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  9648. }
  9649. return oldValue.Toid, nil
  9650. }
  9651. // ClearToid clears the value of the "toid" field.
  9652. func (m *MsgMutation) ClearToid() {
  9653. m.toid = nil
  9654. m.clearedFields[msg.FieldToid] = struct{}{}
  9655. }
  9656. // ToidCleared returns if the "toid" field was cleared in this mutation.
  9657. func (m *MsgMutation) ToidCleared() bool {
  9658. _, ok := m.clearedFields[msg.FieldToid]
  9659. return ok
  9660. }
  9661. // ResetToid resets all changes to the "toid" field.
  9662. func (m *MsgMutation) ResetToid() {
  9663. m.toid = nil
  9664. delete(m.clearedFields, msg.FieldToid)
  9665. }
  9666. // SetMsgtype sets the "msgtype" field.
  9667. func (m *MsgMutation) SetMsgtype(i int32) {
  9668. m.msgtype = &i
  9669. m.addmsgtype = nil
  9670. }
  9671. // Msgtype returns the value of the "msgtype" field in the mutation.
  9672. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  9673. v := m.msgtype
  9674. if v == nil {
  9675. return
  9676. }
  9677. return *v, true
  9678. }
  9679. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  9680. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  9681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9682. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  9683. if !m.op.Is(OpUpdateOne) {
  9684. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  9685. }
  9686. if m.id == nil || m.oldValue == nil {
  9687. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  9688. }
  9689. oldValue, err := m.oldValue(ctx)
  9690. if err != nil {
  9691. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  9692. }
  9693. return oldValue.Msgtype, nil
  9694. }
  9695. // AddMsgtype adds i to the "msgtype" field.
  9696. func (m *MsgMutation) AddMsgtype(i int32) {
  9697. if m.addmsgtype != nil {
  9698. *m.addmsgtype += i
  9699. } else {
  9700. m.addmsgtype = &i
  9701. }
  9702. }
  9703. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  9704. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  9705. v := m.addmsgtype
  9706. if v == nil {
  9707. return
  9708. }
  9709. return *v, true
  9710. }
  9711. // ClearMsgtype clears the value of the "msgtype" field.
  9712. func (m *MsgMutation) ClearMsgtype() {
  9713. m.msgtype = nil
  9714. m.addmsgtype = nil
  9715. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  9716. }
  9717. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  9718. func (m *MsgMutation) MsgtypeCleared() bool {
  9719. _, ok := m.clearedFields[msg.FieldMsgtype]
  9720. return ok
  9721. }
  9722. // ResetMsgtype resets all changes to the "msgtype" field.
  9723. func (m *MsgMutation) ResetMsgtype() {
  9724. m.msgtype = nil
  9725. m.addmsgtype = nil
  9726. delete(m.clearedFields, msg.FieldMsgtype)
  9727. }
  9728. // SetMsg sets the "msg" field.
  9729. func (m *MsgMutation) SetMsg(s string) {
  9730. m.msg = &s
  9731. }
  9732. // Msg returns the value of the "msg" field in the mutation.
  9733. func (m *MsgMutation) Msg() (r string, exists bool) {
  9734. v := m.msg
  9735. if v == nil {
  9736. return
  9737. }
  9738. return *v, true
  9739. }
  9740. // OldMsg returns the old "msg" field's value of the Msg entity.
  9741. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  9742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9743. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  9744. if !m.op.Is(OpUpdateOne) {
  9745. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  9746. }
  9747. if m.id == nil || m.oldValue == nil {
  9748. return v, errors.New("OldMsg requires an ID field in the mutation")
  9749. }
  9750. oldValue, err := m.oldValue(ctx)
  9751. if err != nil {
  9752. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  9753. }
  9754. return oldValue.Msg, nil
  9755. }
  9756. // ClearMsg clears the value of the "msg" field.
  9757. func (m *MsgMutation) ClearMsg() {
  9758. m.msg = nil
  9759. m.clearedFields[msg.FieldMsg] = struct{}{}
  9760. }
  9761. // MsgCleared returns if the "msg" field was cleared in this mutation.
  9762. func (m *MsgMutation) MsgCleared() bool {
  9763. _, ok := m.clearedFields[msg.FieldMsg]
  9764. return ok
  9765. }
  9766. // ResetMsg resets all changes to the "msg" field.
  9767. func (m *MsgMutation) ResetMsg() {
  9768. m.msg = nil
  9769. delete(m.clearedFields, msg.FieldMsg)
  9770. }
  9771. // SetBatchNo sets the "batch_no" field.
  9772. func (m *MsgMutation) SetBatchNo(s string) {
  9773. m.batch_no = &s
  9774. }
  9775. // BatchNo returns the value of the "batch_no" field in the mutation.
  9776. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  9777. v := m.batch_no
  9778. if v == nil {
  9779. return
  9780. }
  9781. return *v, true
  9782. }
  9783. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  9784. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  9785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9786. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  9787. if !m.op.Is(OpUpdateOne) {
  9788. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  9789. }
  9790. if m.id == nil || m.oldValue == nil {
  9791. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  9792. }
  9793. oldValue, err := m.oldValue(ctx)
  9794. if err != nil {
  9795. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  9796. }
  9797. return oldValue.BatchNo, nil
  9798. }
  9799. // ClearBatchNo clears the value of the "batch_no" field.
  9800. func (m *MsgMutation) ClearBatchNo() {
  9801. m.batch_no = nil
  9802. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  9803. }
  9804. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  9805. func (m *MsgMutation) BatchNoCleared() bool {
  9806. _, ok := m.clearedFields[msg.FieldBatchNo]
  9807. return ok
  9808. }
  9809. // ResetBatchNo resets all changes to the "batch_no" field.
  9810. func (m *MsgMutation) ResetBatchNo() {
  9811. m.batch_no = nil
  9812. delete(m.clearedFields, msg.FieldBatchNo)
  9813. }
  9814. // Where appends a list predicates to the MsgMutation builder.
  9815. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  9816. m.predicates = append(m.predicates, ps...)
  9817. }
  9818. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  9819. // users can use type-assertion to append predicates that do not depend on any generated package.
  9820. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  9821. p := make([]predicate.Msg, len(ps))
  9822. for i := range ps {
  9823. p[i] = ps[i]
  9824. }
  9825. m.Where(p...)
  9826. }
  9827. // Op returns the operation name.
  9828. func (m *MsgMutation) Op() Op {
  9829. return m.op
  9830. }
  9831. // SetOp allows setting the mutation operation.
  9832. func (m *MsgMutation) SetOp(op Op) {
  9833. m.op = op
  9834. }
  9835. // Type returns the node type of this mutation (Msg).
  9836. func (m *MsgMutation) Type() string {
  9837. return m.typ
  9838. }
  9839. // Fields returns all fields that were changed during this mutation. Note that in
  9840. // order to get all numeric fields that were incremented/decremented, call
  9841. // AddedFields().
  9842. func (m *MsgMutation) Fields() []string {
  9843. fields := make([]string, 0, 9)
  9844. if m.created_at != nil {
  9845. fields = append(fields, msg.FieldCreatedAt)
  9846. }
  9847. if m.updated_at != nil {
  9848. fields = append(fields, msg.FieldUpdatedAt)
  9849. }
  9850. if m.deleted_at != nil {
  9851. fields = append(fields, msg.FieldDeletedAt)
  9852. }
  9853. if m.status != nil {
  9854. fields = append(fields, msg.FieldStatus)
  9855. }
  9856. if m.fromwxid != nil {
  9857. fields = append(fields, msg.FieldFromwxid)
  9858. }
  9859. if m.toid != nil {
  9860. fields = append(fields, msg.FieldToid)
  9861. }
  9862. if m.msgtype != nil {
  9863. fields = append(fields, msg.FieldMsgtype)
  9864. }
  9865. if m.msg != nil {
  9866. fields = append(fields, msg.FieldMsg)
  9867. }
  9868. if m.batch_no != nil {
  9869. fields = append(fields, msg.FieldBatchNo)
  9870. }
  9871. return fields
  9872. }
  9873. // Field returns the value of a field with the given name. The second boolean
  9874. // return value indicates that this field was not set, or was not defined in the
  9875. // schema.
  9876. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  9877. switch name {
  9878. case msg.FieldCreatedAt:
  9879. return m.CreatedAt()
  9880. case msg.FieldUpdatedAt:
  9881. return m.UpdatedAt()
  9882. case msg.FieldDeletedAt:
  9883. return m.DeletedAt()
  9884. case msg.FieldStatus:
  9885. return m.Status()
  9886. case msg.FieldFromwxid:
  9887. return m.Fromwxid()
  9888. case msg.FieldToid:
  9889. return m.Toid()
  9890. case msg.FieldMsgtype:
  9891. return m.Msgtype()
  9892. case msg.FieldMsg:
  9893. return m.Msg()
  9894. case msg.FieldBatchNo:
  9895. return m.BatchNo()
  9896. }
  9897. return nil, false
  9898. }
  9899. // OldField returns the old value of the field from the database. An error is
  9900. // returned if the mutation operation is not UpdateOne, or the query to the
  9901. // database failed.
  9902. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9903. switch name {
  9904. case msg.FieldCreatedAt:
  9905. return m.OldCreatedAt(ctx)
  9906. case msg.FieldUpdatedAt:
  9907. return m.OldUpdatedAt(ctx)
  9908. case msg.FieldDeletedAt:
  9909. return m.OldDeletedAt(ctx)
  9910. case msg.FieldStatus:
  9911. return m.OldStatus(ctx)
  9912. case msg.FieldFromwxid:
  9913. return m.OldFromwxid(ctx)
  9914. case msg.FieldToid:
  9915. return m.OldToid(ctx)
  9916. case msg.FieldMsgtype:
  9917. return m.OldMsgtype(ctx)
  9918. case msg.FieldMsg:
  9919. return m.OldMsg(ctx)
  9920. case msg.FieldBatchNo:
  9921. return m.OldBatchNo(ctx)
  9922. }
  9923. return nil, fmt.Errorf("unknown Msg field %s", name)
  9924. }
  9925. // SetField sets the value of a field with the given name. It returns an error if
  9926. // the field is not defined in the schema, or if the type mismatched the field
  9927. // type.
  9928. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  9929. switch name {
  9930. case msg.FieldCreatedAt:
  9931. v, ok := value.(time.Time)
  9932. if !ok {
  9933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9934. }
  9935. m.SetCreatedAt(v)
  9936. return nil
  9937. case msg.FieldUpdatedAt:
  9938. v, ok := value.(time.Time)
  9939. if !ok {
  9940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9941. }
  9942. m.SetUpdatedAt(v)
  9943. return nil
  9944. case msg.FieldDeletedAt:
  9945. v, ok := value.(time.Time)
  9946. if !ok {
  9947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9948. }
  9949. m.SetDeletedAt(v)
  9950. return nil
  9951. case msg.FieldStatus:
  9952. v, ok := value.(uint8)
  9953. if !ok {
  9954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9955. }
  9956. m.SetStatus(v)
  9957. return nil
  9958. case msg.FieldFromwxid:
  9959. v, ok := value.(string)
  9960. if !ok {
  9961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9962. }
  9963. m.SetFromwxid(v)
  9964. return nil
  9965. case msg.FieldToid:
  9966. v, ok := value.(string)
  9967. if !ok {
  9968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9969. }
  9970. m.SetToid(v)
  9971. return nil
  9972. case msg.FieldMsgtype:
  9973. v, ok := value.(int32)
  9974. if !ok {
  9975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9976. }
  9977. m.SetMsgtype(v)
  9978. return nil
  9979. case msg.FieldMsg:
  9980. v, ok := value.(string)
  9981. if !ok {
  9982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9983. }
  9984. m.SetMsg(v)
  9985. return nil
  9986. case msg.FieldBatchNo:
  9987. v, ok := value.(string)
  9988. if !ok {
  9989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9990. }
  9991. m.SetBatchNo(v)
  9992. return nil
  9993. }
  9994. return fmt.Errorf("unknown Msg field %s", name)
  9995. }
  9996. // AddedFields returns all numeric fields that were incremented/decremented during
  9997. // this mutation.
  9998. func (m *MsgMutation) AddedFields() []string {
  9999. var fields []string
  10000. if m.addstatus != nil {
  10001. fields = append(fields, msg.FieldStatus)
  10002. }
  10003. if m.addmsgtype != nil {
  10004. fields = append(fields, msg.FieldMsgtype)
  10005. }
  10006. return fields
  10007. }
  10008. // AddedField returns the numeric value that was incremented/decremented on a field
  10009. // with the given name. The second boolean return value indicates that this field
  10010. // was not set, or was not defined in the schema.
  10011. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  10012. switch name {
  10013. case msg.FieldStatus:
  10014. return m.AddedStatus()
  10015. case msg.FieldMsgtype:
  10016. return m.AddedMsgtype()
  10017. }
  10018. return nil, false
  10019. }
  10020. // AddField adds the value to the field with the given name. It returns an error if
  10021. // the field is not defined in the schema, or if the type mismatched the field
  10022. // type.
  10023. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  10024. switch name {
  10025. case msg.FieldStatus:
  10026. v, ok := value.(int8)
  10027. if !ok {
  10028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10029. }
  10030. m.AddStatus(v)
  10031. return nil
  10032. case msg.FieldMsgtype:
  10033. v, ok := value.(int32)
  10034. if !ok {
  10035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10036. }
  10037. m.AddMsgtype(v)
  10038. return nil
  10039. }
  10040. return fmt.Errorf("unknown Msg numeric field %s", name)
  10041. }
  10042. // ClearedFields returns all nullable fields that were cleared during this
  10043. // mutation.
  10044. func (m *MsgMutation) ClearedFields() []string {
  10045. var fields []string
  10046. if m.FieldCleared(msg.FieldDeletedAt) {
  10047. fields = append(fields, msg.FieldDeletedAt)
  10048. }
  10049. if m.FieldCleared(msg.FieldStatus) {
  10050. fields = append(fields, msg.FieldStatus)
  10051. }
  10052. if m.FieldCleared(msg.FieldFromwxid) {
  10053. fields = append(fields, msg.FieldFromwxid)
  10054. }
  10055. if m.FieldCleared(msg.FieldToid) {
  10056. fields = append(fields, msg.FieldToid)
  10057. }
  10058. if m.FieldCleared(msg.FieldMsgtype) {
  10059. fields = append(fields, msg.FieldMsgtype)
  10060. }
  10061. if m.FieldCleared(msg.FieldMsg) {
  10062. fields = append(fields, msg.FieldMsg)
  10063. }
  10064. if m.FieldCleared(msg.FieldBatchNo) {
  10065. fields = append(fields, msg.FieldBatchNo)
  10066. }
  10067. return fields
  10068. }
  10069. // FieldCleared returns a boolean indicating if a field with the given name was
  10070. // cleared in this mutation.
  10071. func (m *MsgMutation) FieldCleared(name string) bool {
  10072. _, ok := m.clearedFields[name]
  10073. return ok
  10074. }
  10075. // ClearField clears the value of the field with the given name. It returns an
  10076. // error if the field is not defined in the schema.
  10077. func (m *MsgMutation) ClearField(name string) error {
  10078. switch name {
  10079. case msg.FieldDeletedAt:
  10080. m.ClearDeletedAt()
  10081. return nil
  10082. case msg.FieldStatus:
  10083. m.ClearStatus()
  10084. return nil
  10085. case msg.FieldFromwxid:
  10086. m.ClearFromwxid()
  10087. return nil
  10088. case msg.FieldToid:
  10089. m.ClearToid()
  10090. return nil
  10091. case msg.FieldMsgtype:
  10092. m.ClearMsgtype()
  10093. return nil
  10094. case msg.FieldMsg:
  10095. m.ClearMsg()
  10096. return nil
  10097. case msg.FieldBatchNo:
  10098. m.ClearBatchNo()
  10099. return nil
  10100. }
  10101. return fmt.Errorf("unknown Msg nullable field %s", name)
  10102. }
  10103. // ResetField resets all changes in the mutation for the field with the given name.
  10104. // It returns an error if the field is not defined in the schema.
  10105. func (m *MsgMutation) ResetField(name string) error {
  10106. switch name {
  10107. case msg.FieldCreatedAt:
  10108. m.ResetCreatedAt()
  10109. return nil
  10110. case msg.FieldUpdatedAt:
  10111. m.ResetUpdatedAt()
  10112. return nil
  10113. case msg.FieldDeletedAt:
  10114. m.ResetDeletedAt()
  10115. return nil
  10116. case msg.FieldStatus:
  10117. m.ResetStatus()
  10118. return nil
  10119. case msg.FieldFromwxid:
  10120. m.ResetFromwxid()
  10121. return nil
  10122. case msg.FieldToid:
  10123. m.ResetToid()
  10124. return nil
  10125. case msg.FieldMsgtype:
  10126. m.ResetMsgtype()
  10127. return nil
  10128. case msg.FieldMsg:
  10129. m.ResetMsg()
  10130. return nil
  10131. case msg.FieldBatchNo:
  10132. m.ResetBatchNo()
  10133. return nil
  10134. }
  10135. return fmt.Errorf("unknown Msg field %s", name)
  10136. }
  10137. // AddedEdges returns all edge names that were set/added in this mutation.
  10138. func (m *MsgMutation) AddedEdges() []string {
  10139. edges := make([]string, 0, 0)
  10140. return edges
  10141. }
  10142. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10143. // name in this mutation.
  10144. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  10145. return nil
  10146. }
  10147. // RemovedEdges returns all edge names that were removed in this mutation.
  10148. func (m *MsgMutation) RemovedEdges() []string {
  10149. edges := make([]string, 0, 0)
  10150. return edges
  10151. }
  10152. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10153. // the given name in this mutation.
  10154. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  10155. return nil
  10156. }
  10157. // ClearedEdges returns all edge names that were cleared in this mutation.
  10158. func (m *MsgMutation) ClearedEdges() []string {
  10159. edges := make([]string, 0, 0)
  10160. return edges
  10161. }
  10162. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10163. // was cleared in this mutation.
  10164. func (m *MsgMutation) EdgeCleared(name string) bool {
  10165. return false
  10166. }
  10167. // ClearEdge clears the value of the edge with the given name. It returns an error
  10168. // if that edge is not defined in the schema.
  10169. func (m *MsgMutation) ClearEdge(name string) error {
  10170. return fmt.Errorf("unknown Msg unique edge %s", name)
  10171. }
  10172. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10173. // It returns an error if the edge is not defined in the schema.
  10174. func (m *MsgMutation) ResetEdge(name string) error {
  10175. return fmt.Errorf("unknown Msg edge %s", name)
  10176. }
  10177. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  10178. type ServerMutation struct {
  10179. config
  10180. op Op
  10181. typ string
  10182. id *uint64
  10183. created_at *time.Time
  10184. updated_at *time.Time
  10185. status *uint8
  10186. addstatus *int8
  10187. deleted_at *time.Time
  10188. name *string
  10189. public_ip *string
  10190. private_ip *string
  10191. admin_port *string
  10192. clearedFields map[string]struct{}
  10193. wxs map[uint64]struct{}
  10194. removedwxs map[uint64]struct{}
  10195. clearedwxs bool
  10196. done bool
  10197. oldValue func(context.Context) (*Server, error)
  10198. predicates []predicate.Server
  10199. }
  10200. var _ ent.Mutation = (*ServerMutation)(nil)
  10201. // serverOption allows management of the mutation configuration using functional options.
  10202. type serverOption func(*ServerMutation)
  10203. // newServerMutation creates new mutation for the Server entity.
  10204. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  10205. m := &ServerMutation{
  10206. config: c,
  10207. op: op,
  10208. typ: TypeServer,
  10209. clearedFields: make(map[string]struct{}),
  10210. }
  10211. for _, opt := range opts {
  10212. opt(m)
  10213. }
  10214. return m
  10215. }
  10216. // withServerID sets the ID field of the mutation.
  10217. func withServerID(id uint64) serverOption {
  10218. return func(m *ServerMutation) {
  10219. var (
  10220. err error
  10221. once sync.Once
  10222. value *Server
  10223. )
  10224. m.oldValue = func(ctx context.Context) (*Server, error) {
  10225. once.Do(func() {
  10226. if m.done {
  10227. err = errors.New("querying old values post mutation is not allowed")
  10228. } else {
  10229. value, err = m.Client().Server.Get(ctx, id)
  10230. }
  10231. })
  10232. return value, err
  10233. }
  10234. m.id = &id
  10235. }
  10236. }
  10237. // withServer sets the old Server of the mutation.
  10238. func withServer(node *Server) serverOption {
  10239. return func(m *ServerMutation) {
  10240. m.oldValue = func(context.Context) (*Server, error) {
  10241. return node, nil
  10242. }
  10243. m.id = &node.ID
  10244. }
  10245. }
  10246. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10247. // executed in a transaction (ent.Tx), a transactional client is returned.
  10248. func (m ServerMutation) Client() *Client {
  10249. client := &Client{config: m.config}
  10250. client.init()
  10251. return client
  10252. }
  10253. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10254. // it returns an error otherwise.
  10255. func (m ServerMutation) Tx() (*Tx, error) {
  10256. if _, ok := m.driver.(*txDriver); !ok {
  10257. return nil, errors.New("ent: mutation is not running in a transaction")
  10258. }
  10259. tx := &Tx{config: m.config}
  10260. tx.init()
  10261. return tx, nil
  10262. }
  10263. // SetID sets the value of the id field. Note that this
  10264. // operation is only accepted on creation of Server entities.
  10265. func (m *ServerMutation) SetID(id uint64) {
  10266. m.id = &id
  10267. }
  10268. // ID returns the ID value in the mutation. Note that the ID is only available
  10269. // if it was provided to the builder or after it was returned from the database.
  10270. func (m *ServerMutation) ID() (id uint64, exists bool) {
  10271. if m.id == nil {
  10272. return
  10273. }
  10274. return *m.id, true
  10275. }
  10276. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10277. // That means, if the mutation is applied within a transaction with an isolation level such
  10278. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10279. // or updated by the mutation.
  10280. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  10281. switch {
  10282. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10283. id, exists := m.ID()
  10284. if exists {
  10285. return []uint64{id}, nil
  10286. }
  10287. fallthrough
  10288. case m.op.Is(OpUpdate | OpDelete):
  10289. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  10290. default:
  10291. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10292. }
  10293. }
  10294. // SetCreatedAt sets the "created_at" field.
  10295. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  10296. m.created_at = &t
  10297. }
  10298. // CreatedAt returns the value of the "created_at" field in the mutation.
  10299. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  10300. v := m.created_at
  10301. if v == nil {
  10302. return
  10303. }
  10304. return *v, true
  10305. }
  10306. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  10307. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  10308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10309. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10310. if !m.op.Is(OpUpdateOne) {
  10311. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10312. }
  10313. if m.id == nil || m.oldValue == nil {
  10314. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10315. }
  10316. oldValue, err := m.oldValue(ctx)
  10317. if err != nil {
  10318. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10319. }
  10320. return oldValue.CreatedAt, nil
  10321. }
  10322. // ResetCreatedAt resets all changes to the "created_at" field.
  10323. func (m *ServerMutation) ResetCreatedAt() {
  10324. m.created_at = nil
  10325. }
  10326. // SetUpdatedAt sets the "updated_at" field.
  10327. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  10328. m.updated_at = &t
  10329. }
  10330. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10331. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  10332. v := m.updated_at
  10333. if v == nil {
  10334. return
  10335. }
  10336. return *v, true
  10337. }
  10338. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  10339. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  10340. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10341. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10342. if !m.op.Is(OpUpdateOne) {
  10343. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10344. }
  10345. if m.id == nil || m.oldValue == nil {
  10346. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10347. }
  10348. oldValue, err := m.oldValue(ctx)
  10349. if err != nil {
  10350. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10351. }
  10352. return oldValue.UpdatedAt, nil
  10353. }
  10354. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10355. func (m *ServerMutation) ResetUpdatedAt() {
  10356. m.updated_at = nil
  10357. }
  10358. // SetStatus sets the "status" field.
  10359. func (m *ServerMutation) SetStatus(u uint8) {
  10360. m.status = &u
  10361. m.addstatus = nil
  10362. }
  10363. // Status returns the value of the "status" field in the mutation.
  10364. func (m *ServerMutation) Status() (r uint8, exists bool) {
  10365. v := m.status
  10366. if v == nil {
  10367. return
  10368. }
  10369. return *v, true
  10370. }
  10371. // OldStatus returns the old "status" field's value of the Server entity.
  10372. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  10373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10374. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  10375. if !m.op.Is(OpUpdateOne) {
  10376. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10377. }
  10378. if m.id == nil || m.oldValue == nil {
  10379. return v, errors.New("OldStatus requires an ID field in the mutation")
  10380. }
  10381. oldValue, err := m.oldValue(ctx)
  10382. if err != nil {
  10383. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10384. }
  10385. return oldValue.Status, nil
  10386. }
  10387. // AddStatus adds u to the "status" field.
  10388. func (m *ServerMutation) AddStatus(u int8) {
  10389. if m.addstatus != nil {
  10390. *m.addstatus += u
  10391. } else {
  10392. m.addstatus = &u
  10393. }
  10394. }
  10395. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10396. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  10397. v := m.addstatus
  10398. if v == nil {
  10399. return
  10400. }
  10401. return *v, true
  10402. }
  10403. // ClearStatus clears the value of the "status" field.
  10404. func (m *ServerMutation) ClearStatus() {
  10405. m.status = nil
  10406. m.addstatus = nil
  10407. m.clearedFields[server.FieldStatus] = struct{}{}
  10408. }
  10409. // StatusCleared returns if the "status" field was cleared in this mutation.
  10410. func (m *ServerMutation) StatusCleared() bool {
  10411. _, ok := m.clearedFields[server.FieldStatus]
  10412. return ok
  10413. }
  10414. // ResetStatus resets all changes to the "status" field.
  10415. func (m *ServerMutation) ResetStatus() {
  10416. m.status = nil
  10417. m.addstatus = nil
  10418. delete(m.clearedFields, server.FieldStatus)
  10419. }
  10420. // SetDeletedAt sets the "deleted_at" field.
  10421. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  10422. m.deleted_at = &t
  10423. }
  10424. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10425. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  10426. v := m.deleted_at
  10427. if v == nil {
  10428. return
  10429. }
  10430. return *v, true
  10431. }
  10432. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  10433. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  10434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10435. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10436. if !m.op.Is(OpUpdateOne) {
  10437. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10438. }
  10439. if m.id == nil || m.oldValue == nil {
  10440. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10441. }
  10442. oldValue, err := m.oldValue(ctx)
  10443. if err != nil {
  10444. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10445. }
  10446. return oldValue.DeletedAt, nil
  10447. }
  10448. // ClearDeletedAt clears the value of the "deleted_at" field.
  10449. func (m *ServerMutation) ClearDeletedAt() {
  10450. m.deleted_at = nil
  10451. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  10452. }
  10453. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10454. func (m *ServerMutation) DeletedAtCleared() bool {
  10455. _, ok := m.clearedFields[server.FieldDeletedAt]
  10456. return ok
  10457. }
  10458. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10459. func (m *ServerMutation) ResetDeletedAt() {
  10460. m.deleted_at = nil
  10461. delete(m.clearedFields, server.FieldDeletedAt)
  10462. }
  10463. // SetName sets the "name" field.
  10464. func (m *ServerMutation) SetName(s string) {
  10465. m.name = &s
  10466. }
  10467. // Name returns the value of the "name" field in the mutation.
  10468. func (m *ServerMutation) Name() (r string, exists bool) {
  10469. v := m.name
  10470. if v == nil {
  10471. return
  10472. }
  10473. return *v, true
  10474. }
  10475. // OldName returns the old "name" field's value of the Server entity.
  10476. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  10477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10478. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  10479. if !m.op.Is(OpUpdateOne) {
  10480. return v, errors.New("OldName is only allowed on UpdateOne operations")
  10481. }
  10482. if m.id == nil || m.oldValue == nil {
  10483. return v, errors.New("OldName requires an ID field in the mutation")
  10484. }
  10485. oldValue, err := m.oldValue(ctx)
  10486. if err != nil {
  10487. return v, fmt.Errorf("querying old value for OldName: %w", err)
  10488. }
  10489. return oldValue.Name, nil
  10490. }
  10491. // ResetName resets all changes to the "name" field.
  10492. func (m *ServerMutation) ResetName() {
  10493. m.name = nil
  10494. }
  10495. // SetPublicIP sets the "public_ip" field.
  10496. func (m *ServerMutation) SetPublicIP(s string) {
  10497. m.public_ip = &s
  10498. }
  10499. // PublicIP returns the value of the "public_ip" field in the mutation.
  10500. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  10501. v := m.public_ip
  10502. if v == nil {
  10503. return
  10504. }
  10505. return *v, true
  10506. }
  10507. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  10508. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  10509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10510. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  10511. if !m.op.Is(OpUpdateOne) {
  10512. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  10513. }
  10514. if m.id == nil || m.oldValue == nil {
  10515. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  10516. }
  10517. oldValue, err := m.oldValue(ctx)
  10518. if err != nil {
  10519. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  10520. }
  10521. return oldValue.PublicIP, nil
  10522. }
  10523. // ResetPublicIP resets all changes to the "public_ip" field.
  10524. func (m *ServerMutation) ResetPublicIP() {
  10525. m.public_ip = nil
  10526. }
  10527. // SetPrivateIP sets the "private_ip" field.
  10528. func (m *ServerMutation) SetPrivateIP(s string) {
  10529. m.private_ip = &s
  10530. }
  10531. // PrivateIP returns the value of the "private_ip" field in the mutation.
  10532. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  10533. v := m.private_ip
  10534. if v == nil {
  10535. return
  10536. }
  10537. return *v, true
  10538. }
  10539. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  10540. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  10541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10542. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  10543. if !m.op.Is(OpUpdateOne) {
  10544. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  10545. }
  10546. if m.id == nil || m.oldValue == nil {
  10547. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  10548. }
  10549. oldValue, err := m.oldValue(ctx)
  10550. if err != nil {
  10551. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  10552. }
  10553. return oldValue.PrivateIP, nil
  10554. }
  10555. // ResetPrivateIP resets all changes to the "private_ip" field.
  10556. func (m *ServerMutation) ResetPrivateIP() {
  10557. m.private_ip = nil
  10558. }
  10559. // SetAdminPort sets the "admin_port" field.
  10560. func (m *ServerMutation) SetAdminPort(s string) {
  10561. m.admin_port = &s
  10562. }
  10563. // AdminPort returns the value of the "admin_port" field in the mutation.
  10564. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  10565. v := m.admin_port
  10566. if v == nil {
  10567. return
  10568. }
  10569. return *v, true
  10570. }
  10571. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  10572. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  10573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10574. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  10575. if !m.op.Is(OpUpdateOne) {
  10576. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  10577. }
  10578. if m.id == nil || m.oldValue == nil {
  10579. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  10580. }
  10581. oldValue, err := m.oldValue(ctx)
  10582. if err != nil {
  10583. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  10584. }
  10585. return oldValue.AdminPort, nil
  10586. }
  10587. // ResetAdminPort resets all changes to the "admin_port" field.
  10588. func (m *ServerMutation) ResetAdminPort() {
  10589. m.admin_port = nil
  10590. }
  10591. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  10592. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  10593. if m.wxs == nil {
  10594. m.wxs = make(map[uint64]struct{})
  10595. }
  10596. for i := range ids {
  10597. m.wxs[ids[i]] = struct{}{}
  10598. }
  10599. }
  10600. // ClearWxs clears the "wxs" edge to the Wx entity.
  10601. func (m *ServerMutation) ClearWxs() {
  10602. m.clearedwxs = true
  10603. }
  10604. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  10605. func (m *ServerMutation) WxsCleared() bool {
  10606. return m.clearedwxs
  10607. }
  10608. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  10609. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  10610. if m.removedwxs == nil {
  10611. m.removedwxs = make(map[uint64]struct{})
  10612. }
  10613. for i := range ids {
  10614. delete(m.wxs, ids[i])
  10615. m.removedwxs[ids[i]] = struct{}{}
  10616. }
  10617. }
  10618. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  10619. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  10620. for id := range m.removedwxs {
  10621. ids = append(ids, id)
  10622. }
  10623. return
  10624. }
  10625. // WxsIDs returns the "wxs" edge IDs in the mutation.
  10626. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  10627. for id := range m.wxs {
  10628. ids = append(ids, id)
  10629. }
  10630. return
  10631. }
  10632. // ResetWxs resets all changes to the "wxs" edge.
  10633. func (m *ServerMutation) ResetWxs() {
  10634. m.wxs = nil
  10635. m.clearedwxs = false
  10636. m.removedwxs = nil
  10637. }
  10638. // Where appends a list predicates to the ServerMutation builder.
  10639. func (m *ServerMutation) Where(ps ...predicate.Server) {
  10640. m.predicates = append(m.predicates, ps...)
  10641. }
  10642. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  10643. // users can use type-assertion to append predicates that do not depend on any generated package.
  10644. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  10645. p := make([]predicate.Server, len(ps))
  10646. for i := range ps {
  10647. p[i] = ps[i]
  10648. }
  10649. m.Where(p...)
  10650. }
  10651. // Op returns the operation name.
  10652. func (m *ServerMutation) Op() Op {
  10653. return m.op
  10654. }
  10655. // SetOp allows setting the mutation operation.
  10656. func (m *ServerMutation) SetOp(op Op) {
  10657. m.op = op
  10658. }
  10659. // Type returns the node type of this mutation (Server).
  10660. func (m *ServerMutation) Type() string {
  10661. return m.typ
  10662. }
  10663. // Fields returns all fields that were changed during this mutation. Note that in
  10664. // order to get all numeric fields that were incremented/decremented, call
  10665. // AddedFields().
  10666. func (m *ServerMutation) Fields() []string {
  10667. fields := make([]string, 0, 8)
  10668. if m.created_at != nil {
  10669. fields = append(fields, server.FieldCreatedAt)
  10670. }
  10671. if m.updated_at != nil {
  10672. fields = append(fields, server.FieldUpdatedAt)
  10673. }
  10674. if m.status != nil {
  10675. fields = append(fields, server.FieldStatus)
  10676. }
  10677. if m.deleted_at != nil {
  10678. fields = append(fields, server.FieldDeletedAt)
  10679. }
  10680. if m.name != nil {
  10681. fields = append(fields, server.FieldName)
  10682. }
  10683. if m.public_ip != nil {
  10684. fields = append(fields, server.FieldPublicIP)
  10685. }
  10686. if m.private_ip != nil {
  10687. fields = append(fields, server.FieldPrivateIP)
  10688. }
  10689. if m.admin_port != nil {
  10690. fields = append(fields, server.FieldAdminPort)
  10691. }
  10692. return fields
  10693. }
  10694. // Field returns the value of a field with the given name. The second boolean
  10695. // return value indicates that this field was not set, or was not defined in the
  10696. // schema.
  10697. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  10698. switch name {
  10699. case server.FieldCreatedAt:
  10700. return m.CreatedAt()
  10701. case server.FieldUpdatedAt:
  10702. return m.UpdatedAt()
  10703. case server.FieldStatus:
  10704. return m.Status()
  10705. case server.FieldDeletedAt:
  10706. return m.DeletedAt()
  10707. case server.FieldName:
  10708. return m.Name()
  10709. case server.FieldPublicIP:
  10710. return m.PublicIP()
  10711. case server.FieldPrivateIP:
  10712. return m.PrivateIP()
  10713. case server.FieldAdminPort:
  10714. return m.AdminPort()
  10715. }
  10716. return nil, false
  10717. }
  10718. // OldField returns the old value of the field from the database. An error is
  10719. // returned if the mutation operation is not UpdateOne, or the query to the
  10720. // database failed.
  10721. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10722. switch name {
  10723. case server.FieldCreatedAt:
  10724. return m.OldCreatedAt(ctx)
  10725. case server.FieldUpdatedAt:
  10726. return m.OldUpdatedAt(ctx)
  10727. case server.FieldStatus:
  10728. return m.OldStatus(ctx)
  10729. case server.FieldDeletedAt:
  10730. return m.OldDeletedAt(ctx)
  10731. case server.FieldName:
  10732. return m.OldName(ctx)
  10733. case server.FieldPublicIP:
  10734. return m.OldPublicIP(ctx)
  10735. case server.FieldPrivateIP:
  10736. return m.OldPrivateIP(ctx)
  10737. case server.FieldAdminPort:
  10738. return m.OldAdminPort(ctx)
  10739. }
  10740. return nil, fmt.Errorf("unknown Server field %s", name)
  10741. }
  10742. // SetField sets the value of a field with the given name. It returns an error if
  10743. // the field is not defined in the schema, or if the type mismatched the field
  10744. // type.
  10745. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  10746. switch name {
  10747. case server.FieldCreatedAt:
  10748. v, ok := value.(time.Time)
  10749. if !ok {
  10750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10751. }
  10752. m.SetCreatedAt(v)
  10753. return nil
  10754. case server.FieldUpdatedAt:
  10755. v, ok := value.(time.Time)
  10756. if !ok {
  10757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10758. }
  10759. m.SetUpdatedAt(v)
  10760. return nil
  10761. case server.FieldStatus:
  10762. v, ok := value.(uint8)
  10763. if !ok {
  10764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10765. }
  10766. m.SetStatus(v)
  10767. return nil
  10768. case server.FieldDeletedAt:
  10769. v, ok := value.(time.Time)
  10770. if !ok {
  10771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10772. }
  10773. m.SetDeletedAt(v)
  10774. return nil
  10775. case server.FieldName:
  10776. v, ok := value.(string)
  10777. if !ok {
  10778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10779. }
  10780. m.SetName(v)
  10781. return nil
  10782. case server.FieldPublicIP:
  10783. v, ok := value.(string)
  10784. if !ok {
  10785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10786. }
  10787. m.SetPublicIP(v)
  10788. return nil
  10789. case server.FieldPrivateIP:
  10790. v, ok := value.(string)
  10791. if !ok {
  10792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10793. }
  10794. m.SetPrivateIP(v)
  10795. return nil
  10796. case server.FieldAdminPort:
  10797. v, ok := value.(string)
  10798. if !ok {
  10799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10800. }
  10801. m.SetAdminPort(v)
  10802. return nil
  10803. }
  10804. return fmt.Errorf("unknown Server field %s", name)
  10805. }
  10806. // AddedFields returns all numeric fields that were incremented/decremented during
  10807. // this mutation.
  10808. func (m *ServerMutation) AddedFields() []string {
  10809. var fields []string
  10810. if m.addstatus != nil {
  10811. fields = append(fields, server.FieldStatus)
  10812. }
  10813. return fields
  10814. }
  10815. // AddedField returns the numeric value that was incremented/decremented on a field
  10816. // with the given name. The second boolean return value indicates that this field
  10817. // was not set, or was not defined in the schema.
  10818. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  10819. switch name {
  10820. case server.FieldStatus:
  10821. return m.AddedStatus()
  10822. }
  10823. return nil, false
  10824. }
  10825. // AddField adds the value to the field with the given name. It returns an error if
  10826. // the field is not defined in the schema, or if the type mismatched the field
  10827. // type.
  10828. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  10829. switch name {
  10830. case server.FieldStatus:
  10831. v, ok := value.(int8)
  10832. if !ok {
  10833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10834. }
  10835. m.AddStatus(v)
  10836. return nil
  10837. }
  10838. return fmt.Errorf("unknown Server numeric field %s", name)
  10839. }
  10840. // ClearedFields returns all nullable fields that were cleared during this
  10841. // mutation.
  10842. func (m *ServerMutation) ClearedFields() []string {
  10843. var fields []string
  10844. if m.FieldCleared(server.FieldStatus) {
  10845. fields = append(fields, server.FieldStatus)
  10846. }
  10847. if m.FieldCleared(server.FieldDeletedAt) {
  10848. fields = append(fields, server.FieldDeletedAt)
  10849. }
  10850. return fields
  10851. }
  10852. // FieldCleared returns a boolean indicating if a field with the given name was
  10853. // cleared in this mutation.
  10854. func (m *ServerMutation) FieldCleared(name string) bool {
  10855. _, ok := m.clearedFields[name]
  10856. return ok
  10857. }
  10858. // ClearField clears the value of the field with the given name. It returns an
  10859. // error if the field is not defined in the schema.
  10860. func (m *ServerMutation) ClearField(name string) error {
  10861. switch name {
  10862. case server.FieldStatus:
  10863. m.ClearStatus()
  10864. return nil
  10865. case server.FieldDeletedAt:
  10866. m.ClearDeletedAt()
  10867. return nil
  10868. }
  10869. return fmt.Errorf("unknown Server nullable field %s", name)
  10870. }
  10871. // ResetField resets all changes in the mutation for the field with the given name.
  10872. // It returns an error if the field is not defined in the schema.
  10873. func (m *ServerMutation) ResetField(name string) error {
  10874. switch name {
  10875. case server.FieldCreatedAt:
  10876. m.ResetCreatedAt()
  10877. return nil
  10878. case server.FieldUpdatedAt:
  10879. m.ResetUpdatedAt()
  10880. return nil
  10881. case server.FieldStatus:
  10882. m.ResetStatus()
  10883. return nil
  10884. case server.FieldDeletedAt:
  10885. m.ResetDeletedAt()
  10886. return nil
  10887. case server.FieldName:
  10888. m.ResetName()
  10889. return nil
  10890. case server.FieldPublicIP:
  10891. m.ResetPublicIP()
  10892. return nil
  10893. case server.FieldPrivateIP:
  10894. m.ResetPrivateIP()
  10895. return nil
  10896. case server.FieldAdminPort:
  10897. m.ResetAdminPort()
  10898. return nil
  10899. }
  10900. return fmt.Errorf("unknown Server field %s", name)
  10901. }
  10902. // AddedEdges returns all edge names that were set/added in this mutation.
  10903. func (m *ServerMutation) AddedEdges() []string {
  10904. edges := make([]string, 0, 1)
  10905. if m.wxs != nil {
  10906. edges = append(edges, server.EdgeWxs)
  10907. }
  10908. return edges
  10909. }
  10910. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10911. // name in this mutation.
  10912. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  10913. switch name {
  10914. case server.EdgeWxs:
  10915. ids := make([]ent.Value, 0, len(m.wxs))
  10916. for id := range m.wxs {
  10917. ids = append(ids, id)
  10918. }
  10919. return ids
  10920. }
  10921. return nil
  10922. }
  10923. // RemovedEdges returns all edge names that were removed in this mutation.
  10924. func (m *ServerMutation) RemovedEdges() []string {
  10925. edges := make([]string, 0, 1)
  10926. if m.removedwxs != nil {
  10927. edges = append(edges, server.EdgeWxs)
  10928. }
  10929. return edges
  10930. }
  10931. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10932. // the given name in this mutation.
  10933. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  10934. switch name {
  10935. case server.EdgeWxs:
  10936. ids := make([]ent.Value, 0, len(m.removedwxs))
  10937. for id := range m.removedwxs {
  10938. ids = append(ids, id)
  10939. }
  10940. return ids
  10941. }
  10942. return nil
  10943. }
  10944. // ClearedEdges returns all edge names that were cleared in this mutation.
  10945. func (m *ServerMutation) ClearedEdges() []string {
  10946. edges := make([]string, 0, 1)
  10947. if m.clearedwxs {
  10948. edges = append(edges, server.EdgeWxs)
  10949. }
  10950. return edges
  10951. }
  10952. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10953. // was cleared in this mutation.
  10954. func (m *ServerMutation) EdgeCleared(name string) bool {
  10955. switch name {
  10956. case server.EdgeWxs:
  10957. return m.clearedwxs
  10958. }
  10959. return false
  10960. }
  10961. // ClearEdge clears the value of the edge with the given name. It returns an error
  10962. // if that edge is not defined in the schema.
  10963. func (m *ServerMutation) ClearEdge(name string) error {
  10964. switch name {
  10965. }
  10966. return fmt.Errorf("unknown Server unique edge %s", name)
  10967. }
  10968. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10969. // It returns an error if the edge is not defined in the schema.
  10970. func (m *ServerMutation) ResetEdge(name string) error {
  10971. switch name {
  10972. case server.EdgeWxs:
  10973. m.ResetWxs()
  10974. return nil
  10975. }
  10976. return fmt.Errorf("unknown Server edge %s", name)
  10977. }
  10978. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  10979. type SopNodeMutation struct {
  10980. config
  10981. op Op
  10982. typ string
  10983. id *uint64
  10984. created_at *time.Time
  10985. updated_at *time.Time
  10986. status *uint8
  10987. addstatus *int8
  10988. deleted_at *time.Time
  10989. parent_id *uint64
  10990. addparent_id *int64
  10991. name *string
  10992. condition_type *int
  10993. addcondition_type *int
  10994. condition_list *[]string
  10995. appendcondition_list []string
  10996. no_reply_condition *uint64
  10997. addno_reply_condition *int64
  10998. action_message *[]custom_types.Action
  10999. appendaction_message []custom_types.Action
  11000. action_label *[]uint64
  11001. appendaction_label []uint64
  11002. clearedFields map[string]struct{}
  11003. sop_stage *uint64
  11004. clearedsop_stage bool
  11005. node_messages map[uint64]struct{}
  11006. removednode_messages map[uint64]struct{}
  11007. clearednode_messages bool
  11008. done bool
  11009. oldValue func(context.Context) (*SopNode, error)
  11010. predicates []predicate.SopNode
  11011. }
  11012. var _ ent.Mutation = (*SopNodeMutation)(nil)
  11013. // sopnodeOption allows management of the mutation configuration using functional options.
  11014. type sopnodeOption func(*SopNodeMutation)
  11015. // newSopNodeMutation creates new mutation for the SopNode entity.
  11016. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  11017. m := &SopNodeMutation{
  11018. config: c,
  11019. op: op,
  11020. typ: TypeSopNode,
  11021. clearedFields: make(map[string]struct{}),
  11022. }
  11023. for _, opt := range opts {
  11024. opt(m)
  11025. }
  11026. return m
  11027. }
  11028. // withSopNodeID sets the ID field of the mutation.
  11029. func withSopNodeID(id uint64) sopnodeOption {
  11030. return func(m *SopNodeMutation) {
  11031. var (
  11032. err error
  11033. once sync.Once
  11034. value *SopNode
  11035. )
  11036. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  11037. once.Do(func() {
  11038. if m.done {
  11039. err = errors.New("querying old values post mutation is not allowed")
  11040. } else {
  11041. value, err = m.Client().SopNode.Get(ctx, id)
  11042. }
  11043. })
  11044. return value, err
  11045. }
  11046. m.id = &id
  11047. }
  11048. }
  11049. // withSopNode sets the old SopNode of the mutation.
  11050. func withSopNode(node *SopNode) sopnodeOption {
  11051. return func(m *SopNodeMutation) {
  11052. m.oldValue = func(context.Context) (*SopNode, error) {
  11053. return node, nil
  11054. }
  11055. m.id = &node.ID
  11056. }
  11057. }
  11058. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11059. // executed in a transaction (ent.Tx), a transactional client is returned.
  11060. func (m SopNodeMutation) Client() *Client {
  11061. client := &Client{config: m.config}
  11062. client.init()
  11063. return client
  11064. }
  11065. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11066. // it returns an error otherwise.
  11067. func (m SopNodeMutation) Tx() (*Tx, error) {
  11068. if _, ok := m.driver.(*txDriver); !ok {
  11069. return nil, errors.New("ent: mutation is not running in a transaction")
  11070. }
  11071. tx := &Tx{config: m.config}
  11072. tx.init()
  11073. return tx, nil
  11074. }
  11075. // SetID sets the value of the id field. Note that this
  11076. // operation is only accepted on creation of SopNode entities.
  11077. func (m *SopNodeMutation) SetID(id uint64) {
  11078. m.id = &id
  11079. }
  11080. // ID returns the ID value in the mutation. Note that the ID is only available
  11081. // if it was provided to the builder or after it was returned from the database.
  11082. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  11083. if m.id == nil {
  11084. return
  11085. }
  11086. return *m.id, true
  11087. }
  11088. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11089. // That means, if the mutation is applied within a transaction with an isolation level such
  11090. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11091. // or updated by the mutation.
  11092. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  11093. switch {
  11094. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11095. id, exists := m.ID()
  11096. if exists {
  11097. return []uint64{id}, nil
  11098. }
  11099. fallthrough
  11100. case m.op.Is(OpUpdate | OpDelete):
  11101. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  11102. default:
  11103. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11104. }
  11105. }
  11106. // SetCreatedAt sets the "created_at" field.
  11107. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  11108. m.created_at = &t
  11109. }
  11110. // CreatedAt returns the value of the "created_at" field in the mutation.
  11111. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  11112. v := m.created_at
  11113. if v == nil {
  11114. return
  11115. }
  11116. return *v, true
  11117. }
  11118. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  11119. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11121. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11122. if !m.op.Is(OpUpdateOne) {
  11123. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11124. }
  11125. if m.id == nil || m.oldValue == nil {
  11126. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11127. }
  11128. oldValue, err := m.oldValue(ctx)
  11129. if err != nil {
  11130. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11131. }
  11132. return oldValue.CreatedAt, nil
  11133. }
  11134. // ResetCreatedAt resets all changes to the "created_at" field.
  11135. func (m *SopNodeMutation) ResetCreatedAt() {
  11136. m.created_at = nil
  11137. }
  11138. // SetUpdatedAt sets the "updated_at" field.
  11139. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  11140. m.updated_at = &t
  11141. }
  11142. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11143. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  11144. v := m.updated_at
  11145. if v == nil {
  11146. return
  11147. }
  11148. return *v, true
  11149. }
  11150. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  11151. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11153. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11154. if !m.op.Is(OpUpdateOne) {
  11155. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11156. }
  11157. if m.id == nil || m.oldValue == nil {
  11158. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11159. }
  11160. oldValue, err := m.oldValue(ctx)
  11161. if err != nil {
  11162. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11163. }
  11164. return oldValue.UpdatedAt, nil
  11165. }
  11166. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11167. func (m *SopNodeMutation) ResetUpdatedAt() {
  11168. m.updated_at = nil
  11169. }
  11170. // SetStatus sets the "status" field.
  11171. func (m *SopNodeMutation) SetStatus(u uint8) {
  11172. m.status = &u
  11173. m.addstatus = nil
  11174. }
  11175. // Status returns the value of the "status" field in the mutation.
  11176. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  11177. v := m.status
  11178. if v == nil {
  11179. return
  11180. }
  11181. return *v, true
  11182. }
  11183. // OldStatus returns the old "status" field's value of the SopNode entity.
  11184. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11186. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11187. if !m.op.Is(OpUpdateOne) {
  11188. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11189. }
  11190. if m.id == nil || m.oldValue == nil {
  11191. return v, errors.New("OldStatus requires an ID field in the mutation")
  11192. }
  11193. oldValue, err := m.oldValue(ctx)
  11194. if err != nil {
  11195. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11196. }
  11197. return oldValue.Status, nil
  11198. }
  11199. // AddStatus adds u to the "status" field.
  11200. func (m *SopNodeMutation) AddStatus(u int8) {
  11201. if m.addstatus != nil {
  11202. *m.addstatus += u
  11203. } else {
  11204. m.addstatus = &u
  11205. }
  11206. }
  11207. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11208. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  11209. v := m.addstatus
  11210. if v == nil {
  11211. return
  11212. }
  11213. return *v, true
  11214. }
  11215. // ClearStatus clears the value of the "status" field.
  11216. func (m *SopNodeMutation) ClearStatus() {
  11217. m.status = nil
  11218. m.addstatus = nil
  11219. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  11220. }
  11221. // StatusCleared returns if the "status" field was cleared in this mutation.
  11222. func (m *SopNodeMutation) StatusCleared() bool {
  11223. _, ok := m.clearedFields[sopnode.FieldStatus]
  11224. return ok
  11225. }
  11226. // ResetStatus resets all changes to the "status" field.
  11227. func (m *SopNodeMutation) ResetStatus() {
  11228. m.status = nil
  11229. m.addstatus = nil
  11230. delete(m.clearedFields, sopnode.FieldStatus)
  11231. }
  11232. // SetDeletedAt sets the "deleted_at" field.
  11233. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  11234. m.deleted_at = &t
  11235. }
  11236. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11237. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  11238. v := m.deleted_at
  11239. if v == nil {
  11240. return
  11241. }
  11242. return *v, true
  11243. }
  11244. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  11245. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11247. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11248. if !m.op.Is(OpUpdateOne) {
  11249. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11250. }
  11251. if m.id == nil || m.oldValue == nil {
  11252. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11253. }
  11254. oldValue, err := m.oldValue(ctx)
  11255. if err != nil {
  11256. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11257. }
  11258. return oldValue.DeletedAt, nil
  11259. }
  11260. // ClearDeletedAt clears the value of the "deleted_at" field.
  11261. func (m *SopNodeMutation) ClearDeletedAt() {
  11262. m.deleted_at = nil
  11263. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  11264. }
  11265. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11266. func (m *SopNodeMutation) DeletedAtCleared() bool {
  11267. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  11268. return ok
  11269. }
  11270. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11271. func (m *SopNodeMutation) ResetDeletedAt() {
  11272. m.deleted_at = nil
  11273. delete(m.clearedFields, sopnode.FieldDeletedAt)
  11274. }
  11275. // SetStageID sets the "stage_id" field.
  11276. func (m *SopNodeMutation) SetStageID(u uint64) {
  11277. m.sop_stage = &u
  11278. }
  11279. // StageID returns the value of the "stage_id" field in the mutation.
  11280. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  11281. v := m.sop_stage
  11282. if v == nil {
  11283. return
  11284. }
  11285. return *v, true
  11286. }
  11287. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  11288. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11290. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  11291. if !m.op.Is(OpUpdateOne) {
  11292. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  11293. }
  11294. if m.id == nil || m.oldValue == nil {
  11295. return v, errors.New("OldStageID requires an ID field in the mutation")
  11296. }
  11297. oldValue, err := m.oldValue(ctx)
  11298. if err != nil {
  11299. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  11300. }
  11301. return oldValue.StageID, nil
  11302. }
  11303. // ResetStageID resets all changes to the "stage_id" field.
  11304. func (m *SopNodeMutation) ResetStageID() {
  11305. m.sop_stage = nil
  11306. }
  11307. // SetParentID sets the "parent_id" field.
  11308. func (m *SopNodeMutation) SetParentID(u uint64) {
  11309. m.parent_id = &u
  11310. m.addparent_id = nil
  11311. }
  11312. // ParentID returns the value of the "parent_id" field in the mutation.
  11313. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  11314. v := m.parent_id
  11315. if v == nil {
  11316. return
  11317. }
  11318. return *v, true
  11319. }
  11320. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  11321. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11322. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11323. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  11324. if !m.op.Is(OpUpdateOne) {
  11325. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  11326. }
  11327. if m.id == nil || m.oldValue == nil {
  11328. return v, errors.New("OldParentID requires an ID field in the mutation")
  11329. }
  11330. oldValue, err := m.oldValue(ctx)
  11331. if err != nil {
  11332. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  11333. }
  11334. return oldValue.ParentID, nil
  11335. }
  11336. // AddParentID adds u to the "parent_id" field.
  11337. func (m *SopNodeMutation) AddParentID(u int64) {
  11338. if m.addparent_id != nil {
  11339. *m.addparent_id += u
  11340. } else {
  11341. m.addparent_id = &u
  11342. }
  11343. }
  11344. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  11345. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  11346. v := m.addparent_id
  11347. if v == nil {
  11348. return
  11349. }
  11350. return *v, true
  11351. }
  11352. // ResetParentID resets all changes to the "parent_id" field.
  11353. func (m *SopNodeMutation) ResetParentID() {
  11354. m.parent_id = nil
  11355. m.addparent_id = nil
  11356. }
  11357. // SetName sets the "name" field.
  11358. func (m *SopNodeMutation) SetName(s string) {
  11359. m.name = &s
  11360. }
  11361. // Name returns the value of the "name" field in the mutation.
  11362. func (m *SopNodeMutation) Name() (r string, exists bool) {
  11363. v := m.name
  11364. if v == nil {
  11365. return
  11366. }
  11367. return *v, true
  11368. }
  11369. // OldName returns the old "name" field's value of the SopNode entity.
  11370. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11372. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  11373. if !m.op.Is(OpUpdateOne) {
  11374. return v, errors.New("OldName is only allowed on UpdateOne operations")
  11375. }
  11376. if m.id == nil || m.oldValue == nil {
  11377. return v, errors.New("OldName requires an ID field in the mutation")
  11378. }
  11379. oldValue, err := m.oldValue(ctx)
  11380. if err != nil {
  11381. return v, fmt.Errorf("querying old value for OldName: %w", err)
  11382. }
  11383. return oldValue.Name, nil
  11384. }
  11385. // ResetName resets all changes to the "name" field.
  11386. func (m *SopNodeMutation) ResetName() {
  11387. m.name = nil
  11388. }
  11389. // SetConditionType sets the "condition_type" field.
  11390. func (m *SopNodeMutation) SetConditionType(i int) {
  11391. m.condition_type = &i
  11392. m.addcondition_type = nil
  11393. }
  11394. // ConditionType returns the value of the "condition_type" field in the mutation.
  11395. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  11396. v := m.condition_type
  11397. if v == nil {
  11398. return
  11399. }
  11400. return *v, true
  11401. }
  11402. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  11403. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11405. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  11406. if !m.op.Is(OpUpdateOne) {
  11407. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  11408. }
  11409. if m.id == nil || m.oldValue == nil {
  11410. return v, errors.New("OldConditionType requires an ID field in the mutation")
  11411. }
  11412. oldValue, err := m.oldValue(ctx)
  11413. if err != nil {
  11414. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  11415. }
  11416. return oldValue.ConditionType, nil
  11417. }
  11418. // AddConditionType adds i to the "condition_type" field.
  11419. func (m *SopNodeMutation) AddConditionType(i int) {
  11420. if m.addcondition_type != nil {
  11421. *m.addcondition_type += i
  11422. } else {
  11423. m.addcondition_type = &i
  11424. }
  11425. }
  11426. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  11427. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  11428. v := m.addcondition_type
  11429. if v == nil {
  11430. return
  11431. }
  11432. return *v, true
  11433. }
  11434. // ResetConditionType resets all changes to the "condition_type" field.
  11435. func (m *SopNodeMutation) ResetConditionType() {
  11436. m.condition_type = nil
  11437. m.addcondition_type = nil
  11438. }
  11439. // SetConditionList sets the "condition_list" field.
  11440. func (m *SopNodeMutation) SetConditionList(s []string) {
  11441. m.condition_list = &s
  11442. m.appendcondition_list = nil
  11443. }
  11444. // ConditionList returns the value of the "condition_list" field in the mutation.
  11445. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  11446. v := m.condition_list
  11447. if v == nil {
  11448. return
  11449. }
  11450. return *v, true
  11451. }
  11452. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  11453. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11455. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  11456. if !m.op.Is(OpUpdateOne) {
  11457. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  11458. }
  11459. if m.id == nil || m.oldValue == nil {
  11460. return v, errors.New("OldConditionList requires an ID field in the mutation")
  11461. }
  11462. oldValue, err := m.oldValue(ctx)
  11463. if err != nil {
  11464. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  11465. }
  11466. return oldValue.ConditionList, nil
  11467. }
  11468. // AppendConditionList adds s to the "condition_list" field.
  11469. func (m *SopNodeMutation) AppendConditionList(s []string) {
  11470. m.appendcondition_list = append(m.appendcondition_list, s...)
  11471. }
  11472. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  11473. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  11474. if len(m.appendcondition_list) == 0 {
  11475. return nil, false
  11476. }
  11477. return m.appendcondition_list, true
  11478. }
  11479. // ClearConditionList clears the value of the "condition_list" field.
  11480. func (m *SopNodeMutation) ClearConditionList() {
  11481. m.condition_list = nil
  11482. m.appendcondition_list = nil
  11483. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  11484. }
  11485. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  11486. func (m *SopNodeMutation) ConditionListCleared() bool {
  11487. _, ok := m.clearedFields[sopnode.FieldConditionList]
  11488. return ok
  11489. }
  11490. // ResetConditionList resets all changes to the "condition_list" field.
  11491. func (m *SopNodeMutation) ResetConditionList() {
  11492. m.condition_list = nil
  11493. m.appendcondition_list = nil
  11494. delete(m.clearedFields, sopnode.FieldConditionList)
  11495. }
  11496. // SetNoReplyCondition sets the "no_reply_condition" field.
  11497. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  11498. m.no_reply_condition = &u
  11499. m.addno_reply_condition = nil
  11500. }
  11501. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  11502. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  11503. v := m.no_reply_condition
  11504. if v == nil {
  11505. return
  11506. }
  11507. return *v, true
  11508. }
  11509. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  11510. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11512. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  11513. if !m.op.Is(OpUpdateOne) {
  11514. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  11515. }
  11516. if m.id == nil || m.oldValue == nil {
  11517. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  11518. }
  11519. oldValue, err := m.oldValue(ctx)
  11520. if err != nil {
  11521. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  11522. }
  11523. return oldValue.NoReplyCondition, nil
  11524. }
  11525. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  11526. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  11527. if m.addno_reply_condition != nil {
  11528. *m.addno_reply_condition += u
  11529. } else {
  11530. m.addno_reply_condition = &u
  11531. }
  11532. }
  11533. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  11534. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  11535. v := m.addno_reply_condition
  11536. if v == nil {
  11537. return
  11538. }
  11539. return *v, true
  11540. }
  11541. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  11542. func (m *SopNodeMutation) ResetNoReplyCondition() {
  11543. m.no_reply_condition = nil
  11544. m.addno_reply_condition = nil
  11545. }
  11546. // SetActionMessage sets the "action_message" field.
  11547. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  11548. m.action_message = &ct
  11549. m.appendaction_message = nil
  11550. }
  11551. // ActionMessage returns the value of the "action_message" field in the mutation.
  11552. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  11553. v := m.action_message
  11554. if v == nil {
  11555. return
  11556. }
  11557. return *v, true
  11558. }
  11559. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  11560. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11562. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  11563. if !m.op.Is(OpUpdateOne) {
  11564. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  11565. }
  11566. if m.id == nil || m.oldValue == nil {
  11567. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  11568. }
  11569. oldValue, err := m.oldValue(ctx)
  11570. if err != nil {
  11571. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  11572. }
  11573. return oldValue.ActionMessage, nil
  11574. }
  11575. // AppendActionMessage adds ct to the "action_message" field.
  11576. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  11577. m.appendaction_message = append(m.appendaction_message, ct...)
  11578. }
  11579. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  11580. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  11581. if len(m.appendaction_message) == 0 {
  11582. return nil, false
  11583. }
  11584. return m.appendaction_message, true
  11585. }
  11586. // ClearActionMessage clears the value of the "action_message" field.
  11587. func (m *SopNodeMutation) ClearActionMessage() {
  11588. m.action_message = nil
  11589. m.appendaction_message = nil
  11590. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  11591. }
  11592. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  11593. func (m *SopNodeMutation) ActionMessageCleared() bool {
  11594. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  11595. return ok
  11596. }
  11597. // ResetActionMessage resets all changes to the "action_message" field.
  11598. func (m *SopNodeMutation) ResetActionMessage() {
  11599. m.action_message = nil
  11600. m.appendaction_message = nil
  11601. delete(m.clearedFields, sopnode.FieldActionMessage)
  11602. }
  11603. // SetActionLabel sets the "action_label" field.
  11604. func (m *SopNodeMutation) SetActionLabel(u []uint64) {
  11605. m.action_label = &u
  11606. m.appendaction_label = nil
  11607. }
  11608. // ActionLabel returns the value of the "action_label" field in the mutation.
  11609. func (m *SopNodeMutation) ActionLabel() (r []uint64, exists bool) {
  11610. v := m.action_label
  11611. if v == nil {
  11612. return
  11613. }
  11614. return *v, true
  11615. }
  11616. // OldActionLabel returns the old "action_label" field's value of the SopNode entity.
  11617. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11619. func (m *SopNodeMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  11620. if !m.op.Is(OpUpdateOne) {
  11621. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  11622. }
  11623. if m.id == nil || m.oldValue == nil {
  11624. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  11625. }
  11626. oldValue, err := m.oldValue(ctx)
  11627. if err != nil {
  11628. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  11629. }
  11630. return oldValue.ActionLabel, nil
  11631. }
  11632. // AppendActionLabel adds u to the "action_label" field.
  11633. func (m *SopNodeMutation) AppendActionLabel(u []uint64) {
  11634. m.appendaction_label = append(m.appendaction_label, u...)
  11635. }
  11636. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  11637. func (m *SopNodeMutation) AppendedActionLabel() ([]uint64, bool) {
  11638. if len(m.appendaction_label) == 0 {
  11639. return nil, false
  11640. }
  11641. return m.appendaction_label, true
  11642. }
  11643. // ClearActionLabel clears the value of the "action_label" field.
  11644. func (m *SopNodeMutation) ClearActionLabel() {
  11645. m.action_label = nil
  11646. m.appendaction_label = nil
  11647. m.clearedFields[sopnode.FieldActionLabel] = struct{}{}
  11648. }
  11649. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  11650. func (m *SopNodeMutation) ActionLabelCleared() bool {
  11651. _, ok := m.clearedFields[sopnode.FieldActionLabel]
  11652. return ok
  11653. }
  11654. // ResetActionLabel resets all changes to the "action_label" field.
  11655. func (m *SopNodeMutation) ResetActionLabel() {
  11656. m.action_label = nil
  11657. m.appendaction_label = nil
  11658. delete(m.clearedFields, sopnode.FieldActionLabel)
  11659. }
  11660. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  11661. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  11662. m.sop_stage = &id
  11663. }
  11664. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  11665. func (m *SopNodeMutation) ClearSopStage() {
  11666. m.clearedsop_stage = true
  11667. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  11668. }
  11669. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  11670. func (m *SopNodeMutation) SopStageCleared() bool {
  11671. return m.clearedsop_stage
  11672. }
  11673. // SopStageID returns the "sop_stage" edge ID in the mutation.
  11674. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  11675. if m.sop_stage != nil {
  11676. return *m.sop_stage, true
  11677. }
  11678. return
  11679. }
  11680. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  11681. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  11682. // SopStageID instead. It exists only for internal usage by the builders.
  11683. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  11684. if id := m.sop_stage; id != nil {
  11685. ids = append(ids, *id)
  11686. }
  11687. return
  11688. }
  11689. // ResetSopStage resets all changes to the "sop_stage" edge.
  11690. func (m *SopNodeMutation) ResetSopStage() {
  11691. m.sop_stage = nil
  11692. m.clearedsop_stage = false
  11693. }
  11694. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  11695. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  11696. if m.node_messages == nil {
  11697. m.node_messages = make(map[uint64]struct{})
  11698. }
  11699. for i := range ids {
  11700. m.node_messages[ids[i]] = struct{}{}
  11701. }
  11702. }
  11703. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  11704. func (m *SopNodeMutation) ClearNodeMessages() {
  11705. m.clearednode_messages = true
  11706. }
  11707. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  11708. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  11709. return m.clearednode_messages
  11710. }
  11711. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  11712. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  11713. if m.removednode_messages == nil {
  11714. m.removednode_messages = make(map[uint64]struct{})
  11715. }
  11716. for i := range ids {
  11717. delete(m.node_messages, ids[i])
  11718. m.removednode_messages[ids[i]] = struct{}{}
  11719. }
  11720. }
  11721. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  11722. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  11723. for id := range m.removednode_messages {
  11724. ids = append(ids, id)
  11725. }
  11726. return
  11727. }
  11728. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  11729. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  11730. for id := range m.node_messages {
  11731. ids = append(ids, id)
  11732. }
  11733. return
  11734. }
  11735. // ResetNodeMessages resets all changes to the "node_messages" edge.
  11736. func (m *SopNodeMutation) ResetNodeMessages() {
  11737. m.node_messages = nil
  11738. m.clearednode_messages = false
  11739. m.removednode_messages = nil
  11740. }
  11741. // Where appends a list predicates to the SopNodeMutation builder.
  11742. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  11743. m.predicates = append(m.predicates, ps...)
  11744. }
  11745. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  11746. // users can use type-assertion to append predicates that do not depend on any generated package.
  11747. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  11748. p := make([]predicate.SopNode, len(ps))
  11749. for i := range ps {
  11750. p[i] = ps[i]
  11751. }
  11752. m.Where(p...)
  11753. }
  11754. // Op returns the operation name.
  11755. func (m *SopNodeMutation) Op() Op {
  11756. return m.op
  11757. }
  11758. // SetOp allows setting the mutation operation.
  11759. func (m *SopNodeMutation) SetOp(op Op) {
  11760. m.op = op
  11761. }
  11762. // Type returns the node type of this mutation (SopNode).
  11763. func (m *SopNodeMutation) Type() string {
  11764. return m.typ
  11765. }
  11766. // Fields returns all fields that were changed during this mutation. Note that in
  11767. // order to get all numeric fields that were incremented/decremented, call
  11768. // AddedFields().
  11769. func (m *SopNodeMutation) Fields() []string {
  11770. fields := make([]string, 0, 12)
  11771. if m.created_at != nil {
  11772. fields = append(fields, sopnode.FieldCreatedAt)
  11773. }
  11774. if m.updated_at != nil {
  11775. fields = append(fields, sopnode.FieldUpdatedAt)
  11776. }
  11777. if m.status != nil {
  11778. fields = append(fields, sopnode.FieldStatus)
  11779. }
  11780. if m.deleted_at != nil {
  11781. fields = append(fields, sopnode.FieldDeletedAt)
  11782. }
  11783. if m.sop_stage != nil {
  11784. fields = append(fields, sopnode.FieldStageID)
  11785. }
  11786. if m.parent_id != nil {
  11787. fields = append(fields, sopnode.FieldParentID)
  11788. }
  11789. if m.name != nil {
  11790. fields = append(fields, sopnode.FieldName)
  11791. }
  11792. if m.condition_type != nil {
  11793. fields = append(fields, sopnode.FieldConditionType)
  11794. }
  11795. if m.condition_list != nil {
  11796. fields = append(fields, sopnode.FieldConditionList)
  11797. }
  11798. if m.no_reply_condition != nil {
  11799. fields = append(fields, sopnode.FieldNoReplyCondition)
  11800. }
  11801. if m.action_message != nil {
  11802. fields = append(fields, sopnode.FieldActionMessage)
  11803. }
  11804. if m.action_label != nil {
  11805. fields = append(fields, sopnode.FieldActionLabel)
  11806. }
  11807. return fields
  11808. }
  11809. // Field returns the value of a field with the given name. The second boolean
  11810. // return value indicates that this field was not set, or was not defined in the
  11811. // schema.
  11812. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  11813. switch name {
  11814. case sopnode.FieldCreatedAt:
  11815. return m.CreatedAt()
  11816. case sopnode.FieldUpdatedAt:
  11817. return m.UpdatedAt()
  11818. case sopnode.FieldStatus:
  11819. return m.Status()
  11820. case sopnode.FieldDeletedAt:
  11821. return m.DeletedAt()
  11822. case sopnode.FieldStageID:
  11823. return m.StageID()
  11824. case sopnode.FieldParentID:
  11825. return m.ParentID()
  11826. case sopnode.FieldName:
  11827. return m.Name()
  11828. case sopnode.FieldConditionType:
  11829. return m.ConditionType()
  11830. case sopnode.FieldConditionList:
  11831. return m.ConditionList()
  11832. case sopnode.FieldNoReplyCondition:
  11833. return m.NoReplyCondition()
  11834. case sopnode.FieldActionMessage:
  11835. return m.ActionMessage()
  11836. case sopnode.FieldActionLabel:
  11837. return m.ActionLabel()
  11838. }
  11839. return nil, false
  11840. }
  11841. // OldField returns the old value of the field from the database. An error is
  11842. // returned if the mutation operation is not UpdateOne, or the query to the
  11843. // database failed.
  11844. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11845. switch name {
  11846. case sopnode.FieldCreatedAt:
  11847. return m.OldCreatedAt(ctx)
  11848. case sopnode.FieldUpdatedAt:
  11849. return m.OldUpdatedAt(ctx)
  11850. case sopnode.FieldStatus:
  11851. return m.OldStatus(ctx)
  11852. case sopnode.FieldDeletedAt:
  11853. return m.OldDeletedAt(ctx)
  11854. case sopnode.FieldStageID:
  11855. return m.OldStageID(ctx)
  11856. case sopnode.FieldParentID:
  11857. return m.OldParentID(ctx)
  11858. case sopnode.FieldName:
  11859. return m.OldName(ctx)
  11860. case sopnode.FieldConditionType:
  11861. return m.OldConditionType(ctx)
  11862. case sopnode.FieldConditionList:
  11863. return m.OldConditionList(ctx)
  11864. case sopnode.FieldNoReplyCondition:
  11865. return m.OldNoReplyCondition(ctx)
  11866. case sopnode.FieldActionMessage:
  11867. return m.OldActionMessage(ctx)
  11868. case sopnode.FieldActionLabel:
  11869. return m.OldActionLabel(ctx)
  11870. }
  11871. return nil, fmt.Errorf("unknown SopNode field %s", name)
  11872. }
  11873. // SetField sets the value of a field with the given name. It returns an error if
  11874. // the field is not defined in the schema, or if the type mismatched the field
  11875. // type.
  11876. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  11877. switch name {
  11878. case sopnode.FieldCreatedAt:
  11879. v, ok := value.(time.Time)
  11880. if !ok {
  11881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11882. }
  11883. m.SetCreatedAt(v)
  11884. return nil
  11885. case sopnode.FieldUpdatedAt:
  11886. v, ok := value.(time.Time)
  11887. if !ok {
  11888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11889. }
  11890. m.SetUpdatedAt(v)
  11891. return nil
  11892. case sopnode.FieldStatus:
  11893. v, ok := value.(uint8)
  11894. if !ok {
  11895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11896. }
  11897. m.SetStatus(v)
  11898. return nil
  11899. case sopnode.FieldDeletedAt:
  11900. v, ok := value.(time.Time)
  11901. if !ok {
  11902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11903. }
  11904. m.SetDeletedAt(v)
  11905. return nil
  11906. case sopnode.FieldStageID:
  11907. v, ok := value.(uint64)
  11908. if !ok {
  11909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11910. }
  11911. m.SetStageID(v)
  11912. return nil
  11913. case sopnode.FieldParentID:
  11914. v, ok := value.(uint64)
  11915. if !ok {
  11916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11917. }
  11918. m.SetParentID(v)
  11919. return nil
  11920. case sopnode.FieldName:
  11921. v, ok := value.(string)
  11922. if !ok {
  11923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11924. }
  11925. m.SetName(v)
  11926. return nil
  11927. case sopnode.FieldConditionType:
  11928. v, ok := value.(int)
  11929. if !ok {
  11930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11931. }
  11932. m.SetConditionType(v)
  11933. return nil
  11934. case sopnode.FieldConditionList:
  11935. v, ok := value.([]string)
  11936. if !ok {
  11937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11938. }
  11939. m.SetConditionList(v)
  11940. return nil
  11941. case sopnode.FieldNoReplyCondition:
  11942. v, ok := value.(uint64)
  11943. if !ok {
  11944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11945. }
  11946. m.SetNoReplyCondition(v)
  11947. return nil
  11948. case sopnode.FieldActionMessage:
  11949. v, ok := value.([]custom_types.Action)
  11950. if !ok {
  11951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11952. }
  11953. m.SetActionMessage(v)
  11954. return nil
  11955. case sopnode.FieldActionLabel:
  11956. v, ok := value.([]uint64)
  11957. if !ok {
  11958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11959. }
  11960. m.SetActionLabel(v)
  11961. return nil
  11962. }
  11963. return fmt.Errorf("unknown SopNode field %s", name)
  11964. }
  11965. // AddedFields returns all numeric fields that were incremented/decremented during
  11966. // this mutation.
  11967. func (m *SopNodeMutation) AddedFields() []string {
  11968. var fields []string
  11969. if m.addstatus != nil {
  11970. fields = append(fields, sopnode.FieldStatus)
  11971. }
  11972. if m.addparent_id != nil {
  11973. fields = append(fields, sopnode.FieldParentID)
  11974. }
  11975. if m.addcondition_type != nil {
  11976. fields = append(fields, sopnode.FieldConditionType)
  11977. }
  11978. if m.addno_reply_condition != nil {
  11979. fields = append(fields, sopnode.FieldNoReplyCondition)
  11980. }
  11981. return fields
  11982. }
  11983. // AddedField returns the numeric value that was incremented/decremented on a field
  11984. // with the given name. The second boolean return value indicates that this field
  11985. // was not set, or was not defined in the schema.
  11986. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  11987. switch name {
  11988. case sopnode.FieldStatus:
  11989. return m.AddedStatus()
  11990. case sopnode.FieldParentID:
  11991. return m.AddedParentID()
  11992. case sopnode.FieldConditionType:
  11993. return m.AddedConditionType()
  11994. case sopnode.FieldNoReplyCondition:
  11995. return m.AddedNoReplyCondition()
  11996. }
  11997. return nil, false
  11998. }
  11999. // AddField adds the value to the field with the given name. It returns an error if
  12000. // the field is not defined in the schema, or if the type mismatched the field
  12001. // type.
  12002. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  12003. switch name {
  12004. case sopnode.FieldStatus:
  12005. v, ok := value.(int8)
  12006. if !ok {
  12007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12008. }
  12009. m.AddStatus(v)
  12010. return nil
  12011. case sopnode.FieldParentID:
  12012. v, ok := value.(int64)
  12013. if !ok {
  12014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12015. }
  12016. m.AddParentID(v)
  12017. return nil
  12018. case sopnode.FieldConditionType:
  12019. v, ok := value.(int)
  12020. if !ok {
  12021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12022. }
  12023. m.AddConditionType(v)
  12024. return nil
  12025. case sopnode.FieldNoReplyCondition:
  12026. v, ok := value.(int64)
  12027. if !ok {
  12028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12029. }
  12030. m.AddNoReplyCondition(v)
  12031. return nil
  12032. }
  12033. return fmt.Errorf("unknown SopNode numeric field %s", name)
  12034. }
  12035. // ClearedFields returns all nullable fields that were cleared during this
  12036. // mutation.
  12037. func (m *SopNodeMutation) ClearedFields() []string {
  12038. var fields []string
  12039. if m.FieldCleared(sopnode.FieldStatus) {
  12040. fields = append(fields, sopnode.FieldStatus)
  12041. }
  12042. if m.FieldCleared(sopnode.FieldDeletedAt) {
  12043. fields = append(fields, sopnode.FieldDeletedAt)
  12044. }
  12045. if m.FieldCleared(sopnode.FieldConditionList) {
  12046. fields = append(fields, sopnode.FieldConditionList)
  12047. }
  12048. if m.FieldCleared(sopnode.FieldActionMessage) {
  12049. fields = append(fields, sopnode.FieldActionMessage)
  12050. }
  12051. if m.FieldCleared(sopnode.FieldActionLabel) {
  12052. fields = append(fields, sopnode.FieldActionLabel)
  12053. }
  12054. return fields
  12055. }
  12056. // FieldCleared returns a boolean indicating if a field with the given name was
  12057. // cleared in this mutation.
  12058. func (m *SopNodeMutation) FieldCleared(name string) bool {
  12059. _, ok := m.clearedFields[name]
  12060. return ok
  12061. }
  12062. // ClearField clears the value of the field with the given name. It returns an
  12063. // error if the field is not defined in the schema.
  12064. func (m *SopNodeMutation) ClearField(name string) error {
  12065. switch name {
  12066. case sopnode.FieldStatus:
  12067. m.ClearStatus()
  12068. return nil
  12069. case sopnode.FieldDeletedAt:
  12070. m.ClearDeletedAt()
  12071. return nil
  12072. case sopnode.FieldConditionList:
  12073. m.ClearConditionList()
  12074. return nil
  12075. case sopnode.FieldActionMessage:
  12076. m.ClearActionMessage()
  12077. return nil
  12078. case sopnode.FieldActionLabel:
  12079. m.ClearActionLabel()
  12080. return nil
  12081. }
  12082. return fmt.Errorf("unknown SopNode nullable field %s", name)
  12083. }
  12084. // ResetField resets all changes in the mutation for the field with the given name.
  12085. // It returns an error if the field is not defined in the schema.
  12086. func (m *SopNodeMutation) ResetField(name string) error {
  12087. switch name {
  12088. case sopnode.FieldCreatedAt:
  12089. m.ResetCreatedAt()
  12090. return nil
  12091. case sopnode.FieldUpdatedAt:
  12092. m.ResetUpdatedAt()
  12093. return nil
  12094. case sopnode.FieldStatus:
  12095. m.ResetStatus()
  12096. return nil
  12097. case sopnode.FieldDeletedAt:
  12098. m.ResetDeletedAt()
  12099. return nil
  12100. case sopnode.FieldStageID:
  12101. m.ResetStageID()
  12102. return nil
  12103. case sopnode.FieldParentID:
  12104. m.ResetParentID()
  12105. return nil
  12106. case sopnode.FieldName:
  12107. m.ResetName()
  12108. return nil
  12109. case sopnode.FieldConditionType:
  12110. m.ResetConditionType()
  12111. return nil
  12112. case sopnode.FieldConditionList:
  12113. m.ResetConditionList()
  12114. return nil
  12115. case sopnode.FieldNoReplyCondition:
  12116. m.ResetNoReplyCondition()
  12117. return nil
  12118. case sopnode.FieldActionMessage:
  12119. m.ResetActionMessage()
  12120. return nil
  12121. case sopnode.FieldActionLabel:
  12122. m.ResetActionLabel()
  12123. return nil
  12124. }
  12125. return fmt.Errorf("unknown SopNode field %s", name)
  12126. }
  12127. // AddedEdges returns all edge names that were set/added in this mutation.
  12128. func (m *SopNodeMutation) AddedEdges() []string {
  12129. edges := make([]string, 0, 2)
  12130. if m.sop_stage != nil {
  12131. edges = append(edges, sopnode.EdgeSopStage)
  12132. }
  12133. if m.node_messages != nil {
  12134. edges = append(edges, sopnode.EdgeNodeMessages)
  12135. }
  12136. return edges
  12137. }
  12138. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12139. // name in this mutation.
  12140. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  12141. switch name {
  12142. case sopnode.EdgeSopStage:
  12143. if id := m.sop_stage; id != nil {
  12144. return []ent.Value{*id}
  12145. }
  12146. case sopnode.EdgeNodeMessages:
  12147. ids := make([]ent.Value, 0, len(m.node_messages))
  12148. for id := range m.node_messages {
  12149. ids = append(ids, id)
  12150. }
  12151. return ids
  12152. }
  12153. return nil
  12154. }
  12155. // RemovedEdges returns all edge names that were removed in this mutation.
  12156. func (m *SopNodeMutation) RemovedEdges() []string {
  12157. edges := make([]string, 0, 2)
  12158. if m.removednode_messages != nil {
  12159. edges = append(edges, sopnode.EdgeNodeMessages)
  12160. }
  12161. return edges
  12162. }
  12163. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12164. // the given name in this mutation.
  12165. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  12166. switch name {
  12167. case sopnode.EdgeNodeMessages:
  12168. ids := make([]ent.Value, 0, len(m.removednode_messages))
  12169. for id := range m.removednode_messages {
  12170. ids = append(ids, id)
  12171. }
  12172. return ids
  12173. }
  12174. return nil
  12175. }
  12176. // ClearedEdges returns all edge names that were cleared in this mutation.
  12177. func (m *SopNodeMutation) ClearedEdges() []string {
  12178. edges := make([]string, 0, 2)
  12179. if m.clearedsop_stage {
  12180. edges = append(edges, sopnode.EdgeSopStage)
  12181. }
  12182. if m.clearednode_messages {
  12183. edges = append(edges, sopnode.EdgeNodeMessages)
  12184. }
  12185. return edges
  12186. }
  12187. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12188. // was cleared in this mutation.
  12189. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  12190. switch name {
  12191. case sopnode.EdgeSopStage:
  12192. return m.clearedsop_stage
  12193. case sopnode.EdgeNodeMessages:
  12194. return m.clearednode_messages
  12195. }
  12196. return false
  12197. }
  12198. // ClearEdge clears the value of the edge with the given name. It returns an error
  12199. // if that edge is not defined in the schema.
  12200. func (m *SopNodeMutation) ClearEdge(name string) error {
  12201. switch name {
  12202. case sopnode.EdgeSopStage:
  12203. m.ClearSopStage()
  12204. return nil
  12205. }
  12206. return fmt.Errorf("unknown SopNode unique edge %s", name)
  12207. }
  12208. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12209. // It returns an error if the edge is not defined in the schema.
  12210. func (m *SopNodeMutation) ResetEdge(name string) error {
  12211. switch name {
  12212. case sopnode.EdgeSopStage:
  12213. m.ResetSopStage()
  12214. return nil
  12215. case sopnode.EdgeNodeMessages:
  12216. m.ResetNodeMessages()
  12217. return nil
  12218. }
  12219. return fmt.Errorf("unknown SopNode edge %s", name)
  12220. }
  12221. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  12222. type SopStageMutation struct {
  12223. config
  12224. op Op
  12225. typ string
  12226. id *uint64
  12227. created_at *time.Time
  12228. updated_at *time.Time
  12229. status *uint8
  12230. addstatus *int8
  12231. deleted_at *time.Time
  12232. name *string
  12233. condition_type *int
  12234. addcondition_type *int
  12235. condition_operator *int
  12236. addcondition_operator *int
  12237. condition_list *[]custom_types.Condition
  12238. appendcondition_list []custom_types.Condition
  12239. action_message *[]custom_types.Action
  12240. appendaction_message []custom_types.Action
  12241. action_label *[]uint64
  12242. appendaction_label []uint64
  12243. index_sort *int
  12244. addindex_sort *int
  12245. clearedFields map[string]struct{}
  12246. sop_task *uint64
  12247. clearedsop_task bool
  12248. stage_nodes map[uint64]struct{}
  12249. removedstage_nodes map[uint64]struct{}
  12250. clearedstage_nodes bool
  12251. stage_messages map[uint64]struct{}
  12252. removedstage_messages map[uint64]struct{}
  12253. clearedstage_messages bool
  12254. done bool
  12255. oldValue func(context.Context) (*SopStage, error)
  12256. predicates []predicate.SopStage
  12257. }
  12258. var _ ent.Mutation = (*SopStageMutation)(nil)
  12259. // sopstageOption allows management of the mutation configuration using functional options.
  12260. type sopstageOption func(*SopStageMutation)
  12261. // newSopStageMutation creates new mutation for the SopStage entity.
  12262. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  12263. m := &SopStageMutation{
  12264. config: c,
  12265. op: op,
  12266. typ: TypeSopStage,
  12267. clearedFields: make(map[string]struct{}),
  12268. }
  12269. for _, opt := range opts {
  12270. opt(m)
  12271. }
  12272. return m
  12273. }
  12274. // withSopStageID sets the ID field of the mutation.
  12275. func withSopStageID(id uint64) sopstageOption {
  12276. return func(m *SopStageMutation) {
  12277. var (
  12278. err error
  12279. once sync.Once
  12280. value *SopStage
  12281. )
  12282. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  12283. once.Do(func() {
  12284. if m.done {
  12285. err = errors.New("querying old values post mutation is not allowed")
  12286. } else {
  12287. value, err = m.Client().SopStage.Get(ctx, id)
  12288. }
  12289. })
  12290. return value, err
  12291. }
  12292. m.id = &id
  12293. }
  12294. }
  12295. // withSopStage sets the old SopStage of the mutation.
  12296. func withSopStage(node *SopStage) sopstageOption {
  12297. return func(m *SopStageMutation) {
  12298. m.oldValue = func(context.Context) (*SopStage, error) {
  12299. return node, nil
  12300. }
  12301. m.id = &node.ID
  12302. }
  12303. }
  12304. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12305. // executed in a transaction (ent.Tx), a transactional client is returned.
  12306. func (m SopStageMutation) Client() *Client {
  12307. client := &Client{config: m.config}
  12308. client.init()
  12309. return client
  12310. }
  12311. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12312. // it returns an error otherwise.
  12313. func (m SopStageMutation) Tx() (*Tx, error) {
  12314. if _, ok := m.driver.(*txDriver); !ok {
  12315. return nil, errors.New("ent: mutation is not running in a transaction")
  12316. }
  12317. tx := &Tx{config: m.config}
  12318. tx.init()
  12319. return tx, nil
  12320. }
  12321. // SetID sets the value of the id field. Note that this
  12322. // operation is only accepted on creation of SopStage entities.
  12323. func (m *SopStageMutation) SetID(id uint64) {
  12324. m.id = &id
  12325. }
  12326. // ID returns the ID value in the mutation. Note that the ID is only available
  12327. // if it was provided to the builder or after it was returned from the database.
  12328. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  12329. if m.id == nil {
  12330. return
  12331. }
  12332. return *m.id, true
  12333. }
  12334. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12335. // That means, if the mutation is applied within a transaction with an isolation level such
  12336. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12337. // or updated by the mutation.
  12338. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  12339. switch {
  12340. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12341. id, exists := m.ID()
  12342. if exists {
  12343. return []uint64{id}, nil
  12344. }
  12345. fallthrough
  12346. case m.op.Is(OpUpdate | OpDelete):
  12347. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  12348. default:
  12349. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12350. }
  12351. }
  12352. // SetCreatedAt sets the "created_at" field.
  12353. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  12354. m.created_at = &t
  12355. }
  12356. // CreatedAt returns the value of the "created_at" field in the mutation.
  12357. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  12358. v := m.created_at
  12359. if v == nil {
  12360. return
  12361. }
  12362. return *v, true
  12363. }
  12364. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  12365. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12367. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12368. if !m.op.Is(OpUpdateOne) {
  12369. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12370. }
  12371. if m.id == nil || m.oldValue == nil {
  12372. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12373. }
  12374. oldValue, err := m.oldValue(ctx)
  12375. if err != nil {
  12376. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12377. }
  12378. return oldValue.CreatedAt, nil
  12379. }
  12380. // ResetCreatedAt resets all changes to the "created_at" field.
  12381. func (m *SopStageMutation) ResetCreatedAt() {
  12382. m.created_at = nil
  12383. }
  12384. // SetUpdatedAt sets the "updated_at" field.
  12385. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  12386. m.updated_at = &t
  12387. }
  12388. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12389. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  12390. v := m.updated_at
  12391. if v == nil {
  12392. return
  12393. }
  12394. return *v, true
  12395. }
  12396. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  12397. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12399. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12400. if !m.op.Is(OpUpdateOne) {
  12401. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12402. }
  12403. if m.id == nil || m.oldValue == nil {
  12404. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12405. }
  12406. oldValue, err := m.oldValue(ctx)
  12407. if err != nil {
  12408. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12409. }
  12410. return oldValue.UpdatedAt, nil
  12411. }
  12412. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12413. func (m *SopStageMutation) ResetUpdatedAt() {
  12414. m.updated_at = nil
  12415. }
  12416. // SetStatus sets the "status" field.
  12417. func (m *SopStageMutation) SetStatus(u uint8) {
  12418. m.status = &u
  12419. m.addstatus = nil
  12420. }
  12421. // Status returns the value of the "status" field in the mutation.
  12422. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  12423. v := m.status
  12424. if v == nil {
  12425. return
  12426. }
  12427. return *v, true
  12428. }
  12429. // OldStatus returns the old "status" field's value of the SopStage entity.
  12430. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12432. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12433. if !m.op.Is(OpUpdateOne) {
  12434. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12435. }
  12436. if m.id == nil || m.oldValue == nil {
  12437. return v, errors.New("OldStatus requires an ID field in the mutation")
  12438. }
  12439. oldValue, err := m.oldValue(ctx)
  12440. if err != nil {
  12441. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12442. }
  12443. return oldValue.Status, nil
  12444. }
  12445. // AddStatus adds u to the "status" field.
  12446. func (m *SopStageMutation) AddStatus(u int8) {
  12447. if m.addstatus != nil {
  12448. *m.addstatus += u
  12449. } else {
  12450. m.addstatus = &u
  12451. }
  12452. }
  12453. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12454. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  12455. v := m.addstatus
  12456. if v == nil {
  12457. return
  12458. }
  12459. return *v, true
  12460. }
  12461. // ClearStatus clears the value of the "status" field.
  12462. func (m *SopStageMutation) ClearStatus() {
  12463. m.status = nil
  12464. m.addstatus = nil
  12465. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  12466. }
  12467. // StatusCleared returns if the "status" field was cleared in this mutation.
  12468. func (m *SopStageMutation) StatusCleared() bool {
  12469. _, ok := m.clearedFields[sopstage.FieldStatus]
  12470. return ok
  12471. }
  12472. // ResetStatus resets all changes to the "status" field.
  12473. func (m *SopStageMutation) ResetStatus() {
  12474. m.status = nil
  12475. m.addstatus = nil
  12476. delete(m.clearedFields, sopstage.FieldStatus)
  12477. }
  12478. // SetDeletedAt sets the "deleted_at" field.
  12479. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  12480. m.deleted_at = &t
  12481. }
  12482. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12483. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  12484. v := m.deleted_at
  12485. if v == nil {
  12486. return
  12487. }
  12488. return *v, true
  12489. }
  12490. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  12491. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12493. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12494. if !m.op.Is(OpUpdateOne) {
  12495. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12496. }
  12497. if m.id == nil || m.oldValue == nil {
  12498. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12499. }
  12500. oldValue, err := m.oldValue(ctx)
  12501. if err != nil {
  12502. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12503. }
  12504. return oldValue.DeletedAt, nil
  12505. }
  12506. // ClearDeletedAt clears the value of the "deleted_at" field.
  12507. func (m *SopStageMutation) ClearDeletedAt() {
  12508. m.deleted_at = nil
  12509. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  12510. }
  12511. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12512. func (m *SopStageMutation) DeletedAtCleared() bool {
  12513. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  12514. return ok
  12515. }
  12516. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12517. func (m *SopStageMutation) ResetDeletedAt() {
  12518. m.deleted_at = nil
  12519. delete(m.clearedFields, sopstage.FieldDeletedAt)
  12520. }
  12521. // SetTaskID sets the "task_id" field.
  12522. func (m *SopStageMutation) SetTaskID(u uint64) {
  12523. m.sop_task = &u
  12524. }
  12525. // TaskID returns the value of the "task_id" field in the mutation.
  12526. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  12527. v := m.sop_task
  12528. if v == nil {
  12529. return
  12530. }
  12531. return *v, true
  12532. }
  12533. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  12534. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12536. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  12537. if !m.op.Is(OpUpdateOne) {
  12538. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  12539. }
  12540. if m.id == nil || m.oldValue == nil {
  12541. return v, errors.New("OldTaskID requires an ID field in the mutation")
  12542. }
  12543. oldValue, err := m.oldValue(ctx)
  12544. if err != nil {
  12545. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  12546. }
  12547. return oldValue.TaskID, nil
  12548. }
  12549. // ResetTaskID resets all changes to the "task_id" field.
  12550. func (m *SopStageMutation) ResetTaskID() {
  12551. m.sop_task = nil
  12552. }
  12553. // SetName sets the "name" field.
  12554. func (m *SopStageMutation) SetName(s string) {
  12555. m.name = &s
  12556. }
  12557. // Name returns the value of the "name" field in the mutation.
  12558. func (m *SopStageMutation) Name() (r string, exists bool) {
  12559. v := m.name
  12560. if v == nil {
  12561. return
  12562. }
  12563. return *v, true
  12564. }
  12565. // OldName returns the old "name" field's value of the SopStage entity.
  12566. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12568. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  12569. if !m.op.Is(OpUpdateOne) {
  12570. return v, errors.New("OldName is only allowed on UpdateOne operations")
  12571. }
  12572. if m.id == nil || m.oldValue == nil {
  12573. return v, errors.New("OldName requires an ID field in the mutation")
  12574. }
  12575. oldValue, err := m.oldValue(ctx)
  12576. if err != nil {
  12577. return v, fmt.Errorf("querying old value for OldName: %w", err)
  12578. }
  12579. return oldValue.Name, nil
  12580. }
  12581. // ResetName resets all changes to the "name" field.
  12582. func (m *SopStageMutation) ResetName() {
  12583. m.name = nil
  12584. }
  12585. // SetConditionType sets the "condition_type" field.
  12586. func (m *SopStageMutation) SetConditionType(i int) {
  12587. m.condition_type = &i
  12588. m.addcondition_type = nil
  12589. }
  12590. // ConditionType returns the value of the "condition_type" field in the mutation.
  12591. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  12592. v := m.condition_type
  12593. if v == nil {
  12594. return
  12595. }
  12596. return *v, true
  12597. }
  12598. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  12599. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12601. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  12602. if !m.op.Is(OpUpdateOne) {
  12603. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  12604. }
  12605. if m.id == nil || m.oldValue == nil {
  12606. return v, errors.New("OldConditionType requires an ID field in the mutation")
  12607. }
  12608. oldValue, err := m.oldValue(ctx)
  12609. if err != nil {
  12610. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  12611. }
  12612. return oldValue.ConditionType, nil
  12613. }
  12614. // AddConditionType adds i to the "condition_type" field.
  12615. func (m *SopStageMutation) AddConditionType(i int) {
  12616. if m.addcondition_type != nil {
  12617. *m.addcondition_type += i
  12618. } else {
  12619. m.addcondition_type = &i
  12620. }
  12621. }
  12622. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  12623. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  12624. v := m.addcondition_type
  12625. if v == nil {
  12626. return
  12627. }
  12628. return *v, true
  12629. }
  12630. // ResetConditionType resets all changes to the "condition_type" field.
  12631. func (m *SopStageMutation) ResetConditionType() {
  12632. m.condition_type = nil
  12633. m.addcondition_type = nil
  12634. }
  12635. // SetConditionOperator sets the "condition_operator" field.
  12636. func (m *SopStageMutation) SetConditionOperator(i int) {
  12637. m.condition_operator = &i
  12638. m.addcondition_operator = nil
  12639. }
  12640. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  12641. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  12642. v := m.condition_operator
  12643. if v == nil {
  12644. return
  12645. }
  12646. return *v, true
  12647. }
  12648. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  12649. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12651. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  12652. if !m.op.Is(OpUpdateOne) {
  12653. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  12654. }
  12655. if m.id == nil || m.oldValue == nil {
  12656. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  12657. }
  12658. oldValue, err := m.oldValue(ctx)
  12659. if err != nil {
  12660. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  12661. }
  12662. return oldValue.ConditionOperator, nil
  12663. }
  12664. // AddConditionOperator adds i to the "condition_operator" field.
  12665. func (m *SopStageMutation) AddConditionOperator(i int) {
  12666. if m.addcondition_operator != nil {
  12667. *m.addcondition_operator += i
  12668. } else {
  12669. m.addcondition_operator = &i
  12670. }
  12671. }
  12672. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  12673. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  12674. v := m.addcondition_operator
  12675. if v == nil {
  12676. return
  12677. }
  12678. return *v, true
  12679. }
  12680. // ResetConditionOperator resets all changes to the "condition_operator" field.
  12681. func (m *SopStageMutation) ResetConditionOperator() {
  12682. m.condition_operator = nil
  12683. m.addcondition_operator = nil
  12684. }
  12685. // SetConditionList sets the "condition_list" field.
  12686. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  12687. m.condition_list = &ct
  12688. m.appendcondition_list = nil
  12689. }
  12690. // ConditionList returns the value of the "condition_list" field in the mutation.
  12691. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  12692. v := m.condition_list
  12693. if v == nil {
  12694. return
  12695. }
  12696. return *v, true
  12697. }
  12698. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  12699. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12701. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  12702. if !m.op.Is(OpUpdateOne) {
  12703. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  12704. }
  12705. if m.id == nil || m.oldValue == nil {
  12706. return v, errors.New("OldConditionList requires an ID field in the mutation")
  12707. }
  12708. oldValue, err := m.oldValue(ctx)
  12709. if err != nil {
  12710. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  12711. }
  12712. return oldValue.ConditionList, nil
  12713. }
  12714. // AppendConditionList adds ct to the "condition_list" field.
  12715. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  12716. m.appendcondition_list = append(m.appendcondition_list, ct...)
  12717. }
  12718. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  12719. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  12720. if len(m.appendcondition_list) == 0 {
  12721. return nil, false
  12722. }
  12723. return m.appendcondition_list, true
  12724. }
  12725. // ResetConditionList resets all changes to the "condition_list" field.
  12726. func (m *SopStageMutation) ResetConditionList() {
  12727. m.condition_list = nil
  12728. m.appendcondition_list = nil
  12729. }
  12730. // SetActionMessage sets the "action_message" field.
  12731. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  12732. m.action_message = &ct
  12733. m.appendaction_message = nil
  12734. }
  12735. // ActionMessage returns the value of the "action_message" field in the mutation.
  12736. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  12737. v := m.action_message
  12738. if v == nil {
  12739. return
  12740. }
  12741. return *v, true
  12742. }
  12743. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  12744. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12746. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  12747. if !m.op.Is(OpUpdateOne) {
  12748. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  12749. }
  12750. if m.id == nil || m.oldValue == nil {
  12751. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  12752. }
  12753. oldValue, err := m.oldValue(ctx)
  12754. if err != nil {
  12755. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  12756. }
  12757. return oldValue.ActionMessage, nil
  12758. }
  12759. // AppendActionMessage adds ct to the "action_message" field.
  12760. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  12761. m.appendaction_message = append(m.appendaction_message, ct...)
  12762. }
  12763. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  12764. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  12765. if len(m.appendaction_message) == 0 {
  12766. return nil, false
  12767. }
  12768. return m.appendaction_message, true
  12769. }
  12770. // ClearActionMessage clears the value of the "action_message" field.
  12771. func (m *SopStageMutation) ClearActionMessage() {
  12772. m.action_message = nil
  12773. m.appendaction_message = nil
  12774. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  12775. }
  12776. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  12777. func (m *SopStageMutation) ActionMessageCleared() bool {
  12778. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  12779. return ok
  12780. }
  12781. // ResetActionMessage resets all changes to the "action_message" field.
  12782. func (m *SopStageMutation) ResetActionMessage() {
  12783. m.action_message = nil
  12784. m.appendaction_message = nil
  12785. delete(m.clearedFields, sopstage.FieldActionMessage)
  12786. }
  12787. // SetActionLabel sets the "action_label" field.
  12788. func (m *SopStageMutation) SetActionLabel(u []uint64) {
  12789. m.action_label = &u
  12790. m.appendaction_label = nil
  12791. }
  12792. // ActionLabel returns the value of the "action_label" field in the mutation.
  12793. func (m *SopStageMutation) ActionLabel() (r []uint64, exists bool) {
  12794. v := m.action_label
  12795. if v == nil {
  12796. return
  12797. }
  12798. return *v, true
  12799. }
  12800. // OldActionLabel returns the old "action_label" field's value of the SopStage entity.
  12801. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12803. func (m *SopStageMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  12804. if !m.op.Is(OpUpdateOne) {
  12805. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  12806. }
  12807. if m.id == nil || m.oldValue == nil {
  12808. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  12809. }
  12810. oldValue, err := m.oldValue(ctx)
  12811. if err != nil {
  12812. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  12813. }
  12814. return oldValue.ActionLabel, nil
  12815. }
  12816. // AppendActionLabel adds u to the "action_label" field.
  12817. func (m *SopStageMutation) AppendActionLabel(u []uint64) {
  12818. m.appendaction_label = append(m.appendaction_label, u...)
  12819. }
  12820. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  12821. func (m *SopStageMutation) AppendedActionLabel() ([]uint64, bool) {
  12822. if len(m.appendaction_label) == 0 {
  12823. return nil, false
  12824. }
  12825. return m.appendaction_label, true
  12826. }
  12827. // ClearActionLabel clears the value of the "action_label" field.
  12828. func (m *SopStageMutation) ClearActionLabel() {
  12829. m.action_label = nil
  12830. m.appendaction_label = nil
  12831. m.clearedFields[sopstage.FieldActionLabel] = struct{}{}
  12832. }
  12833. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  12834. func (m *SopStageMutation) ActionLabelCleared() bool {
  12835. _, ok := m.clearedFields[sopstage.FieldActionLabel]
  12836. return ok
  12837. }
  12838. // ResetActionLabel resets all changes to the "action_label" field.
  12839. func (m *SopStageMutation) ResetActionLabel() {
  12840. m.action_label = nil
  12841. m.appendaction_label = nil
  12842. delete(m.clearedFields, sopstage.FieldActionLabel)
  12843. }
  12844. // SetIndexSort sets the "index_sort" field.
  12845. func (m *SopStageMutation) SetIndexSort(i int) {
  12846. m.index_sort = &i
  12847. m.addindex_sort = nil
  12848. }
  12849. // IndexSort returns the value of the "index_sort" field in the mutation.
  12850. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  12851. v := m.index_sort
  12852. if v == nil {
  12853. return
  12854. }
  12855. return *v, true
  12856. }
  12857. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  12858. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  12859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12860. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  12861. if !m.op.Is(OpUpdateOne) {
  12862. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  12863. }
  12864. if m.id == nil || m.oldValue == nil {
  12865. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  12866. }
  12867. oldValue, err := m.oldValue(ctx)
  12868. if err != nil {
  12869. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  12870. }
  12871. return oldValue.IndexSort, nil
  12872. }
  12873. // AddIndexSort adds i to the "index_sort" field.
  12874. func (m *SopStageMutation) AddIndexSort(i int) {
  12875. if m.addindex_sort != nil {
  12876. *m.addindex_sort += i
  12877. } else {
  12878. m.addindex_sort = &i
  12879. }
  12880. }
  12881. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  12882. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  12883. v := m.addindex_sort
  12884. if v == nil {
  12885. return
  12886. }
  12887. return *v, true
  12888. }
  12889. // ClearIndexSort clears the value of the "index_sort" field.
  12890. func (m *SopStageMutation) ClearIndexSort() {
  12891. m.index_sort = nil
  12892. m.addindex_sort = nil
  12893. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  12894. }
  12895. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  12896. func (m *SopStageMutation) IndexSortCleared() bool {
  12897. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  12898. return ok
  12899. }
  12900. // ResetIndexSort resets all changes to the "index_sort" field.
  12901. func (m *SopStageMutation) ResetIndexSort() {
  12902. m.index_sort = nil
  12903. m.addindex_sort = nil
  12904. delete(m.clearedFields, sopstage.FieldIndexSort)
  12905. }
  12906. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  12907. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  12908. m.sop_task = &id
  12909. }
  12910. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  12911. func (m *SopStageMutation) ClearSopTask() {
  12912. m.clearedsop_task = true
  12913. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  12914. }
  12915. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  12916. func (m *SopStageMutation) SopTaskCleared() bool {
  12917. return m.clearedsop_task
  12918. }
  12919. // SopTaskID returns the "sop_task" edge ID in the mutation.
  12920. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  12921. if m.sop_task != nil {
  12922. return *m.sop_task, true
  12923. }
  12924. return
  12925. }
  12926. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  12927. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12928. // SopTaskID instead. It exists only for internal usage by the builders.
  12929. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  12930. if id := m.sop_task; id != nil {
  12931. ids = append(ids, *id)
  12932. }
  12933. return
  12934. }
  12935. // ResetSopTask resets all changes to the "sop_task" edge.
  12936. func (m *SopStageMutation) ResetSopTask() {
  12937. m.sop_task = nil
  12938. m.clearedsop_task = false
  12939. }
  12940. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  12941. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  12942. if m.stage_nodes == nil {
  12943. m.stage_nodes = make(map[uint64]struct{})
  12944. }
  12945. for i := range ids {
  12946. m.stage_nodes[ids[i]] = struct{}{}
  12947. }
  12948. }
  12949. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  12950. func (m *SopStageMutation) ClearStageNodes() {
  12951. m.clearedstage_nodes = true
  12952. }
  12953. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  12954. func (m *SopStageMutation) StageNodesCleared() bool {
  12955. return m.clearedstage_nodes
  12956. }
  12957. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  12958. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  12959. if m.removedstage_nodes == nil {
  12960. m.removedstage_nodes = make(map[uint64]struct{})
  12961. }
  12962. for i := range ids {
  12963. delete(m.stage_nodes, ids[i])
  12964. m.removedstage_nodes[ids[i]] = struct{}{}
  12965. }
  12966. }
  12967. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  12968. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  12969. for id := range m.removedstage_nodes {
  12970. ids = append(ids, id)
  12971. }
  12972. return
  12973. }
  12974. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  12975. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  12976. for id := range m.stage_nodes {
  12977. ids = append(ids, id)
  12978. }
  12979. return
  12980. }
  12981. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  12982. func (m *SopStageMutation) ResetStageNodes() {
  12983. m.stage_nodes = nil
  12984. m.clearedstage_nodes = false
  12985. m.removedstage_nodes = nil
  12986. }
  12987. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  12988. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  12989. if m.stage_messages == nil {
  12990. m.stage_messages = make(map[uint64]struct{})
  12991. }
  12992. for i := range ids {
  12993. m.stage_messages[ids[i]] = struct{}{}
  12994. }
  12995. }
  12996. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  12997. func (m *SopStageMutation) ClearStageMessages() {
  12998. m.clearedstage_messages = true
  12999. }
  13000. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  13001. func (m *SopStageMutation) StageMessagesCleared() bool {
  13002. return m.clearedstage_messages
  13003. }
  13004. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  13005. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  13006. if m.removedstage_messages == nil {
  13007. m.removedstage_messages = make(map[uint64]struct{})
  13008. }
  13009. for i := range ids {
  13010. delete(m.stage_messages, ids[i])
  13011. m.removedstage_messages[ids[i]] = struct{}{}
  13012. }
  13013. }
  13014. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  13015. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  13016. for id := range m.removedstage_messages {
  13017. ids = append(ids, id)
  13018. }
  13019. return
  13020. }
  13021. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  13022. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  13023. for id := range m.stage_messages {
  13024. ids = append(ids, id)
  13025. }
  13026. return
  13027. }
  13028. // ResetStageMessages resets all changes to the "stage_messages" edge.
  13029. func (m *SopStageMutation) ResetStageMessages() {
  13030. m.stage_messages = nil
  13031. m.clearedstage_messages = false
  13032. m.removedstage_messages = nil
  13033. }
  13034. // Where appends a list predicates to the SopStageMutation builder.
  13035. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  13036. m.predicates = append(m.predicates, ps...)
  13037. }
  13038. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  13039. // users can use type-assertion to append predicates that do not depend on any generated package.
  13040. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  13041. p := make([]predicate.SopStage, len(ps))
  13042. for i := range ps {
  13043. p[i] = ps[i]
  13044. }
  13045. m.Where(p...)
  13046. }
  13047. // Op returns the operation name.
  13048. func (m *SopStageMutation) Op() Op {
  13049. return m.op
  13050. }
  13051. // SetOp allows setting the mutation operation.
  13052. func (m *SopStageMutation) SetOp(op Op) {
  13053. m.op = op
  13054. }
  13055. // Type returns the node type of this mutation (SopStage).
  13056. func (m *SopStageMutation) Type() string {
  13057. return m.typ
  13058. }
  13059. // Fields returns all fields that were changed during this mutation. Note that in
  13060. // order to get all numeric fields that were incremented/decremented, call
  13061. // AddedFields().
  13062. func (m *SopStageMutation) Fields() []string {
  13063. fields := make([]string, 0, 12)
  13064. if m.created_at != nil {
  13065. fields = append(fields, sopstage.FieldCreatedAt)
  13066. }
  13067. if m.updated_at != nil {
  13068. fields = append(fields, sopstage.FieldUpdatedAt)
  13069. }
  13070. if m.status != nil {
  13071. fields = append(fields, sopstage.FieldStatus)
  13072. }
  13073. if m.deleted_at != nil {
  13074. fields = append(fields, sopstage.FieldDeletedAt)
  13075. }
  13076. if m.sop_task != nil {
  13077. fields = append(fields, sopstage.FieldTaskID)
  13078. }
  13079. if m.name != nil {
  13080. fields = append(fields, sopstage.FieldName)
  13081. }
  13082. if m.condition_type != nil {
  13083. fields = append(fields, sopstage.FieldConditionType)
  13084. }
  13085. if m.condition_operator != nil {
  13086. fields = append(fields, sopstage.FieldConditionOperator)
  13087. }
  13088. if m.condition_list != nil {
  13089. fields = append(fields, sopstage.FieldConditionList)
  13090. }
  13091. if m.action_message != nil {
  13092. fields = append(fields, sopstage.FieldActionMessage)
  13093. }
  13094. if m.action_label != nil {
  13095. fields = append(fields, sopstage.FieldActionLabel)
  13096. }
  13097. if m.index_sort != nil {
  13098. fields = append(fields, sopstage.FieldIndexSort)
  13099. }
  13100. return fields
  13101. }
  13102. // Field returns the value of a field with the given name. The second boolean
  13103. // return value indicates that this field was not set, or was not defined in the
  13104. // schema.
  13105. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  13106. switch name {
  13107. case sopstage.FieldCreatedAt:
  13108. return m.CreatedAt()
  13109. case sopstage.FieldUpdatedAt:
  13110. return m.UpdatedAt()
  13111. case sopstage.FieldStatus:
  13112. return m.Status()
  13113. case sopstage.FieldDeletedAt:
  13114. return m.DeletedAt()
  13115. case sopstage.FieldTaskID:
  13116. return m.TaskID()
  13117. case sopstage.FieldName:
  13118. return m.Name()
  13119. case sopstage.FieldConditionType:
  13120. return m.ConditionType()
  13121. case sopstage.FieldConditionOperator:
  13122. return m.ConditionOperator()
  13123. case sopstage.FieldConditionList:
  13124. return m.ConditionList()
  13125. case sopstage.FieldActionMessage:
  13126. return m.ActionMessage()
  13127. case sopstage.FieldActionLabel:
  13128. return m.ActionLabel()
  13129. case sopstage.FieldIndexSort:
  13130. return m.IndexSort()
  13131. }
  13132. return nil, false
  13133. }
  13134. // OldField returns the old value of the field from the database. An error is
  13135. // returned if the mutation operation is not UpdateOne, or the query to the
  13136. // database failed.
  13137. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13138. switch name {
  13139. case sopstage.FieldCreatedAt:
  13140. return m.OldCreatedAt(ctx)
  13141. case sopstage.FieldUpdatedAt:
  13142. return m.OldUpdatedAt(ctx)
  13143. case sopstage.FieldStatus:
  13144. return m.OldStatus(ctx)
  13145. case sopstage.FieldDeletedAt:
  13146. return m.OldDeletedAt(ctx)
  13147. case sopstage.FieldTaskID:
  13148. return m.OldTaskID(ctx)
  13149. case sopstage.FieldName:
  13150. return m.OldName(ctx)
  13151. case sopstage.FieldConditionType:
  13152. return m.OldConditionType(ctx)
  13153. case sopstage.FieldConditionOperator:
  13154. return m.OldConditionOperator(ctx)
  13155. case sopstage.FieldConditionList:
  13156. return m.OldConditionList(ctx)
  13157. case sopstage.FieldActionMessage:
  13158. return m.OldActionMessage(ctx)
  13159. case sopstage.FieldActionLabel:
  13160. return m.OldActionLabel(ctx)
  13161. case sopstage.FieldIndexSort:
  13162. return m.OldIndexSort(ctx)
  13163. }
  13164. return nil, fmt.Errorf("unknown SopStage field %s", name)
  13165. }
  13166. // SetField sets the value of a field with the given name. It returns an error if
  13167. // the field is not defined in the schema, or if the type mismatched the field
  13168. // type.
  13169. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  13170. switch name {
  13171. case sopstage.FieldCreatedAt:
  13172. v, ok := value.(time.Time)
  13173. if !ok {
  13174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13175. }
  13176. m.SetCreatedAt(v)
  13177. return nil
  13178. case sopstage.FieldUpdatedAt:
  13179. v, ok := value.(time.Time)
  13180. if !ok {
  13181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13182. }
  13183. m.SetUpdatedAt(v)
  13184. return nil
  13185. case sopstage.FieldStatus:
  13186. v, ok := value.(uint8)
  13187. if !ok {
  13188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13189. }
  13190. m.SetStatus(v)
  13191. return nil
  13192. case sopstage.FieldDeletedAt:
  13193. v, ok := value.(time.Time)
  13194. if !ok {
  13195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13196. }
  13197. m.SetDeletedAt(v)
  13198. return nil
  13199. case sopstage.FieldTaskID:
  13200. v, ok := value.(uint64)
  13201. if !ok {
  13202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13203. }
  13204. m.SetTaskID(v)
  13205. return nil
  13206. case sopstage.FieldName:
  13207. v, ok := value.(string)
  13208. if !ok {
  13209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13210. }
  13211. m.SetName(v)
  13212. return nil
  13213. case sopstage.FieldConditionType:
  13214. v, ok := value.(int)
  13215. if !ok {
  13216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13217. }
  13218. m.SetConditionType(v)
  13219. return nil
  13220. case sopstage.FieldConditionOperator:
  13221. v, ok := value.(int)
  13222. if !ok {
  13223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13224. }
  13225. m.SetConditionOperator(v)
  13226. return nil
  13227. case sopstage.FieldConditionList:
  13228. v, ok := value.([]custom_types.Condition)
  13229. if !ok {
  13230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13231. }
  13232. m.SetConditionList(v)
  13233. return nil
  13234. case sopstage.FieldActionMessage:
  13235. v, ok := value.([]custom_types.Action)
  13236. if !ok {
  13237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13238. }
  13239. m.SetActionMessage(v)
  13240. return nil
  13241. case sopstage.FieldActionLabel:
  13242. v, ok := value.([]uint64)
  13243. if !ok {
  13244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13245. }
  13246. m.SetActionLabel(v)
  13247. return nil
  13248. case sopstage.FieldIndexSort:
  13249. v, ok := value.(int)
  13250. if !ok {
  13251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13252. }
  13253. m.SetIndexSort(v)
  13254. return nil
  13255. }
  13256. return fmt.Errorf("unknown SopStage field %s", name)
  13257. }
  13258. // AddedFields returns all numeric fields that were incremented/decremented during
  13259. // this mutation.
  13260. func (m *SopStageMutation) AddedFields() []string {
  13261. var fields []string
  13262. if m.addstatus != nil {
  13263. fields = append(fields, sopstage.FieldStatus)
  13264. }
  13265. if m.addcondition_type != nil {
  13266. fields = append(fields, sopstage.FieldConditionType)
  13267. }
  13268. if m.addcondition_operator != nil {
  13269. fields = append(fields, sopstage.FieldConditionOperator)
  13270. }
  13271. if m.addindex_sort != nil {
  13272. fields = append(fields, sopstage.FieldIndexSort)
  13273. }
  13274. return fields
  13275. }
  13276. // AddedField returns the numeric value that was incremented/decremented on a field
  13277. // with the given name. The second boolean return value indicates that this field
  13278. // was not set, or was not defined in the schema.
  13279. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  13280. switch name {
  13281. case sopstage.FieldStatus:
  13282. return m.AddedStatus()
  13283. case sopstage.FieldConditionType:
  13284. return m.AddedConditionType()
  13285. case sopstage.FieldConditionOperator:
  13286. return m.AddedConditionOperator()
  13287. case sopstage.FieldIndexSort:
  13288. return m.AddedIndexSort()
  13289. }
  13290. return nil, false
  13291. }
  13292. // AddField adds the value to the field with the given name. It returns an error if
  13293. // the field is not defined in the schema, or if the type mismatched the field
  13294. // type.
  13295. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  13296. switch name {
  13297. case sopstage.FieldStatus:
  13298. v, ok := value.(int8)
  13299. if !ok {
  13300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13301. }
  13302. m.AddStatus(v)
  13303. return nil
  13304. case sopstage.FieldConditionType:
  13305. v, ok := value.(int)
  13306. if !ok {
  13307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13308. }
  13309. m.AddConditionType(v)
  13310. return nil
  13311. case sopstage.FieldConditionOperator:
  13312. v, ok := value.(int)
  13313. if !ok {
  13314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13315. }
  13316. m.AddConditionOperator(v)
  13317. return nil
  13318. case sopstage.FieldIndexSort:
  13319. v, ok := value.(int)
  13320. if !ok {
  13321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13322. }
  13323. m.AddIndexSort(v)
  13324. return nil
  13325. }
  13326. return fmt.Errorf("unknown SopStage numeric field %s", name)
  13327. }
  13328. // ClearedFields returns all nullable fields that were cleared during this
  13329. // mutation.
  13330. func (m *SopStageMutation) ClearedFields() []string {
  13331. var fields []string
  13332. if m.FieldCleared(sopstage.FieldStatus) {
  13333. fields = append(fields, sopstage.FieldStatus)
  13334. }
  13335. if m.FieldCleared(sopstage.FieldDeletedAt) {
  13336. fields = append(fields, sopstage.FieldDeletedAt)
  13337. }
  13338. if m.FieldCleared(sopstage.FieldActionMessage) {
  13339. fields = append(fields, sopstage.FieldActionMessage)
  13340. }
  13341. if m.FieldCleared(sopstage.FieldActionLabel) {
  13342. fields = append(fields, sopstage.FieldActionLabel)
  13343. }
  13344. if m.FieldCleared(sopstage.FieldIndexSort) {
  13345. fields = append(fields, sopstage.FieldIndexSort)
  13346. }
  13347. return fields
  13348. }
  13349. // FieldCleared returns a boolean indicating if a field with the given name was
  13350. // cleared in this mutation.
  13351. func (m *SopStageMutation) FieldCleared(name string) bool {
  13352. _, ok := m.clearedFields[name]
  13353. return ok
  13354. }
  13355. // ClearField clears the value of the field with the given name. It returns an
  13356. // error if the field is not defined in the schema.
  13357. func (m *SopStageMutation) ClearField(name string) error {
  13358. switch name {
  13359. case sopstage.FieldStatus:
  13360. m.ClearStatus()
  13361. return nil
  13362. case sopstage.FieldDeletedAt:
  13363. m.ClearDeletedAt()
  13364. return nil
  13365. case sopstage.FieldActionMessage:
  13366. m.ClearActionMessage()
  13367. return nil
  13368. case sopstage.FieldActionLabel:
  13369. m.ClearActionLabel()
  13370. return nil
  13371. case sopstage.FieldIndexSort:
  13372. m.ClearIndexSort()
  13373. return nil
  13374. }
  13375. return fmt.Errorf("unknown SopStage nullable field %s", name)
  13376. }
  13377. // ResetField resets all changes in the mutation for the field with the given name.
  13378. // It returns an error if the field is not defined in the schema.
  13379. func (m *SopStageMutation) ResetField(name string) error {
  13380. switch name {
  13381. case sopstage.FieldCreatedAt:
  13382. m.ResetCreatedAt()
  13383. return nil
  13384. case sopstage.FieldUpdatedAt:
  13385. m.ResetUpdatedAt()
  13386. return nil
  13387. case sopstage.FieldStatus:
  13388. m.ResetStatus()
  13389. return nil
  13390. case sopstage.FieldDeletedAt:
  13391. m.ResetDeletedAt()
  13392. return nil
  13393. case sopstage.FieldTaskID:
  13394. m.ResetTaskID()
  13395. return nil
  13396. case sopstage.FieldName:
  13397. m.ResetName()
  13398. return nil
  13399. case sopstage.FieldConditionType:
  13400. m.ResetConditionType()
  13401. return nil
  13402. case sopstage.FieldConditionOperator:
  13403. m.ResetConditionOperator()
  13404. return nil
  13405. case sopstage.FieldConditionList:
  13406. m.ResetConditionList()
  13407. return nil
  13408. case sopstage.FieldActionMessage:
  13409. m.ResetActionMessage()
  13410. return nil
  13411. case sopstage.FieldActionLabel:
  13412. m.ResetActionLabel()
  13413. return nil
  13414. case sopstage.FieldIndexSort:
  13415. m.ResetIndexSort()
  13416. return nil
  13417. }
  13418. return fmt.Errorf("unknown SopStage field %s", name)
  13419. }
  13420. // AddedEdges returns all edge names that were set/added in this mutation.
  13421. func (m *SopStageMutation) AddedEdges() []string {
  13422. edges := make([]string, 0, 3)
  13423. if m.sop_task != nil {
  13424. edges = append(edges, sopstage.EdgeSopTask)
  13425. }
  13426. if m.stage_nodes != nil {
  13427. edges = append(edges, sopstage.EdgeStageNodes)
  13428. }
  13429. if m.stage_messages != nil {
  13430. edges = append(edges, sopstage.EdgeStageMessages)
  13431. }
  13432. return edges
  13433. }
  13434. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13435. // name in this mutation.
  13436. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  13437. switch name {
  13438. case sopstage.EdgeSopTask:
  13439. if id := m.sop_task; id != nil {
  13440. return []ent.Value{*id}
  13441. }
  13442. case sopstage.EdgeStageNodes:
  13443. ids := make([]ent.Value, 0, len(m.stage_nodes))
  13444. for id := range m.stage_nodes {
  13445. ids = append(ids, id)
  13446. }
  13447. return ids
  13448. case sopstage.EdgeStageMessages:
  13449. ids := make([]ent.Value, 0, len(m.stage_messages))
  13450. for id := range m.stage_messages {
  13451. ids = append(ids, id)
  13452. }
  13453. return ids
  13454. }
  13455. return nil
  13456. }
  13457. // RemovedEdges returns all edge names that were removed in this mutation.
  13458. func (m *SopStageMutation) RemovedEdges() []string {
  13459. edges := make([]string, 0, 3)
  13460. if m.removedstage_nodes != nil {
  13461. edges = append(edges, sopstage.EdgeStageNodes)
  13462. }
  13463. if m.removedstage_messages != nil {
  13464. edges = append(edges, sopstage.EdgeStageMessages)
  13465. }
  13466. return edges
  13467. }
  13468. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13469. // the given name in this mutation.
  13470. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  13471. switch name {
  13472. case sopstage.EdgeStageNodes:
  13473. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  13474. for id := range m.removedstage_nodes {
  13475. ids = append(ids, id)
  13476. }
  13477. return ids
  13478. case sopstage.EdgeStageMessages:
  13479. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  13480. for id := range m.removedstage_messages {
  13481. ids = append(ids, id)
  13482. }
  13483. return ids
  13484. }
  13485. return nil
  13486. }
  13487. // ClearedEdges returns all edge names that were cleared in this mutation.
  13488. func (m *SopStageMutation) ClearedEdges() []string {
  13489. edges := make([]string, 0, 3)
  13490. if m.clearedsop_task {
  13491. edges = append(edges, sopstage.EdgeSopTask)
  13492. }
  13493. if m.clearedstage_nodes {
  13494. edges = append(edges, sopstage.EdgeStageNodes)
  13495. }
  13496. if m.clearedstage_messages {
  13497. edges = append(edges, sopstage.EdgeStageMessages)
  13498. }
  13499. return edges
  13500. }
  13501. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13502. // was cleared in this mutation.
  13503. func (m *SopStageMutation) EdgeCleared(name string) bool {
  13504. switch name {
  13505. case sopstage.EdgeSopTask:
  13506. return m.clearedsop_task
  13507. case sopstage.EdgeStageNodes:
  13508. return m.clearedstage_nodes
  13509. case sopstage.EdgeStageMessages:
  13510. return m.clearedstage_messages
  13511. }
  13512. return false
  13513. }
  13514. // ClearEdge clears the value of the edge with the given name. It returns an error
  13515. // if that edge is not defined in the schema.
  13516. func (m *SopStageMutation) ClearEdge(name string) error {
  13517. switch name {
  13518. case sopstage.EdgeSopTask:
  13519. m.ClearSopTask()
  13520. return nil
  13521. }
  13522. return fmt.Errorf("unknown SopStage unique edge %s", name)
  13523. }
  13524. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13525. // It returns an error if the edge is not defined in the schema.
  13526. func (m *SopStageMutation) ResetEdge(name string) error {
  13527. switch name {
  13528. case sopstage.EdgeSopTask:
  13529. m.ResetSopTask()
  13530. return nil
  13531. case sopstage.EdgeStageNodes:
  13532. m.ResetStageNodes()
  13533. return nil
  13534. case sopstage.EdgeStageMessages:
  13535. m.ResetStageMessages()
  13536. return nil
  13537. }
  13538. return fmt.Errorf("unknown SopStage edge %s", name)
  13539. }
  13540. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  13541. type SopTaskMutation struct {
  13542. config
  13543. op Op
  13544. typ string
  13545. id *uint64
  13546. created_at *time.Time
  13547. updated_at *time.Time
  13548. status *uint8
  13549. addstatus *int8
  13550. deleted_at *time.Time
  13551. name *string
  13552. bot_wxid_list *[]string
  13553. appendbot_wxid_list []string
  13554. _type *int
  13555. add_type *int
  13556. plan_start_time *time.Time
  13557. plan_end_time *time.Time
  13558. creator_id *string
  13559. organization_id *uint64
  13560. addorganization_id *int64
  13561. clearedFields map[string]struct{}
  13562. task_stages map[uint64]struct{}
  13563. removedtask_stages map[uint64]struct{}
  13564. clearedtask_stages bool
  13565. done bool
  13566. oldValue func(context.Context) (*SopTask, error)
  13567. predicates []predicate.SopTask
  13568. }
  13569. var _ ent.Mutation = (*SopTaskMutation)(nil)
  13570. // soptaskOption allows management of the mutation configuration using functional options.
  13571. type soptaskOption func(*SopTaskMutation)
  13572. // newSopTaskMutation creates new mutation for the SopTask entity.
  13573. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  13574. m := &SopTaskMutation{
  13575. config: c,
  13576. op: op,
  13577. typ: TypeSopTask,
  13578. clearedFields: make(map[string]struct{}),
  13579. }
  13580. for _, opt := range opts {
  13581. opt(m)
  13582. }
  13583. return m
  13584. }
  13585. // withSopTaskID sets the ID field of the mutation.
  13586. func withSopTaskID(id uint64) soptaskOption {
  13587. return func(m *SopTaskMutation) {
  13588. var (
  13589. err error
  13590. once sync.Once
  13591. value *SopTask
  13592. )
  13593. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  13594. once.Do(func() {
  13595. if m.done {
  13596. err = errors.New("querying old values post mutation is not allowed")
  13597. } else {
  13598. value, err = m.Client().SopTask.Get(ctx, id)
  13599. }
  13600. })
  13601. return value, err
  13602. }
  13603. m.id = &id
  13604. }
  13605. }
  13606. // withSopTask sets the old SopTask of the mutation.
  13607. func withSopTask(node *SopTask) soptaskOption {
  13608. return func(m *SopTaskMutation) {
  13609. m.oldValue = func(context.Context) (*SopTask, error) {
  13610. return node, nil
  13611. }
  13612. m.id = &node.ID
  13613. }
  13614. }
  13615. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13616. // executed in a transaction (ent.Tx), a transactional client is returned.
  13617. func (m SopTaskMutation) Client() *Client {
  13618. client := &Client{config: m.config}
  13619. client.init()
  13620. return client
  13621. }
  13622. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13623. // it returns an error otherwise.
  13624. func (m SopTaskMutation) Tx() (*Tx, error) {
  13625. if _, ok := m.driver.(*txDriver); !ok {
  13626. return nil, errors.New("ent: mutation is not running in a transaction")
  13627. }
  13628. tx := &Tx{config: m.config}
  13629. tx.init()
  13630. return tx, nil
  13631. }
  13632. // SetID sets the value of the id field. Note that this
  13633. // operation is only accepted on creation of SopTask entities.
  13634. func (m *SopTaskMutation) SetID(id uint64) {
  13635. m.id = &id
  13636. }
  13637. // ID returns the ID value in the mutation. Note that the ID is only available
  13638. // if it was provided to the builder or after it was returned from the database.
  13639. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  13640. if m.id == nil {
  13641. return
  13642. }
  13643. return *m.id, true
  13644. }
  13645. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13646. // That means, if the mutation is applied within a transaction with an isolation level such
  13647. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13648. // or updated by the mutation.
  13649. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  13650. switch {
  13651. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13652. id, exists := m.ID()
  13653. if exists {
  13654. return []uint64{id}, nil
  13655. }
  13656. fallthrough
  13657. case m.op.Is(OpUpdate | OpDelete):
  13658. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  13659. default:
  13660. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13661. }
  13662. }
  13663. // SetCreatedAt sets the "created_at" field.
  13664. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  13665. m.created_at = &t
  13666. }
  13667. // CreatedAt returns the value of the "created_at" field in the mutation.
  13668. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  13669. v := m.created_at
  13670. if v == nil {
  13671. return
  13672. }
  13673. return *v, true
  13674. }
  13675. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  13676. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  13677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13678. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13679. if !m.op.Is(OpUpdateOne) {
  13680. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13681. }
  13682. if m.id == nil || m.oldValue == nil {
  13683. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13684. }
  13685. oldValue, err := m.oldValue(ctx)
  13686. if err != nil {
  13687. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13688. }
  13689. return oldValue.CreatedAt, nil
  13690. }
  13691. // ResetCreatedAt resets all changes to the "created_at" field.
  13692. func (m *SopTaskMutation) ResetCreatedAt() {
  13693. m.created_at = nil
  13694. }
  13695. // SetUpdatedAt sets the "updated_at" field.
  13696. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  13697. m.updated_at = &t
  13698. }
  13699. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13700. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  13701. v := m.updated_at
  13702. if v == nil {
  13703. return
  13704. }
  13705. return *v, true
  13706. }
  13707. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  13708. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  13709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13710. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13711. if !m.op.Is(OpUpdateOne) {
  13712. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13713. }
  13714. if m.id == nil || m.oldValue == nil {
  13715. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13716. }
  13717. oldValue, err := m.oldValue(ctx)
  13718. if err != nil {
  13719. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13720. }
  13721. return oldValue.UpdatedAt, nil
  13722. }
  13723. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13724. func (m *SopTaskMutation) ResetUpdatedAt() {
  13725. m.updated_at = nil
  13726. }
  13727. // SetStatus sets the "status" field.
  13728. func (m *SopTaskMutation) SetStatus(u uint8) {
  13729. m.status = &u
  13730. m.addstatus = nil
  13731. }
  13732. // Status returns the value of the "status" field in the mutation.
  13733. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  13734. v := m.status
  13735. if v == nil {
  13736. return
  13737. }
  13738. return *v, true
  13739. }
  13740. // OldStatus returns the old "status" field's value of the SopTask entity.
  13741. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  13742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13743. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13744. if !m.op.Is(OpUpdateOne) {
  13745. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13746. }
  13747. if m.id == nil || m.oldValue == nil {
  13748. return v, errors.New("OldStatus requires an ID field in the mutation")
  13749. }
  13750. oldValue, err := m.oldValue(ctx)
  13751. if err != nil {
  13752. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13753. }
  13754. return oldValue.Status, nil
  13755. }
  13756. // AddStatus adds u to the "status" field.
  13757. func (m *SopTaskMutation) AddStatus(u int8) {
  13758. if m.addstatus != nil {
  13759. *m.addstatus += u
  13760. } else {
  13761. m.addstatus = &u
  13762. }
  13763. }
  13764. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13765. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  13766. v := m.addstatus
  13767. if v == nil {
  13768. return
  13769. }
  13770. return *v, true
  13771. }
  13772. // ClearStatus clears the value of the "status" field.
  13773. func (m *SopTaskMutation) ClearStatus() {
  13774. m.status = nil
  13775. m.addstatus = nil
  13776. m.clearedFields[soptask.FieldStatus] = struct{}{}
  13777. }
  13778. // StatusCleared returns if the "status" field was cleared in this mutation.
  13779. func (m *SopTaskMutation) StatusCleared() bool {
  13780. _, ok := m.clearedFields[soptask.FieldStatus]
  13781. return ok
  13782. }
  13783. // ResetStatus resets all changes to the "status" field.
  13784. func (m *SopTaskMutation) ResetStatus() {
  13785. m.status = nil
  13786. m.addstatus = nil
  13787. delete(m.clearedFields, soptask.FieldStatus)
  13788. }
  13789. // SetDeletedAt sets the "deleted_at" field.
  13790. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  13791. m.deleted_at = &t
  13792. }
  13793. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13794. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  13795. v := m.deleted_at
  13796. if v == nil {
  13797. return
  13798. }
  13799. return *v, true
  13800. }
  13801. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  13802. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  13803. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13804. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13805. if !m.op.Is(OpUpdateOne) {
  13806. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13807. }
  13808. if m.id == nil || m.oldValue == nil {
  13809. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13810. }
  13811. oldValue, err := m.oldValue(ctx)
  13812. if err != nil {
  13813. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13814. }
  13815. return oldValue.DeletedAt, nil
  13816. }
  13817. // ClearDeletedAt clears the value of the "deleted_at" field.
  13818. func (m *SopTaskMutation) ClearDeletedAt() {
  13819. m.deleted_at = nil
  13820. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  13821. }
  13822. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13823. func (m *SopTaskMutation) DeletedAtCleared() bool {
  13824. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  13825. return ok
  13826. }
  13827. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13828. func (m *SopTaskMutation) ResetDeletedAt() {
  13829. m.deleted_at = nil
  13830. delete(m.clearedFields, soptask.FieldDeletedAt)
  13831. }
  13832. // SetName sets the "name" field.
  13833. func (m *SopTaskMutation) SetName(s string) {
  13834. m.name = &s
  13835. }
  13836. // Name returns the value of the "name" field in the mutation.
  13837. func (m *SopTaskMutation) Name() (r string, exists bool) {
  13838. v := m.name
  13839. if v == nil {
  13840. return
  13841. }
  13842. return *v, true
  13843. }
  13844. // OldName returns the old "name" field's value of the SopTask entity.
  13845. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  13846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13847. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  13848. if !m.op.Is(OpUpdateOne) {
  13849. return v, errors.New("OldName is only allowed on UpdateOne operations")
  13850. }
  13851. if m.id == nil || m.oldValue == nil {
  13852. return v, errors.New("OldName requires an ID field in the mutation")
  13853. }
  13854. oldValue, err := m.oldValue(ctx)
  13855. if err != nil {
  13856. return v, fmt.Errorf("querying old value for OldName: %w", err)
  13857. }
  13858. return oldValue.Name, nil
  13859. }
  13860. // ResetName resets all changes to the "name" field.
  13861. func (m *SopTaskMutation) ResetName() {
  13862. m.name = nil
  13863. }
  13864. // SetBotWxidList sets the "bot_wxid_list" field.
  13865. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  13866. m.bot_wxid_list = &s
  13867. m.appendbot_wxid_list = nil
  13868. }
  13869. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  13870. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  13871. v := m.bot_wxid_list
  13872. if v == nil {
  13873. return
  13874. }
  13875. return *v, true
  13876. }
  13877. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  13878. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  13879. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13880. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  13881. if !m.op.Is(OpUpdateOne) {
  13882. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  13883. }
  13884. if m.id == nil || m.oldValue == nil {
  13885. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  13886. }
  13887. oldValue, err := m.oldValue(ctx)
  13888. if err != nil {
  13889. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  13890. }
  13891. return oldValue.BotWxidList, nil
  13892. }
  13893. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  13894. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  13895. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  13896. }
  13897. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  13898. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  13899. if len(m.appendbot_wxid_list) == 0 {
  13900. return nil, false
  13901. }
  13902. return m.appendbot_wxid_list, true
  13903. }
  13904. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  13905. func (m *SopTaskMutation) ClearBotWxidList() {
  13906. m.bot_wxid_list = nil
  13907. m.appendbot_wxid_list = nil
  13908. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  13909. }
  13910. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  13911. func (m *SopTaskMutation) BotWxidListCleared() bool {
  13912. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  13913. return ok
  13914. }
  13915. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  13916. func (m *SopTaskMutation) ResetBotWxidList() {
  13917. m.bot_wxid_list = nil
  13918. m.appendbot_wxid_list = nil
  13919. delete(m.clearedFields, soptask.FieldBotWxidList)
  13920. }
  13921. // SetType sets the "type" field.
  13922. func (m *SopTaskMutation) SetType(i int) {
  13923. m._type = &i
  13924. m.add_type = nil
  13925. }
  13926. // GetType returns the value of the "type" field in the mutation.
  13927. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  13928. v := m._type
  13929. if v == nil {
  13930. return
  13931. }
  13932. return *v, true
  13933. }
  13934. // OldType returns the old "type" field's value of the SopTask entity.
  13935. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  13936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13937. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  13938. if !m.op.Is(OpUpdateOne) {
  13939. return v, errors.New("OldType is only allowed on UpdateOne operations")
  13940. }
  13941. if m.id == nil || m.oldValue == nil {
  13942. return v, errors.New("OldType requires an ID field in the mutation")
  13943. }
  13944. oldValue, err := m.oldValue(ctx)
  13945. if err != nil {
  13946. return v, fmt.Errorf("querying old value for OldType: %w", err)
  13947. }
  13948. return oldValue.Type, nil
  13949. }
  13950. // AddType adds i to the "type" field.
  13951. func (m *SopTaskMutation) AddType(i int) {
  13952. if m.add_type != nil {
  13953. *m.add_type += i
  13954. } else {
  13955. m.add_type = &i
  13956. }
  13957. }
  13958. // AddedType returns the value that was added to the "type" field in this mutation.
  13959. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  13960. v := m.add_type
  13961. if v == nil {
  13962. return
  13963. }
  13964. return *v, true
  13965. }
  13966. // ResetType resets all changes to the "type" field.
  13967. func (m *SopTaskMutation) ResetType() {
  13968. m._type = nil
  13969. m.add_type = nil
  13970. }
  13971. // SetPlanStartTime sets the "plan_start_time" field.
  13972. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  13973. m.plan_start_time = &t
  13974. }
  13975. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  13976. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  13977. v := m.plan_start_time
  13978. if v == nil {
  13979. return
  13980. }
  13981. return *v, true
  13982. }
  13983. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  13984. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  13985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13986. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  13987. if !m.op.Is(OpUpdateOne) {
  13988. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  13989. }
  13990. if m.id == nil || m.oldValue == nil {
  13991. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  13992. }
  13993. oldValue, err := m.oldValue(ctx)
  13994. if err != nil {
  13995. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  13996. }
  13997. return oldValue.PlanStartTime, nil
  13998. }
  13999. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  14000. func (m *SopTaskMutation) ClearPlanStartTime() {
  14001. m.plan_start_time = nil
  14002. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  14003. }
  14004. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  14005. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  14006. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  14007. return ok
  14008. }
  14009. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  14010. func (m *SopTaskMutation) ResetPlanStartTime() {
  14011. m.plan_start_time = nil
  14012. delete(m.clearedFields, soptask.FieldPlanStartTime)
  14013. }
  14014. // SetPlanEndTime sets the "plan_end_time" field.
  14015. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  14016. m.plan_end_time = &t
  14017. }
  14018. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  14019. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  14020. v := m.plan_end_time
  14021. if v == nil {
  14022. return
  14023. }
  14024. return *v, true
  14025. }
  14026. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  14027. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14029. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  14030. if !m.op.Is(OpUpdateOne) {
  14031. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  14032. }
  14033. if m.id == nil || m.oldValue == nil {
  14034. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  14035. }
  14036. oldValue, err := m.oldValue(ctx)
  14037. if err != nil {
  14038. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  14039. }
  14040. return oldValue.PlanEndTime, nil
  14041. }
  14042. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  14043. func (m *SopTaskMutation) ClearPlanEndTime() {
  14044. m.plan_end_time = nil
  14045. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  14046. }
  14047. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  14048. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  14049. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  14050. return ok
  14051. }
  14052. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  14053. func (m *SopTaskMutation) ResetPlanEndTime() {
  14054. m.plan_end_time = nil
  14055. delete(m.clearedFields, soptask.FieldPlanEndTime)
  14056. }
  14057. // SetCreatorID sets the "creator_id" field.
  14058. func (m *SopTaskMutation) SetCreatorID(s string) {
  14059. m.creator_id = &s
  14060. }
  14061. // CreatorID returns the value of the "creator_id" field in the mutation.
  14062. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  14063. v := m.creator_id
  14064. if v == nil {
  14065. return
  14066. }
  14067. return *v, true
  14068. }
  14069. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  14070. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14072. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  14073. if !m.op.Is(OpUpdateOne) {
  14074. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  14075. }
  14076. if m.id == nil || m.oldValue == nil {
  14077. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  14078. }
  14079. oldValue, err := m.oldValue(ctx)
  14080. if err != nil {
  14081. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  14082. }
  14083. return oldValue.CreatorID, nil
  14084. }
  14085. // ClearCreatorID clears the value of the "creator_id" field.
  14086. func (m *SopTaskMutation) ClearCreatorID() {
  14087. m.creator_id = nil
  14088. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  14089. }
  14090. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  14091. func (m *SopTaskMutation) CreatorIDCleared() bool {
  14092. _, ok := m.clearedFields[soptask.FieldCreatorID]
  14093. return ok
  14094. }
  14095. // ResetCreatorID resets all changes to the "creator_id" field.
  14096. func (m *SopTaskMutation) ResetCreatorID() {
  14097. m.creator_id = nil
  14098. delete(m.clearedFields, soptask.FieldCreatorID)
  14099. }
  14100. // SetOrganizationID sets the "organization_id" field.
  14101. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  14102. m.organization_id = &u
  14103. m.addorganization_id = nil
  14104. }
  14105. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14106. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  14107. v := m.organization_id
  14108. if v == nil {
  14109. return
  14110. }
  14111. return *v, true
  14112. }
  14113. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  14114. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14116. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14117. if !m.op.Is(OpUpdateOne) {
  14118. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14119. }
  14120. if m.id == nil || m.oldValue == nil {
  14121. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14122. }
  14123. oldValue, err := m.oldValue(ctx)
  14124. if err != nil {
  14125. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14126. }
  14127. return oldValue.OrganizationID, nil
  14128. }
  14129. // AddOrganizationID adds u to the "organization_id" field.
  14130. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  14131. if m.addorganization_id != nil {
  14132. *m.addorganization_id += u
  14133. } else {
  14134. m.addorganization_id = &u
  14135. }
  14136. }
  14137. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14138. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  14139. v := m.addorganization_id
  14140. if v == nil {
  14141. return
  14142. }
  14143. return *v, true
  14144. }
  14145. // ClearOrganizationID clears the value of the "organization_id" field.
  14146. func (m *SopTaskMutation) ClearOrganizationID() {
  14147. m.organization_id = nil
  14148. m.addorganization_id = nil
  14149. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  14150. }
  14151. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14152. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  14153. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  14154. return ok
  14155. }
  14156. // ResetOrganizationID resets all changes to the "organization_id" field.
  14157. func (m *SopTaskMutation) ResetOrganizationID() {
  14158. m.organization_id = nil
  14159. m.addorganization_id = nil
  14160. delete(m.clearedFields, soptask.FieldOrganizationID)
  14161. }
  14162. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  14163. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  14164. if m.task_stages == nil {
  14165. m.task_stages = make(map[uint64]struct{})
  14166. }
  14167. for i := range ids {
  14168. m.task_stages[ids[i]] = struct{}{}
  14169. }
  14170. }
  14171. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  14172. func (m *SopTaskMutation) ClearTaskStages() {
  14173. m.clearedtask_stages = true
  14174. }
  14175. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  14176. func (m *SopTaskMutation) TaskStagesCleared() bool {
  14177. return m.clearedtask_stages
  14178. }
  14179. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  14180. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  14181. if m.removedtask_stages == nil {
  14182. m.removedtask_stages = make(map[uint64]struct{})
  14183. }
  14184. for i := range ids {
  14185. delete(m.task_stages, ids[i])
  14186. m.removedtask_stages[ids[i]] = struct{}{}
  14187. }
  14188. }
  14189. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  14190. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  14191. for id := range m.removedtask_stages {
  14192. ids = append(ids, id)
  14193. }
  14194. return
  14195. }
  14196. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  14197. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  14198. for id := range m.task_stages {
  14199. ids = append(ids, id)
  14200. }
  14201. return
  14202. }
  14203. // ResetTaskStages resets all changes to the "task_stages" edge.
  14204. func (m *SopTaskMutation) ResetTaskStages() {
  14205. m.task_stages = nil
  14206. m.clearedtask_stages = false
  14207. m.removedtask_stages = nil
  14208. }
  14209. // Where appends a list predicates to the SopTaskMutation builder.
  14210. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  14211. m.predicates = append(m.predicates, ps...)
  14212. }
  14213. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  14214. // users can use type-assertion to append predicates that do not depend on any generated package.
  14215. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  14216. p := make([]predicate.SopTask, len(ps))
  14217. for i := range ps {
  14218. p[i] = ps[i]
  14219. }
  14220. m.Where(p...)
  14221. }
  14222. // Op returns the operation name.
  14223. func (m *SopTaskMutation) Op() Op {
  14224. return m.op
  14225. }
  14226. // SetOp allows setting the mutation operation.
  14227. func (m *SopTaskMutation) SetOp(op Op) {
  14228. m.op = op
  14229. }
  14230. // Type returns the node type of this mutation (SopTask).
  14231. func (m *SopTaskMutation) Type() string {
  14232. return m.typ
  14233. }
  14234. // Fields returns all fields that were changed during this mutation. Note that in
  14235. // order to get all numeric fields that were incremented/decremented, call
  14236. // AddedFields().
  14237. func (m *SopTaskMutation) Fields() []string {
  14238. fields := make([]string, 0, 11)
  14239. if m.created_at != nil {
  14240. fields = append(fields, soptask.FieldCreatedAt)
  14241. }
  14242. if m.updated_at != nil {
  14243. fields = append(fields, soptask.FieldUpdatedAt)
  14244. }
  14245. if m.status != nil {
  14246. fields = append(fields, soptask.FieldStatus)
  14247. }
  14248. if m.deleted_at != nil {
  14249. fields = append(fields, soptask.FieldDeletedAt)
  14250. }
  14251. if m.name != nil {
  14252. fields = append(fields, soptask.FieldName)
  14253. }
  14254. if m.bot_wxid_list != nil {
  14255. fields = append(fields, soptask.FieldBotWxidList)
  14256. }
  14257. if m._type != nil {
  14258. fields = append(fields, soptask.FieldType)
  14259. }
  14260. if m.plan_start_time != nil {
  14261. fields = append(fields, soptask.FieldPlanStartTime)
  14262. }
  14263. if m.plan_end_time != nil {
  14264. fields = append(fields, soptask.FieldPlanEndTime)
  14265. }
  14266. if m.creator_id != nil {
  14267. fields = append(fields, soptask.FieldCreatorID)
  14268. }
  14269. if m.organization_id != nil {
  14270. fields = append(fields, soptask.FieldOrganizationID)
  14271. }
  14272. return fields
  14273. }
  14274. // Field returns the value of a field with the given name. The second boolean
  14275. // return value indicates that this field was not set, or was not defined in the
  14276. // schema.
  14277. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  14278. switch name {
  14279. case soptask.FieldCreatedAt:
  14280. return m.CreatedAt()
  14281. case soptask.FieldUpdatedAt:
  14282. return m.UpdatedAt()
  14283. case soptask.FieldStatus:
  14284. return m.Status()
  14285. case soptask.FieldDeletedAt:
  14286. return m.DeletedAt()
  14287. case soptask.FieldName:
  14288. return m.Name()
  14289. case soptask.FieldBotWxidList:
  14290. return m.BotWxidList()
  14291. case soptask.FieldType:
  14292. return m.GetType()
  14293. case soptask.FieldPlanStartTime:
  14294. return m.PlanStartTime()
  14295. case soptask.FieldPlanEndTime:
  14296. return m.PlanEndTime()
  14297. case soptask.FieldCreatorID:
  14298. return m.CreatorID()
  14299. case soptask.FieldOrganizationID:
  14300. return m.OrganizationID()
  14301. }
  14302. return nil, false
  14303. }
  14304. // OldField returns the old value of the field from the database. An error is
  14305. // returned if the mutation operation is not UpdateOne, or the query to the
  14306. // database failed.
  14307. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14308. switch name {
  14309. case soptask.FieldCreatedAt:
  14310. return m.OldCreatedAt(ctx)
  14311. case soptask.FieldUpdatedAt:
  14312. return m.OldUpdatedAt(ctx)
  14313. case soptask.FieldStatus:
  14314. return m.OldStatus(ctx)
  14315. case soptask.FieldDeletedAt:
  14316. return m.OldDeletedAt(ctx)
  14317. case soptask.FieldName:
  14318. return m.OldName(ctx)
  14319. case soptask.FieldBotWxidList:
  14320. return m.OldBotWxidList(ctx)
  14321. case soptask.FieldType:
  14322. return m.OldType(ctx)
  14323. case soptask.FieldPlanStartTime:
  14324. return m.OldPlanStartTime(ctx)
  14325. case soptask.FieldPlanEndTime:
  14326. return m.OldPlanEndTime(ctx)
  14327. case soptask.FieldCreatorID:
  14328. return m.OldCreatorID(ctx)
  14329. case soptask.FieldOrganizationID:
  14330. return m.OldOrganizationID(ctx)
  14331. }
  14332. return nil, fmt.Errorf("unknown SopTask field %s", name)
  14333. }
  14334. // SetField sets the value of a field with the given name. It returns an error if
  14335. // the field is not defined in the schema, or if the type mismatched the field
  14336. // type.
  14337. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  14338. switch name {
  14339. case soptask.FieldCreatedAt:
  14340. v, ok := value.(time.Time)
  14341. if !ok {
  14342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14343. }
  14344. m.SetCreatedAt(v)
  14345. return nil
  14346. case soptask.FieldUpdatedAt:
  14347. v, ok := value.(time.Time)
  14348. if !ok {
  14349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14350. }
  14351. m.SetUpdatedAt(v)
  14352. return nil
  14353. case soptask.FieldStatus:
  14354. v, ok := value.(uint8)
  14355. if !ok {
  14356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14357. }
  14358. m.SetStatus(v)
  14359. return nil
  14360. case soptask.FieldDeletedAt:
  14361. v, ok := value.(time.Time)
  14362. if !ok {
  14363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14364. }
  14365. m.SetDeletedAt(v)
  14366. return nil
  14367. case soptask.FieldName:
  14368. v, ok := value.(string)
  14369. if !ok {
  14370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14371. }
  14372. m.SetName(v)
  14373. return nil
  14374. case soptask.FieldBotWxidList:
  14375. v, ok := value.([]string)
  14376. if !ok {
  14377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14378. }
  14379. m.SetBotWxidList(v)
  14380. return nil
  14381. case soptask.FieldType:
  14382. v, ok := value.(int)
  14383. if !ok {
  14384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14385. }
  14386. m.SetType(v)
  14387. return nil
  14388. case soptask.FieldPlanStartTime:
  14389. v, ok := value.(time.Time)
  14390. if !ok {
  14391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14392. }
  14393. m.SetPlanStartTime(v)
  14394. return nil
  14395. case soptask.FieldPlanEndTime:
  14396. v, ok := value.(time.Time)
  14397. if !ok {
  14398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14399. }
  14400. m.SetPlanEndTime(v)
  14401. return nil
  14402. case soptask.FieldCreatorID:
  14403. v, ok := value.(string)
  14404. if !ok {
  14405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14406. }
  14407. m.SetCreatorID(v)
  14408. return nil
  14409. case soptask.FieldOrganizationID:
  14410. v, ok := value.(uint64)
  14411. if !ok {
  14412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14413. }
  14414. m.SetOrganizationID(v)
  14415. return nil
  14416. }
  14417. return fmt.Errorf("unknown SopTask field %s", name)
  14418. }
  14419. // AddedFields returns all numeric fields that were incremented/decremented during
  14420. // this mutation.
  14421. func (m *SopTaskMutation) AddedFields() []string {
  14422. var fields []string
  14423. if m.addstatus != nil {
  14424. fields = append(fields, soptask.FieldStatus)
  14425. }
  14426. if m.add_type != nil {
  14427. fields = append(fields, soptask.FieldType)
  14428. }
  14429. if m.addorganization_id != nil {
  14430. fields = append(fields, soptask.FieldOrganizationID)
  14431. }
  14432. return fields
  14433. }
  14434. // AddedField returns the numeric value that was incremented/decremented on a field
  14435. // with the given name. The second boolean return value indicates that this field
  14436. // was not set, or was not defined in the schema.
  14437. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  14438. switch name {
  14439. case soptask.FieldStatus:
  14440. return m.AddedStatus()
  14441. case soptask.FieldType:
  14442. return m.AddedType()
  14443. case soptask.FieldOrganizationID:
  14444. return m.AddedOrganizationID()
  14445. }
  14446. return nil, false
  14447. }
  14448. // AddField adds the value to the field with the given name. It returns an error if
  14449. // the field is not defined in the schema, or if the type mismatched the field
  14450. // type.
  14451. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  14452. switch name {
  14453. case soptask.FieldStatus:
  14454. v, ok := value.(int8)
  14455. if !ok {
  14456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14457. }
  14458. m.AddStatus(v)
  14459. return nil
  14460. case soptask.FieldType:
  14461. v, ok := value.(int)
  14462. if !ok {
  14463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14464. }
  14465. m.AddType(v)
  14466. return nil
  14467. case soptask.FieldOrganizationID:
  14468. v, ok := value.(int64)
  14469. if !ok {
  14470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14471. }
  14472. m.AddOrganizationID(v)
  14473. return nil
  14474. }
  14475. return fmt.Errorf("unknown SopTask numeric field %s", name)
  14476. }
  14477. // ClearedFields returns all nullable fields that were cleared during this
  14478. // mutation.
  14479. func (m *SopTaskMutation) ClearedFields() []string {
  14480. var fields []string
  14481. if m.FieldCleared(soptask.FieldStatus) {
  14482. fields = append(fields, soptask.FieldStatus)
  14483. }
  14484. if m.FieldCleared(soptask.FieldDeletedAt) {
  14485. fields = append(fields, soptask.FieldDeletedAt)
  14486. }
  14487. if m.FieldCleared(soptask.FieldBotWxidList) {
  14488. fields = append(fields, soptask.FieldBotWxidList)
  14489. }
  14490. if m.FieldCleared(soptask.FieldPlanStartTime) {
  14491. fields = append(fields, soptask.FieldPlanStartTime)
  14492. }
  14493. if m.FieldCleared(soptask.FieldPlanEndTime) {
  14494. fields = append(fields, soptask.FieldPlanEndTime)
  14495. }
  14496. if m.FieldCleared(soptask.FieldCreatorID) {
  14497. fields = append(fields, soptask.FieldCreatorID)
  14498. }
  14499. if m.FieldCleared(soptask.FieldOrganizationID) {
  14500. fields = append(fields, soptask.FieldOrganizationID)
  14501. }
  14502. return fields
  14503. }
  14504. // FieldCleared returns a boolean indicating if a field with the given name was
  14505. // cleared in this mutation.
  14506. func (m *SopTaskMutation) FieldCleared(name string) bool {
  14507. _, ok := m.clearedFields[name]
  14508. return ok
  14509. }
  14510. // ClearField clears the value of the field with the given name. It returns an
  14511. // error if the field is not defined in the schema.
  14512. func (m *SopTaskMutation) ClearField(name string) error {
  14513. switch name {
  14514. case soptask.FieldStatus:
  14515. m.ClearStatus()
  14516. return nil
  14517. case soptask.FieldDeletedAt:
  14518. m.ClearDeletedAt()
  14519. return nil
  14520. case soptask.FieldBotWxidList:
  14521. m.ClearBotWxidList()
  14522. return nil
  14523. case soptask.FieldPlanStartTime:
  14524. m.ClearPlanStartTime()
  14525. return nil
  14526. case soptask.FieldPlanEndTime:
  14527. m.ClearPlanEndTime()
  14528. return nil
  14529. case soptask.FieldCreatorID:
  14530. m.ClearCreatorID()
  14531. return nil
  14532. case soptask.FieldOrganizationID:
  14533. m.ClearOrganizationID()
  14534. return nil
  14535. }
  14536. return fmt.Errorf("unknown SopTask nullable field %s", name)
  14537. }
  14538. // ResetField resets all changes in the mutation for the field with the given name.
  14539. // It returns an error if the field is not defined in the schema.
  14540. func (m *SopTaskMutation) ResetField(name string) error {
  14541. switch name {
  14542. case soptask.FieldCreatedAt:
  14543. m.ResetCreatedAt()
  14544. return nil
  14545. case soptask.FieldUpdatedAt:
  14546. m.ResetUpdatedAt()
  14547. return nil
  14548. case soptask.FieldStatus:
  14549. m.ResetStatus()
  14550. return nil
  14551. case soptask.FieldDeletedAt:
  14552. m.ResetDeletedAt()
  14553. return nil
  14554. case soptask.FieldName:
  14555. m.ResetName()
  14556. return nil
  14557. case soptask.FieldBotWxidList:
  14558. m.ResetBotWxidList()
  14559. return nil
  14560. case soptask.FieldType:
  14561. m.ResetType()
  14562. return nil
  14563. case soptask.FieldPlanStartTime:
  14564. m.ResetPlanStartTime()
  14565. return nil
  14566. case soptask.FieldPlanEndTime:
  14567. m.ResetPlanEndTime()
  14568. return nil
  14569. case soptask.FieldCreatorID:
  14570. m.ResetCreatorID()
  14571. return nil
  14572. case soptask.FieldOrganizationID:
  14573. m.ResetOrganizationID()
  14574. return nil
  14575. }
  14576. return fmt.Errorf("unknown SopTask field %s", name)
  14577. }
  14578. // AddedEdges returns all edge names that were set/added in this mutation.
  14579. func (m *SopTaskMutation) AddedEdges() []string {
  14580. edges := make([]string, 0, 1)
  14581. if m.task_stages != nil {
  14582. edges = append(edges, soptask.EdgeTaskStages)
  14583. }
  14584. return edges
  14585. }
  14586. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14587. // name in this mutation.
  14588. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  14589. switch name {
  14590. case soptask.EdgeTaskStages:
  14591. ids := make([]ent.Value, 0, len(m.task_stages))
  14592. for id := range m.task_stages {
  14593. ids = append(ids, id)
  14594. }
  14595. return ids
  14596. }
  14597. return nil
  14598. }
  14599. // RemovedEdges returns all edge names that were removed in this mutation.
  14600. func (m *SopTaskMutation) RemovedEdges() []string {
  14601. edges := make([]string, 0, 1)
  14602. if m.removedtask_stages != nil {
  14603. edges = append(edges, soptask.EdgeTaskStages)
  14604. }
  14605. return edges
  14606. }
  14607. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14608. // the given name in this mutation.
  14609. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  14610. switch name {
  14611. case soptask.EdgeTaskStages:
  14612. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  14613. for id := range m.removedtask_stages {
  14614. ids = append(ids, id)
  14615. }
  14616. return ids
  14617. }
  14618. return nil
  14619. }
  14620. // ClearedEdges returns all edge names that were cleared in this mutation.
  14621. func (m *SopTaskMutation) ClearedEdges() []string {
  14622. edges := make([]string, 0, 1)
  14623. if m.clearedtask_stages {
  14624. edges = append(edges, soptask.EdgeTaskStages)
  14625. }
  14626. return edges
  14627. }
  14628. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14629. // was cleared in this mutation.
  14630. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  14631. switch name {
  14632. case soptask.EdgeTaskStages:
  14633. return m.clearedtask_stages
  14634. }
  14635. return false
  14636. }
  14637. // ClearEdge clears the value of the edge with the given name. It returns an error
  14638. // if that edge is not defined in the schema.
  14639. func (m *SopTaskMutation) ClearEdge(name string) error {
  14640. switch name {
  14641. }
  14642. return fmt.Errorf("unknown SopTask unique edge %s", name)
  14643. }
  14644. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14645. // It returns an error if the edge is not defined in the schema.
  14646. func (m *SopTaskMutation) ResetEdge(name string) error {
  14647. switch name {
  14648. case soptask.EdgeTaskStages:
  14649. m.ResetTaskStages()
  14650. return nil
  14651. }
  14652. return fmt.Errorf("unknown SopTask edge %s", name)
  14653. }
  14654. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  14655. type TokenMutation struct {
  14656. config
  14657. op Op
  14658. typ string
  14659. id *uint64
  14660. created_at *time.Time
  14661. updated_at *time.Time
  14662. deleted_at *time.Time
  14663. expire_at *time.Time
  14664. token *string
  14665. mac *string
  14666. clearedFields map[string]struct{}
  14667. done bool
  14668. oldValue func(context.Context) (*Token, error)
  14669. predicates []predicate.Token
  14670. }
  14671. var _ ent.Mutation = (*TokenMutation)(nil)
  14672. // tokenOption allows management of the mutation configuration using functional options.
  14673. type tokenOption func(*TokenMutation)
  14674. // newTokenMutation creates new mutation for the Token entity.
  14675. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  14676. m := &TokenMutation{
  14677. config: c,
  14678. op: op,
  14679. typ: TypeToken,
  14680. clearedFields: make(map[string]struct{}),
  14681. }
  14682. for _, opt := range opts {
  14683. opt(m)
  14684. }
  14685. return m
  14686. }
  14687. // withTokenID sets the ID field of the mutation.
  14688. func withTokenID(id uint64) tokenOption {
  14689. return func(m *TokenMutation) {
  14690. var (
  14691. err error
  14692. once sync.Once
  14693. value *Token
  14694. )
  14695. m.oldValue = func(ctx context.Context) (*Token, error) {
  14696. once.Do(func() {
  14697. if m.done {
  14698. err = errors.New("querying old values post mutation is not allowed")
  14699. } else {
  14700. value, err = m.Client().Token.Get(ctx, id)
  14701. }
  14702. })
  14703. return value, err
  14704. }
  14705. m.id = &id
  14706. }
  14707. }
  14708. // withToken sets the old Token of the mutation.
  14709. func withToken(node *Token) tokenOption {
  14710. return func(m *TokenMutation) {
  14711. m.oldValue = func(context.Context) (*Token, error) {
  14712. return node, nil
  14713. }
  14714. m.id = &node.ID
  14715. }
  14716. }
  14717. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14718. // executed in a transaction (ent.Tx), a transactional client is returned.
  14719. func (m TokenMutation) Client() *Client {
  14720. client := &Client{config: m.config}
  14721. client.init()
  14722. return client
  14723. }
  14724. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14725. // it returns an error otherwise.
  14726. func (m TokenMutation) Tx() (*Tx, error) {
  14727. if _, ok := m.driver.(*txDriver); !ok {
  14728. return nil, errors.New("ent: mutation is not running in a transaction")
  14729. }
  14730. tx := &Tx{config: m.config}
  14731. tx.init()
  14732. return tx, nil
  14733. }
  14734. // SetID sets the value of the id field. Note that this
  14735. // operation is only accepted on creation of Token entities.
  14736. func (m *TokenMutation) SetID(id uint64) {
  14737. m.id = &id
  14738. }
  14739. // ID returns the ID value in the mutation. Note that the ID is only available
  14740. // if it was provided to the builder or after it was returned from the database.
  14741. func (m *TokenMutation) ID() (id uint64, exists bool) {
  14742. if m.id == nil {
  14743. return
  14744. }
  14745. return *m.id, true
  14746. }
  14747. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14748. // That means, if the mutation is applied within a transaction with an isolation level such
  14749. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14750. // or updated by the mutation.
  14751. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  14752. switch {
  14753. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14754. id, exists := m.ID()
  14755. if exists {
  14756. return []uint64{id}, nil
  14757. }
  14758. fallthrough
  14759. case m.op.Is(OpUpdate | OpDelete):
  14760. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  14761. default:
  14762. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14763. }
  14764. }
  14765. // SetCreatedAt sets the "created_at" field.
  14766. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  14767. m.created_at = &t
  14768. }
  14769. // CreatedAt returns the value of the "created_at" field in the mutation.
  14770. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  14771. v := m.created_at
  14772. if v == nil {
  14773. return
  14774. }
  14775. return *v, true
  14776. }
  14777. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  14778. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  14779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14780. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14781. if !m.op.Is(OpUpdateOne) {
  14782. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14783. }
  14784. if m.id == nil || m.oldValue == nil {
  14785. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14786. }
  14787. oldValue, err := m.oldValue(ctx)
  14788. if err != nil {
  14789. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14790. }
  14791. return oldValue.CreatedAt, nil
  14792. }
  14793. // ResetCreatedAt resets all changes to the "created_at" field.
  14794. func (m *TokenMutation) ResetCreatedAt() {
  14795. m.created_at = nil
  14796. }
  14797. // SetUpdatedAt sets the "updated_at" field.
  14798. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  14799. m.updated_at = &t
  14800. }
  14801. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14802. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  14803. v := m.updated_at
  14804. if v == nil {
  14805. return
  14806. }
  14807. return *v, true
  14808. }
  14809. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  14810. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  14811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14812. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14813. if !m.op.Is(OpUpdateOne) {
  14814. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14815. }
  14816. if m.id == nil || m.oldValue == nil {
  14817. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14818. }
  14819. oldValue, err := m.oldValue(ctx)
  14820. if err != nil {
  14821. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14822. }
  14823. return oldValue.UpdatedAt, nil
  14824. }
  14825. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14826. func (m *TokenMutation) ResetUpdatedAt() {
  14827. m.updated_at = nil
  14828. }
  14829. // SetDeletedAt sets the "deleted_at" field.
  14830. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  14831. m.deleted_at = &t
  14832. }
  14833. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14834. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  14835. v := m.deleted_at
  14836. if v == nil {
  14837. return
  14838. }
  14839. return *v, true
  14840. }
  14841. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  14842. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  14843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14844. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14845. if !m.op.Is(OpUpdateOne) {
  14846. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14847. }
  14848. if m.id == nil || m.oldValue == nil {
  14849. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14850. }
  14851. oldValue, err := m.oldValue(ctx)
  14852. if err != nil {
  14853. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14854. }
  14855. return oldValue.DeletedAt, nil
  14856. }
  14857. // ClearDeletedAt clears the value of the "deleted_at" field.
  14858. func (m *TokenMutation) ClearDeletedAt() {
  14859. m.deleted_at = nil
  14860. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  14861. }
  14862. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14863. func (m *TokenMutation) DeletedAtCleared() bool {
  14864. _, ok := m.clearedFields[token.FieldDeletedAt]
  14865. return ok
  14866. }
  14867. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14868. func (m *TokenMutation) ResetDeletedAt() {
  14869. m.deleted_at = nil
  14870. delete(m.clearedFields, token.FieldDeletedAt)
  14871. }
  14872. // SetExpireAt sets the "expire_at" field.
  14873. func (m *TokenMutation) SetExpireAt(t time.Time) {
  14874. m.expire_at = &t
  14875. }
  14876. // ExpireAt returns the value of the "expire_at" field in the mutation.
  14877. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  14878. v := m.expire_at
  14879. if v == nil {
  14880. return
  14881. }
  14882. return *v, true
  14883. }
  14884. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  14885. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  14886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14887. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  14888. if !m.op.Is(OpUpdateOne) {
  14889. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  14890. }
  14891. if m.id == nil || m.oldValue == nil {
  14892. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  14893. }
  14894. oldValue, err := m.oldValue(ctx)
  14895. if err != nil {
  14896. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  14897. }
  14898. return oldValue.ExpireAt, nil
  14899. }
  14900. // ClearExpireAt clears the value of the "expire_at" field.
  14901. func (m *TokenMutation) ClearExpireAt() {
  14902. m.expire_at = nil
  14903. m.clearedFields[token.FieldExpireAt] = struct{}{}
  14904. }
  14905. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  14906. func (m *TokenMutation) ExpireAtCleared() bool {
  14907. _, ok := m.clearedFields[token.FieldExpireAt]
  14908. return ok
  14909. }
  14910. // ResetExpireAt resets all changes to the "expire_at" field.
  14911. func (m *TokenMutation) ResetExpireAt() {
  14912. m.expire_at = nil
  14913. delete(m.clearedFields, token.FieldExpireAt)
  14914. }
  14915. // SetToken sets the "token" field.
  14916. func (m *TokenMutation) SetToken(s string) {
  14917. m.token = &s
  14918. }
  14919. // Token returns the value of the "token" field in the mutation.
  14920. func (m *TokenMutation) Token() (r string, exists bool) {
  14921. v := m.token
  14922. if v == nil {
  14923. return
  14924. }
  14925. return *v, true
  14926. }
  14927. // OldToken returns the old "token" field's value of the Token entity.
  14928. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  14929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14930. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  14931. if !m.op.Is(OpUpdateOne) {
  14932. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  14933. }
  14934. if m.id == nil || m.oldValue == nil {
  14935. return v, errors.New("OldToken requires an ID field in the mutation")
  14936. }
  14937. oldValue, err := m.oldValue(ctx)
  14938. if err != nil {
  14939. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  14940. }
  14941. return oldValue.Token, nil
  14942. }
  14943. // ClearToken clears the value of the "token" field.
  14944. func (m *TokenMutation) ClearToken() {
  14945. m.token = nil
  14946. m.clearedFields[token.FieldToken] = struct{}{}
  14947. }
  14948. // TokenCleared returns if the "token" field was cleared in this mutation.
  14949. func (m *TokenMutation) TokenCleared() bool {
  14950. _, ok := m.clearedFields[token.FieldToken]
  14951. return ok
  14952. }
  14953. // ResetToken resets all changes to the "token" field.
  14954. func (m *TokenMutation) ResetToken() {
  14955. m.token = nil
  14956. delete(m.clearedFields, token.FieldToken)
  14957. }
  14958. // SetMAC sets the "mac" field.
  14959. func (m *TokenMutation) SetMAC(s string) {
  14960. m.mac = &s
  14961. }
  14962. // MAC returns the value of the "mac" field in the mutation.
  14963. func (m *TokenMutation) MAC() (r string, exists bool) {
  14964. v := m.mac
  14965. if v == nil {
  14966. return
  14967. }
  14968. return *v, true
  14969. }
  14970. // OldMAC returns the old "mac" field's value of the Token entity.
  14971. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  14972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14973. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  14974. if !m.op.Is(OpUpdateOne) {
  14975. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  14976. }
  14977. if m.id == nil || m.oldValue == nil {
  14978. return v, errors.New("OldMAC requires an ID field in the mutation")
  14979. }
  14980. oldValue, err := m.oldValue(ctx)
  14981. if err != nil {
  14982. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  14983. }
  14984. return oldValue.MAC, nil
  14985. }
  14986. // ResetMAC resets all changes to the "mac" field.
  14987. func (m *TokenMutation) ResetMAC() {
  14988. m.mac = nil
  14989. }
  14990. // Where appends a list predicates to the TokenMutation builder.
  14991. func (m *TokenMutation) Where(ps ...predicate.Token) {
  14992. m.predicates = append(m.predicates, ps...)
  14993. }
  14994. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  14995. // users can use type-assertion to append predicates that do not depend on any generated package.
  14996. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  14997. p := make([]predicate.Token, len(ps))
  14998. for i := range ps {
  14999. p[i] = ps[i]
  15000. }
  15001. m.Where(p...)
  15002. }
  15003. // Op returns the operation name.
  15004. func (m *TokenMutation) Op() Op {
  15005. return m.op
  15006. }
  15007. // SetOp allows setting the mutation operation.
  15008. func (m *TokenMutation) SetOp(op Op) {
  15009. m.op = op
  15010. }
  15011. // Type returns the node type of this mutation (Token).
  15012. func (m *TokenMutation) Type() string {
  15013. return m.typ
  15014. }
  15015. // Fields returns all fields that were changed during this mutation. Note that in
  15016. // order to get all numeric fields that were incremented/decremented, call
  15017. // AddedFields().
  15018. func (m *TokenMutation) Fields() []string {
  15019. fields := make([]string, 0, 6)
  15020. if m.created_at != nil {
  15021. fields = append(fields, token.FieldCreatedAt)
  15022. }
  15023. if m.updated_at != nil {
  15024. fields = append(fields, token.FieldUpdatedAt)
  15025. }
  15026. if m.deleted_at != nil {
  15027. fields = append(fields, token.FieldDeletedAt)
  15028. }
  15029. if m.expire_at != nil {
  15030. fields = append(fields, token.FieldExpireAt)
  15031. }
  15032. if m.token != nil {
  15033. fields = append(fields, token.FieldToken)
  15034. }
  15035. if m.mac != nil {
  15036. fields = append(fields, token.FieldMAC)
  15037. }
  15038. return fields
  15039. }
  15040. // Field returns the value of a field with the given name. The second boolean
  15041. // return value indicates that this field was not set, or was not defined in the
  15042. // schema.
  15043. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  15044. switch name {
  15045. case token.FieldCreatedAt:
  15046. return m.CreatedAt()
  15047. case token.FieldUpdatedAt:
  15048. return m.UpdatedAt()
  15049. case token.FieldDeletedAt:
  15050. return m.DeletedAt()
  15051. case token.FieldExpireAt:
  15052. return m.ExpireAt()
  15053. case token.FieldToken:
  15054. return m.Token()
  15055. case token.FieldMAC:
  15056. return m.MAC()
  15057. }
  15058. return nil, false
  15059. }
  15060. // OldField returns the old value of the field from the database. An error is
  15061. // returned if the mutation operation is not UpdateOne, or the query to the
  15062. // database failed.
  15063. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15064. switch name {
  15065. case token.FieldCreatedAt:
  15066. return m.OldCreatedAt(ctx)
  15067. case token.FieldUpdatedAt:
  15068. return m.OldUpdatedAt(ctx)
  15069. case token.FieldDeletedAt:
  15070. return m.OldDeletedAt(ctx)
  15071. case token.FieldExpireAt:
  15072. return m.OldExpireAt(ctx)
  15073. case token.FieldToken:
  15074. return m.OldToken(ctx)
  15075. case token.FieldMAC:
  15076. return m.OldMAC(ctx)
  15077. }
  15078. return nil, fmt.Errorf("unknown Token field %s", name)
  15079. }
  15080. // SetField sets the value of a field with the given name. It returns an error if
  15081. // the field is not defined in the schema, or if the type mismatched the field
  15082. // type.
  15083. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  15084. switch name {
  15085. case token.FieldCreatedAt:
  15086. v, ok := value.(time.Time)
  15087. if !ok {
  15088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15089. }
  15090. m.SetCreatedAt(v)
  15091. return nil
  15092. case token.FieldUpdatedAt:
  15093. v, ok := value.(time.Time)
  15094. if !ok {
  15095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15096. }
  15097. m.SetUpdatedAt(v)
  15098. return nil
  15099. case token.FieldDeletedAt:
  15100. v, ok := value.(time.Time)
  15101. if !ok {
  15102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15103. }
  15104. m.SetDeletedAt(v)
  15105. return nil
  15106. case token.FieldExpireAt:
  15107. v, ok := value.(time.Time)
  15108. if !ok {
  15109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15110. }
  15111. m.SetExpireAt(v)
  15112. return nil
  15113. case token.FieldToken:
  15114. v, ok := value.(string)
  15115. if !ok {
  15116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15117. }
  15118. m.SetToken(v)
  15119. return nil
  15120. case token.FieldMAC:
  15121. v, ok := value.(string)
  15122. if !ok {
  15123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15124. }
  15125. m.SetMAC(v)
  15126. return nil
  15127. }
  15128. return fmt.Errorf("unknown Token field %s", name)
  15129. }
  15130. // AddedFields returns all numeric fields that were incremented/decremented during
  15131. // this mutation.
  15132. func (m *TokenMutation) AddedFields() []string {
  15133. return nil
  15134. }
  15135. // AddedField returns the numeric value that was incremented/decremented on a field
  15136. // with the given name. The second boolean return value indicates that this field
  15137. // was not set, or was not defined in the schema.
  15138. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  15139. return nil, false
  15140. }
  15141. // AddField adds the value to the field with the given name. It returns an error if
  15142. // the field is not defined in the schema, or if the type mismatched the field
  15143. // type.
  15144. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  15145. switch name {
  15146. }
  15147. return fmt.Errorf("unknown Token numeric field %s", name)
  15148. }
  15149. // ClearedFields returns all nullable fields that were cleared during this
  15150. // mutation.
  15151. func (m *TokenMutation) ClearedFields() []string {
  15152. var fields []string
  15153. if m.FieldCleared(token.FieldDeletedAt) {
  15154. fields = append(fields, token.FieldDeletedAt)
  15155. }
  15156. if m.FieldCleared(token.FieldExpireAt) {
  15157. fields = append(fields, token.FieldExpireAt)
  15158. }
  15159. if m.FieldCleared(token.FieldToken) {
  15160. fields = append(fields, token.FieldToken)
  15161. }
  15162. return fields
  15163. }
  15164. // FieldCleared returns a boolean indicating if a field with the given name was
  15165. // cleared in this mutation.
  15166. func (m *TokenMutation) FieldCleared(name string) bool {
  15167. _, ok := m.clearedFields[name]
  15168. return ok
  15169. }
  15170. // ClearField clears the value of the field with the given name. It returns an
  15171. // error if the field is not defined in the schema.
  15172. func (m *TokenMutation) ClearField(name string) error {
  15173. switch name {
  15174. case token.FieldDeletedAt:
  15175. m.ClearDeletedAt()
  15176. return nil
  15177. case token.FieldExpireAt:
  15178. m.ClearExpireAt()
  15179. return nil
  15180. case token.FieldToken:
  15181. m.ClearToken()
  15182. return nil
  15183. }
  15184. return fmt.Errorf("unknown Token nullable field %s", name)
  15185. }
  15186. // ResetField resets all changes in the mutation for the field with the given name.
  15187. // It returns an error if the field is not defined in the schema.
  15188. func (m *TokenMutation) ResetField(name string) error {
  15189. switch name {
  15190. case token.FieldCreatedAt:
  15191. m.ResetCreatedAt()
  15192. return nil
  15193. case token.FieldUpdatedAt:
  15194. m.ResetUpdatedAt()
  15195. return nil
  15196. case token.FieldDeletedAt:
  15197. m.ResetDeletedAt()
  15198. return nil
  15199. case token.FieldExpireAt:
  15200. m.ResetExpireAt()
  15201. return nil
  15202. case token.FieldToken:
  15203. m.ResetToken()
  15204. return nil
  15205. case token.FieldMAC:
  15206. m.ResetMAC()
  15207. return nil
  15208. }
  15209. return fmt.Errorf("unknown Token field %s", name)
  15210. }
  15211. // AddedEdges returns all edge names that were set/added in this mutation.
  15212. func (m *TokenMutation) AddedEdges() []string {
  15213. edges := make([]string, 0, 0)
  15214. return edges
  15215. }
  15216. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15217. // name in this mutation.
  15218. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  15219. return nil
  15220. }
  15221. // RemovedEdges returns all edge names that were removed in this mutation.
  15222. func (m *TokenMutation) RemovedEdges() []string {
  15223. edges := make([]string, 0, 0)
  15224. return edges
  15225. }
  15226. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15227. // the given name in this mutation.
  15228. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  15229. return nil
  15230. }
  15231. // ClearedEdges returns all edge names that were cleared in this mutation.
  15232. func (m *TokenMutation) ClearedEdges() []string {
  15233. edges := make([]string, 0, 0)
  15234. return edges
  15235. }
  15236. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15237. // was cleared in this mutation.
  15238. func (m *TokenMutation) EdgeCleared(name string) bool {
  15239. return false
  15240. }
  15241. // ClearEdge clears the value of the edge with the given name. It returns an error
  15242. // if that edge is not defined in the schema.
  15243. func (m *TokenMutation) ClearEdge(name string) error {
  15244. return fmt.Errorf("unknown Token unique edge %s", name)
  15245. }
  15246. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15247. // It returns an error if the edge is not defined in the schema.
  15248. func (m *TokenMutation) ResetEdge(name string) error {
  15249. return fmt.Errorf("unknown Token edge %s", name)
  15250. }
  15251. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  15252. type TutorialMutation struct {
  15253. config
  15254. op Op
  15255. typ string
  15256. id *uint64
  15257. created_at *time.Time
  15258. updated_at *time.Time
  15259. deleted_at *time.Time
  15260. index *int
  15261. addindex *int
  15262. title *string
  15263. content *string
  15264. organization_id *uint64
  15265. addorganization_id *int64
  15266. clearedFields map[string]struct{}
  15267. employee *uint64
  15268. clearedemployee bool
  15269. done bool
  15270. oldValue func(context.Context) (*Tutorial, error)
  15271. predicates []predicate.Tutorial
  15272. }
  15273. var _ ent.Mutation = (*TutorialMutation)(nil)
  15274. // tutorialOption allows management of the mutation configuration using functional options.
  15275. type tutorialOption func(*TutorialMutation)
  15276. // newTutorialMutation creates new mutation for the Tutorial entity.
  15277. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  15278. m := &TutorialMutation{
  15279. config: c,
  15280. op: op,
  15281. typ: TypeTutorial,
  15282. clearedFields: make(map[string]struct{}),
  15283. }
  15284. for _, opt := range opts {
  15285. opt(m)
  15286. }
  15287. return m
  15288. }
  15289. // withTutorialID sets the ID field of the mutation.
  15290. func withTutorialID(id uint64) tutorialOption {
  15291. return func(m *TutorialMutation) {
  15292. var (
  15293. err error
  15294. once sync.Once
  15295. value *Tutorial
  15296. )
  15297. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  15298. once.Do(func() {
  15299. if m.done {
  15300. err = errors.New("querying old values post mutation is not allowed")
  15301. } else {
  15302. value, err = m.Client().Tutorial.Get(ctx, id)
  15303. }
  15304. })
  15305. return value, err
  15306. }
  15307. m.id = &id
  15308. }
  15309. }
  15310. // withTutorial sets the old Tutorial of the mutation.
  15311. func withTutorial(node *Tutorial) tutorialOption {
  15312. return func(m *TutorialMutation) {
  15313. m.oldValue = func(context.Context) (*Tutorial, error) {
  15314. return node, nil
  15315. }
  15316. m.id = &node.ID
  15317. }
  15318. }
  15319. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15320. // executed in a transaction (ent.Tx), a transactional client is returned.
  15321. func (m TutorialMutation) Client() *Client {
  15322. client := &Client{config: m.config}
  15323. client.init()
  15324. return client
  15325. }
  15326. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15327. // it returns an error otherwise.
  15328. func (m TutorialMutation) Tx() (*Tx, error) {
  15329. if _, ok := m.driver.(*txDriver); !ok {
  15330. return nil, errors.New("ent: mutation is not running in a transaction")
  15331. }
  15332. tx := &Tx{config: m.config}
  15333. tx.init()
  15334. return tx, nil
  15335. }
  15336. // SetID sets the value of the id field. Note that this
  15337. // operation is only accepted on creation of Tutorial entities.
  15338. func (m *TutorialMutation) SetID(id uint64) {
  15339. m.id = &id
  15340. }
  15341. // ID returns the ID value in the mutation. Note that the ID is only available
  15342. // if it was provided to the builder or after it was returned from the database.
  15343. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  15344. if m.id == nil {
  15345. return
  15346. }
  15347. return *m.id, true
  15348. }
  15349. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15350. // That means, if the mutation is applied within a transaction with an isolation level such
  15351. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15352. // or updated by the mutation.
  15353. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  15354. switch {
  15355. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15356. id, exists := m.ID()
  15357. if exists {
  15358. return []uint64{id}, nil
  15359. }
  15360. fallthrough
  15361. case m.op.Is(OpUpdate | OpDelete):
  15362. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  15363. default:
  15364. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15365. }
  15366. }
  15367. // SetCreatedAt sets the "created_at" field.
  15368. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  15369. m.created_at = &t
  15370. }
  15371. // CreatedAt returns the value of the "created_at" field in the mutation.
  15372. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  15373. v := m.created_at
  15374. if v == nil {
  15375. return
  15376. }
  15377. return *v, true
  15378. }
  15379. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  15380. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  15381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15382. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15383. if !m.op.Is(OpUpdateOne) {
  15384. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15385. }
  15386. if m.id == nil || m.oldValue == nil {
  15387. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15388. }
  15389. oldValue, err := m.oldValue(ctx)
  15390. if err != nil {
  15391. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15392. }
  15393. return oldValue.CreatedAt, nil
  15394. }
  15395. // ResetCreatedAt resets all changes to the "created_at" field.
  15396. func (m *TutorialMutation) ResetCreatedAt() {
  15397. m.created_at = nil
  15398. }
  15399. // SetUpdatedAt sets the "updated_at" field.
  15400. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  15401. m.updated_at = &t
  15402. }
  15403. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15404. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  15405. v := m.updated_at
  15406. if v == nil {
  15407. return
  15408. }
  15409. return *v, true
  15410. }
  15411. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  15412. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  15413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15414. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15415. if !m.op.Is(OpUpdateOne) {
  15416. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15417. }
  15418. if m.id == nil || m.oldValue == nil {
  15419. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15420. }
  15421. oldValue, err := m.oldValue(ctx)
  15422. if err != nil {
  15423. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15424. }
  15425. return oldValue.UpdatedAt, nil
  15426. }
  15427. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15428. func (m *TutorialMutation) ResetUpdatedAt() {
  15429. m.updated_at = nil
  15430. }
  15431. // SetDeletedAt sets the "deleted_at" field.
  15432. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  15433. m.deleted_at = &t
  15434. }
  15435. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15436. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  15437. v := m.deleted_at
  15438. if v == nil {
  15439. return
  15440. }
  15441. return *v, true
  15442. }
  15443. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  15444. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  15445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15446. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15447. if !m.op.Is(OpUpdateOne) {
  15448. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15449. }
  15450. if m.id == nil || m.oldValue == nil {
  15451. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15452. }
  15453. oldValue, err := m.oldValue(ctx)
  15454. if err != nil {
  15455. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15456. }
  15457. return oldValue.DeletedAt, nil
  15458. }
  15459. // ClearDeletedAt clears the value of the "deleted_at" field.
  15460. func (m *TutorialMutation) ClearDeletedAt() {
  15461. m.deleted_at = nil
  15462. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  15463. }
  15464. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15465. func (m *TutorialMutation) DeletedAtCleared() bool {
  15466. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  15467. return ok
  15468. }
  15469. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15470. func (m *TutorialMutation) ResetDeletedAt() {
  15471. m.deleted_at = nil
  15472. delete(m.clearedFields, tutorial.FieldDeletedAt)
  15473. }
  15474. // SetEmployeeID sets the "employee_id" field.
  15475. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  15476. m.employee = &u
  15477. }
  15478. // EmployeeID returns the value of the "employee_id" field in the mutation.
  15479. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  15480. v := m.employee
  15481. if v == nil {
  15482. return
  15483. }
  15484. return *v, true
  15485. }
  15486. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  15487. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  15488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15489. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  15490. if !m.op.Is(OpUpdateOne) {
  15491. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  15492. }
  15493. if m.id == nil || m.oldValue == nil {
  15494. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  15495. }
  15496. oldValue, err := m.oldValue(ctx)
  15497. if err != nil {
  15498. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  15499. }
  15500. return oldValue.EmployeeID, nil
  15501. }
  15502. // ResetEmployeeID resets all changes to the "employee_id" field.
  15503. func (m *TutorialMutation) ResetEmployeeID() {
  15504. m.employee = nil
  15505. }
  15506. // SetIndex sets the "index" field.
  15507. func (m *TutorialMutation) SetIndex(i int) {
  15508. m.index = &i
  15509. m.addindex = nil
  15510. }
  15511. // Index returns the value of the "index" field in the mutation.
  15512. func (m *TutorialMutation) Index() (r int, exists bool) {
  15513. v := m.index
  15514. if v == nil {
  15515. return
  15516. }
  15517. return *v, true
  15518. }
  15519. // OldIndex returns the old "index" field's value of the Tutorial entity.
  15520. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  15521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15522. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  15523. if !m.op.Is(OpUpdateOne) {
  15524. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  15525. }
  15526. if m.id == nil || m.oldValue == nil {
  15527. return v, errors.New("OldIndex requires an ID field in the mutation")
  15528. }
  15529. oldValue, err := m.oldValue(ctx)
  15530. if err != nil {
  15531. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  15532. }
  15533. return oldValue.Index, nil
  15534. }
  15535. // AddIndex adds i to the "index" field.
  15536. func (m *TutorialMutation) AddIndex(i int) {
  15537. if m.addindex != nil {
  15538. *m.addindex += i
  15539. } else {
  15540. m.addindex = &i
  15541. }
  15542. }
  15543. // AddedIndex returns the value that was added to the "index" field in this mutation.
  15544. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  15545. v := m.addindex
  15546. if v == nil {
  15547. return
  15548. }
  15549. return *v, true
  15550. }
  15551. // ResetIndex resets all changes to the "index" field.
  15552. func (m *TutorialMutation) ResetIndex() {
  15553. m.index = nil
  15554. m.addindex = nil
  15555. }
  15556. // SetTitle sets the "title" field.
  15557. func (m *TutorialMutation) SetTitle(s string) {
  15558. m.title = &s
  15559. }
  15560. // Title returns the value of the "title" field in the mutation.
  15561. func (m *TutorialMutation) Title() (r string, exists bool) {
  15562. v := m.title
  15563. if v == nil {
  15564. return
  15565. }
  15566. return *v, true
  15567. }
  15568. // OldTitle returns the old "title" field's value of the Tutorial entity.
  15569. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  15570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15571. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  15572. if !m.op.Is(OpUpdateOne) {
  15573. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  15574. }
  15575. if m.id == nil || m.oldValue == nil {
  15576. return v, errors.New("OldTitle requires an ID field in the mutation")
  15577. }
  15578. oldValue, err := m.oldValue(ctx)
  15579. if err != nil {
  15580. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  15581. }
  15582. return oldValue.Title, nil
  15583. }
  15584. // ResetTitle resets all changes to the "title" field.
  15585. func (m *TutorialMutation) ResetTitle() {
  15586. m.title = nil
  15587. }
  15588. // SetContent sets the "content" field.
  15589. func (m *TutorialMutation) SetContent(s string) {
  15590. m.content = &s
  15591. }
  15592. // Content returns the value of the "content" field in the mutation.
  15593. func (m *TutorialMutation) Content() (r string, exists bool) {
  15594. v := m.content
  15595. if v == nil {
  15596. return
  15597. }
  15598. return *v, true
  15599. }
  15600. // OldContent returns the old "content" field's value of the Tutorial entity.
  15601. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  15602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15603. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  15604. if !m.op.Is(OpUpdateOne) {
  15605. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  15606. }
  15607. if m.id == nil || m.oldValue == nil {
  15608. return v, errors.New("OldContent requires an ID field in the mutation")
  15609. }
  15610. oldValue, err := m.oldValue(ctx)
  15611. if err != nil {
  15612. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  15613. }
  15614. return oldValue.Content, nil
  15615. }
  15616. // ResetContent resets all changes to the "content" field.
  15617. func (m *TutorialMutation) ResetContent() {
  15618. m.content = nil
  15619. }
  15620. // SetOrganizationID sets the "organization_id" field.
  15621. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  15622. m.organization_id = &u
  15623. m.addorganization_id = nil
  15624. }
  15625. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15626. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  15627. v := m.organization_id
  15628. if v == nil {
  15629. return
  15630. }
  15631. return *v, true
  15632. }
  15633. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  15634. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  15635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15636. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15637. if !m.op.Is(OpUpdateOne) {
  15638. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15639. }
  15640. if m.id == nil || m.oldValue == nil {
  15641. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15642. }
  15643. oldValue, err := m.oldValue(ctx)
  15644. if err != nil {
  15645. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15646. }
  15647. return oldValue.OrganizationID, nil
  15648. }
  15649. // AddOrganizationID adds u to the "organization_id" field.
  15650. func (m *TutorialMutation) AddOrganizationID(u int64) {
  15651. if m.addorganization_id != nil {
  15652. *m.addorganization_id += u
  15653. } else {
  15654. m.addorganization_id = &u
  15655. }
  15656. }
  15657. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15658. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  15659. v := m.addorganization_id
  15660. if v == nil {
  15661. return
  15662. }
  15663. return *v, true
  15664. }
  15665. // ResetOrganizationID resets all changes to the "organization_id" field.
  15666. func (m *TutorialMutation) ResetOrganizationID() {
  15667. m.organization_id = nil
  15668. m.addorganization_id = nil
  15669. }
  15670. // ClearEmployee clears the "employee" edge to the Employee entity.
  15671. func (m *TutorialMutation) ClearEmployee() {
  15672. m.clearedemployee = true
  15673. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  15674. }
  15675. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  15676. func (m *TutorialMutation) EmployeeCleared() bool {
  15677. return m.clearedemployee
  15678. }
  15679. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  15680. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15681. // EmployeeID instead. It exists only for internal usage by the builders.
  15682. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  15683. if id := m.employee; id != nil {
  15684. ids = append(ids, *id)
  15685. }
  15686. return
  15687. }
  15688. // ResetEmployee resets all changes to the "employee" edge.
  15689. func (m *TutorialMutation) ResetEmployee() {
  15690. m.employee = nil
  15691. m.clearedemployee = false
  15692. }
  15693. // Where appends a list predicates to the TutorialMutation builder.
  15694. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  15695. m.predicates = append(m.predicates, ps...)
  15696. }
  15697. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  15698. // users can use type-assertion to append predicates that do not depend on any generated package.
  15699. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  15700. p := make([]predicate.Tutorial, len(ps))
  15701. for i := range ps {
  15702. p[i] = ps[i]
  15703. }
  15704. m.Where(p...)
  15705. }
  15706. // Op returns the operation name.
  15707. func (m *TutorialMutation) Op() Op {
  15708. return m.op
  15709. }
  15710. // SetOp allows setting the mutation operation.
  15711. func (m *TutorialMutation) SetOp(op Op) {
  15712. m.op = op
  15713. }
  15714. // Type returns the node type of this mutation (Tutorial).
  15715. func (m *TutorialMutation) Type() string {
  15716. return m.typ
  15717. }
  15718. // Fields returns all fields that were changed during this mutation. Note that in
  15719. // order to get all numeric fields that were incremented/decremented, call
  15720. // AddedFields().
  15721. func (m *TutorialMutation) Fields() []string {
  15722. fields := make([]string, 0, 8)
  15723. if m.created_at != nil {
  15724. fields = append(fields, tutorial.FieldCreatedAt)
  15725. }
  15726. if m.updated_at != nil {
  15727. fields = append(fields, tutorial.FieldUpdatedAt)
  15728. }
  15729. if m.deleted_at != nil {
  15730. fields = append(fields, tutorial.FieldDeletedAt)
  15731. }
  15732. if m.employee != nil {
  15733. fields = append(fields, tutorial.FieldEmployeeID)
  15734. }
  15735. if m.index != nil {
  15736. fields = append(fields, tutorial.FieldIndex)
  15737. }
  15738. if m.title != nil {
  15739. fields = append(fields, tutorial.FieldTitle)
  15740. }
  15741. if m.content != nil {
  15742. fields = append(fields, tutorial.FieldContent)
  15743. }
  15744. if m.organization_id != nil {
  15745. fields = append(fields, tutorial.FieldOrganizationID)
  15746. }
  15747. return fields
  15748. }
  15749. // Field returns the value of a field with the given name. The second boolean
  15750. // return value indicates that this field was not set, or was not defined in the
  15751. // schema.
  15752. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  15753. switch name {
  15754. case tutorial.FieldCreatedAt:
  15755. return m.CreatedAt()
  15756. case tutorial.FieldUpdatedAt:
  15757. return m.UpdatedAt()
  15758. case tutorial.FieldDeletedAt:
  15759. return m.DeletedAt()
  15760. case tutorial.FieldEmployeeID:
  15761. return m.EmployeeID()
  15762. case tutorial.FieldIndex:
  15763. return m.Index()
  15764. case tutorial.FieldTitle:
  15765. return m.Title()
  15766. case tutorial.FieldContent:
  15767. return m.Content()
  15768. case tutorial.FieldOrganizationID:
  15769. return m.OrganizationID()
  15770. }
  15771. return nil, false
  15772. }
  15773. // OldField returns the old value of the field from the database. An error is
  15774. // returned if the mutation operation is not UpdateOne, or the query to the
  15775. // database failed.
  15776. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15777. switch name {
  15778. case tutorial.FieldCreatedAt:
  15779. return m.OldCreatedAt(ctx)
  15780. case tutorial.FieldUpdatedAt:
  15781. return m.OldUpdatedAt(ctx)
  15782. case tutorial.FieldDeletedAt:
  15783. return m.OldDeletedAt(ctx)
  15784. case tutorial.FieldEmployeeID:
  15785. return m.OldEmployeeID(ctx)
  15786. case tutorial.FieldIndex:
  15787. return m.OldIndex(ctx)
  15788. case tutorial.FieldTitle:
  15789. return m.OldTitle(ctx)
  15790. case tutorial.FieldContent:
  15791. return m.OldContent(ctx)
  15792. case tutorial.FieldOrganizationID:
  15793. return m.OldOrganizationID(ctx)
  15794. }
  15795. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  15796. }
  15797. // SetField sets the value of a field with the given name. It returns an error if
  15798. // the field is not defined in the schema, or if the type mismatched the field
  15799. // type.
  15800. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  15801. switch name {
  15802. case tutorial.FieldCreatedAt:
  15803. v, ok := value.(time.Time)
  15804. if !ok {
  15805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15806. }
  15807. m.SetCreatedAt(v)
  15808. return nil
  15809. case tutorial.FieldUpdatedAt:
  15810. v, ok := value.(time.Time)
  15811. if !ok {
  15812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15813. }
  15814. m.SetUpdatedAt(v)
  15815. return nil
  15816. case tutorial.FieldDeletedAt:
  15817. v, ok := value.(time.Time)
  15818. if !ok {
  15819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15820. }
  15821. m.SetDeletedAt(v)
  15822. return nil
  15823. case tutorial.FieldEmployeeID:
  15824. v, ok := value.(uint64)
  15825. if !ok {
  15826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15827. }
  15828. m.SetEmployeeID(v)
  15829. return nil
  15830. case tutorial.FieldIndex:
  15831. v, ok := value.(int)
  15832. if !ok {
  15833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15834. }
  15835. m.SetIndex(v)
  15836. return nil
  15837. case tutorial.FieldTitle:
  15838. v, ok := value.(string)
  15839. if !ok {
  15840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15841. }
  15842. m.SetTitle(v)
  15843. return nil
  15844. case tutorial.FieldContent:
  15845. v, ok := value.(string)
  15846. if !ok {
  15847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15848. }
  15849. m.SetContent(v)
  15850. return nil
  15851. case tutorial.FieldOrganizationID:
  15852. v, ok := value.(uint64)
  15853. if !ok {
  15854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15855. }
  15856. m.SetOrganizationID(v)
  15857. return nil
  15858. }
  15859. return fmt.Errorf("unknown Tutorial field %s", name)
  15860. }
  15861. // AddedFields returns all numeric fields that were incremented/decremented during
  15862. // this mutation.
  15863. func (m *TutorialMutation) AddedFields() []string {
  15864. var fields []string
  15865. if m.addindex != nil {
  15866. fields = append(fields, tutorial.FieldIndex)
  15867. }
  15868. if m.addorganization_id != nil {
  15869. fields = append(fields, tutorial.FieldOrganizationID)
  15870. }
  15871. return fields
  15872. }
  15873. // AddedField returns the numeric value that was incremented/decremented on a field
  15874. // with the given name. The second boolean return value indicates that this field
  15875. // was not set, or was not defined in the schema.
  15876. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  15877. switch name {
  15878. case tutorial.FieldIndex:
  15879. return m.AddedIndex()
  15880. case tutorial.FieldOrganizationID:
  15881. return m.AddedOrganizationID()
  15882. }
  15883. return nil, false
  15884. }
  15885. // AddField adds the value to the field with the given name. It returns an error if
  15886. // the field is not defined in the schema, or if the type mismatched the field
  15887. // type.
  15888. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  15889. switch name {
  15890. case tutorial.FieldIndex:
  15891. v, ok := value.(int)
  15892. if !ok {
  15893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15894. }
  15895. m.AddIndex(v)
  15896. return nil
  15897. case tutorial.FieldOrganizationID:
  15898. v, ok := value.(int64)
  15899. if !ok {
  15900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15901. }
  15902. m.AddOrganizationID(v)
  15903. return nil
  15904. }
  15905. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  15906. }
  15907. // ClearedFields returns all nullable fields that were cleared during this
  15908. // mutation.
  15909. func (m *TutorialMutation) ClearedFields() []string {
  15910. var fields []string
  15911. if m.FieldCleared(tutorial.FieldDeletedAt) {
  15912. fields = append(fields, tutorial.FieldDeletedAt)
  15913. }
  15914. return fields
  15915. }
  15916. // FieldCleared returns a boolean indicating if a field with the given name was
  15917. // cleared in this mutation.
  15918. func (m *TutorialMutation) FieldCleared(name string) bool {
  15919. _, ok := m.clearedFields[name]
  15920. return ok
  15921. }
  15922. // ClearField clears the value of the field with the given name. It returns an
  15923. // error if the field is not defined in the schema.
  15924. func (m *TutorialMutation) ClearField(name string) error {
  15925. switch name {
  15926. case tutorial.FieldDeletedAt:
  15927. m.ClearDeletedAt()
  15928. return nil
  15929. }
  15930. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  15931. }
  15932. // ResetField resets all changes in the mutation for the field with the given name.
  15933. // It returns an error if the field is not defined in the schema.
  15934. func (m *TutorialMutation) ResetField(name string) error {
  15935. switch name {
  15936. case tutorial.FieldCreatedAt:
  15937. m.ResetCreatedAt()
  15938. return nil
  15939. case tutorial.FieldUpdatedAt:
  15940. m.ResetUpdatedAt()
  15941. return nil
  15942. case tutorial.FieldDeletedAt:
  15943. m.ResetDeletedAt()
  15944. return nil
  15945. case tutorial.FieldEmployeeID:
  15946. m.ResetEmployeeID()
  15947. return nil
  15948. case tutorial.FieldIndex:
  15949. m.ResetIndex()
  15950. return nil
  15951. case tutorial.FieldTitle:
  15952. m.ResetTitle()
  15953. return nil
  15954. case tutorial.FieldContent:
  15955. m.ResetContent()
  15956. return nil
  15957. case tutorial.FieldOrganizationID:
  15958. m.ResetOrganizationID()
  15959. return nil
  15960. }
  15961. return fmt.Errorf("unknown Tutorial field %s", name)
  15962. }
  15963. // AddedEdges returns all edge names that were set/added in this mutation.
  15964. func (m *TutorialMutation) AddedEdges() []string {
  15965. edges := make([]string, 0, 1)
  15966. if m.employee != nil {
  15967. edges = append(edges, tutorial.EdgeEmployee)
  15968. }
  15969. return edges
  15970. }
  15971. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15972. // name in this mutation.
  15973. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  15974. switch name {
  15975. case tutorial.EdgeEmployee:
  15976. if id := m.employee; id != nil {
  15977. return []ent.Value{*id}
  15978. }
  15979. }
  15980. return nil
  15981. }
  15982. // RemovedEdges returns all edge names that were removed in this mutation.
  15983. func (m *TutorialMutation) RemovedEdges() []string {
  15984. edges := make([]string, 0, 1)
  15985. return edges
  15986. }
  15987. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15988. // the given name in this mutation.
  15989. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  15990. return nil
  15991. }
  15992. // ClearedEdges returns all edge names that were cleared in this mutation.
  15993. func (m *TutorialMutation) ClearedEdges() []string {
  15994. edges := make([]string, 0, 1)
  15995. if m.clearedemployee {
  15996. edges = append(edges, tutorial.EdgeEmployee)
  15997. }
  15998. return edges
  15999. }
  16000. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16001. // was cleared in this mutation.
  16002. func (m *TutorialMutation) EdgeCleared(name string) bool {
  16003. switch name {
  16004. case tutorial.EdgeEmployee:
  16005. return m.clearedemployee
  16006. }
  16007. return false
  16008. }
  16009. // ClearEdge clears the value of the edge with the given name. It returns an error
  16010. // if that edge is not defined in the schema.
  16011. func (m *TutorialMutation) ClearEdge(name string) error {
  16012. switch name {
  16013. case tutorial.EdgeEmployee:
  16014. m.ClearEmployee()
  16015. return nil
  16016. }
  16017. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  16018. }
  16019. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16020. // It returns an error if the edge is not defined in the schema.
  16021. func (m *TutorialMutation) ResetEdge(name string) error {
  16022. switch name {
  16023. case tutorial.EdgeEmployee:
  16024. m.ResetEmployee()
  16025. return nil
  16026. }
  16027. return fmt.Errorf("unknown Tutorial edge %s", name)
  16028. }
  16029. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  16030. type WorkExperienceMutation struct {
  16031. config
  16032. op Op
  16033. typ string
  16034. id *uint64
  16035. created_at *time.Time
  16036. updated_at *time.Time
  16037. deleted_at *time.Time
  16038. start_date *time.Time
  16039. end_date *time.Time
  16040. company *string
  16041. experience *string
  16042. organization_id *uint64
  16043. addorganization_id *int64
  16044. clearedFields map[string]struct{}
  16045. employee *uint64
  16046. clearedemployee bool
  16047. done bool
  16048. oldValue func(context.Context) (*WorkExperience, error)
  16049. predicates []predicate.WorkExperience
  16050. }
  16051. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  16052. // workexperienceOption allows management of the mutation configuration using functional options.
  16053. type workexperienceOption func(*WorkExperienceMutation)
  16054. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  16055. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  16056. m := &WorkExperienceMutation{
  16057. config: c,
  16058. op: op,
  16059. typ: TypeWorkExperience,
  16060. clearedFields: make(map[string]struct{}),
  16061. }
  16062. for _, opt := range opts {
  16063. opt(m)
  16064. }
  16065. return m
  16066. }
  16067. // withWorkExperienceID sets the ID field of the mutation.
  16068. func withWorkExperienceID(id uint64) workexperienceOption {
  16069. return func(m *WorkExperienceMutation) {
  16070. var (
  16071. err error
  16072. once sync.Once
  16073. value *WorkExperience
  16074. )
  16075. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  16076. once.Do(func() {
  16077. if m.done {
  16078. err = errors.New("querying old values post mutation is not allowed")
  16079. } else {
  16080. value, err = m.Client().WorkExperience.Get(ctx, id)
  16081. }
  16082. })
  16083. return value, err
  16084. }
  16085. m.id = &id
  16086. }
  16087. }
  16088. // withWorkExperience sets the old WorkExperience of the mutation.
  16089. func withWorkExperience(node *WorkExperience) workexperienceOption {
  16090. return func(m *WorkExperienceMutation) {
  16091. m.oldValue = func(context.Context) (*WorkExperience, error) {
  16092. return node, nil
  16093. }
  16094. m.id = &node.ID
  16095. }
  16096. }
  16097. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16098. // executed in a transaction (ent.Tx), a transactional client is returned.
  16099. func (m WorkExperienceMutation) Client() *Client {
  16100. client := &Client{config: m.config}
  16101. client.init()
  16102. return client
  16103. }
  16104. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16105. // it returns an error otherwise.
  16106. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  16107. if _, ok := m.driver.(*txDriver); !ok {
  16108. return nil, errors.New("ent: mutation is not running in a transaction")
  16109. }
  16110. tx := &Tx{config: m.config}
  16111. tx.init()
  16112. return tx, nil
  16113. }
  16114. // SetID sets the value of the id field. Note that this
  16115. // operation is only accepted on creation of WorkExperience entities.
  16116. func (m *WorkExperienceMutation) SetID(id uint64) {
  16117. m.id = &id
  16118. }
  16119. // ID returns the ID value in the mutation. Note that the ID is only available
  16120. // if it was provided to the builder or after it was returned from the database.
  16121. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  16122. if m.id == nil {
  16123. return
  16124. }
  16125. return *m.id, true
  16126. }
  16127. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16128. // That means, if the mutation is applied within a transaction with an isolation level such
  16129. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16130. // or updated by the mutation.
  16131. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  16132. switch {
  16133. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16134. id, exists := m.ID()
  16135. if exists {
  16136. return []uint64{id}, nil
  16137. }
  16138. fallthrough
  16139. case m.op.Is(OpUpdate | OpDelete):
  16140. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  16141. default:
  16142. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16143. }
  16144. }
  16145. // SetCreatedAt sets the "created_at" field.
  16146. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  16147. m.created_at = &t
  16148. }
  16149. // CreatedAt returns the value of the "created_at" field in the mutation.
  16150. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  16151. v := m.created_at
  16152. if v == nil {
  16153. return
  16154. }
  16155. return *v, true
  16156. }
  16157. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  16158. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16160. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16161. if !m.op.Is(OpUpdateOne) {
  16162. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16163. }
  16164. if m.id == nil || m.oldValue == nil {
  16165. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16166. }
  16167. oldValue, err := m.oldValue(ctx)
  16168. if err != nil {
  16169. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16170. }
  16171. return oldValue.CreatedAt, nil
  16172. }
  16173. // ResetCreatedAt resets all changes to the "created_at" field.
  16174. func (m *WorkExperienceMutation) ResetCreatedAt() {
  16175. m.created_at = nil
  16176. }
  16177. // SetUpdatedAt sets the "updated_at" field.
  16178. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  16179. m.updated_at = &t
  16180. }
  16181. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16182. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  16183. v := m.updated_at
  16184. if v == nil {
  16185. return
  16186. }
  16187. return *v, true
  16188. }
  16189. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  16190. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16192. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16193. if !m.op.Is(OpUpdateOne) {
  16194. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16195. }
  16196. if m.id == nil || m.oldValue == nil {
  16197. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16198. }
  16199. oldValue, err := m.oldValue(ctx)
  16200. if err != nil {
  16201. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16202. }
  16203. return oldValue.UpdatedAt, nil
  16204. }
  16205. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16206. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  16207. m.updated_at = nil
  16208. }
  16209. // SetDeletedAt sets the "deleted_at" field.
  16210. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  16211. m.deleted_at = &t
  16212. }
  16213. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16214. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  16215. v := m.deleted_at
  16216. if v == nil {
  16217. return
  16218. }
  16219. return *v, true
  16220. }
  16221. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  16222. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16224. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16225. if !m.op.Is(OpUpdateOne) {
  16226. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16227. }
  16228. if m.id == nil || m.oldValue == nil {
  16229. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16230. }
  16231. oldValue, err := m.oldValue(ctx)
  16232. if err != nil {
  16233. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16234. }
  16235. return oldValue.DeletedAt, nil
  16236. }
  16237. // ClearDeletedAt clears the value of the "deleted_at" field.
  16238. func (m *WorkExperienceMutation) ClearDeletedAt() {
  16239. m.deleted_at = nil
  16240. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  16241. }
  16242. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16243. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  16244. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  16245. return ok
  16246. }
  16247. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16248. func (m *WorkExperienceMutation) ResetDeletedAt() {
  16249. m.deleted_at = nil
  16250. delete(m.clearedFields, workexperience.FieldDeletedAt)
  16251. }
  16252. // SetEmployeeID sets the "employee_id" field.
  16253. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  16254. m.employee = &u
  16255. }
  16256. // EmployeeID returns the value of the "employee_id" field in the mutation.
  16257. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  16258. v := m.employee
  16259. if v == nil {
  16260. return
  16261. }
  16262. return *v, true
  16263. }
  16264. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  16265. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16267. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  16268. if !m.op.Is(OpUpdateOne) {
  16269. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  16270. }
  16271. if m.id == nil || m.oldValue == nil {
  16272. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  16273. }
  16274. oldValue, err := m.oldValue(ctx)
  16275. if err != nil {
  16276. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  16277. }
  16278. return oldValue.EmployeeID, nil
  16279. }
  16280. // ResetEmployeeID resets all changes to the "employee_id" field.
  16281. func (m *WorkExperienceMutation) ResetEmployeeID() {
  16282. m.employee = nil
  16283. }
  16284. // SetStartDate sets the "start_date" field.
  16285. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  16286. m.start_date = &t
  16287. }
  16288. // StartDate returns the value of the "start_date" field in the mutation.
  16289. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  16290. v := m.start_date
  16291. if v == nil {
  16292. return
  16293. }
  16294. return *v, true
  16295. }
  16296. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  16297. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16299. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  16300. if !m.op.Is(OpUpdateOne) {
  16301. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  16302. }
  16303. if m.id == nil || m.oldValue == nil {
  16304. return v, errors.New("OldStartDate requires an ID field in the mutation")
  16305. }
  16306. oldValue, err := m.oldValue(ctx)
  16307. if err != nil {
  16308. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  16309. }
  16310. return oldValue.StartDate, nil
  16311. }
  16312. // ResetStartDate resets all changes to the "start_date" field.
  16313. func (m *WorkExperienceMutation) ResetStartDate() {
  16314. m.start_date = nil
  16315. }
  16316. // SetEndDate sets the "end_date" field.
  16317. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  16318. m.end_date = &t
  16319. }
  16320. // EndDate returns the value of the "end_date" field in the mutation.
  16321. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  16322. v := m.end_date
  16323. if v == nil {
  16324. return
  16325. }
  16326. return *v, true
  16327. }
  16328. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  16329. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16331. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  16332. if !m.op.Is(OpUpdateOne) {
  16333. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  16334. }
  16335. if m.id == nil || m.oldValue == nil {
  16336. return v, errors.New("OldEndDate requires an ID field in the mutation")
  16337. }
  16338. oldValue, err := m.oldValue(ctx)
  16339. if err != nil {
  16340. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  16341. }
  16342. return oldValue.EndDate, nil
  16343. }
  16344. // ResetEndDate resets all changes to the "end_date" field.
  16345. func (m *WorkExperienceMutation) ResetEndDate() {
  16346. m.end_date = nil
  16347. }
  16348. // SetCompany sets the "company" field.
  16349. func (m *WorkExperienceMutation) SetCompany(s string) {
  16350. m.company = &s
  16351. }
  16352. // Company returns the value of the "company" field in the mutation.
  16353. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  16354. v := m.company
  16355. if v == nil {
  16356. return
  16357. }
  16358. return *v, true
  16359. }
  16360. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  16361. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16363. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  16364. if !m.op.Is(OpUpdateOne) {
  16365. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  16366. }
  16367. if m.id == nil || m.oldValue == nil {
  16368. return v, errors.New("OldCompany requires an ID field in the mutation")
  16369. }
  16370. oldValue, err := m.oldValue(ctx)
  16371. if err != nil {
  16372. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  16373. }
  16374. return oldValue.Company, nil
  16375. }
  16376. // ResetCompany resets all changes to the "company" field.
  16377. func (m *WorkExperienceMutation) ResetCompany() {
  16378. m.company = nil
  16379. }
  16380. // SetExperience sets the "experience" field.
  16381. func (m *WorkExperienceMutation) SetExperience(s string) {
  16382. m.experience = &s
  16383. }
  16384. // Experience returns the value of the "experience" field in the mutation.
  16385. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  16386. v := m.experience
  16387. if v == nil {
  16388. return
  16389. }
  16390. return *v, true
  16391. }
  16392. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  16393. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16395. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  16396. if !m.op.Is(OpUpdateOne) {
  16397. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  16398. }
  16399. if m.id == nil || m.oldValue == nil {
  16400. return v, errors.New("OldExperience requires an ID field in the mutation")
  16401. }
  16402. oldValue, err := m.oldValue(ctx)
  16403. if err != nil {
  16404. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  16405. }
  16406. return oldValue.Experience, nil
  16407. }
  16408. // ResetExperience resets all changes to the "experience" field.
  16409. func (m *WorkExperienceMutation) ResetExperience() {
  16410. m.experience = nil
  16411. }
  16412. // SetOrganizationID sets the "organization_id" field.
  16413. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  16414. m.organization_id = &u
  16415. m.addorganization_id = nil
  16416. }
  16417. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16418. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  16419. v := m.organization_id
  16420. if v == nil {
  16421. return
  16422. }
  16423. return *v, true
  16424. }
  16425. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  16426. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16428. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16429. if !m.op.Is(OpUpdateOne) {
  16430. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16431. }
  16432. if m.id == nil || m.oldValue == nil {
  16433. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16434. }
  16435. oldValue, err := m.oldValue(ctx)
  16436. if err != nil {
  16437. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16438. }
  16439. return oldValue.OrganizationID, nil
  16440. }
  16441. // AddOrganizationID adds u to the "organization_id" field.
  16442. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  16443. if m.addorganization_id != nil {
  16444. *m.addorganization_id += u
  16445. } else {
  16446. m.addorganization_id = &u
  16447. }
  16448. }
  16449. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16450. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  16451. v := m.addorganization_id
  16452. if v == nil {
  16453. return
  16454. }
  16455. return *v, true
  16456. }
  16457. // ResetOrganizationID resets all changes to the "organization_id" field.
  16458. func (m *WorkExperienceMutation) ResetOrganizationID() {
  16459. m.organization_id = nil
  16460. m.addorganization_id = nil
  16461. }
  16462. // ClearEmployee clears the "employee" edge to the Employee entity.
  16463. func (m *WorkExperienceMutation) ClearEmployee() {
  16464. m.clearedemployee = true
  16465. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  16466. }
  16467. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  16468. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  16469. return m.clearedemployee
  16470. }
  16471. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  16472. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  16473. // EmployeeID instead. It exists only for internal usage by the builders.
  16474. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  16475. if id := m.employee; id != nil {
  16476. ids = append(ids, *id)
  16477. }
  16478. return
  16479. }
  16480. // ResetEmployee resets all changes to the "employee" edge.
  16481. func (m *WorkExperienceMutation) ResetEmployee() {
  16482. m.employee = nil
  16483. m.clearedemployee = false
  16484. }
  16485. // Where appends a list predicates to the WorkExperienceMutation builder.
  16486. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  16487. m.predicates = append(m.predicates, ps...)
  16488. }
  16489. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  16490. // users can use type-assertion to append predicates that do not depend on any generated package.
  16491. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  16492. p := make([]predicate.WorkExperience, len(ps))
  16493. for i := range ps {
  16494. p[i] = ps[i]
  16495. }
  16496. m.Where(p...)
  16497. }
  16498. // Op returns the operation name.
  16499. func (m *WorkExperienceMutation) Op() Op {
  16500. return m.op
  16501. }
  16502. // SetOp allows setting the mutation operation.
  16503. func (m *WorkExperienceMutation) SetOp(op Op) {
  16504. m.op = op
  16505. }
  16506. // Type returns the node type of this mutation (WorkExperience).
  16507. func (m *WorkExperienceMutation) Type() string {
  16508. return m.typ
  16509. }
  16510. // Fields returns all fields that were changed during this mutation. Note that in
  16511. // order to get all numeric fields that were incremented/decremented, call
  16512. // AddedFields().
  16513. func (m *WorkExperienceMutation) Fields() []string {
  16514. fields := make([]string, 0, 9)
  16515. if m.created_at != nil {
  16516. fields = append(fields, workexperience.FieldCreatedAt)
  16517. }
  16518. if m.updated_at != nil {
  16519. fields = append(fields, workexperience.FieldUpdatedAt)
  16520. }
  16521. if m.deleted_at != nil {
  16522. fields = append(fields, workexperience.FieldDeletedAt)
  16523. }
  16524. if m.employee != nil {
  16525. fields = append(fields, workexperience.FieldEmployeeID)
  16526. }
  16527. if m.start_date != nil {
  16528. fields = append(fields, workexperience.FieldStartDate)
  16529. }
  16530. if m.end_date != nil {
  16531. fields = append(fields, workexperience.FieldEndDate)
  16532. }
  16533. if m.company != nil {
  16534. fields = append(fields, workexperience.FieldCompany)
  16535. }
  16536. if m.experience != nil {
  16537. fields = append(fields, workexperience.FieldExperience)
  16538. }
  16539. if m.organization_id != nil {
  16540. fields = append(fields, workexperience.FieldOrganizationID)
  16541. }
  16542. return fields
  16543. }
  16544. // Field returns the value of a field with the given name. The second boolean
  16545. // return value indicates that this field was not set, or was not defined in the
  16546. // schema.
  16547. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  16548. switch name {
  16549. case workexperience.FieldCreatedAt:
  16550. return m.CreatedAt()
  16551. case workexperience.FieldUpdatedAt:
  16552. return m.UpdatedAt()
  16553. case workexperience.FieldDeletedAt:
  16554. return m.DeletedAt()
  16555. case workexperience.FieldEmployeeID:
  16556. return m.EmployeeID()
  16557. case workexperience.FieldStartDate:
  16558. return m.StartDate()
  16559. case workexperience.FieldEndDate:
  16560. return m.EndDate()
  16561. case workexperience.FieldCompany:
  16562. return m.Company()
  16563. case workexperience.FieldExperience:
  16564. return m.Experience()
  16565. case workexperience.FieldOrganizationID:
  16566. return m.OrganizationID()
  16567. }
  16568. return nil, false
  16569. }
  16570. // OldField returns the old value of the field from the database. An error is
  16571. // returned if the mutation operation is not UpdateOne, or the query to the
  16572. // database failed.
  16573. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16574. switch name {
  16575. case workexperience.FieldCreatedAt:
  16576. return m.OldCreatedAt(ctx)
  16577. case workexperience.FieldUpdatedAt:
  16578. return m.OldUpdatedAt(ctx)
  16579. case workexperience.FieldDeletedAt:
  16580. return m.OldDeletedAt(ctx)
  16581. case workexperience.FieldEmployeeID:
  16582. return m.OldEmployeeID(ctx)
  16583. case workexperience.FieldStartDate:
  16584. return m.OldStartDate(ctx)
  16585. case workexperience.FieldEndDate:
  16586. return m.OldEndDate(ctx)
  16587. case workexperience.FieldCompany:
  16588. return m.OldCompany(ctx)
  16589. case workexperience.FieldExperience:
  16590. return m.OldExperience(ctx)
  16591. case workexperience.FieldOrganizationID:
  16592. return m.OldOrganizationID(ctx)
  16593. }
  16594. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  16595. }
  16596. // SetField sets the value of a field with the given name. It returns an error if
  16597. // the field is not defined in the schema, or if the type mismatched the field
  16598. // type.
  16599. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  16600. switch name {
  16601. case workexperience.FieldCreatedAt:
  16602. v, ok := value.(time.Time)
  16603. if !ok {
  16604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16605. }
  16606. m.SetCreatedAt(v)
  16607. return nil
  16608. case workexperience.FieldUpdatedAt:
  16609. v, ok := value.(time.Time)
  16610. if !ok {
  16611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16612. }
  16613. m.SetUpdatedAt(v)
  16614. return nil
  16615. case workexperience.FieldDeletedAt:
  16616. v, ok := value.(time.Time)
  16617. if !ok {
  16618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16619. }
  16620. m.SetDeletedAt(v)
  16621. return nil
  16622. case workexperience.FieldEmployeeID:
  16623. v, ok := value.(uint64)
  16624. if !ok {
  16625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16626. }
  16627. m.SetEmployeeID(v)
  16628. return nil
  16629. case workexperience.FieldStartDate:
  16630. v, ok := value.(time.Time)
  16631. if !ok {
  16632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16633. }
  16634. m.SetStartDate(v)
  16635. return nil
  16636. case workexperience.FieldEndDate:
  16637. v, ok := value.(time.Time)
  16638. if !ok {
  16639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16640. }
  16641. m.SetEndDate(v)
  16642. return nil
  16643. case workexperience.FieldCompany:
  16644. v, ok := value.(string)
  16645. if !ok {
  16646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16647. }
  16648. m.SetCompany(v)
  16649. return nil
  16650. case workexperience.FieldExperience:
  16651. v, ok := value.(string)
  16652. if !ok {
  16653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16654. }
  16655. m.SetExperience(v)
  16656. return nil
  16657. case workexperience.FieldOrganizationID:
  16658. v, ok := value.(uint64)
  16659. if !ok {
  16660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16661. }
  16662. m.SetOrganizationID(v)
  16663. return nil
  16664. }
  16665. return fmt.Errorf("unknown WorkExperience field %s", name)
  16666. }
  16667. // AddedFields returns all numeric fields that were incremented/decremented during
  16668. // this mutation.
  16669. func (m *WorkExperienceMutation) AddedFields() []string {
  16670. var fields []string
  16671. if m.addorganization_id != nil {
  16672. fields = append(fields, workexperience.FieldOrganizationID)
  16673. }
  16674. return fields
  16675. }
  16676. // AddedField returns the numeric value that was incremented/decremented on a field
  16677. // with the given name. The second boolean return value indicates that this field
  16678. // was not set, or was not defined in the schema.
  16679. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  16680. switch name {
  16681. case workexperience.FieldOrganizationID:
  16682. return m.AddedOrganizationID()
  16683. }
  16684. return nil, false
  16685. }
  16686. // AddField adds the value to the field with the given name. It returns an error if
  16687. // the field is not defined in the schema, or if the type mismatched the field
  16688. // type.
  16689. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  16690. switch name {
  16691. case workexperience.FieldOrganizationID:
  16692. v, ok := value.(int64)
  16693. if !ok {
  16694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16695. }
  16696. m.AddOrganizationID(v)
  16697. return nil
  16698. }
  16699. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  16700. }
  16701. // ClearedFields returns all nullable fields that were cleared during this
  16702. // mutation.
  16703. func (m *WorkExperienceMutation) ClearedFields() []string {
  16704. var fields []string
  16705. if m.FieldCleared(workexperience.FieldDeletedAt) {
  16706. fields = append(fields, workexperience.FieldDeletedAt)
  16707. }
  16708. return fields
  16709. }
  16710. // FieldCleared returns a boolean indicating if a field with the given name was
  16711. // cleared in this mutation.
  16712. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  16713. _, ok := m.clearedFields[name]
  16714. return ok
  16715. }
  16716. // ClearField clears the value of the field with the given name. It returns an
  16717. // error if the field is not defined in the schema.
  16718. func (m *WorkExperienceMutation) ClearField(name string) error {
  16719. switch name {
  16720. case workexperience.FieldDeletedAt:
  16721. m.ClearDeletedAt()
  16722. return nil
  16723. }
  16724. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  16725. }
  16726. // ResetField resets all changes in the mutation for the field with the given name.
  16727. // It returns an error if the field is not defined in the schema.
  16728. func (m *WorkExperienceMutation) ResetField(name string) error {
  16729. switch name {
  16730. case workexperience.FieldCreatedAt:
  16731. m.ResetCreatedAt()
  16732. return nil
  16733. case workexperience.FieldUpdatedAt:
  16734. m.ResetUpdatedAt()
  16735. return nil
  16736. case workexperience.FieldDeletedAt:
  16737. m.ResetDeletedAt()
  16738. return nil
  16739. case workexperience.FieldEmployeeID:
  16740. m.ResetEmployeeID()
  16741. return nil
  16742. case workexperience.FieldStartDate:
  16743. m.ResetStartDate()
  16744. return nil
  16745. case workexperience.FieldEndDate:
  16746. m.ResetEndDate()
  16747. return nil
  16748. case workexperience.FieldCompany:
  16749. m.ResetCompany()
  16750. return nil
  16751. case workexperience.FieldExperience:
  16752. m.ResetExperience()
  16753. return nil
  16754. case workexperience.FieldOrganizationID:
  16755. m.ResetOrganizationID()
  16756. return nil
  16757. }
  16758. return fmt.Errorf("unknown WorkExperience field %s", name)
  16759. }
  16760. // AddedEdges returns all edge names that were set/added in this mutation.
  16761. func (m *WorkExperienceMutation) AddedEdges() []string {
  16762. edges := make([]string, 0, 1)
  16763. if m.employee != nil {
  16764. edges = append(edges, workexperience.EdgeEmployee)
  16765. }
  16766. return edges
  16767. }
  16768. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16769. // name in this mutation.
  16770. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  16771. switch name {
  16772. case workexperience.EdgeEmployee:
  16773. if id := m.employee; id != nil {
  16774. return []ent.Value{*id}
  16775. }
  16776. }
  16777. return nil
  16778. }
  16779. // RemovedEdges returns all edge names that were removed in this mutation.
  16780. func (m *WorkExperienceMutation) RemovedEdges() []string {
  16781. edges := make([]string, 0, 1)
  16782. return edges
  16783. }
  16784. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16785. // the given name in this mutation.
  16786. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  16787. return nil
  16788. }
  16789. // ClearedEdges returns all edge names that were cleared in this mutation.
  16790. func (m *WorkExperienceMutation) ClearedEdges() []string {
  16791. edges := make([]string, 0, 1)
  16792. if m.clearedemployee {
  16793. edges = append(edges, workexperience.EdgeEmployee)
  16794. }
  16795. return edges
  16796. }
  16797. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16798. // was cleared in this mutation.
  16799. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  16800. switch name {
  16801. case workexperience.EdgeEmployee:
  16802. return m.clearedemployee
  16803. }
  16804. return false
  16805. }
  16806. // ClearEdge clears the value of the edge with the given name. It returns an error
  16807. // if that edge is not defined in the schema.
  16808. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  16809. switch name {
  16810. case workexperience.EdgeEmployee:
  16811. m.ClearEmployee()
  16812. return nil
  16813. }
  16814. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  16815. }
  16816. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16817. // It returns an error if the edge is not defined in the schema.
  16818. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  16819. switch name {
  16820. case workexperience.EdgeEmployee:
  16821. m.ResetEmployee()
  16822. return nil
  16823. }
  16824. return fmt.Errorf("unknown WorkExperience edge %s", name)
  16825. }
  16826. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  16827. type WxMutation struct {
  16828. config
  16829. op Op
  16830. typ string
  16831. id *uint64
  16832. created_at *time.Time
  16833. updated_at *time.Time
  16834. status *uint8
  16835. addstatus *int8
  16836. deleted_at *time.Time
  16837. port *string
  16838. process_id *string
  16839. callback *string
  16840. wxid *string
  16841. account *string
  16842. nickname *string
  16843. tel *string
  16844. head_big *string
  16845. organization_id *uint64
  16846. addorganization_id *int64
  16847. clearedFields map[string]struct{}
  16848. server *uint64
  16849. clearedserver bool
  16850. agent *uint64
  16851. clearedagent bool
  16852. done bool
  16853. oldValue func(context.Context) (*Wx, error)
  16854. predicates []predicate.Wx
  16855. }
  16856. var _ ent.Mutation = (*WxMutation)(nil)
  16857. // wxOption allows management of the mutation configuration using functional options.
  16858. type wxOption func(*WxMutation)
  16859. // newWxMutation creates new mutation for the Wx entity.
  16860. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  16861. m := &WxMutation{
  16862. config: c,
  16863. op: op,
  16864. typ: TypeWx,
  16865. clearedFields: make(map[string]struct{}),
  16866. }
  16867. for _, opt := range opts {
  16868. opt(m)
  16869. }
  16870. return m
  16871. }
  16872. // withWxID sets the ID field of the mutation.
  16873. func withWxID(id uint64) wxOption {
  16874. return func(m *WxMutation) {
  16875. var (
  16876. err error
  16877. once sync.Once
  16878. value *Wx
  16879. )
  16880. m.oldValue = func(ctx context.Context) (*Wx, error) {
  16881. once.Do(func() {
  16882. if m.done {
  16883. err = errors.New("querying old values post mutation is not allowed")
  16884. } else {
  16885. value, err = m.Client().Wx.Get(ctx, id)
  16886. }
  16887. })
  16888. return value, err
  16889. }
  16890. m.id = &id
  16891. }
  16892. }
  16893. // withWx sets the old Wx of the mutation.
  16894. func withWx(node *Wx) wxOption {
  16895. return func(m *WxMutation) {
  16896. m.oldValue = func(context.Context) (*Wx, error) {
  16897. return node, nil
  16898. }
  16899. m.id = &node.ID
  16900. }
  16901. }
  16902. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16903. // executed in a transaction (ent.Tx), a transactional client is returned.
  16904. func (m WxMutation) Client() *Client {
  16905. client := &Client{config: m.config}
  16906. client.init()
  16907. return client
  16908. }
  16909. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16910. // it returns an error otherwise.
  16911. func (m WxMutation) Tx() (*Tx, error) {
  16912. if _, ok := m.driver.(*txDriver); !ok {
  16913. return nil, errors.New("ent: mutation is not running in a transaction")
  16914. }
  16915. tx := &Tx{config: m.config}
  16916. tx.init()
  16917. return tx, nil
  16918. }
  16919. // SetID sets the value of the id field. Note that this
  16920. // operation is only accepted on creation of Wx entities.
  16921. func (m *WxMutation) SetID(id uint64) {
  16922. m.id = &id
  16923. }
  16924. // ID returns the ID value in the mutation. Note that the ID is only available
  16925. // if it was provided to the builder or after it was returned from the database.
  16926. func (m *WxMutation) ID() (id uint64, exists bool) {
  16927. if m.id == nil {
  16928. return
  16929. }
  16930. return *m.id, true
  16931. }
  16932. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16933. // That means, if the mutation is applied within a transaction with an isolation level such
  16934. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16935. // or updated by the mutation.
  16936. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  16937. switch {
  16938. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16939. id, exists := m.ID()
  16940. if exists {
  16941. return []uint64{id}, nil
  16942. }
  16943. fallthrough
  16944. case m.op.Is(OpUpdate | OpDelete):
  16945. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  16946. default:
  16947. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16948. }
  16949. }
  16950. // SetCreatedAt sets the "created_at" field.
  16951. func (m *WxMutation) SetCreatedAt(t time.Time) {
  16952. m.created_at = &t
  16953. }
  16954. // CreatedAt returns the value of the "created_at" field in the mutation.
  16955. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  16956. v := m.created_at
  16957. if v == nil {
  16958. return
  16959. }
  16960. return *v, true
  16961. }
  16962. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  16963. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  16964. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16965. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16966. if !m.op.Is(OpUpdateOne) {
  16967. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16968. }
  16969. if m.id == nil || m.oldValue == nil {
  16970. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16971. }
  16972. oldValue, err := m.oldValue(ctx)
  16973. if err != nil {
  16974. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16975. }
  16976. return oldValue.CreatedAt, nil
  16977. }
  16978. // ResetCreatedAt resets all changes to the "created_at" field.
  16979. func (m *WxMutation) ResetCreatedAt() {
  16980. m.created_at = nil
  16981. }
  16982. // SetUpdatedAt sets the "updated_at" field.
  16983. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  16984. m.updated_at = &t
  16985. }
  16986. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16987. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  16988. v := m.updated_at
  16989. if v == nil {
  16990. return
  16991. }
  16992. return *v, true
  16993. }
  16994. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  16995. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  16996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16997. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16998. if !m.op.Is(OpUpdateOne) {
  16999. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17000. }
  17001. if m.id == nil || m.oldValue == nil {
  17002. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17003. }
  17004. oldValue, err := m.oldValue(ctx)
  17005. if err != nil {
  17006. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17007. }
  17008. return oldValue.UpdatedAt, nil
  17009. }
  17010. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17011. func (m *WxMutation) ResetUpdatedAt() {
  17012. m.updated_at = nil
  17013. }
  17014. // SetStatus sets the "status" field.
  17015. func (m *WxMutation) SetStatus(u uint8) {
  17016. m.status = &u
  17017. m.addstatus = nil
  17018. }
  17019. // Status returns the value of the "status" field in the mutation.
  17020. func (m *WxMutation) Status() (r uint8, exists bool) {
  17021. v := m.status
  17022. if v == nil {
  17023. return
  17024. }
  17025. return *v, true
  17026. }
  17027. // OldStatus returns the old "status" field's value of the Wx entity.
  17028. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17029. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17030. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17031. if !m.op.Is(OpUpdateOne) {
  17032. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17033. }
  17034. if m.id == nil || m.oldValue == nil {
  17035. return v, errors.New("OldStatus requires an ID field in the mutation")
  17036. }
  17037. oldValue, err := m.oldValue(ctx)
  17038. if err != nil {
  17039. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17040. }
  17041. return oldValue.Status, nil
  17042. }
  17043. // AddStatus adds u to the "status" field.
  17044. func (m *WxMutation) AddStatus(u int8) {
  17045. if m.addstatus != nil {
  17046. *m.addstatus += u
  17047. } else {
  17048. m.addstatus = &u
  17049. }
  17050. }
  17051. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17052. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  17053. v := m.addstatus
  17054. if v == nil {
  17055. return
  17056. }
  17057. return *v, true
  17058. }
  17059. // ClearStatus clears the value of the "status" field.
  17060. func (m *WxMutation) ClearStatus() {
  17061. m.status = nil
  17062. m.addstatus = nil
  17063. m.clearedFields[wx.FieldStatus] = struct{}{}
  17064. }
  17065. // StatusCleared returns if the "status" field was cleared in this mutation.
  17066. func (m *WxMutation) StatusCleared() bool {
  17067. _, ok := m.clearedFields[wx.FieldStatus]
  17068. return ok
  17069. }
  17070. // ResetStatus resets all changes to the "status" field.
  17071. func (m *WxMutation) ResetStatus() {
  17072. m.status = nil
  17073. m.addstatus = nil
  17074. delete(m.clearedFields, wx.FieldStatus)
  17075. }
  17076. // SetDeletedAt sets the "deleted_at" field.
  17077. func (m *WxMutation) SetDeletedAt(t time.Time) {
  17078. m.deleted_at = &t
  17079. }
  17080. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17081. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  17082. v := m.deleted_at
  17083. if v == nil {
  17084. return
  17085. }
  17086. return *v, true
  17087. }
  17088. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  17089. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17091. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17092. if !m.op.Is(OpUpdateOne) {
  17093. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17094. }
  17095. if m.id == nil || m.oldValue == nil {
  17096. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17097. }
  17098. oldValue, err := m.oldValue(ctx)
  17099. if err != nil {
  17100. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17101. }
  17102. return oldValue.DeletedAt, nil
  17103. }
  17104. // ClearDeletedAt clears the value of the "deleted_at" field.
  17105. func (m *WxMutation) ClearDeletedAt() {
  17106. m.deleted_at = nil
  17107. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  17108. }
  17109. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17110. func (m *WxMutation) DeletedAtCleared() bool {
  17111. _, ok := m.clearedFields[wx.FieldDeletedAt]
  17112. return ok
  17113. }
  17114. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17115. func (m *WxMutation) ResetDeletedAt() {
  17116. m.deleted_at = nil
  17117. delete(m.clearedFields, wx.FieldDeletedAt)
  17118. }
  17119. // SetServerID sets the "server_id" field.
  17120. func (m *WxMutation) SetServerID(u uint64) {
  17121. m.server = &u
  17122. }
  17123. // ServerID returns the value of the "server_id" field in the mutation.
  17124. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  17125. v := m.server
  17126. if v == nil {
  17127. return
  17128. }
  17129. return *v, true
  17130. }
  17131. // OldServerID returns the old "server_id" field's value of the Wx entity.
  17132. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17134. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  17135. if !m.op.Is(OpUpdateOne) {
  17136. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  17137. }
  17138. if m.id == nil || m.oldValue == nil {
  17139. return v, errors.New("OldServerID requires an ID field in the mutation")
  17140. }
  17141. oldValue, err := m.oldValue(ctx)
  17142. if err != nil {
  17143. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  17144. }
  17145. return oldValue.ServerID, nil
  17146. }
  17147. // ClearServerID clears the value of the "server_id" field.
  17148. func (m *WxMutation) ClearServerID() {
  17149. m.server = nil
  17150. m.clearedFields[wx.FieldServerID] = struct{}{}
  17151. }
  17152. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  17153. func (m *WxMutation) ServerIDCleared() bool {
  17154. _, ok := m.clearedFields[wx.FieldServerID]
  17155. return ok
  17156. }
  17157. // ResetServerID resets all changes to the "server_id" field.
  17158. func (m *WxMutation) ResetServerID() {
  17159. m.server = nil
  17160. delete(m.clearedFields, wx.FieldServerID)
  17161. }
  17162. // SetPort sets the "port" field.
  17163. func (m *WxMutation) SetPort(s string) {
  17164. m.port = &s
  17165. }
  17166. // Port returns the value of the "port" field in the mutation.
  17167. func (m *WxMutation) Port() (r string, exists bool) {
  17168. v := m.port
  17169. if v == nil {
  17170. return
  17171. }
  17172. return *v, true
  17173. }
  17174. // OldPort returns the old "port" field's value of the Wx entity.
  17175. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17177. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  17178. if !m.op.Is(OpUpdateOne) {
  17179. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  17180. }
  17181. if m.id == nil || m.oldValue == nil {
  17182. return v, errors.New("OldPort requires an ID field in the mutation")
  17183. }
  17184. oldValue, err := m.oldValue(ctx)
  17185. if err != nil {
  17186. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  17187. }
  17188. return oldValue.Port, nil
  17189. }
  17190. // ResetPort resets all changes to the "port" field.
  17191. func (m *WxMutation) ResetPort() {
  17192. m.port = nil
  17193. }
  17194. // SetProcessID sets the "process_id" field.
  17195. func (m *WxMutation) SetProcessID(s string) {
  17196. m.process_id = &s
  17197. }
  17198. // ProcessID returns the value of the "process_id" field in the mutation.
  17199. func (m *WxMutation) ProcessID() (r string, exists bool) {
  17200. v := m.process_id
  17201. if v == nil {
  17202. return
  17203. }
  17204. return *v, true
  17205. }
  17206. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  17207. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17209. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  17210. if !m.op.Is(OpUpdateOne) {
  17211. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  17212. }
  17213. if m.id == nil || m.oldValue == nil {
  17214. return v, errors.New("OldProcessID requires an ID field in the mutation")
  17215. }
  17216. oldValue, err := m.oldValue(ctx)
  17217. if err != nil {
  17218. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  17219. }
  17220. return oldValue.ProcessID, nil
  17221. }
  17222. // ResetProcessID resets all changes to the "process_id" field.
  17223. func (m *WxMutation) ResetProcessID() {
  17224. m.process_id = nil
  17225. }
  17226. // SetCallback sets the "callback" field.
  17227. func (m *WxMutation) SetCallback(s string) {
  17228. m.callback = &s
  17229. }
  17230. // Callback returns the value of the "callback" field in the mutation.
  17231. func (m *WxMutation) Callback() (r string, exists bool) {
  17232. v := m.callback
  17233. if v == nil {
  17234. return
  17235. }
  17236. return *v, true
  17237. }
  17238. // OldCallback returns the old "callback" field's value of the Wx entity.
  17239. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17241. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  17242. if !m.op.Is(OpUpdateOne) {
  17243. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  17244. }
  17245. if m.id == nil || m.oldValue == nil {
  17246. return v, errors.New("OldCallback requires an ID field in the mutation")
  17247. }
  17248. oldValue, err := m.oldValue(ctx)
  17249. if err != nil {
  17250. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  17251. }
  17252. return oldValue.Callback, nil
  17253. }
  17254. // ResetCallback resets all changes to the "callback" field.
  17255. func (m *WxMutation) ResetCallback() {
  17256. m.callback = nil
  17257. }
  17258. // SetWxid sets the "wxid" field.
  17259. func (m *WxMutation) SetWxid(s string) {
  17260. m.wxid = &s
  17261. }
  17262. // Wxid returns the value of the "wxid" field in the mutation.
  17263. func (m *WxMutation) Wxid() (r string, exists bool) {
  17264. v := m.wxid
  17265. if v == nil {
  17266. return
  17267. }
  17268. return *v, true
  17269. }
  17270. // OldWxid returns the old "wxid" field's value of the Wx entity.
  17271. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17272. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17273. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  17274. if !m.op.Is(OpUpdateOne) {
  17275. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  17276. }
  17277. if m.id == nil || m.oldValue == nil {
  17278. return v, errors.New("OldWxid requires an ID field in the mutation")
  17279. }
  17280. oldValue, err := m.oldValue(ctx)
  17281. if err != nil {
  17282. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  17283. }
  17284. return oldValue.Wxid, nil
  17285. }
  17286. // ResetWxid resets all changes to the "wxid" field.
  17287. func (m *WxMutation) ResetWxid() {
  17288. m.wxid = nil
  17289. }
  17290. // SetAccount sets the "account" field.
  17291. func (m *WxMutation) SetAccount(s string) {
  17292. m.account = &s
  17293. }
  17294. // Account returns the value of the "account" field in the mutation.
  17295. func (m *WxMutation) Account() (r string, exists bool) {
  17296. v := m.account
  17297. if v == nil {
  17298. return
  17299. }
  17300. return *v, true
  17301. }
  17302. // OldAccount returns the old "account" field's value of the Wx entity.
  17303. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17305. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  17306. if !m.op.Is(OpUpdateOne) {
  17307. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  17308. }
  17309. if m.id == nil || m.oldValue == nil {
  17310. return v, errors.New("OldAccount requires an ID field in the mutation")
  17311. }
  17312. oldValue, err := m.oldValue(ctx)
  17313. if err != nil {
  17314. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  17315. }
  17316. return oldValue.Account, nil
  17317. }
  17318. // ResetAccount resets all changes to the "account" field.
  17319. func (m *WxMutation) ResetAccount() {
  17320. m.account = nil
  17321. }
  17322. // SetNickname sets the "nickname" field.
  17323. func (m *WxMutation) SetNickname(s string) {
  17324. m.nickname = &s
  17325. }
  17326. // Nickname returns the value of the "nickname" field in the mutation.
  17327. func (m *WxMutation) Nickname() (r string, exists bool) {
  17328. v := m.nickname
  17329. if v == nil {
  17330. return
  17331. }
  17332. return *v, true
  17333. }
  17334. // OldNickname returns the old "nickname" field's value of the Wx entity.
  17335. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17337. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  17338. if !m.op.Is(OpUpdateOne) {
  17339. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  17340. }
  17341. if m.id == nil || m.oldValue == nil {
  17342. return v, errors.New("OldNickname requires an ID field in the mutation")
  17343. }
  17344. oldValue, err := m.oldValue(ctx)
  17345. if err != nil {
  17346. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  17347. }
  17348. return oldValue.Nickname, nil
  17349. }
  17350. // ResetNickname resets all changes to the "nickname" field.
  17351. func (m *WxMutation) ResetNickname() {
  17352. m.nickname = nil
  17353. }
  17354. // SetTel sets the "tel" field.
  17355. func (m *WxMutation) SetTel(s string) {
  17356. m.tel = &s
  17357. }
  17358. // Tel returns the value of the "tel" field in the mutation.
  17359. func (m *WxMutation) Tel() (r string, exists bool) {
  17360. v := m.tel
  17361. if v == nil {
  17362. return
  17363. }
  17364. return *v, true
  17365. }
  17366. // OldTel returns the old "tel" field's value of the Wx entity.
  17367. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17369. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  17370. if !m.op.Is(OpUpdateOne) {
  17371. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  17372. }
  17373. if m.id == nil || m.oldValue == nil {
  17374. return v, errors.New("OldTel requires an ID field in the mutation")
  17375. }
  17376. oldValue, err := m.oldValue(ctx)
  17377. if err != nil {
  17378. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  17379. }
  17380. return oldValue.Tel, nil
  17381. }
  17382. // ResetTel resets all changes to the "tel" field.
  17383. func (m *WxMutation) ResetTel() {
  17384. m.tel = nil
  17385. }
  17386. // SetHeadBig sets the "head_big" field.
  17387. func (m *WxMutation) SetHeadBig(s string) {
  17388. m.head_big = &s
  17389. }
  17390. // HeadBig returns the value of the "head_big" field in the mutation.
  17391. func (m *WxMutation) HeadBig() (r string, exists bool) {
  17392. v := m.head_big
  17393. if v == nil {
  17394. return
  17395. }
  17396. return *v, true
  17397. }
  17398. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  17399. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17400. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17401. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  17402. if !m.op.Is(OpUpdateOne) {
  17403. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  17404. }
  17405. if m.id == nil || m.oldValue == nil {
  17406. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  17407. }
  17408. oldValue, err := m.oldValue(ctx)
  17409. if err != nil {
  17410. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  17411. }
  17412. return oldValue.HeadBig, nil
  17413. }
  17414. // ResetHeadBig resets all changes to the "head_big" field.
  17415. func (m *WxMutation) ResetHeadBig() {
  17416. m.head_big = nil
  17417. }
  17418. // SetOrganizationID sets the "organization_id" field.
  17419. func (m *WxMutation) SetOrganizationID(u uint64) {
  17420. m.organization_id = &u
  17421. m.addorganization_id = nil
  17422. }
  17423. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17424. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  17425. v := m.organization_id
  17426. if v == nil {
  17427. return
  17428. }
  17429. return *v, true
  17430. }
  17431. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  17432. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17433. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17434. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17435. if !m.op.Is(OpUpdateOne) {
  17436. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17437. }
  17438. if m.id == nil || m.oldValue == nil {
  17439. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17440. }
  17441. oldValue, err := m.oldValue(ctx)
  17442. if err != nil {
  17443. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17444. }
  17445. return oldValue.OrganizationID, nil
  17446. }
  17447. // AddOrganizationID adds u to the "organization_id" field.
  17448. func (m *WxMutation) AddOrganizationID(u int64) {
  17449. if m.addorganization_id != nil {
  17450. *m.addorganization_id += u
  17451. } else {
  17452. m.addorganization_id = &u
  17453. }
  17454. }
  17455. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17456. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  17457. v := m.addorganization_id
  17458. if v == nil {
  17459. return
  17460. }
  17461. return *v, true
  17462. }
  17463. // ClearOrganizationID clears the value of the "organization_id" field.
  17464. func (m *WxMutation) ClearOrganizationID() {
  17465. m.organization_id = nil
  17466. m.addorganization_id = nil
  17467. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  17468. }
  17469. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17470. func (m *WxMutation) OrganizationIDCleared() bool {
  17471. _, ok := m.clearedFields[wx.FieldOrganizationID]
  17472. return ok
  17473. }
  17474. // ResetOrganizationID resets all changes to the "organization_id" field.
  17475. func (m *WxMutation) ResetOrganizationID() {
  17476. m.organization_id = nil
  17477. m.addorganization_id = nil
  17478. delete(m.clearedFields, wx.FieldOrganizationID)
  17479. }
  17480. // SetAgentID sets the "agent_id" field.
  17481. func (m *WxMutation) SetAgentID(u uint64) {
  17482. m.agent = &u
  17483. }
  17484. // AgentID returns the value of the "agent_id" field in the mutation.
  17485. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  17486. v := m.agent
  17487. if v == nil {
  17488. return
  17489. }
  17490. return *v, true
  17491. }
  17492. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  17493. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17495. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  17496. if !m.op.Is(OpUpdateOne) {
  17497. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  17498. }
  17499. if m.id == nil || m.oldValue == nil {
  17500. return v, errors.New("OldAgentID requires an ID field in the mutation")
  17501. }
  17502. oldValue, err := m.oldValue(ctx)
  17503. if err != nil {
  17504. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  17505. }
  17506. return oldValue.AgentID, nil
  17507. }
  17508. // ResetAgentID resets all changes to the "agent_id" field.
  17509. func (m *WxMutation) ResetAgentID() {
  17510. m.agent = nil
  17511. }
  17512. // ClearServer clears the "server" edge to the Server entity.
  17513. func (m *WxMutation) ClearServer() {
  17514. m.clearedserver = true
  17515. m.clearedFields[wx.FieldServerID] = struct{}{}
  17516. }
  17517. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  17518. func (m *WxMutation) ServerCleared() bool {
  17519. return m.ServerIDCleared() || m.clearedserver
  17520. }
  17521. // ServerIDs returns the "server" edge IDs in the mutation.
  17522. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17523. // ServerID instead. It exists only for internal usage by the builders.
  17524. func (m *WxMutation) ServerIDs() (ids []uint64) {
  17525. if id := m.server; id != nil {
  17526. ids = append(ids, *id)
  17527. }
  17528. return
  17529. }
  17530. // ResetServer resets all changes to the "server" edge.
  17531. func (m *WxMutation) ResetServer() {
  17532. m.server = nil
  17533. m.clearedserver = false
  17534. }
  17535. // ClearAgent clears the "agent" edge to the Agent entity.
  17536. func (m *WxMutation) ClearAgent() {
  17537. m.clearedagent = true
  17538. m.clearedFields[wx.FieldAgentID] = struct{}{}
  17539. }
  17540. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  17541. func (m *WxMutation) AgentCleared() bool {
  17542. return m.clearedagent
  17543. }
  17544. // AgentIDs returns the "agent" edge IDs in the mutation.
  17545. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17546. // AgentID instead. It exists only for internal usage by the builders.
  17547. func (m *WxMutation) AgentIDs() (ids []uint64) {
  17548. if id := m.agent; id != nil {
  17549. ids = append(ids, *id)
  17550. }
  17551. return
  17552. }
  17553. // ResetAgent resets all changes to the "agent" edge.
  17554. func (m *WxMutation) ResetAgent() {
  17555. m.agent = nil
  17556. m.clearedagent = false
  17557. }
  17558. // Where appends a list predicates to the WxMutation builder.
  17559. func (m *WxMutation) Where(ps ...predicate.Wx) {
  17560. m.predicates = append(m.predicates, ps...)
  17561. }
  17562. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  17563. // users can use type-assertion to append predicates that do not depend on any generated package.
  17564. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  17565. p := make([]predicate.Wx, len(ps))
  17566. for i := range ps {
  17567. p[i] = ps[i]
  17568. }
  17569. m.Where(p...)
  17570. }
  17571. // Op returns the operation name.
  17572. func (m *WxMutation) Op() Op {
  17573. return m.op
  17574. }
  17575. // SetOp allows setting the mutation operation.
  17576. func (m *WxMutation) SetOp(op Op) {
  17577. m.op = op
  17578. }
  17579. // Type returns the node type of this mutation (Wx).
  17580. func (m *WxMutation) Type() string {
  17581. return m.typ
  17582. }
  17583. // Fields returns all fields that were changed during this mutation. Note that in
  17584. // order to get all numeric fields that were incremented/decremented, call
  17585. // AddedFields().
  17586. func (m *WxMutation) Fields() []string {
  17587. fields := make([]string, 0, 15)
  17588. if m.created_at != nil {
  17589. fields = append(fields, wx.FieldCreatedAt)
  17590. }
  17591. if m.updated_at != nil {
  17592. fields = append(fields, wx.FieldUpdatedAt)
  17593. }
  17594. if m.status != nil {
  17595. fields = append(fields, wx.FieldStatus)
  17596. }
  17597. if m.deleted_at != nil {
  17598. fields = append(fields, wx.FieldDeletedAt)
  17599. }
  17600. if m.server != nil {
  17601. fields = append(fields, wx.FieldServerID)
  17602. }
  17603. if m.port != nil {
  17604. fields = append(fields, wx.FieldPort)
  17605. }
  17606. if m.process_id != nil {
  17607. fields = append(fields, wx.FieldProcessID)
  17608. }
  17609. if m.callback != nil {
  17610. fields = append(fields, wx.FieldCallback)
  17611. }
  17612. if m.wxid != nil {
  17613. fields = append(fields, wx.FieldWxid)
  17614. }
  17615. if m.account != nil {
  17616. fields = append(fields, wx.FieldAccount)
  17617. }
  17618. if m.nickname != nil {
  17619. fields = append(fields, wx.FieldNickname)
  17620. }
  17621. if m.tel != nil {
  17622. fields = append(fields, wx.FieldTel)
  17623. }
  17624. if m.head_big != nil {
  17625. fields = append(fields, wx.FieldHeadBig)
  17626. }
  17627. if m.organization_id != nil {
  17628. fields = append(fields, wx.FieldOrganizationID)
  17629. }
  17630. if m.agent != nil {
  17631. fields = append(fields, wx.FieldAgentID)
  17632. }
  17633. return fields
  17634. }
  17635. // Field returns the value of a field with the given name. The second boolean
  17636. // return value indicates that this field was not set, or was not defined in the
  17637. // schema.
  17638. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  17639. switch name {
  17640. case wx.FieldCreatedAt:
  17641. return m.CreatedAt()
  17642. case wx.FieldUpdatedAt:
  17643. return m.UpdatedAt()
  17644. case wx.FieldStatus:
  17645. return m.Status()
  17646. case wx.FieldDeletedAt:
  17647. return m.DeletedAt()
  17648. case wx.FieldServerID:
  17649. return m.ServerID()
  17650. case wx.FieldPort:
  17651. return m.Port()
  17652. case wx.FieldProcessID:
  17653. return m.ProcessID()
  17654. case wx.FieldCallback:
  17655. return m.Callback()
  17656. case wx.FieldWxid:
  17657. return m.Wxid()
  17658. case wx.FieldAccount:
  17659. return m.Account()
  17660. case wx.FieldNickname:
  17661. return m.Nickname()
  17662. case wx.FieldTel:
  17663. return m.Tel()
  17664. case wx.FieldHeadBig:
  17665. return m.HeadBig()
  17666. case wx.FieldOrganizationID:
  17667. return m.OrganizationID()
  17668. case wx.FieldAgentID:
  17669. return m.AgentID()
  17670. }
  17671. return nil, false
  17672. }
  17673. // OldField returns the old value of the field from the database. An error is
  17674. // returned if the mutation operation is not UpdateOne, or the query to the
  17675. // database failed.
  17676. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17677. switch name {
  17678. case wx.FieldCreatedAt:
  17679. return m.OldCreatedAt(ctx)
  17680. case wx.FieldUpdatedAt:
  17681. return m.OldUpdatedAt(ctx)
  17682. case wx.FieldStatus:
  17683. return m.OldStatus(ctx)
  17684. case wx.FieldDeletedAt:
  17685. return m.OldDeletedAt(ctx)
  17686. case wx.FieldServerID:
  17687. return m.OldServerID(ctx)
  17688. case wx.FieldPort:
  17689. return m.OldPort(ctx)
  17690. case wx.FieldProcessID:
  17691. return m.OldProcessID(ctx)
  17692. case wx.FieldCallback:
  17693. return m.OldCallback(ctx)
  17694. case wx.FieldWxid:
  17695. return m.OldWxid(ctx)
  17696. case wx.FieldAccount:
  17697. return m.OldAccount(ctx)
  17698. case wx.FieldNickname:
  17699. return m.OldNickname(ctx)
  17700. case wx.FieldTel:
  17701. return m.OldTel(ctx)
  17702. case wx.FieldHeadBig:
  17703. return m.OldHeadBig(ctx)
  17704. case wx.FieldOrganizationID:
  17705. return m.OldOrganizationID(ctx)
  17706. case wx.FieldAgentID:
  17707. return m.OldAgentID(ctx)
  17708. }
  17709. return nil, fmt.Errorf("unknown Wx field %s", name)
  17710. }
  17711. // SetField sets the value of a field with the given name. It returns an error if
  17712. // the field is not defined in the schema, or if the type mismatched the field
  17713. // type.
  17714. func (m *WxMutation) SetField(name string, value ent.Value) error {
  17715. switch name {
  17716. case wx.FieldCreatedAt:
  17717. v, ok := value.(time.Time)
  17718. if !ok {
  17719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17720. }
  17721. m.SetCreatedAt(v)
  17722. return nil
  17723. case wx.FieldUpdatedAt:
  17724. v, ok := value.(time.Time)
  17725. if !ok {
  17726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17727. }
  17728. m.SetUpdatedAt(v)
  17729. return nil
  17730. case wx.FieldStatus:
  17731. v, ok := value.(uint8)
  17732. if !ok {
  17733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17734. }
  17735. m.SetStatus(v)
  17736. return nil
  17737. case wx.FieldDeletedAt:
  17738. v, ok := value.(time.Time)
  17739. if !ok {
  17740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17741. }
  17742. m.SetDeletedAt(v)
  17743. return nil
  17744. case wx.FieldServerID:
  17745. v, ok := value.(uint64)
  17746. if !ok {
  17747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17748. }
  17749. m.SetServerID(v)
  17750. return nil
  17751. case wx.FieldPort:
  17752. v, ok := value.(string)
  17753. if !ok {
  17754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17755. }
  17756. m.SetPort(v)
  17757. return nil
  17758. case wx.FieldProcessID:
  17759. v, ok := value.(string)
  17760. if !ok {
  17761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17762. }
  17763. m.SetProcessID(v)
  17764. return nil
  17765. case wx.FieldCallback:
  17766. v, ok := value.(string)
  17767. if !ok {
  17768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17769. }
  17770. m.SetCallback(v)
  17771. return nil
  17772. case wx.FieldWxid:
  17773. v, ok := value.(string)
  17774. if !ok {
  17775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17776. }
  17777. m.SetWxid(v)
  17778. return nil
  17779. case wx.FieldAccount:
  17780. v, ok := value.(string)
  17781. if !ok {
  17782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17783. }
  17784. m.SetAccount(v)
  17785. return nil
  17786. case wx.FieldNickname:
  17787. v, ok := value.(string)
  17788. if !ok {
  17789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17790. }
  17791. m.SetNickname(v)
  17792. return nil
  17793. case wx.FieldTel:
  17794. v, ok := value.(string)
  17795. if !ok {
  17796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17797. }
  17798. m.SetTel(v)
  17799. return nil
  17800. case wx.FieldHeadBig:
  17801. v, ok := value.(string)
  17802. if !ok {
  17803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17804. }
  17805. m.SetHeadBig(v)
  17806. return nil
  17807. case wx.FieldOrganizationID:
  17808. v, ok := value.(uint64)
  17809. if !ok {
  17810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17811. }
  17812. m.SetOrganizationID(v)
  17813. return nil
  17814. case wx.FieldAgentID:
  17815. v, ok := value.(uint64)
  17816. if !ok {
  17817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17818. }
  17819. m.SetAgentID(v)
  17820. return nil
  17821. }
  17822. return fmt.Errorf("unknown Wx field %s", name)
  17823. }
  17824. // AddedFields returns all numeric fields that were incremented/decremented during
  17825. // this mutation.
  17826. func (m *WxMutation) AddedFields() []string {
  17827. var fields []string
  17828. if m.addstatus != nil {
  17829. fields = append(fields, wx.FieldStatus)
  17830. }
  17831. if m.addorganization_id != nil {
  17832. fields = append(fields, wx.FieldOrganizationID)
  17833. }
  17834. return fields
  17835. }
  17836. // AddedField returns the numeric value that was incremented/decremented on a field
  17837. // with the given name. The second boolean return value indicates that this field
  17838. // was not set, or was not defined in the schema.
  17839. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  17840. switch name {
  17841. case wx.FieldStatus:
  17842. return m.AddedStatus()
  17843. case wx.FieldOrganizationID:
  17844. return m.AddedOrganizationID()
  17845. }
  17846. return nil, false
  17847. }
  17848. // AddField adds the value to the field with the given name. It returns an error if
  17849. // the field is not defined in the schema, or if the type mismatched the field
  17850. // type.
  17851. func (m *WxMutation) AddField(name string, value ent.Value) error {
  17852. switch name {
  17853. case wx.FieldStatus:
  17854. v, ok := value.(int8)
  17855. if !ok {
  17856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17857. }
  17858. m.AddStatus(v)
  17859. return nil
  17860. case wx.FieldOrganizationID:
  17861. v, ok := value.(int64)
  17862. if !ok {
  17863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17864. }
  17865. m.AddOrganizationID(v)
  17866. return nil
  17867. }
  17868. return fmt.Errorf("unknown Wx numeric field %s", name)
  17869. }
  17870. // ClearedFields returns all nullable fields that were cleared during this
  17871. // mutation.
  17872. func (m *WxMutation) ClearedFields() []string {
  17873. var fields []string
  17874. if m.FieldCleared(wx.FieldStatus) {
  17875. fields = append(fields, wx.FieldStatus)
  17876. }
  17877. if m.FieldCleared(wx.FieldDeletedAt) {
  17878. fields = append(fields, wx.FieldDeletedAt)
  17879. }
  17880. if m.FieldCleared(wx.FieldServerID) {
  17881. fields = append(fields, wx.FieldServerID)
  17882. }
  17883. if m.FieldCleared(wx.FieldOrganizationID) {
  17884. fields = append(fields, wx.FieldOrganizationID)
  17885. }
  17886. return fields
  17887. }
  17888. // FieldCleared returns a boolean indicating if a field with the given name was
  17889. // cleared in this mutation.
  17890. func (m *WxMutation) FieldCleared(name string) bool {
  17891. _, ok := m.clearedFields[name]
  17892. return ok
  17893. }
  17894. // ClearField clears the value of the field with the given name. It returns an
  17895. // error if the field is not defined in the schema.
  17896. func (m *WxMutation) ClearField(name string) error {
  17897. switch name {
  17898. case wx.FieldStatus:
  17899. m.ClearStatus()
  17900. return nil
  17901. case wx.FieldDeletedAt:
  17902. m.ClearDeletedAt()
  17903. return nil
  17904. case wx.FieldServerID:
  17905. m.ClearServerID()
  17906. return nil
  17907. case wx.FieldOrganizationID:
  17908. m.ClearOrganizationID()
  17909. return nil
  17910. }
  17911. return fmt.Errorf("unknown Wx nullable field %s", name)
  17912. }
  17913. // ResetField resets all changes in the mutation for the field with the given name.
  17914. // It returns an error if the field is not defined in the schema.
  17915. func (m *WxMutation) ResetField(name string) error {
  17916. switch name {
  17917. case wx.FieldCreatedAt:
  17918. m.ResetCreatedAt()
  17919. return nil
  17920. case wx.FieldUpdatedAt:
  17921. m.ResetUpdatedAt()
  17922. return nil
  17923. case wx.FieldStatus:
  17924. m.ResetStatus()
  17925. return nil
  17926. case wx.FieldDeletedAt:
  17927. m.ResetDeletedAt()
  17928. return nil
  17929. case wx.FieldServerID:
  17930. m.ResetServerID()
  17931. return nil
  17932. case wx.FieldPort:
  17933. m.ResetPort()
  17934. return nil
  17935. case wx.FieldProcessID:
  17936. m.ResetProcessID()
  17937. return nil
  17938. case wx.FieldCallback:
  17939. m.ResetCallback()
  17940. return nil
  17941. case wx.FieldWxid:
  17942. m.ResetWxid()
  17943. return nil
  17944. case wx.FieldAccount:
  17945. m.ResetAccount()
  17946. return nil
  17947. case wx.FieldNickname:
  17948. m.ResetNickname()
  17949. return nil
  17950. case wx.FieldTel:
  17951. m.ResetTel()
  17952. return nil
  17953. case wx.FieldHeadBig:
  17954. m.ResetHeadBig()
  17955. return nil
  17956. case wx.FieldOrganizationID:
  17957. m.ResetOrganizationID()
  17958. return nil
  17959. case wx.FieldAgentID:
  17960. m.ResetAgentID()
  17961. return nil
  17962. }
  17963. return fmt.Errorf("unknown Wx field %s", name)
  17964. }
  17965. // AddedEdges returns all edge names that were set/added in this mutation.
  17966. func (m *WxMutation) AddedEdges() []string {
  17967. edges := make([]string, 0, 2)
  17968. if m.server != nil {
  17969. edges = append(edges, wx.EdgeServer)
  17970. }
  17971. if m.agent != nil {
  17972. edges = append(edges, wx.EdgeAgent)
  17973. }
  17974. return edges
  17975. }
  17976. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17977. // name in this mutation.
  17978. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  17979. switch name {
  17980. case wx.EdgeServer:
  17981. if id := m.server; id != nil {
  17982. return []ent.Value{*id}
  17983. }
  17984. case wx.EdgeAgent:
  17985. if id := m.agent; id != nil {
  17986. return []ent.Value{*id}
  17987. }
  17988. }
  17989. return nil
  17990. }
  17991. // RemovedEdges returns all edge names that were removed in this mutation.
  17992. func (m *WxMutation) RemovedEdges() []string {
  17993. edges := make([]string, 0, 2)
  17994. return edges
  17995. }
  17996. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17997. // the given name in this mutation.
  17998. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  17999. return nil
  18000. }
  18001. // ClearedEdges returns all edge names that were cleared in this mutation.
  18002. func (m *WxMutation) ClearedEdges() []string {
  18003. edges := make([]string, 0, 2)
  18004. if m.clearedserver {
  18005. edges = append(edges, wx.EdgeServer)
  18006. }
  18007. if m.clearedagent {
  18008. edges = append(edges, wx.EdgeAgent)
  18009. }
  18010. return edges
  18011. }
  18012. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18013. // was cleared in this mutation.
  18014. func (m *WxMutation) EdgeCleared(name string) bool {
  18015. switch name {
  18016. case wx.EdgeServer:
  18017. return m.clearedserver
  18018. case wx.EdgeAgent:
  18019. return m.clearedagent
  18020. }
  18021. return false
  18022. }
  18023. // ClearEdge clears the value of the edge with the given name. It returns an error
  18024. // if that edge is not defined in the schema.
  18025. func (m *WxMutation) ClearEdge(name string) error {
  18026. switch name {
  18027. case wx.EdgeServer:
  18028. m.ClearServer()
  18029. return nil
  18030. case wx.EdgeAgent:
  18031. m.ClearAgent()
  18032. return nil
  18033. }
  18034. return fmt.Errorf("unknown Wx unique edge %s", name)
  18035. }
  18036. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18037. // It returns an error if the edge is not defined in the schema.
  18038. func (m *WxMutation) ResetEdge(name string) error {
  18039. switch name {
  18040. case wx.EdgeServer:
  18041. m.ResetServer()
  18042. return nil
  18043. case wx.EdgeAgent:
  18044. m.ResetAgent()
  18045. return nil
  18046. }
  18047. return fmt.Errorf("unknown Wx edge %s", name)
  18048. }